diff --git a/Zend/tests/001.phpt b/Zend/tests/001.phpt index c7c2060dc2f6..d041d20a3b4a 100644 --- a/Zend/tests/001.phpt +++ b/Zend/tests/001.phpt @@ -4,39 +4,39 @@ func_num_args() tests getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } test3(1,2); call_user_func("test1"); try { - call_user_func("test3", 1); + call_user_func("test3", 1); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } call_user_func("test3", 1, 2); class test { - static function test1($a) { - var_dump(func_num_args()); - } + static function test1($a) { + var_dump(func_num_args()); + } } test::test1(1); diff --git a/Zend/tests/002.phpt b/Zend/tests/002.phpt index e89f71ef51ff..1311e3b5703e 100644 --- a/Zend/tests/002.phpt +++ b/Zend/tests/002.phpt @@ -4,45 +4,45 @@ func_get_arg() tests getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } test3(1,2); call_user_func("test1"); try { - call_user_func("test3", 1); + call_user_func("test3", 1); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } call_user_func("test3", 1, 2); class test { - static function test1($a) { - var_dump(func_get_arg(0)); - var_dump(func_get_arg(1)); - } + static function test1($a) { + var_dump(func_get_arg(0)); + var_dump(func_get_arg(1)); + } } test::test1(1); diff --git a/Zend/tests/003.phpt b/Zend/tests/003.phpt index b1ef79ebcb78..6680956f7e9a 100644 --- a/Zend/tests/003.phpt +++ b/Zend/tests/003.phpt @@ -4,39 +4,39 @@ func_get_args() tests getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } test3(1,2); call_user_func("test1"); try { - call_user_func("test3", 1); + call_user_func("test3", 1); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } call_user_func("test3", 1, 2); class test { - static function test1($a) { - var_dump(func_get_args()); - } + static function test1($a) { + var_dump(func_get_args()); + } } test::test1(1); diff --git a/Zend/tests/009.phpt b/Zend/tests/009.phpt index 15449df3d1fa..d6ac1be4e2cc 100644 --- a/Zend/tests/009.phpt +++ b/Zend/tests/009.phpt @@ -4,9 +4,9 @@ get_class() tests baz(); - } + $this->baz(); + } - public function baz() { - foreach ($this as $k => $v) { - printf("'%s' => '%s'\n", $k, $v); - } - print "ok\n"; - } + public function baz() { + foreach ($this as $k => $v) { + printf("'%s' => '%s'\n", $k, $v); + } + print "ok\n"; + } } $test = new foo; diff --git a/Zend/tests/034.phpt b/Zend/tests/034.phpt index 132fbf78f512..c608ef96c9b1 100644 --- a/Zend/tests/034.phpt +++ b/Zend/tests/034.phpt @@ -4,21 +4,21 @@ Testing multiples 'default:' in switch diff --git a/Zend/tests/access_modifiers_001.phpt b/Zend/tests/access_modifiers_001.phpt index f89d55bd9385..6ffb40eb6d5f 100644 --- a/Zend/tests/access_modifiers_001.phpt +++ b/Zend/tests/access_modifiers_001.phpt @@ -4,8 +4,8 @@ using multiple access modifiers (methods) test2(); - } + public function test() { + $this->test2(); + } } abstract class b extends a { } class c extends b { - public function __construct() { - $this->test(); - } + public function __construct() { + $this->test(); + } } new c; diff --git a/Zend/tests/access_modifiers_011.phpt b/Zend/tests/access_modifiers_011.phpt index 23846fc04052..ef24df6431db 100644 --- a/Zend/tests/access_modifiers_011.phpt +++ b/Zend/tests/access_modifiers_011.phpt @@ -4,25 +4,25 @@ __call() for private/protected methods $var; - } - public function __call($func, array $args = array()) - { - return call_user_func_array(array($this, $func), $args); - } + private function func1() + { + return "in func1"; + } + protected function func2() + { + return "in func2"; + } + public function __get($var) + { + return $this->$var; + } + public function __call($func, array $args = array()) + { + return call_user_func_array(array($this, $func), $args); + } } $a = new A(); diff --git a/Zend/tests/access_modifiers_012.phpt b/Zend/tests/access_modifiers_012.phpt index 86f678634b64..4d07102cf282 100644 --- a/Zend/tests/access_modifiers_012.phpt +++ b/Zend/tests/access_modifiers_012.phpt @@ -3,9 +3,9 @@ Trigger __call() in lieu of non visible methods when called via a callback. --FILE-- diff --git a/Zend/tests/add_002.phpt b/Zend/tests/add_002.phpt index de0a3e8a6317..5d862ef729df 100644 --- a/Zend/tests/add_002.phpt +++ b/Zend/tests/add_002.phpt @@ -9,9 +9,9 @@ $o = new stdclass; $o->prop = "value"; try { - var_dump($a + $o); + var_dump($a + $o); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $a + $o; diff --git a/Zend/tests/add_003.phpt b/Zend/tests/add_003.phpt index f0066ee3cd1e..b70ff022ecbf 100644 --- a/Zend/tests/add_003.phpt +++ b/Zend/tests/add_003.phpt @@ -9,9 +9,9 @@ $o = new stdclass; $o->prop = "value"; try { - var_dump($o + $a); + var_dump($o + $a); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $o + $a; diff --git a/Zend/tests/add_004.phpt b/Zend/tests/add_004.phpt index a46f70b818f3..161c4c2b3957 100644 --- a/Zend/tests/add_004.phpt +++ b/Zend/tests/add_004.phpt @@ -6,9 +6,9 @@ adding numbers to arrays $a = array(1,2,3); try { - var_dump($a + 5); + var_dump($a + 5); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $a + 5; diff --git a/Zend/tests/add_007.phpt b/Zend/tests/add_007.phpt index 3b24a1c99ca3..e490826d8f0a 100644 --- a/Zend/tests/add_007.phpt +++ b/Zend/tests/add_007.phpt @@ -8,9 +8,9 @@ $a = array(1,2,3); $s1 = "some string"; try { - var_dump($a + $s1); + var_dump($a + $s1); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $a + $s1; diff --git a/Zend/tests/anon/011.phpt b/Zend/tests/anon/011.phpt index 0d16c874e866..1435d5353e08 100644 --- a/Zend/tests/anon/011.phpt +++ b/Zend/tests/anon/011.phpt @@ -5,9 +5,9 @@ Ensure proper inheritance with get_class(anon class instance) used via class_ali class_alias(get_class(new class { protected $foo = 1; }), "AnonBase"); var_dump((new class extends AnonBase { - function getFoo() { - return $this->foo; - } + function getFoo() { + return $this->foo; + } })->getFoo()); ?> --EXPECT-- diff --git a/Zend/tests/arg_unpack/non_integer_keys.phpt b/Zend/tests/arg_unpack/non_integer_keys.phpt index 19ed61f2ee33..6b73efa416dd 100644 --- a/Zend/tests/arg_unpack/non_integer_keys.phpt +++ b/Zend/tests/arg_unpack/non_integer_keys.phpt @@ -3,17 +3,17 @@ Argument unpacking does not work with non-integer keys --FILE-- 123; - yield "2.34" => 234; + yield 1.23 => 123; + yield "2.34" => 234; } try { - foo(...gen()); + foo(...gen()); } catch (Error $ex) { - echo "Exception: " . $ex->getMessage() . "\n"; + echo "Exception: " . $ex->getMessage() . "\n"; } ?> diff --git a/Zend/tests/arg_unpack/string_keys.phpt b/Zend/tests/arg_unpack/string_keys.phpt index c2913db5b401..7b620b08304b 100644 --- a/Zend/tests/arg_unpack/string_keys.phpt +++ b/Zend/tests/arg_unpack/string_keys.phpt @@ -8,14 +8,14 @@ set_error_handler(function($errno, $errstr) { }); try { - var_dump(...[1, 2, "foo" => 3, 4]); + var_dump(...[1, 2, "foo" => 3, 4]); } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } try { - var_dump(...new ArrayIterator([1, 2, "foo" => 3, 4])); + var_dump(...new ArrayIterator([1, 2, "foo" => 3, 4])); } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } ?> diff --git a/Zend/tests/argument_restriction_001.phpt b/Zend/tests/argument_restriction_001.phpt index 2cd527f4fa97..c7deb760a063 100644 --- a/Zend/tests/argument_restriction_001.phpt +++ b/Zend/tests/argument_restriction_001.phpt @@ -3,13 +3,13 @@ Bug #55719 (Argument restriction should come with a more specific error message) --FILE-- --EXPECTF-- diff --git a/Zend/tests/argument_restriction_002.phpt b/Zend/tests/argument_restriction_002.phpt index 511e4d33320d..f80e9779ff66 100644 --- a/Zend/tests/argument_restriction_002.phpt +++ b/Zend/tests/argument_restriction_002.phpt @@ -3,13 +3,13 @@ Bug #55719 (Argument restriction should come with a more specific error message) --FILE-- --EXPECTF-- diff --git a/Zend/tests/argument_restriction_003.phpt b/Zend/tests/argument_restriction_003.phpt index fb602194bb58..7857d377aeba 100644 --- a/Zend/tests/argument_restriction_003.phpt +++ b/Zend/tests/argument_restriction_003.phpt @@ -6,13 +6,13 @@ class Foo { } Abstract Class Base { - public function test(Foo $foo, array $bar, $option = NULL, $extra = "lllllllllllllllllllllllllllllllllllllllllllllllllll") { - } + public function test(Foo $foo, array $bar, $option = NULL, $extra = "lllllllllllllllllllllllllllllllllllllllllllllllllll") { + } } class Sub extends Base { - public function test() { - } + public function test() { + } } ?> --EXPECTF-- diff --git a/Zend/tests/argument_restriction_004.phpt b/Zend/tests/argument_restriction_004.phpt index 8313d6908cd1..90736e8783e1 100644 --- a/Zend/tests/argument_restriction_004.phpt +++ b/Zend/tests/argument_restriction_004.phpt @@ -6,12 +6,12 @@ class Foo { } Abstract Class Base { - abstract public function test(Foo $foo, array $bar, $option = NULL, $extra = 16777215) ; + abstract public function test(Foo $foo, array $bar, $option = NULL, $extra = 16777215) ; } class Sub extends Base { - public function test(Foo $foo, array $bar, $option = NULL, $extra = 0xffffff ) { - } + public function test(Foo $foo, array $bar, $option = NULL, $extra = 0xffffff ) { + } } ?> --EXPECT-- diff --git a/Zend/tests/argument_restriction_005.phpt b/Zend/tests/argument_restriction_005.phpt index 712ccc878a83..0982ccde4aa8 100644 --- a/Zend/tests/argument_restriction_005.phpt +++ b/Zend/tests/argument_restriction_005.phpt @@ -3,8 +3,8 @@ Bug #55719 (Argument restriction should come with a more specific error message) --FILE-- --EXPECTF-- diff --git a/Zend/tests/argument_restriction_006.phpt b/Zend/tests/argument_restriction_006.phpt index 788670cd517d..5298c6959d13 100644 --- a/Zend/tests/argument_restriction_006.phpt +++ b/Zend/tests/argument_restriction_006.phpt @@ -3,13 +3,13 @@ Bug #60174 (Notice when array in method prototype error) --FILE-- --EXPECTF-- diff --git a/Zend/tests/array_append_COW.phpt b/Zend/tests/array_append_COW.phpt index 0e3008589b8e..b9965742bc57 100644 --- a/Zend/tests/array_append_COW.phpt +++ b/Zend/tests/array_append_COW.phpt @@ -2,12 +2,12 @@ Tests that array manipulation code is correctly dealing with copy on write and splitting on reference --FILE-- --EXPECT-- array(1) { diff --git a/Zend/tests/array_hash_zero.phpt b/Zend/tests/array_hash_zero.phpt index 337cdfd1a2a4..0939d5bf1203 100644 --- a/Zend/tests/array_hash_zero.phpt +++ b/Zend/tests/array_hash_zero.phpt @@ -4,12 +4,12 @@ Accept hashes being equal to zero 32, - "\xf7\x17\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x6b\x03\x6a\x13\x63\x17\x6b\x1d\x67" => 64, + "\x8e\x1a\x63\x0f\x61" => 32, + "\xf7\x17\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x6b\x03\x6a\x13\x63\x17\x6b\x1d\x67" => 64, ]; foreach ($hashes as $hash => $bits) { - var_dump($hashes[$hash], $bits); + var_dump($hashes[$hash], $bits); } ?> diff --git a/Zend/tests/array_unpack/basic.phpt b/Zend/tests/array_unpack/basic.phpt index 3363c487ec4e..dece3b826574 100644 --- a/Zend/tests/array_unpack/basic.phpt +++ b/Zend/tests/array_unpack/basic.phpt @@ -5,13 +5,13 @@ Basic array unpacking $array = [1, 2, 3]; function getArr() { - return [4, 5]; + return [4, 5]; } function arrGen() { - for($i = 11; $i < 15; $i++) { - yield $i; - } + for($i = 11; $i < 15; $i++) { + yield $i; + } } var_dump([...[]]); diff --git a/Zend/tests/array_unpack/classes.phpt b/Zend/tests/array_unpack/classes.phpt index 573c5f1c32d7..a459a229e306 100644 --- a/Zend/tests/array_unpack/classes.phpt +++ b/Zend/tests/array_unpack/classes.phpt @@ -4,23 +4,23 @@ Array unpacking with classes getMessage() . "\n"; + echo "Exception: " . $ex->getMessage() . "\n"; } --EXPECT-- array(5) { diff --git a/Zend/tests/array_unpack/non_integer_keys.phpt b/Zend/tests/array_unpack/non_integer_keys.phpt index 5c9310290795..0e082e71f3e0 100644 --- a/Zend/tests/array_unpack/non_integer_keys.phpt +++ b/Zend/tests/array_unpack/non_integer_keys.phpt @@ -3,14 +3,14 @@ Array unpacking does not work with non-integer keys --FILE-- 1; - yield 1.23 => 123; + yield [] => 1; + yield 1.23 => 123; } try { - [...gen()]; + [...gen()]; } catch (Error $ex) { - echo "Exception: " . $ex->getMessage() . "\n"; + echo "Exception: " . $ex->getMessage() . "\n"; } --EXPECT-- diff --git a/Zend/tests/array_unpack/string_keys.phpt b/Zend/tests/array_unpack/string_keys.phpt index 6032d7cc3f23..c06a2b4b8b13 100644 --- a/Zend/tests/array_unpack/string_keys.phpt +++ b/Zend/tests/array_unpack/string_keys.phpt @@ -4,16 +4,16 @@ array unpacking with string keys (not supported) 3, 4]; - var_dump([...$array]); + $array = [1, 2, "foo" => 3, 4]; + var_dump([...$array]); } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } try { - $iterator = new ArrayIterator([1, 2, "foo" => 3, 4]); - var_dump([...$iterator]); + $iterator = new ArrayIterator([1, 2, "foo" => 3, 4]); + var_dump([...$iterator]); } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } --EXPECT-- diff --git a/Zend/tests/array_unshift_COW.phpt b/Zend/tests/array_unshift_COW.phpt index ecc42bb0f4ec..a3110693abdf 100644 --- a/Zend/tests/array_unshift_COW.phpt +++ b/Zend/tests/array_unshift_COW.phpt @@ -2,12 +2,12 @@ Tests that array unshift code is correctly dealing with copy on write and splitting on reference --FILE-- --EXPECT-- array(1) { diff --git a/Zend/tests/assert/expect_015.phpt b/Zend/tests/assert/expect_015.phpt index 5d172649af80..9b2cabd59f8b 100644 --- a/Zend/tests/assert/expect_015.phpt +++ b/Zend/tests/assert/expect_015.phpt @@ -6,137 +6,137 @@ assert.exception=0 --FILE-- 'x', 'z'=>'c']; - @foo(); - $y = clone $x; - yield 1 => 2; - yield from $x; + global $a, $$b; + static $c, $d = 0; + unset($e); + $x = isset($a) && !empty($b) || eval($c); + $x = $a ? $b : $c; + $x = $a ?: $c; + $x = $a ?? $b; + list($a, $b, $c) = [1, 2=>'x', 'z'=>'c']; + @foo(); + $y = clone $x; + yield 1 => 2; + yield from $x; })); assert(0 && ($a = function &(array &$a, ?X $b = null) use ($c,&$d) : ?X { - abstract class A extends B implements C, D { - const X = 12; - const Y = self::X, Z = "aaa"; + abstract class A extends B implements C, D { + const X = 12; + const Y = self::X, Z = "aaa"; - public $a = 1, $b; - protected $c; - static private $d = null; + public $a = 1, $b; + protected $c; + static private $d = null; - abstract function foo(); + abstract function foo(); - static private function f1() { - for ($i = 0, $j = 100; $i < $j; $i++, --$j) { - $s[$i] = $a[$j]; - } - foreach ($a as $key => &$val) { - print "$key => $val\n"; - } - while ($s[$i]) { - $i++; - } - do { - $i--; - } while ($s[$i]); - $x = foo($a + 1, 4, ...[1,2,3]); - $x = ${$a . "_1"}(); - $x = A::foo(); - $x = ${$a . "_1"}::foo(); - $x = A::${$a . "_1"}(); - $x = $x->foo(); - $x = ${$a . "_1"}->foo(); - $x = $x->{$a . "_1"}(); - $x->a = C::C; - ${$a . "_1"}->a = ${$a . "_1"}::C; - $x->{a . "_1"} = C::C; - $x = C::$z; - $x = ${$a . "_1"}::$z; - $x = C::${$z . "_1"}; - } - } + static private function f1() { + for ($i = 0, $j = 100; $i < $j; $i++, --$j) { + $s[$i] = $a[$j]; + } + foreach ($a as $key => &$val) { + print "$key => $val\n"; + } + while ($s[$i]) { + $i++; + } + do { + $i--; + } while ($s[$i]); + $x = foo($a + 1, 4, ...[1,2,3]); + $x = ${$a . "_1"}(); + $x = A::foo(); + $x = ${$a . "_1"}::foo(); + $x = A::${$a . "_1"}(); + $x = $x->foo(); + $x = ${$a . "_1"}->foo(); + $x = $x->{$a . "_1"}(); + $x->a = C::C; + ${$a . "_1"}->a = ${$a . "_1"}::C; + $x->{a . "_1"} = C::C; + $x = C::$z; + $x = ${$a . "_1"}::$z; + $x = C::${$z . "_1"}; + } + } })); assert(0 && ($a = function &(array &$a, X $b = null, int|float $c) use ($c,&$d) : X { - final class A { - final protected function f2() { - if (!$x) { - return 0; - } - if ($x == 1) { - return 1; - } else if ($x == 2) { - return 2; - } else if ($x == 3) { - return 3; - } else { - if ($x == 9) { - return 9; - } + final class A { + final protected function f2() { + if (!$x) { + return 0; + } + if ($x == 1) { + return 1; + } else if ($x == 2) { + return 2; + } else if ($x == 3) { + return 3; + } else { + if ($x == 9) { + return 9; + } L0: do { - switch ($x) { - case 4: break; - case 5: continue; - case 6: break 2; - case 7: continue 2; - case 8: goto L0; - default: return; - } - } while (0); - } - } - } + switch ($x) { + case 4: break; + case 5: continue; + case 6: break 2; + case 7: continue 2; + case 8: goto L0; + default: return; + } + } while (0); + } + } + } })); assert(0 && ($a = function &(?array &$a, X $b = null) use ($c,&$d) : X { - class A { - use T1, T2 { - T1::foo insteadof foo; - T2::foo as bar; - baz as public; - ops as protected x; - } - use T3; - } + class A { + use T1, T2 { + T1::foo insteadof foo; + T2::foo as bar; + baz as public; + ops as protected x; + } + use T3; + } })); assert(0 && ($a = function &(array &...$a) { - declare(A=1,B=2); - try { - $i++; - } catch (MyException $e) { - echo 1; - } catch (Exception $e) { - echo 2; - } finally { - echo 3; - } + declare(A=1,B=2); + try { + $i++; + } catch (MyException $e) { + echo 1; + } catch (Exception $e) { + echo 2; + } finally { + echo 3; + } })); assert(0 && ($a = function () { - declare(C=1) { echo 1; } - $x = '\'"`$a'; - $x = "'\"`$a"; - $x = `'"\`$a`; - $x = "{$a}b"; - $x = "${a}b"; - $x = " {$foo->bar} ${$foo->bar} "; - $x = " ${'---'} "; - foo(); - \foo(); - namespace\foo(); - $x = foo; - $x = \foo; - $x = namespace\foo; - $x = new foo(); - $x = new \foo(); - $x = new namespace\foo(); + declare(C=1) { echo 1; } + $x = '\'"`$a'; + $x = "'\"`$a"; + $x = `'"\`$a`; + $x = "{$a}b"; + $x = "${a}b"; + $x = " {$foo->bar} ${$foo->bar} "; + $x = " ${'---'} "; + foo(); + \foo(); + namespace\foo(); + $x = foo; + $x = \foo; + $x = namespace\foo; + $x = new foo(); + $x = new \foo(); + $x = new namespace\foo(); if ($a) { } elseif ($b) { } diff --git a/Zend/tests/assert/expect_020.phpt b/Zend/tests/assert/expect_020.phpt index ef8fd5ec1255..91b303a42fcc 100644 --- a/Zend/tests/assert/expect_020.phpt +++ b/Zend/tests/assert/expect_020.phpt @@ -6,8 +6,8 @@ assert.exception=0 --FILE-- --EXPECTF-- diff --git a/Zend/tests/assign_to_obj_002.phpt b/Zend/tests/assign_to_obj_002.phpt index 0ab2e84163ba..a911c06f36d5 100644 --- a/Zend/tests/assign_to_obj_002.phpt +++ b/Zend/tests/assign_to_obj_002.phpt @@ -4,7 +4,7 @@ Assign to $this leaks when $this not defined a = new stdClass; + $this->a = new stdClass; } catch (Error $e) { echo $e->getMessage(), "\n"; } ?> diff --git a/Zend/tests/break_error_001.phpt b/Zend/tests/break_error_001.phpt index d823f5056329..63c9cc3c8e99 100644 --- a/Zend/tests/break_error_001.phpt +++ b/Zend/tests/break_error_001.phpt @@ -3,7 +3,7 @@ --FILE-- --EXPECTF-- diff --git a/Zend/tests/break_error_002.phpt b/Zend/tests/break_error_002.phpt index e78fd7594e18..afc889d0fd07 100644 --- a/Zend/tests/break_error_002.phpt +++ b/Zend/tests/break_error_002.phpt @@ -3,7 +3,7 @@ --FILE-- --EXPECTF-- diff --git a/Zend/tests/break_error_003.phpt b/Zend/tests/break_error_003.phpt index fa782343b174..44a0e849ff2a 100644 --- a/Zend/tests/break_error_003.phpt +++ b/Zend/tests/break_error_003.phpt @@ -3,7 +3,7 @@ --FILE-- --EXPECTF-- diff --git a/Zend/tests/break_error_004.phpt b/Zend/tests/break_error_004.phpt index 1b99a99ee9d3..e82d96f72791 100644 --- a/Zend/tests/break_error_004.phpt +++ b/Zend/tests/break_error_004.phpt @@ -3,9 +3,9 @@ --FILE-- --EXPECTF-- diff --git a/Zend/tests/bug18556.phpt b/Zend/tests/bug18556.phpt index da083937c5d9..94e12097de13 100644 --- a/Zend/tests/bug18556.phpt +++ b/Zend/tests/bug18556.phpt @@ -23,8 +23,8 @@ echo "\n"; setlocale(LC_ALL, "tr_TR.utf8"); foreach(get_declared_classes() as $class) { - if(!class_exists($class)) - echo "$class No Longer Exists!\n"; + if(!class_exists($class)) + echo "$class No Longer Exists!\n"; } echo "Done.\n"; diff --git a/Zend/tests/bug20242.phpt b/Zend/tests/bug20242.phpt index 064f8235fa95..f1223a03c621 100644 --- a/Zend/tests/bug20242.phpt +++ b/Zend/tests/bug20242.phpt @@ -8,12 +8,12 @@ $t = new test; $t->show_method(); class test { - static function show_static() { - echo "static\n"; - } - function show_method() { - echo "method\n"; - } + static function show_static() { + echo "static\n"; + } + function show_method() { + echo "method\n"; + } } ?> --EXPECT-- diff --git a/Zend/tests/bug22836.phpt b/Zend/tests/bug22836.phpt index 8141f178c6bf..a9597c4bb41a 100644 --- a/Zend/tests/bug22836.phpt +++ b/Zend/tests/bug22836.phpt @@ -4,13 +4,13 @@ Bug #22836 (returning references to NULL) --EXPECT-- diff --git a/Zend/tests/bug23104.phpt b/Zend/tests/bug23104.phpt index 04df3bdeb54d..38f7d652a4a4 100644 --- a/Zend/tests/bug23104.phpt +++ b/Zend/tests/bug23104.phpt @@ -4,7 +4,7 @@ Bug #23104 (Hash position not reset for constant arrays) diff --git a/Zend/tests/bug24635.phpt b/Zend/tests/bug24635.phpt index 7235859d3ad1..7210f83743a2 100644 --- a/Zend/tests/bug24635.phpt +++ b/Zend/tests/bug24635.phpt @@ -3,21 +3,21 @@ Bug #24635 (crash on dtor calling other functions) --FILE-- page = new PageClass(); } + function __construct() { $this->page = new PageClass(); } } class PageClass { - function Display() { - $section = new SectionClass("PageClass::Display"); - } + function Display() { + $section = new SectionClass("PageClass::Display"); + } } class SectionClass { - function __construct($comment) { - $this->Comment = $comment; - } - function __destruct() { - out($this->Comment); // this line doesn't crash PHP - out("\n"); // this line - } + function __construct($comment) { + $this->Comment = $comment; + } + function __destruct() { + out($this->Comment); // this line doesn't crash PHP + out("\n"); // this line + } } function out($code) { return; } $site = new SiteClass(); diff --git a/Zend/tests/bug24773.phpt b/Zend/tests/bug24773.phpt index 411649280715..1a73b3df1b24 100644 --- a/Zend/tests/bug24773.phpt +++ b/Zend/tests/bug24773.phpt @@ -2,8 +2,8 @@ Bug #24773 (unset() of integers treated as arrays causes a crash) --FILE-- --EXPECTF-- Fatal error: Uncaught Error: Cannot use string offset as an array in %s:%d diff --git a/Zend/tests/bug26010.phpt b/Zend/tests/bug26010.phpt index 9761700bb89a..bb5789ae29e9 100644 --- a/Zend/tests/bug26010.phpt +++ b/Zend/tests/bug26010.phpt @@ -3,9 +3,9 @@ Bug #26010 (private / protected variables get exposed by get_object_vars()) --FILE-- getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/Zend/tests/bug26229.phpt b/Zend/tests/bug26229.phpt index 393b49f3d03a..ffc6995f4375 100644 --- a/Zend/tests/bug26229.phpt +++ b/Zend/tests/bug26229.phpt @@ -13,14 +13,14 @@ $obj = new array_iterator; try { - foreach ($obj as $property => $value) - { - var_dump($value); - } + foreach ($obj as $property => $value) + { + var_dump($value); + } } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug26281.phpt b/Zend/tests/bug26281.phpt index e1888a88ddac..9844d31538fd 100644 --- a/Zend/tests/bug26281.phpt +++ b/Zend/tests/bug26281.phpt @@ -2,12 +2,12 @@ Bug #26281 (switch() crash when condition is a string offset) --FILE-- --EXPECT-- no crash diff --git a/Zend/tests/bug26696.phpt b/Zend/tests/bug26696.phpt index 57ba310c1dc1..a55dcf6ee5c2 100644 --- a/Zend/tests/bug26696.phpt +++ b/Zend/tests/bug26696.phpt @@ -5,14 +5,14 @@ Bug #26696 (crash in switch() when string index is used) $str = 'asdd/?'; $len = strlen($str); for ($i = 0; $i < $len; $i++) { - switch ($str[$i]) { - case '?': - echo "?+\n"; - break; - default: - echo $str[$i].'-'; - break; - } + switch ($str[$i]) { + case '?': + echo "?+\n"; + break; + default: + echo $str[$i].'-'; + break; + } } ?> diff --git a/Zend/tests/bug26697.phpt b/Zend/tests/bug26697.phpt index 1692e388efb1..d5e3592764bc 100644 --- a/Zend/tests/bug26697.phpt +++ b/Zend/tests/bug26697.phpt @@ -4,9 +4,9 @@ Bug #26697 (calling class_exists on a nonexistent class in autoloader results in three($res->getNone()); - } - catch(Exception $e) - { - echo 'Caught: '.$e->getMessage()."\n"; - } - } + function callOne() + { + try + { + $res = new ObjectOne(); + $this->three($res->getNone()); + } + catch(Exception $e) + { + echo 'Caught: '.$e->getMessage()."\n"; + } + } - function callTwo() - { - try - { - $res = new ObjectOne(); - $this->three(1, $res->getNone()); - } - catch(Exception $e) - { - echo 'Caught: '.$e->getMessage()."\n"; - } - } + function callTwo() + { + try + { + $res = new ObjectOne(); + $this->three(1, $res->getNone()); + } + catch(Exception $e) + { + echo 'Caught: '.$e->getMessage()."\n"; + } + } - function callThree() - { - try - { - $res = new ObjectOne(); - $this->three(1, 2, $res->getNone()); - } - catch(Exception $e) - { - echo 'Caught: '.$e->getMessage()."\n"; - } - } + function callThree() + { + try + { + $res = new ObjectOne(); + $this->three(1, 2, $res->getNone()); + } + catch(Exception $e) + { + echo 'Caught: '.$e->getMessage()."\n"; + } + } } $p = new Proxy(); diff --git a/Zend/tests/bug26801.phpt b/Zend/tests/bug26801.phpt index b8cc37aa1628..34f1a693fd03 100644 --- a/Zend/tests/bug26801.phpt +++ b/Zend/tests/bug26801.phpt @@ -6,14 +6,14 @@ Bug #26801 (switch ($a{0}) crash) $a = '11'; $b = $a[0]; switch ($b) { - case '-': - break; + case '-': + break; } $a = '22'; switch ($a[0]) { - case '-': - break; + case '-': + break; } ?> diff --git a/Zend/tests/bug26802.phpt b/Zend/tests/bug26802.phpt index 11e468d088aa..52dc45b3b07a 100644 --- a/Zend/tests/bug26802.phpt +++ b/Zend/tests/bug26802.phpt @@ -5,7 +5,7 @@ Bug #26802 (Can't call static method using a variable) function global_func() { - echo __METHOD__ . "\n"; + echo __METHOD__ . "\n"; } $function = 'global_func'; @@ -13,12 +13,12 @@ $function(); class foo { - static $method = 'global_func'; + static $method = 'global_func'; - static public function foo_func() - { - echo __METHOD__ . "\n"; - } + static public function foo_func() + { + echo __METHOD__ . "\n"; + } } /* The following is a BC break with PHP 4 where it would diff --git a/Zend/tests/bug27304.phpt b/Zend/tests/bug27304.phpt index f9ca3e2ecfd1..7400a8fa1fbb 100644 --- a/Zend/tests/bug27304.phpt +++ b/Zend/tests/bug27304.phpt @@ -5,10 +5,10 @@ Bug #27304 (Static functions don't function properly) class Staticexample { - static function test() - { - var_dump(isset($this)); - } + static function test() + { + var_dump(isset($this)); + } } $b = new Staticexample(); diff --git a/Zend/tests/bug27669.phpt b/Zend/tests/bug27669.phpt index 679c7a61056a..7067c23e0d47 100644 --- a/Zend/tests/bug27669.phpt +++ b/Zend/tests/bug27669.phpt @@ -2,13 +2,13 @@ Bug #27669 (PHP 5 didn't support all possibilities for calling static methods dynamically) --FILE-- --EXPECTF-- Hello World diff --git a/Zend/tests/bug27731.phpt b/Zend/tests/bug27731.phpt index 408e4242ad5e..655fffd51582 100644 --- a/Zend/tests/bug27731.phpt +++ b/Zend/tests/bug27731.phpt @@ -2,9 +2,9 @@ Bug #27731 (error_reporing() call inside @ block does not work correctly) --FILE-- --EXPECT-- int(2) diff --git a/Zend/tests/bug27798.phpt b/Zend/tests/bug27798.phpt index 9c84731fe675..310fd97991cb 100644 --- a/Zend/tests/bug27798.phpt +++ b/Zend/tests/bug27798.phpt @@ -5,27 +5,27 @@ Bug #27798 (private / protected variables not exposed by get_object_vars() insid class Base { - public $Foo = 1; - protected $Bar = 2; - private $Baz = 3; + public $Foo = 1; + protected $Bar = 2; + private $Baz = 3; - function __construct() - { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($this)); - } + function __construct() + { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($this)); + } } class Child extends Base { - private $Baz = 4; + private $Baz = 4; - function __construct() - { - parent::__construct(); - echo __METHOD__ . "\n"; - var_dump(get_object_vars($this)); - } + function __construct() + { + parent::__construct(); + echo __METHOD__ . "\n"; + var_dump(get_object_vars($this)); + } } var_dump(get_object_vars(new Base)); diff --git a/Zend/tests/bug28444.phpt b/Zend/tests/bug28444.phpt index 245a1f2704cb..586976a6752e 100644 --- a/Zend/tests/bug28444.phpt +++ b/Zend/tests/bug28444.phpt @@ -5,39 +5,39 @@ Bug #28444 (Cannot access undefined property for object with overloaded property class ObjectOne { - public $x; + public $x; - function __construct($x) - { - $this->x = $x; - } + function __construct($x) + { + $this->x = $x; + } - function __toString() { - return "Object"; - } + function __toString() { + return "Object"; + } } class Overloaded { - public $props = array(); - public $x; + public $props = array(); + public $x; - function __construct($x) - { - $this->x = new ObjectOne($x); - } + function __construct($x) + { + $this->x = new ObjectOne($x); + } - function __get($prop) - { - echo __METHOD__ . "($prop)\n"; - return $this->props[$prop]; - } + function __get($prop) + { + echo __METHOD__ . "($prop)\n"; + return $this->props[$prop]; + } - function __set($prop, $val) - { - echo __METHOD__ . "($prop,$val)\n"; - $this->props[$prop] = $val; - } + function __set($prop, $val) + { + echo __METHOD__ . "($prop,$val)\n"; + $this->props[$prop] = $val; + } } $y = new Overloaded(2); var_dump($y->x); diff --git a/Zend/tests/bug29210.phpt b/Zend/tests/bug29210.phpt index db3a67bee6c4..e50b7c2905c4 100644 --- a/Zend/tests/bug29210.phpt +++ b/Zend/tests/bug29210.phpt @@ -4,35 +4,35 @@ Bug #29210 (Function is_callable does not support private and protected methods) test_func1(); + $this->test_func1(); } else { echo "test_func1 isn't callable from inside\n"; } if (is_callable(array($this,'test_func2'))) { - $this->test_func2(); + $this->test_func2(); } else { echo "test_func2 isn't callable from inside\n"; } if (is_callable(array('test_class','test_func3'))) { - test_class::test_func3(); + test_class::test_func3(); } else { echo "test_func3 isn't callable from inside\n"; } if (is_callable(array('test_class','test_func4'))) { - test_class::test_func4(); + test_class::test_func4(); } else { echo "test_func4 isn't callable from inside\n"; } @@ -42,22 +42,22 @@ class test_class { class foo extends test_class { function test() { if (is_callable(array($this,'test_func1'))) { - $this->test_func1(); + $this->test_func1(); } else { echo "test_func1 isn't callable from child\n"; } if (is_callable(array($this,'test_func2'))) { - $this->test_func2(); + $this->test_func2(); } else { echo "test_func2 isn't callable from child\n"; } if (is_callable(array('test_class','test_func3'))) { - test_class::test_func3(); + test_class::test_func3(); } else { echo "test_func3 isn't callable from child\n"; } if (is_callable(array('test_class','test_func4'))) { - test_class::test_func4(); + test_class::test_func4(); } else { echo "test_func4 isn't callable from child\n"; } @@ -67,12 +67,12 @@ class foo extends test_class { $object = new test_class; $object->test(); if (is_callable(array($object,'test_func1'))) { - $object->test_func1(); + $object->test_func1(); } else { echo "test_func1 isn't callable from outside\n"; } if (is_callable(array($object,'test_func2'))) { - $object->test_func2(); + $object->test_func2(); } else { echo "test_func2 isn't callable from outside\n"; } diff --git a/Zend/tests/bug29368.phpt b/Zend/tests/bug29368.phpt index 20dc59a64478..ae6139efc631 100644 --- a/Zend/tests/bug29368.phpt +++ b/Zend/tests/bug29368.phpt @@ -5,23 +5,23 @@ Bug #29368 (The destructor is called when an exception is thrown from the constr class Foo { - function __construct() - { - echo __METHOD__ . "\n"; - throw new Exception; - } - function __destruct() - { - echo __METHOD__ . "\n"; - } + function __construct() + { + echo __METHOD__ . "\n"; + throw new Exception; + } + function __destruct() + { + echo __METHOD__ . "\n"; + } } try { - $bar = new Foo; + $bar = new Foo; } catch(Exception $exc) { - echo "Caught exception!\n"; + echo "Caught exception!\n"; } unset($bar); diff --git a/Zend/tests/bug29368_2.phpt b/Zend/tests/bug29368_2.phpt index acecefcb9bbc..e13d6da88467 100644 --- a/Zend/tests/bug29368_2.phpt +++ b/Zend/tests/bug29368_2.phpt @@ -3,16 +3,16 @@ Bug #29368.2 (The destructor is called when an exception is thrown from the cons --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } echo "ok\n"; ?> diff --git a/Zend/tests/bug29368_3.phpt b/Zend/tests/bug29368_3.phpt index fafcc2a0efa8..5193a91c89ae 100644 --- a/Zend/tests/bug29368_3.phpt +++ b/Zend/tests/bug29368_3.phpt @@ -3,27 +3,27 @@ Bug #29368.3 (The destructor is called when an exception is thrown from the cons --FILE-- --EXPECT-- diff --git a/Zend/tests/bug29674.phpt b/Zend/tests/bug29674.phpt index f1706cabb775..b9cb4230fe66 100644 --- a/Zend/tests/bug29674.phpt +++ b/Zend/tests/bug29674.phpt @@ -5,18 +5,18 @@ Bug #29674 (inherited method doesn't have access to private variables of the der class BaseClass { - private $private_base = "Base"; + private $private_base = "Base"; - function printVars () - { - var_dump($this->private_base); - var_dump($this->private_child); - } + function printVars () + { + var_dump($this->private_base); + var_dump($this->private_child); + } } class ChildClass extends BaseClass { - private $private_child = "Child"; + private $private_child = "Child"; } echo "===BASE===\n"; diff --git a/Zend/tests/bug30140.phpt b/Zend/tests/bug30140.phpt index 1dfb83500f31..157e7071cc49 100644 --- a/Zend/tests/bug30140.phpt +++ b/Zend/tests/bug30140.phpt @@ -3,9 +3,9 @@ Bug #30140 (Problem with array in static properties) --FILE-- x = "x"; - throw new Exception; - } + public function __construct() { + $this->x = "x"; + throw new Exception; + } } class hariCow extends FIIFO { - public function __construct() { - try { - parent::__construct(); - } catch(Exception $e) { - } - $this->y = "y"; - try { - $this->z = new FIIFO; - } catch(Exception $e) { - } - } - - public function __toString() { - return "Rusticus in asino sedet."; - } + public function __construct() { + try { + parent::__construct(); + } catch(Exception $e) { + } + $this->y = "y"; + try { + $this->z = new FIIFO; + } catch(Exception $e) { + } + } + + public function __toString() { + return "Rusticus in asino sedet."; + } } try { - $db = new FIIFO(); + $db = new FIIFO(); } catch(Exception $e) { } var_dump($db); diff --git a/Zend/tests/bug30394.phpt b/Zend/tests/bug30394.phpt index 516bea2d2d98..895326359bbf 100644 --- a/Zend/tests/bug30394.phpt +++ b/Zend/tests/bug30394.phpt @@ -4,17 +4,17 @@ Bug #30394 (Assignment operators yield wrong result with __get/__set) _p[ $what ]; - } + public function __get( $what ) + { + return $this->_p[ $what ]; + } - public function __set( $what, $value ) - { - $this->_p[ $what ] = $value; - } + public function __set( $what, $value ) + { + $this->_p[ $what ] = $value; + } - private $_p = array(); + private $_p = array(); } $c = new Container(); diff --git a/Zend/tests/bug30407.phpt b/Zend/tests/bug30407.phpt index ad1993897d54..16cadaa78004 100644 --- a/Zend/tests/bug30407.phpt +++ b/Zend/tests/bug30407.phpt @@ -4,8 +4,8 @@ Bug #30407 (Strange behaviour of default arguments) plap($this->plop()); - } catch(Exception $e) { - } - } + function plip() { + try { + $this->plap($this->plop()); + } catch(Exception $e) { + } + } - function plap($a) { - } + function plap($a) { + } - function plop() { - throw new Exception; - } + function plop() { + throw new Exception; + } } $x = new C; diff --git a/Zend/tests/bug30725.phpt b/Zend/tests/bug30725.phpt index bbcf09dfdd9e..b2ed209bcd10 100644 --- a/Zend/tests/bug30725.phpt +++ b/Zend/tests/bug30725.phpt @@ -5,24 +5,24 @@ Bug #30725 (PHP segfaults when an exception is thrown in getIterator() within fo class Test implements IteratorAggregate { - function getIterator() - { - throw new Exception(); - } + function getIterator() + { + throw new Exception(); + } } try { - $it = new Test; - foreach($it as $v) - { - echo "Fail\n"; - } - echo "Wrong\n"; + $it = new Test; + foreach($it as $v) + { + echo "Fail\n"; + } + echo "Wrong\n"; } catch(Exception $e) { - echo "Caught\n"; + echo "Caught\n"; } ?> diff --git a/Zend/tests/bug30828.phpt b/Zend/tests/bug30828.phpt index d05dbb606dcd..4e921403b7f8 100644 --- a/Zend/tests/bug30828.phpt +++ b/Zend/tests/bug30828.phpt @@ -3,43 +3,43 @@ Bug #30828 (debug_backtrace() reports incorrect class in overridden methods) --FILE-- getMessage() . "\n"; - } + try + { + eval("\$bug = new Test$test();"); + } + catch (Exception $e) + { + echo "Caught: " . $e->getMessage() . "\n"; + } } ?> ===DONE=== diff --git a/Zend/tests/bug31177.phpt b/Zend/tests/bug31177.phpt index c44342011854..2cd3dac92071 100644 --- a/Zend/tests/bug31177.phpt +++ b/Zend/tests/bug31177.phpt @@ -4,39 +4,39 @@ Bug #31177 (Memory leak) query()); - } + public function select() { + return new DbGowRecordSet($this->query()); + } - public function select2() { - new DbGowRecordSet($this->query()); - } + public function select2() { + new DbGowRecordSet($this->query()); + } } class DbGowRecordSet { - public function __construct($resource) { - } + public function __construct($resource) { + } } $db = new DbGow; try { - $rs = $db->select(); + $rs = $db->select(); } catch(Exception $e) { - echo "ok\n"; + echo "ok\n"; } try { - $db->select2(); + $db->select2(); } catch(Exception $e) { - echo "ok\n"; + echo "ok\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug31341.phpt b/Zend/tests/bug31341.phpt index 309a54d76b2e..289e03a0baf7 100644 --- a/Zend/tests/bug31341.phpt +++ b/Zend/tests/bug31341.phpt @@ -3,18 +3,18 @@ Bug #31341 (escape on curly inconsistent) --FILE-- --EXPECT-- diff --git a/Zend/tests/bug32226.phpt b/Zend/tests/bug32226.phpt index d3432c4247fc..f56f06f107f3 100644 --- a/Zend/tests/bug32226.phpt +++ b/Zend/tests/bug32226.phpt @@ -26,7 +26,7 @@ $a = new A(); } catch(Exception $e) { - echo "Caught\n"; + echo "Caught\n"; } ?> diff --git a/Zend/tests/bug32252.phpt b/Zend/tests/bug32252.phpt index ce97384c0e82..f1388571757d 100644 --- a/Zend/tests/bug32252.phpt +++ b/Zend/tests/bug32252.phpt @@ -5,28 +5,28 @@ Bug #32252 (Segfault when offsetSet throws an Exception (only without debug)) class Test implements ArrayAccess { - function offsetExists($offset) - { - echo __METHOD__ . "($offset)\n"; - return false; - } + function offsetExists($offset) + { + echo __METHOD__ . "($offset)\n"; + return false; + } - function offsetGet($offset) - { - echo __METHOD__ . "($offset)\n"; - return null; - } + function offsetGet($offset) + { + echo __METHOD__ . "($offset)\n"; + return null; + } - function offsetSet($offset, $value) - { - echo __METHOD__ . "($offset, $value)\n"; - throw new Exception("Ooops"); - } + function offsetSet($offset, $value) + { + echo __METHOD__ . "($offset, $value)\n"; + throw new Exception("Ooops"); + } - function offsetUnset($offset) - { - echo __METHOD__ . "($offset)\n"; - } + function offsetUnset($offset) + { + echo __METHOD__ . "($offset)\n"; + } } $list = new Test(); @@ -36,7 +36,7 @@ try } catch (Exception $e) { - echo "CAUGHT\n"; + echo "CAUGHT\n"; } ?> diff --git a/Zend/tests/bug32290.phpt b/Zend/tests/bug32290.phpt index a58bcf4ce386..957bbd44a193 100644 --- a/Zend/tests/bug32290.phpt +++ b/Zend/tests/bug32290.phpt @@ -7,78 +7,78 @@ error_reporting=8191 class TestA { - public function doSomething($i) - { - echo __METHOD__ . "($i)\n"; - return --$i; - } - - public function doSomethingThis($i) - { - echo __METHOD__ . "($i)\n"; - return --$i; - } - - public function doSomethingParent($i) - { - echo __METHOD__ . "($i)\n"; - return --$i; - } - - public function doSomethingParentThis($i) - { - echo __METHOD__ . "($i)\n"; - return --$i; - } - - public static function doSomethingStatic($i) - { - echo __METHOD__ . "($i)\n"; - return --$i; - } + public function doSomething($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public function doSomethingThis($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public function doSomethingParent($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public function doSomethingParentThis($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } + + public static function doSomethingStatic($i) + { + echo __METHOD__ . "($i)\n"; + return --$i; + } } class TestB extends TestA { - public function doSomething($i) - { - echo __METHOD__ . "($i)\n"; - $i++; - if ($i >= 5) return 5; - return call_user_func_array(array("TestA", "doSomething"), array($i)); - } - - public function doSomethingThis($i) - { - echo __METHOD__ . "($i)\n"; - $i++; - if ($i >= 5) return 5; - return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i)); - } - - public function doSomethingParent($i) - { - echo __METHOD__ . "($i)\n"; - $i++; - if ($i >= 5) return 5; - return call_user_func_array(array("parent", "doSomethingParent"), array($i)); - } - - public function doSomethingParentThis($i) - { - echo __METHOD__ . "($i)\n"; - $i++; - if ($i >= 5) return 5; - return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i)); - } - - public static function doSomethingStatic($i) - { - echo __METHOD__ . "($i)\n"; - $i++; - if ($i >= 5) return 5; - return call_user_func_array(array("TestA", "doSomethingStatic"), array($i)); - } + public function doSomething($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array("TestA", "doSomething"), array($i)); + } + + public function doSomethingThis($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i)); + } + + public function doSomethingParent($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array("parent", "doSomethingParent"), array($i)); + } + + public function doSomethingParentThis($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i)); + } + + public static function doSomethingStatic($i) + { + echo __METHOD__ . "($i)\n"; + $i++; + if ($i >= 5) return 5; + return call_user_func_array(array("TestA", "doSomethingStatic"), array($i)); + } } $x = new TestB(); diff --git a/Zend/tests/bug32296.phpt b/Zend/tests/bug32296.phpt index b3e705ec14de..16914a71b433 100644 --- a/Zend/tests/bug32296.phpt +++ b/Zend/tests/bug32296.phpt @@ -3,26 +3,26 @@ Bug #32296 (get_class_methods output has changed between 5.0.2 and 5.0.3) --FILE-- test(); - } - } + if (method_exists($this, 'test')) { + $this->test(); + } + } - public function __call($name, $args) { - throw new Exception('Call to undefined method'.get_class($this).'::'.$name.'()'); - } + public function __call($name, $args) { + throw new Exception('Call to undefined method'.get_class($this).'::'.$name.'()'); + } } try { - $test = new TestClass; + $test = new TestClass; } catch (Exception $e) { exit($e->getMessage()); } diff --git a/Zend/tests/bug32660.phpt b/Zend/tests/bug32660.phpt index 8651d491f856..1a6e4d80689c 100644 --- a/Zend/tests/bug32660.phpt +++ b/Zend/tests/bug32660.phpt @@ -4,17 +4,17 @@ Bug #32660 (Assignment by reference causes crash when field access is overloaded q = 3;//array(); - } + function __construct() + { + $this->q = 3;//array(); + } - function __get($name) - { - return $this->q; - } + function __get($name) + { + return $this->q; + } } $a = new A; diff --git a/Zend/tests/bug32674.phpt b/Zend/tests/bug32674.phpt index f932517d9b7b..8f4cef4157d5 100644 --- a/Zend/tests/bug32674.phpt +++ b/Zend/tests/bug32674.phpt @@ -48,14 +48,14 @@ $obj = new class2(); $col = new collection(); try { - foreach($col as $co) { - //irrelevant - } - echo 'shouldn`t get here'; - //$dummy = 'this will not crash'; - $obj->dummy = 'this will crash'; + foreach($col as $co) { + //irrelevant + } + echo 'shouldn`t get here'; + //$dummy = 'this will not crash'; + $obj->dummy = 'this will crash'; } catch (Exception $e) { - echo "ok\n"; + echo "ok\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug32799.phpt b/Zend/tests/bug32799.phpt index c76daeddef1e..036d94711d5f 100644 --- a/Zend/tests/bug32799.phpt +++ b/Zend/tests/bug32799.phpt @@ -5,13 +5,13 @@ Bug #32799 (crash: calling the corresponding global var during the destruct) class test{ public $c=1; function __destruct (){ - if (!isset($GLOBALS['p'])) { - echo "NULL\n"; - } else { - $GLOBALS['p']->c++; // no warning - print $GLOBALS['p']->c."\n"; // segfault - var_dump($GLOBALS['p']); - } + if (!isset($GLOBALS['p'])) { + echo "NULL\n"; + } else { + $GLOBALS['p']->c++; // no warning + print $GLOBALS['p']->c."\n"; // segfault + var_dump($GLOBALS['p']); + } } } $p=new test; diff --git a/Zend/tests/bug33171.phpt b/Zend/tests/bug33171.phpt index a342e10439e3..5fb1a30f9a7e 100644 --- a/Zend/tests/bug33171.phpt +++ b/Zend/tests/bug33171.phpt @@ -4,20 +4,20 @@ Bug #33171 (foreach enumerates private fields declared in base classes) $val) - { - echo "$key => $val\n"; - } - } + public function go() + { + foreach ($this as $key => $val) + { + echo "$key => $val\n"; + } + } }; $x = new B; diff --git a/Zend/tests/bug33282.phpt b/Zend/tests/bug33282.phpt index 27f399046ebf..d75c2684a400 100644 --- a/Zend/tests/bug33282.phpt +++ b/Zend/tests/bug33282.phpt @@ -2,11 +2,11 @@ Bug #33282 (Re-assignment by reference does not clear the is_ref flag) --FILE-- --EXPECT-- array(3) { diff --git a/Zend/tests/bug33512.phpt b/Zend/tests/bug33512.phpt index 0a0e4e7b117c..dbeee22baba3 100644 --- a/Zend/tests/bug33512.phpt +++ b/Zend/tests/bug33512.phpt @@ -3,59 +3,59 @@ Bug #33512 (unset() overloaded properties doesn't work) --FILE-- Var[$var] = $val; - } - function __get($var) { - if(isset($this->Var[$var])) return $this->Var[$var]; - else return -1; - } - function __unset($var) { - unset($this->Var[$var]); - } - } + function __set($var, $val) { + $this->Var[$var] = $val; + } + function __get($var) { + if(isset($this->Var[$var])) return $this->Var[$var]; + else return -1; + } + function __unset($var) { + unset($this->Var[$var]); + } + } - $SomeObj = new TheObj; + $SomeObj = new TheObj; - // this will fine - $SomeObj->RealVar1 = 'somevalue'; - $SomeObj->{'RealVar2'} = 'othervalue'; - $SomeObj->{'RealVar'.(3)} = 'othervaluetoo'; - $SomeObj->{'RealVar'.'4'} = 'anothervalue'; + // this will fine + $SomeObj->RealVar1 = 'somevalue'; + $SomeObj->{'RealVar2'} = 'othervalue'; + $SomeObj->{'RealVar'.(3)} = 'othervaluetoo'; + $SomeObj->{'RealVar'.'4'} = 'anothervalue'; - // this will fine too - $SomeObj->Virtual1 = 'somevalue'; - $SomeObj->{'Virtual2'} = 'othervalue'; + // this will fine too + $SomeObj->Virtual1 = 'somevalue'; + $SomeObj->{'Virtual2'} = 'othervalue'; - // it's can't be used since this will encounter error - $SomeObj->{'Virtual'.(3)} = 'othervaluetoo'; - $SomeObj->{'Virtual'.'4'} = 'anothervalue'; + // it's can't be used since this will encounter error + $SomeObj->{'Virtual'.(3)} = 'othervaluetoo'; + $SomeObj->{'Virtual'.'4'} = 'anothervalue'; - // but this will fine, ofcourse - $SomeObj->Var['Virtual'.(3)] = 'othervaluetoo'; - $SomeObj->Var['Virtual'.'4'] = 'anothervalue'; + // but this will fine, ofcourse + $SomeObj->Var['Virtual'.(3)] = 'othervaluetoo'; + $SomeObj->Var['Virtual'.'4'] = 'anothervalue'; - var_dump($SomeObj->RealVar1); - print $SomeObj->{'RealVar'.(3)}."\n"; + var_dump($SomeObj->RealVar1); + print $SomeObj->{'RealVar'.(3)}."\n"; - unset($SomeObj->RealVar1); - unset($SomeObj->{'RealVar'.(3)}); + unset($SomeObj->RealVar1); + unset($SomeObj->{'RealVar'.(3)}); - //the lines below will catch by '__get' magic method since these variables are unavailable anymore - var_dump($SomeObj->RealVar1); - print $SomeObj->{'RealVar'.(3)}."\n"; + //the lines below will catch by '__get' magic method since these variables are unavailable anymore + var_dump($SomeObj->RealVar1); + print $SomeObj->{'RealVar'.(3)}."\n"; - // now we will try to unset these variables - unset($SomeObj->Virtual1); - unset($SomeObj->{'Virtual'.(3)}); + // now we will try to unset these variables + unset($SomeObj->Virtual1); + unset($SomeObj->{'Virtual'.(3)}); - //but, these variables are still available??? even though they're "unset"-ed - print $SomeObj->Virtual1."\n"; - print $SomeObj->{'Virtual'.(3)}."\n"; + //but, these variables are still available??? even though they're "unset"-ed + print $SomeObj->Virtual1."\n"; + print $SomeObj->{'Virtual'.(3)}."\n"; ?> --EXPECT-- string(9) "somevalue" diff --git a/Zend/tests/bug33710.phpt b/Zend/tests/bug33710.phpt index f65576074b57..f731c39509a8 100644 --- a/Zend/tests/bug33710.phpt +++ b/Zend/tests/bug33710.phpt @@ -5,21 +5,21 @@ Bug #33710 (ArrayAccess objects doesn't initialize $this) class Foo implements ArrayAccess { - function offsetExists($offset) {/*...*/} - function offsetGet($offset) {/*...*/} - function offsetSet($offset, $value) {/*...*/} - function offsetUnset($offset) {/*...*/} + function offsetExists($offset) {/*...*/} + function offsetGet($offset) {/*...*/} + function offsetSet($offset, $value) {/*...*/} + function offsetUnset($offset) {/*...*/} - function fail() - { - $this['blah']; - } + function fail() + { + $this['blah']; + } - function succeed() - { - $this; - $this['blah']; - } + function succeed() + { + $this; + $this['blah']; + } } $bar = new Foo(); diff --git a/Zend/tests/bug33771.phpt b/Zend/tests/bug33771.phpt index 6eea49edbe64..368a1662a8f6 100644 --- a/Zend/tests/bug33771.phpt +++ b/Zend/tests/bug33771.phpt @@ -20,13 +20,13 @@ function make_exception_and_change_err_reporting() try { - @make_exception(); + @make_exception(); } catch (Exception $e) {} var_dump(error_reporting()); try { - @make_exception_and_change_err_reporting(); + @make_exception_and_change_err_reporting(); } catch (Exception $e) {} var_dump(error_reporting()); diff --git a/Zend/tests/bug33996.phpt b/Zend/tests/bug33996.phpt index 3936eb8845b8..d5ec3386d6e9 100644 --- a/Zend/tests/bug33996.phpt +++ b/Zend/tests/bug33996.phpt @@ -20,14 +20,14 @@ function NormalTest($a) } try { - NormalTest(); + NormalTest(); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - FooTest(); + FooTest(); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } FooTest(new Foo()); ?> diff --git a/Zend/tests/bug34062.phpt b/Zend/tests/bug34062.phpt index f1c0e477a94e..456682753dd4 100644 --- a/Zend/tests/bug34062.phpt +++ b/Zend/tests/bug34062.phpt @@ -8,13 +8,13 @@ function f2() { echo "here\n"; } try { // Currently it's the minimum required number of zeros // If you remove one, it won't crash - max(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + max(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, f1()); } catch (Exception $e) { - echo "(((\n"; - f2(0, 0, 0); // Won't crash if less than 3 zeros here - echo ")))\n"; + echo "(((\n"; + f2(0, 0, 0); // Won't crash if less than 3 zeros here + echo ")))\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug34064.phpt b/Zend/tests/bug34064.phpt index 83c69028032e..3cdd70923827 100644 --- a/Zend/tests/bug34064.phpt +++ b/Zend/tests/bug34064.phpt @@ -6,7 +6,7 @@ class XmlTest { function test_ref(&$test) { - $test = "ok"; + $test = "ok"; } function test($test) diff --git a/Zend/tests/bug34310.phpt b/Zend/tests/bug34310.phpt index 1d2bb03ad3e5..2a5a36daea19 100644 --- a/Zend/tests/bug34310.phpt +++ b/Zend/tests/bug34310.phpt @@ -5,7 +5,7 @@ Bug #34310 (foreach($arr as $c->d => $x) crashes) class C { - public $d; + public $d; } $c = new C(); @@ -15,13 +15,13 @@ $arr = array (1 => 'a', 2 => 'b', 3 => 'c'); // Works fine: foreach($arr as $x => $c->d) { - echo "{$x} => {$c->d}\n"; + echo "{$x} => {$c->d}\n"; } // Crashes: foreach($arr as $c->d => $x) { - echo "{$c->d} => {$x}\n"; + echo "{$c->d} => {$x}\n"; } ?> diff --git a/Zend/tests/bug34467.phpt b/Zend/tests/bug34467.phpt index fa1d8de2cdba..e301291e3c49 100644 --- a/Zend/tests/bug34467.phpt +++ b/Zend/tests/bug34467.phpt @@ -3,19 +3,19 @@ Bug #34467 (foreach + __get + __set incosistency) --FILE-- arr[$key] = $value; } - function __get ($key) { - return $this->arr[$key]; - } + function __get ($key) { + return $this->arr[$key]; + } } $abc = new abc(); foreach (array (1,2,3) as $abc->k => $abc->v) { - var_dump($abc->k,$abc->v); + var_dump($abc->k,$abc->v); } ?> --EXPECT-- diff --git a/Zend/tests/bug34678.phpt b/Zend/tests/bug34678.phpt index 2a13201f265e..86db44357e78 100644 --- a/Zend/tests/bug34678.phpt +++ b/Zend/tests/bug34678.phpt @@ -3,22 +3,22 @@ Bug #34678 (__call(), is_callable() and static methods) --FILE-- --EXPECT-- diff --git a/Zend/tests/bug34873.phpt b/Zend/tests/bug34873.phpt index da1127645857..fd31842d59d4 100644 --- a/Zend/tests/bug34873.phpt +++ b/Zend/tests/bug34873.phpt @@ -3,19 +3,19 @@ Bug #34873 (Segmentation Fault on foreach in object) --FILE-- var = array(); - } + function __construct(){ + $this->var = array(); + } - function test (){ - $cont = array(); - $cont["mykey"] = "myvalue"; + function test (){ + $cont = array(); + $cont["mykey"] = "myvalue"; - foreach ($cont as $this->var['key'] => $this->var['value']) - var_dump($this->var['value']); - } + foreach ($cont as $this->var['key'] => $this->var['value']) + var_dump($this->var['value']); + } } $myPwa = new Pwa(); $myPwa->test(); diff --git a/Zend/tests/bug34893.phpt b/Zend/tests/bug34893.phpt index bbe02358e9e1..c821875a99a8 100644 --- a/Zend/tests/bug34893.phpt +++ b/Zend/tests/bug34893.phpt @@ -3,22 +3,22 @@ Bug #34893 (PHP5.1 overloading, Cannot access private property) --FILE-- $name; - } - function __set($name, $value) { - $this->$name = $value; - } + private $p; + function __get($name){ + return $this->$name; + } + function __set($name, $value) { + $this->$name = $value; + } } class B { - private $t; - function __get($name){ - return $this->$name; - } - function __set($name, $value) { - $this->$name = $value; - } + private $t; + function __get($name){ + return $this->$name; + } + function __set($name, $value) { + $this->$name = $value; + } } $a = new A; $b = new B; diff --git a/Zend/tests/bug35017.phpt b/Zend/tests/bug35017.phpt index 8a747be7e159..0b9e9a95e2c4 100644 --- a/Zend/tests/bug35017.phpt +++ b/Zend/tests/bug35017.phpt @@ -4,17 +4,17 @@ Bug #35017 (Exception thrown in error handler may cause unexpected behavior) --EXPECT-- diff --git a/Zend/tests/bug36006.phpt b/Zend/tests/bug36006.phpt index 79f9897d1343..f86c4b5a2965 100644 --- a/Zend/tests/bug36006.phpt +++ b/Zend/tests/bug36006.phpt @@ -4,22 +4,22 @@ Bug #36006 (Problem with $this in __destruct()) dad = null; /* no segfault if this is commented out */ - } + public $dad; + public function __destruct() { + $this->dad = null; /* no segfault if this is commented out */ + } } class Dad extends Person { - public $son; - public function __construct() { - $this->son = new Person; - $this->son->dad = $this; /* no segfault if this is commented out */ - } - public function __destruct() { - $this->son = null; - parent::__destruct(); /* segfault here */ - } + public $son; + public function __construct() { + $this->son = new Person; + $this->son->dad = $this; /* no segfault if this is commented out */ + } + public function __destruct() { + $this->son = null; + parent::__destruct(); /* segfault here */ + } } $o = new Dad; diff --git a/Zend/tests/bug36268.phpt b/Zend/tests/bug36268.phpt index 3bec61ff49fb..e95b91cc3ed5 100644 --- a/Zend/tests/bug36268.phpt +++ b/Zend/tests/bug36268.phpt @@ -3,9 +3,9 @@ Bug #36268 (Object destructors called even after fatal errors) --FILE-- bar(); + $foo = new Foo(); + $foo->bar(); } catch (Error $e) { - echo 'OK'; + echo 'OK'; } --EXPECT-- OK diff --git a/Zend/tests/bug37632.phpt b/Zend/tests/bug37632.phpt index a5a782508c25..fbfae5b25488 100644 --- a/Zend/tests/bug37632.phpt +++ b/Zend/tests/bug37632.phpt @@ -5,27 +5,27 @@ Bug #37632 (Protected method access problem) class A1 { - protected function test() - { - echo __METHOD__ . "\n"; - } + protected function test() + { + echo __METHOD__ . "\n"; + } } class B1 extends A1 { - public function doTest(A1 $obj) - { - echo __METHOD__ . "\n"; - $obj->test(); - } + public function doTest(A1 $obj) + { + echo __METHOD__ . "\n"; + $obj->test(); + } } class C1 extends A1 { - protected function test() - { - echo __METHOD__ . "\n"; - } + protected function test() + { + echo __METHOD__ . "\n"; + } } $b = new B1; @@ -33,27 +33,27 @@ $b->doTest(new C1); class A2 { - static protected function test() - { - echo __METHOD__ . "\n"; - } + static protected function test() + { + echo __METHOD__ . "\n"; + } } class B2 extends A2 { - static public function doTest(A2 $obj) - { - echo __METHOD__ . "\n"; - $obj->test(); - } + static public function doTest(A2 $obj) + { + echo __METHOD__ . "\n"; + $obj->test(); + } } class C2 extends A2 { - static protected function test() - { - echo __METHOD__ . "\n"; - } + static protected function test() + { + echo __METHOD__ . "\n"; + } } B2::doTest(new C2); @@ -64,32 +64,32 @@ B2::doTest(new C2); interface Ctor { - function __construct($x); + function __construct($x); } class A3 implements Ctor { - protected function __construct() - { - echo __METHOD__ . "\n"; - } + protected function __construct() + { + echo __METHOD__ . "\n"; + } } class B3 extends A3 { - static public function doTest() - { - echo __METHOD__ . "\n"; - new C3; - } + static public function doTest() + { + echo __METHOD__ . "\n"; + new C3; + } } class C3 extends A3 { - protected function __construct() - { - echo __METHOD__ . "\n"; - } + protected function __construct() + { + echo __METHOD__ . "\n"; + } } B3::doTest(); @@ -98,27 +98,27 @@ B3::doTest(); class A4 { - protected function __construct() - { - echo __METHOD__ . "\n"; - } + protected function __construct() + { + echo __METHOD__ . "\n"; + } } class B4 extends A4 { - static public function doTest() - { - echo __METHOD__ . "\n"; - new C4; - } + static public function doTest() + { + echo __METHOD__ . "\n"; + new C4; + } } class C4 extends A4 { - protected function __construct() - { - echo __METHOD__ . "\n"; - } + protected function __construct() + { + echo __METHOD__ . "\n"; + } } B4::doTest(); diff --git a/Zend/tests/bug37667.phpt b/Zend/tests/bug37667.phpt index 83a87a96881c..38adb4e9989b 100644 --- a/Zend/tests/bug37667.phpt +++ b/Zend/tests/bug37667.phpt @@ -5,12 +5,12 @@ Bug #37667 (Object is not added into array returned by __get) class Test { - protected $property = array('foo' => 'bar'); + protected $property = array('foo' => 'bar'); - function __get($name) - { - return $this->property; - } + function __get($name) + { + return $this->property; + } } $obj = new Test; diff --git a/Zend/tests/bug37707.phpt b/Zend/tests/bug37707.phpt index ac2dfb8777db..6781804aa51e 100644 --- a/Zend/tests/bug37707.phpt +++ b/Zend/tests/bug37707.phpt @@ -3,9 +3,9 @@ Bug #37707 (clone without assigning leaks memory) --FILE-- obj->i}\n"; - } + function func1() { + echo "func1(): {$this->obj->i}\n"; + } - function close() { - echo "close(): {$this->obj->i}\n"; - } + function close() { + echo "close(): {$this->obj->i}\n"; + } } class A { - public $i; + public $i; - function __construct($i) { - $this->i = $i; + function __construct($i) { + $this->i = $i; - } + } - function __call($method, $args) { - $drv = myserv::drv(); + function __call($method, $args) { + $drv = myserv::drv(); - $drv->obj = $this; + $drv->obj = $this; - echo "before call $method\n"; - print_r($this); - call_user_func_array(array($drv, $method), $args); - echo "after call $method\n"; + echo "before call $method\n"; + print_r($this); + call_user_func_array(array($drv, $method), $args); + echo "after call $method\n"; - // Uncomment this line to work without crash + // Uncomment this line to work without crash // $drv->obj = null; - } + } - function __destruct() { - echo "A::__destruct()\n"; - $this->close(); - } + function __destruct() { + echo "A::__destruct()\n"; + $this->close(); + } } class myserv { - private static $drv = null; + private static $drv = null; - static function drv() { - if (is_null(self::$drv)) - self::$drv = new drv; - return self::$drv; - } + static function drv() { + if (is_null(self::$drv)) + self::$drv = new drv; + return self::$drv; + } } $obj1 = new A(1); diff --git a/Zend/tests/bug38234.phpt b/Zend/tests/bug38234.phpt index a81a3aadcca7..413ebf721f5a 100644 --- a/Zend/tests/bug38234.phpt +++ b/Zend/tests/bug38234.phpt @@ -3,13 +3,13 @@ Bug #38234 (Exception in __clone makes memory leak) --FILE-- diff --git a/Zend/tests/bug38623.phpt b/Zend/tests/bug38623.phpt index 9b042a914181..873cdf42d461 100644 --- a/Zend/tests/bug38623.phpt +++ b/Zend/tests/bug38623.phpt @@ -3,11 +3,11 @@ Bug #38623 (leaks in a tricky code with switch() and exceptions) --FILE-- foo(); - } + public function __construct() { + $this -> foo(); + } - private function foo() { - echo __METHOD__ . "\r\n"; - } + private function foo() { + echo __METHOD__ . "\r\n"; + } } class B extends A { - public function foo() { - echo __METHOD__ . "\r\n"; - } + public function foo() { + echo __METHOD__ . "\r\n"; + } } class C extends A { - protected function foo() { - echo __METHOD__ . "\r\n"; - } + protected function foo() { + echo __METHOD__ . "\r\n"; + } } class D extends A { diff --git a/Zend/tests/bug38779.phpt b/Zend/tests/bug38779.phpt index d552f8e20d5f..7260a709d0fa 100644 --- a/Zend/tests/bug38779.phpt +++ b/Zend/tests/bug38779.phpt @@ -4,27 +4,27 @@ Bug #38779 (engine crashes when require()'ing file with syntax error through use data = '<' . "?php \n\"\";ll l\n ?" . '>'; - $this->position = 0; - return true; - } - function stream_read($count) { - $ret = substr($this->data, $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - function stream_eof() { - return $this->position >= strlen($this->data); - } - function stream_stat() { - return array('size' => strlen($this->data)); - } - function stream_set_option($option, $arg1, $arg2) { - return false; - } + private $position; + private $data; + public function stream_open($path, $mode, $options, &$opened_path) { + $this->data = '<' . "?php \n\"\";ll l\n ?" . '>'; + $this->position = 0; + return true; + } + function stream_read($count) { + $ret = substr($this->data, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + function stream_eof() { + return $this->position >= strlen($this->data); + } + function stream_stat() { + return array('size' => strlen($this->data)); + } + function stream_set_option($option, $arg1, $arg2) { + return false; + } } stream_wrapper_register('Loader', 'Loader'); require 'Loader://qqq.php'; diff --git a/Zend/tests/bug38779_1.phpt b/Zend/tests/bug38779_1.phpt index f4f89235a4a2..084463116a11 100644 --- a/Zend/tests/bug38779_1.phpt +++ b/Zend/tests/bug38779_1.phpt @@ -4,28 +4,28 @@ Bug #38779 (engine crashes when require()'ing file with syntax error through use data = '<' . "?php \n\"\";ll l\n ?" . '>'; - $this->position = 0; - return true; - } - function stream_read($count) { - $ret = substr($this->data, $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - function stream_eof() { - return $this->position >= strlen($this->data); - } - function stream_flush() { - var_dump("flush!"); - } - function stream_close() { - @unlink(__DIR__."/bug38779.txt"); - var_dump("close!"); - } + private $position; + private $data; + public function stream_open($path, $mode, $options, &$opened_path) { + $this->data = '<' . "?php \n\"\";ll l\n ?" . '>'; + $this->position = 0; + return true; + } + function stream_read($count) { + $ret = substr($this->data, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + function stream_eof() { + return $this->position >= strlen($this->data); + } + function stream_flush() { + var_dump("flush!"); + } + function stream_close() { + @unlink(__DIR__."/bug38779.txt"); + var_dump("close!"); + } } stream_wrapper_register('Loader', 'Loader'); $fp = fopen ('Loader://qqq.php', 'r'); diff --git a/Zend/tests/bug39003.phpt b/Zend/tests/bug39003.phpt index 791e11b6144f..9fa3e0d26bbd 100644 --- a/Zend/tests/bug39003.phpt +++ b/Zend/tests/bug39003.phpt @@ -5,7 +5,7 @@ Bug #39003 (autoloader is called for type hinting) class ClassName { - public $var = 'bla'; + public $var = 'bla'; } function test (OtherClassName $object) { } diff --git a/Zend/tests/bug39036.phpt b/Zend/tests/bug39036.phpt index 0cdd75150de0..4179ba542067 100644 --- a/Zend/tests/bug39036.phpt +++ b/Zend/tests/bug39036.phpt @@ -6,7 +6,7 @@ Bug #39036 (Unsetting key of foreach() yields segmentation fault) $key = 'asdf'; foreach (get_defined_vars() as $key => $value) { - unset($$key); + unset($$key); } var_dump($key); diff --git a/Zend/tests/bug39297.phpt b/Zend/tests/bug39297.phpt index 36c0af7dbbda..6ea989da46f3 100644 --- a/Zend/tests/bug39297.phpt +++ b/Zend/tests/bug39297.phpt @@ -17,14 +17,14 @@ class MyTree implements ArrayAccess { } public function offsetSet($offset, $value) { - echo "offsetSet()\n"; + echo "offsetSet()\n"; $cannonicalName = strtolower($offset); $this->children[$cannonicalName] = $value; $value->parent = $this; } public function offsetGet($offset) { - echo "offsetGet()\n"; + echo "offsetGet()\n"; $cannonicalName = strtolower($offset); return $this->children[$cannonicalName]; } diff --git a/Zend/tests/bug39346.phpt b/Zend/tests/bug39346.phpt index bde88edb9d51..6e47ca037d32 100644 --- a/Zend/tests/bug39346.phpt +++ b/Zend/tests/bug39346.phpt @@ -4,17 +4,17 @@ Bug #39346 (Unsetting a static variable inside a destructor causes segfault late _id = $id; - self::$instances[$this->_id] = $this; - } + public function __construct($id) { + $this->_id = $id; + self::$instances[$this->_id] = $this; + } - function __destruct() { - unset(self::$instances[$this->_id]); - } + function __destruct() { + unset(self::$instances[$this->_id]); + } } $test = new test(2); $test = new test(1); diff --git a/Zend/tests/bug39438.phpt b/Zend/tests/bug39438.phpt index d10e6d9ab722..5336d3ad813a 100644 --- a/Zend/tests/bug39438.phpt +++ b/Zend/tests/bug39438.phpt @@ -7,36 +7,36 @@ memory_limit=16M $i=0; $test2=array( 'a1_teasermenu' => array( - 'downloadcounter' => 2777, + 'downloadcounter' => 2777, 'versions' => array( - '0.1.0' => array ( - 'title' => 'A1 Teasermenu', - 'description' => 'Displays a teaser for advanced subpages or a selection of advanced pages', - 'state' => 'stable', - 'reviewstate' => 0, - 'category' => 'plugin', - 'downloadcounter' => 2787, - 'lastuploaddate' => 1088427240, - 'dependencies' => array ( - 'depends' => array( - 'typo3' =>'', - 'php' =>'', - 'cms' => '' - ), - 'conflicts' => array('' =>'') - ), - 'authorname' => 'Mirko Balluff', - 'authoremail' => 'balluff@amt1.de', - 'ownerusername' => 'amt1', - 't3xfilemd5' => '3a4ec198b6ea8d0bc2d69d9b7400398f', - ) - ) - ) + '0.1.0' => array ( + 'title' => 'A1 Teasermenu', + 'description' => 'Displays a teaser for advanced subpages or a selection of advanced pages', + 'state' => 'stable', + 'reviewstate' => 0, + 'category' => 'plugin', + 'downloadcounter' => 2787, + 'lastuploaddate' => 1088427240, + 'dependencies' => array ( + 'depends' => array( + 'typo3' =>'', + 'php' =>'', + 'cms' => '' + ), + 'conflicts' => array('' =>'') + ), + 'authorname' => 'Mirko Balluff', + 'authoremail' => 'balluff@amt1.de', + 'ownerusername' => 'amt1', + 't3xfilemd5' => '3a4ec198b6ea8d0bc2d69d9b7400398f', + ) + ) + ) ); $test=array(); while($i<1200) { - $test[]=$test2; - $i++; + $test[]=$test2; + $i++; } $out=serialize($test); echo "ok\n"; diff --git a/Zend/tests/bug39445.phpt b/Zend/tests/bug39445.phpt index cf1607f2dddc..d86b2ce19eb7 100644 --- a/Zend/tests/bug39445.phpt +++ b/Zend/tests/bug39445.phpt @@ -3,14 +3,14 @@ Bug #39445 (Calling debug_backtrace() in the __toString() function produces a cr --FILE-- --EXPECT-- LOWERCASE diff --git a/Zend/tests/bug39542.phpt b/Zend/tests/bug39542.phpt index 336deb7f187b..79c1c56e9185 100644 --- a/Zend/tests/bug39542.phpt +++ b/Zend/tests/bug39542.phpt @@ -5,9 +5,9 @@ Bug #39542 (Behaviour of require_once/include_once different to < 5.2.0) $oldcwd = getcwd(); chdir(__DIR__); if (substr(PHP_OS, 0, 3) == 'WIN') { - set_include_path(__DIR__.'/bug39542;.'); + set_include_path(__DIR__.'/bug39542;.'); } else { - set_include_path(__DIR__.'/bug39542:.'); + set_include_path(__DIR__.'/bug39542:.'); } spl_autoload_register(function ($class) { diff --git a/Zend/tests/bug39542/bug39542.inc b/Zend/tests/bug39542/bug39542.inc index 13b3b3eaf477..c0dcada75047 100644 --- a/Zend/tests/bug39542/bug39542.inc +++ b/Zend/tests/bug39542/bug39542.inc @@ -1,7 +1,7 @@ diff --git a/Zend/tests/bug39721.phpt b/Zend/tests/bug39721.phpt index aa0df793ff50..e25cfe882093 100644 --- a/Zend/tests/bug39721.phpt +++ b/Zend/tests/bug39721.phpt @@ -3,21 +3,21 @@ Bug #39721 (Runtime inheritance causes data corruption) --FILE-- instance = ++self::$instances; - } + public function __construct() { + $this->instance = ++self::$instances; + } } $foo = new test2(); if (is_object($foo)) { - class test2_child extends test2 { + class test2_child extends test2 { - } + } } $child = new test2_child(); diff --git a/Zend/tests/bug39775.phpt b/Zend/tests/bug39775.phpt index 4c6ce6baf1ff..ed6d66a9cc66 100644 --- a/Zend/tests/bug39775.phpt +++ b/Zend/tests/bug39775.phpt @@ -3,11 +3,11 @@ Bug #39775 ("Indirect modification ..." message is not shown) --FILE-- array; - return $this->array; - } + var $array = array(); + function __get($var) { + $v =& $this->array; + return $this->array; + } } $t = new test; $t->anything[] = 'bar'; diff --git a/Zend/tests/bug39825.phpt b/Zend/tests/bug39825.phpt index a241e0de36e0..305ed895d5b5 100644 --- a/Zend/tests/bug39825.phpt +++ b/Zend/tests/bug39825.phpt @@ -5,7 +5,7 @@ Bug #39825 (foreach produces memory error) $array = array(1 => 2, "foo" => "bar"); $obj = (object)$array; foreach ($obj as $name => $value) { - echo "$name -> $value\n"; + echo "$name -> $value\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug39944.phpt b/Zend/tests/bug39944.phpt index d602a45b8869..f68b656504a8 100644 --- a/Zend/tests/bug39944.phpt +++ b/Zend/tests/bug39944.phpt @@ -26,12 +26,12 @@ echo "intTheValue = {$intTheValue}\n"; $arrTheArray = array(); function &getArray() { - global $arrTheArray; - return $arrTheArray; + global $arrTheArray; + return $arrTheArray; } function addToArray(&$arr, $strToAdd) { - $arr[] = $strToAdd; + $arr[] = $strToAdd; } addToArray(getArray(), "xx1"); @@ -47,21 +47,21 @@ echo "arrTheArray = " . print_r($arrTheArray, 1); /****/ class RefTest { - protected $arr; + protected $arr; - function Add($strToAdd) { - $this->addToArray($this->getArray(), $strToAdd); - } + function Add($strToAdd) { + $this->addToArray($this->getArray(), $strToAdd); + } - function &getArray() { - if (!$this->arr) - $this->arr = array(); - return $this->arr; - } + function &getArray() { + if (!$this->arr) + $this->arr = array(); + return $this->arr; + } - private function addToArray(&$arr, $strToAdd) { - $arr[] = $strToAdd; - } + private function addToArray(&$arr, $strToAdd) { + $arr[] = $strToAdd; + } } $objRefTest = new RefTest(); diff --git a/Zend/tests/bug40509.phpt b/Zend/tests/bug40509.phpt index 5b7dfa09c86f..473e5cb43a74 100644 --- a/Zend/tests/bug40509.phpt +++ b/Zend/tests/bug40509.phpt @@ -4,10 +4,10 @@ Bug #40509 (key() function changed behaviour if global array is used within func $v) { - var_dump($k); + var_dump($k); } var_dump(key($arr["v"])); --EXPECT-- diff --git a/Zend/tests/bug40621.phpt b/Zend/tests/bug40621.phpt index 8650fd56fa01..40259580602e 100644 --- a/Zend/tests/bug40621.phpt +++ b/Zend/tests/bug40621.phpt @@ -4,10 +4,10 @@ Bug #40621 (Crash when constructor called inappropriately (statically)) $v) { - var_dump($k); + var_dump($k); } var_dump(key($foo)); --EXPECT-- diff --git a/Zend/tests/bug40815.phpt b/Zend/tests/bug40815.phpt index 3386097523a0..542a820f52a3 100644 --- a/Zend/tests/bug40815.phpt +++ b/Zend/tests/bug40815.phpt @@ -4,9 +4,9 @@ Bug #40815 (using strings like "class::func" and static methods in set_exception data[$name]) ) - return $this->data[$name]; - else - return $this->data[$name] = new set($this); - } + function __get($name) + { + if ( isset($this->data[$name]) ) + return $this->data[$name]; + else + return $this->data[$name] = new set($this); + } - function __set($name, $value) - { - $this->modified[$name] = $value; - } - } + function __set($name, $value) + { + $this->modified[$name] = $value; + } + } - class set implements ArrayAccess - { - private $entity; + class set implements ArrayAccess + { + private $entity; - function __construct($entity) - { - $this->entity = $entity; - $this->entity->whatever = $this; - } + function __construct($entity) + { + $this->entity = $entity; + $this->entity->whatever = $this; + } - function clear() { - $this->entity->whatever = null; - } + function clear() { + $this->entity->whatever = null; + } - function offsetUnset($offset) - { - $this->clear(); + function offsetUnset($offset) + { + $this->clear(); // $this->entity->{$this->name} = null; - } + } - function offsetSet($offset, $value) - { - } + function offsetSet($offset, $value) + { + } - function offsetGet($offset) - { - return 'Bogus '; - } + function offsetGet($offset) + { + return 'Bogus '; + } - function offsetExists($offset) - { - } - } + function offsetExists($offset) + { + } + } - $entity = new entity(); - echo($entity->whatever[0]); + $entity = new entity(); + echo($entity->whatever[0]); - //This will crash + //This will crash // $entity->whatever->clear(); - unset($entity->whatever[0]); + unset($entity->whatever[0]); - //This will not crash (comment previous & uncomment this to test + //This will not crash (comment previous & uncomment this to test // $test = $entity->whatever; unset($test[0]); - echo($entity->whatever[0]); - echo "ok\n"; + echo($entity->whatever[0]); + echo "ok\n"; ?> --EXPECT-- Bogus Bogus ok diff --git a/Zend/tests/bug41026.phpt b/Zend/tests/bug41026.phpt index e159ad36f6db..055e5f574dc0 100644 --- a/Zend/tests/bug41026.phpt +++ b/Zend/tests/bug41026.phpt @@ -5,15 +5,15 @@ Bug #41026 (segfault when calling "self::method()" in shutdown functions) class try_class { - static public function main () - { - register_shutdown_function (array ("self", "on_shutdown")); - } + static public function main () + { + register_shutdown_function (array ("self", "on_shutdown")); + } - static public function on_shutdown () - { - printf ("CHECKPOINT\n"); /* never reached */ - } + static public function on_shutdown () + { + printf ("CHECKPOINT\n"); /* never reached */ + } } try_class::main (); diff --git a/Zend/tests/bug41421.phpt b/Zend/tests/bug41421.phpt index e4fa9447de39..0cfee271a47b 100644 --- a/Zend/tests/bug41421.phpt +++ b/Zend/tests/bug41421.phpt @@ -4,12 +4,12 @@ Bug #41421 (Uncaught exception from a stream wrapper segfaults) diff --git a/Zend/tests/bug41633_2.phpt b/Zend/tests/bug41633_2.phpt index df6705645f59..180e6ac970a6 100644 --- a/Zend/tests/bug41633_2.phpt +++ b/Zend/tests/bug41633_2.phpt @@ -3,7 +3,7 @@ Bug #41633.2 (Undefined class constants must not be substituted by strings) --FILE-- diff --git a/Zend/tests/bug41633_3.phpt b/Zend/tests/bug41633_3.phpt index dd4b75c9d935..c7afb65a8720 100644 --- a/Zend/tests/bug41633_3.phpt +++ b/Zend/tests/bug41633_3.phpt @@ -3,8 +3,8 @@ Bug #41633.3 (Crash instantiating classes with self-referencing constants) --FILE-- diff --git a/Zend/tests/bug41633_4.phpt b/Zend/tests/bug41633_4.phpt index 3507f6a08cdb..c74cd7e45bcb 100644 --- a/Zend/tests/bug41633_4.phpt +++ b/Zend/tests/bug41633_4.phpt @@ -3,8 +3,8 @@ Bug #41633.4 (self:: doesn't work for constants) --FILE-- diff --git a/Zend/tests/bug42802.phpt b/Zend/tests/bug42802.phpt index ebfb52882740..1294bdbb2fde 100644 --- a/Zend/tests/bug42802.phpt +++ b/Zend/tests/bug42802.phpt @@ -8,7 +8,7 @@ class bar { } function test1(bar $bar) { - echo "ok\n"; + echo "ok\n"; } function test2(\foo\bar $bar) { @@ -18,7 +18,7 @@ function test3(\foo\bar $bar) { echo "ok\n"; } function test4(\Exception $e) { - echo "ok\n"; + echo "ok\n"; } function test5(\bar $bar) { echo "bug\n"; diff --git a/Zend/tests/bug42819.phpt b/Zend/tests/bug42819.phpt index d0b5c0b2ee66..615aabc8ed27 100644 --- a/Zend/tests/bug42819.phpt +++ b/Zend/tests/bug42819.phpt @@ -19,65 +19,65 @@ const C = "foo\\C\n"; const I = 11; class foo { - const C = "foo\\foo::C\n"; - const I = 22; - const C1 = C; - const C2 = foo\C; - const C3 = foo\foo::C; - const C4 = \foo\C; - const C5 = \foo\foo::C; - const C6 = ArrayObject::STD_PROP_LIST; - const C7 = E_ERROR; + const C = "foo\\foo::C\n"; + const I = 22; + const C1 = C; + const C2 = foo\C; + const C3 = foo\foo::C; + const C4 = \foo\C; + const C5 = \foo\foo::C; + const C6 = ArrayObject::STD_PROP_LIST; + const C7 = E_ERROR; } class bar1 { - static $a1 = array(I => 0); - static $a2 = array(foo\I => 0); - static $a3 = array(foo\foo::I => 0); - static $a4 = array(\foo\I => 0); - static $a5 = array(\foo\foo::I => 0); - static $a6 = array(ArrayObject::STD_PROP_LIST => 0); - static $a7 = array(E_ERROR => 0); + static $a1 = array(I => 0); + static $a2 = array(foo\I => 0); + static $a3 = array(foo\foo::I => 0); + static $a4 = array(\foo\I => 0); + static $a5 = array(\foo\foo::I => 0); + static $a6 = array(ArrayObject::STD_PROP_LIST => 0); + static $a7 = array(E_ERROR => 0); } class bar2 { - static $a1 = array(I => I); - static $a2 = array(foo\I => I); - static $a3 = array(foo\foo::I => I); - static $a4 = array(\foo\I => I); - static $a5 = array(\foo\foo::I => I); - static $a6 = array(ArrayObject::STD_PROP_LIST => I); - static $a7 = array(E_ERROR => I); + static $a1 = array(I => I); + static $a2 = array(foo\I => I); + static $a3 = array(foo\foo::I => I); + static $a4 = array(\foo\I => I); + static $a5 = array(\foo\foo::I => I); + static $a6 = array(ArrayObject::STD_PROP_LIST => I); + static $a7 = array(E_ERROR => I); } class bar3 { - static $a1 = array(I => foo\I); - static $a2 = array(foo\I => foo\I); - static $a3 = array(foo\foo::I => foo\I); - static $a4 = array(\foo\I => foo\I); - static $a5 = array(\foo\foo::I => foo\I); - static $a6 = array(ArrayObject::STD_PROP_LIST => foo\I); - static $a7 = array(E_ERROR => foo\I); + static $a1 = array(I => foo\I); + static $a2 = array(foo\I => foo\I); + static $a3 = array(foo\foo::I => foo\I); + static $a4 = array(\foo\I => foo\I); + static $a5 = array(\foo\foo::I => foo\I); + static $a6 = array(ArrayObject::STD_PROP_LIST => foo\I); + static $a7 = array(E_ERROR => foo\I); } class bar4 { - static $a1 = array(I => ArrayObject::STD_PROP_LIST); - static $a2 = array(foo\I => ArrayObject::STD_PROP_LIST); - static $a3 = array(foo\foo::I => ArrayObject::STD_PROP_LIST); - static $a4 = array(\foo\I => ArrayObject::STD_PROP_LIST); - static $a5 = array(\foo\foo::I => ArrayObject::STD_PROP_LIST); - static $a6 = array(ArrayObject::STD_PROP_LIST => ArrayObject::STD_PROP_LIST); - static $a7 = array(E_ERROR => ArrayObject::STD_PROP_LIST); + static $a1 = array(I => ArrayObject::STD_PROP_LIST); + static $a2 = array(foo\I => ArrayObject::STD_PROP_LIST); + static $a3 = array(foo\foo::I => ArrayObject::STD_PROP_LIST); + static $a4 = array(\foo\I => ArrayObject::STD_PROP_LIST); + static $a5 = array(\foo\foo::I => ArrayObject::STD_PROP_LIST); + static $a6 = array(ArrayObject::STD_PROP_LIST => ArrayObject::STD_PROP_LIST); + static $a7 = array(E_ERROR => ArrayObject::STD_PROP_LIST); } class bar5 { - static $a1 = array(I => E_ERROR); - static $a2 = array(foo\I => E_ERROR); - static $a3 = array(foo\foo::I => E_ERROR); - static $a4 = array(\foo\I => E_ERROR); - static $a5 = array(\foo\foo::I => E_ERROR); - static $a6 = array(ArrayObject::STD_PROP_LIST => E_ERROR); - static $a7 = array(E_ERROR => E_ERROR); + static $a1 = array(I => E_ERROR); + static $a2 = array(foo\I => E_ERROR); + static $a3 = array(foo\foo::I => E_ERROR); + static $a4 = array(\foo\I => E_ERROR); + static $a5 = array(\foo\foo::I => E_ERROR); + static $a6 = array(ArrayObject::STD_PROP_LIST => E_ERROR); + static $a7 = array(E_ERROR => E_ERROR); } echo "first\n"; diff --git a/Zend/tests/bug42820.phpt b/Zend/tests/bug42820.phpt index a53ed1af6875..af9230be102d 100644 --- a/Zend/tests/bug42820.phpt +++ b/Zend/tests/bug42820.phpt @@ -5,7 +5,7 @@ Bug #42820 (defined() on constant with namespace prefixes tries to load class) namespace ns; const ok = 0; class foo { - const ok = 0; + const ok = 0; } var_dump(defined('ns\\ok')); var_dump(defined('ns\\bug')); diff --git a/Zend/tests/bug42937.phpt b/Zend/tests/bug42937.phpt index 2ade186b9cc9..0aeeec86377e 100644 --- a/Zend/tests/bug42937.phpt +++ b/Zend/tests/bug42937.phpt @@ -3,26 +3,26 @@ Bug #42937 (__call() method not invoked when methods are called on parent from c --FILE-- $k = $v; - } + function __get($k) { + return null; + } + function __set($k, $v) { + $this->$k = $v; + } } $c = new Foo(); @@ -16,8 +16,8 @@ $c = new Foo(); $c->arr[0]["k"] = 1; $c->arr[0]["k2"] = $ref; for($cnt=0;$cnt<6;$cnt++) { - $ref = chop($undef); - $c->arr[$cnt]["k2"] = $ref; + $ref = chop($undef); + $c->arr[$cnt]["k2"] = $ref; } echo "ok\n"; ?> diff --git a/Zend/tests/bug43344_1.phpt b/Zend/tests/bug43344_1.phpt index 28af70dc67e2..aca548ba5fc0 100644 --- a/Zend/tests/bug43344_1.phpt +++ b/Zend/tests/bug43344_1.phpt @@ -6,14 +6,14 @@ namespace Foo; use Error; function f1($a=bar) { - return $a; + return $a; } function f2($a=array(bar)) { - return $a[0]; + return $a[0]; } function f3($a=array(bar=>0)) { - reset($a); - return key($a); + reset($a); + return key($a); } try { diff --git a/Zend/tests/bug43344_11.phpt b/Zend/tests/bug43344_11.phpt index 27c3160f5af5..47a59eb28061 100644 --- a/Zend/tests/bug43344_11.phpt +++ b/Zend/tests/bug43344_11.phpt @@ -3,7 +3,7 @@ Bug #43344.11 (Wrong error message for undefined namespace constant) --FILE-- diff --git a/Zend/tests/bug43344_12.phpt b/Zend/tests/bug43344_12.phpt index 71031f5819f1..3224a7de9246 100644 --- a/Zend/tests/bug43344_12.phpt +++ b/Zend/tests/bug43344_12.phpt @@ -3,7 +3,7 @@ Bug #43344.12 (Wrong error message for undefined namespace constant) --FILE-- diff --git a/Zend/tests/bug43344_13.phpt b/Zend/tests/bug43344_13.phpt index bdce5a8a758a..6b08562b2911 100644 --- a/Zend/tests/bug43344_13.phpt +++ b/Zend/tests/bug43344_13.phpt @@ -3,8 +3,8 @@ Bug #43344.13 (Wrong error message for undefined namespace constant) --FILE-- 0)) { - reset($a); - return key($a); + reset($a); + return key($a); } echo f()."\n"; ?> diff --git a/Zend/tests/bug43344_3.phpt b/Zend/tests/bug43344_3.phpt index 5450759bcc7d..6b1b6c46c9cc 100644 --- a/Zend/tests/bug43344_3.phpt +++ b/Zend/tests/bug43344_3.phpt @@ -4,7 +4,7 @@ Bug #43344.3 (Wrong error message for undefined namespace constant) diff --git a/Zend/tests/bug43344_4.phpt b/Zend/tests/bug43344_4.phpt index c147766bf6b2..0e2e3c7886ea 100644 --- a/Zend/tests/bug43344_4.phpt +++ b/Zend/tests/bug43344_4.phpt @@ -4,7 +4,7 @@ Bug #43344.4 (Wrong error message for undefined namespace constant) diff --git a/Zend/tests/bug43344_5.phpt b/Zend/tests/bug43344_5.phpt index 8cc333fd3143..5ca2144438f0 100644 --- a/Zend/tests/bug43344_5.phpt +++ b/Zend/tests/bug43344_5.phpt @@ -4,8 +4,8 @@ Bug #43344.5 (Wrong error message for undefined namespace constant) 0)) { - reset($a); - return key($a); + reset($a); + return key($a); } echo f()."\n"; ?> diff --git a/Zend/tests/bug43344_7.phpt b/Zend/tests/bug43344_7.phpt index dfab0cad904a..965419c12aaa 100644 --- a/Zend/tests/bug43344_7.phpt +++ b/Zend/tests/bug43344_7.phpt @@ -4,7 +4,7 @@ Bug #43344.7 (Wrong error message for undefined namespace constant) diff --git a/Zend/tests/bug43344_8.phpt b/Zend/tests/bug43344_8.phpt index b1e6f61a54c7..b0c247c8e386 100644 --- a/Zend/tests/bug43344_8.phpt +++ b/Zend/tests/bug43344_8.phpt @@ -4,7 +4,7 @@ Bug #43344.8 (Wrong error message for undefined namespace constant) diff --git a/Zend/tests/bug43344_9.phpt b/Zend/tests/bug43344_9.phpt index 7f7f2df38ff0..edaa332b93c7 100644 --- a/Zend/tests/bug43344_9.phpt +++ b/Zend/tests/bug43344_9.phpt @@ -4,8 +4,8 @@ Bug #43344.9 (Wrong error message for undefined namespace constant) 0)) { - reset($a); - return key($a); + reset($a); + return key($a); } echo f()."\n"; ?> diff --git a/Zend/tests/bug43450.phpt b/Zend/tests/bug43450.phpt index 05f2f7cbf6da..f47f491471e9 100644 --- a/Zend/tests/bug43450.phpt +++ b/Zend/tests/bug43450.phpt @@ -8,9 +8,9 @@ opcache.enable_cli=0 class Foo { public function __toString() - { - return __CLASS__; - } + { + return __CLASS__; + } } $num_repeats = 100000; @@ -18,15 +18,15 @@ $num_repeats = 100000; $start = memory_get_usage() / 1024; for ($i=1;$i<$num_repeats;$i++) { - $foo = new Foo(); - md5($foo); + $foo = new Foo(); + md5($foo); } $end = memory_get_usage() / 1024; if ($start + 16 < $end) { - echo 'FAIL'; + echo 'FAIL'; } else { - echo 'PASS'; + echo 'PASS'; } ?> diff --git a/Zend/tests/bug43483.phpt b/Zend/tests/bug43483.phpt index 0cfbfe8780e8..b82fc96aea21 100644 --- a/Zend/tests/bug43483.phpt +++ b/Zend/tests/bug43483.phpt @@ -3,15 +3,15 @@ Bug #43483 (get_class_methods() does not list all visible methods) --FILE-- diff --git a/Zend/tests/bug43851.phpt b/Zend/tests/bug43851.phpt index e19e393df098..7b0de5b1179f 100644 --- a/Zend/tests/bug43851.phpt +++ b/Zend/tests/bug43851.phpt @@ -4,9 +4,9 @@ Bug #43851 (Memory corrution on reuse of assigned value) --EXPECT-- diff --git a/Zend/tests/bug44069.phpt b/Zend/tests/bug44069.phpt index 75beaafed7ef..b18e16b254e6 100644 --- a/Zend/tests/bug44069.phpt +++ b/Zend/tests/bug44069.phpt @@ -8,12 +8,12 @@ $string = str_repeat('This is a teststring.', 50); for($i = 1; $i <= 2000; $i++) { // $newstring .= $string; //This uses an expected amount of mem. - $newstring = $newstring . $string; //This uses very much mem. + $newstring = $newstring . $string; //This uses very much mem. - for($j = 1; $j <= 10; $j++) - { - $array[] = 'test'; - } + for($j = 1; $j <= 10; $j++) + { + $array[] = 'test'; + } } echo "ok\n"; ?> diff --git a/Zend/tests/bug44184.phpt b/Zend/tests/bug44184.phpt index 7f277acc747c..e6e72554ad3c 100644 --- a/Zend/tests/bug44184.phpt +++ b/Zend/tests/bug44184.phpt @@ -3,18 +3,18 @@ Bug #44184 (Double free of loop-variable on exception) --FILE-- --EXPECT-- diff --git a/Zend/tests/bug44653.phpt b/Zend/tests/bug44653.phpt index 28e1d8ef7189..8657beba0064 100644 --- a/Zend/tests/bug44653.phpt +++ b/Zend/tests/bug44653.phpt @@ -8,10 +8,10 @@ function fooBar() { echo __FUNCTION__ . PHP_EOL; } namespace B; class A { - static function fooBar() { echo "bag1\n"; } + static function fooBar() { echo "bag1\n"; } } class B { - static function fooBar() { echo "bag2\n"; } + static function fooBar() { echo "bag2\n"; } } function fooBar() { echo __FUNCTION__ . PHP_EOL; } var_dump(\A\XX); diff --git a/Zend/tests/bug44899.phpt b/Zend/tests/bug44899.phpt index d9c0de0ef7b7..bebbe33a9f8c 100644 --- a/Zend/tests/bug44899.phpt +++ b/Zend/tests/bug44899.phpt @@ -5,17 +5,17 @@ Bug #44899 (__isset usage changes behavior of empty()) class myclass { - private $_data = array(); + private $_data = array(); - function __construct($data) - { - $this->_data = $data; - } + function __construct($data) + { + $this->_data = $data; + } - function __isset($field_name) - { - return isset($this->_data[$field_name]); - } + function __isset($field_name) + { + return isset($this->_data[$field_name]); + } } $arr = array('foo' => ''); diff --git a/Zend/tests/bug44899_2.phpt b/Zend/tests/bug44899_2.phpt index f3ff50604c62..ff4412979af8 100644 --- a/Zend/tests/bug44899_2.phpt +++ b/Zend/tests/bug44899_2.phpt @@ -5,22 +5,22 @@ Bug #44899 (__isset usage changes behavior of empty()) - 2 class myclass { - private $_data = array(); - - function __construct($data) - { - $this->_data = $data; - } - - function __isset($field_name) - { - return isset($this->_data[$field_name]); - } - - function __get($var) { - var_dump(empty($this->_data[$var])); - return $this->_data[$var]; - } + private $_data = array(); + + function __construct($data) + { + $this->_data = $data; + } + + function __isset($field_name) + { + return isset($this->_data[$field_name]); + } + + function __get($var) { + var_dump(empty($this->_data[$var])); + return $this->_data[$var]; + } } $arr = array('foo' => ''); diff --git a/Zend/tests/bug45147.phpt b/Zend/tests/bug45147.phpt index b940777d1292..eb5d89c70265 100644 --- a/Zend/tests/bug45147.phpt +++ b/Zend/tests/bug45147.phpt @@ -2,7 +2,7 @@ Bug #45147 (unexpected T_ENDFOR) --FILE-- - ## + ## --EXPECT-- # diff --git a/Zend/tests/bug45180.phpt b/Zend/tests/bug45180.phpt index 285543aaf08d..77daa07b4db1 100644 --- a/Zend/tests/bug45180.phpt +++ b/Zend/tests/bug45180.phpt @@ -4,21 +4,21 @@ Testing callback formats within class method diff --git a/Zend/tests/bug45910.phpt b/Zend/tests/bug45910.phpt index 7f2ea8b2052d..172443482aed 100644 --- a/Zend/tests/bug45910.phpt +++ b/Zend/tests/bug45910.phpt @@ -4,20 +4,20 @@ Bug #45910 (Cannot declare self-referencing constant) 'a', - self::CCC => 'b', - self::DDD => self::AAA - ); + private static $foo = array( + self::BBB => 'a', + self::CCC => 'b', + self::DDD => self::AAA + ); - public static function test() { - self::$foo; - } + public static function test() { + self::$foo; + } } foo::test(); diff --git a/Zend/tests/bug45910_2.phpt b/Zend/tests/bug45910_2.phpt index dec6565c0e75..a93f424f4d59 100644 --- a/Zend/tests/bug45910_2.phpt +++ b/Zend/tests/bug45910_2.phpt @@ -4,20 +4,20 @@ Bug #45910.2 (Cannot declare self-referencing constant) 'a', - self::CCC => 'b', - self::DDD => 11 - ); + private static $foo = array( + self::BBB => 'a', + self::CCC => 'b', + self::DDD => 11 + ); - public static function test() { - self::$foo; - } + public static function test() { + self::$foo; + } } foo::test(); diff --git a/Zend/tests/bug46106.phpt b/Zend/tests/bug46106.phpt index b0e769e05a01..525c4df6c5d9 100644 --- a/Zend/tests/bug46106.phpt +++ b/Zend/tests/bug46106.phpt @@ -9,9 +9,9 @@ function foobar($errno, $errstr, $errfile, $errline) { } set_error_handler('foobar'); function test($x) { - global $foo; + global $foo; - $x->invokeArgs(array(0)); + $x->invokeArgs(array(0)); } $x = new ReflectionFunction('str_pad'); diff --git a/Zend/tests/bug46246.phpt b/Zend/tests/bug46246.phpt index 12be587d74be..6671c5a1254e 100644 --- a/Zend/tests/bug46246.phpt +++ b/Zend/tests/bug46246.phpt @@ -4,25 +4,25 @@ Bug #46246 (difference between call_user_func(array($this, $method)) and $this-> Test(); - $this->$method(); - call_user_func(array($this, $method)); - } + public function call($method, $args = array()) + { + $this->Test(); + $this->$method(); + call_user_func(array($this, $method)); + } } class B extends A { - protected function Test() - { - echo 'Overridden hello from '.get_class($this)."\n"; - } + protected function Test() + { + echo 'Overridden hello from '.get_class($this)."\n"; + } } $a = new A; diff --git a/Zend/tests/bug46381.phpt b/Zend/tests/bug46381.phpt index ce4e399284b4..db948832e68b 100644 --- a/Zend/tests/bug46381.phpt +++ b/Zend/tests/bug46381.phpt @@ -4,9 +4,9 @@ Bug #46381 (wrong $this passed to internal methods causes segfault) method(); diff --git a/Zend/tests/bug46701.phpt b/Zend/tests/bug46701.phpt index 523a96735fe9..5da5a9afc75c 100644 --- a/Zend/tests/bug46701.phpt +++ b/Zend/tests/bug46701.phpt @@ -6,8 +6,8 @@ Bug #46701 (Creating associative array with long values in the key fails on 32bi 1, - 0xce331a00 => 2 + 0xcc5c4600 => 1, + 0xce331a00 => 2 ); $test_array[0xce359000] = 3; @@ -15,12 +15,12 @@ var_dump($test_array); var_dump($test_array[0xce331a00]); class foo { - public $x; + public $x; - public function __construct() { - $this->x[0xce359000] = 3; - var_dump($this->x); - } + public function __construct() { + $this->x[0xce359000] = 3; + var_dump($this->x); + } } new foo; diff --git a/Zend/tests/bug46813.phpt b/Zend/tests/bug46813.phpt index b1505fc07dab..321c5775b5e4 100644 --- a/Zend/tests/bug46813.phpt +++ b/Zend/tests/bug46813.phpt @@ -4,10 +4,10 @@ Bug #46813: class_exists doesn`t work with fully qualified namespace bar; - } + static function bar() { + static $instance = null; + $instance = new Foo(); + return $instance->bar; + } } extract(Foo::bar()); echo "ok\n"; diff --git a/Zend/tests/bug47343.phpt b/Zend/tests/bug47343.phpt index bf1a5d2b3121..f6168acf749f 100644 --- a/Zend/tests/bug47343.phpt +++ b/Zend/tests/bug47343.phpt @@ -4,38 +4,38 @@ Bug #47343 (gc_collect_cycles causes a segfault when called within a destructor data['foo'] = new B($this); - $this->data['bar'] = new B($this); - // Return either of the above - return $this->data['foo']; - } + public function getB() + { + $this->data['foo'] = new B($this); + $this->data['bar'] = new B($this); + // Return either of the above + return $this->data['foo']; + } } class B { - public function __construct($A) - { - $this->A = $A; - } + public function __construct($A) + { + $this->A = $A; + } - public function __destruct() - { - } + public function __destruct() + { + } } for ($i = 0; $i < 2; $i++) { - $Aobj = new A; - $Bobj = $Aobj->getB(); - unset($Bobj); - unset($Aobj); + $Aobj = new A; + $Bobj = $Aobj->getB(); + unset($Bobj); + unset($Aobj); } echo "DONE\n"; diff --git a/Zend/tests/bug47353.phpt b/Zend/tests/bug47353.phpt index 189b1f51a680..de5c280e6ade 100644 --- a/Zend/tests/bug47353.phpt +++ b/Zend/tests/bug47353.phpt @@ -5,17 +5,17 @@ Bug #47353 (crash when creating a lot of objects in object destructor) class A { - function __destruct() - { - $myArray = array(); + function __destruct() + { + $myArray = array(); - for($i = 1; $i <= 3000; $i++) { - if(!isset($myArray[$i])) - $myArray[$i] = array(); - $ref = & $myArray[$i]; - $ref[] = new stdClass(); - } - } + for($i = 1; $i <= 3000; $i++) { + if(!isset($myArray[$i])) + $myArray[$i] = array(); + $ref = & $myArray[$i]; + $ref[] = new stdClass(); + } + } } $a = new A(); diff --git a/Zend/tests/bug47593.phpt b/Zend/tests/bug47593.phpt index ffbe7c8dbb51..fb3bfeab52a0 100644 --- a/Zend/tests/bug47593.phpt +++ b/Zend/tests/bug47593.phpt @@ -7,8 +7,8 @@ namespace test; const TEST = 11; class foo { - public function xyz() { - } + public function xyz() { + } } interface baz { diff --git a/Zend/tests/bug47699.phpt b/Zend/tests/bug47699.phpt index 6d4871bc2dd4..a30c8a817098 100644 --- a/Zend/tests/bug47699.phpt +++ b/Zend/tests/bug47699.phpt @@ -3,9 +3,9 @@ Bug #47699 (autoload and late static binding) --FILE-- A(); diff --git a/Zend/tests/bug48215_2.phpt b/Zend/tests/bug48215_2.phpt index 67380063c6aa..aa687196e114 100644 --- a/Zend/tests/bug48215_2.phpt +++ b/Zend/tests/bug48215_2.phpt @@ -3,14 +3,14 @@ Bug #48215 - parent::method() calls __construct, case sensitive test --FILE-- diff --git a/Zend/tests/bug48228.phpt b/Zend/tests/bug48228.phpt index d91ded28be44..a4fa5483b98f 100644 --- a/Zend/tests/bug48228.phpt +++ b/Zend/tests/bug48228.phpt @@ -4,19 +4,19 @@ Bug #48228 (crash when exception is thrown while passing function arguments) check(do_throw()); - } + function dosome() + { + $this->check(do_throw()); + } } $l_aa=new aa(); diff --git a/Zend/tests/bug48408.phpt b/Zend/tests/bug48408.phpt index 3315f4096288..cc34e1742429 100644 --- a/Zend/tests/bug48408.phpt +++ b/Zend/tests/bug48408.phpt @@ -3,22 +3,22 @@ Bug #48408 (crash when exception is thrown while passing function arguments) --FILE-- process($c->generate(0)); + $b->process($c->generate(0)); } catch(Exception $e){ - $c->generate(0); + $c->generate(0); } ?> --EXPECTF-- diff --git a/Zend/tests/bug48409.phpt b/Zend/tests/bug48409.phpt index 7ba99cdbf403..d05f5c42f432 100644 --- a/Zend/tests/bug48409.phpt +++ b/Zend/tests/bug48409.phpt @@ -7,59 +7,59 @@ class ABCException extends Exception {} class BBB { - public function xyz($d, $x) - { - if ($x == 34) { - throw new ABCException; - } - return array('foo' => 'xyz'); - } + public function xyz($d, $x) + { + if ($x == 34) { + throw new ABCException; + } + return array('foo' => 'xyz'); + } } class CCC { - public function process($p) - { - return $p; - } + public function process($p) + { + return $p; + } } class AAA { - public function func() - { - $b = new BBB; - $c = new CCC; - $i = 34; - $item = array('foo' => 'bar'); - try { - $c->process($b->xyz($item['foo'], $i)); - } - catch(ABCException $e) { - $b->xyz($item['foo'], $i); - } - } // end func(); + public function func() + { + $b = new BBB; + $c = new CCC; + $i = 34; + $item = array('foo' => 'bar'); + try { + $c->process($b->xyz($item['foo'], $i)); + } + catch(ABCException $e) { + $b->xyz($item['foo'], $i); + } + } // end func(); } class Runner { - public function run($x) - { - try { - $x->func(); - } - catch(ABCException $e) { - throw new Exception; - } - } + public function run($x) + { + try { + $x->func(); + } + catch(ABCException $e) { + throw new Exception; + } + } } try { - $runner = new Runner; - $runner->run(new AAA); + $runner = new Runner; + $runner->run(new AAA); } catch(Exception $e) { - die('Exception thrown'); + die('Exception thrown'); } ?> diff --git a/Zend/tests/bug48428.phpt b/Zend/tests/bug48428.phpt index ae9ac936a3bb..0cda84dea4ee 100644 --- a/Zend/tests/bug48428.phpt +++ b/Zend/tests/bug48428.phpt @@ -3,10 +3,10 @@ Bug #48428 (crash when exception is thrown while passing function arguments) --FILE-- getMessage()); + echo($e -> getMessage()); } ?> --EXPECT-- diff --git a/Zend/tests/bug48533.phpt b/Zend/tests/bug48533.phpt index 3dfbc658ecdf..39b1db9ee7e4 100644 --- a/Zend/tests/bug48533.phpt +++ b/Zend/tests/bug48533.phpt @@ -4,21 +4,21 @@ Bug #48533 (__callStatic is not invoked for private/protected methods) 1)); diff --git a/Zend/tests/bug49472.phpt b/Zend/tests/bug49472.phpt index 2d7ae514f227..e5b21fd50080 100644 --- a/Zend/tests/bug49472.phpt +++ b/Zend/tests/bug49472.phpt @@ -12,12 +12,12 @@ class Foo implements ia { } class FooBar extends Foo implements ia { - const x = 1; - const c = 'Ocean'; + const x = 1; + const c = 'Ocean'; - public function show() { - return ia::c; - } + public function show() { + return ia::c; + } } new FooBar; diff --git a/Zend/tests/bug49893.phpt b/Zend/tests/bug49893.phpt index addf4470736e..adab4421ddcb 100644 --- a/Zend/tests/bug49893.phpt +++ b/Zend/tests/bug49893.phpt @@ -3,24 +3,24 @@ Bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3) --FILE-- getMessage() . "\n"; - } - } + function __destruct() { + try { + throw new Exception("2"); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } + } } class B { - function __construct() { - $this->a = new A(); - throw new Exception("1"); - } + function __construct() { + $this->a = new A(); + throw new Exception("1"); + } } try { - $b = new B(); + $b = new B(); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug49908.phpt b/Zend/tests/bug49908.phpt index 8ab6307180af..e108918b13dd 100644 --- a/Zend/tests/bug49908.phpt +++ b/Zend/tests/bug49908.phpt @@ -4,13 +4,13 @@ Bug #49908 (throwing exception in autoloader crashes when interface is not defin file = null; - } + public function __construct() { + $this->file = null; + } } throw new a; diff --git a/Zend/tests/bug50174.phpt b/Zend/tests/bug50174.phpt index 6ed5733b67e7..5f0bbd7dd49e 100644 --- a/Zend/tests/bug50174.phpt +++ b/Zend/tests/bug50174.phpt @@ -5,10 +5,10 @@ Bug #50174 (Incorrectly matched docComment) class TestClass { - /** const comment */ - const C = 0; + /** const comment */ + const C = 0; - function x() {} + function x() {} } $rm = new ReflectionMethod('TestClass', 'x'); @@ -16,10 +16,10 @@ var_dump($rm->getDocComment()); class TestClass2 { - /** const comment */ - const C = 0; + /** const comment */ + const C = 0; - public $x; + public $x; } $rp = new ReflectionProperty('TestClass2', 'x'); diff --git a/Zend/tests/bug50383.phpt b/Zend/tests/bug50383.phpt index de81facd053c..2f72ea51f853 100644 --- a/Zend/tests/bug50383.phpt +++ b/Zend/tests/bug50383.phpt @@ -4,34 +4,34 @@ Bug #50383 (Exceptions thrown in __call / __callStatic do not include file and l foo(); + $x = new myClass; + $x->foo(); } try { - thrower(); + thrower(); } catch(Exception $e) { - print $e->getMessage(); - print_r($e->getTrace()); + print $e->getMessage(); + print_r($e->getTrace()); } try { - thrower2(); + thrower2(); } catch (Exception $e) { - print $e->getMessage(); - print_r($e->getTrace()); + print $e->getMessage(); + print_r($e->getTrace()); } ?> diff --git a/Zend/tests/bug50394.phpt b/Zend/tests/bug50394.phpt index 60b9d34582e0..e3beb2a2e46e 100644 --- a/Zend/tests/bug50394.phpt +++ b/Zend/tests/bug50394.phpt @@ -6,7 +6,7 @@ function inc( &$x ) { $x++; } class Proxy { function __call( $name, $args ) { - echo "$name called!\n"; + echo "$name called!\n"; call_user_func_array( 'inc', $args ); } } diff --git a/Zend/tests/bug51176.phpt b/Zend/tests/bug51176.phpt index c5185cc5fa61..cf47b74da8a7 100644 --- a/Zend/tests/bug51176.phpt +++ b/Zend/tests/bug51176.phpt @@ -4,22 +4,22 @@ Bug #51176 (Static calling in non-static method behaves like $this->) diff --git a/Zend/tests/bug51822.phpt b/Zend/tests/bug51822.phpt index c0973952834b..0a3813b2f149 100644 --- a/Zend/tests/bug51822.phpt +++ b/Zend/tests/bug51822.phpt @@ -4,24 +4,24 @@ Bug #51822 (Segfault with strange __destruct() for static class variables) test = new DestructableObject; - echo "1\n"; - } + public function __destruct() + { + $this->test = new DestructableObject; + echo "1\n"; + } } class Test { - public static $mystatic; + public static $mystatic; } // Uncomment this to avoid segfault @@ -30,7 +30,7 @@ class Test $x = new Test(); if (!isset(Test::$mystatic)) - Test::$mystatic = new DestructorCreator(); + Test::$mystatic = new DestructorCreator(); echo "bla\n"; ?> diff --git a/Zend/tests/bug51827.phpt b/Zend/tests/bug51827.phpt index 77bdc069c306..6c3d72171694 100644 --- a/Zend/tests/bug51827.phpt +++ b/Zend/tests/bug51827.phpt @@ -5,7 +5,7 @@ Bug #51827 (Bad warning when register_shutdown_function called with wrong num of function abc() { - var_dump(1); + var_dump(1); } register_shutdown_function('timE'); diff --git a/Zend/tests/bug52041.phpt b/Zend/tests/bug52041.phpt index 467a29fe7705..e5aca5c82eb3 100644 --- a/Zend/tests/bug52041.phpt +++ b/Zend/tests/bug52041.phpt @@ -3,7 +3,7 @@ Bug #52041 (Memory leak when writing on uninitialized variable returned from fun --FILE-- --EXPECTF-- diff --git a/Zend/tests/bug52484.phpt b/Zend/tests/bug52484.phpt index b8202a450430..9b40b4cae79f 100644 --- a/Zend/tests/bug52484.phpt +++ b/Zend/tests/bug52484.phpt @@ -4,9 +4,9 @@ Bug #52484 (__set() ignores setting properties with empty names) $prop); - } + function __unset($prop) { + unset($this->$prop); + } } $a = new A(); diff --git a/Zend/tests/bug52484_2.phpt b/Zend/tests/bug52484_2.phpt index 3b12950c6689..698f2d94b5be 100644 --- a/Zend/tests/bug52484_2.phpt +++ b/Zend/tests/bug52484_2.phpt @@ -4,9 +4,9 @@ Bug #52484.2 (__set() ignores setting properties with empty names) $prop = $val; - } + function __set($prop, $val) { + $this->$prop = $val; + } } $a = new A(); diff --git a/Zend/tests/bug52484_3.phpt b/Zend/tests/bug52484_3.phpt index 995e624dfc55..3bb5743963ae 100644 --- a/Zend/tests/bug52484_3.phpt +++ b/Zend/tests/bug52484_3.phpt @@ -4,9 +4,9 @@ Bug #52484.3 (__set() ignores setting properties with empty names) $prop); - } + function __get($prop) { + var_dump($this->$prop); + } } $a = new A(); diff --git a/Zend/tests/bug52614.phpt b/Zend/tests/bug52614.phpt index 77a5f30f6796..30c1fc488ad4 100644 --- a/Zend/tests/bug52614.phpt +++ b/Zend/tests/bug52614.phpt @@ -3,41 +3,41 @@ Bug #52614 (Memory leak when writing on uninitialized variable returned from met --FILE-- a1; - } + public function f1() { + return $this->a1; + } - public function f2() { - return $this->a2; - } + public function f2() { + return $this->a2; + } - public function f3() { - $this->a3 = array(); - return $this->a3; - } + public function f3() { + $this->a3 = array(); + return $this->a3; + } - public function f4() { - return $this->o1; - } + public function f4() { + return $this->o1; + } - public function f5() { - $this->o2 = new stdClass; - return $this->o2; - } + public function f5() { + $this->o2 = new stdClass; + return $this->o2; + } - public function &f6() { - return $this->a1; - } + public function &f6() { + return $this->a1; + } - public function f7(&$x) { - $x = 2; - } + public function f7(&$x) { + $x = 2; + } } diff --git a/Zend/tests/bug52879.phpt b/Zend/tests/bug52879.phpt index 6c3232f32dfc..09369d2d2f69 100644 --- a/Zend/tests/bug52879.phpt +++ b/Zend/tests/bug52879.phpt @@ -3,10 +3,10 @@ Bug #52879 (Objects unreferenced in __get, __set, __isset or __unset can be free --FILE-- myRef = $value; - } + public $myRef; + public function __set($property,$value) { + $this->myRef = $value; + } } $myGlobal=new MyClass(); $myGlobal->myRef=&$myGlobal; diff --git a/Zend/tests/bug52940.phpt b/Zend/tests/bug52940.phpt index 51137c091e4f..a3a130619f1f 100644 --- a/Zend/tests/bug52940.phpt +++ b/Zend/tests/bug52940.phpt @@ -3,8 +3,8 @@ Bug #52940 (call_user_func_array still allows call-time pass-by-reference) --FILE-- getMessage()."\n"; - } + $e = new Foo(); + try { + throw new Exception("ops 2"); + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } } test(); diff --git a/Zend/tests/bug54039.phpt b/Zend/tests/bug54039.phpt index ccdfe94305d1..aade872bf2c5 100644 --- a/Zend/tests/bug54039.phpt +++ b/Zend/tests/bug54039.phpt @@ -3,41 +3,41 @@ Bug #54039 (use() of static variables in lambda functions can break staticness) --FILE-- getDocComment()); + $x = new \ReflectionFunction('foo\test'); + var_dump($x->getDocComment()); - /** test1 */ - class bar { } + /** test1 */ + class bar { } - /** test2 */ - class foo extends namespace\bar { } + /** test2 */ + class foo extends namespace\bar { } - $x = new \ReflectionClass('foo\bar'); - var_dump($x->getDocComment()); + $x = new \ReflectionClass('foo\bar'); + var_dump($x->getDocComment()); - $x = new \ReflectionClass('foo\foo'); - var_dump($x->getDocComment()); + $x = new \ReflectionClass('foo\foo'); + var_dump($x->getDocComment()); } ?> diff --git a/Zend/tests/bug55247.phpt b/Zend/tests/bug55247.phpt index 8c21019abdd5..163cc721fbdd 100644 --- a/Zend/tests/bug55247.phpt +++ b/Zend/tests/bug55247.phpt @@ -4,11 +4,11 @@ Request #55247 (Parser problem with static calls using string method name) --EXPECTF-- diff --git a/Zend/tests/bug60444.phpt b/Zend/tests/bug60444.phpt index 38f81bc41381..a86e1d422ff6 100644 --- a/Zend/tests/bug60444.phpt +++ b/Zend/tests/bug60444.phpt @@ -3,14 +3,14 @@ Bug #60444 (Segmentation fault with include & class extending) --FILE-- x; + use T; + function __construct() { + return ++$this->x; } } class Z extends Y { - function __construct() { - return ++$this->x; + function __construct() { + return ++$this->x; } } $a = new Z(); diff --git a/Zend/tests/bug60536_002.phpt b/Zend/tests/bug60536_002.phpt index 2701ac34cdb5..4d49caa28bda 100644 --- a/Zend/tests/bug60536_002.phpt +++ b/Zend/tests/bug60536_002.phpt @@ -21,7 +21,7 @@ echo "POST-CLASS-GUARD\n"; // now we do the test for a fatal error class TraitsTest { - use THello1; + use THello1; public $hello; } diff --git a/Zend/tests/bug60569.phpt b/Zend/tests/bug60569.phpt index 56aaa2c6024f..480c9c8f8a12 100644 Binary files a/Zend/tests/bug60569.phpt and b/Zend/tests/bug60569.phpt differ diff --git a/Zend/tests/bug60598.phpt b/Zend/tests/bug60598.phpt index 143ac7950460..2db0402fa95f 100644 --- a/Zend/tests/bug60598.phpt +++ b/Zend/tests/bug60598.phpt @@ -9,12 +9,12 @@ $containers = array(); class ObjectOne { protected $_guid = 0; public function __construct() { - global $containers; - $this->guid = 1; + global $containers; + $this->guid = 1; $containers[spl_object_hash($this)] = $this; } public function __destruct() { - global $containers; + global $containers; $containers[spl_object_hash($this)] = NULL; } } diff --git a/Zend/tests/bug60611.phpt b/Zend/tests/bug60611.phpt index abd04b089159..e90479f6bae1 100644 --- a/Zend/tests/bug60611.phpt +++ b/Zend/tests/bug60611.phpt @@ -3,10 +3,10 @@ Bug #60611 (Segmentation fault with Cls::{expr}() syntax) --FILE-- v1 = new sELF; - $this->v2 = new SELF; - } + static $x = "A"; + function testit() { + $this->v1 = new sELF; + $this->v2 = new SELF; + } } class B extends A { - static $x = "B"; - function testit() { - PARENT::testit(); - $this->v3 = new sELF; - $this->v4 = new PARENT; - $this->v4 = STATIC::$x; - } + static $x = "B"; + function testit() { + PARENT::testit(); + $this->v3 = new sELF; + $this->v4 = new PARENT; + $this->v4 = STATIC::$x; + } } $t = new B(); $t->testit(); diff --git a/Zend/tests/bug61011.phpt b/Zend/tests/bug61011.phpt index b9088c68f17b..53fd7a2fbc5f 100644 --- a/Zend/tests/bug61011.phpt +++ b/Zend/tests/bug61011.phpt @@ -3,33 +3,33 @@ Bug #61011 (Crash when an exception is thrown by autoloader accessing a static p --FILE-- _this = $this; // <-- uncomment this return 'A'; } @@ -18,7 +18,7 @@ class T { $t = new T; for ($i = 0; $i < 3; $i++) { strip_tags($t); - strip_tags(new T); + strip_tags(new T); } var_dump($handler); --EXPECTF-- diff --git a/Zend/tests/bug61362.phpt b/Zend/tests/bug61362.phpt index af216b566fa8..ac9e976f3f6e 100644 --- a/Zend/tests/bug61362.phpt +++ b/Zend/tests/bug61362.phpt @@ -3,15 +3,15 @@ Bug #61362 (Exception::getTraceAsString, Exception::__toString not able to handl --FILE-- getTraceAsString(), "\n"; - echo (string)$e; + echo $e->getTraceAsString(), "\n"; + echo (string)$e; } ?> --EXPECTF-- diff --git a/Zend/tests/bug62097.phpt b/Zend/tests/bug62097.phpt index 07e93bfa8806..dda3b34a2635 100644 --- a/Zend/tests/bug62097.phpt +++ b/Zend/tests/bug62097.phpt @@ -7,9 +7,9 @@ if (PHP_INT_MAX !== 2147483647) --FILE-- diff --git a/Zend/tests/bug63111.phpt b/Zend/tests/bug63111.phpt index 077e350bc22e..2b06d3583a70 100644 --- a/Zend/tests/bug63111.phpt +++ b/Zend/tests/bug63111.phpt @@ -9,9 +9,9 @@ interface MyInterface { static function bar(); } abstract class Bar { - static function foo() { - echo "ok\n"; - } + static function foo() { + echo "ok\n"; + } } var_dump(is_callable(array("Foo", "bar"))); var_dump(is_callable("Foo::bar")); diff --git a/Zend/tests/bug63462.phpt b/Zend/tests/bug63462.phpt index bcc2c679970b..03182224ef55 100644 --- a/Zend/tests/bug63462.phpt +++ b/Zend/tests/bug63462.phpt @@ -5,32 +5,32 @@ Marco Pivetta --FILE-- publicProperty, - $this->protectedProperty, - $this->privateProperty - ); - } + public function __construct() { + unset( + $this->publicProperty, + $this->protectedProperty, + $this->privateProperty + ); + } - function __get($name) { - echo '__get ' . $name . "\n"; - return $this->$name; - } + function __get($name) { + echo '__get ' . $name . "\n"; + return $this->$name; + } - function __set($name, $value) { - echo '__set ' . $name . "\n"; - $this->$name = $value; - } + function __set($name, $value) { + echo '__set ' . $name . "\n"; + $this->$name = $value; + } - function __isset($name) { - echo '__isset ' . $name . "\n"; - return isset($this->$name); - } + function __isset($name) { + echo '__isset ' . $name . "\n"; + return isset($this->$name); + } } $test = new Test(); diff --git a/Zend/tests/bug63468.phpt b/Zend/tests/bug63468.phpt index 02c3c06c1725..ca66c4caeddc 100644 --- a/Zend/tests/bug63468.phpt +++ b/Zend/tests/bug63468.phpt @@ -4,23 +4,23 @@ Bug #63468 (wrong called method as callback with inheritance) children[] = $this; - } - $this->children[] = $this; - } + function __construct(Node $parent=NULL) { + if ($parent) { + $parent->children[] = $this; + } + $this->children[] = $this; + } - function __destruct() { - $this->children = NULL; - } + function __destruct() { + $this->children = NULL; + } } define("MAX", 16); for ($n = 0; $n < 20; $n++) { - $top = new Node(); - for ($i=0 ; $ibacktrace(); } + use T1; + public function test() { $this->backtrace(); } } class B { - use T2 { t2method as Bmethod; } + use T2 { t2method as Bmethod; } } class C extends A { } trait T1 { - protected function backtrace() { - $b = new B(); - $b->Bmethod(); - } + protected function backtrace() { + $b = new B(); + $b->Bmethod(); + } } trait T2 { - public function t2method() { - print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)); - } + public function t2method() { + print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)); + } } $a = new A(); $a->test(); diff --git a/Zend/tests/bug64239_3.phpt b/Zend/tests/bug64239_3.phpt index 15faeb9852d8..1a7da60e3c65 100644 --- a/Zend/tests/bug64239_3.phpt +++ b/Zend/tests/bug64239_3.phpt @@ -3,19 +3,19 @@ Bug #64239 (debug_print_backtrace() changed behavior) --FILE-- container[$offset]); } public function &offsetGet($offset) { - $result = null; + $result = null; if (isset($this->container[$offset])) { $result = &$this->container[$offset]; } diff --git a/Zend/tests/bug64515.phpt b/Zend/tests/bug64515.phpt index b101c17c3a58..aeb2cd156455 100644 --- a/Zend/tests/bug64515.phpt +++ b/Zend/tests/bug64515.phpt @@ -3,7 +3,7 @@ Bug #64515 (Memoryleak when using the same variablename 2times in function decla --FILE-- show_output('Files: ', trim(`cd .`)); // this gives invalid args to shell_exec @@ -12,7 +12,7 @@ $cat->show_output('Files: ', `cd .`); // this causes a segmentation fault $cat->show_output(`cd .`); // this causes a segmentation fault function show_outputa($prepend, $output) { - echo "Okey"; + echo "Okey"; } show_outputa('Files: ', `cd .`); // this works as expected diff --git a/Zend/tests/bug64821.1.phpt b/Zend/tests/bug64821.1.phpt index 39bec77a453d..52713e2211c5 100644 --- a/Zend/tests/bug64821.1.phpt +++ b/Zend/tests/bug64821.1.phpt @@ -4,12 +4,12 @@ Bug #64821 Custom Exceptions crash when internal properties overridden (variatio message = NULL; - $this->string = NULL; - $this->code = array(); - $this->line = "hello"; - } + public function __construct() { + $this->message = NULL; + $this->string = NULL; + $this->code = array(); + $this->line = "hello"; + } } throw new a; diff --git a/Zend/tests/bug64821.2.phpt b/Zend/tests/bug64821.2.phpt index 5650c48872d9..cac0a948f9be 100644 --- a/Zend/tests/bug64821.2.phpt +++ b/Zend/tests/bug64821.2.phpt @@ -4,9 +4,9 @@ Bug #64821 Custom Exceptions crash when internal properties overridden (variatio line = array(); - } + public function __construct() { + $this->line = array(); + } } throw new a; diff --git a/Zend/tests/bug64821.3.phpt b/Zend/tests/bug64821.3.phpt index 831665e3646e..d94f1ba361ed 100644 --- a/Zend/tests/bug64821.3.phpt +++ b/Zend/tests/bug64821.3.phpt @@ -4,10 +4,10 @@ Bug #64821 Custom Exceptions crash when internal properties overridden (variatio line = array(); - $this->file = NULL; - } + public function __construct() { + $this->line = array(); + $this->file = NULL; + } } throw new a; diff --git a/Zend/tests/bug64896.phpt b/Zend/tests/bug64896.phpt index 59c59b7fe2e7..cae45e3b2eee 100644 --- a/Zend/tests/bug64896.phpt +++ b/Zend/tests/bug64896.phpt @@ -7,18 +7,18 @@ zend.enable_gc=1 $bar = NULL; class bad { - private $_private = array(); + private $_private = array(); - public function __construct() - { - $this->_private[] = 'php'; - } + public function __construct() + { + $this->_private[] = 'php'; + } - public function __destruct() - { - global $bar; - $bar = $this; - } + public function __destruct() + { + global $bar; + $bar = $this; + } } $foo = new stdclass; diff --git a/Zend/tests/bug64960.phpt b/Zend/tests/bug64960.phpt index 3c1d38ad9e88..360b5bf72282 100644 --- a/Zend/tests/bug64960.phpt +++ b/Zend/tests/bug64960.phpt @@ -6,11 +6,11 @@ Bug #64960 (Segfault in gc_zval_possible_root) ob_end_flush(); class ExceptionHandler { - public function __invoke (Exception $e) - { - // this triggers the custom error handler - ob_end_clean(); - } + public function __invoke (Exception $e) + { + // this triggers the custom error handler + ob_end_clean(); + } } // this must be a class, closure does not trigger segfault @@ -19,10 +19,10 @@ set_exception_handler(new ExceptionHandler()); // exception must be thrown from error handler. set_error_handler(function() { - $e = new Exception; - $e->_trace = debug_backtrace(); + $e = new Exception; + $e->_trace = debug_backtrace(); - throw $e; + throw $e; }); // trigger error handler diff --git a/Zend/tests/bug64966.phpt b/Zend/tests/bug64966.phpt index 329503e5af5b..0d610ce2ff09 100644 --- a/Zend/tests/bug64966.phpt +++ b/Zend/tests/bug64966.phpt @@ -3,18 +3,18 @@ Bug #64966 (segfault in zend_do_fcall_common_helper_SPEC) --FILE-- getMessage()); - } while ($e = $e->getPrevious()); + do { + var_dump($e->getMessage()); + } while ($e = $e->getPrevious()); } function foo2() { - try { - try { - throw new Exception("caught"); - return true; - } finally { - try { - throw new Exception("caught"); - } catch (Exception $e) { - } - } - } catch (Exception $e) { - } + try { + try { + throw new Exception("caught"); + return true; + } finally { + try { + throw new Exception("caught"); + } catch (Exception $e) { + } + } + } catch (Exception $e) { + } } $foo = foo2(); var_dump($foo); function foo3() { - try { - throw new Exception("not caught"); - return true; - } finally { - try { - throw new NotExists(); - } catch (Exception $e) { - } - } + try { + throw new Exception("not caught"); + return true; + } finally { + try { + throw new NotExists(); + } catch (Exception $e) { + } + } } $bar = foo3(); diff --git a/Zend/tests/bug65911.phpt b/Zend/tests/bug65911.phpt index 753c8c6c7d81..b9d973eb45ea 100644 --- a/Zend/tests/bug65911.phpt +++ b/Zend/tests/bug65911.phpt @@ -6,11 +6,11 @@ class A {} class B { - public function go() - { - $this->foo = 'bar'; - echo A::$this->foo; // should not output 'bar' - } + public function go() + { + $this->foo = 'bar'; + echo A::$this->foo; // should not output 'bar' + } } $obj = new B(); diff --git a/Zend/tests/bug66218.phpt b/Zend/tests/bug66218.phpt index db3c7c655afa..5809af741e2b 100644 --- a/Zend/tests/bug66218.phpt +++ b/Zend/tests/bug66218.phpt @@ -9,9 +9,9 @@ if (!function_exists("dl")) die("skip need dl"); $tab = get_extension_funcs("standard"); $fcts = array("dl"); foreach ($fcts as $fct) { - if (in_array($fct, $tab)) { - echo "$fct Ok\n"; - } + if (in_array($fct, $tab)) { + echo "$fct Ok\n"; + } } ?> Done diff --git a/Zend/tests/bug66252.phpt b/Zend/tests/bug66252.phpt index 93f6253a55ac..8b5919801e43 100644 --- a/Zend/tests/bug66252.phpt +++ b/Zend/tests/bug66252.phpt @@ -3,10 +3,10 @@ Bug #66252 (Problems in AST evaluation invalidating valid parent:: reference) --FILE-- foo; - } + public function __get($x) { + global $foo; + return $foo->foo; + } } class Foo { - public function __get($x) { - global $bar; - return $bar->bar; - } + public function __get($x) { + global $bar; + return $bar->bar; + } } $foo->blah += 1; //crash ++$foo->blah; //crash diff --git a/Zend/tests/bug67368.phpt b/Zend/tests/bug67368.phpt index b3aff293a039..39d8bd30d60f 100644 --- a/Zend/tests/bug67368.phpt +++ b/Zend/tests/bug67368.phpt @@ -5,7 +5,7 @@ report_memleaks=1 --FILE-- 3]["bar"]; + const bar = ["bar" => 3]["bar"]; } echo "okey"; --EXPECT-- diff --git a/Zend/tests/bug67436/a.inc b/Zend/tests/bug67436/a.inc index c560c2db7d0b..f49556c84de0 100644 --- a/Zend/tests/bug67436/a.inc +++ b/Zend/tests/bug67436/a.inc @@ -1,10 +1,10 @@ array( - 'a' => 'apple', - 'b' => 'banana', - 'c' => 'cranberry', - 'd' => 'mango', - 'e' => 'pineapple' - ), - 'b' => array( - 'a' => 'apple', - 'b' => 'banana', - 'c' => 'cranberry', - 'd' => 'mango', - 'e' => 'pineapple' - ), - 'c' => 'cranberry', - 'd' => 'mango', - 'e' => 'pineapple' + 'a' => array( + 'a' => 'apple', + 'b' => 'banana', + 'c' => 'cranberry', + 'd' => 'mango', + 'e' => 'pineapple' + ), + 'b' => array( + 'a' => 'apple', + 'b' => 'banana', + 'c' => 'cranberry', + 'd' => 'mango', + 'e' => 'pineapple' + ), + 'c' => 'cranberry', + 'd' => 'mango', + 'e' => 'pineapple' ); function test(&$child, $entry) { - $i = 1; + $i = 1; - foreach ($child AS $key => $fruit) - { - if (!is_numeric($key)) - { - $child[$i] = $fruit; - unset($child[$key]); - $i++; - } - } + foreach ($child AS $key => $fruit) + { + if (!is_numeric($key)) + { + $child[$i] = $fruit; + unset($child[$key]); + $i++; + } + } } $i = 1; foreach ($arr AS $key => $fruit) { - $arr[$i] = $fruit; + $arr[$i] = $fruit; - if (is_array($fruit)) - { - test($arr[$i], $fruit); - } + if (is_array($fruit)) + { + test($arr[$i], $fruit); + } - unset($arr[$key]); - $i++; + unset($arr[$key]); + $i++; } var_dump($arr); diff --git a/Zend/tests/bug68370.phpt b/Zend/tests/bug68370.phpt index 73411ca9b954..b480bffab541 100644 --- a/Zend/tests/bug68370.phpt +++ b/Zend/tests/bug68370.phpt @@ -3,10 +3,10 @@ Bug #68370 "unset($this)" can make the program crash --FILE-- test(); diff --git a/Zend/tests/bug68446.phpt b/Zend/tests/bug68446.phpt index 91685ebb5e5a..1f682af9aa4e 100644 --- a/Zend/tests/bug68446.phpt +++ b/Zend/tests/bug68446.phpt @@ -6,11 +6,11 @@ const FOO = [1]; const BAR = null; function a(array $a = FOO) { - var_dump($a); + var_dump($a); } function b(?array $b = BAR) { - var_dump($b); + var_dump($b); } b(null); diff --git a/Zend/tests/bug68896.phpt b/Zend/tests/bug68896.phpt index 31823a2873f6..988e98e31ef1 100644 --- a/Zend/tests/bug68896.phpt +++ b/Zend/tests/bug68896.phpt @@ -3,10 +3,10 @@ Bug #68896 (Changing ArrayObject value cause Segment Fault) --FILE-- a[$offset]; - } + private $a = []; + function offsetGet($offset) { + return $this->a[$offset]; + } function offsetSet($offset, $value) { $this->a[$offset] = $value; } diff --git a/Zend/tests/bug69017.phpt b/Zend/tests/bug69017.phpt index d6d20d7c08cd..d1608ebbf9db 100644 --- a/Zend/tests/bug69017.phpt +++ b/Zend/tests/bug69017.phpt @@ -5,12 +5,12 @@ class c1 { - const ZERO = 0; - const ONE = 1; - const MAX = PHP_INT_MAX; - public static $a1 = array(self::ONE => 'one'); - public static $a2 = array(self::ZERO => 'zero'); - public static $a3 = array(self::MAX => 'zero'); + const ZERO = 0; + const ONE = 1; + const MAX = PHP_INT_MAX; + public static $a1 = array(self::ONE => 'one'); + public static $a2 = array(self::ZERO => 'zero'); + public static $a3 = array(self::MAX => 'zero'); } diff --git a/Zend/tests/bug69025.phpt b/Zend/tests/bug69025.phpt index 389c09f75fb9..8cb5f878f21d 100644 --- a/Zend/tests/bug69025.phpt +++ b/Zend/tests/bug69025.phpt @@ -3,9 +3,9 @@ Bug #69025 (Invalid read of size 4 when calling __callStatic) --FILE-- {$method}(); + $instance->{$method}(); } $instance = new Foo; diff --git a/Zend/tests/bug69167.phpt b/Zend/tests/bug69167.phpt index cae3528406ad..d75f0500fc8d 100644 --- a/Zend/tests/bug69167.phpt +++ b/Zend/tests/bug69167.phpt @@ -3,7 +3,7 @@ Bug #69167 (call_user_func does not support references anymore) --FILE-- ==DONE== diff --git a/Zend/tests/bug69201.phpt b/Zend/tests/bug69201.phpt index 7e2944c49fcd..7a70912cf06b 100644 --- a/Zend/tests/bug69201.phpt +++ b/Zend/tests/bug69201.phpt @@ -5,17 +5,17 @@ Bug #69201 (Memory leak using iterator and get by reference on PHP 7) class Entity { - protected $_properties = []; + protected $_properties = []; - public function &__get($property) - { - $value = null; - return $value; - } + public function &__get($property) + { + $value = null; + return $value; + } - public function __set($property, $value) - { - } + public function __set($property, $value) + { + } } $e = new Entity; diff --git a/Zend/tests/bug69212.phpt b/Zend/tests/bug69212.phpt index 5f20faaf4eb0..418753c3d60e 100644 --- a/Zend/tests/bug69212.phpt +++ b/Zend/tests/bug69212.phpt @@ -22,17 +22,17 @@ try { } try { - $f = function () {}; - $f->__invoke(do_throw()); + $f = function () {}; + $f->__invoke(do_throw()); } catch (Exception $e) { - echo "Caught!\n"; + echo "Caught!\n"; } try { - $t = new Test; - $f->__invoke($t->bar(Test::foo(do_throw()))); + $t = new Test; + $f->__invoke($t->bar(Test::foo(do_throw()))); } catch (Exception $e) { - echo "Caught!\n"; + echo "Caught!\n"; } ?> diff --git a/Zend/tests/bug69221.phpt b/Zend/tests/bug69221.phpt index 72f242f9954b..a681e5bb689a 100644 --- a/Zend/tests/bug69221.phpt +++ b/Zend/tests/bug69221.phpt @@ -4,7 +4,7 @@ Bug #69221: Segmentation fault when using a generator in combination with an Ite test(); - } + use T; + public function foo() { + $this->test(); + } } diff --git a/Zend/tests/bug69427.phpt b/Zend/tests/bug69427.phpt index 6b739df9617f..e482fa85f37f 100644 --- a/Zend/tests/bug69427.phpt +++ b/Zend/tests/bug69427.phpt @@ -9,15 +9,15 @@ class SubClass extends BaseClass abstract class BaseClass { - public function __call($name, $arguments) - { - return $this->$name(); - } + public function __call($name, $arguments) + { + return $this->$name(); + } - private function foobar() - { - return 'okey'; - } + private function foobar() + { + return 'okey'; + } } $test = new SubClass(); diff --git a/Zend/tests/bug69446.phpt b/Zend/tests/bug69446.phpt index 66595c170cb3..e68443b803ae 100644 --- a/Zend/tests/bug69446.phpt +++ b/Zend/tests/bug69446.phpt @@ -6,11 +6,11 @@ zend.enable_gc = 1 y = new stdClass; - } + public function __destruct() { + global $bar; + $bar = $this; + $bar->y = new stdClass; + } } $foo = new stdClass; diff --git a/Zend/tests/bug69446_2.phpt b/Zend/tests/bug69446_2.phpt index b7c6e0e32999..8ef2300e930c 100644 --- a/Zend/tests/bug69446_2.phpt +++ b/Zend/tests/bug69446_2.phpt @@ -7,18 +7,18 @@ zend.enable_gc = 1 $bar = NULL; class bad { - public $_private = array(); + public $_private = array(); - public function __construct() - { - $this->_private[] = 'php'; - } + public function __construct() + { + $this->_private[] = 'php'; + } - public function __destruct() - { - global $bar; - $bar = $this; - } + public function __destruct() + { + global $bar; + $bar = $this; + } } $foo = new stdclass; diff --git a/Zend/tests/bug69676.phpt b/Zend/tests/bug69676.phpt index 54b9d4004740..c18eb8f6015c 100644 --- a/Zend/tests/bug69676.phpt +++ b/Zend/tests/bug69676.phpt @@ -3,12 +3,12 @@ Bug #69676: Resolution of self::FOO in class constants not correct --FILE-- 'bar', $x); } diff --git a/Zend/tests/bug69754.phpt b/Zend/tests/bug69754.phpt index be55ae2b78b7..d496b8913e02 100644 --- a/Zend/tests/bug69754.phpt +++ b/Zend/tests/bug69754.phpt @@ -4,11 +4,11 @@ Bug #69754 (Use of ::class inside array causes compile error) diff --git a/Zend/tests/bug69957.phpt b/Zend/tests/bug69957.phpt index 01b024e77864..188e56405b80 100644 --- a/Zend/tests/bug69957.phpt +++ b/Zend/tests/bug69957.phpt @@ -4,59 +4,59 @@ Bug #69957 (Different ways of handling div/mod by zero) getMessage()); + echo "Variable div\n"; + printf("Type: %s\n", get_class($t)); + printf("Message: %s\n", $t->getMessage()); } try { - $divisor = 0; - $result = 1 % $divisor; - var_dump($result); + $divisor = 0; + $result = 1 % $divisor; + var_dump($result); } catch (DivisionByZeroError $t){ - echo "\nVariable mod\n"; - printf("Type: %s\n", get_class($t)); - printf("Message: %s\n", $t->getMessage()); + echo "\nVariable mod\n"; + printf("Type: %s\n", get_class($t)); + printf("Message: %s\n", $t->getMessage()); } try { - $result = 1 / 0; - var_dump($result); + $result = 1 / 0; + var_dump($result); } catch (DivisionByZeroError $t){ - echo "\nLiteral div\n"; - printf("Type: %s\n", get_class($t)); - printf("Message: %s\n", $t->getMessage()); + echo "\nLiteral div\n"; + printf("Type: %s\n", get_class($t)); + printf("Message: %s\n", $t->getMessage()); } try { - $result = 1 % 0; - var_dump($result); + $result = 1 % 0; + var_dump($result); } catch (DivisionByZeroError $t){ - echo "\nLiteral mod\n"; - printf("Type: %s\n", get_class($t)); - printf("Message: %s\n", $t->getMessage()); + echo "\nLiteral mod\n"; + printf("Type: %s\n", get_class($t)); + printf("Message: %s\n", $t->getMessage()); } try { - $result = 1 / 0.0; - var_dump($result); + $result = 1 / 0.0; + var_dump($result); } catch (DivisionByZeroError $t){ - echo "\nDouble div\n"; - printf("Type: %s\n", get_class($t)); - printf("Message: %s\n", $t->getMessage()); + echo "\nDouble div\n"; + printf("Type: %s\n", get_class($t)); + printf("Message: %s\n", $t->getMessage()); } try { - $result = 1 % 0.0; - var_dump($result); + $result = 1 % 0.0; + var_dump($result); } catch (DivisionByZeroError $t){ - echo "\nDouble mod\n"; - printf("Type: %s\n", get_class($t)); - printf("Message: %s\n", $t->getMessage()); + echo "\nDouble mod\n"; + printf("Type: %s\n", get_class($t)); + printf("Message: %s\n", $t->getMessage()); } ?> diff --git a/Zend/tests/bug69996.phpt b/Zend/tests/bug69996.phpt index 178e36837ac3..f9044677cd4c 100644 --- a/Zend/tests/bug69996.phpt +++ b/Zend/tests/bug69996.phpt @@ -4,17 +4,17 @@ Bug #69996 (Changing the property of a cloned object affects the original) data); - $prepared->data = "bad"; - return $prepared; + $prepared = clone $cache; + var_dump($prepared->data); + $prepared->data = "bad"; + return $prepared; } $cache = new stdClass(); $cache->data = "good"; for ($i = 0; $i < 5; ++$i) { - method($cache); + method($cache); } ?> --EXPECT-- diff --git a/Zend/tests/bug70012.phpt b/Zend/tests/bug70012.phpt index 9e532218a917..3892fefcf2d5 100644 --- a/Zend/tests/bug70012.phpt +++ b/Zend/tests/bug70012.phpt @@ -3,23 +3,23 @@ Bug #70012 (Exception lost with nested finally block) --FILE-- --EXPECT-- diff --git a/Zend/tests/bug70083.phpt b/Zend/tests/bug70083.phpt index 5bc3656e9fca..691e6a412510 100644 --- a/Zend/tests/bug70083.phpt +++ b/Zend/tests/bug70083.phpt @@ -4,10 +4,10 @@ Bug #70083 (Use after free with assign by ref to overloaded objects) getMessage()); + var_dump($e->getMessage()); } try { - unset(chr(0)[0][0]); + unset(chr(0)[0][0]); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } eval("function runtimetest(&\$a) {} "); try { - runtimetest(chr(0)[0]); + runtimetest(chr(0)[0]); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - ++chr(0)[0]; + ++chr(0)[0]; } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> --EXPECT-- diff --git a/Zend/tests/bug70117.phpt b/Zend/tests/bug70117.phpt index 4bdd12caef99..cc46be64587a 100644 --- a/Zend/tests/bug70117.phpt +++ b/Zend/tests/bug70117.phpt @@ -4,14 +4,14 @@ Bug #70117 (Unexpected return type error) getMessage()); + var_dump($e->getMessage()); } class A { } try { - echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),a::y("test"))],chr(48)); + echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),a::y("test"))],chr(48)); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } $a = new A; try { - echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),$a->y("test"))],chr(48)); + echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),$a->y("test"))],chr(48)); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),\bar\y("test"))],chr(48)); + echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),\bar\y("test"))],chr(48)); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),y("test"))],chr(48)); + echo base_convert([array_search(chr(48),chr(48),chr(48),chr(48),chr(48),y("test"))],chr(48)); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> --EXPECTF-- diff --git a/Zend/tests/bug70156.phpt b/Zend/tests/bug70156.phpt index 6b5e38333742..0d20b3818125 100644 --- a/Zend/tests/bug70156.phpt +++ b/Zend/tests/bug70156.phpt @@ -3,30 +3,30 @@ Bug #70156 (Segfault in zend_find_alias_name) --FILE-- bar(); - } + protected function foo1() + { + $this->bar(); + } } trait T2 { - protected function foo2() - { - debug_print_backtrace(); - } + protected function foo2() + { + debug_print_backtrace(); + } } class dummy { - use T1 { - foo1 as private; - } - use T2 { - foo2 as bar; - } - public function __construct() - { - $this->foo1(); - } + use T1 { + foo1 as private; + } + use T2 { + foo2 as bar; + } + public function __construct() + { + $this->foo1(); + } } new dummy(); diff --git a/Zend/tests/bug70164.phpt b/Zend/tests/bug70164.phpt index 7777be4ee085..258d59442125 100644 --- a/Zend/tests/bug70164.phpt +++ b/Zend/tests/bug70164.phpt @@ -4,14 +4,14 @@ __COMPILER_HALT_OFFSET__ is a "magic" constant, which should work if referenced arr["no_pack"] = 1; - while (1) { - $this->arr[] = 1; - } - } + public $arr; + public function core() { + $this->arr["no_pack"] = 1; + while (1) { + $this->arr[] = 1; + } + } } $a = new A; diff --git a/Zend/tests/bug70288.phpt b/Zend/tests/bug70288.phpt index 4b55d0b4769f..502bfc7bf006 100644 --- a/Zend/tests/bug70288.phpt +++ b/Zend/tests/bug70288.phpt @@ -3,13 +3,13 @@ Bug #70288 (Apache crash related to ZEND_SEND_REF) --FILE-- dummy); diff --git a/Zend/tests/bug70321.phpt b/Zend/tests/bug70321.phpt index 19f691f41848..6e490555be4d 100644 --- a/Zend/tests/bug70321.phpt +++ b/Zend/tests/bug70321.phpt @@ -4,27 +4,27 @@ bug #70321 (Magic getter breaks reference to array property) bar = new bar(); - } - public function & __get($key) - { - $bar = $this->bar; - return $bar; - } + private $bar; + public function __construct() + { + $this->bar = new bar(); + } + public function & __get($key) + { + $bar = $this->bar; + return $bar; + } - public function & offsetGet($key) { - $bar = $this->bar; - return $bar; - } - public function offsetSet($key, $val) { - } - public function offsetUnset($key) { - } - public function offsetExists($key) { - } + public function & offsetGet($key) { + $bar = $this->bar; + return $bar; + } + public function offsetSet($key, $val) { + } + public function offsetUnset($key) { + } + public function offsetExists($key) { + } } class bar { public $onBaz = []; } diff --git a/Zend/tests/bug70332.phpt b/Zend/tests/bug70332.phpt index 217070f133aa..f078a65a2f22 100644 --- a/Zend/tests/bug70332.phpt +++ b/Zend/tests/bug70332.phpt @@ -3,7 +3,7 @@ Bug #70332 (Wrong behavior while returning reference on object) --FILE-- a **= $this->b; - } + function __construct() { + $this->a **= $this->b; + } } $a = new foo; diff --git a/Zend/tests/bug70547.phpt b/Zend/tests/bug70547.phpt index f793e70781cd..d185cbc3a6f9 100644 --- a/Zend/tests/bug70547.phpt +++ b/Zend/tests/bug70547.phpt @@ -3,29 +3,29 @@ Bug #70547 (unsetting function variables corrupts backtrace) --FILE-- --EXPECT-- diff --git a/Zend/tests/bug70689.phpt b/Zend/tests/bug70689.phpt index 882dd89b75c9..d1895cf39e54 100644 --- a/Zend/tests/bug70689.phpt +++ b/Zend/tests/bug70689.phpt @@ -4,17 +4,17 @@ Bug #70689 (Exception handler does not work as expected) getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/Zend/tests/bug70785.phpt b/Zend/tests/bug70785.phpt index f48bc3cdb99e..05b1b6afa0a0 100644 --- a/Zend/tests/bug70785.phpt +++ b/Zend/tests/bug70785.phpt @@ -4,19 +4,19 @@ Bug #70785 (Infinite loop due to exception during identical comparison) diff --git a/Zend/tests/bug70805.phpt b/Zend/tests/bug70805.phpt index 1177233184a9..86c8a2c800aa 100644 --- a/Zend/tests/bug70805.phpt +++ b/Zend/tests/bug70805.phpt @@ -9,12 +9,12 @@ class B { } class C { - public function __destruct() { - if (isset($GLOBALS["a"])) { - unset($GLOBALS["array"]); - unset($GLOBALS["a"]); // this will be called in gc_colloct_roots and put $a into gc roots buf - } - } + public function __destruct() { + if (isset($GLOBALS["a"])) { + unset($GLOBALS["array"]); + unset($GLOBALS["a"]); // this will be called in gc_colloct_roots and put $a into gc roots buf + } + } } $a = new A; @@ -28,9 +28,9 @@ $array = array($c); //This is used to leave a room for $GLOBALS["a"] unset($c); while ($i++ < 9998) { - $t = []; - $t[] = &$t; - unset($t); + $t = []; + $t[] = &$t; + unset($t); } $t = [new C]; $t[] = &$t; @@ -39,7 +39,7 @@ unset($t); // This is used to trigger C::__destruct while doing gc_colloct_roots $e = $a; unset($a); // This one can not be putted into roots buf because it's full, thus gc_colloct_roots will be called, // but C::__destructor which is called in gc_colloct_roots will put $a into buf - // which will make $a be putted into gc roots buf twice + // which will make $a be putted into gc roots buf twice var_dump(gc_collect_cycles()); ?> --EXPECT-- diff --git a/Zend/tests/bug70805_1.phpt b/Zend/tests/bug70805_1.phpt index 035ec6884fc3..7d699e25e396 100644 --- a/Zend/tests/bug70805_1.phpt +++ b/Zend/tests/bug70805_1.phpt @@ -11,12 +11,12 @@ class B { } class C { - public function __destruct() { - if (isset($GLOBALS["a"])) { - unset($GLOBALS["array"]); - unset($GLOBALS["a"]); - } - } + public function __destruct() { + if (isset($GLOBALS["a"])) { + unset($GLOBALS["array"]); + unset($GLOBALS["a"]); + } + } } $a = new A; @@ -30,9 +30,9 @@ $array = array($c); unset($c); while ($i++ < 9998) { - $t = []; - $t[] = &$t; - unset($t); + $t = []; + $t[] = &$t; + unset($t); } $t = [new C]; $t[] = &$t; diff --git a/Zend/tests/bug70805_2.phpt b/Zend/tests/bug70805_2.phpt index a4d01aa626de..b33d47a6a9f0 100644 --- a/Zend/tests/bug70805_2.phpt +++ b/Zend/tests/bug70805_2.phpt @@ -11,11 +11,11 @@ class B { } class C { - public function __destruct() { - if (isset($GLOBALS["a"])) { - unset($GLOBALS["a"]); - } - } + public function __destruct() { + if (isset($GLOBALS["a"])) { + unset($GLOBALS["a"]); + } + } } $a = new A; @@ -25,9 +25,9 @@ $a->b->a = $a; $i = 0; while ($i++ < 9999) { - $t = []; - $t[] = &$t; - unset($t); + $t = []; + $t[] = &$t; + unset($t); } $t = [new C]; $t[] = &$t; diff --git a/Zend/tests/bug70873.phpt b/Zend/tests/bug70873.phpt index aecc0e879bcc..fd6274c4d2be 100644 --- a/Zend/tests/bug70873.phpt +++ b/Zend/tests/bug70873.phpt @@ -4,19 +4,19 @@ Bug #70873 (Regression on private static properties access) --EXPECTF-- diff --git a/Zend/tests/bug70918.phpt b/Zend/tests/bug70918.phpt index 81e2192d8a47..d376d2147a95 100644 --- a/Zend/tests/bug70918.phpt +++ b/Zend/tests/bug70918.phpt @@ -3,39 +3,39 @@ Bug #70918 (Segfault using static outside of class scope) --FILE-- getMessage()); + var_dump($e->getMessage()); } try { - parent::x; + parent::x; } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - self::x; + self::x; } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - new static; + new static; } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - static::x(); + static::x(); } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - static::$i; + static::$i; } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> --EXPECT-- diff --git a/Zend/tests/bug70944.phpt b/Zend/tests/bug70944.phpt index afb10bc27f00..6a617f5e465c 100644 --- a/Zend/tests/bug70944.phpt +++ b/Zend/tests/bug70944.phpt @@ -3,25 +3,25 @@ Bug #70944 (try{ } finally{} can create infinite chains of exceptions) --FILE-- --EXPECTF-- diff --git a/Zend/tests/bug70958.phpt b/Zend/tests/bug70958.phpt index faa75e0b16b6..5a0d605ad39c 100644 --- a/Zend/tests/bug70958.phpt +++ b/Zend/tests/bug70958.phpt @@ -4,13 +4,13 @@ Bug #70958 (Invalid opcode while using ::class as trait method parameter default [] - ]; - $arr->children[] = 1; - return $arr; - } + public function test(){ + $arr = (object) [ + 'children' => [] + ]; + $arr->children[] = 1; + return $arr; + } } $o = new Test(); diff --git a/Zend/tests/bug71163.phpt b/Zend/tests/bug71163.phpt index f87b95148075..71470027ba44 100644 --- a/Zend/tests/bug71163.phpt +++ b/Zend/tests/bug71163.phpt @@ -3,20 +3,20 @@ Bug #71163 (Segmentation Fault (cleanup_unfinished_calls)) --FILE-- bar); - $vars = get_object_vars($this); - $this->bar[] = array('buz'); - print_r($vars); - } + function bar() + { + array_pop($this->bar); + $vars = get_object_vars($this); + $this->bar[] = array('buz'); + print_r($vars); + } - function foo() { - array_pop($this->bar); - $dummy = &$this->bar; - $vars = get_object_vars($this); - $this->bar[] = array('buz'); - print_r($vars); - } + function foo() { + array_pop($this->bar); + $dummy = &$this->bar; + $vars = get_object_vars($this); + $this->bar[] = array('buz'); + print_r($vars); + } } (new A())->bar(); diff --git a/Zend/tests/bug71428.2.phpt b/Zend/tests/bug71428.2.phpt index 0056bd8144a7..9cc7304e4a56 100644 --- a/Zend/tests/bug71428.2.phpt +++ b/Zend/tests/bug71428.2.phpt @@ -5,13 +5,13 @@ bug #71428.2: inheritance of ye olde dynamic interfaces --FILE-- 0) { - $x->bug(); - test($n - 1, $x); - } + if ($n > 0) { + $x->bug(); + test($n - 1, $x); + } } test(3000, new foo()); diff --git a/Zend/tests/bug71622.phpt b/Zend/tests/bug71622.phpt index 3ef0ba80e1e2..c23547788a03 100644 --- a/Zend/tests/bug71622.phpt +++ b/Zend/tests/bug71622.phpt @@ -4,22 +4,22 @@ Bug #71622 (Strings used in pass-as-reference cannot be used to invoke C::$calla "foo"); + var_dump(array_key_exists("foo", $GLOBALS)); + var_dump(isset($GLOBALS["foo"])); + $GLOBALS += array("foo" => "foo"); } provideGlobals(); diff --git a/Zend/tests/bug71756.phpt b/Zend/tests/bug71756.phpt index 1f43c082f0eb..9bf88c079232 100644 --- a/Zend/tests/bug71756.phpt +++ b/Zend/tests/bug71756.phpt @@ -3,20 +3,20 @@ Bug #71756 (Call-by-reference widens scope to uninvolved functions when used in --FILE-- 'false')); ?> diff --git a/Zend/tests/bug71914.phpt b/Zend/tests/bug71914.phpt index a43eb56bbd68..d7cae342f687 100644 --- a/Zend/tests/bug71914.phpt +++ b/Zend/tests/bug71914.phpt @@ -4,26 +4,26 @@ Bug #71914 (Reference is lost in "switch") "xxxx"); + public $array = array("str" => "xxxx"); } function test($arr, &$dummy) { - bug($arr["str"]); - var_dump($arr["str"]); + bug($arr["str"]); + var_dump($arr["str"]); } $foo = new Foo(); diff --git a/Zend/tests/bug71930.phpt b/Zend/tests/bug71930.phpt index 40348cc9043e..1aa64bf58326 100644 --- a/Zend/tests/bug71930.phpt +++ b/Zend/tests/bug71930.phpt @@ -10,8 +10,8 @@ if (!extension_loaded("curl")) { $foo, - $bar + '' => $foo, + $bar ) = $array; ?> --EXPECTF-- diff --git a/Zend/tests/bug72508.phpt b/Zend/tests/bug72508.phpt index b39aa16d02a3..86ad749a407d 100644 --- a/Zend/tests/bug72508.phpt +++ b/Zend/tests/bug72508.phpt @@ -3,20 +3,20 @@ Bug #72508 (strange references after recursive function call and "switch" statem --FILE-- 'fasel')); diff --git a/Zend/tests/bug72594.phpt b/Zend/tests/bug72594.phpt index c67e68e4ac80..5ffbe1ef344d 100644 --- a/Zend/tests/bug72594.phpt +++ b/Zend/tests/bug72594.phpt @@ -5,12 +5,12 @@ opcache.enable=0 --FILE-- bing(); - } - }; + return new class { + public $bar; + public function bing($foo = null) { + if ($foo) $foo->bing(); + } + }; } $runtime = 1; diff --git a/Zend/tests/bug72598.phpt b/Zend/tests/bug72598.phpt index dfb09a05b8f5..eeee51027949 100644 --- a/Zend/tests/bug72598.phpt +++ b/Zend/tests/bug72598.phpt @@ -3,7 +3,7 @@ Bug #72598 (Reference is lost after array_slice()) --FILE-- x; + $c = new C; + $b = clone $c->x; } test_clone(); diff --git a/Zend/tests/bug73663.phpt b/Zend/tests/bug73663.phpt index 06dd7f6700fe..85b61b0f4671 100644 --- a/Zend/tests/bug73663.phpt +++ b/Zend/tests/bug73663.phpt @@ -3,12 +3,12 @@ Bug #73663 ("Invalid opcode 65/16/8" occurs with a variable created with list()) --FILE-- --EXPECTF-- diff --git a/Zend/tests/bug73989.phpt b/Zend/tests/bug73989.phpt index 48e5a7a73428..04d776cb9e3d 100644 --- a/Zend/tests/bug73989.phpt +++ b/Zend/tests/bug73989.phpt @@ -8,13 +8,13 @@ class Cycle public function __construct() { - $obj = $this; + $obj = $this; $this->thing = function() use($obj) {}; } public function __destruct() { - ($this->thing)(); + ($this->thing)(); } } diff --git a/Zend/tests/bug74053.phpt b/Zend/tests/bug74053.phpt index b1936a58e9e2..16d430405bd6 100644 --- a/Zend/tests/bug74053.phpt +++ b/Zend/tests/bug74053.phpt @@ -4,7 +4,7 @@ Bug #74053 (Corrupted class entries on shutdown when a destructor spawns another "bar"]; + public $options = [self::FOO => "bar"]; } try { - var_dump((new C)->options); + var_dump((new C)->options); } catch (Throwable $e) {} var_dump((new C)->options); diff --git a/Zend/tests/bug74840.phpt b/Zend/tests/bug74840.phpt index 68e27cba8404..713e7908ddc3 100644 --- a/Zend/tests/bug74840.phpt +++ b/Zend/tests/bug74840.phpt @@ -4,13 +4,13 @@ Bug #74840: Opcache overwrites argument of GENERATOR_RETURN within finally next(); var_dump($g->getReturn()); diff --git a/Zend/tests/bug75420.1.phpt b/Zend/tests/bug75420.1.phpt index 80e951ac9ed7..fe7fbabcc593 100644 --- a/Zend/tests/bug75420.1.phpt +++ b/Zend/tests/bug75420.1.phpt @@ -3,8 +3,8 @@ Bug #75420.1 (Indirect modification of magic method argument) --FILE-- _stdObject = new stdClass; } - function &__get($property) - { - if (isset($this->_stdObject->{$property})) { - $retval =& $this->_stdObject->{$property}; - return $retval; - } else { - return NULL; - } - } - function &__set($property, $value) - { - return $this->_stdObject->{$property} = $value; - } - function __isset($property_name) - { - return isset($this->_stdObject->{$property_name}); - } + function &__get($property) + { + if (isset($this->_stdObject->{$property})) { + $retval =& $this->_stdObject->{$property}; + return $retval; + } else { + return NULL; + } + } + function &__set($property, $value) + { + return $this->_stdObject->{$property} = $value; + } + function __isset($property_name) + { + return isset($this->_stdObject->{$property_name}); + } } class B extends A { - function &__get($property) - { - if (isset($this->settings) && isset($this->settings[$property])) { - $retval =& $this->settings[$property]; - return $retval; - } else { - return parent::__get($property); - } - } + function &__get($property) + { + if (isset($this->settings) && isset($this->settings[$property])) { + $retval =& $this->settings[$property]; + return $retval; + } else { + return parent::__get($property); + } + } } $b = new B(); diff --git a/Zend/tests/bug76025.phpt b/Zend/tests/bug76025.phpt index 903cec260753..ba89e8a3f9ec 100644 --- a/Zend/tests/bug76025.phpt +++ b/Zend/tests/bug76025.phpt @@ -4,8 +4,8 @@ Bug #76025 (Segfault while throwing exception in error_handler) $k; - } - - public function __set($k, $v) - { - return $this->$v /= 0; - } + public function __get($k) + { + return $undefined->$k; + } + + public function __set($k, $v) + { + return $this->$v /= 0; + } }; $x = new T; diff --git a/Zend/tests/bug76754.phpt b/Zend/tests/bug76754.phpt index 424f1fbffc64..5cdac04fcf24 100644 --- a/Zend/tests/bug76754.phpt +++ b/Zend/tests/bug76754.phpt @@ -8,7 +8,7 @@ opcache.enable_cli=0 class FOO { - private const FOO = 'BAR'; + private const FOO = 'BAR'; } class BAR extends FOO { } diff --git a/Zend/tests/bug76860.phpt b/Zend/tests/bug76860.phpt index 67baa3996fe2..defe6153ba69 100644 --- a/Zend/tests/bug76860.phpt +++ b/Zend/tests/bug76860.phpt @@ -7,7 +7,7 @@ class A { protected static $b = "b"; public static $c = "c"; public function __construct() { - var_dump($this->a, $this->b, $this->c); + var_dump($this->a, $this->b, $this->c); } } class B extends A { diff --git a/Zend/tests/bug76860_2.phpt b/Zend/tests/bug76860_2.phpt index 1ab85f69f266..2a64a97c2f4f 100644 --- a/Zend/tests/bug76860_2.phpt +++ b/Zend/tests/bug76860_2.phpt @@ -7,7 +7,7 @@ class A { private static $b = "b"; private static $c = "c"; public function __construct() { - var_dump($this->a, $this->b, $this->c); + var_dump($this->a, $this->b, $this->c); } } class B extends A { diff --git a/Zend/tests/bug76869.phpt b/Zend/tests/bug76869.phpt index 0193bf21028a..825bed0eb1b9 100644 --- a/Zend/tests/bug76869.phpt +++ b/Zend/tests/bug76869.phpt @@ -3,20 +3,20 @@ Bug #76869 (Incorrect bypassing protected method accessibility check) --FILE-- f()); + var_dump($b->f()); } catch (Throwable $e) { - echo "Exception: ", $e->getMessage(), "\n"; + echo "Exception: ", $e->getMessage(), "\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug76965.phpt b/Zend/tests/bug76965.phpt index ce157733a5f1..64165e81f691 100644 --- a/Zend/tests/bug76965.phpt +++ b/Zend/tests/bug76965.phpt @@ -4,10 +4,10 @@ Bug #76965 (INI_SCANNER_RAW doesn't strip trailing whitespace) getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - call_user_func([new Foo, 'bar']); + call_user_func([new Foo, 'bar']); } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/Zend/tests/bug78379.phpt b/Zend/tests/bug78379.phpt index e48e9b7ca4c4..ebe0d1e329cf 100644 --- a/Zend/tests/bug78379.phpt +++ b/Zend/tests/bug78379.phpt @@ -5,9 +5,9 @@ opcache.enable=0 --FILE-- p = (object)["x" => [1]]; - } + public function __construct() { + $this->p = (object)["x" => [1]]; + } } class E { } diff --git a/Zend/tests/bug78379_2.phpt b/Zend/tests/bug78379_2.phpt index 0a515a2b0711..b1e7e3527f4d 100644 --- a/Zend/tests/bug78379_2.phpt +++ b/Zend/tests/bug78379_2.phpt @@ -4,12 +4,12 @@ Bug #78379.2 (Cast to object confuses GC, causes crash) $e2]; - $e1->a = (object)$a; - $e2->e1 = $e1; - $e2->a = (object)$a; + $e1 = new E; + $e2 = new E; + $a = ['e2' => $e2]; + $e1->a = (object)$a; + $e2->e1 = $e1; + $e2->a = (object)$a; } f(); gc_collect_cycles(); diff --git a/Zend/tests/bug78396.phpt b/Zend/tests/bug78396.phpt index 1f08a47dc41b..f5d8281941c1 100644 --- a/Zend/tests/bug78396.phpt +++ b/Zend/tests/bug78396.phpt @@ -2,7 +2,7 @@ Bug #78396: Second file_put_contents in Shutdown hangs script --FILE-- private++; //fails with EG(fake_scope) != NULL && EG(fake_scope) != "C" - } + function foo() { + $this->private++; //fails with EG(fake_scope) != NULL && EG(fake_scope) != "C" + } } class A { - static $foo = B::foo; //not resolved on include() + static $foo = B::foo; //not resolved on include() } function main_autoload($class_name) { - $c = new C; - $c->foo(); - //doesn't affect the error - eval("class B {const foo = 1;}"); + $c = new C; + $c->foo(); + //doesn't affect the error + eval("class B {const foo = 1;}"); } spl_autoload_register('main_autoload', false); diff --git a/Zend/tests/bug78898.phpt b/Zend/tests/bug78898.phpt index 9efd1416e205..248195e551ec 100644 --- a/Zend/tests/bug78898.phpt +++ b/Zend/tests/bug78898.phpt @@ -5,25 +5,25 @@ Bug #78898: call_user_func(['parent', ...]) fails while other succeed class A { - protected function _x() - { - echo "a"; - } + protected function _x() + { + echo "a"; + } - public function __call($methodName, array $arguments) - { - throw new Exception("Unknown method."); - } + public function __call($methodName, array $arguments) + { + throw new Exception("Unknown method."); + } } class B extends A { - public function x() - { - parent::_x(); - call_user_func('parent::_x'); - call_user_func(['parent', '_x']); - } + public function x() + { + parent::_x(); + call_user_func('parent::_x'); + call_user_func(['parent', '_x']); + } } $b = new B; diff --git a/Zend/tests/bug78999.phpt b/Zend/tests/bug78999.phpt index d4ec16b972b8..e44a38f07794 100644 --- a/Zend/tests/bug78999.phpt +++ b/Zend/tests/bug78999.phpt @@ -3,9 +3,9 @@ Bug #78999 (Cycle leak when using function result as temporary) --FILE-- prop = $t; - return $t; + $t = new stdClass; + $t->prop = $t; + return $t; } var_dump(get()); var_dump(gc_collect_cycles()); diff --git a/Zend/tests/bug79022.phpt b/Zend/tests/bug79022.phpt index 0657b20355e4..904195518ee5 100644 --- a/Zend/tests/bug79022.phpt +++ b/Zend/tests/bug79022.phpt @@ -4,31 +4,31 @@ Bug #79022 (class_exists returns True for classes that are not ready to be used) fOoBaR(); - self::foOBAr(); - $this::fOOBAr(); - } + public function __call($a, $b) { + print "nonstatic\n"; + var_dump($a); + } + static public function __callStatic($a, $b) { + print "static\n"; + var_dump($a); + } + public function test() { + $this->fOoBaR(); + self::foOBAr(); + $this::fOOBAr(); + } } $a = new Foo; diff --git a/Zend/tests/call_static_004.phpt b/Zend/tests/call_static_004.phpt index af53afb12be5..af49b1b2a288 100644 --- a/Zend/tests/call_static_004.phpt +++ b/Zend/tests/call_static_004.phpt @@ -4,9 +4,9 @@ Invalid method name in dynamic static call getMessage(), "\n"; } - try { + try { call_user_func(array(new $class, 'prot'), 'foobar'); } catch (\TypeError $e) { echo $e->getMessage(), "\n"; diff --git a/Zend/tests/call_user_func_003.phpt b/Zend/tests/call_user_func_003.phpt index 1aad22fba756..b501d803e776 100644 --- a/Zend/tests/call_user_func_003.phpt +++ b/Zend/tests/call_user_func_003.phpt @@ -4,15 +4,15 @@ Testing call_user_func() with closures __invoke()); diff --git a/Zend/tests/call_user_func_005.phpt b/Zend/tests/call_user_func_005.phpt index 13d69fd60d3f..fd130eb773a4 100644 --- a/Zend/tests/call_user_func_005.phpt +++ b/Zend/tests/call_user_func_005.phpt @@ -4,14 +4,14 @@ Passing Closure as parameter to an non-existent function --EXPECT-- diff --git a/Zend/tests/class_alias_005.phpt b/Zend/tests/class_alias_005.phpt index ecc96c8cfa29..15f5b28d50dc 100644 --- a/Zend/tests/class_alias_005.phpt +++ b/Zend/tests/class_alias_005.phpt @@ -4,9 +4,9 @@ Testing static call method using the original class name DATA; @@ -15,7 +15,7 @@ $filename = __DIR__."/cc003.dat"; file_put_contents($filename, $class_data); function foo($v = test::val) { - var_dump($v); + var_dump($v); } include $filename; diff --git a/Zend/tests/class_constants_004.phpt b/Zend/tests/class_constants_004.phpt index 1ca49ebdf00e..7f1247e6fd01 100644 --- a/Zend/tests/class_constants_004.phpt +++ b/Zend/tests/class_constants_004.phpt @@ -10,26 +10,26 @@ define('foo', 3); const foo = 1; class foo { - const foo = 2; + const foo = 2; } interface Ifoo { - const foo = 4; + const foo = 4; } $const = __NAMESPACE__ .'\\foo'; // class $const2 = __NAMESPACE__ .'\\Ifoo'; // interface var_dump( foo, - \foo\foo, - namespace\foo, - \foo\foo::foo, - $const::foo, - \foo, - constant('foo'), - Ifoo::foo, - $const2::foo - ); + \foo\foo, + namespace\foo, + \foo\foo::foo, + $const::foo, + \foo, + constant('foo'), + Ifoo::foo, + $const2::foo + ); ?> --EXPECT-- diff --git a/Zend/tests/class_properties_dynamic.phpt b/Zend/tests/class_properties_dynamic.phpt index 456bcf4a5b5b..db8ed9b7d0af 100644 --- a/Zend/tests/class_properties_dynamic.phpt +++ b/Zend/tests/class_properties_dynamic.phpt @@ -3,9 +3,9 @@ Class Property Expressions --FILE-- bar; ?> diff --git a/Zend/tests/class_properties_static.phpt b/Zend/tests/class_properties_static.phpt index 9a56466340c1..309c0f7ef444 100644 --- a/Zend/tests/class_properties_static.phpt +++ b/Zend/tests/class_properties_static.phpt @@ -3,15 +3,15 @@ Static Class Property Expressions --FILE-- b1, - $f->b2, - $f->b3 + $f->b1, + $f->b2, + $f->b3 ); ?> --EXPECT-- diff --git a/Zend/tests/clone_004.phpt b/Zend/tests/clone_004.phpt index c97bb032c005..812eb6dfdd99 100644 --- a/Zend/tests/clone_004.phpt +++ b/Zend/tests/clone_004.phpt @@ -4,9 +4,9 @@ Testing usage of object as array on clone statement x = $x; - } - - function __destruct() { - echo "Destroyed\n"; - } - - function getIncer($val) { - return function() use ($val) { - $this->x += $val; - }; - } - - function getPrinter() { - return function() { - echo $this->x."\n"; - }; - } - - function getError() { - return static function() { - echo $this->x."\n"; - }; - } - - function printX() { - echo $this->x."\n"; - } + private $x; + + function __construct($x) { + $this->x = $x; + } + + function __destruct() { + echo "Destroyed\n"; + } + + function getIncer($val) { + return function() use ($val) { + $this->x += $val; + }; + } + + function getPrinter() { + return function() { + echo $this->x."\n"; + }; + } + + function getError() { + return static function() { + echo $this->x."\n"; + }; + } + + function printX() { + echo $this->x."\n"; + } } $a = new A(3); diff --git a/Zend/tests/closure_006.phpt b/Zend/tests/closure_006.phpt index aa0ec1199502..a3707cb1f791 100644 --- a/Zend/tests/closure_006.phpt +++ b/Zend/tests/closure_006.phpt @@ -4,9 +4,9 @@ Closure 006: Nested lambdas x++; - }; - }; - } + function getClosureGetter () { + return function () { + return function () { + $this->x++; + }; + }; + } - function printX () { - echo $this->x."\n"; - } + function printX () { + echo $this->x."\n"; + } } $a = new A; diff --git a/Zend/tests/closure_008.phpt b/Zend/tests/closure_008.phpt index 64c7e659e694..238bbea002d8 100644 --- a/Zend/tests/closure_008.phpt +++ b/Zend/tests/closure_008.phpt @@ -4,10 +4,10 @@ Closure 008: Use in preg_replace_callback() __invoke(); diff --git a/Zend/tests/closure_014.phpt b/Zend/tests/closure_014.phpt index 9e4819b9dd82..fbd1109dc897 100644 --- a/Zend/tests/closure_014.phpt +++ b/Zend/tests/closure_014.phpt @@ -3,18 +3,18 @@ Closure 014: return by value/reference --FILE-- __invoke()); $x(); $x->__invoke(); $x = function() { - return 0; + return 0; }; var_dump($x()); var_dump($x->__invoke()); @@ -41,7 +41,7 @@ var_dump($b); $x($b); $x->__invoke($b); $x = function & (&$a) { - return $a; + return $a; }; $e =& $x($c); $e = 4; diff --git a/Zend/tests/closure_016.phpt b/Zend/tests/closure_016.phpt index ae0036586ce1..0f87f20f435a 100644 --- a/Zend/tests/closure_016.phpt +++ b/Zend/tests/closure_016.phpt @@ -3,15 +3,15 @@ Closure 016: closures and is_callable() --FILE-- a = function() use (&$a) { return $a; }; - var_dump($this->a->__invoke()); - var_dump(is_a($this->a, 'closure')); - var_dump(is_callable($this->a)); + public function x() { + $a = &$this; + $this->a = function() use (&$a) { return $a; }; + var_dump($this->a->__invoke()); + var_dump(is_a($this->a, 'closure')); + var_dump(is_callable($this->a)); - return $this->a; - } + return $this->a; + } } $foo = new foo; diff --git a/Zend/tests/closure_021.phpt b/Zend/tests/closure_021.phpt index 76be762f0828..95ff7d889f9e 100644 --- a/Zend/tests/closure_021.phpt +++ b/Zend/tests/closure_021.phpt @@ -4,17 +4,17 @@ Closure 021: Throwing exception inside lambda getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/Zend/tests/closure_026.phpt b/Zend/tests/closure_026.phpt index 50c850e787c3..62702a5e03d6 100644 --- a/Zend/tests/closure_026.phpt +++ b/Zend/tests/closure_026.phpt @@ -4,17 +4,17 @@ Closure 026: Assigning a closure object to an array in $this a[] = function() { - return 1; - }; + $a->a[] = function() { + return 1; + }; - var_dump($this); + var_dump($this); - var_dump($this->a[0]()); - } + var_dump($this->a[0]()); + } } $x = new foo; @@ -22,8 +22,8 @@ $x = new foo; print "--------------\n"; foreach ($x as $b => $c) { - var_dump($b, $c); - var_dump($c[0]()); + var_dump($b, $c); + var_dump($c[0]()); } ?> diff --git a/Zend/tests/closure_027.phpt b/Zend/tests/closure_027.phpt index 9fc29a4f18aa..ab5fde202679 100644 --- a/Zend/tests/closure_027.phpt +++ b/Zend/tests/closure_027.phpt @@ -4,7 +4,7 @@ Closure 027: Testing Closure type-hint getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } test(new stdclass); diff --git a/Zend/tests/closure_028.phpt b/Zend/tests/closure_028.phpt index c28849f44818..2449f2bfdcc9 100644 --- a/Zend/tests/closure_028.phpt +++ b/Zend/tests/closure_028.phpt @@ -4,7 +4,7 @@ Closure 028: Trying to use lambda directly in foreach a); + var_dump($foo->a); } catch (Error $ex) { - echo "Error: {$ex->getMessage()}\n"; + echo "Error: {$ex->getMessage()}\n"; } ?> --EXPECT-- diff --git a/Zend/tests/closure_033.phpt b/Zend/tests/closure_033.phpt index c83a53898d4f..d86f59068255 100644 --- a/Zend/tests/closure_033.phpt +++ b/Zend/tests/closure_033.phpt @@ -4,15 +4,15 @@ Closure 033: Dynamic closure property and private function func = function() { - echo __METHOD__ . "()\n"; - }; - } - private function func() { - echo __METHOD__ . "()\n"; - } + public $func; + function __construct() { + $this->func = function() { + echo __METHOD__ . "()\n"; + }; + } + private function func() { + echo __METHOD__ . "()\n"; + } } $o = new Test; diff --git a/Zend/tests/closure_035.phpt b/Zend/tests/closure_035.phpt index d06d0bb25bde..14c11a82196a 100644 --- a/Zend/tests/closure_035.phpt +++ b/Zend/tests/closure_035.phpt @@ -4,11 +4,11 @@ Testing recursion detection with Closures x = $v; - } + public function __construct($v) { + $this->x = $v; + } - public function getIncrementor() { - return function() { return ++$this->x; }; - } + public function getIncrementor() { + return function() { return ++$this->x; }; + } } $a = new A(0); diff --git a/Zend/tests/closure_037.phpt b/Zend/tests/closure_037.phpt index 1257d6bc7e81..ba4cfd64646b 100644 --- a/Zend/tests/closure_037.phpt +++ b/Zend/tests/closure_037.phpt @@ -3,30 +3,30 @@ Closure 037: self:: and static:: within closures --FILE-- x++; - self::printX(); - self::print42(); - static::print42(); - }; - } + function getClosure () { + return function () { + $this->x++; + self::printX(); + self::print42(); + static::print42(); + }; + } - function printX () { - echo $this->x."\n"; - } + function printX () { + echo $this->x."\n"; + } - function print42() { - echo "42\n"; - } + function print42() { + echo "42\n"; + } } class B extends A { - function print42() { - echo "forty two\n"; - } + function print42() { + echo "forty two\n"; + } } $a = new A; diff --git a/Zend/tests/closure_038.phpt b/Zend/tests/closure_038.phpt index d1ec446c9d2e..b89ff93c4f44 100644 --- a/Zend/tests/closure_038.phpt +++ b/Zend/tests/closure_038.phpt @@ -4,22 +4,22 @@ Closure 038: Rebinding closures, change scope, different runtime type x = $v; - } + public function __construct($v) { + $this->x = $v; + } - public function getIncrementor() { - return function() { return ++$this->x; }; - } + public function getIncrementor() { + return function() { return ++$this->x; }; + } } class B extends A { - private $x; - public function __construct($v) { - parent::__construct($v); - $this->x = $v*2; - } + private $x; + public function __construct($v) { + parent::__construct($v); + $this->x = $v*2; + } } $a = new A(0); diff --git a/Zend/tests/closure_039.phpt b/Zend/tests/closure_039.phpt index fa454c38c4d7..760ad716e5c7 100644 --- a/Zend/tests/closure_039.phpt +++ b/Zend/tests/closure_039.phpt @@ -4,22 +4,22 @@ Closure 039: Rebinding closures, change scope, same runtime type x = $v; - } + public function __construct($v) { + $this->x = $v; + } - public function getIncrementor() { - return function() { return ++$this->x; }; - } + public function getIncrementor() { + return function() { return ++$this->x; }; + } } class B extends A { - private $x; - public function __construct($v) { - parent::__construct($v); - $this->x = $v*2; - } + private $x; + public function __construct($v) { + parent::__construct($v); + $this->x = $v*2; + } } $a = new B(-5); diff --git a/Zend/tests/closure_040.phpt b/Zend/tests/closure_040.phpt index a5f52e70b00f..9c59e798f75a 100644 --- a/Zend/tests/closure_040.phpt +++ b/Zend/tests/closure_040.phpt @@ -4,19 +4,19 @@ Closure 040: Rebinding closures, bad arguments x = $v; - } - - public function getIncrementor() { - return function() { return ++$this->x; }; - } - public function getStaticIncrementor() { - return static function() { return ++static::$xs; }; - } + private $x; + private static $xs = 10; + + public function __construct($v) { + $this->x = $v; + } + + public function getIncrementor() { + return function() { return ++$this->x; }; + } + public function getStaticIncrementor() { + return static function() { return ++static::$xs; }; + } } $a = new A(20); diff --git a/Zend/tests/closure_041.phpt b/Zend/tests/closure_041.phpt index 42fc55dfe773..20e5217095c4 100644 --- a/Zend/tests/closure_041.phpt +++ b/Zend/tests/closure_041.phpt @@ -8,29 +8,29 @@ Closure 041: Rebinding: preservation of previous scope when not given as arg unl * to having a bound instance. */ $staticUnscoped = static function () { - echo "scoped to A: "; var_dump(isset(A::$priv)); - echo "bound: ", isset($this)?get_class($this):"no"; + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; }; $nonstaticUnscoped = function () { - echo "scoped to A: "; var_dump(isset(A::$priv)); - echo "bound: ", isset($this)?get_class($this):"no"; + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; }; class A { - private static $priv = 7; - function getClosure() { - return function () { - echo "scoped to A: "; var_dump(isset(A::$priv)); - echo "bound: ", isset($this)?get_class($this):"no"; - }; - } - function getStaticClosure() { - return static function () { - echo "scoped to A: "; var_dump(isset(A::$priv)); - echo "bound: ", isset($this)?get_class($this):"no"; - }; - } + private static $priv = 7; + function getClosure() { + return function () { + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; + }; + } + function getStaticClosure() { + return static function () { + echo "scoped to A: "; var_dump(isset(A::$priv)); + echo "bound: ", isset($this)?get_class($this):"no"; + }; + } } class B extends A {} diff --git a/Zend/tests/closure_043.phpt b/Zend/tests/closure_043.phpt index 2390aa153b23..13c3e519b951 100644 --- a/Zend/tests/closure_043.phpt +++ b/Zend/tests/closure_043.phpt @@ -9,10 +9,10 @@ Closure 043: Scope/bounding combination invariants; static closures $staticUnscoped = static function () { var_dump(isset(A::$priv)); var_dump(isset($this)); }; class A { - private static $priv = 7; - static function getStaticClosure() { - return static function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; - } + private static $priv = 7; + static function getStaticClosure() { + return static function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + } } $staticScoped = A::getStaticClosure(); diff --git a/Zend/tests/closure_044.phpt b/Zend/tests/closure_044.phpt index a848c0b17aa2..e886f5e764d9 100644 --- a/Zend/tests/closure_044.phpt +++ b/Zend/tests/closure_044.phpt @@ -8,10 +8,10 @@ Closure 044: Scope/bounding combination invariants; non static closures $nonstaticUnscoped = function () { var_dump(isset(A::$priv)); var_dump(isset($this)); }; class A { - private static $priv = 7; - function getClosure() { - return function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; - } + private static $priv = 7; + function getClosure() { + return function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + } } $a = new A(); diff --git a/Zend/tests/closure_046.phpt b/Zend/tests/closure_046.phpt index 7d94df33b635..5f0a0ba1601c 100644 --- a/Zend/tests/closure_046.phpt +++ b/Zend/tests/closure_046.phpt @@ -10,10 +10,10 @@ Closure 046: Rebinding: preservation of previous scope when "static" given as sc $nonstaticUnscoped = function () { var_dump(isset(A::$priv)); var_dump(isset($this)); }; class A { - private static $priv = 7; - function getClosure() { - return function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; - } + private static $priv = 7; + function getClosure() { + return function() { var_dump(isset(A::$priv)); var_dump(isset($this)); }; + } } class B extends A {} diff --git a/Zend/tests/closure_047.phpt b/Zend/tests/closure_047.phpt index 736793448df7..60d791619802 100644 --- a/Zend/tests/closure_047.phpt +++ b/Zend/tests/closure_047.phpt @@ -5,13 +5,13 @@ Closure 047: Use in preg_replace_callback() using variables by reference function replace_variables($text, $params) { - preg_replace_callback( '/(\?)/', function($matches) use (&$params, &$text) { + preg_replace_callback( '/(\?)/', function($matches) use (&$params, &$text) { - $text = preg_replace( '/(\?)/', array_shift( $params ), $text, 1 ); + $text = preg_replace( '/(\?)/', array_shift( $params ), $text, 1 ); - }, $text ); + }, $text ); - return $text; + return $text; } echo replace_variables('a=?', array('0')) . "\n"; diff --git a/Zend/tests/closure_048.phpt b/Zend/tests/closure_048.phpt index 47781641a845..8365109934bd 100644 --- a/Zend/tests/closure_048.phpt +++ b/Zend/tests/closure_048.phpt @@ -5,13 +5,13 @@ Closure 048: Use in preg_replace_callback() using variables by reference function replace_variables($text, $params) { - $c = function($matches) use (&$params, &$text) { - $text = preg_replace( '/(\?)/', array_shift( $params ), $text, 1 ); - }; + $c = function($matches) use (&$params, &$text) { + $text = preg_replace( '/(\?)/', array_shift( $params ), $text, 1 ); + }; - preg_replace_callback( '/(\?)/', $c, $text ); + preg_replace_callback( '/(\?)/', $c, $text ); - return $text; + return $text; } echo replace_variables('a=?', array('0')) . "\n"; diff --git a/Zend/tests/closure_057.phpt b/Zend/tests/closure_057.phpt index f0062244d26d..db998c5184cc 100644 --- a/Zend/tests/closure_057.phpt +++ b/Zend/tests/closure_057.phpt @@ -6,12 +6,12 @@ class A { } function getfunc() { - $b = function() { - $a = function() { - }; - $a(); - }; - return $b->bindTo(new A()); + $b = function() { + $a = function() { + }; + $a(); + }; + return $b->bindTo(new A()); } call_user_func(getfunc()); diff --git a/Zend/tests/closure_058.phpt b/Zend/tests/closure_058.phpt index 128661f4fc08..2a83778954af 100644 --- a/Zend/tests/closure_058.phpt +++ b/Zend/tests/closure_058.phpt @@ -3,12 +3,12 @@ Closure 058: Closure scope and object --FILE-- __invoke($a); call_user_func(array($f,"__invoke"), $a); try { - $f($b); + $f($b); } catch (Error $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - $f->__invoke($b); + $f->__invoke($b); } catch (Error $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - call_user_func(array($f,"__invoke"), $b); + call_user_func(array($f,"__invoke"), $b); } catch (Error $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } --EXPECTF-- Exception: Argument 1 passed to {closure}() must be an instance of A, instance of B %s diff --git a/Zend/tests/closure_060.phpt b/Zend/tests/closure_060.phpt index f03160dab991..9762318469bc 100644 --- a/Zend/tests/closure_060.phpt +++ b/Zend/tests/closure_060.phpt @@ -4,13 +4,13 @@ runtime cache must be invalidated for Closure::call() valid(); // start ?> diff --git a/Zend/tests/closures/closure_from_callable.inc b/Zend/tests/closures/closure_from_callable.inc index cef6105ec1cf..d691ef175774 100644 --- a/Zend/tests/closures/closure_from_callable.inc +++ b/Zend/tests/closures/closure_from_callable.inc @@ -2,186 +2,186 @@ function bar($param1) { - return $param1; + return $param1; } $closure = function($param1) { - return $param1; + return $param1; }; function test($fn) { - static $count = 0; - $input = "foo".$count; - $count++; + static $count = 0; + $input = "foo".$count; + $count++; - $output = $fn($input); - return $input === $output; + $output = $fn($input); + return $input === $output; } class Foo { - public static function publicStaticFunction($param1) - { - return $param1; - } - - private static function privateStaticFunction($param1) - { - return $param1; - } - - protected static function protectedStaticFunction($param1) - { - return $param1; - } - - private function privateInstanceFunc($param1) - { - return $param1; - } - - protected function protectedInstanceFunc($param1) - { - return $param1; - } - - - public function publicInstanceFunc($param1) - { - return $param1; - } - - public function closePrivateValid() - { - return Closure::fromCallable([$this, 'privateInstanceFunc']); - } - - public function closePrivateStatic() - { - return Closure::fromCallable([__CLASS__, 'privateStaticFunction']); - } - - public function bar($param1) - { - echo "this is bar\n"; - } - - public function getCallable() - { - return Closure::fromCallable([$this, 'publicInstanceFunc']); - } - - public function getSelfPublicInstance() - { - return Closure::fromCallable([$this, 'publicInstanceFunc']); - } - - public function getSelfColonPublicInstanceMethod() - { - return Closure::fromCallable('self::publicInstanceFunc'); - } + public static function publicStaticFunction($param1) + { + return $param1; + } + + private static function privateStaticFunction($param1) + { + return $param1; + } + + protected static function protectedStaticFunction($param1) + { + return $param1; + } + + private function privateInstanceFunc($param1) + { + return $param1; + } + + protected function protectedInstanceFunc($param1) + { + return $param1; + } + + + public function publicInstanceFunc($param1) + { + return $param1; + } + + public function closePrivateValid() + { + return Closure::fromCallable([$this, 'privateInstanceFunc']); + } + + public function closePrivateStatic() + { + return Closure::fromCallable([__CLASS__, 'privateStaticFunction']); + } + + public function bar($param1) + { + echo "this is bar\n"; + } + + public function getCallable() + { + return Closure::fromCallable([$this, 'publicInstanceFunc']); + } + + public function getSelfPublicInstance() + { + return Closure::fromCallable([$this, 'publicInstanceFunc']); + } + + public function getSelfColonPublicInstanceMethod() + { + return Closure::fromCallable('self::publicInstanceFunc'); + } } class SubFoo extends Foo { - public function closePrivateStaticInvalid() - { - return Closure::fromCallable([__CLASS__, 'privateStaticFunction']); - } + public function closePrivateStaticInvalid() + { + return Closure::fromCallable([__CLASS__, 'privateStaticFunction']); + } - public function closePrivateInvalid() - { - return Closure::fromCallable([$this, 'privateInstanceFunc']); - } + public function closePrivateInvalid() + { + return Closure::fromCallable([$this, 'privateInstanceFunc']); + } - public function closeProtectedStaticMethod() - { - return Closure::fromCallable([__CLASS__, 'protectedStaticFunction']); - } + public function closeProtectedStaticMethod() + { + return Closure::fromCallable([__CLASS__, 'protectedStaticFunction']); + } - public function closeProtectedValid() - { - return Closure::fromCallable([$this, 'protectedInstanceFunc']); - } + public function closeProtectedValid() + { + return Closure::fromCallable([$this, 'protectedInstanceFunc']); + } - public function getParentPublicInstanceMethod() - { - return Closure::fromCallable('parent::publicInstanceFunc'); - } + public function getParentPublicInstanceMethod() + { + return Closure::fromCallable('parent::publicInstanceFunc'); + } - public function getSelfColonParentPublicInstanceMethod() - { - return Closure::fromCallable('self::publicInstanceFunc'); - } + public function getSelfColonParentPublicInstanceMethod() + { + return Closure::fromCallable('self::publicInstanceFunc'); + } - public function getSelfColonParentProtectedInstanceMethod() - { - return Closure::fromCallable('self::protectedInstanceFunc'); - } + public function getSelfColonParentProtectedInstanceMethod() + { + return Closure::fromCallable('self::protectedInstanceFunc'); + } - public function getSelfColonParentPrivateInstanceMethod() - { - return Closure::fromCallable('self::privateInstanceFunc'); - } + public function getSelfColonParentPrivateInstanceMethod() + { + return Closure::fromCallable('self::privateInstanceFunc'); + } } class MagicCall { - public function __call($name, $arguments) - { - $info = ['__call']; - $info[] = $name; - $info = array_merge($info, $arguments); - return implode(',', $info); - } - - public static function __callStatic($name, $arguments) - { - $info = ['__callStatic']; - $info[] = $name; - $info = array_merge($info, $arguments); - return implode(',', $info); - } + public function __call($name, $arguments) + { + $info = ['__call']; + $info[] = $name; + $info = array_merge($info, $arguments); + return implode(',', $info); + } + + public static function __callStatic($name, $arguments) + { + $info = ['__callStatic']; + $info[] = $name; + $info = array_merge($info, $arguments); + return implode(',', $info); + } } class PublicInvocable { - public function __invoke($param1) - { - return $param1; - } + public function __invoke($param1) + { + return $param1; + } } function functionAccessProtected() { - $foo = new Foo; + $foo = new Foo; - return Closure::fromCallable([$foo, 'protectedStaticFunction']); + return Closure::fromCallable([$foo, 'protectedStaticFunction']); } function functionAccessPrivate() { - $foo = new Foo; + $foo = new Foo; - return Closure::fromCallable([$foo, 'privateStaticFunction']); + return Closure::fromCallable([$foo, 'privateStaticFunction']); } function functionAccessMethodDoesntExist() { - $foo = new Foo; + $foo = new Foo; - return Closure::fromCallable([$foo, 'thisDoesNotExist']); + return Closure::fromCallable([$foo, 'thisDoesNotExist']); } ?> diff --git a/Zend/tests/closures/closure_from_callable_error.phpt b/Zend/tests/closures/closure_from_callable_error.phpt index 5ada0ef2bf1e..5d1e078c1ee2 100644 --- a/Zend/tests/closures/closure_from_callable_error.phpt +++ b/Zend/tests/closures/closure_from_callable_error.phpt @@ -7,187 +7,187 @@ include('closure_from_callable.inc'); echo 'Cannot access privateInstance method statically'."\n"; try { - $fn = Closure::fromCallable(['Foo', 'privateInstanceFunc']); - echo "Test failed to fail and return was : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable(['Foo', 'privateInstanceFunc']); + echo "Test failed to fail and return was : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Cannot access privateInstance method statically with colon scheme'."\n"; try { - $fn = Closure::fromCallable('Foo::privateInstanceFunc'); - echo "Test failed to fail and return was : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable('Foo::privateInstanceFunc'); + echo "Test failed to fail and return was : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Cannot access privateInstance method'."\n"; try { - $fn = Closure::fromCallable([new Foo, 'privateInstanceFunc']); - echo "Test failed to fail and return was : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable([new Foo, 'privateInstanceFunc']); + echo "Test failed to fail and return was : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'SubClass cannot access private instance method'."\n"; try { - $fn = Closure::fromCallable([new SubFoo, 'privateInstanceFunc']); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable([new SubFoo, 'privateInstanceFunc']); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Cannot access private static function of instance'."\n"; try { - $fn = Closure::fromCallable([new Foo, 'privateStaticFunction']); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable([new Foo, 'privateStaticFunction']); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Cannot access private static method statically'."\n"; try { - $fn = Closure::fromCallable(['Foo', 'privateStaticFunction']); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable(['Foo', 'privateStaticFunction']); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Cannot access private static method statically with colon scheme'."\n"; try { - $fn = Closure::fromCallable('Foo::privateStaticFunction'); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable('Foo::privateStaticFunction'); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Non-existent method should fail'."\n"; try { - $fn = Closure::fromCallable('Foo::nonExistentFunction'); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable('Foo::nonExistentFunction'); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Non-existent class should fail'."\n"; try { - $fn = Closure::fromCallable(['NonExistentClass', 'foo']); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable(['NonExistentClass', 'foo']); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Non-existent function should fail'."\n"; try { - $fn = Closure::fromCallable('thisDoesNotExist'); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = Closure::fromCallable('thisDoesNotExist'); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Subclass cannot closure over parent private instance method'."\n"; try { - $subFoo = new SubFoo; - $fn = $subFoo->closePrivateInvalid(); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $subFoo = new SubFoo; + $fn = $subFoo->closePrivateInvalid(); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Subclass cannot closure over parant private static method'."\n"; try { - $subFoo = new SubFoo; - $fn = $subFoo->closePrivateStaticInvalid(); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $subFoo = new SubFoo; + $fn = $subFoo->closePrivateStaticInvalid(); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Function scope cannot closure over protected instance method'."\n"; try { - $fn = functionAccessProtected(); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = functionAccessProtected(); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Function scope cannot closure over private instance method'."\n"; try { - $fn = functionAccessPrivate(); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $fn = functionAccessPrivate(); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo 'Access private instance method of parent object through "self::" to parent method'."\n"; try { - $foo = new SubFoo; - $fn = $foo->getSelfColonParentPrivateInstanceMethod(); - echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; + $foo = new SubFoo; + $fn = $foo->getSelfColonParentPrivateInstanceMethod(); + echo "Test failed to fail, closure is : ".var_export($fn, true)."\n"; } catch (\TypeError $te) { - //This is the expected outcome. + //This is the expected outcome. } catch (\Throwable $t) { - echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; + echo "Wrong exception type thrown: ".get_class($t)." : ".$t->getMessage()."\n"; } echo "OK\n"; diff --git a/Zend/tests/closures/closure_from_callable_reflection.phpt b/Zend/tests/closures/closure_from_callable_reflection.phpt index 111115a44aeb..4cd850426658 100644 --- a/Zend/tests/closures/closure_from_callable_reflection.phpt +++ b/Zend/tests/closures/closure_from_callable_reflection.phpt @@ -4,8 +4,8 @@ Testing Closure::fromCallable() functionality: Reflection getParameters() as $param) { - if ($param->hasType()) { - $type = $param->getType(); - echo $type->getName() . "\n"; - } - } + $closure = Closure::fromCallable($callable); + $refl = new ReflectionFunction($closure); + foreach ($refl->getParameters() as $param) { + if ($param->hasType()) { + $type = $param->getType(); + echo $type->getName() . "\n"; + } + } } ?> diff --git a/Zend/tests/compare_001.phpt b/Zend/tests/compare_001.phpt index d9f3f080bc86..dcf305d74245 100644 --- a/Zend/tests/compare_001.phpt +++ b/Zend/tests/compare_001.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var == $a[$i]) ? " == " : " != "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var == $a[$i]) ? " == " : " != "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_001_64bit.phpt b/Zend/tests/compare_001_64bit.phpt index f72f91d17bbf..2536073089e7 100644 --- a/Zend/tests/compare_001_64bit.phpt +++ b/Zend/tests/compare_001_64bit.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var == $a[$i]) ? " == " : " != "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var == $a[$i]) ? " == " : " != "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_002.phpt b/Zend/tests/compare_002.phpt index 9e3eb86d5700..f4646c84fa68 100644 --- a/Zend/tests/compare_002.phpt +++ b/Zend/tests/compare_002.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var === $a[$i]) ? " === " : " !== "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var === $a[$i]) ? " === " : " !== "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_002_64bit.phpt b/Zend/tests/compare_002_64bit.phpt index a18269e9f355..b0418cca1103 100644 --- a/Zend/tests/compare_002_64bit.phpt +++ b/Zend/tests/compare_002_64bit.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var === $a[$i]) ? " === " : " !== "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var === $a[$i]) ? " === " : " !== "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_003.phpt b/Zend/tests/compare_003.phpt index 4cb7a027cd93..c52df7963483 100644 --- a/Zend/tests/compare_003.phpt +++ b/Zend/tests/compare_003.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var > $a[$i]) ? " > " : " <= "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var > $a[$i]) ? " > " : " <= "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_003_64bit.phpt b/Zend/tests/compare_003_64bit.phpt index 2c361257ae41..af1878285707 100644 --- a/Zend/tests/compare_003_64bit.phpt +++ b/Zend/tests/compare_003_64bit.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var > $a[$i]) ? " > " : " <= "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var > $a[$i]) ? " > " : " <= "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_004.phpt b/Zend/tests/compare_004.phpt index 1d13f363345d..f53f22a9e5e1 100644 --- a/Zend/tests/compare_004.phpt +++ b/Zend/tests/compare_004.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var < $a[$i]) ? " < " : " >= "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var < $a[$i]) ? " < " : " >= "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_004_64bit.phpt b/Zend/tests/compare_004_64bit.phpt index 8a69ae7816a1..cdd880299636 100644 --- a/Zend/tests/compare_004_64bit.phpt +++ b/Zend/tests/compare_004_64bit.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var < $a[$i]) ? " < " : " >= "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var < $a[$i]) ? " < " : " >= "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_005.phpt b/Zend/tests/compare_005.phpt index 43ed96e70bde..87241a50e2f3 100644 --- a/Zend/tests/compare_005.phpt +++ b/Zend/tests/compare_005.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var >= $a[$i]) ? " >= " : " < "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var >= $a[$i]) ? " >= " : " < "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_005_64bit.phpt b/Zend/tests/compare_005_64bit.phpt index 821f2a0ee4f0..ab3d0cf0bc21 100644 --- a/Zend/tests/compare_005_64bit.phpt +++ b/Zend/tests/compare_005_64bit.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var >= $a[$i]) ? " >= " : " < "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var >= $a[$i]) ? " >= " : " < "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_006.phpt b/Zend/tests/compare_006.phpt index 1c212c5487f2..824c162b8280 100644 --- a/Zend/tests/compare_006.phpt +++ b/Zend/tests/compare_006.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var <= $a[$i]) ? " <= " : " > "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var <= $a[$i]) ? " <= " : " > "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compare_006_64bit.phpt b/Zend/tests/compare_006_64bit.phpt index 41973a990d75..f85b0d28c0f4 100644 --- a/Zend/tests/compare_006_64bit.phpt +++ b/Zend/tests/compare_006_64bit.phpt @@ -9,41 +9,41 @@ class test { } $a = array( - array(1,2,3), - "", - 1, - 2.5, - 0, - "string", - "123", - "2.5", - NULL, - true, - false, - new stdclass, - new stdclass, - new test, - array(), - -PHP_INT_MAX-1, - (string)(-PHP_INT_MAX-1), + array(1,2,3), + "", + 1, + 2.5, + 0, + "string", + "123", + "2.5", + NULL, + true, + false, + new stdclass, + new stdclass, + new test, + array(), + -PHP_INT_MAX-1, + (string)(-PHP_INT_MAX-1), ); $var_cnt = count($a); function my_dump($var) { - ob_start(); - var_dump($var); - $buf = ob_get_clean(); - echo str_replace("\n", "", $buf); + ob_start(); + var_dump($var); + $buf = ob_get_clean(); + echo str_replace("\n", "", $buf); } foreach($a as $var) { - for ($i = 0; $i < $var_cnt; $i++) { - my_dump($var); - echo ($var <= $a[$i]) ? " <= " : " > "; - my_dump($a[$i]); - echo "\n"; - } + for ($i = 0; $i < $var_cnt; $i++) { + my_dump($var); + echo ($var <= $a[$i]) ? " <= " : " > "; + my_dump($a[$i]); + echo "\n"; + } } echo "Done\n"; diff --git a/Zend/tests/compound_assign_failure.phpt b/Zend/tests/compound_assign_failure.phpt index 2e35ab4fff78..673baecff071 100644 --- a/Zend/tests/compound_assign_failure.phpt +++ b/Zend/tests/compound_assign_failure.phpt @@ -6,30 +6,30 @@ opcache.optimization_level=0 >= -1; + $a = 1; + $a >>= -1; } catch (Error $e) { var_dump($a); } try { - $a = 1; - $a <<= -1; + $a = 1; + $a <<= -1; } catch (Error $e) { var_dump($a); } set_error_handler(function($type, $msg) { throw new Exception($msg); }); try { - $a = []; - $a .= "foo"; + $a = []; + $a .= "foo"; } catch (Throwable $e) { var_dump($a); } try { - $a = "foo"; - $a .= []; + $a = "foo"; + $a .= []; } catch (Throwable $e) { var_dump($a); } $x = new stdClass; diff --git a/Zend/tests/compound_assign_with_numeric_strings.phpt b/Zend/tests/compound_assign_with_numeric_strings.phpt index e5cdb344ef86..a801991a1ef4 100644 --- a/Zend/tests/compound_assign_with_numeric_strings.phpt +++ b/Zend/tests/compound_assign_with_numeric_strings.phpt @@ -12,7 +12,7 @@ try { $n <<= $n; var_dump($n); } catch (ArithmeticError $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $n = "65"; @@ -24,7 +24,7 @@ try { $n >>= $n; var_dump($n); } catch (ArithmeticError $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $n = "0"; @@ -32,7 +32,7 @@ try{ $n %= $n; var_dump($n); } catch (DivisionByZeroError $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $n = "-1"; diff --git a/Zend/tests/concat_001.phpt b/Zend/tests/concat_001.phpt index b8fad29674a6..887370aee726 100644 --- a/Zend/tests/concat_001.phpt +++ b/Zend/tests/concat_001.phpt @@ -6,9 +6,9 @@ precision=14 [1]]["string"][0]; var_dump(b, c, e); function test ($a = d[1][0]) { - var_dump($a); + var_dump($a); } test(); class foo { - const bar = [1][0]; + const bar = [1][0]; } var_dump(foo::bar); diff --git a/Zend/tests/constant_expressions_classes.phpt b/Zend/tests/constant_expressions_classes.phpt index 9deec49561ca..6cca7176723d 100644 --- a/Zend/tests/constant_expressions_classes.phpt +++ b/Zend/tests/constant_expressions_classes.phpt @@ -20,11 +20,11 @@ $classlist = [ ]; spl_autoload_register(function ($class) use ($classlist) { - if (isset($classlist[$class])) { - eval($classlist[$class]); - } else { - die("Cannot autoload $class\n"); - } + if (isset($classlist[$class])) { + eval($classlist[$class]); + } else { + die("Cannot autoload $class\n"); + } }); printf("B::HW = %s\n", B::HW); diff --git a/Zend/tests/constant_expressions_exceptions_002.phpt b/Zend/tests/constant_expressions_exceptions_002.phpt index fc15af5e9a53..c10bd1084334 100644 --- a/Zend/tests/constant_expressions_exceptions_002.phpt +++ b/Zend/tests/constant_expressions_exceptions_002.phpt @@ -3,9 +3,9 @@ Constant Expressions with unsupported operands 002 --FILE-- getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } ?> DONE diff --git a/Zend/tests/constants_006.phpt b/Zend/tests/constants_006.phpt index 6458a078256b..77e71de437c6 100644 --- a/Zend/tests/constants_006.phpt +++ b/Zend/tests/constants_006.phpt @@ -10,11 +10,11 @@ var_dump(__file__); var_dump(__line__); class foo { - public function __construct() { - var_dump(__method__); - var_dump(__class__); - var_dump(__function__); - } + public function __construct() { + var_dump(__method__); + var_dump(__class__); + var_dump(__function__); + } } new foo; diff --git a/Zend/tests/constants_007.phpt b/Zend/tests/constants_007.phpt index 7d9f3feb729f..c1242dc0c31c 100644 --- a/Zend/tests/constants_007.phpt +++ b/Zend/tests/constants_007.phpt @@ -8,8 +8,8 @@ const A = 'b'; class a { - const a = 'c'; - const A = 'd'; + const a = 'c'; + const A = 'd'; } var_dump(a, A, a::a, a::A); diff --git a/Zend/tests/constants_008.phpt b/Zend/tests/constants_008.phpt index 226e147ffdba..6a8f00edec23 100644 --- a/Zend/tests/constants_008.phpt +++ b/Zend/tests/constants_008.phpt @@ -8,7 +8,7 @@ const a = 1; if (defined('a')) { - print a; + print a; } ?> diff --git a/Zend/tests/constants_009.phpt b/Zend/tests/constants_009.phpt index 35c64dff162b..953bc9196543 100644 --- a/Zend/tests/constants_009.phpt +++ b/Zend/tests/constants_009.phpt @@ -8,7 +8,7 @@ namespace foo\x; const x = 2; class x { - const x = 1; + const x = 1; } diff --git a/Zend/tests/debug_backtrace_options.phpt b/Zend/tests/debug_backtrace_options.phpt index a35eb64ff62b..94842279ea97 100644 --- a/Zend/tests/debug_backtrace_options.phpt +++ b/Zend/tests/debug_backtrace_options.phpt @@ -5,39 +5,39 @@ debug_backtrace options function backtrace_print($opt = null) { - if(is_null($opt)) { - print_r(debug_backtrace()); - } else { - print_r(debug_backtrace($opt)); - } + if(is_null($opt)) { + print_r(debug_backtrace()); + } else { + print_r(debug_backtrace($opt)); + } } function doit($a, $b, $how) { - echo "==default\n"; - $how(); - echo "==true\n"; - $how(true); - echo "==false\n"; - $how(false); - echo "==DEBUG_BACKTRACE_PROVIDE_OBJECT\n"; - $how(DEBUG_BACKTRACE_PROVIDE_OBJECT); - echo "==DEBUG_BACKTRACE_IGNORE_ARGS\n"; - $how(DEBUG_BACKTRACE_IGNORE_ARGS); - echo "==both\n"; - $how(DEBUG_BACKTRACE_PROVIDE_OBJECT|DEBUG_BACKTRACE_IGNORE_ARGS); + echo "==default\n"; + $how(); + echo "==true\n"; + $how(true); + echo "==false\n"; + $how(false); + echo "==DEBUG_BACKTRACE_PROVIDE_OBJECT\n"; + $how(DEBUG_BACKTRACE_PROVIDE_OBJECT); + echo "==DEBUG_BACKTRACE_IGNORE_ARGS\n"; + $how(DEBUG_BACKTRACE_IGNORE_ARGS); + echo "==both\n"; + $how(DEBUG_BACKTRACE_PROVIDE_OBJECT|DEBUG_BACKTRACE_IGNORE_ARGS); } class foo { - protected function doCall($dowhat, $how) - { - $dowhat('a','b', $how); - } - static function statCall($dowhat, $how) - { - $obj = new self(); - $obj->doCall($dowhat, $how); - } + protected function doCall($dowhat, $how) + { + $dowhat('a','b', $how); + } + static function statCall($dowhat, $how) + { + $obj = new self(); + $obj->doCall($dowhat, $how); + } } foo::statCall("doit", "debug_print_backtrace"); foo::statCall("doit", "backtrace_print"); diff --git a/Zend/tests/decrement_001.phpt b/Zend/tests/decrement_001.phpt index b768b5a8e548..22d95b16ac66 100644 --- a/Zend/tests/decrement_001.phpt +++ b/Zend/tests/decrement_001.phpt @@ -8,26 +8,26 @@ precision=14 y); // int(1) function d() { - $obj = new foo; - return $obj->test(); + $obj = new foo; + return $obj->test(); } var_dump(d()[0][0][0][3]); // string(1) "b" function e() { - $y = 'bar'; - $x = array('a' => 'foo', 'b' => $y); - return $x; + $y = 'bar'; + $x = array('a' => 'foo', 'b' => $y); + return $x; } var_dump(e()['b']); // string(3) "bar" diff --git a/Zend/tests/dereference_002.phpt b/Zend/tests/dereference_002.phpt index e17e5e85b625..e196b91e6781 100644 --- a/Zend/tests/dereference_002.phpt +++ b/Zend/tests/dereference_002.phpt @@ -6,13 +6,13 @@ Testing array dereference on method calls error_reporting(E_ALL); class foo { - public function bar() { - $x = array(); - $x[] = 3; - $x[] = array(1, 5); - $x[] = new foo; - return $x; - } + public function bar() { + $x = array(); + $x[] = 3; + $x[] = array(1, 5); + $x[] = new foo; + return $x; + } } $foo = new foo; diff --git a/Zend/tests/dereference_003.phpt b/Zend/tests/dereference_003.phpt index 3a5487596418..93bdb1968409 100644 --- a/Zend/tests/dereference_003.phpt +++ b/Zend/tests/dereference_003.phpt @@ -6,24 +6,24 @@ Testing array dereference on method calls error_reporting(E_ALL); class foo { - public $x = 2; - public function a() { - $x = array(); - $x[] = new foo; - return $x; - } - public function b() { - return array(1.2, array(new self)); - } - public function c() { - $a = array(); - $b = &$a; - $b[] = true; - return $a; - } - public function d() { - return $this->b(); - } + public $x = 2; + public function a() { + $x = array(); + $x[] = new foo; + return $x; + } + public function b() { + return array(1.2, array(new self)); + } + public function c() { + $a = array(); + $b = &$a; + $b[] = true; + return $a; + } + public function d() { + return $this->b(); + } } $foo = new foo; diff --git a/Zend/tests/dereference_004.phpt b/Zend/tests/dereference_004.phpt index a77cf032ed1a..1ffe4bf3886e 100644 --- a/Zend/tests/dereference_004.phpt +++ b/Zend/tests/dereference_004.phpt @@ -6,15 +6,15 @@ Testing array dereference on __invoke() result error_reporting(E_ALL); class foo { - public $x = array(); - public function __construct() { - $h = array(); - $h[] = new stdclass; - $this->x = $h; - } - public function __invoke() { - return $this->x; - } + public $x = array(); + public function __construct() { + $h = array(); + $h[] = new stdclass; + $this->x = $h; + } + public function __invoke() { + return $this->x; + } } diff --git a/Zend/tests/dereference_005.phpt b/Zend/tests/dereference_005.phpt index cca87571cd06..5dba2276e9d7 100644 --- a/Zend/tests/dereference_005.phpt +++ b/Zend/tests/dereference_005.phpt @@ -29,7 +29,7 @@ class obj implements arrayaccess { } function x() { - return new obj; + return new obj; } var_dump(x()['two']); diff --git a/Zend/tests/dereference_006.phpt b/Zend/tests/dereference_006.phpt index 61a07353a4ce..694ded85b7c2 100644 --- a/Zend/tests/dereference_006.phpt +++ b/Zend/tests/dereference_006.phpt @@ -6,7 +6,7 @@ Testing array dereference and references error_reporting(E_ALL); function &foo(&$foo) { - return $foo; + return $foo; } $a = array(1); diff --git a/Zend/tests/dereference_007.phpt b/Zend/tests/dereference_007.phpt index afe6e9d5b2ce..4d677c6ea10d 100644 --- a/Zend/tests/dereference_007.phpt +++ b/Zend/tests/dereference_007.phpt @@ -6,19 +6,19 @@ Trying to write on method return error_reporting(E_ALL); class foo { - public $x = array(); + public $x = array(); - public function b() { - return $this->x; - } + public function b() { + return $this->x; + } - public function c() { - return $x; - } + public function c() { + return $x; + } - static public function d() { + static public function d() { - } + } } $foo = new foo; diff --git a/Zend/tests/dereference_008.phpt b/Zend/tests/dereference_008.phpt index c615b9cd8592..973fd24ffdd7 100644 --- a/Zend/tests/dereference_008.phpt +++ b/Zend/tests/dereference_008.phpt @@ -6,11 +6,11 @@ Testing array dereference with dynamic method name and references error_reporting(E_ALL); class foo { - public $x = array(1); + public $x = array(1); - public function &b() { - return $this->x; - } + public function &b() { + return $this->x; + } } $foo = new foo; diff --git a/Zend/tests/dereference_009.phpt b/Zend/tests/dereference_009.phpt index e579c44bae0c..5cf36a475870 100644 --- a/Zend/tests/dereference_009.phpt +++ b/Zend/tests/dereference_009.phpt @@ -8,7 +8,7 @@ error_reporting(E_ALL); $a = array(); function &a() { - return $GLOBALS['a']; + return $GLOBALS['a']; } var_dump($h =& a()); diff --git a/Zend/tests/dereference_010.phpt b/Zend/tests/dereference_010.phpt index c916352afa4c..191da8f3488f 100644 --- a/Zend/tests/dereference_010.phpt +++ b/Zend/tests/dereference_010.phpt @@ -6,7 +6,7 @@ Testing dereference in non-array values error_reporting(E_ALL); function a() { - return 1; + return 1; } $a = 1; @@ -14,7 +14,7 @@ var_dump($a[1]); var_dump(a()[1]); function b() { - return new stdClass; + return new stdClass; } var_dump(b()[1]); diff --git a/Zend/tests/dereference_011.phpt b/Zend/tests/dereference_011.phpt index 43fec9b92aa7..26c77718247c 100644 --- a/Zend/tests/dereference_011.phpt +++ b/Zend/tests/dereference_011.phpt @@ -6,11 +6,11 @@ Testing array dereference with chaining error_reporting(E_ALL); class foo { - public $arr; + public $arr; - public function &a() { - return $this->arr; - } + public function &a() { + return $this->arr; + } } $foo = new foo; diff --git a/Zend/tests/dereference_012.phpt b/Zend/tests/dereference_012.phpt index ab70957a0a48..7c1501e73fc6 100644 --- a/Zend/tests/dereference_012.phpt +++ b/Zend/tests/dereference_012.phpt @@ -4,18 +4,18 @@ Testing array dereferencing on return of a method with and without reference x) == 1) { - $this->x[] = $y[0]; - } - return $this->x; - } + public $x = array(2); + + public function __call($x, $y) { + if (count($this->x) == 1) { + $this->x[] = $y[0]; + } + return $this->x; + } } $foo = new foo; diff --git a/Zend/tests/dereference_014.phpt b/Zend/tests/dereference_014.phpt index 470c233a19d8..c6f21ab0ed92 100644 --- a/Zend/tests/dereference_014.phpt +++ b/Zend/tests/dereference_014.phpt @@ -6,16 +6,16 @@ Trying to create an object from dereferencing uninitialized variable error_reporting(E_ALL); class foo { - public $x; - static public $y; + public $x; + static public $y; - public function a() { - return $this->x; - } + public function a() { + return $this->x; + } - static public function b() { - return self::$y; - } + static public function b() { + return self::$y; + } } $foo = new foo; diff --git a/Zend/tests/div_002.phpt b/Zend/tests/div_002.phpt index be7b38e5b26a..1fc006def5db 100644 --- a/Zend/tests/div_002.phpt +++ b/Zend/tests/div_002.phpt @@ -7,9 +7,9 @@ $a = array(1,2,3); $b = array(1); try { - var_dump($a / $b); + var_dump($a / $b); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $a / $b; diff --git a/Zend/tests/double_to_string.phpt b/Zend/tests/double_to_string.phpt index a778017a63d0..808024b0e568 100644 --- a/Zend/tests/double_to_string.phpt +++ b/Zend/tests/double_to_string.phpt @@ -8,26 +8,26 @@ precision=14 --FILE-- --EXPECT-- diff --git a/Zend/tests/dval_to_lval_64.phpt b/Zend/tests/dval_to_lval_64.phpt index da7f56d81cee..3d6b736b8fdf 100644 --- a/Zend/tests/dval_to_lval_64.phpt +++ b/Zend/tests/dval_to_lval_64.phpt @@ -7,18 +7,18 @@ if (PHP_INT_SIZE != 8) ?> --FILE-- --EXPECT-- diff --git a/Zend/tests/errmsg_001.phpt b/Zend/tests/errmsg_001.phpt index c17764cdecdc..e629f19c4055 100644 --- a/Zend/tests/errmsg_001.phpt +++ b/Zend/tests/errmsg_001.phpt @@ -7,7 +7,7 @@ abstract class test { } class Impl extends Test { - function Foo(); + function Foo(); } echo "Done\n"; diff --git a/Zend/tests/errmsg_002.phpt b/Zend/tests/errmsg_002.phpt index d1c4cb893f6e..b00a850fade6 100644 --- a/Zend/tests/errmsg_002.phpt +++ b/Zend/tests/errmsg_002.phpt @@ -4,8 +4,8 @@ errmsg: function cannot be declared private getMessage()); - throw $e; - } - } catch (Exception $e) { - var_dump($e->getMessage()); - throw $e; - } - } catch (Exception $e) { - var_dump($e->getMessage()); - throw $e; - } + try { + try { + try { + throw new Exception(NULL); + } catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; + } + } catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; + } + } catch (Exception $e) { + var_dump($e->getMessage()); + throw $e; + } } catch (Exception $e) { - var_dump($e->getMessage()); - throw $e; + var_dump($e->getMessage()); + throw $e; } ?> diff --git a/Zend/tests/exception_002.phpt b/Zend/tests/exception_002.phpt index 4554200aab52..fee76de0eed3 100644 --- a/Zend/tests/exception_002.phpt +++ b/Zend/tests/exception_002.phpt @@ -6,10 +6,10 @@ Testing exception and GOTO goto foo; try { - print 1; + print 1; - foo: - print 2; + foo: + print 2; } catch (Exception $e) { } diff --git a/Zend/tests/exception_004.phpt b/Zend/tests/exception_004.phpt index d9ffc748a4f2..e94f0e1b6e3d 100644 --- a/Zend/tests/exception_004.phpt +++ b/Zend/tests/exception_004.phpt @@ -6,9 +6,9 @@ Throwing exception using a class that isn't derived from the Exception base clas class Foo { } try { - throw new Foo(); + throw new Foo(); } catch (Foo $e) { - var_dump($e); + var_dump($e); } ?> diff --git a/Zend/tests/exception_007.phpt b/Zend/tests/exception_007.phpt index b3da7099a210..c24dac1d8d4d 100644 --- a/Zend/tests/exception_007.phpt +++ b/Zend/tests/exception_007.phpt @@ -4,15 +4,15 @@ Setting previous exception diff --git a/Zend/tests/exception_008.phpt b/Zend/tests/exception_008.phpt index b88198302be2..4640ec965ad5 100644 --- a/Zend/tests/exception_008.phpt +++ b/Zend/tests/exception_008.phpt @@ -5,16 +5,16 @@ Exception in __destruct while exception is pending class TestFirst { - function __destruct() { - throw new Exception("First"); - } + function __destruct() { + throw new Exception("First"); + } } class TestSecond { - function __destruct() { - throw new Exception("Second"); - } + function __destruct() { + throw new Exception("Second"); + } } $ar = array(new TestFirst, new TestSecond); diff --git a/Zend/tests/exception_013.phpt b/Zend/tests/exception_013.phpt index d8f5d907e361..4f5d07c7cfe3 100644 --- a/Zend/tests/exception_013.phpt +++ b/Zend/tests/exception_013.phpt @@ -3,25 +3,25 @@ Exceptions on improper access to static class properties --FILE-- getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } try { - var_dump(C::$p); + var_dump(C::$p); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } try { - unset(C::$a); + unset(C::$a); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } var_dump(C::$a); diff --git a/Zend/tests/exception_014.phpt b/Zend/tests/exception_014.phpt index fedeee21c922..aaf411dae56c 100644 --- a/Zend/tests/exception_014.phpt +++ b/Zend/tests/exception_014.phpt @@ -3,14 +3,14 @@ Exceptions on improper access to static class properties --FILE-- p); + var_dump($x->p); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } var_dump($x->p); diff --git a/Zend/tests/exception_015.phpt b/Zend/tests/exception_015.phpt index e35a1eefe223..a2b27154f657 100644 --- a/Zend/tests/exception_015.phpt +++ b/Zend/tests/exception_015.phpt @@ -4,9 +4,9 @@ Exceptions on improper access to string getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } $s[] = "D"; diff --git a/Zend/tests/exception_016.phpt b/Zend/tests/exception_016.phpt index 98831d933ae7..5b52cf72cd7a 100644 --- a/Zend/tests/exception_016.phpt +++ b/Zend/tests/exception_016.phpt @@ -3,9 +3,9 @@ Exceptions on improper usage of $this --FILE-- foo(); + $this->foo(); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n"; } $this->foo(); diff --git a/Zend/tests/exception_017.phpt b/Zend/tests/exception_017.phpt index 77fbf2d8446f..260cfbd8e23d 100644 --- a/Zend/tests/exception_017.phpt +++ b/Zend/tests/exception_017.phpt @@ -3,20 +3,20 @@ Exceptions on improper usage of $this --FILE-- diff --git a/Zend/tests/exception_from_toString.phpt b/Zend/tests/exception_from_toString.phpt index ee6dde9187c3..dd4de341caf2 100644 --- a/Zend/tests/exception_from_toString.phpt +++ b/Zend/tests/exception_from_toString.phpt @@ -19,7 +19,7 @@ try { $x = $badStr . $str; } catch (Exception $e) { echo $e->getMessage(), "\n"; } try { $x = $str .= $badStr; } catch (Exception $e) { echo $e->getMessage(), "\n"; } -var_dump($str); +var_dump($str); try { $x = $num . $badStr; } catch (Exception $e) { echo $e->getMessage(), "\n"; } try { $x = $badStr . $num; } diff --git a/Zend/tests/exception_handler_001.phpt b/Zend/tests/exception_handler_001.phpt index d4e205cceb95..bb3cf4eb7a33 100644 --- a/Zend/tests/exception_handler_001.phpt +++ b/Zend/tests/exception_handler_001.phpt @@ -6,7 +6,7 @@ exception handler tests - 1 set_exception_handler("foo"); function foo($e) { - var_dump(get_class($e)." thrown!"); + var_dump(get_class($e)." thrown!"); } class test extends Exception { diff --git a/Zend/tests/exception_handler_002.phpt b/Zend/tests/exception_handler_002.phpt index da57572300d6..4570cc85ab7d 100644 --- a/Zend/tests/exception_handler_002.phpt +++ b/Zend/tests/exception_handler_002.phpt @@ -6,8 +6,8 @@ exception handler tests - 2 set_exception_handler("foo"); function foo($e) { - var_dump(get_class($e)." thrown!"); - throw new Exception(); + var_dump(get_class($e)." thrown!"); + throw new Exception(); } class test extends Exception { diff --git a/Zend/tests/exception_handler_003.phpt b/Zend/tests/exception_handler_003.phpt index 8d3635c4b835..a398a16df797 100644 --- a/Zend/tests/exception_handler_003.phpt +++ b/Zend/tests/exception_handler_003.phpt @@ -5,13 +5,13 @@ exception handler tests - 3 class test { - function foo () { - set_exception_handler(array($this, "bar")); - } + function foo () { + set_exception_handler(array($this, "bar")); + } - function bar($e) { - var_dump(get_class($e)." thrown!"); - } + function bar($e) { + var_dump(get_class($e)." thrown!"); + } } $a = new test; diff --git a/Zend/tests/exception_handler_005.phpt b/Zend/tests/exception_handler_005.phpt index af9662756136..cad39dc40115 100644 --- a/Zend/tests/exception_handler_005.phpt +++ b/Zend/tests/exception_handler_005.phpt @@ -7,11 +7,11 @@ set_exception_handler("foo"); set_exception_handler("foo1"); function foo($e) { - var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); } function foo1($e) { - var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); } diff --git a/Zend/tests/exception_handler_006.phpt b/Zend/tests/exception_handler_006.phpt index 861a10ffa16f..7bed20bbf7f9 100644 --- a/Zend/tests/exception_handler_006.phpt +++ b/Zend/tests/exception_handler_006.phpt @@ -9,11 +9,11 @@ set_exception_handler("foo1"); restore_exception_handler(); function foo($e) { - var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); } function foo1($e) { - var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); + var_dump(__FUNCTION__."(): ".get_class($e)." thrown!"); } diff --git a/Zend/tests/foreach.phpt b/Zend/tests/foreach.phpt index 0835e40aaf69..059a3a4c32ef 100644 --- a/Zend/tests/foreach.phpt +++ b/Zend/tests/foreach.phpt @@ -4,11 +4,11 @@ foreach() by-ref bug &$val) { - if($val == 3) { - $foo[$key] = 0; - } else { - $val++; - } + if($val == 3) { + $foo[$key] = 0; + } else { + $val++; + } } var_dump($foo); ?> diff --git a/Zend/tests/foreach_002.phpt b/Zend/tests/foreach_002.phpt index 77fe20cb64cf..2daa48c3f6b5 100644 --- a/Zend/tests/foreach_002.phpt +++ b/Zend/tests/foreach_002.phpt @@ -8,7 +8,7 @@ zend.enable_gc=1 error_reporting(E_ALL); foreach (($a = array('a' => array('a' => &$a))) as $a) { - var_dump($a); + var_dump($a); } ?> diff --git a/Zend/tests/foreach_003.phpt b/Zend/tests/foreach_003.phpt index 71b0f2a5a3ab..95863e71bac4 100644 --- a/Zend/tests/foreach_003.phpt +++ b/Zend/tests/foreach_003.phpt @@ -8,14 +8,14 @@ class IT implements Iterator { private $trap = null; function __construct($count, $trap = null) { - $this->count = $count; - $this->trap = $trap; + $this->count = $count; + $this->trap = $trap; } function trap($trap) { - if ($trap === $this->trap) { - throw new Exception($trap); - } + if ($trap === $this->trap) { + throw new Exception($trap); + } } function rewind() {$this->trap(__FUNCTION__); $this->n = 0;} @@ -26,28 +26,28 @@ class IT implements Iterator { } foreach(['rewind', 'valid', 'key', 'current', 'next'] as $trap) { - $obj = new IT(3, $trap); - try { - // IS_CV - foreach ($obj as $key => $val) echo "$val\n"; - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } - unset($obj); + $obj = new IT(3, $trap); + try { + // IS_CV + foreach ($obj as $key => $val) echo "$val\n"; + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } + unset($obj); - try { - // IS_VAR - foreach (new IT(3, $trap) as $key => $val) echo "$val\n"; - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + try { + // IS_VAR + foreach (new IT(3, $trap) as $key => $val) echo "$val\n"; + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } - try { - // IS_TMP_VAR - foreach ((object)new IT(2, $trap) as $key => $val) echo "$val\n"; - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + try { + // IS_TMP_VAR + foreach ((object)new IT(2, $trap) as $key => $val) echo "$val\n"; + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } } ?> --EXPECT-- diff --git a/Zend/tests/foreach_004.phpt b/Zend/tests/foreach_004.phpt index 1f754a77edd3..8a7b915c2e96 100644 --- a/Zend/tests/foreach_004.phpt +++ b/Zend/tests/foreach_004.phpt @@ -6,14 +6,14 @@ class IT extends ArrayIterator { private $n = 0; function __construct($trap = null) { - parent::__construct([0, 1]); - $this->trap = $trap; + parent::__construct([0, 1]); + $this->trap = $trap; } function trap($trap) { - if ($trap === $this->trap) { - throw new Exception($trap); - } + if ($trap === $this->trap) { + throw new Exception($trap); + } } function rewind() {$this->trap(__FUNCTION__); return parent::rewind();} @@ -23,28 +23,28 @@ class IT extends ArrayIterator { } foreach(['rewind', 'valid', 'key', 'next'] as $trap) { - $obj = new IT($trap); - try { - // IS_CV - foreach ($obj as $key => &$val) echo "$val\n"; - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } - unset($obj); + $obj = new IT($trap); + try { + // IS_CV + foreach ($obj as $key => &$val) echo "$val\n"; + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } + unset($obj); - try { - // IS_VAR - foreach (new IT($trap) as $key => &$val) echo "$val\n"; - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + try { + // IS_VAR + foreach (new IT($trap) as $key => &$val) echo "$val\n"; + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } - try { - // IS_TMP_VAR - foreach ((object)new IT($trap) as $key => &$val) echo "$val\n"; - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + try { + // IS_TMP_VAR + foreach ((object)new IT($trap) as $key => &$val) echo "$val\n"; + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } } ?> --EXPECT-- diff --git a/Zend/tests/foreach_005.phpt b/Zend/tests/foreach_005.phpt index 063dc70de069..097d74d4fded 100644 --- a/Zend/tests/foreach_005.phpt +++ b/Zend/tests/foreach_005.phpt @@ -4,10 +4,10 @@ Nested foreach by reference on the same array --EXPECT-- diff --git a/Zend/tests/foreach_006.phpt b/Zend/tests/foreach_006.phpt index 65d6fdc52cc8..8e81a686b5bc 100644 --- a/Zend/tests/foreach_006.phpt +++ b/Zend/tests/foreach_006.phpt @@ -3,9 +3,9 @@ Foreach by reference on constant --FILE-- --EXPECT-- diff --git a/Zend/tests/foreach_007.phpt b/Zend/tests/foreach_007.phpt index b99bc73ebe44..09cf60246ef5 100644 --- a/Zend/tests/foreach_007.phpt +++ b/Zend/tests/foreach_007.phpt @@ -4,8 +4,8 @@ Foreach by reference and inserting new element when we are already at the end --EXPECT-- diff --git a/Zend/tests/foreach_008.phpt b/Zend/tests/foreach_008.phpt index c68bcd89da76..c412ac3f8d61 100644 --- a/Zend/tests/foreach_008.phpt +++ b/Zend/tests/foreach_008.phpt @@ -4,13 +4,13 @@ Nested foreach by reference and array modification --EXPECT-- diff --git a/Zend/tests/foreach_009.phpt b/Zend/tests/foreach_009.phpt index 754d9acb2f33..a1859fc7efc7 100644 --- a/Zend/tests/foreach_009.phpt +++ b/Zend/tests/foreach_009.phpt @@ -5,12 +5,12 @@ Nested foreach by reference and array modification with resize $a = [0, 1, 2, 3, 4, 5, 6, 7]; unset($a[0], $a[1], $a[2], $a[3]); foreach ($a as &$ref) { - foreach ($a as &$ref2) { - echo "$ref-$ref2\n"; - if ($ref == 5 && $ref2 == 6) { - $a[42] = 8; - } - } + foreach ($a as &$ref2) { + echo "$ref-$ref2\n"; + if ($ref == 5 && $ref2 == 6) { + $a[42] = 8; + } + } } ?> --EXPECT-- diff --git a/Zend/tests/foreach_010.phpt b/Zend/tests/foreach_010.phpt index a86f87f6df86..8a60b89dc2ac 100644 --- a/Zend/tests/foreach_010.phpt +++ b/Zend/tests/foreach_010.phpt @@ -5,12 +5,12 @@ Nested foreach by value over object and object modification with resize $o = (object)['a'=>0, 'b'=>1, 'c'=>2, 'd'=>3, 'e'=>4, 'f'=>5, 'g'=>6, 'h'=>7]; unset($o->a, $o->b, $o->c, $o->d); foreach ($o as $v1) { - foreach ($o as $v2) { - echo "$v1-$v2\n"; - if ($v1 == 5 && $v2 == 6) { - $o->i = 8; - } - } + foreach ($o as $v2) { + echo "$v1-$v2\n"; + if ($v1 == 5 && $v2 == 6) { + $o->i = 8; + } + } } ?> --EXPECT-- diff --git a/Zend/tests/foreach_011.phpt b/Zend/tests/foreach_011.phpt index e91426fb27df..37eb55a12697 100644 --- a/Zend/tests/foreach_011.phpt +++ b/Zend/tests/foreach_011.phpt @@ -4,10 +4,10 @@ sort() functions precerve foreach by reference iterator pointer --EXPECT-- diff --git a/Zend/tests/foreach_012.phpt b/Zend/tests/foreach_012.phpt index 517e0ac94319..59a5aff0a8b9 100644 --- a/Zend/tests/foreach_012.phpt +++ b/Zend/tests/foreach_012.phpt @@ -4,10 +4,10 @@ array_walk() function precerve foreach by reference iterator pointer --EXPECT-- diff --git a/Zend/tests/foreach_013.phpt b/Zend/tests/foreach_013.phpt index cfbb3d7f7915..8a88c459ec57 100644 --- a/Zend/tests/foreach_013.phpt +++ b/Zend/tests/foreach_013.phpt @@ -4,10 +4,10 @@ array_push() function precerve foreach by reference iterator pointer --EXPECT-- diff --git a/Zend/tests/foreach_014.phpt b/Zend/tests/foreach_014.phpt index 8d0ac582a9ec..ce05ad141072 100644 --- a/Zend/tests/foreach_014.phpt +++ b/Zend/tests/foreach_014.phpt @@ -4,10 +4,10 @@ array_pop() function precerve foreach by reference iterator pointer --EXPECT-- diff --git a/Zend/tests/foreach_015.phpt b/Zend/tests/foreach_015.phpt index b7482b66a027..865356db1bba 100644 --- a/Zend/tests/foreach_015.phpt +++ b/Zend/tests/foreach_015.phpt @@ -4,8 +4,8 @@ array_shift() function precerve foreach by reference iterator pointer diff --git a/Zend/tests/foreach_016.phpt b/Zend/tests/foreach_016.phpt index 423c8dd0a624..461c5b2431b4 100644 --- a/Zend/tests/foreach_016.phpt +++ b/Zend/tests/foreach_016.phpt @@ -4,10 +4,10 @@ array_unshift() function precerve foreach by reference iterator pointer diff --git a/Zend/tests/foreach_017.phpt b/Zend/tests/foreach_017.phpt index e27b04c934ef..022086236301 100644 --- a/Zend/tests/foreach_017.phpt +++ b/Zend/tests/foreach_017.phpt @@ -6,11 +6,11 @@ array_splice() function precerve foreach by reference iterator pointer $done = 0; $a = [0,1,2,3,4]; foreach($a as &$v) { - echo "$v\n"; - if (!$done && $v == 3) { - $done = 1; - array_splice($a, 1, 2); - } + echo "$v\n"; + if (!$done && $v == 3) { + $done = 1; + array_splice($a, 1, 2); + } } echo "\n"; @@ -18,11 +18,11 @@ echo "\n"; $done = 0; $a = [0,1,2,3,4]; foreach($a as &$v) { - echo "$v\n"; - if (!$done && $v == 0) { - $done = 1; - array_splice($a, 2, 2); - } + echo "$v\n"; + if (!$done && $v == 0) { + $done = 1; + array_splice($a, 2, 2); + } } echo "\n"; @@ -30,11 +30,11 @@ echo "\n"; $done = 0; $a = [0,1,2,3,4]; foreach($a as &$v) { - echo "$v\n"; - if (!$done && $v == 2) { - $done = 1; - array_splice($a, 1, 3); - } + echo "$v\n"; + if (!$done && $v == 2) { + $done = 1; + array_splice($a, 1, 3); + } } echo "\n"; @@ -44,11 +44,11 @@ $replacement = ['x', 'y', 'z']; $done = 0; $a = [0,1,2,3,4]; foreach($a as &$v) { - echo "$v\n"; - if (!$done && $v == 3) { - $done = 1; - array_splice($a, 1, 2, $replacement); - } + echo "$v\n"; + if (!$done && $v == 3) { + $done = 1; + array_splice($a, 1, 2, $replacement); + } } echo "\n"; @@ -56,11 +56,11 @@ echo "\n"; $done = 0; $a = [0,1,2,3,4]; foreach($a as &$v) { - echo "$v\n"; - if (!$done && $v == 0) { - $done = 1; - array_splice($a, 2, 2, $replacement); - } + echo "$v\n"; + if (!$done && $v == 0) { + $done = 1; + array_splice($a, 2, 2, $replacement); + } } echo "\n"; @@ -68,11 +68,11 @@ echo "\n"; $done = 0; $a = [0,1,2,3,4]; foreach($a as &$v) { - echo "$v\n"; - if (!$done && $v == 2) { - $done = 1; - array_splice($a, 1, 3, $replacement); - } + echo "$v\n"; + if (!$done && $v == 2) { + $done = 1; + array_splice($a, 1, 3, $replacement); + } } echo "\n"; ?> diff --git a/Zend/tests/foreach_shadowed_dyn_property.phpt b/Zend/tests/foreach_shadowed_dyn_property.phpt index 8f71cdf24084..acbd05bf6d95 100644 --- a/Zend/tests/foreach_shadowed_dyn_property.phpt +++ b/Zend/tests/foreach_shadowed_dyn_property.phpt @@ -2,7 +2,7 @@ Dynamic property shadowed by private property --FILE-- 1, "b" => 2); foreach ($arr as $key => $val) { - unset($GLOBALS[$key]); + unset($GLOBALS[$key]); } var_dump($arr); diff --git a/Zend/tests/fr47160.phpt b/Zend/tests/fr47160.phpt index 6567804902b9..9702537e3707 100644 --- a/Zend/tests/fr47160.phpt +++ b/Zend/tests/fr47160.phpt @@ -4,36 +4,36 @@ Calling method from array getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { array_diff([]); } catch (ArgumentCountError $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; echo $e->getMessage(), "\n"; } --EXPECT-- diff --git a/Zend/tests/function_arguments/argument_count_incorrect_userland.phpt b/Zend/tests/function_arguments/argument_count_incorrect_userland.phpt index 94525c85b72d..1e7969b44ceb 100644 --- a/Zend/tests/function_arguments/argument_count_incorrect_userland.phpt +++ b/Zend/tests/function_arguments/argument_count_incorrect_userland.phpt @@ -3,35 +3,35 @@ Call userland function with incorrect number of arguments --FILE-- getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { - function bar($foo, $bar) { } - bar(1); + function bar($foo, $bar) { } + bar(1); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } function bat(int $foo, string $bar) { } try { - bat(123); + bat(123); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { - bat("123"); + bat("123"); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } --EXPECTF-- ArgumentCountError diff --git a/Zend/tests/function_arguments/argument_count_incorrect_userland_strict.phpt b/Zend/tests/function_arguments/argument_count_incorrect_userland_strict.phpt index 1e535ea9f99a..e47d03d5f675 100644 --- a/Zend/tests/function_arguments/argument_count_incorrect_userland_strict.phpt +++ b/Zend/tests/function_arguments/argument_count_incorrect_userland_strict.phpt @@ -4,42 +4,42 @@ Call userland function with incorrect number of arguments with strict types getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { - function bar($foo, $bar) { } - bar(1); + function bar($foo, $bar) { } + bar(1); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } function bat(int $foo, string $bar) { } try { - bat(123); + bat(123); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { - bat("123"); + bat("123"); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { - bat(123, 456); + bat(123, 456); } catch (\Error $e) { - echo get_class($e) . PHP_EOL; - echo $e->getMessage() . PHP_EOL; + echo get_class($e) . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } --EXPECTF-- ArgumentCountError diff --git a/Zend/tests/function_arguments_003.phpt b/Zend/tests/function_arguments_003.phpt index b882476d1d90..aa7fd0a19777 100644 --- a/Zend/tests/function_arguments_003.phpt +++ b/Zend/tests/function_arguments_003.phpt @@ -5,7 +5,7 @@ Function Argument Parsing #003 const a = 10; function t1($a = 1 + 1, $b = 1 << 2, $c = "foo" . "bar", $d = a * 10) { - var_dump($a, $b, $c, $d); + var_dump($a, $b, $c, $d); } t1(); diff --git a/Zend/tests/function_exists_basic.phpt b/Zend/tests/function_exists_basic.phpt index 5125350d8dca..025a4a7d4173 100644 --- a/Zend/tests/function_exists_basic.phpt +++ b/Zend/tests/function_exists_basic.phpt @@ -24,7 +24,7 @@ var_dump(function_exists('g')); echo "Method: "; Class C { - static function f() {} + static function f() {} } var_dump(function_exists('C::f')); ?> diff --git a/Zend/tests/gc_011.phpt b/Zend/tests/gc_011.phpt index d11d7b6b46e4..3c6731c547e8 100644 --- a/Zend/tests/gc_011.phpt +++ b/Zend/tests/gc_011.phpt @@ -5,10 +5,10 @@ zend.enable_gc=1 --FILE-- a = $a; diff --git a/Zend/tests/gc_012.phpt b/Zend/tests/gc_012.phpt index f6c853897987..409d2d8f169a 100644 --- a/Zend/tests/gc_012.phpt +++ b/Zend/tests/gc_012.phpt @@ -6,8 +6,8 @@ zend.enable_gc=1 {"a".$i} = $a; + $b =& $a; + $a->{"a".$i} = $a; } unset($b); $a->b = "xxx"; diff --git a/Zend/tests/gc_016.phpt b/Zend/tests/gc_016.phpt index 211f03a60530..f28005e1bc5e 100644 --- a/Zend/tests/gc_016.phpt +++ b/Zend/tests/gc_016.phpt @@ -5,14 +5,14 @@ zend.enable_gc=1 --FILE-- "; - $a = array(); - $a[] =& $a; - unset($a); - var_dump(gc_collect_cycles()); - } + public $a; + function __destruct() { + echo "-> "; + $a = array(); + $a[] =& $a; + unset($a); + var_dump(gc_collect_cycles()); + } } $a = new Foo(); $a->a = $a; diff --git a/Zend/tests/gc_017.phpt b/Zend/tests/gc_017.phpt index 55f381992e69..118da8341333 100644 --- a/Zend/tests/gc_017.phpt +++ b/Zend/tests/gc_017.phpt @@ -5,23 +5,23 @@ zend.enable_gc=1 --FILE-- name = $name; - $this->parent = null; - } - function insert($node) { - $node->parent = $this; - $this->children[] = $node; - } - function __destruct() { - var_dump($this->name); - unset($this->name); - unset($this->children); - unset($this->parent); - } + public $name; + public $children; + public $parent; + function __construct($name) { + $this->name = $name; + $this->parent = null; + } + function insert($node) { + $node->parent = $this; + $this->children[] = $node; + } + function __destruct() { + var_dump($this->name); + unset($this->name); + unset($this->children); + unset($this->parent); + } } $a = new Node('A'); $b = new Node('B'); diff --git a/Zend/tests/gc_023.phpt b/Zend/tests/gc_023.phpt index 6d6e1e6376bb..3f1b0f0187f3 100644 --- a/Zend/tests/gc_023.phpt +++ b/Zend/tests/gc_023.phpt @@ -6,16 +6,16 @@ zend.enable_gc=1 bar !== null) { - unset($this->bar); - } - } + public $bar; + function __destruct() { + if ($this->bar !== null) { + unset($this->bar); + } + } } class Bar { - public $foo; + public $foo; function __destruct() { if ($this->foo !== null) { unset($this->foo); diff --git a/Zend/tests/gc_029.phpt b/Zend/tests/gc_029.phpt index 89c55e5ba76d..b5ecc8fff21b 100644 --- a/Zend/tests/gc_029.phpt +++ b/Zend/tests/gc_029.phpt @@ -5,17 +5,17 @@ zend.enable_gc=1 --FILE-- bar !== null) { - $this->x = null; - unset($this->bar); - } - } + public $bar; + public $x = array(1,2,3); + function __destruct() { + if ($this->bar !== null) { + $this->x = null; + unset($this->bar); + } + } } class Bar { - public $foo; + public $foo; function __destruct() { if ($this->foo !== null) { unset($this->foo); diff --git a/Zend/tests/gc_033.phpt b/Zend/tests/gc_033.phpt index 1fd36976add0..cc28fd6a1062 100644 --- a/Zend/tests/gc_033.phpt +++ b/Zend/tests/gc_033.phpt @@ -18,9 +18,9 @@ unset($a); /* let's full the gc roots */ for ($i=0; $i<9999; $i++) { - $b = range(0, 1); - $b[0] = &$b; - unset($b); + $b = range(0, 1); + $b[0] = &$b; + unset($b); } /* then $a will be freed, but $a->a[0] is not. reference to a freed $a */ diff --git a/Zend/tests/gc_035.phpt b/Zend/tests/gc_035.phpt index 187af9108bd7..56b4aae866db 100644 --- a/Zend/tests/gc_035.phpt +++ b/Zend/tests/gc_035.phpt @@ -5,11 +5,11 @@ zend.enable_gc = 1 --FILE-- x); - } + public $a; + public $x; + function __destruct() { + unset($this->x); + } } $a = new A; $a->a = $a; diff --git a/Zend/tests/gc_036.phpt b/Zend/tests/gc_036.phpt index 67f9a4546522..40b65987e273 100644 --- a/Zend/tests/gc_036.phpt +++ b/Zend/tests/gc_036.phpt @@ -5,12 +5,12 @@ zend.enable_gc = 1 --FILE-- x= $x; - @$x += 5; - $n = gc_collect_cycles(); - echo "+=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x += 5; + $n = gc_collect_cycles(); + echo "+=\t$n\n"; } test_add(); function test_sub() { - $x = new stdClass; - $x->x= $x; - @$x -= 5; - $n = gc_collect_cycles(); - echo "-=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x -= 5; + $n = gc_collect_cycles(); + echo "-=\t$n\n"; } test_sub(); function test_mul() { - $x = new stdClass; - $x->x= $x; - @$x *= 5; - $n = gc_collect_cycles(); - echo "*=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x *= 5; + $n = gc_collect_cycles(); + echo "*=\t$n\n"; } test_mul(); function test_div() { - $x = new stdClass; - $x->x= $x; - @$x /= 5; - $n = gc_collect_cycles(); - echo "/=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x /= 5; + $n = gc_collect_cycles(); + echo "/=\t$n\n"; } test_div(); function test_mod() { - $x = new stdClass; - $x->x= $x; - @$x %= 5; - $n = gc_collect_cycles(); - echo "%=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x %= 5; + $n = gc_collect_cycles(); + echo "%=\t$n\n"; } test_mod(); function test_sl() { - $x = new stdClass; - $x->x= $x; - @$x <<= 5; - $n = gc_collect_cycles(); - echo "<<=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x <<= 5; + $n = gc_collect_cycles(); + echo "<<=\t$n\n"; } test_sl(); function test_sr() { - $x = new stdClass; - $x->x= $x; - @$x >>= 5; - $n = gc_collect_cycles(); - echo ">>=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x >>= 5; + $n = gc_collect_cycles(); + echo ">>=\t$n\n"; } test_sr(); function test_or() { - $x = new stdClass; - $x->x= $x; - @$x |= 1; - $n = gc_collect_cycles(); - echo "|=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x |= 1; + $n = gc_collect_cycles(); + echo "|=\t$n\n"; } test_or(); function test_and() { - $x = new stdClass; - $x->x= $x; - @$x &= 1; - $n = gc_collect_cycles(); - echo "&=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x &= 1; + $n = gc_collect_cycles(); + echo "&=\t$n\n"; } test_and(); function test_xor() { - $x = new stdClass; - $x->x= $x; - @$x ^= 1; - $n = gc_collect_cycles(); - echo "^=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x ^= 1; + $n = gc_collect_cycles(); + echo "^=\t$n\n"; } test_xor(); function test_pow() { - $x = new stdClass; - $x->x= $x; - @$x **= 1; - $n = gc_collect_cycles(); - echo "**=\t$n\n"; + $x = new stdClass; + $x->x= $x; + @$x **= 1; + $n = gc_collect_cycles(); + echo "**=\t$n\n"; } test_pow(); class Y { - function __toString() { - return "y"; - } + function __toString() { + return "y"; + } } function test_concat() { - $x = new Y; - $x->x= $x; - @$x .= "x"; - $n = gc_collect_cycles(); - echo ".=\t$n\n"; + $x = new Y; + $x->x= $x; + @$x .= "x"; + $n = gc_collect_cycles(); + echo ".=\t$n\n"; } test_concat(); ?> diff --git a/Zend/tests/gc_041.phpt b/Zend/tests/gc_041.phpt index fc849991e173..e5870286ba29 100644 --- a/Zend/tests/gc_041.phpt +++ b/Zend/tests/gc_041.phpt @@ -5,11 +5,11 @@ zend.enable_gc = 1 --FILE-- 0; - } catch (Exception $e) { print "catch in gen()\n$e\n"; } - try { - yield from from(0); - } catch (Exception $e) { print "catch in gen()\n$e\n"; } - yield from from(2); + try { + yield "gen" => 0; + } catch (Exception $e) { print "catch in gen()\n$e\n"; } + try { + yield from from(0); + } catch (Exception $e) { print "catch in gen()\n$e\n"; } + yield from from(2); } $i = 0; try { - for ($gen = gen(); $gen->valid(); $gen->throw(new Exception((string) $i++))) { - var_dump($gen->current()); - } + for ($gen = gen(); $gen->valid(); $gen->throw(new Exception((string) $i++))) { + var_dump($gen->current()); + } } catch (Exception $e) { print "catch in {main}\n$e\n"; } var_dump($gen->valid()); diff --git a/Zend/tests/generators/basic_yield_from_proxying.phpt b/Zend/tests/generators/basic_yield_from_proxying.phpt index 74ffc5da800c..ce9a09cba30b 100644 --- a/Zend/tests/generators/basic_yield_from_proxying.phpt +++ b/Zend/tests/generators/basic_yield_from_proxying.phpt @@ -3,24 +3,24 @@ Basic test if yield from works --FILE-- 1; - yield 2; + yield "from" => 1; + yield 2; } function gen() { - yield "gen" => 0; - yield from from(); - yield 3; + yield "gen" => 0; + yield from from(); + yield 3; } /* foreach API */ foreach (gen() as $k => $v) { - var_dump($k, $v); + var_dump($k, $v); } /* iterator API */ for ($gen = gen(); $gen->valid(); $gen->next()) { - var_dump($gen->key(), $gen->current()); + var_dump($gen->key(), $gen->current()); } ?> --EXPECT-- diff --git a/Zend/tests/generators/bug63066.phpt b/Zend/tests/generators/bug63066.phpt index 3237c8a7a3cf..df62fcebe2d5 100644 --- a/Zend/tests/generators/bug63066.phpt +++ b/Zend/tests/generators/bug63066.phpt @@ -4,12 +4,12 @@ Bug #63066 (Calling an undefined method in a generator results in a seg fault) fatalError(); + yield 'foo'; + $o->fatalError(); } foreach(gen(new stdClass()) as $value) - echo $value, "\n"; + echo $value, "\n"; --EXPECTF-- foo diff --git a/Zend/tests/generators/bug67497.phpt b/Zend/tests/generators/bug67497.phpt index edbd578da58f..727847320b0d 100644 --- a/Zend/tests/generators/bug67497.phpt +++ b/Zend/tests/generators/bug67497.phpt @@ -9,7 +9,7 @@ function gen() { } try { - eval('abc'); + eval('abc'); } catch (ParseError $ex) { } diff --git a/Zend/tests/generators/bug70904.phpt b/Zend/tests/generators/bug70904.phpt index cd00e0bb3473..2fbbfe6918fe 100644 --- a/Zend/tests/generators/bug70904.phpt +++ b/Zend/tests/generators/bug70904.phpt @@ -4,13 +4,13 @@ Bug #70904 (yield from incorrectly marks valid generator as finished) diff --git a/Zend/tests/generators/bug71441.phpt b/Zend/tests/generators/bug71441.phpt index 14395d2402e5..a0d270a05f61 100644 --- a/Zend/tests/generators/bug71441.phpt +++ b/Zend/tests/generators/bug71441.phpt @@ -7,13 +7,13 @@ $num = 2000; /* to be sure to be in wild memory */ $add = str_repeat("1 +", $num); $gen = (eval(<<a(); var_dump($gen->current()); diff --git a/Zend/tests/generators/bug74157.phpt b/Zend/tests/generators/bug74157.phpt index e5b9111f7827..7033d8228214 100644 --- a/Zend/tests/generators/bug74157.phpt +++ b/Zend/tests/generators/bug74157.phpt @@ -4,15 +4,15 @@ Bug #74157 (Segfault with nested generators) --EXPECT-- diff --git a/Zend/tests/generators/bug74606.phpt b/Zend/tests/generators/bug74606.phpt index cfb7f7f8cd8e..ec5ef26ee15c 100644 --- a/Zend/tests/generators/bug74606.phpt +++ b/Zend/tests/generators/bug74606.phpt @@ -4,21 +4,21 @@ Bug #74606 (Segfault within try/catch/finally nesting in Generators) throw(new Exception); diff --git a/Zend/tests/generators/bug76427.phpt b/Zend/tests/generators/bug76427.phpt index 53851b0f35fe..dbf466c2def1 100644 --- a/Zend/tests/generators/bug76427.phpt +++ b/Zend/tests/generators/bug76427.phpt @@ -3,7 +3,7 @@ Bug #76427 (Segfault in zend_objects_store_put) --FILE-- next(); - } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; - } - $gen->next(); + $gen->next(); + } catch (Error $e) { + echo "\nException: " . $e->getMessage() . "\n"; + } + $gen->next(); } $gen = gen(); diff --git a/Zend/tests/generators/gc_with_yield_from.phpt b/Zend/tests/generators/gc_with_yield_from.phpt index 952352c8539b..68ec7ebe92e4 100644 --- a/Zend/tests/generators/gc_with_yield_from.phpt +++ b/Zend/tests/generators/gc_with_yield_from.phpt @@ -6,17 +6,17 @@ zend.enable_gc = 1 valid()); diff --git a/Zend/tests/generators/generator_return_without_value.phpt b/Zend/tests/generators/generator_return_without_value.phpt index c507ebeb9cf5..3aed7feea006 100644 --- a/Zend/tests/generators/generator_return_without_value.phpt +++ b/Zend/tests/generators/generator_return_without_value.phpt @@ -14,12 +14,12 @@ function gen2() { } function gen3() { - return; + return; yield; } function gen4() { - return; + return; yield; } diff --git a/Zend/tests/generators/generator_returns_generator.phpt b/Zend/tests/generators/generator_returns_generator.phpt index ad332a3be924..cdf9e06e69d6 100644 --- a/Zend/tests/generators/generator_returns_generator.phpt +++ b/Zend/tests/generators/generator_returns_generator.phpt @@ -6,7 +6,7 @@ A generator function returns a Generator object function gen() { // execution is suspended here, so the following never gets run: echo "Foo"; - // trigger a generator + // trigger a generator yield; } diff --git a/Zend/tests/generators/generator_symtable_leak.phpt b/Zend/tests/generators/generator_symtable_leak.phpt index 7c736222d016..778b72479a7f 100644 --- a/Zend/tests/generators/generator_symtable_leak.phpt +++ b/Zend/tests/generators/generator_symtable_leak.phpt @@ -4,10 +4,10 @@ Generators using symtables must not leak valid(); diff --git a/Zend/tests/generators/generator_with_type_check_2.phpt b/Zend/tests/generators/generator_with_type_check_2.phpt index ba1216224c81..d4ebbd2ad3b5 100644 --- a/Zend/tests/generators/generator_with_type_check_2.phpt +++ b/Zend/tests/generators/generator_with_type_check_2.phpt @@ -4,15 +4,15 @@ Generator wit type check getMessage()."\n"; + echo $e->getMessage()."\n"; } try { - foreach (gen(42) as $val) { - var_dump($val); - } + foreach (gen(42) as $val) { + var_dump($val); + } } catch (TypeError $e) { echo $e->getMessage()."\n"; } diff --git a/Zend/tests/generators/multiple_yield_from_on_same_generator.phpt b/Zend/tests/generators/multiple_yield_from_on_same_generator.phpt index 52dbea89b2be..b0de7d32d1c8 100644 --- a/Zend/tests/generators/multiple_yield_from_on_same_generator.phpt +++ b/Zend/tests/generators/multiple_yield_from_on_same_generator.phpt @@ -4,16 +4,16 @@ Multiple yield from on a same Generator instance current()); - $g->next(); - } + foreach ($gens as $g) { + var_dump($g->current()); + $g->next(); + } } while($gens[0]->valid()); var_dump($gens[1]->valid()); diff --git a/Zend/tests/generators/mutli_yield_from_with_exception.phpt b/Zend/tests/generators/mutli_yield_from_with_exception.phpt index 4be2449a4667..30b188515d03 100644 --- a/Zend/tests/generators/mutli_yield_from_with_exception.phpt +++ b/Zend/tests/generators/mutli_yield_from_with_exception.phpt @@ -3,14 +3,14 @@ Multiple yield from on a same Generator throwing an Exception --FILE-- current(); // init. + $g->current(); // init. } do { - foreach ($gens as $i => $g) { - print "Generator $i\n"; - var_dump($g->current()); - $g->next(); - } + foreach ($gens as $i => $g) { + print "Generator $i\n"; + var_dump($g->current()); + $g->next(); + } } while($gens[0]->valid()); ?> --EXPECTF-- diff --git a/Zend/tests/generators/no_foreach_var_leaks.phpt b/Zend/tests/generators/no_foreach_var_leaks.phpt index 62743895ebcb..c9d56b9fb7b0 100644 --- a/Zend/tests/generators/no_foreach_var_leaks.phpt +++ b/Zend/tests/generators/no_foreach_var_leaks.phpt @@ -4,9 +4,9 @@ foreach() (and other) variables aren't leaked on premature close --EXPECT-- diff --git a/Zend/tests/generators/throw_into_yield_from_array.phpt b/Zend/tests/generators/throw_into_yield_from_array.phpt index b1571f663997..aa9fa822061b 100644 --- a/Zend/tests/generators/throw_into_yield_from_array.phpt +++ b/Zend/tests/generators/throw_into_yield_from_array.phpt @@ -6,23 +6,23 @@ Throwing into a generator yielding from an array/iterator $data = [1, 2, 3]; function yielditer($arr) { - foreach($arr as $val) { - yield $val; - } + foreach($arr as $val) { + yield $val; + } } function yf($in) { - yield from $in; + yield from $in; } function test($g) { - var_dump($g->current()); - try { - $g->throw(new Exception("Exception!")); - } catch (Exception $e) { - echo "{$e->getMessage()}\n"; - } - var_dump($g->current()); + var_dump($g->current()); + try { + $g->throw(new Exception("Exception!")); + } catch (Exception $e) { + echo "{$e->getMessage()}\n"; + } + var_dump($g->current()); } $yfiter = yf($data); diff --git a/Zend/tests/generators/xrange.phpt b/Zend/tests/generators/xrange.phpt index 4d8b60fa909a..3b8283e15022 100644 --- a/Zend/tests/generators/xrange.phpt +++ b/Zend/tests/generators/xrange.phpt @@ -4,13 +4,13 @@ Simple generator xrange() test diff --git a/Zend/tests/generators/yield_during_function_call.phpt b/Zend/tests/generators/yield_during_function_call.phpt index 21071f9fb4af..9960e6d92b9c 100644 --- a/Zend/tests/generators/yield_during_function_call.phpt +++ b/Zend/tests/generators/yield_during_function_call.phpt @@ -4,7 +4,7 @@ send($gen); diff --git a/Zend/tests/generators/yield_from_array.phpt b/Zend/tests/generators/yield_from_array.phpt index 1652ab22365b..b1560170b1d2 100644 --- a/Zend/tests/generators/yield_from_array.phpt +++ b/Zend/tests/generators/yield_from_array.phpt @@ -3,17 +3,17 @@ yielding values from an array --FILE-- --EXPECT-- diff --git a/Zend/tests/generators/yield_from_backtrace.phpt b/Zend/tests/generators/yield_from_backtrace.phpt index e5d79723e7f0..8fb1aeef8cb1 100644 --- a/Zend/tests/generators/yield_from_backtrace.phpt +++ b/Zend/tests/generators/yield_from_backtrace.phpt @@ -3,26 +3,26 @@ Exceptions in linear yield from setup --FILE-- valid(); $gen->next()) { - var_dump($gen->current()); + var_dump($gen->current()); } ?> --EXPECTF-- diff --git a/Zend/tests/generators/yield_from_deep_recursion.phpt b/Zend/tests/generators/yield_from_deep_recursion.phpt index 8ef3b891299d..f6d6c3e79fa4 100644 --- a/Zend/tests/generators/yield_from_deep_recursion.phpt +++ b/Zend/tests/generators/yield_from_deep_recursion.phpt @@ -5,20 +5,20 @@ Deep recursion with yield from ini_set("memory_limit", "512M"); function from($i) { - yield $i; + yield $i; } function gen($i = 0) { - if ($i < 50000) { - yield from gen(++$i); - } else { - yield $i; - yield from from(++$i); - } + if ($i < 50000) { + yield from gen(++$i); + } else { + yield $i; + yield from from(++$i); + } } foreach (gen() as $v) { - var_dump($v); + var_dump($v); } ?> --EXPECT-- diff --git a/Zend/tests/generators/yield_from_iterator.phpt b/Zend/tests/generators/yield_from_iterator.phpt index 959d6a2d3311..162a4dd9e345 100644 --- a/Zend/tests/generators/yield_from_iterator.phpt +++ b/Zend/tests/generators/yield_from_iterator.phpt @@ -3,14 +3,14 @@ yield from with an (Array)Iterator --FILE-- --EXPECT-- diff --git a/Zend/tests/generators/yield_from_multi_tree.phpt b/Zend/tests/generators/yield_from_multi_tree.phpt index 9bec1381496f..a8fd195bd6b6 100644 --- a/Zend/tests/generators/yield_from_multi_tree.phpt +++ b/Zend/tests/generators/yield_from_multi_tree.phpt @@ -4,41 +4,41 @@ yield from on multiple trees needing merge current(); - } - yield from $gen; + if ($level % 2) { + yield $gen->current(); + } + yield from $gen; } foreach (range(0, 6) as $levels) { - print "$levels level".($levels == 1 ? "" : "s")."\n\n"; + print "$levels level".($levels == 1 ? "" : "s")."\n\n"; - $all = array(); - $all[] = $gens[0][0] = from($levels); + $all = array(); + $all[] = $gens[0][0] = from($levels); - for ($level = 1; $level < $levels; $level++) { - for ($i = 0; $i < (1 << $level); $i++) { - $all[] = $gens[$level][$i] = gen($gens[$level-1][$i >> 1], $level); - } - } + for ($level = 1; $level < $levels; $level++) { + for ($i = 0; $i < (1 << $level); $i++) { + $all[] = $gens[$level][$i] = gen($gens[$level-1][$i >> 1], $level); + } + } - while (1) { - foreach ($all as $gen) { - var_dump($gen->current()); - $gen->next(); - if (!$gen->valid()) { - break 2; - } - } - } + while (1) { + foreach ($all as $gen) { + var_dump($gen->current()); + $gen->next(); + if (!$gen->valid()) { + break 2; + } + } + } - print "\n\n"; + print "\n\n"; } ?> --EXPECT-- diff --git a/Zend/tests/generators/yield_from_multi_tree_exception.phpt b/Zend/tests/generators/yield_from_multi_tree_exception.phpt index 4ff2e4e41f5a..cb8aedfd327f 100644 --- a/Zend/tests/generators/yield_from_multi_tree_exception.phpt +++ b/Zend/tests/generators/yield_from_multi_tree_exception.phpt @@ -4,16 +4,16 @@ yield from on multiple trees needing merge > 1], $level); - } + for ($i = 0; $i < (1 << $level); $i++) { + $all[] = $gens[$level][$i] = gen($gens[$level-1][$i >> 1], $level); + } } for ($i = 0; $i < 2; $i++) { - try { - foreach ($all as $gen) { - var_dump($gen->current()); - $gen->next(); - if (!$gen->valid()) { - break; - } - } - } catch(Exception $e) { - print "$e\n"; - unset($all[array_search($gen, $all)]); - } + try { + foreach ($all as $gen) { + var_dump($gen->current()); + $gen->next(); + if (!$gen->valid()) { + break; + } + } + } catch(Exception $e) { + print "$e\n"; + unset($all[array_search($gen, $all)]); + } } ?> --EXPECTF-- diff --git a/Zend/tests/generators/yield_unary_precedence.phpt b/Zend/tests/generators/yield_unary_precedence.phpt index 54eb0feb5f97..3ebeed2d8c8b 100644 --- a/Zend/tests/generators/yield_unary_precedence.phpt +++ b/Zend/tests/generators/yield_unary_precedence.phpt @@ -3,14 +3,14 @@ When + or - are used on yield, they must be unary (and not binary) (Bug #69160) --FILE-- valid(); $gen->send(1)) { - echo "\n"; - var_dump($gen->current()); + echo "\n"; + var_dump($gen->current()); } ?> --EXPECT-- diff --git a/Zend/tests/get_class_methods_001.phpt b/Zend/tests/get_class_methods_001.phpt index d0d51220aab1..3ec51f1bcd40 100644 --- a/Zend/tests/get_class_methods_001.phpt +++ b/Zend/tests/get_class_methods_001.phpt @@ -4,18 +4,18 @@ get_class_methods(): Testing scope a, $this->b, $this->c); - } + var_dump($this->a, $this->b, $this->c); + } } new C; diff --git a/Zend/tests/get_class_vars_003.phpt b/Zend/tests/get_class_vars_003.phpt index 5fe9f9971b3f..5659a49704fe 100644 --- a/Zend/tests/get_class_vars_003.phpt +++ b/Zend/tests/get_class_vars_003.phpt @@ -4,29 +4,29 @@ get_class_vars(): Testing the scope diff --git a/Zend/tests/get_parent_class_001.phpt b/Zend/tests/get_parent_class_001.phpt index 95395f935be4..fefcbeb6833e 100644 --- a/Zend/tests/get_parent_class_001.phpt +++ b/Zend/tests/get_parent_class_001.phpt @@ -4,19 +4,19 @@ Testing get_parent_class() getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } $foo = new foo; $arr = array($foo, 'abc'); diff --git a/Zend/tests/indirect_call_array_004.phpt b/Zend/tests/indirect_call_array_004.phpt index 07d8a0921514..e8520efd12b0 100644 --- a/Zend/tests/indirect_call_array_004.phpt +++ b/Zend/tests/indirect_call_array_004.phpt @@ -4,36 +4,36 @@ Indirect method call by array - Testing exception and method magics getMessage(), "\n"; + echo $e->getMessage(), "\n"; } $arr = array('foo', '123'); try { - $arr(); + $arr(); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } @@ -43,10 +43,10 @@ $foo = new foo; $arr = array($foo, 'abc'); try { - $arr(); + $arr(); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } @@ -54,10 +54,10 @@ $foo = new foo; $arr = array($foo, '123'); try { - $arr(); + $arr(); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/Zend/tests/indirect_method_call_001.phpt b/Zend/tests/indirect_method_call_001.phpt index 7018eaa74029..39967fdb267d 100644 --- a/Zend/tests/indirect_method_call_001.phpt +++ b/Zend/tests/indirect_method_call_001.phpt @@ -4,15 +4,15 @@ Testing indirect method call and exceptions Inexistent(3); + $X = (new foo)->Inexistent(3); } catch (Exception $e) { - var_dump($e->getMessage()); // foobar + var_dump($e->getMessage()); // foobar } ?> diff --git a/Zend/tests/indirect_method_call_002.phpt b/Zend/tests/indirect_method_call_002.phpt index 059061f21155..e8ea14b16572 100644 --- a/Zend/tests/indirect_method_call_002.phpt +++ b/Zend/tests/indirect_method_call_002.phpt @@ -4,16 +4,16 @@ Indirect method call with chaining bar()); // string(3) "foo" diff --git a/Zend/tests/indirect_method_call_003.phpt b/Zend/tests/indirect_method_call_003.phpt index 3df495422da7..2ae694d82157 100644 --- a/Zend/tests/indirect_method_call_003.phpt +++ b/Zend/tests/indirect_method_call_003.phpt @@ -4,15 +4,15 @@ Testing indirect method call x; - } - public function setX($val) { - $this->x = $val; - return $this; - } + public function getX() { + return $this->x; + } + public function setX($val) { + $this->x = $val; + return $this; + } } $X = (new foo)->setX(10)->getX(); diff --git a/Zend/tests/indirect_method_call_004.phpt b/Zend/tests/indirect_method_call_004.phpt index 689600d1f446..6a4055595c2f 100644 --- a/Zend/tests/indirect_method_call_004.phpt +++ b/Zend/tests/indirect_method_call_004.phpt @@ -5,14 +5,14 @@ Indirect method call and cloning class bar { - public $z; + public $z; - public function __construct() { - $this->z = new stdclass; - } - public function getZ() { - return $this->z; - } + public function __construct() { + $this->z = new stdclass; + } + public function getZ() { + return $this->z; + } } var_dump(clone (new bar)->z); diff --git a/Zend/tests/indirect_method_call_005.phpt b/Zend/tests/indirect_method_call_005.phpt index 4f4b3631c0f5..d3e2de2c8445 100644 --- a/Zend/tests/indirect_method_call_005.phpt +++ b/Zend/tests/indirect_method_call_005.phpt @@ -4,9 +4,9 @@ Testing array dereferencing from instance with ArrayObject --EXPECT-- diff --git a/Zend/tests/jump04.phpt b/Zend/tests/jump04.phpt index 29ec25d8bd03..ed6ccf6e67a6 100644 --- a/Zend/tests/jump04.phpt +++ b/Zend/tests/jump04.phpt @@ -5,16 +5,16 @@ jump 04: goto from loop (backward) $s = "X"; echo "1: ok\n"; L1: if ($s != "X") { - echo "4: ok\n"; + echo "4: ok\n"; } else { - echo "2: ok\n"; - while ($s != "XXX") { - echo "3: ok\n"; - $s .= "X"; - goto L1; - echo "bug\n"; - } - echo "bug\n"; + echo "2: ok\n"; + while ($s != "XXX") { + echo "3: ok\n"; + $s .= "X"; + goto L1; + echo "bug\n"; + } + echo "bug\n"; } ?> --EXPECT-- diff --git a/Zend/tests/jump05.phpt b/Zend/tests/jump05.phpt index 2e5e50c0682d..1dec75e4a753 100644 --- a/Zend/tests/jump05.phpt +++ b/Zend/tests/jump05.phpt @@ -4,17 +4,17 @@ jump 05: goto from loop (forward) diff --git a/Zend/tests/jump08.phpt b/Zend/tests/jump08.phpt index 25a211c8c443..e2f7cd4bc6d3 100644 --- a/Zend/tests/jump08.phpt +++ b/Zend/tests/jump08.phpt @@ -4,7 +4,7 @@ jump 08: goto into loop (forward) --EXPECTF-- diff --git a/Zend/tests/jump09.phpt b/Zend/tests/jump09.phpt index 52a14b7d542f..1d3420fddb20 100644 --- a/Zend/tests/jump09.phpt +++ b/Zend/tests/jump09.phpt @@ -3,9 +3,9 @@ jump 09: goto into switch (backward) --FILE-- diff --git a/Zend/tests/jump10.phpt b/Zend/tests/jump10.phpt index 67206a29ae84..e69c508d6ad8 100644 --- a/Zend/tests/jump10.phpt +++ b/Zend/tests/jump10.phpt @@ -4,9 +4,9 @@ jump 10: goto into switch (forward) --EXPECTF-- diff --git a/Zend/tests/jump14.phpt b/Zend/tests/jump14.phpt index f55480acc757..4df251f7661d 100644 --- a/Zend/tests/jump14.phpt +++ b/Zend/tests/jump14.phpt @@ -6,21 +6,21 @@ Testing GOTO inside blocks goto A; { - B: - goto C; - return; + B: + goto C; + return; } A: - goto B; + goto B; { - C: - { - print "Done!\n"; - } + C: + { + print "Done!\n"; + } } ?> diff --git a/Zend/tests/jump15.phpt b/Zend/tests/jump15.phpt index 456d27785de1..4f599a3bb072 100644 --- a/Zend/tests/jump15.phpt +++ b/Zend/tests/jump15.phpt @@ -4,22 +4,22 @@ jump 15: goto from loop (forward) diff --git a/Zend/tests/jump16.phpt b/Zend/tests/jump16.phpt index cc820c4a6cb7..0a4acd14225d 100644 --- a/Zend/tests/jump16.phpt +++ b/Zend/tests/jump16.phpt @@ -4,22 +4,22 @@ jump 16: goto into try/catch diff --git a/Zend/tests/jump17.phpt b/Zend/tests/jump17.phpt index 92d3be511b57..62bcaef8236b 100644 --- a/Zend/tests/jump17.phpt +++ b/Zend/tests/jump17.phpt @@ -4,18 +4,18 @@ jump 17: goto into try/catch with finally diff --git a/Zend/tests/lsb_012.phpt b/Zend/tests/lsb_012.phpt index 3ac8d3884007..21ddff3524f4 100644 --- a/Zend/tests/lsb_012.phpt +++ b/Zend/tests/lsb_012.phpt @@ -4,18 +4,18 @@ ZE2 Late Static Binding call to static::method() from internal function (string) diff --git a/Zend/tests/lsb_013.phpt b/Zend/tests/lsb_013.phpt index 3f32dc3a66db..3af7f1bea7eb 100644 --- a/Zend/tests/lsb_013.phpt +++ b/Zend/tests/lsb_013.phpt @@ -4,15 +4,15 @@ ZE2 Late Static Binding is_callable() and static::method() instanceId = self::$nextInstanceId++; - } - return self::$instances[$caller]; - } - public final function getInstanceId() - { - return $this->instanceId; - } - public final function identify() - { - var_dump($this); - } + static private $instances = array(); + static private $nextInstanceId = 0; + private $instanceId = NULL; + static final public function getInstance() + { + $caller = get_called_class(); + if (!isset(self::$instances[$caller])) { + self::$instances[$caller] = new $caller; + self::$instances[$caller]->instanceId = self::$nextInstanceId++; + } + return self::$instances[$caller]; + } + public final function getInstanceId() + { + return $this->instanceId; + } + public final function identify() + { + var_dump($this); + } } class Foo extends Singleton { diff --git a/Zend/tests/lsb_019.phpt b/Zend/tests/lsb_019.phpt index 4073dac8d8a1..74d674dc733e 100644 --- a/Zend/tests/lsb_019.phpt +++ b/Zend/tests/lsb_019.phpt @@ -3,29 +3,29 @@ ZE2 Late Static Binding properties and methods declared as protected and overrid --FILE-- diff --git a/Zend/tests/magic_methods_003.phpt b/Zend/tests/magic_methods_003.phpt index 7e965ba3fda7..cd96d15b2fae 100644 --- a/Zend/tests/magic_methods_003.phpt +++ b/Zend/tests/magic_methods_003.phpt @@ -4,9 +4,9 @@ Testing __unset declaring as static diff --git a/Zend/tests/magic_methods_004.phpt b/Zend/tests/magic_methods_004.phpt index 8caf5d4aa1ba..3c1df73d095b 100644 --- a/Zend/tests/magic_methods_004.phpt +++ b/Zend/tests/magic_methods_004.phpt @@ -4,9 +4,9 @@ Testing __unset() with protected visibility diff --git a/Zend/tests/magic_methods_005.phpt b/Zend/tests/magic_methods_005.phpt index 76ab30087eab..8e7749381ca2 100644 --- a/Zend/tests/magic_methods_005.phpt +++ b/Zend/tests/magic_methods_005.phpt @@ -4,7 +4,7 @@ Testing __call() declaration in interface with wrong modifier diff --git a/Zend/tests/magic_methods_006.phpt b/Zend/tests/magic_methods_006.phpt index 2e84a41c5cc3..68eac7439d6f 100644 --- a/Zend/tests/magic_methods_006.phpt +++ b/Zend/tests/magic_methods_006.phpt @@ -4,7 +4,7 @@ Testing __callstatic declaration in interface with missing the 'static' modifier diff --git a/Zend/tests/magic_methods_007.phpt b/Zend/tests/magic_methods_007.phpt index 0630c63e9f6c..63f4cadff574 100644 --- a/Zend/tests/magic_methods_007.phpt +++ b/Zend/tests/magic_methods_007.phpt @@ -4,7 +4,7 @@ Testing __set() declaration in abstract class with wrong modifier diff --git a/Zend/tests/magic_methods_008.phpt b/Zend/tests/magic_methods_008.phpt index 25731516e66c..7d7a839afe82 100644 --- a/Zend/tests/magic_methods_008.phpt +++ b/Zend/tests/magic_methods_008.phpt @@ -4,12 +4,12 @@ Testing __set implementation with wrong declaration diff --git a/Zend/tests/magic_methods_009.phpt b/Zend/tests/magic_methods_009.phpt index 2b514c3bfff9..ff609ce4523c 100644 --- a/Zend/tests/magic_methods_009.phpt +++ b/Zend/tests/magic_methods_009.phpt @@ -4,8 +4,8 @@ Testing __callstatic declaration with wrong modifier diff --git a/Zend/tests/magic_methods_010.phpt b/Zend/tests/magic_methods_010.phpt index 06d46dbd2872..8ec3f23e614d 100644 --- a/Zend/tests/magic_methods_010.phpt +++ b/Zend/tests/magic_methods_010.phpt @@ -4,8 +4,8 @@ Testing __toString() declaration with wrong modifier diff --git a/Zend/tests/method_exists_002.phpt b/Zend/tests/method_exists_002.phpt index 89d3f2824d78..a777cd3c3ba3 100644 --- a/Zend/tests/method_exists_002.phpt +++ b/Zend/tests/method_exists_002.phpt @@ -4,37 +4,37 @@ Testing method_exists() method()); + var_dump($x->method()); } catch (Error $e) { var_dump($e->getCode(), $e->getMessage()); } diff --git a/Zend/tests/methods-on-non-objects-usort.phpt b/Zend/tests/methods-on-non-objects-usort.phpt index ff4ad7451c69..8a89023b7e81 100644 --- a/Zend/tests/methods-on-non-objects-usort.phpt +++ b/Zend/tests/methods-on-non-objects-usort.phpt @@ -10,10 +10,10 @@ $comparator= null; $list= [1, 4, 2, 3, -1]; usort($list, function($a, $b) use ($comparator) { try { - return $comparator->compare($a, $b); + return $comparator->compare($a, $b); } catch (Error $e) { - var_dump($e->getCode(), $e->getMessage()); - return 0; + var_dump($e->getCode(), $e->getMessage()); + return 0; } }); var_dump($list); diff --git a/Zend/tests/mod_001.phpt b/Zend/tests/mod_001.phpt index 2c1ebc7cc2b1..a393a4364486 100644 --- a/Zend/tests/mod_001.phpt +++ b/Zend/tests/mod_001.phpt @@ -10,7 +10,7 @@ try { $c = $a % $b; var_dump($c); } catch (DivisionByZeroError $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "Done\n"; diff --git a/Zend/tests/mul_001.phpt b/Zend/tests/mul_001.phpt index ea587902d0d3..b57c61776cd6 100644 --- a/Zend/tests/mul_001.phpt +++ b/Zend/tests/mul_001.phpt @@ -7,9 +7,9 @@ $a = array(1,2,3); $b = array(1); try { - var_dump($a * $b); + var_dump($a * $b); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $a * $b; diff --git a/Zend/tests/multibyte/multibyte_encoding_004.phpt b/Zend/tests/multibyte/multibyte_encoding_004.phpt index 0f7ab0cb1044..124cd036de9e 100644 --- a/Zend/tests/multibyte/multibyte_encoding_004.phpt +++ b/Zend/tests/multibyte/multibyte_encoding_004.phpt @@ -12,12 +12,12 @@ zend.script_encoding=Shift_JIS internal_encoding=Shift_JIS --FILE-- --EXPECT-- ƒhƒŒƒ~ƒtƒ@ƒ\ diff --git a/Zend/tests/multibyte/multibyte_encoding_005.phpt b/Zend/tests/multibyte/multibyte_encoding_005.phpt index 6cf0630d9f12..993e078b219a 100644 --- a/Zend/tests/multibyte/multibyte_encoding_005.phpt +++ b/Zend/tests/multibyte/multibyte_encoding_005.phpt @@ -13,12 +13,12 @@ zend.script_encoding=Shift_JIS internal_encoding=UTF-8 --FILE-- --EXPECT-- ドレミファソ diff --git a/Zend/tests/nested_method_and_function.phpt b/Zend/tests/nested_method_and_function.phpt index 3d19a0608883..5965a9274c3c 100644 --- a/Zend/tests/nested_method_and_function.phpt +++ b/Zend/tests/nested_method_and_function.phpt @@ -6,21 +6,21 @@ active_class_entry must be always correct (__METHOD__ should not depend on decla namespace Baz; class Foo { - public static function bar() { - function foo() { - var_dump(__FUNCTION__); - var_dump(__METHOD__); - var_dump(__CLASS__); - } + public static function bar() { + function foo() { + var_dump(__FUNCTION__); + var_dump(__METHOD__); + var_dump(__CLASS__); + } - foo(); + foo(); - var_dump(__FUNCTION__); - var_dump(__METHOD__); - var_dump(__CLASS__); + var_dump(__FUNCTION__); + var_dump(__METHOD__); + var_dump(__CLASS__); - return function() {var_dump(__FUNCTION__); var_dump(__METHOD__); var_dump(__CLASS__); }; - } + return function() {var_dump(__FUNCTION__); var_dump(__METHOD__); var_dump(__CLASS__); }; + } } $c = Foo::bar(); diff --git a/Zend/tests/not_002.phpt b/Zend/tests/not_002.phpt index 11efcaa2ea7d..38691a1a510e 100644 --- a/Zend/tests/not_002.phpt +++ b/Zend/tests/not_002.phpt @@ -7,9 +7,9 @@ $a = array(1,2,3); $b = array(1,2); try { - var_dump(~$b); + var_dump(~$b); } catch (Error $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $a = ~$b; diff --git a/Zend/tests/nowdoc_015.phpt b/Zend/tests/nowdoc_015.phpt index 56de362dd5dc..3b0227392096 100644 --- a/Zend/tests/nowdoc_015.phpt +++ b/Zend/tests/nowdoc_015.phpt @@ -3,7 +3,7 @@ Test nowdoc and line numbering --FILE-- B)) { - foreach ($a as $key => $val) { - echo "$key\n"; - echo "$val\n"; - } + foreach ($a as $key => $val) { + echo "$key\n"; + echo "$val\n"; + } } const A = "ok"; const B = A; diff --git a/Zend/tests/ns_040.phpt b/Zend/tests/ns_040.phpt index 42a3ac07e9a1..f5b9942c1237 100644 --- a/Zend/tests/ns_040.phpt +++ b/Zend/tests/ns_040.phpt @@ -7,28 +7,28 @@ use X as Y; const A = "ok\n"; const B = A; function f1($x=A) { - echo $x; + echo $x; } function f2($x=\X\A) { - echo $x; + echo $x; } function f3($x=Y\A) { - echo $x; + echo $x; } function f4($x=\X\A) { - echo $x; + echo $x; } function f5($x=B) { - echo $x; + echo $x; } function f6($x=array(A)) { - echo $x[0]; + echo $x[0]; } function f7($x=array("aaa"=>A)) { - echo $x["aaa"]; + echo $x["aaa"]; } function f8($x=array(A=>"aaa\n")) { - echo $x["ok\n"]; + echo $x["ok\n"]; } echo A; echo \X\A; diff --git a/Zend/tests/ns_050.phpt b/Zend/tests/ns_050.phpt index f827ec858d7f..e7cc750a2b97 100644 --- a/Zend/tests/ns_050.phpt +++ b/Zend/tests/ns_050.phpt @@ -7,7 +7,7 @@ namespace test\ns1; const INI_ALL = 0; function foo($x = INI_ALL) { - var_dump($x); + var_dump($x); } foo(); --EXPECT-- diff --git a/Zend/tests/ns_051.phpt b/Zend/tests/ns_051.phpt index b95b53f78bfc..ee8c369a3c43 100644 --- a/Zend/tests/ns_051.phpt +++ b/Zend/tests/ns_051.phpt @@ -5,7 +5,7 @@ namespace test\ns1; function foo($x = INI_ALL) { - var_dump($x); + var_dump($x); } foo(); --EXPECT-- diff --git a/Zend/tests/ns_052.phpt b/Zend/tests/ns_052.phpt index cb0a05ff9ffe..06700d948db0 100644 --- a/Zend/tests/ns_052.phpt +++ b/Zend/tests/ns_052.phpt @@ -7,7 +7,7 @@ namespace test\ns1; const INI_ALL = 0; function foo($x = \INI_ALL) { - var_dump($x); + var_dump($x); } foo(); --EXPECT-- diff --git a/Zend/tests/ns_054.phpt b/Zend/tests/ns_054.phpt index c6dd2553f835..9b8defc9ac3f 100644 --- a/Zend/tests/ns_054.phpt +++ b/Zend/tests/ns_054.phpt @@ -5,19 +5,19 @@ namespace test\ns1; class Foo implements \SplObserver { - function update(\SplSubject $x) { - echo "ok\n"; - } + function update(\SplSubject $x) { + echo "ok\n"; + } } class Bar implements \SplSubject { - function attach(\SplObserver $x) { - echo "ok\n"; - } - function notify() { - } - function detach(\SplObserver $x) { - } + function attach(\SplObserver $x) { + echo "ok\n"; + } + function notify() { + } + function detach(\SplObserver $x) { + } } $foo = new Foo(); $bar = new Bar(); diff --git a/Zend/tests/ns_055.phpt b/Zend/tests/ns_055.phpt index 16e3e6977737..9df9c2b007e1 100644 --- a/Zend/tests/ns_055.phpt +++ b/Zend/tests/ns_055.phpt @@ -5,15 +5,15 @@ namespace test\ns1; class Foo { - function test1(Foo $x) { - echo "ok\n"; - } - function test2(\test\ns1\Foo $x) { - echo "ok\n"; - } - function test3(\Exception $x) { - echo "ok\n"; - } + function test1(Foo $x) { + echo "ok\n"; + } + function test2(\test\ns1\Foo $x) { + echo "ok\n"; + } + function test3(\Exception $x) { + echo "ok\n"; + } } $foo = new Foo(); diff --git a/Zend/tests/ns_056.phpt b/Zend/tests/ns_056.phpt index b61609793d0e..cc61c7f8f135 100644 --- a/Zend/tests/ns_056.phpt +++ b/Zend/tests/ns_056.phpt @@ -6,19 +6,19 @@ namespace test\ns1; use \SplObserver; class Foo implements SplObserver { - function update(\SplSubject $x) { - echo "ok\n"; - } + function update(\SplSubject $x) { + echo "ok\n"; + } } class Bar implements \SplSubject { - function attach(SplObserver $x) { - echo "ok\n"; - } - function notify() { - } - function detach(SplObserver $x) { - } + function attach(SplObserver $x) { + echo "ok\n"; + } + function notify() { + } + function detach(SplObserver $x) { + } } $foo = new Foo(); $bar = new Bar(); diff --git a/Zend/tests/ns_057.phpt b/Zend/tests/ns_057.phpt index 6c7a72f86e68..ad44d09d2823 100644 --- a/Zend/tests/ns_057.phpt +++ b/Zend/tests/ns_057.phpt @@ -7,30 +7,30 @@ namespace Test\ns1; const C = "const ok\n"; function foo() { - return "func ok\n"; + return "func ok\n"; } class foo { - const C = "const ok\n"; - const C2 = namespace\C; - static $var = "var ok\n"; - function __construct() { - echo "class ok\n"; - } - static function bar() { - return "method ok\n"; - } + const C = "const ok\n"; + const C2 = namespace\C; + static $var = "var ok\n"; + function __construct() { + echo "class ok\n"; + } + static function bar() { + return "method ok\n"; + } } function f1($x=namespace\C) { - return $x; + return $x; } function f2($x=namespace\foo::C) { - return $x; + return $x; } function f3(namespace\foo $x) { - return "ok\n"; + return "ok\n"; } echo namespace\C; diff --git a/Zend/tests/ns_058.phpt b/Zend/tests/ns_058.phpt index 54e84aa030d7..6672d8a0b09d 100644 --- a/Zend/tests/ns_058.phpt +++ b/Zend/tests/ns_058.phpt @@ -5,30 +5,30 @@ const C = "const ok\n"; function foo() { - return "func ok\n"; + return "func ok\n"; } class foo { - const C = "const ok\n"; - const C2 = namespace\C; - static $var = "var ok\n"; - function __construct() { - echo "class ok\n"; - } - static function bar() { - return "method ok\n"; - } + const C = "const ok\n"; + const C2 = namespace\C; + static $var = "var ok\n"; + function __construct() { + echo "class ok\n"; + } + static function bar() { + return "method ok\n"; + } } function f1($x=namespace\C) { - return $x; + return $x; } function f2($x=namespace\foo::C) { - return $x; + return $x; } function f3(namespace\foo $x) { - return "ok\n"; + return "ok\n"; } echo namespace\C; diff --git a/Zend/tests/ns_063.phpt b/Zend/tests/ns_063.phpt index dbe34b428ebb..625a499fa2fb 100644 --- a/Zend/tests/ns_063.phpt +++ b/Zend/tests/ns_063.phpt @@ -4,9 +4,9 @@ e[] = $this; - } + public function __construct() { + $this->e[] = $this; + } - public function __set($a, $b) { - var_dump($a, $b); - } - public function __get($a) { - var_dump($a); - return $this; - } + public function __set($a, $b) { + var_dump($a, $b); + } + public function __get($a) { + var_dump($a); + return $this; + } } use test\foo as stdClass; diff --git a/Zend/tests/ns_065.inc b/Zend/tests/ns_065.inc index 963a74e14063..4bc1f6f8199c 100644 --- a/Zend/tests/ns_065.inc +++ b/Zend/tests/ns_065.inc @@ -1,9 +1,9 @@ diff --git a/Zend/tests/objects_003.phpt b/Zend/tests/objects_003.phpt index 300cda0cd90c..d4fc2e58fc11 100644 --- a/Zend/tests/objects_003.phpt +++ b/Zend/tests/objects_003.phpt @@ -6,15 +6,15 @@ error_reporting=8191 diff --git a/Zend/tests/objects_004.phpt b/Zend/tests/objects_004.phpt index 7c9ca452c8e3..6af4e813dea5 100644 --- a/Zend/tests/objects_004.phpt +++ b/Zend/tests/objects_004.phpt @@ -6,15 +6,15 @@ error_reporting=8191 diff --git a/Zend/tests/objects_005.phpt b/Zend/tests/objects_005.phpt index 6007ccbbc9f9..9b9a41465f95 100644 --- a/Zend/tests/objects_005.phpt +++ b/Zend/tests/objects_005.phpt @@ -6,15 +6,15 @@ error_reporting=8191 diff --git a/Zend/tests/objects_006.phpt b/Zend/tests/objects_006.phpt index e5203421800f..6ae7d574687c 100644 --- a/Zend/tests/objects_006.phpt +++ b/Zend/tests/objects_006.phpt @@ -6,15 +6,15 @@ error_reporting=8191 diff --git a/Zend/tests/objects_007.phpt b/Zend/tests/objects_007.phpt index 2df30b9068fb..9a23522cb29c 100644 --- a/Zend/tests/objects_007.phpt +++ b/Zend/tests/objects_007.phpt @@ -6,15 +6,15 @@ error_reporting=8191 diff --git a/Zend/tests/objects_008.phpt b/Zend/tests/objects_008.phpt index b563061051fa..fe5d2741e464 100644 --- a/Zend/tests/objects_008.phpt +++ b/Zend/tests/objects_008.phpt @@ -6,15 +6,15 @@ error_reporting=8191 diff --git a/Zend/tests/objects_009.phpt b/Zend/tests/objects_009.phpt index 3c91b22742d6..f0e9c15d45cd 100644 --- a/Zend/tests/objects_009.phpt +++ b/Zend/tests/objects_009.phpt @@ -6,15 +6,15 @@ error_reporting=8191 test = 2; diff --git a/Zend/tests/objects_018.phpt b/Zend/tests/objects_018.phpt index 98ea982940ce..35a6d9542cc3 100644 --- a/Zend/tests/objects_018.phpt +++ b/Zend/tests/objects_018.phpt @@ -4,11 +4,11 @@ Using the same function name on interface with inheritance a - ->b() - ->c = 1; + ->a + ->b() + ->c = 1; var_dump(test::$i); diff --git a/Zend/tests/objects_024.phpt b/Zend/tests/objects_024.phpt index 50659f16045f..3cf565984a9a 100644 --- a/Zend/tests/objects_024.phpt +++ b/Zend/tests/objects_024.phpt @@ -4,20 +4,20 @@ Testing direct assigning for property of object returned by function bar = 1; diff --git a/Zend/tests/objects_025.phpt b/Zend/tests/objects_025.phpt index 53c1ae077ae6..4856e3bd3cd4 100644 --- a/Zend/tests/objects_025.phpt +++ b/Zend/tests/objects_025.phpt @@ -4,13 +4,13 @@ Testing invalid method names with __call and __callstatic a = 1; + $this->a = 1; } catch (Exception $e) { } diff --git a/Zend/tests/objects_027.phpt b/Zend/tests/objects_027.phpt index b579278f2e66..84dca0573ad6 100644 --- a/Zend/tests/objects_027.phpt +++ b/Zend/tests/objects_027.phpt @@ -4,15 +4,15 @@ Testing 'new static;' calling parent method prop; diff --git a/Zend/tests/return_types/014.phpt b/Zend/tests/return_types/014.phpt index 655c5a9cc6d1..25bd79fb814b 100644 --- a/Zend/tests/return_types/014.phpt +++ b/Zend/tests/return_types/014.phpt @@ -4,7 +4,7 @@ Constructors cannot declare a return type getMessage(), " in ", $e->getFile(), " on line ", $e->getLine(); + echo $e->getMessage(), " in ", $e->getFile(), " on line ", $e->getLine(); } ?> diff --git a/Zend/tests/return_types/029.phpt b/Zend/tests/return_types/029.phpt index adc07cde7f4d..5741763abb72 100644 --- a/Zend/tests/return_types/029.phpt +++ b/Zend/tests/return_types/029.phpt @@ -6,11 +6,11 @@ opcache.enable=0 DONE diff --git a/Zend/tests/return_types/032.phpt b/Zend/tests/return_types/032.phpt index 00790b5d608e..9d011c0062c1 100644 --- a/Zend/tests/return_types/032.phpt +++ b/Zend/tests/return_types/032.phpt @@ -3,10 +3,10 @@ Nullable return type inheritance rules (nullable and non-nullable) --FILE-- DONE diff --git a/Zend/tests/return_types/bug70557.phpt b/Zend/tests/return_types/bug70557.phpt index cb4eb498b97d..5917197045a8 100644 --- a/Zend/tests/return_types/bug70557.phpt +++ b/Zend/tests/return_types/bug70557.phpt @@ -6,13 +6,13 @@ opcache.enable=0 getMessage()); + var_dump($e->getMessage()); } ?> --EXPECT-- diff --git a/Zend/tests/return_types/bug71092.phpt b/Zend/tests/return_types/bug71092.phpt index 1d4fe983b36a..abc43356bcdc 100644 --- a/Zend/tests/return_types/bug71092.phpt +++ b/Zend/tests/return_types/bug71092.phpt @@ -6,11 +6,11 @@ opcache.enable=0 --EXPECTF-- diff --git a/Zend/tests/return_types/return_reference_separation.phpt b/Zend/tests/return_types/return_reference_separation.phpt index 0151e5ec317c..86c206a0d51e 100644 --- a/Zend/tests/return_types/return_reference_separation.phpt +++ b/Zend/tests/return_types/return_reference_separation.phpt @@ -3,15 +3,15 @@ Return value separation --FILE-- x|"; - echo "should never be reached"; + $x = new Obj; + $y = 0; + $r = "$y|$x->x|"; + echo "should never be reached"; } catch (Exception $e) { - echo "$e\n"; + echo "$e\n"; } try { - $x = new Obj; - $y = 0; - $r = "$y$x->x|"; - echo "should never be reached"; + $x = new Obj; + $y = 0; + $r = "$y$x->x|"; + echo "should never be reached"; } catch (Exception $e) { - echo "$e\n"; + echo "$e\n"; } try { - $x = new Obj; - $y = 0; - $r = "$y|$y$x->x"; - echo "should never be reached"; + $x = new Obj; + $y = 0; + $r = "$y|$y$x->x"; + echo "should never be reached"; } catch (Exception $e) { - echo "$e\n"; + echo "$e\n"; } ?> diff --git a/Zend/tests/runtime_compile_time_binary_operands.phpt b/Zend/tests/runtime_compile_time_binary_operands.phpt index 2908bc3db19b..8c15a9658fd1 100644 --- a/Zend/tests/runtime_compile_time_binary_operands.phpt +++ b/Zend/tests/runtime_compile_time_binary_operands.phpt @@ -6,120 +6,120 @@ memory_limit=256M ", - ">=", - "<=>", - "+", - "-", - "*", - "/", - "%", - "**", - ".", - "|", - "&", - "^", - "or", - "and", - "xor", - "||", - "&&", + "==", + "!=", + "===", + "!==", + "<", + "<=", + ">", + ">=", + "<=>", + "+", + "-", + "*", + "/", + "%", + "**", + ".", + "|", + "&", + "^", + "or", + "and", + "xor", + "||", + "&&", ]; $input = [ - 0, - 1, - 2, - -1, - 2.0, - 2.1, - -2.0, - -2.1, - PHP_INT_MAX, - PHP_INT_MIN, - PHP_INT_MAX * 2, - PHP_INT_MIN * 2, - INF, - NAN, - [], - [1, 2], - [1, 2, 3], - [1 => 2, 0 => 1], - [1, 'a' => 2], - [1, 4], - [1, 'a'], - [1, 2 => 2], - [1, [ 2 ]], - null, - false, - true, - "", - " ", - "banana", - "Banana", - "banan", - "0", - "200", - "20", - "20a", - " \t\n\r\v\f20", - "20 ", - "2e1", - "2e150", - "9179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368", - "-9179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368", - "0.1", - "-0.1", - "1e-1", - "-20", - "-20.0", - "0x14", - (string) PHP_INT_MAX * 2, - (string) PHP_INT_MIN * 2, + 0, + 1, + 2, + -1, + 2.0, + 2.1, + -2.0, + -2.1, + PHP_INT_MAX, + PHP_INT_MIN, + PHP_INT_MAX * 2, + PHP_INT_MIN * 2, + INF, + NAN, + [], + [1, 2], + [1, 2, 3], + [1 => 2, 0 => 1], + [1, 'a' => 2], + [1, 4], + [1, 'a'], + [1, 2 => 2], + [1, [ 2 ]], + null, + false, + true, + "", + " ", + "banana", + "Banana", + "banan", + "0", + "200", + "20", + "20a", + " \t\n\r\v\f20", + "20 ", + "2e1", + "2e150", + "9179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368", + "-9179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368", + "0.1", + "-0.1", + "1e-1", + "-20", + "-20.0", + "0x14", + (string) PHP_INT_MAX * 2, + (string) PHP_INT_MIN * 2, ]; function makeParam($param) { - if ($param === PHP_INT_MIN) { - return "PHP_INT_MIN"; - } - if ($param === PHP_INT_MAX) { - return "PHP_INT_MAX"; - } - if (is_string($param)) { - return '"' . strtr($param, ["\t" => '\t', "\n" => '\n', "\r" => '\r', "\v" => '\v', "\f" => '\f', '$' => '\$', '"' => '\"']) . '"'; - } - return "(" . str_replace("\n", "", var_export($param, true)) . ")"; + if ($param === PHP_INT_MIN) { + return "PHP_INT_MIN"; + } + if ($param === PHP_INT_MAX) { + return "PHP_INT_MAX"; + } + if (is_string($param)) { + return '"' . strtr($param, ["\t" => '\t', "\n" => '\n', "\r" => '\r', "\v" => '\v', "\f" => '\f', '$' => '\$', '"' => '\"']) . '"'; + } + return "(" . str_replace("\n", "", var_export($param, true)) . ")"; } $c = 0; $f = 0; function prepareLine($op1, $op2, $cmp, $operator) { - - $op1_p = makeParam($op1); - $op2_p = makeParam($op2); - $error = "echo '" . addcslashes("$op1_p $operator $op2_p", "\\'") . '\', "\n"; $f++;'; + $op1_p = makeParam($op1); + $op2_p = makeParam($op2); - $compare = "@($op1_p $operator $op2_p)"; - $line = "\$c++; "; - try { - $result = makeParam($cmp()); - $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : "$compare !== $result") . ") { $error }"; - } catch (Error $e) { - if (get_class($e) == "Error") { - return "// exempt $op1_p $operator $op2_p from checking, it generates a compile time error"; - } - $msg = makeParam($e->getMessage()); - $line .= "try { $compare; $error } catch (Error \$e) { if (\$e->getMessage() !== $msg) { $error } }"; - } - return $line; + $error = "echo '" . addcslashes("$op1_p $operator $op2_p", "\\'") . '\', "\n"; $f++;'; + + $compare = "@($op1_p $operator $op2_p)"; + $line = "\$c++; "; + try { + $result = makeParam($cmp()); + $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : "$compare !== $result") . ") { $error }"; + } catch (Error $e) { + if (get_class($e) == "Error") { + return "// exempt $op1_p $operator $op2_p from checking, it generates a compile time error"; + } + $msg = makeParam($e->getMessage()); + $line .= "try { $compare; $error } catch (Error \$e) { if (\$e->getMessage() !== $msg) { $error } }"; + } + return $line; } $filename = __DIR__ . DIRECTORY_SEPARATOR . 'compare_binary_operands_temp.php'; @@ -128,14 +128,14 @@ $file = fopen($filename, "w"); fwrite($file, " --CLEAN-- diff --git a/Zend/tests/selfParent_001.phpt b/Zend/tests/selfParent_001.phpt index e7f1d2defa1b..e66185fc8fdd 100644 --- a/Zend/tests/selfParent_001.phpt +++ b/Zend/tests/selfParent_001.phpt @@ -3,20 +3,20 @@ Test when constants are initialised. See also selfParent_002.phpt. --FILE-- 1 + 1, baz * 2 => 1 << 2]; - static $c = [1 => bar, 3 => baz]; - var_dump($a, $b, $c); + static $a = 1 + 1; + static $b = [bar => 1 + 1, baz * 2 => 1 << 2]; + static $c = [1 => bar, 3 => baz]; + var_dump($a, $b, $c); } foo(); diff --git a/Zend/tests/str_offset_001.phpt b/Zend/tests/str_offset_001.phpt index 04fadd3023fe..02e7ccb666da 100644 --- a/Zend/tests/str_offset_001.phpt +++ b/Zend/tests/str_offset_001.phpt @@ -5,7 +5,7 @@ string offset 001 // Test positive or null string offsets function foo($x) { - var_dump($x); + var_dump($x); } $str = "abc"; diff --git a/Zend/tests/str_offset_003.phpt b/Zend/tests/str_offset_003.phpt index 4101ce522ab0..db7644c32102 100644 --- a/Zend/tests/str_offset_003.phpt +++ b/Zend/tests/str_offset_003.phpt @@ -5,7 +5,7 @@ string offset 003 // Test negative string offsets function foo($x) { - var_dump($x); + var_dump($x); } $str = "abcdef"; diff --git a/Zend/tests/strict_002.phpt b/Zend/tests/strict_002.phpt index 8f76c8cf0168..7f9c61380139 100644 --- a/Zend/tests/strict_002.phpt +++ b/Zend/tests/strict_002.phpt @@ -6,7 +6,7 @@ error_reporting=8191 getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } $c = $a - $b; diff --git a/Zend/tests/temporary_cleaning_001.phpt b/Zend/tests/temporary_cleaning_001.phpt index f2ccbb35b8f1..9622a4a5421b 100644 --- a/Zend/tests/temporary_cleaning_001.phpt +++ b/Zend/tests/temporary_cleaning_001.phpt @@ -8,12 +8,12 @@ function ops() { } try { - $x = 2; - $y = new stdClass; - while ($x-- && new stdClass) { - $r = [$x] + ($y ? ((array) $x) + [2] : ops()); - $y = (array) $y; - } + $x = 2; + $y = new stdClass; + while ($x-- && new stdClass) { + $r = [$x] + ($y ? ((array) $x) + [2] : ops()); + $y = (array) $y; + } } catch (Exception $e) { } diff --git a/Zend/tests/temporary_cleaning_002.phpt b/Zend/tests/temporary_cleaning_002.phpt index bea54e7f77be..77be1dbd0a03 100644 --- a/Zend/tests/temporary_cleaning_002.phpt +++ b/Zend/tests/temporary_cleaning_002.phpt @@ -3,26 +3,26 @@ Temporary leak on rope (encapsed string) --FILE-- x|"; + $r = "$y|$x->x|"; } catch (Exception $e) { } try { - $r = "$x->x|$y|"; + $r = "$x->x|$y|"; } catch (Exception $e) { } try { - $r = "$y|$y|$x->x"; + $r = "$y|$y|$x->x"; } catch (Exception $e) { } diff --git a/Zend/tests/temporary_cleaning_004.phpt b/Zend/tests/temporary_cleaning_004.phpt index b8a02516b0ef..8e94b25229eb 100644 --- a/Zend/tests/temporary_cleaning_004.phpt +++ b/Zend/tests/temporary_cleaning_004.phpt @@ -9,32 +9,32 @@ function ops() { $a = [new stdClass, new stdClass]; switch ($a[0]) { - case false: - break; - default: - try { - $x = 2; - $y = new stdClass; - while ($x-- && new stdClass) { - $r = [$x] + ($y ? ((array) $x) + [2] : ops()); - $y = (array) $y; - } - } catch (Exception $e) { - } + case false: + break; + default: + try { + $x = 2; + $y = new stdClass; + while ($x-- && new stdClass) { + $r = [$x] + ($y ? ((array) $x) + [2] : ops()); + $y = (array) $y; + } + } catch (Exception $e) { + } } try { - switch ($a[0]) { - case false: - break; - default: - $x = 2; - $y = new stdClass; - while ($x-- && new stdClass) { - $r = [$x] + ($y ? ((array) $x) + [2] : ops()); - $y = (array) $y; - } - } + switch ($a[0]) { + case false: + break; + default: + $x = 2; + $y = new stdClass; + while ($x-- && new stdClass) { + $r = [$x] + ($y ? ((array) $x) + [2] : ops()); + $y = (array) $y; + } + } } catch (Exception $e) { } diff --git a/Zend/tests/temporary_cleaning_005.phpt b/Zend/tests/temporary_cleaning_005.phpt index e8c7febe0b12..61bb563a7676 100644 --- a/Zend/tests/temporary_cleaning_005.phpt +++ b/Zend/tests/temporary_cleaning_005.phpt @@ -9,37 +9,37 @@ function ops() { $a = [new stdClass, new stdClass]; foreach ([$a, [new stdClass]] as $b) { - switch ($b[0]) { - case false: - break; - default: - try { - $x = 2; - $y = new stdClass; - while ($x-- && new stdClass) { - $r = [$x] + ($y ? ((array) $x) + [2] : ops()); - $y = (array) $y; - } - } catch (Exception $e) { - } - } + switch ($b[0]) { + case false: + break; + default: + try { + $x = 2; + $y = new stdClass; + while ($x-- && new stdClass) { + $r = [$x] + ($y ? ((array) $x) + [2] : ops()); + $y = (array) $y; + } + } catch (Exception $e) { + } + } } foreach ([$a, [new stdClass]] as $b) { - try { - switch ($b[0]) { - case false: - break; - default: - $x = 2; - $y = new stdClass; - while ($x-- && new stdClass) { - $r = [$x] + ($y ? ((array) $x) + [2] : ops()); - $y = (array) $y; - } - } - } catch (Exception $e) { - } + try { + switch ($b[0]) { + case false: + break; + default: + $x = 2; + $y = new stdClass; + while ($x-- && new stdClass) { + $r = [$x] + ($y ? ((array) $x) + [2] : ops()); + $y = (array) $y; + } + } + } catch (Exception $e) { + } } ?> diff --git a/Zend/tests/temporary_cleaning_008.phpt b/Zend/tests/temporary_cleaning_008.phpt index c876f3c2e83f..81a54f351efc 100644 --- a/Zend/tests/temporary_cleaning_008.phpt +++ b/Zend/tests/temporary_cleaning_008.phpt @@ -3,12 +3,12 @@ Optimization of constant switch expression --FILE-- --EXPECT-- diff --git a/Zend/tests/temporary_cleaning_010.phpt b/Zend/tests/temporary_cleaning_010.phpt index e4456041b2f7..122a0b28a76a 100644 --- a/Zend/tests/temporary_cleaning_010.phpt +++ b/Zend/tests/temporary_cleaning_010.phpt @@ -14,7 +14,7 @@ function test() { try { test(); } catch (Exception $e) { - echo "exception\n"; + echo "exception\n"; } ?> --EXPECT-- diff --git a/Zend/tests/temporary_cleaning_011.phpt b/Zend/tests/temporary_cleaning_011.phpt index aa1be00e5659..09e2148f72be 100644 --- a/Zend/tests/temporary_cleaning_011.phpt +++ b/Zend/tests/temporary_cleaning_011.phpt @@ -3,17 +3,17 @@ Live range & lists --FILE-- --EXPECT-- diff --git a/Zend/tests/temporary_cleaning_013.phpt b/Zend/tests/temporary_cleaning_013.phpt index 34e4080f568d..d9e7dd82f5c7 100644 --- a/Zend/tests/temporary_cleaning_013.phpt +++ b/Zend/tests/temporary_cleaning_013.phpt @@ -4,271 +4,271 @@ Exceptions thrown in operand cleaning must cause leak of return value [0]]; - var_dump($foo->foo += [new class { - function __destruct() { throw new Exception; } - }]); + $foo = (object)["foo" => [0]]; + var_dump($foo->foo += [new class { + function __destruct() { throw new Exception; } + }]); } catch (Exception $e) { print "caught Exception 4\n"; } try { - $foo = new class { - function __get($x) { return [0]; } - function __set($x, $y) {} - }; - var_dump($foo->foo += [new class { - function __destruct() { throw new Exception; } - }]); + $foo = new class { + function __get($x) { return [0]; } + function __set($x, $y) {} + }; + var_dump($foo->foo += [new class { + function __destruct() { throw new Exception; } + }]); } catch (Exception $e) { print "caught Exception 5\n"; } try { - $foo = new class { - public $bar = [0]; - function &__get($x) { return $this->bar; } - }; - var_dump($foo->foo += [new class { - function __destruct() { throw new Exception; } - }]); + $foo = new class { + public $bar = [0]; + function &__get($x) { return $this->bar; } + }; + var_dump($foo->foo += [new class { + function __destruct() { throw new Exception; } + }]); } catch (Exception $e) { print "caught Exception 6\n"; } try { - $foo = new class implements ArrayAccess { - function offsetGet($x) { return [0]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} - }; - var_dump($foo[0] += [new class { - function __destruct() { throw new Exception; } - }]); + $foo = new class implements ArrayAccess { + function offsetGet($x) { return [0]; } + function offsetSet($x, $y) {} + function offsetExists($x) { return true; } + function offsetUnset($x) {} + }; + var_dump($foo[0] += [new class { + function __destruct() { throw new Exception; } + }]); } catch (Exception $e) { print "caught Exception 7\n"; } try { - $foo = new class implements ArrayAccess { - public $foo = [0]; - function &offsetGet($x) { return $this->foo; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} - }; - var_dump($foo[0] += [new class { - function __destruct() { throw new Exception; } - }]); + $foo = new class implements ArrayAccess { + public $foo = [0]; + function &offsetGet($x) { return $this->foo; } + function offsetSet($x, $y) {} + function offsetExists($x) { return true; } + function offsetUnset($x) {} + }; + var_dump($foo[0] += [new class { + function __destruct() { throw new Exception; } + }]); } catch (Exception $e) { print "caught Exception 8\n"; } try { - var_dump((function() { return new class { - function __construct() { $this->foo = new stdClass; } - function __destruct() { throw new Exception; } - }; })()->foo++); + var_dump((function() { return new class { + function __construct() { $this->foo = new stdClass; } + function __destruct() { throw new Exception; } + }; })()->foo++); } catch (Exception $e) { print "caught Exception 9\n"; } try { - var_dump((function() { return new class { - function __get($x) { return new stdClass; } - function __set($x, $y) {} - function __destruct() { throw new Exception; } - }; })()->foo++); + var_dump((function() { return new class { + function __get($x) { return new stdClass; } + function __set($x, $y) {} + function __destruct() { throw new Exception; } + }; })()->foo++); } catch (Exception $e) { print "caught Exception 10\n"; } try { - var_dump((function() { return new class { - function __construct() { $this->bar = new stdClass; } - function &__get($x) { return $this->bar; } - function __destruct() { throw new Exception; } - }; })()->foo++); + var_dump((function() { return new class { + function __construct() { $this->bar = new stdClass; } + function &__get($x) { return $this->bar; } + function __destruct() { throw new Exception; } + }; })()->foo++); } catch (Exception $e) { print "caught Exception 11\n"; } try { - var_dump(++(function() { return new class { - function __construct() { $this->foo = new stdClass; } - function __destruct() { throw new Exception; } - }; })()->foo); + var_dump(++(function() { return new class { + function __construct() { $this->foo = new stdClass; } + function __destruct() { throw new Exception; } + }; })()->foo); } catch (Exception $e) { print "caught Exception 12\n"; } try { - var_dump(++(function() { return new class { - function __get($x) { return new stdClass; } - function __set($x, $y) {} - function __destruct() { throw new Exception; } - }; })()->foo); + var_dump(++(function() { return new class { + function __get($x) { return new stdClass; } + function __set($x, $y) {} + function __destruct() { throw new Exception; } + }; })()->foo); } catch (Exception $e) { print "caught Exception 13\n"; } try { - var_dump(++(function() { return new class { - function __construct() { $this->bar = new stdClass; } - function &__get($x) { return $this->bar; } - function __destruct() { throw new Exception; } - }; })()->foo); + var_dump(++(function() { return new class { + function __construct() { $this->bar = new stdClass; } + function &__get($x) { return $this->bar; } + function __destruct() { throw new Exception; } + }; })()->foo); } catch (Exception $e) { print "caught Exception 14\n"; } try { - var_dump((function() { return new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} - function __destruct() { throw new Exception; } - }; })()[0]++); + var_dump((function() { return new class implements ArrayAccess { + function offsetGet($x) { return [new stdClass]; } + function offsetSet($x, $y) {} + function offsetExists($x) { return true; } + function offsetUnset($x) {} + function __destruct() { throw new Exception; } + }; })()[0]++); } catch (Exception $e) { print "caught Exception 15\n"; } try { - var_dump(++(function() { return new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} - function __destruct() { throw new Exception; } - }; })()[0]); + var_dump(++(function() { return new class implements ArrayAccess { + function offsetGet($x) { return [new stdClass]; } + function offsetSet($x, $y) {} + function offsetExists($x) { return true; } + function offsetUnset($x) {} + function __destruct() { throw new Exception; } + }; })()[0]); } catch (Exception $e) { print "caught Exception 16\n"; } try { - var_dump((new class { - function __construct() { $this->foo = new stdClass; } - function __destruct() { throw new Exception; } - })->foo); + var_dump((new class { + function __construct() { $this->foo = new stdClass; } + function __destruct() { throw new Exception; } + })->foo); } catch (Exception $e) { print "caught Exception 17\n"; } try { - var_dump((new class { - function __get($x) { return new stdClass; } - function __set($x, $y) {} - function __destruct() { throw new Exception; } - })->foo); + var_dump((new class { + function __get($x) { return new stdClass; } + function __set($x, $y) {} + function __destruct() { throw new Exception; } + })->foo); } catch (Exception $e) { print "caught Exception 18\n"; } try { - var_dump((new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} - function __destruct() { throw new Exception; } - })[0]); + var_dump((new class implements ArrayAccess { + function offsetGet($x) { return [new stdClass]; } + function offsetSet($x, $y) {} + function offsetExists($x) { return true; } + function offsetUnset($x) {} + function __destruct() { throw new Exception; } + })[0]); } catch (Exception $e) { print "caught Exception 19\n"; } try { - var_dump(isset((new class { - function __construct() { $this->foo = new stdClass; } - function __destruct() { throw new Exception; } - })->foo->bar)); + var_dump(isset((new class { + function __construct() { $this->foo = new stdClass; } + function __destruct() { throw new Exception; } + })->foo->bar)); } catch (Exception $e) { print "caught Exception 20\n"; } try { - var_dump(isset((new class { - function __get($x) { return new stdClass; } - function __set($x, $y) {} - function __destruct() { throw new Exception; } - })->foo->bar)); + var_dump(isset((new class { + function __get($x) { return new stdClass; } + function __set($x, $y) {} + function __destruct() { throw new Exception; } + })->foo->bar)); } catch (Exception $e) { print "caught Exception 21\n"; } try { - var_dump(isset((new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} - function __destruct() { throw new Exception; } - })[0]->bar)); + var_dump(isset((new class implements ArrayAccess { + function offsetGet($x) { return [new stdClass]; } + function offsetSet($x, $y) {} + function offsetExists($x) { return true; } + function offsetUnset($x) {} + function __destruct() { throw new Exception; } + })[0]->bar)); } catch (Exception $e) { print "caught Exception 22\n"; } try { - $foo = new class { - function __destruct() { throw new Exception; } - }; - var_dump($foo = new stdClass); + $foo = new class { + function __destruct() { throw new Exception; } + }; + var_dump($foo = new stdClass); } catch (Exception $e) { print "caught Exception 23\n"; } try { - $foo = [new class { - function __destruct() { throw new Exception; } - }]; - var_dump($foo[0] = new stdClass); + $foo = [new class { + function __destruct() { throw new Exception; } + }]; + var_dump($foo[0] = new stdClass); } catch (Exception $e) { print "caught Exception 24\n"; } try { - $foo = (object) ["foo" => new class { - function __destruct() { throw new Exception; } - }]; - var_dump($foo->foo = new stdClass); + $foo = (object) ["foo" => new class { + function __destruct() { throw new Exception; } + }]; + var_dump($foo->foo = new stdClass); } catch (Exception $e) { print "caught Exception 25\n"; } try { - $foo = new class { - function __get($x) {} - function __set($x, $y) { throw new Exception; } - }; - var_dump($foo->foo = new stdClass); + $foo = new class { + function __get($x) {} + function __set($x, $y) { throw new Exception; } + }; + var_dump($foo->foo = new stdClass); } catch (Exception $e) { print "caught Exception 26\n"; } try { - $foo = new class implements ArrayAccess { - function offsetGet($x) {} - function offsetSet($x, $y) { throw new Exception; } - function offsetExists($x) { return true; } - function offsetUnset($x) {} - }; - var_dump($foo[0] = new stdClass); + $foo = new class implements ArrayAccess { + function offsetGet($x) {} + function offsetSet($x, $y) { throw new Exception; } + function offsetExists($x) { return true; } + function offsetUnset($x) {} + }; + var_dump($foo[0] = new stdClass); } catch (Exception $e) { print "caught Exception 27\n"; } try { - $foo = new class { - function __destruct() { throw new Exception; } - }; - $bar = new stdClass; - var_dump($foo = &$bar); + $foo = new class { + function __destruct() { throw new Exception; } + }; + $bar = new stdClass; + var_dump($foo = &$bar); } catch (Exception $e) { print "caught Exception 28\n"; } try { - $f = function() { - return new class { - function __toString() { return "a"; } - function __destruct() { throw new Exception; } - }; - }; - var_dump("{$f()}foo"); + $f = function() { + return new class { + function __toString() { return "a"; } + function __destruct() { throw new Exception; } + }; + }; + var_dump("{$f()}foo"); } catch (Exception $e) { print "caught Exception 29\n"; } try { - $f = function() { - return new class { - function __toString() { return "a"; } - function __destruct() { throw new Exception; } - }; - }; - var_dump("bar{$f()}foo"); + $f = function() { + return new class { + function __toString() { return "a"; } + function __destruct() { throw new Exception; } + }; + }; + var_dump("bar{$f()}foo"); } catch (Exception $e) { print "caught Exception 30\n"; } try { - var_dump((string) new class { - function __toString() { $x = "Z"; return ++$x; } - function __destruct() { throw new Exception; } - }); + var_dump((string) new class { + function __toString() { $x = "Z"; return ++$x; } + function __destruct() { throw new Exception; } + }); } catch (Exception $e) { print "caught Exception 31\n"; } try { - var_dump(clone (new class { - function __clone() { throw new Exception; } - })); + var_dump(clone (new class { + function __clone() { throw new Exception; } + })); } catch (Exception $e) { print "caught Exception 32\n"; } ?> diff --git a/Zend/tests/temporary_cleaning_014.phpt b/Zend/tests/temporary_cleaning_014.phpt index 39effae18ab7..4ced112094bc 100644 --- a/Zend/tests/temporary_cleaning_014.phpt +++ b/Zend/tests/temporary_cleaning_014.phpt @@ -6,7 +6,7 @@ Leak in JMP_SET diff --git a/Zend/tests/temporary_cleaning_015.phpt b/Zend/tests/temporary_cleaning_015.phpt index 7690abba76db..f5e115faa970 100644 --- a/Zend/tests/temporary_cleaning_015.phpt +++ b/Zend/tests/temporary_cleaning_015.phpt @@ -3,12 +3,12 @@ Attempt to free invalid structure (result of ROPE_INIT is not a zval) --FILE-- diff --git a/Zend/tests/this_as_global.phpt b/Zend/tests/this_as_global.phpt index 0ba9ade1b938..7901dad7d703 100644 --- a/Zend/tests/this_as_global.phpt +++ b/Zend/tests/this_as_global.phpt @@ -3,8 +3,8 @@ $this as global variable --FILE-- diff --git a/Zend/tests/this_as_parameter.phpt b/Zend/tests/this_as_parameter.phpt index 93101969a7e1..a2f13f07e81c 100644 --- a/Zend/tests/this_as_parameter.phpt +++ b/Zend/tests/this_as_parameter.phpt @@ -3,7 +3,7 @@ $this as parameter --FILE-- diff --git a/Zend/tests/this_as_static.phpt b/Zend/tests/this_as_static.phpt index f094449c12dd..d990ab5ba1bf 100644 --- a/Zend/tests/this_as_static.phpt +++ b/Zend/tests/this_as_static.phpt @@ -3,8 +3,8 @@ $this as static variable --FILE-- diff --git a/Zend/tests/this_in_catch.phpt b/Zend/tests/this_in_catch.phpt index d621bb18ea77..d167e047a018 100644 --- a/Zend/tests/this_in_catch.phpt +++ b/Zend/tests/this_in_catch.phpt @@ -3,13 +3,13 @@ $this in catch --FILE-- foo(); diff --git a/Zend/tests/this_in_eval.phpt b/Zend/tests/this_in_eval.phpt index 8da70b76a3fc..a499d8ac7629 100644 --- a/Zend/tests/this_in_eval.phpt +++ b/Zend/tests/this_in_eval.phpt @@ -3,10 +3,10 @@ $this in eval() block --FILE-- foo(); diff --git a/Zend/tests/this_in_foreach_001.phpt b/Zend/tests/this_in_foreach_001.phpt index a724338b905a..b8a1c070044c 100644 --- a/Zend/tests/this_in_foreach_001.phpt +++ b/Zend/tests/this_in_foreach_001.phpt @@ -4,7 +4,7 @@ $this in foreach --EXPECTF-- diff --git a/Zend/tests/this_in_foreach_002.phpt b/Zend/tests/this_in_foreach_002.phpt index 511ea36a2423..3b287d675fc1 100644 --- a/Zend/tests/this_in_foreach_002.phpt +++ b/Zend/tests/this_in_foreach_002.phpt @@ -4,7 +4,7 @@ $this in foreach $dummy) { - var_dump($this); + var_dump($this); } ?> --EXPECTF-- diff --git a/Zend/tests/this_in_foreach_003.phpt b/Zend/tests/this_in_foreach_003.phpt index 5f5b5ae0d8e8..f815ed6f8892 100644 --- a/Zend/tests/this_in_foreach_003.phpt +++ b/Zend/tests/this_in_foreach_003.phpt @@ -4,7 +4,7 @@ $this in foreach --EXPECTF-- diff --git a/Zend/tests/this_in_foreach_004.phpt b/Zend/tests/this_in_foreach_004.phpt index 13bfbf18b4c7..33a8b87f1aa5 100644 --- a/Zend/tests/this_in_foreach_004.phpt +++ b/Zend/tests/this_in_foreach_004.phpt @@ -4,7 +4,7 @@ $this in foreach --EXPECTF-- diff --git a/Zend/tests/this_in_isset.phpt b/Zend/tests/this_in_isset.phpt index 2ae335df933e..6f3b8310e25b 100644 --- a/Zend/tests/this_in_isset.phpt +++ b/Zend/tests/this_in_isset.phpt @@ -4,29 +4,29 @@ $this in isset foo)); + var_dump(isset($this->foo)); } catch (Throwable $e) { - echo "exception\n"; + echo "exception\n"; } try { - var_dump(isset($this->foo->bar)); + var_dump(isset($this->foo->bar)); } catch (Throwable $e) { - echo "exception\n"; + echo "exception\n"; } try { - var_dump(isset($this[0])); + var_dump(isset($this[0])); } catch (Throwable $e) { - echo "exception\n"; + echo "exception\n"; } class A extends ArrayObject { - public $foo = 5; - function foo() { - $this[0] = 5; - var_dump(isset($this)); - var_dump(isset($this->foo)); - var_dump(isset($this[0])); - } + public $foo = 5; + function foo() { + $this[0] = 5; + var_dump(isset($this)); + var_dump(isset($this->foo)); + var_dump(isset($this[0])); + } } $a = new A(); $a->foo(); diff --git a/Zend/tests/this_reassign.phpt b/Zend/tests/this_reassign.phpt index d965ef470100..5a9109fd8cf4 100644 --- a/Zend/tests/this_reassign.phpt +++ b/Zend/tests/this_reassign.phpt @@ -3,9 +3,9 @@ $this re-assign --FILE-- diff --git a/Zend/tests/traits/bug55214.phpt b/Zend/tests/traits/bug55214.phpt index b27ae02428d7..35ef7a20874e 100644 --- a/Zend/tests/traits/bug55214.phpt +++ b/Zend/tests/traits/bug55214.phpt @@ -25,7 +25,7 @@ trait ATrait { } trait Indirect { - use ATrait; + use ATrait; } class SomeClass { @@ -33,7 +33,7 @@ class SomeClass { } class UsingIndirect { - use Indirect; + use Indirect; } $r = SomeClass::get_class_name(); diff --git a/Zend/tests/traits/bug55355.phpt b/Zend/tests/traits/bug55355.phpt index 22350a281fd9..6aae316efff9 100644 --- a/Zend/tests/traits/bug55355.phpt +++ b/Zend/tests/traits/bug55355.phpt @@ -5,16 +5,16 @@ Bug #55355 (Abstract functions required by a trait are not correctly found when // A trait that has a abstract function trait ATrait { - function bar() { - $this->foo(); - } - abstract function foo(); + function bar() { + $this->foo(); + } + abstract function foo(); } // A class on the second level in the // inheritance chain class Level2Impl { - function foo() {} + function foo() {} } class Level1Indirect extends Level2Impl {} diff --git a/Zend/tests/traits/bug55372.phpt b/Zend/tests/traits/bug55372.phpt index e215d968aba5..509b672bf29b 100644 --- a/Zend/tests/traits/bug55372.phpt +++ b/Zend/tests/traits/bug55372.phpt @@ -4,20 +4,20 @@ Bug #55372 (Literal handling in methods is inconsistent, causing memory corrupti setAttribute(); - } + trait ATrait + { + function setRequired() + { + $this->setAttribute(); + } - abstract function setAttribute(); - } + abstract function setAttribute(); + } - class Base - { - function setAttribute() { } - } + class Base + { + function setAttribute() { } + } - class MyClass extends Base - { - use ATrait; - } + class MyClass extends Base + { + use ATrait; + } - $i = new Base(); - $i->setAttribute(); + $i = new Base(); + $i->setAttribute(); - $t = new MyClass(); - /* setAttribute used to disappear for no good reason. */ - $t->setRequired(); - echo 'DONE'; + $t = new MyClass(); + /* setAttribute used to disappear for no good reason. */ + $t->setRequired(); + echo 'DONE'; ?> --EXPECT-- DONE diff --git a/Zend/tests/traits/bug60145.phpt b/Zend/tests/traits/bug60145.phpt index fcd0cfa5f285..fa1dc9bf95b4 100644 --- a/Zend/tests/traits/bug60145.phpt +++ b/Zend/tests/traits/bug60145.phpt @@ -8,9 +8,9 @@ trait foo { } interface MyInterface { - use foo; + use foo; - public function b(); + public function b(); } --EXPECTF-- diff --git a/Zend/tests/traits/bug60717.phpt b/Zend/tests/traits/bug60717.phpt index d38b1c0c24c3..0f5cadb0661c 100644 --- a/Zend/tests/traits/bug60717.phpt +++ b/Zend/tests/traits/bug60717.phpt @@ -5,62 +5,62 @@ Bug #60717 (Order of traits in use statement can cause unexpected unresolved abs namespace HTML { - interface Helper - { - function text($text); - function attributes(array $attributes = null); - function textArea(array $attributes = null, $value); - } + interface Helper + { + function text($text); + function attributes(array $attributes = null); + function textArea(array $attributes = null, $value); + } - trait TextUTF8 - { - function text($text) {} - } + trait TextUTF8 + { + function text($text) {} + } - trait TextArea - { - function textArea(array $attributes = null, $value) {} - abstract function attributes(array $attributes = null); - abstract function text($text); - } + trait TextArea + { + function textArea(array $attributes = null, $value) {} + abstract function attributes(array $attributes = null); + abstract function text($text); + } - trait HTMLAttributes - { - function attributes(array $attributes = null) { } - abstract function text($text); - } + trait HTMLAttributes + { + function attributes(array $attributes = null) { } + abstract function text($text); + } - class HTMLHelper implements Helper - { - use TextArea, HTMLAttributes, TextUTF8; - } + class HTMLHelper implements Helper + { + use TextArea, HTMLAttributes, TextUTF8; + } - class HTMLHelper2 implements Helper - { - use TextArea, TextUTF8, HTMLAttributes; - } + class HTMLHelper2 implements Helper + { + use TextArea, TextUTF8, HTMLAttributes; + } - class HTMLHelper3 implements Helper - { - use HTMLAttributes, TextArea, TextUTF8; - } + class HTMLHelper3 implements Helper + { + use HTMLAttributes, TextArea, TextUTF8; + } - class HTMLHelper4 implements Helper - { - use HTMLAttributes, TextUTF8, TextArea; - } + class HTMLHelper4 implements Helper + { + use HTMLAttributes, TextUTF8, TextArea; + } - class HTMLHelper5 implements Helper - { - use TextUTF8, TextArea, HTMLAttributes; - } + class HTMLHelper5 implements Helper + { + use TextUTF8, TextArea, HTMLAttributes; + } - class HTMLHelper6 implements Helper - { - use TextUTF8, HTMLAttributes, TextArea; - } + class HTMLHelper6 implements Helper + { + use TextUTF8, HTMLAttributes, TextArea; + } - $o = new HTMLHelper; + $o = new HTMLHelper; $o = new HTMLHelper2; $o = new HTMLHelper3; $o = new HTMLHelper4; diff --git a/Zend/tests/traits/bug60809.phpt b/Zend/tests/traits/bug60809.phpt index 78e7898461d9..f1a21b12383e 100644 --- a/Zend/tests/traits/bug60809.phpt +++ b/Zend/tests/traits/bug60809.phpt @@ -3,28 +3,28 @@ Bug #60809 (TRAITS - PHPDoc Comment Style Bug) --FILE-- hello_world; - } + private $hello_world = "hello foo\n"; + public function foo() { + echo $this->hello_world; + } } class Example extends ExampleParent { - use ExampleTrait; + use ExampleTrait; } trait ExampleTrait { - /** - * - */ - private $hello_world = "hello bar\n"; - /** - * - */ - public $prop = "ops"; - public function bar() { - echo $this->hello_world; - } + /** + * + */ + private $hello_world = "hello bar\n"; + /** + * + */ + public $prop = "ops"; + public function bar() { + echo $this->hello_world; + } } $x = new Example(); diff --git a/Zend/tests/traits/bug75607.phpt b/Zend/tests/traits/bug75607.phpt index e466e6333b9e..032b7c3d7884 100644 --- a/Zend/tests/traits/bug75607.phpt +++ b/Zend/tests/traits/bug75607.phpt @@ -5,17 +5,17 @@ Bug #75607 (Comparison of initial static properties failing) trait T1 { - public static $prop1 = 1; + public static $prop1 = 1; } class Base { - public static $prop1 = 1; + public static $prop1 = 1; } class Child extends base { - use T1; + use T1; } echo "DONE"; diff --git a/Zend/tests/traits/bug75607a.phpt b/Zend/tests/traits/bug75607a.phpt index 12b555f72866..fb2ecd410fa3 100644 --- a/Zend/tests/traits/bug75607a.phpt +++ b/Zend/tests/traits/bug75607a.phpt @@ -5,17 +5,17 @@ Bug #75607 (Comparison of initial static properties failing) trait T1 { - public static $prop1 = 1; + public static $prop1 = 1; } trait T2 { - public static $prop1 = 1; + public static $prop1 = 1; } class Base { - use T1; + use T1; } class Child extends base @@ -25,7 +25,7 @@ class Child extends base class Grand extends Child { - use T2; + use T2; } $c = new Grand(); diff --git a/Zend/tests/traits/bug76539.phpt b/Zend/tests/traits/bug76539.phpt index 51a75cdaf6f5..0a6d893032cb 100644 --- a/Zend/tests/traits/bug76539.phpt +++ b/Zend/tests/traits/bug76539.phpt @@ -3,19 +3,19 @@ Bug #76539 (Trait attribute is set incorrectly when using self::class with anoth --FILE-- attr, PHP_EOL; - } + public function test() { + echo $this->attr, PHP_EOL; + } } class A { - use MyTrait; + use MyTrait; } class B { - use MyTrait; + use MyTrait; } (new A())->test(); diff --git a/Zend/tests/traits/bugs/abstract-methods01.phpt b/Zend/tests/traits/bugs/abstract-methods01.phpt index 23cdef3a89fa..721f9657594d 100644 --- a/Zend/tests/traits/bugs/abstract-methods01.phpt +++ b/Zend/tests/traits/bugs/abstract-methods01.phpt @@ -9,7 +9,7 @@ trait THello { } class TraitsTest { - use THello; + use THello; } $test = new TraitsTest(); diff --git a/Zend/tests/traits/bugs/abstract-methods02.phpt b/Zend/tests/traits/bugs/abstract-methods02.phpt index 73bb65d179e8..3bf263f5fa23 100644 --- a/Zend/tests/traits/bugs/abstract-methods02.phpt +++ b/Zend/tests/traits/bugs/abstract-methods02.phpt @@ -15,8 +15,8 @@ trait THelloImpl { } class TraitsTest { - use THello; - use THelloImpl; + use THello; + use THelloImpl; } $test = new TraitsTest(); diff --git a/Zend/tests/traits/bugs/abstract-methods04.phpt b/Zend/tests/traits/bugs/abstract-methods04.phpt index d15bdd9473ca..0ae313765709 100644 --- a/Zend/tests/traits/bugs/abstract-methods04.phpt +++ b/Zend/tests/traits/bugs/abstract-methods04.phpt @@ -11,21 +11,21 @@ trait THello { trait THelloImpl { public function hello() { - echo 'Hello'; + echo 'Hello'; } } class TraitsTest1 { - use THello; - use THelloImpl; + use THello; + use THelloImpl; } $test = new TraitsTest1(); $test->hello(); class TraitsTest2 { - use THelloImpl; - use THello; + use THelloImpl; + use THello; } $test = new TraitsTest2(); diff --git a/Zend/tests/traits/bugs/abstract-methods05.phpt b/Zend/tests/traits/bugs/abstract-methods05.phpt index b40cbe30a6ca..96619eae910b 100644 --- a/Zend/tests/traits/bugs/abstract-methods05.phpt +++ b/Zend/tests/traits/bugs/abstract-methods05.phpt @@ -6,7 +6,7 @@ error_reporting(E_ALL); trait THelloB { public function hello() { - echo 'Hello'; + echo 'Hello'; } } @@ -15,8 +15,8 @@ trait THelloA { } class TraitsTest1 { - use THelloB; - use THelloA; + use THelloB; + use THelloA; } diff --git a/Zend/tests/traits/bugs/abstract-methods06.phpt b/Zend/tests/traits/bugs/abstract-methods06.phpt index d8d4994f663f..8e2f25b048e0 100644 --- a/Zend/tests/traits/bugs/abstract-methods06.phpt +++ b/Zend/tests/traits/bugs/abstract-methods06.phpt @@ -15,8 +15,8 @@ trait THelloA { } class TraitsTest1 { - use THelloA; - use THelloB; + use THelloA; + use THelloB; } diff --git a/Zend/tests/traits/bugs/alias-semantics.phpt b/Zend/tests/traits/bugs/alias-semantics.phpt index eec2de1affb3..d856d166bd89 100644 --- a/Zend/tests/traits/bugs/alias-semantics.phpt +++ b/Zend/tests/traits/bugs/alias-semantics.phpt @@ -11,7 +11,7 @@ trait THello { } class TraitsTest { - use THello { a as b; } + use THello { a as b; } } $test = new TraitsTest(); diff --git a/Zend/tests/traits/bugs/alias-semantics02.phpt b/Zend/tests/traits/bugs/alias-semantics02.phpt index 64491828805c..4ff6f168f06a 100644 --- a/Zend/tests/traits/bugs/alias-semantics02.phpt +++ b/Zend/tests/traits/bugs/alias-semantics02.phpt @@ -13,7 +13,7 @@ trait THello { } class TraitsTest { - use THello { THello::a as b; } + use THello { THello::a as b; } } $test = new TraitsTest(); diff --git a/Zend/tests/traits/bugs/case-sensitive.phpt b/Zend/tests/traits/bugs/case-sensitive.phpt index 6a65ccff03cb..080b6b7cce48 100644 --- a/Zend/tests/traits/bugs/case-sensitive.phpt +++ b/Zend/tests/traits/bugs/case-sensitive.phpt @@ -5,18 +5,18 @@ Check for problems with case sensitivity in compositions error_reporting(E_ALL); trait A { - public function M1() {} - public function M2() {} + public function M1() {} + public function M2() {} } trait B { - public function M1() {} - public function M2() {} + public function M1() {} + public function M2() {} } class MyClass { - use A; - use B; + use A; + use B; } ?> --EXPECTF-- diff --git a/Zend/tests/traits/bugs/interfaces.phpt b/Zend/tests/traits/bugs/interfaces.phpt index 97ec174a7f66..e68e54f3de40 100644 --- a/Zend/tests/traits/bugs/interfaces.phpt +++ b/Zend/tests/traits/bugs/interfaces.phpt @@ -5,7 +5,7 @@ Make sure trait does not implement an interface. error_reporting(E_ALL); interface MyInterface { - public function a(); + public function a(); } trait THello implements MyInterface { diff --git a/Zend/tests/traits/conflict001.phpt b/Zend/tests/traits/conflict001.phpt index 11dababdb5d7..c288df735101 100644 --- a/Zend/tests/traits/conflict001.phpt +++ b/Zend/tests/traits/conflict001.phpt @@ -17,8 +17,8 @@ trait THello2 { } class TraitsTest { - use THello1; - use THello2; + use THello1; + use THello2; } ?> --EXPECTF-- diff --git a/Zend/tests/traits/error_001.phpt b/Zend/tests/traits/error_001.phpt index be4295a6d8bf..31f2ab15c0a0 100644 --- a/Zend/tests/traits/error_001.phpt +++ b/Zend/tests/traits/error_001.phpt @@ -4,23 +4,23 @@ Trying to use instanceof for a method twice diff --git a/Zend/tests/traits/error_002.phpt b/Zend/tests/traits/error_002.phpt index ac98769f47a1..0c2f19d2df17 100644 --- a/Zend/tests/traits/error_002.phpt +++ b/Zend/tests/traits/error_002.phpt @@ -4,7 +4,7 @@ Trying to use an undefined trait diff --git a/Zend/tests/traits/error_003.phpt b/Zend/tests/traits/error_003.phpt index 23f62d2977e8..fdfa0ac1fe22 100644 --- a/Zend/tests/traits/error_003.phpt +++ b/Zend/tests/traits/error_003.phpt @@ -7,7 +7,7 @@ interface abc { } class A { - use abc; + use abc; } ?> diff --git a/Zend/tests/traits/error_004.phpt b/Zend/tests/traits/error_004.phpt index 5bfcc263cc86..d7ff695e047b 100644 --- a/Zend/tests/traits/error_004.phpt +++ b/Zend/tests/traits/error_004.phpt @@ -7,7 +7,7 @@ class abc { } class A { - use abc; + use abc; } ?> diff --git a/Zend/tests/traits/error_005.phpt b/Zend/tests/traits/error_005.phpt index 99952f70e6f3..3b8cc32f9758 100644 --- a/Zend/tests/traits/error_005.phpt +++ b/Zend/tests/traits/error_005.phpt @@ -7,7 +7,7 @@ final class abc { } class A { - use abc; + use abc; } ?> diff --git a/Zend/tests/traits/error_006.phpt b/Zend/tests/traits/error_006.phpt index 54083a310fb4..f3ed87123cf2 100644 --- a/Zend/tests/traits/error_006.phpt +++ b/Zend/tests/traits/error_006.phpt @@ -7,7 +7,7 @@ abstract class abc { } class A { - use abc; + use abc; } ?> diff --git a/Zend/tests/traits/error_010.phpt b/Zend/tests/traits/error_010.phpt index de3741ea572e..f286cba572f4 100644 --- a/Zend/tests/traits/error_010.phpt +++ b/Zend/tests/traits/error_010.phpt @@ -4,15 +4,15 @@ Trying to exclude trait method multiple times diff --git a/Zend/tests/traits/get_declared_traits_002.phpt b/Zend/tests/traits/get_declared_traits_002.phpt index 73dd73c92733..76e529453605 100644 --- a/Zend/tests/traits/get_declared_traits_002.phpt +++ b/Zend/tests/traits/get_declared_traits_002.phpt @@ -4,12 +4,12 @@ Testing get_declared_traits() inside namespace diff --git a/Zend/tests/traits/interface_001.phpt b/Zend/tests/traits/interface_001.phpt index a14f78efc880..46ebf73b57d1 100644 --- a/Zend/tests/traits/interface_001.phpt +++ b/Zend/tests/traits/interface_001.phpt @@ -4,16 +4,16 @@ Using traits to implement interface --EXPECTF-- diff --git a/Zend/tests/traits/language019.phpt b/Zend/tests/traits/language019.phpt index 83318c58a2e7..7764054ebd98 100644 --- a/Zend/tests/traits/language019.phpt +++ b/Zend/tests/traits/language019.phpt @@ -3,12 +3,12 @@ final alias --FILE-- --EXPECTF-- diff --git a/Zend/tests/traits/methods_001.phpt b/Zend/tests/traits/methods_001.phpt index 758234f2d597..8f44898cee3a 100644 --- a/Zend/tests/traits/methods_001.phpt +++ b/Zend/tests/traits/methods_001.phpt @@ -4,25 +4,25 @@ Testing magic method on trait hello . ' ' . $this->world; - } + use THello1; + use THello2; + function test() { + echo $this->hello . ' ' . $this->world; + } } var_dump(property_exists('TraitsTest', 'hello')); diff --git a/Zend/tests/traits/property003.phpt b/Zend/tests/traits/property003.phpt index 5a2863cfe1c0..881edb53f20a 100644 --- a/Zend/tests/traits/property003.phpt +++ b/Zend/tests/traits/property003.phpt @@ -14,8 +14,8 @@ trait THello2 { echo "PRE-CLASS-GUARD\n"; class TraitsTest { - use THello1; - use THello2; + use THello1; + use THello2; } echo "POST-CLASS-GUARD\n"; diff --git a/Zend/tests/traits/property004.phpt b/Zend/tests/traits/property004.phpt index 53dca02e025c..5734b83e2b87 100644 --- a/Zend/tests/traits/property004.phpt +++ b/Zend/tests/traits/property004.phpt @@ -14,11 +14,11 @@ trait THello2 { echo "PRE-CLASS-GUARD\n"; class TraitsTest { - use THello1; - use THello2; - public function getHello() { - return $this->hello; - } + use THello1; + use THello2; + public function getHello() { + return $this->hello; + } } $t = new TraitsTest; diff --git a/Zend/tests/traits/property005.phpt b/Zend/tests/traits/property005.phpt index 5bdbfcdabae5..d0a976cb3768 100644 --- a/Zend/tests/traits/property005.phpt +++ b/Zend/tests/traits/property005.phpt @@ -21,7 +21,7 @@ echo "POST-CLASS-GUARD\n"; // now we do the test for a fatal error class TraitsTest { - use THello1; + use THello1; public $hello; } diff --git a/Zend/tests/traits/static_001.phpt b/Zend/tests/traits/static_001.phpt index 326481c779b6..b8e69d1091b1 100644 --- a/Zend/tests/traits/static_001.phpt +++ b/Zend/tests/traits/static_001.phpt @@ -5,17 +5,17 @@ Simas Toleikis simast@gmail.com --FILE-- --EXPECT-- diff --git a/Zend/tests/traits/static_002.phpt b/Zend/tests/traits/static_002.phpt index 5c1a92a80603..4a75136c4262 100644 --- a/Zend/tests/traits/static_002.phpt +++ b/Zend/tests/traits/static_002.phpt @@ -5,18 +5,18 @@ Simas Toleikis simast@gmail.com --FILE-- --EXPECT-- diff --git a/Zend/tests/traits/static_003.phpt b/Zend/tests/traits/static_003.phpt index 7417083f69c7..87f4b77aa81a 100644 --- a/Zend/tests/traits/static_003.phpt +++ b/Zend/tests/traits/static_003.phpt @@ -5,22 +5,22 @@ Simas Toleikis simast@gmail.com --FILE-- --EXPECT-- diff --git a/Zend/tests/traits/static_004.phpt b/Zend/tests/traits/static_004.phpt index ca02a85e8044..e7ceea881c16 100644 --- a/Zend/tests/traits/static_004.phpt +++ b/Zend/tests/traits/static_004.phpt @@ -5,17 +5,17 @@ Simas Toleikis simast@gmail.com --FILE-- --EXPECT-- diff --git a/Zend/tests/traits/static_forward_static_call.phpt b/Zend/tests/traits/static_forward_static_call.phpt index 9ba53bf08a89..2f6654172927 100644 --- a/Zend/tests/traits/static_forward_static_call.phpt +++ b/Zend/tests/traits/static_forward_static_call.phpt @@ -5,23 +5,23 @@ Simas Toleikis simast@gmail.com --FILE-- --EXPECT-- diff --git a/Zend/tests/traits/static_get_called_class.phpt b/Zend/tests/traits/static_get_called_class.phpt index b1d8fa3d1e18..5f61f8b81b6e 100644 --- a/Zend/tests/traits/static_get_called_class.phpt +++ b/Zend/tests/traits/static_get_called_class.phpt @@ -5,19 +5,19 @@ Simas Toleikis simast@gmail.com --FILE-- --EXPECT-- diff --git a/Zend/tests/traits/trait_constant_001.phpt b/Zend/tests/traits/trait_constant_001.phpt index 7a5268633e7b..9521c9267b09 100644 --- a/Zend/tests/traits/trait_constant_001.phpt +++ b/Zend/tests/traits/trait_constant_001.phpt @@ -4,13 +4,13 @@ __TRAIT__: Basics, a constant denoiting the trait of definition. --EXPECT-- string(0) "" diff --git a/Zend/tests/try/bug70228_8.phpt b/Zend/tests/try/bug70228_8.phpt index 93fc09f6a83f..6e8533414f3d 100644 --- a/Zend/tests/try/bug70228_8.phpt +++ b/Zend/tests/try/bug70228_8.phpt @@ -9,9 +9,9 @@ function foo() { var_dump($value); try { try { - switch (str_repeat("b", 2)) { - case "bb": - return str_repeat("a", 2); + switch (str_repeat("b", 2)) { + case "bb": + return str_repeat("a", 2); } } finally { throw new Exception; diff --git a/Zend/tests/try/bug72213.phpt b/Zend/tests/try/bug72213.phpt index 624050295eab..50555f53e419 100644 --- a/Zend/tests/try/bug72213.phpt +++ b/Zend/tests/try/bug72213.phpt @@ -3,21 +3,21 @@ Bug #72213 (Finally leaks on nested exceptions) --FILE-- getMessage()); - var_dump($e->getPrevious()->getMessage()); + var_dump($e->getMessage()); + var_dump($e->getPrevious()->getMessage()); } ?> --EXPECT-- diff --git a/Zend/tests/try/bug72629.phpt b/Zend/tests/try/bug72629.phpt index 034a63b30612..2e8e40d6b2c9 100644 --- a/Zend/tests/try/bug72629.phpt +++ b/Zend/tests/try/bug72629.phpt @@ -7,7 +7,7 @@ $var = null; $e = &$var; try { - throw new Exception; + throw new Exception; } catch (Exception $e) { } var_dump($var === $e); diff --git a/Zend/tests/try/bug74444.phpt b/Zend/tests/try/bug74444.phpt index 74e0c9d46fb8..949f83cb2354 100644 --- a/Zend/tests/try/bug74444.phpt +++ b/Zend/tests/try/bug74444.phpt @@ -4,71 +4,71 @@ Bug #74444 (multiple catch freezes in some cases) diff --git a/Zend/tests/try/catch_003.phpt b/Zend/tests/try/catch_003.phpt index 579011f867a3..14ff8501233b 100644 --- a/Zend/tests/try/catch_003.phpt +++ b/Zend/tests/try/catch_003.phpt @@ -5,30 +5,30 @@ Catching an exception in a constructor fired form a static method class MyObject { - function fail() - { - throw new Exception(); - } + function fail() + { + throw new Exception(); + } - function __construct() - { - self::fail(); - echo __METHOD__ . "() Must not be reached\n"; - } + function __construct() + { + self::fail(); + echo __METHOD__ . "() Must not be reached\n"; + } - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } } try { - new MyObject(); + new MyObject(); } catch(Exception $e) { - echo "Caught\n"; + echo "Caught\n"; } ?> diff --git a/Zend/tests/try/catch_004.phpt b/Zend/tests/try/catch_004.phpt index 5ec82998f7b1..d4f54ce77606 100644 --- a/Zend/tests/try/catch_004.phpt +++ b/Zend/tests/try/catch_004.phpt @@ -5,33 +5,33 @@ Catching an exception in a constructor inside a static method class MyObject { - function fail() - { - throw new Exception(); - } + function fail() + { + throw new Exception(); + } - function __construct() - { - self::fail(); - echo __METHOD__ . "() Must not be reached\n"; - } + function __construct() + { + self::fail(); + echo __METHOD__ . "() Must not be reached\n"; + } - function __destruct() - { - echo __METHOD__ . "() Must not be called\n"; - } + function __destruct() + { + echo __METHOD__ . "() Must not be called\n"; + } - static function test() - { - try - { - new MyObject(); - } - catch(Exception $e) - { - echo "Caught\n"; - } - } + static function test() + { + try + { + new MyObject(); + } + catch(Exception $e) + { + echo "Caught\n"; + } + } } MyObject::test(); diff --git a/Zend/tests/try/finally_goto_001.phpt b/Zend/tests/try/finally_goto_001.phpt index 990f78d4c743..82bdd1ef9b61 100644 --- a/Zend/tests/try/finally_goto_001.phpt +++ b/Zend/tests/try/finally_goto_001.phpt @@ -3,8 +3,8 @@ jmp into a finally block 01 --FILE-- --EXPECTF-- diff --git a/Zend/tests/try/finally_goto_005.phpt b/Zend/tests/try/finally_goto_005.phpt index 36b4155d81fc..ffb0e68be103 100644 --- a/Zend/tests/try/finally_goto_005.phpt +++ b/Zend/tests/try/finally_goto_005.phpt @@ -4,10 +4,10 @@ There must be a difference between label: try { ... } and try { label: ... } diff --git a/Zend/tests/try/try_finally_010.phpt b/Zend/tests/try/try_finally_010.phpt index 91eb7821eee6..8d5fa1e431cd 100644 --- a/Zend/tests/try/try_finally_010.phpt +++ b/Zend/tests/try/try_finally_010.phpt @@ -3,27 +3,27 @@ Try finally (function call in the finally block after exception) --FILE-- --EXPECT-- diff --git a/Zend/tests/try/try_finally_019.phpt b/Zend/tests/try/try_finally_019.phpt index 2e2069d1be99..2a3c614eba13 100644 --- a/Zend/tests/try/try_finally_019.phpt +++ b/Zend/tests/try/try_finally_019.phpt @@ -3,13 +3,13 @@ Combination of foreach, finally and goto (call order) --FILE-- n = $n; - } - function __destruct() { - echo "destruct" . $this->n . "\n"; - } + public $n = 0; + function __construct($n) { + $this->n = $n; + } + function __destruct() { + echo "destruct" . $this->n . "\n"; + } } foreach ([new A(1)] as $a) { diff --git a/Zend/tests/try/try_finally_020.phpt b/Zend/tests/try/try_finally_020.phpt index cfb72d0c5545..5fda56bcad78 100644 --- a/Zend/tests/try/try_finally_020.phpt +++ b/Zend/tests/try/try_finally_020.phpt @@ -3,13 +3,13 @@ Combination of foreach, finally and exception (call order) --FILE-- n = $n; - } - function __destruct() { - echo "destruct" . $this->n . "\n"; - } + public $n = 0; + function __construct($n) { + $this->n = $n; + } + function __destruct() { + echo "destruct" . $this->n . "\n"; + } } foreach ([new A(1)] as $a) { diff --git a/Zend/tests/try/try_finally_021.phpt b/Zend/tests/try/try_finally_021.phpt index ed162f40d037..d25f393be1f0 100644 --- a/Zend/tests/try/try_finally_021.phpt +++ b/Zend/tests/try/try_finally_021.phpt @@ -6,10 +6,10 @@ $array = [1]; foreach ([0] as $_) { foreach ($array as $v) { try { - echo "ok\n"; + echo "ok\n"; return; } finally { - echo "ok\n"; + echo "ok\n"; return; } } diff --git a/Zend/tests/try/try_finally_022.phpt b/Zend/tests/try/try_finally_022.phpt index ff10dead42ff..7d03264be5f2 100644 --- a/Zend/tests/try/try_finally_022.phpt +++ b/Zend/tests/try/try_finally_022.phpt @@ -3,37 +3,37 @@ Try finally (exception in "return" statement) --FILE-- --EXPECT-- diff --git a/Zend/tests/try/try_multicatch_001.phpt b/Zend/tests/try/try_multicatch_001.phpt index 0dffd32c72d4..ae86c743eabf 100644 --- a/Zend/tests/try/try_multicatch_001.phpt +++ b/Zend/tests/try/try_multicatch_001.phpt @@ -6,11 +6,11 @@ Parsing test require_once __DIR__ . '/exceptions.inc'; try { - echo 'TRY' . PHP_EOL; + echo 'TRY' . PHP_EOL; } catch(Exception1 | Exception2 $e) { - echo 'Exception'; + echo 'Exception'; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> diff --git a/Zend/tests/try/try_multicatch_002.phpt b/Zend/tests/try/try_multicatch_002.phpt index 0e70fec7eb35..559259bba37f 100644 --- a/Zend/tests/try/try_multicatch_002.phpt +++ b/Zend/tests/try/try_multicatch_002.phpt @@ -6,12 +6,12 @@ Catch first exception in the multicatch require_once __DIR__ . '/exceptions.inc'; try { - echo 'TRY' . PHP_EOL; - throw new Exception1; + echo 'TRY' . PHP_EOL; + throw new Exception1; } catch(Exception1 | Exception2 | Exception3 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> diff --git a/Zend/tests/try/try_multicatch_003.phpt b/Zend/tests/try/try_multicatch_003.phpt index 6aed1a2b0900..3bc4dead6916 100644 --- a/Zend/tests/try/try_multicatch_003.phpt +++ b/Zend/tests/try/try_multicatch_003.phpt @@ -6,12 +6,12 @@ Catch second exception in the multicatch require_once __DIR__ . '/exceptions.inc'; try { - echo 'TRY' . PHP_EOL; - throw new Exception2; + echo 'TRY' . PHP_EOL; + throw new Exception2; } catch(Exception1 | Exception2 | Exception3 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> diff --git a/Zend/tests/try/try_multicatch_004.phpt b/Zend/tests/try/try_multicatch_004.phpt index d8b245a767ca..680c252142fd 100644 --- a/Zend/tests/try/try_multicatch_004.phpt +++ b/Zend/tests/try/try_multicatch_004.phpt @@ -6,12 +6,12 @@ Catch last exception in the multicatch require_once __DIR__ . '/exceptions.inc'; try { - echo 'TRY' . PHP_EOL; - throw new Exception3; + echo 'TRY' . PHP_EOL; + throw new Exception3; } catch(Exception1 | Exception2 | Exception3 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> diff --git a/Zend/tests/try/try_multicatch_005.phpt b/Zend/tests/try/try_multicatch_005.phpt index cc3fc890faea..e7bb61b74e1a 100644 --- a/Zend/tests/try/try_multicatch_005.phpt +++ b/Zend/tests/try/try_multicatch_005.phpt @@ -6,16 +6,16 @@ Catch exception in the nested multicatch require_once __DIR__ . '/exceptions.inc'; try { - try { - echo 'TRY' . PHP_EOL; - throw new Exception3; - } catch (Exception1 | Exception3 $e) { - echo get_class($e) . PHP_EOL; - } + try { + echo 'TRY' . PHP_EOL; + throw new Exception3; + } catch (Exception1 | Exception3 $e) { + echo get_class($e) . PHP_EOL; + } } catch(Exception2 | Exception3 $e) { - echo 'Should never be executed'; + echo 'Should never be executed'; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> diff --git a/Zend/tests/try/try_multicatch_006.phpt b/Zend/tests/try/try_multicatch_006.phpt index 440e06593c14..f0eba8981c18 100644 --- a/Zend/tests/try/try_multicatch_006.phpt +++ b/Zend/tests/try/try_multicatch_006.phpt @@ -5,14 +5,14 @@ Catch first exception in the second multicatch require_once __DIR__ . '/exceptions.inc'; try { - echo 'TRY' . PHP_EOL; - throw new Exception3; + echo 'TRY' . PHP_EOL; + throw new Exception3; } catch(Exception1 | Exception2 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } catch(Exception3 | Exception4 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> --EXPECT-- diff --git a/Zend/tests/try/try_multicatch_007.phpt b/Zend/tests/try/try_multicatch_007.phpt index 40784108a059..3ec5c64f68c0 100644 --- a/Zend/tests/try/try_multicatch_007.phpt +++ b/Zend/tests/try/try_multicatch_007.phpt @@ -5,14 +5,14 @@ Catch second exception in the second multicatch require_once __DIR__ . '/exceptions.inc'; try { - echo 'TRY' . PHP_EOL; - throw new Exception4; + echo 'TRY' . PHP_EOL; + throw new Exception4; } catch(Exception1 | Exception2 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } catch(Exception3 | Exception4 $e) { - echo get_class($e) . PHP_EOL; + echo get_class($e) . PHP_EOL; } finally { - echo 'FINALLY' . PHP_EOL; + echo 'FINALLY' . PHP_EOL; } ?> --EXPECT-- diff --git a/Zend/tests/type_declarations/array_001.phpt b/Zend/tests/type_declarations/array_001.phpt index c3315849a2f5..09af9a98f22f 100644 --- a/Zend/tests/type_declarations/array_001.phpt +++ b/Zend/tests/type_declarations/array_001.phpt @@ -3,7 +3,7 @@ Array type declaration --FILE-- getMessage() . PHP_EOL; + echo "*** Caught " . $e->getMessage() . PHP_EOL; } echo "*** Trying Array Map With Invalid Callback" . PHP_EOL; try { - array_map([null, "bar"], []); + array_map([null, "bar"], []); } catch (TypeError $e) { - echo "*** Caught " . $e->getMessage() . PHP_EOL; + echo "*** Caught " . $e->getMessage() . PHP_EOL; } echo "*** Trying Strlen With Float" . PHP_EOL; try { - var_dump(strlen(1.5)); + var_dump(strlen(1.5)); } catch (TypeError $e) { - echo "*** Caught " . $e->getMessage() . PHP_EOL; + echo "*** Caught " . $e->getMessage() . PHP_EOL; } ?> diff --git a/Zend/tests/type_declarations/iterable_003.phpt b/Zend/tests/type_declarations/iterable_003.phpt index e5e6af9ae886..0b6c032b9f85 100644 --- a/Zend/tests/type_declarations/iterable_003.phpt +++ b/Zend/tests/type_declarations/iterable_003.phpt @@ -4,10 +4,10 @@ iterable type#003 - Return types diff --git a/Zend/tests/type_declarations/scalar_constant_defaults.phpt b/Zend/tests/type_declarations/scalar_constant_defaults.phpt index 88c6a4b39fac..e42cb32bde31 100644 --- a/Zend/tests/type_declarations/scalar_constant_defaults.phpt +++ b/Zend/tests/type_declarations/scalar_constant_defaults.phpt @@ -12,35 +12,35 @@ const STRING_ADD_VAL = "this" . " is a test"; const NULL_VAL = null; function int_val(int $a = INT_VAL): int { - return $a; + return $a; } function float_val(float $a = FLOAT_VAL): float { - return $a; + return $a; } function string_val(string $a = STRING_VAL): string { - return $a; + return $a; } function int_add_val(int $a = INT_ADD_VAL): int { - return $a; + return $a; } function float_add_val(float $a = FLOAT_ADD_VAL): float { - return $a; + return $a; } function string_add_val(string $a = STRING_ADD_VAL): string { - return $a; + return $a; } function int_val_default_null(int $a = NULL_VAL) { - return $a; + return $a; } function nullable_int_val_default_null(?int $a = NULL_VAL) { - return $a; + return $a; } echo "Testing int val" . PHP_EOL; diff --git a/Zend/tests/type_declarations/scalar_constant_defaults_error.phpt b/Zend/tests/type_declarations/scalar_constant_defaults_error.phpt index 750edb77faf3..d897bb4822b3 100644 --- a/Zend/tests/type_declarations/scalar_constant_defaults_error.phpt +++ b/Zend/tests/type_declarations/scalar_constant_defaults_error.phpt @@ -6,7 +6,7 @@ Scalar type - default via constants - error condition const STRING_VAL = "test"; function int_val(int $a = STRING_VAL): int { - return $a; + return $a; } var_dump(int_val()); diff --git a/Zend/tests/type_declarations/scalar_relative_typehint_disallowed.phpt b/Zend/tests/type_declarations/scalar_relative_typehint_disallowed.phpt index b0939837172f..7f53b49b9c63 100644 --- a/Zend/tests/type_declarations/scalar_relative_typehint_disallowed.phpt +++ b/Zend/tests/type_declarations/scalar_relative_typehint_disallowed.phpt @@ -4,7 +4,7 @@ Scalar type - disallow relative types diff --git a/Zend/tests/type_declarations/typed_properties_001.phpt b/Zend/tests/type_declarations/typed_properties_001.phpt index 6e34cb478f0a..ce791cd4b56e 100644 --- a/Zend/tests/type_declarations/typed_properties_001.phpt +++ b/Zend/tests/type_declarations/typed_properties_001.phpt @@ -3,21 +3,21 @@ Test typed properties basic operation --FILE-- int = $int; - $this->float = $float; - $this->bool = $bool; - $this->array = $array; - $this->std = $std; - $this->it = $array; - } + public function __construct(int $int, float $float, bool $bool, array $array, stdClass $std) { + $this->int = $int; + $this->float = $float; + $this->bool = $bool; + $this->array = $array; + $this->std = $std; + $this->it = $array; + } }); ?> --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_002.phpt b/Zend/tests/type_declarations/typed_properties_002.phpt index 3aec7a34ba6a..b0d1e1c0f279 100644 --- a/Zend/tests/type_declarations/typed_properties_002.phpt +++ b/Zend/tests/type_declarations/typed_properties_002.phpt @@ -3,7 +3,7 @@ Test typed properties error condition (read uninitialized) --FILE-- int); diff --git a/Zend/tests/type_declarations/typed_properties_003.phpt b/Zend/tests/type_declarations/typed_properties_003.phpt index 59c289a56658..6cde9cc60434 100644 --- a/Zend/tests/type_declarations/typed_properties_003.phpt +++ b/Zend/tests/type_declarations/typed_properties_003.phpt @@ -3,7 +3,7 @@ Test typed properties error condition (fetch uninitialized by reference) --FILE-- int; diff --git a/Zend/tests/type_declarations/typed_properties_004.phpt b/Zend/tests/type_declarations/typed_properties_004.phpt index 2df693aa997c..eb8e1ef6b4a3 100644 --- a/Zend/tests/type_declarations/typed_properties_004.phpt +++ b/Zend/tests/type_declarations/typed_properties_004.phpt @@ -3,11 +3,11 @@ Test typed properties error condition (type mismatch) --FILE-- int = $string; - } + public function __construct(string $string) { + $this->int = $string; + } }; ?> --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_005.phpt b/Zend/tests/type_declarations/typed_properties_005.phpt index 104f4bd57ee3..71f264a926aa 100644 --- a/Zend/tests/type_declarations/typed_properties_005.phpt +++ b/Zend/tests/type_declarations/typed_properties_005.phpt @@ -5,11 +5,11 @@ Test typed properties error condition (type mismatch object) class Dummy {} new class(new Dummy) { - public stdClass $std; + public stdClass $std; - public function __construct(Dummy $dummy) { - $this->std = $dummy; - } + public function __construct(Dummy $dummy) { + $this->std = $dummy; + } }; ?> --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_006.phpt b/Zend/tests/type_declarations/typed_properties_006.phpt index c3a8faefd4ab..493b64fb865c 100644 --- a/Zend/tests/type_declarations/typed_properties_006.phpt +++ b/Zend/tests/type_declarations/typed_properties_006.phpt @@ -3,11 +3,11 @@ Test typed properties inheritance (scalar) --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_007.phpt b/Zend/tests/type_declarations/typed_properties_007.phpt index 19e8022a24fc..90d53b46ade4 100644 --- a/Zend/tests/type_declarations/typed_properties_007.phpt +++ b/Zend/tests/type_declarations/typed_properties_007.phpt @@ -6,11 +6,11 @@ class Whatever {} class Thing extends Whatever {} class Foo { - public Whatever $qux; + public Whatever $qux; } class Bar extends Foo { - public Thing $qux; + public Thing $qux; } ?> --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_008.phpt b/Zend/tests/type_declarations/typed_properties_008.phpt index 70b428262613..3f82d6161dc1 100644 --- a/Zend/tests/type_declarations/typed_properties_008.phpt +++ b/Zend/tests/type_declarations/typed_properties_008.phpt @@ -3,11 +3,11 @@ Test typed properties inheritance (missing info) --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_009.phpt b/Zend/tests/type_declarations/typed_properties_009.phpt index 24013b411806..668dedbbf769 100644 --- a/Zend/tests/type_declarations/typed_properties_009.phpt +++ b/Zend/tests/type_declarations/typed_properties_009.phpt @@ -3,13 +3,13 @@ Test typed properties unset leaves properties in an uninitialized state --FILE-- diff --git a/Zend/tests/type_declarations/typed_properties_013.phpt b/Zend/tests/type_declarations/typed_properties_013.phpt index 7236e21a2c5a..fb481d66cd64 100644 --- a/Zend/tests/type_declarations/typed_properties_013.phpt +++ b/Zend/tests/type_declarations/typed_properties_013.phpt @@ -3,7 +3,7 @@ Test typed properties disallow incorrect type initial value (scalar) --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_014.phpt b/Zend/tests/type_declarations/typed_properties_014.phpt index f7a4449abd0b..161f2e2a5a22 100644 --- a/Zend/tests/type_declarations/typed_properties_014.phpt +++ b/Zend/tests/type_declarations/typed_properties_014.phpt @@ -3,7 +3,7 @@ Test typed properties disallow incorrect type initial value (array) --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_015.phpt b/Zend/tests/type_declarations/typed_properties_015.phpt index ac11c0fe3efa..a40b8764b5f4 100644 --- a/Zend/tests/type_declarations/typed_properties_015.phpt +++ b/Zend/tests/type_declarations/typed_properties_015.phpt @@ -3,7 +3,7 @@ Test typed properties disallow incorrect type initial value (object) --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_016.phpt b/Zend/tests/type_declarations/typed_properties_016.phpt index 3be4d02b7ffa..297ce80d9f44 100644 --- a/Zend/tests/type_declarations/typed_properties_016.phpt +++ b/Zend/tests/type_declarations/typed_properties_016.phpt @@ -3,11 +3,11 @@ Test typed properties initial values --FILE-- bar; - } + public function &method() { + return $this->bar; + } }; var_dump($foo->method()); diff --git a/Zend/tests/type_declarations/typed_properties_033.phpt b/Zend/tests/type_declarations/typed_properties_033.phpt index 87e6aef26b6e..665026f07565 100644 --- a/Zend/tests/type_declarations/typed_properties_033.phpt +++ b/Zend/tests/type_declarations/typed_properties_033.phpt @@ -3,23 +3,23 @@ Test typed properties yield reference guard --FILE-- foo; - yield $this->bar; - yield $this->baz; - yield $this->qux; - } + public function &fetch() { + yield $this->foo; + yield $this->bar; + yield $this->baz; + yield $this->qux; + } }; try { - foreach ($foo->fetch() as &$prop) { - $prop += 1; - } + foreach ($foo->fetch() as &$prop) { + $prop += 1; + } } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($foo); diff --git a/Zend/tests/type_declarations/typed_properties_034.phpt b/Zend/tests/type_declarations/typed_properties_034.phpt index 79317553ab86..4af6baa80aef 100644 --- a/Zend/tests/type_declarations/typed_properties_034.phpt +++ b/Zend/tests/type_declarations/typed_properties_034.phpt @@ -3,35 +3,35 @@ Test typed properties passed to typed function --FILE-- bar] as &$item) { - yield $item; - } - } + public function &getIterator() { + foreach (['1', &$this->bar] as &$item) { + yield $item; + } + } }; function foo(?int &$a) { - var_dump($a); - $a = null; + var_dump($a); + $a = null; } foo($foo->bar); try { - $foo->baz = &$foo->bar; + $foo->baz = &$foo->bar; } catch (Error $e) { echo $e->getMessage(), "\n"; } $foo->bar = 10; foreach ($foo->getIterator() as &$item) { - $foo->baz = &$item; - var_dump($foo->baz); + $foo->baz = &$item; + var_dump($foo->baz); } try { - foo($foo->bar); + foo($foo->bar); } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($foo); diff --git a/Zend/tests/type_declarations/typed_properties_036.phpt b/Zend/tests/type_declarations/typed_properties_036.phpt index 4deb5774f470..df4473dff0e9 100644 --- a/Zend/tests/type_declarations/typed_properties_036.phpt +++ b/Zend/tests/type_declarations/typed_properties_036.phpt @@ -3,11 +3,11 @@ Test uninitialized typed properties normal foreach must not be yielded --FILE-- $bar) { - var_dump($key, $bar); + var_dump($key, $bar); } ?> --EXPECT-- diff --git a/Zend/tests/type_declarations/typed_properties_037.phpt b/Zend/tests/type_declarations/typed_properties_037.phpt index c5dde535728a..9a76791bcd35 100644 --- a/Zend/tests/type_declarations/typed_properties_037.phpt +++ b/Zend/tests/type_declarations/typed_properties_037.phpt @@ -3,7 +3,7 @@ Test typed properties var_dump uninitialized --FILE-- bar++; + $foo->bar++; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump($foo); try { - $foo->bar += 1; + $foo->bar += 1; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump($foo); try { - ++$foo->bar; + ++$foo->bar; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump($foo); try { - $foo->bar = $foo->bar + 1; + $foo->bar = $foo->bar + 1; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump($foo); diff --git a/Zend/tests/type_declarations/typed_properties_040.phpt b/Zend/tests/type_declarations/typed_properties_040.phpt index d1931c5a1125..7a77c4cc0f7e 100644 --- a/Zend/tests/type_declarations/typed_properties_040.phpt +++ b/Zend/tests/type_declarations/typed_properties_040.phpt @@ -5,11 +5,11 @@ Test __get on unset typed property must fail properly declare(strict_types=1); class Foo { - public int $bar; + public int $bar; - public function __get($name) { - var_dump($name); - } + public function __get($name) { + var_dump($name); + } } $foo = new Foo(); diff --git a/Zend/tests/type_declarations/typed_properties_041.phpt b/Zend/tests/type_declarations/typed_properties_041.phpt index 76dbfd8f5d9a..1c5ab0bad516 100644 --- a/Zend/tests/type_declarations/typed_properties_041.phpt +++ b/Zend/tests/type_declarations/typed_properties_041.phpt @@ -4,7 +4,7 @@ Test typed properties weak conversion of strings bar = "5"; - var_dump($foo->bar); + $foo->bar = "5"; + var_dump($foo->bar); } ?> --EXPECT-- diff --git a/Zend/tests/type_declarations/typed_properties_044.phpt b/Zend/tests/type_declarations/typed_properties_044.phpt index 02a71a7b0b6b..f32cd928444e 100644 --- a/Zend/tests/type_declarations/typed_properties_044.phpt +++ b/Zend/tests/type_declarations/typed_properties_044.phpt @@ -5,7 +5,7 @@ Test increment functions on typed property references --FILE-- bar; @@ -20,30 +20,30 @@ var_dump($bar++); $bar = PHP_INT_MAX; try { - var_dump($bar++); + var_dump($bar++); } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(++$bar); + var_dump(++$bar); } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $bar = PHP_INT_MIN; try { - var_dump($bar--); + var_dump($bar--); } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(--$bar); + var_dump(--$bar); } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/Zend/tests/type_declarations/typed_properties_046.phpt b/Zend/tests/type_declarations/typed_properties_046.phpt index d95fe8dc2479..bb524fcf75fe 100644 --- a/Zend/tests/type_declarations/typed_properties_046.phpt +++ b/Zend/tests/type_declarations/typed_properties_046.phpt @@ -3,23 +3,23 @@ Memory leaks on wrong assignment to typed property --FILE-- {bar()} = str_repeat("a", 3); - } catch (Throwable $e) { - echo $e->getMessage() . "\n"; - } + try { + foo()->{bar()} = str_repeat("a", 3); + } catch (Throwable $e) { + echo $e->getMessage() . "\n"; + } } --EXPECT-- Cannot assign string to property Foo::$bbb of type int diff --git a/Zend/tests/type_declarations/typed_properties_047.phpt b/Zend/tests/type_declarations/typed_properties_047.phpt index db78143b02eb..5de7b254d993 100644 --- a/Zend/tests/type_declarations/typed_properties_047.phpt +++ b/Zend/tests/type_declarations/typed_properties_047.phpt @@ -3,7 +3,7 @@ Nullable typed property --FILE-- foo); unset($x->foo); try { - var_dump($x->foo); + var_dump($x->foo); } catch (Throwable $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } try { - $x->foo = "ops"; + $x->foo = "ops"; } catch (Throwable $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/Zend/tests/type_declarations/typed_properties_048.phpt b/Zend/tests/type_declarations/typed_properties_048.phpt index 8a06c55f2360..e432c1afff86 100644 --- a/Zend/tests/type_declarations/typed_properties_048.phpt +++ b/Zend/tests/type_declarations/typed_properties_048.phpt @@ -4,10 +4,10 @@ Parent private property types must be ignored prop; })->call(new B)); diff --git a/Zend/tests/type_declarations/typed_properties_049.phpt b/Zend/tests/type_declarations/typed_properties_049.phpt index e76159054802..ed4f07e4b66d 100644 --- a/Zend/tests/type_declarations/typed_properties_049.phpt +++ b/Zend/tests/type_declarations/typed_properties_049.phpt @@ -3,7 +3,7 @@ Nullable typed property --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/typed_properties_051.phpt b/Zend/tests/type_declarations/typed_properties_051.phpt index 977570b2385c..37972c967b14 100644 --- a/Zend/tests/type_declarations/typed_properties_051.phpt +++ b/Zend/tests/type_declarations/typed_properties_051.phpt @@ -4,12 +4,12 @@ Weak casts must not leak a = new B; var_dump($o->a); try { - $o->a = new C; + $o->a = new C; } catch (Throwable $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/Zend/tests/type_declarations/typed_properties_052.phpt b/Zend/tests/type_declarations/typed_properties_052.phpt index 3a73d7359a03..cf6a6b05a1e2 100644 --- a/Zend/tests/type_declarations/typed_properties_052.phpt +++ b/Zend/tests/type_declarations/typed_properties_052.phpt @@ -5,12 +5,12 @@ Class properties declared in eval() must not leak eval(<<<'EOF' class A { - public A $a1; - public \B $b1; - public Foo\C $c1; - public ?A $a2; - public ?\B $b2; - public ?Foo\C $c2; + public A $a1; + public \B $b1; + public Foo\C $c1; + public ?A $a2; + public ?\B $b2; + public ?Foo\C $c2; } EOF ); diff --git a/Zend/tests/type_declarations/typed_properties_053.phpt b/Zend/tests/type_declarations/typed_properties_053.phpt index 1da42bcbd970..3b347795b325 100644 --- a/Zend/tests/type_declarations/typed_properties_053.phpt +++ b/Zend/tests/type_declarations/typed_properties_053.phpt @@ -3,7 +3,7 @@ Typed properties disallow callable --FILE-- a = new A; diff --git a/Zend/tests/type_declarations/typed_properties_056.phpt b/Zend/tests/type_declarations/typed_properties_056.phpt index 4d2930cc3bca..868594b38adc 100644 --- a/Zend/tests/type_declarations/typed_properties_056.phpt +++ b/Zend/tests/type_declarations/typed_properties_056.phpt @@ -5,15 +5,15 @@ Type change in assign_op (use-after-free) declare(strict_types=1); class A { - public string $foo; + public string $foo; } $o = new A; $o->foo = "1" . str_repeat("0", 2); try { - $o->foo += 5; + $o->foo += 5; } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } var_dump($o->foo); unset($o); diff --git a/Zend/tests/type_declarations/typed_properties_057.phpt b/Zend/tests/type_declarations/typed_properties_057.phpt index ebec0f48bfae..eb565f0c36b4 100644 --- a/Zend/tests/type_declarations/typed_properties_057.phpt +++ b/Zend/tests/type_declarations/typed_properties_057.phpt @@ -5,15 +5,15 @@ Type change in pre/post-increment (use-after-free) declare(strict_types=1); class A { - public string $foo; + public string $foo; } $o = new A; $o->foo = "1" . str_repeat("0", 2); try { - $x = ++$o->foo; + $x = ++$o->foo; } catch (Throwable $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } var_dump($o->foo); try { diff --git a/Zend/tests/type_declarations/typed_properties_058.phpt b/Zend/tests/type_declarations/typed_properties_058.phpt index a6d65daa4c6e..47c75037d163 100644 --- a/Zend/tests/type_declarations/typed_properties_058.phpt +++ b/Zend/tests/type_declarations/typed_properties_058.phpt @@ -7,23 +7,23 @@ declare(strict_types=1); define("FOO", 5); class A { - public int $foo = FOO; + public int $foo = FOO; } class B { - public string $foo = FOO; + public string $foo = FOO; } $o = new A(); var_dump($o->foo); for ($i = 0; $i < 2; $i++) { - try { - $o = new B(); - var_dump($o->foo); - } catch (Throwable $e) { - echo $e->getMessage() . "\n"; - } + try { + $o = new B(); + var_dump($o->foo); + } catch (Throwable $e) { + echo $e->getMessage() . "\n"; + } } ?> --EXPECT-- diff --git a/Zend/tests/type_declarations/typed_properties_059.phpt b/Zend/tests/type_declarations/typed_properties_059.phpt index caee8501f72b..59aaacce600a 100644 --- a/Zend/tests/type_declarations/typed_properties_059.phpt +++ b/Zend/tests/type_declarations/typed_properties_059.phpt @@ -3,14 +3,14 @@ Nullable typed properties in traits --FILE-- foo; - } + function &__get($x) { + return $this->foo; + } - function __set($x, $y) { - echo "set($y)\n"; - } + function __set($x, $y) { + echo "set($y)\n"; + } }; $a->_ += 1; diff --git a/Zend/tests/type_declarations/typed_properties_062.phpt b/Zend/tests/type_declarations/typed_properties_062.phpt index 45f4682806f3..6e1242e9901e 100644 --- a/Zend/tests/type_declarations/typed_properties_062.phpt +++ b/Zend/tests/type_declarations/typed_properties_062.phpt @@ -4,8 +4,8 @@ Typed property on by-ref property _ = &$a->foo; @@ -17,7 +17,7 @@ $a->_ .= "1"; var_dump($a->foo); try { - $a->_ .= "e50"; + $a->_ .= "e50"; } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($a->foo); @@ -30,30 +30,30 @@ var_dump($a->foo); $a->foo = PHP_INT_MIN; try { - $a->_--; + $a->_--; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; try { - --$a->_; + --$a->_; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $a->foo = PHP_INT_MAX; try { - $a->_++; + $a->_++; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; try { - ++$a->_; + ++$a->_; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $a->_ = 0; try { - $a->_ = []; + $a->_ = []; } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($a->foo); diff --git a/Zend/tests/type_declarations/typed_properties_063.phpt b/Zend/tests/type_declarations/typed_properties_063.phpt index bd4cccff22f3..b67e95c24b39 100644 --- a/Zend/tests/type_declarations/typed_properties_063.phpt +++ b/Zend/tests/type_declarations/typed_properties_063.phpt @@ -4,7 +4,7 @@ Typed property on by-ref variable foo; @@ -16,7 +16,7 @@ $_ .= "1"; var_dump($a->foo); try { - $_ .= "e50"; + $_ .= "e50"; } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($a->foo); @@ -29,30 +29,30 @@ var_dump($a->foo); $a->foo = PHP_INT_MIN; try { - $_--; + $_--; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; try { - --$_; + --$_; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $a->foo = PHP_INT_MAX; try { - $_++; + $_++; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; try { - ++$_; + ++$_; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $_ = 0; try { - $_ = []; + $_ = []; } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($a->foo); diff --git a/Zend/tests/type_declarations/typed_properties_064.phpt b/Zend/tests/type_declarations/typed_properties_064.phpt index 59e0552898a8..dd7b5517a7f1 100644 --- a/Zend/tests/type_declarations/typed_properties_064.phpt +++ b/Zend/tests/type_declarations/typed_properties_064.phpt @@ -4,7 +4,7 @@ Typed property on by-ref array value foo]; @@ -16,7 +16,7 @@ $_[0] .= "1"; var_dump($a->foo); try { - $_[0] .= "e50"; + $_[0] .= "e50"; } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($a->foo); @@ -34,25 +34,25 @@ try { echo gettype($a->foo),"\n"; try { - --$_[0]; + --$_[0]; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $a->foo = PHP_INT_MAX; try { - $_[0]++; + $_[0]++; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; try { - ++$_[0]; + ++$_[0]; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $_[0] = 0; try { - $_[0] = []; + $_[0] = []; } catch (Error $e) { echo $e->getMessage(), "\n"; } var_dump($a->foo); diff --git a/Zend/tests/type_declarations/typed_properties_065.phpt b/Zend/tests/type_declarations/typed_properties_065.phpt index da88cbf2cbd4..d81b51d049d6 100644 --- a/Zend/tests/type_declarations/typed_properties_065.phpt +++ b/Zend/tests/type_declarations/typed_properties_065.phpt @@ -4,12 +4,12 @@ Typed property on by-ref array dimension foo; } - function offsetSet($o, $v) { print "offsetSet($v)\n"; } - function offsetUnset($o) { print "offsetUnset() ?!?"; } + function offsetExists($o) { return 1; } + function &offsetGet($o) { return $this->foo; } + function offsetSet($o, $v) { print "offsetSet($v)\n"; } + function offsetUnset($o) { print "offsetUnset() ?!?"; } }; $a[0] += 1; @@ -35,19 +35,19 @@ try { echo gettype($a->foo),"\n"; try { - --$a[0]; + --$a[0]; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; $a->foo = PHP_INT_MAX; try { - $a[0]++; + $a[0]++; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; try { - ++$a[0]; + ++$a[0]; } catch (Error $e) { echo $e->getMessage(), "\n"; } echo gettype($a->foo),"\n"; diff --git a/Zend/tests/type_declarations/typed_properties_066.phpt b/Zend/tests/type_declarations/typed_properties_066.phpt index a91a00df6500..7dc217d2e4c0 100644 --- a/Zend/tests/type_declarations/typed_properties_066.phpt +++ b/Zend/tests/type_declarations/typed_properties_066.phpt @@ -4,7 +4,7 @@ Typed property assignment must not overwrite constants it); diff --git a/Zend/tests/type_declarations/typed_properties_068.phpt b/Zend/tests/type_declarations/typed_properties_068.phpt index dc5cb1b5ffe9..38597559cf04 100644 --- a/Zend/tests/type_declarations/typed_properties_068.phpt +++ b/Zend/tests/type_declarations/typed_properties_068.phpt @@ -3,14 +3,14 @@ Test typed static property by ref --FILE-- getMessage()."\n"; } var_dump($i, Foo::$i); try { - Foo::$i = null; + Foo::$i = null; } catch (TypeError $e) { print $e->getMessage()."\n"; } var_dump($i, Foo::$i); @@ -43,17 +43,17 @@ Foo::$i = &ref("0"); var_dump(Foo::$i, ref()); try { - Foo::$i = &ref("x"); + Foo::$i = &ref("x"); } catch (TypeError $e) { print $e->getMessage()."\n"; } var_dump(Foo::$i, ref()); try { - Foo::$i = &Foo::$s; + Foo::$i = &Foo::$s; } catch (TypeError $e) { print $e->getMessage()."\n"; } var_dump(Foo::$i, Foo::$s); try { - Foo::$s = &Foo::$i; + Foo::$s = &Foo::$i; } catch (TypeError $e) { print $e->getMessage()."\n"; } var_dump(Foo::$i, Foo::$s); diff --git a/Zend/tests/type_declarations/typed_properties_069.phpt b/Zend/tests/type_declarations/typed_properties_069.phpt index 0f804f8f06f6..7d84407102d9 100644 --- a/Zend/tests/type_declarations/typed_properties_069.phpt +++ b/Zend/tests/type_declarations/typed_properties_069.phpt @@ -4,19 +4,19 @@ Test assign of invalid string to typed static int property getMessage()."\n"; } try { - var_dump(Foo::$i); + var_dump(Foo::$i); } catch (Error $e) { print $e->getMessage()."\n"; } var_dump(nonNumericStringRef()); diff --git a/Zend/tests/type_declarations/typed_properties_070.phpt b/Zend/tests/type_declarations/typed_properties_070.phpt index ec2d6bf8c69f..d039fca3b143 100644 --- a/Zend/tests/type_declarations/typed_properties_070.phpt +++ b/Zend/tests/type_declarations/typed_properties_070.phpt @@ -3,15 +3,15 @@ Test typed static property with assign op operators --FILE-- getMessage()."\n"; } var_dump(Foo::$i); try { - Foo::$i .= PHP_INT_MAX; + Foo::$i .= PHP_INT_MAX; } catch (TypeError $e) { print $e->getMessage()."\n"; } var_dump(Foo::$i); diff --git a/Zend/tests/type_declarations/typed_properties_071.phpt b/Zend/tests/type_declarations/typed_properties_071.phpt index 4d0451cf73f7..d45abcd4ca59 100644 --- a/Zend/tests/type_declarations/typed_properties_071.phpt +++ b/Zend/tests/type_declarations/typed_properties_071.phpt @@ -2,7 +2,7 @@ Test assignment to typed reference with weak type conversion --FILE-- prop; - } + public function &__get($name) { + return $this->prop; + } } $test = new Test; diff --git a/Zend/tests/type_declarations/typed_properties_074.phpt b/Zend/tests/type_declarations/typed_properties_074.phpt index 57595057074a..f13398d9d7bb 100644 --- a/Zend/tests/type_declarations/typed_properties_074.phpt +++ b/Zend/tests/type_declarations/typed_properties_074.phpt @@ -2,14 +2,14 @@ Typed property must be compatible when returned via &__get() --FILE-- prop; - } + public function &__get($name) { + return $this->prop; + } } $test = new Test; @@ -17,7 +17,7 @@ $dummyRef = &$test->prop; unset($test->val); var_dump($test); try { - var_dump($test->val); + var_dump($test->val); } catch (TypeError $e) { print $e->getMessage()."\n"; } var_dump($test); diff --git a/Zend/tests/type_declarations/typed_properties_075.phpt b/Zend/tests/type_declarations/typed_properties_075.phpt index def86f369516..42e74ebce441 100644 --- a/Zend/tests/type_declarations/typed_properties_075.phpt +++ b/Zend/tests/type_declarations/typed_properties_075.phpt @@ -6,37 +6,37 @@ Test typed properties overflowing getMessage()); + var_dump($t->getMessage()); } var_dump(Foo::$bar); try { - Foo::$bar += 1; + Foo::$bar += 1; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump(Foo::$bar); try { - ++Foo::$bar; + ++Foo::$bar; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump(Foo::$bar); try { - Foo::$bar = Foo::$bar + 1; + Foo::$bar = Foo::$bar + 1; } catch(TypeError $t) { - var_dump($t->getMessage()); + var_dump($t->getMessage()); } var_dump(Foo::$bar); diff --git a/Zend/tests/type_declarations/typed_properties_078.phpt b/Zend/tests/type_declarations/typed_properties_078.phpt index d8fc67d466f7..c92ed5afc4b1 100644 --- a/Zend/tests/type_declarations/typed_properties_078.phpt +++ b/Zend/tests/type_declarations/typed_properties_078.phpt @@ -4,9 +4,9 @@ Typed references must be kept track of and always be only the intersection of th it; @@ -15,7 +15,7 @@ $a->a = &$ref; var_dump($ref); try { - $a->t = &$ref; + $a->t = &$ref; } catch (TypeError $e) { var_dump($e->getMessage()); } var_dump($ref); @@ -23,7 +23,7 @@ $a->it = [1]; // type is still assignable var_dump($ref); try { - $ref = new ArrayIterator(); + $ref = new ArrayIterator(); } catch (TypeError $e) { var_dump($e->getMessage()); } var_dump($ref instanceof ArrayIterator); @@ -34,7 +34,7 @@ $ref = null; $a->t = &$ref; try { - $ref = []; + $ref = []; } catch (TypeError $e) { var_dump($e->getMessage()); } var_dump($ref instanceof ArrayIterator); diff --git a/Zend/tests/type_declarations/typed_properties_079.phpt b/Zend/tests/type_declarations/typed_properties_079.phpt index 85ed6fc75d4c..d189cec6d4ce 100644 --- a/Zend/tests/type_declarations/typed_properties_079.phpt +++ b/Zend/tests/type_declarations/typed_properties_079.phpt @@ -4,14 +4,14 @@ Test static typed properties with references getMessage()); } var_dump(A::$it); @@ -20,7 +20,7 @@ A::$a = &$a; A::$it = new ArrayIterator(); try { - $a = 1; + $a = 1; } catch (TypeError $e) { var_dump($e->getMessage()); } var_dump($a); diff --git a/Zend/tests/type_declarations/typed_properties_081.phpt b/Zend/tests/type_declarations/typed_properties_081.phpt index 4f49eae4e76c..f6d2114c6f25 100644 --- a/Zend/tests/type_declarations/typed_properties_081.phpt +++ b/Zend/tests/type_declarations/typed_properties_081.phpt @@ -12,7 +12,7 @@ $x =& $test->x; $test2 = clone $test; unset($test); try { - $x = "foo"; + $x = "foo"; } catch (TypeError $e) { echo $e->getMessage(), "\n"; } var_dump($test2->x); diff --git a/Zend/tests/type_declarations/typed_properties_082.phpt b/Zend/tests/type_declarations/typed_properties_082.phpt index 1e4e62e89b43..d212f1852cbf 100644 --- a/Zend/tests/type_declarations/typed_properties_082.phpt +++ b/Zend/tests/type_declarations/typed_properties_082.phpt @@ -4,16 +4,16 @@ Test typed references to static properties getMessage(), "\n"; } var_dump($x, Test::$x); diff --git a/Zend/tests/type_declarations/typed_properties_084.phpt b/Zend/tests/type_declarations/typed_properties_084.phpt index fb3c86115eee..f83be01d53ee 100644 --- a/Zend/tests/type_declarations/typed_properties_084.phpt +++ b/Zend/tests/type_declarations/typed_properties_084.phpt @@ -6,7 +6,7 @@ eval(<<<'PHP' class Foo {} class_alias('Foo', 'Bar'); PHP); - + eval(<<<'PHP' class A { public Foo $prop; diff --git a/Zend/tests/type_declarations/typed_properties_086.phpt b/Zend/tests/type_declarations/typed_properties_086.phpt index c58eb7898efe..7c160dd9d054 100644 --- a/Zend/tests/type_declarations/typed_properties_086.phpt +++ b/Zend/tests/type_declarations/typed_properties_086.phpt @@ -4,9 +4,9 @@ Test typed properties with integer keys prop = "dont "; - $a->prop .= "leak "; - $a->prop .= "me!"; - return "test"; - } + public function __toString() { + global $a; + $a->prop = "dont "; + $a->prop .= "leak "; + $a->prop .= "me!"; + return "test"; + } } $a = new A; diff --git a/Zend/tests/type_declarations/typed_properties_090.phpt b/Zend/tests/type_declarations/typed_properties_090.phpt index 3b75aaa8433d..97bd2ed5239e 100644 --- a/Zend/tests/type_declarations/typed_properties_090.phpt +++ b/Zend/tests/type_declarations/typed_properties_090.phpt @@ -4,17 +4,17 @@ Unsetting typed properties containing a reference must respect shadowing prop; - unset($this->prop); - $x = "foo"; - var_dump($x); - } + public function test() { + $x =& $this->prop; + unset($this->prop); + $x = "foo"; + var_dump($x); + } } class B extends A { - private $prop; + private $prop; } $b = new B; diff --git a/Zend/tests/type_declarations/typed_properties_100.phpt b/Zend/tests/type_declarations/typed_properties_100.phpt index 8ee3deb0f7eb..675b79a7df52 100644 --- a/Zend/tests/type_declarations/typed_properties_100.phpt +++ b/Zend/tests/type_declarations/typed_properties_100.phpt @@ -2,7 +2,7 @@ Property type not enforced for __get if the property is not visible --FILE-- a; try { - $ret = ++$x + 5; + $ret = ++$x + 5; } catch (TypeError $e) { } ?> diff --git a/Zend/tests/type_declarations/types_in_ast.phpt b/Zend/tests/type_declarations/types_in_ast.phpt index 54619c23b712..2e2fd212c717 100644 --- a/Zend/tests/type_declarations/types_in_ast.phpt +++ b/Zend/tests/type_declarations/types_in_ast.phpt @@ -6,11 +6,11 @@ assert.exception=0 --FILE-- --EXPECTF-- diff --git a/Zend/tests/type_declarations/union_types/multiple_classes.phpt b/Zend/tests/type_declarations/union_types/multiple_classes.phpt index aac56c6603f6..72d2e6c291f7 100644 --- a/Zend/tests/type_declarations/union_types/multiple_classes.phpt +++ b/Zend/tests/type_declarations/union_types/multiple_classes.phpt @@ -17,7 +17,7 @@ spl_autoload_register(function($class) { $test = new Test; -$test->prop = 42; +$test->prop = 42; var_dump($test->prop); var_dump($test->method(42)); diff --git a/Zend/tests/type_declarations/union_types/variance/invalid_004.phpt b/Zend/tests/type_declarations/union_types/variance/invalid_004.phpt index db16fecbac45..3bcb6f9f5519 100644 --- a/Zend/tests/type_declarations/union_types/variance/invalid_004.phpt +++ b/Zend/tests/type_declarations/union_types/variance/invalid_004.phpt @@ -7,7 +7,7 @@ class A { } class B extends A { public B $prop; -} +} ?> --EXPECTF-- Fatal error: Type of B::$prop must be X|B (as in class A) in %s on line %d diff --git a/Zend/tests/typehints/bug76198.phpt b/Zend/tests/typehints/bug76198.phpt index fcaefbbec393..8d71d02461b9 100644 --- a/Zend/tests/typehints/bug76198.phpt +++ b/Zend/tests/typehints/bug76198.phpt @@ -4,7 +4,7 @@ diff --git a/Zend/tests/variadic/optional_params.phpt b/Zend/tests/variadic/optional_params.phpt index ba800032d7bb..2c93d67151f0 100644 --- a/Zend/tests/variadic/optional_params.phpt +++ b/Zend/tests/variadic/optional_params.phpt @@ -6,7 +6,7 @@ Optional parameter before variadic parameter function f($reqParam, $optParam = null, ...$params) { var_dump($reqParam, $optParam, $params); } - + f(1); f(1, 2); f(1, 2, 3); diff --git a/Zend/tests/variadic/typehint_suppressed_error.phpt b/Zend/tests/variadic/typehint_suppressed_error.phpt index ebc44c38b12b..e7906ea2f2f6 100644 --- a/Zend/tests/variadic/typehint_suppressed_error.phpt +++ b/Zend/tests/variadic/typehint_suppressed_error.phpt @@ -8,9 +8,9 @@ function test(array... $args) { } try { - test([0], [1], 2); + test([0], [1], 2); } catch(Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/Zend/tests/vm_stack_with_arg_extend.phpt b/Zend/tests/vm_stack_with_arg_extend.phpt index 10f3639d21f5..49f1f5b5c18a 100644 --- a/Zend/tests/vm_stack_with_arg_extend.phpt +++ b/Zend/tests/vm_stack_with_arg_extend.phpt @@ -4,12 +4,12 @@ Ensure valid vm_stack even when it needed to be copied to a new page valid(); ?> diff --git a/Zend/tests/weakrefs/weakrefs_002.phpt b/Zend/tests/weakrefs/weakrefs_002.phpt index a2e277f98d54..f550302aeca5 100644 --- a/Zend/tests/weakrefs/weakrefs_002.phpt +++ b/Zend/tests/weakrefs/weakrefs_002.phpt @@ -5,9 +5,9 @@ WeakReference serials $wr = WeakReference::create(new stdClass); try { - serialize($wr); + serialize($wr); } catch (Exception $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } $wrs = 'O:13:"WeakReference":0:{}'; diff --git a/Zend/tests/weakrefs/weakrefs_003.phpt b/Zend/tests/weakrefs/weakrefs_003.phpt index e7d8e281c5a2..66dc93237216 100644 --- a/Zend/tests/weakrefs/weakrefs_003.phpt +++ b/Zend/tests/weakrefs/weakrefs_003.phpt @@ -5,33 +5,33 @@ WeakReference object handlers $wr = WeakReference::create(new stdClass); try { - $wr->disallow; + $wr->disallow; } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } try { - $wr->disallow = "writes"; + $wr->disallow = "writes"; } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } try { - isset($wr->disallow); + isset($wr->disallow); } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } try { - unset($wr->disallow); + unset($wr->disallow); } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } try { - $disallow = &$wr->disallowed; + $disallow = &$wr->disallowed; } catch (Error $ex) { - var_dump($ex->getMessage()); + var_dump($ex->getMessage()); } ?> --EXPECT-- diff --git a/Zend/tests/zend_signed_multiply-64bit-2.phpt b/Zend/tests/zend_signed_multiply-64bit-2.phpt index aa8ee47db6cf..ff0e88a78dc4 100644 --- a/Zend/tests/zend_signed_multiply-64bit-2.phpt +++ b/Zend/tests/zend_signed_multiply-64bit-2.phpt @@ -6,11 +6,11 @@ Zend signed multiply 64-bit, variation 2 --EXPECT-- diff --git a/ext/bz2/tests/bug71263.phpt b/ext/bz2/tests/bug71263.phpt index d5c3ff91dae9..108469a2930e 100644 --- a/ext/bz2/tests/bug71263.phpt +++ b/ext/bz2/tests/bug71263.phpt @@ -8,11 +8,11 @@ Bug #71263: fread() does not detects decoding errors from filter bzip2.decompres // Should notices be generated? function test($case) { - $plain = "The quick brown fox jumps over the lazy dog."; - $fn = "bug71263.bz2"; - $compressed = (string) bzcompress($plain); - echo "Compressed len = ", strlen($compressed), "\n"; - + $plain = "The quick brown fox jumps over the lazy dog."; + $fn = "bug71263.bz2"; + $compressed = (string) bzcompress($plain); + echo "Compressed len = ", strlen($compressed), "\n"; + if ($case == 1) { // Set a random byte in the middle of the compressed data // --> php_bz2_decompress_filter() detects fatal error @@ -22,24 +22,24 @@ function test($case) { // Truncate the compressed data // --> php_bz2_decompress_filter() does not detect errors, // --> fread() displays the empty string: - $compressed = substr($compressed, 0, strlen($compressed) - 20); + $compressed = substr($compressed, 0, strlen($compressed) - 20); } else { // Corrupted final CRC // --> php_bz2_decompress_filter() detects fatal error // --> fread() displays an empty string, then the correct plain text, no error detected: - $compressed[strlen($compressed)-2] = 'X'; + $compressed[strlen($compressed)-2] = 'X'; } - file_put_contents($fn, $compressed); - - $r = fopen($fn, "r"); - stream_filter_append($r, 'bzip2.decompress', STREAM_FILTER_READ); + file_put_contents($fn, $compressed); + + $r = fopen($fn, "r"); + stream_filter_append($r, 'bzip2.decompress', STREAM_FILTER_READ); while (!feof($r)) { $s = fread($r, 100); echo "read: "; var_dump($s); } - fclose($r); - unlink($fn); + fclose($r); + unlink($fn); } test(1); diff --git a/ext/calendar/tests/jdtogregorian_overflow.phpt b/ext/calendar/tests/jdtogregorian_overflow.phpt index 28f5298e19b3..9d4a1d6b4dfc 100644 --- a/ext/calendar/tests/jdtogregorian_overflow.phpt +++ b/ext/calendar/tests/jdtogregorian_overflow.phpt @@ -10,7 +10,7 @@ if (PHP_INT_SIZE != 4) die('skip this test is for 32bit platforms only'); --FILE-- diff --git a/ext/calendar/tests/jdtojewish.phpt b/ext/calendar/tests/jdtojewish.phpt index 84f95654300c..4fd104c50c92 100644 --- a/ext/calendar/tests/jdtojewish.phpt +++ b/ext/calendar/tests/jdtojewish.phpt @@ -6,24 +6,24 @@ jdtojewish() function getMessage()}\n"; + echo "{$ex->getMessage()}\n"; } ?> --EXPECTF-- diff --git a/ext/calendar/tests/jdtojewish_overflow.phpt b/ext/calendar/tests/jdtojewish_overflow.phpt index 1d1c2eefb911..17a47e06e1e8 100644 --- a/ext/calendar/tests/jdtojewish_overflow.phpt +++ b/ext/calendar/tests/jdtojewish_overflow.phpt @@ -9,7 +9,7 @@ if (!extension_loaded('calendar')) die('skip ext/calendar required'); --FILE-- diff --git a/ext/calendar/tests/jdtomonthname.phpt b/ext/calendar/tests/jdtomonthname.phpt index c7fa6cc77403..004c219bf9c6 100644 --- a/ext/calendar/tests/jdtomonthname.phpt +++ b/ext/calendar/tests/jdtomonthname.phpt @@ -13,14 +13,14 @@ $jd_days = Array( ); foreach ($jd_days as $jd_day) { - echo "=== ", $jd_day, "\n"; + echo "=== ", $jd_day, "\n"; var_dump(jdmonthname($jd_day,0)); var_dump(jdmonthname($jd_day,1)); var_dump(jdmonthname($jd_day,2)); var_dump(jdmonthname($jd_day,3)); var_dump(jdmonthname($jd_day,4)); var_dump(jdmonthname($jd_day,5)); - echo "\n"; + echo "\n"; } echo "Done\n"; diff --git a/ext/calendar/tests/skipif.inc b/ext/calendar/tests/skipif.inc index 71cdc7363086..e867fafd295c 100644 --- a/ext/calendar/tests/skipif.inc +++ b/ext/calendar/tests/skipif.inc @@ -1,4 +1,4 @@ diff --git a/ext/calendar/tests/unixtojd.phpt b/ext/calendar/tests/unixtojd.phpt index 01b3773007e9..28a05c0c6ff3 100644 --- a/ext/calendar/tests/unixtojd.phpt +++ b/ext/calendar/tests/unixtojd.phpt @@ -13,7 +13,7 @@ putenv('TZ=UTC'); // -adding a call direct to GetEnvironmentVariableA just before tzset() is called to check the value of 'TZ' returns 'UTC' // putting a call to date_default_timezone_set() here doesn't help // -// on Windows, the only thing that gets this test to pass is to put TZ=UTC in --ENV-- section +// on Windows, the only thing that gets this test to pass is to put TZ=UTC in--ENV-- section // -since putenv() is written to call tzset() when env var is TZ, I assume that putenv("TZ=UTC") is intended to work // and should work on all platforms(including Windows). // easter_date.phpt passes diff --git a/ext/com_dotnet/tests/27974.phpt b/ext/com_dotnet/tests/27974.phpt index 960a63030411..c76dda9ed568 100644 --- a/ext/com_dotnet/tests/27974.phpt +++ b/ext/com_dotnet/tests/27974.phpt @@ -8,26 +8,26 @@ if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; error_reporting(E_ALL); try { - $v = new VARIANT(array("123", "456", "789")); - var_dump($v); - print $v[0] . "\n"; - print $v[1] . "\n"; - print $v[2] . "\n"; - $v[1] = "hello"; - foreach ($v as $item) { - var_dump($item); - } - try { - $v[3] = "shouldn't work"; - } catch (com_exception $e) { - if ($e->getCode() != DISP_E_BADINDEX) { - throw $e; - } - echo "Got BADINDEX exception OK!\n"; - } - echo "OK!"; + $v = new VARIANT(array("123", "456", "789")); + var_dump($v); + print $v[0] . "\n"; + print $v[1] . "\n"; + print $v[2] . "\n"; + $v[1] = "hello"; + foreach ($v as $item) { + var_dump($item); + } + try { + $v[3] = "shouldn't work"; + } catch (com_exception $e) { + if ($e->getCode() != DISP_E_BADINDEX) { + throw $e; + } + echo "Got BADINDEX exception OK!\n"; + } + echo "OK!"; } catch (Exception $e) { - print $e; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt index 102e69749b5f..7f305d2eb57f 100644 --- a/ext/com_dotnet/tests/bug33386.phpt +++ b/ext/com_dotnet/tests/bug33386.phpt @@ -15,22 +15,22 @@ class twoFuncs { } try { - $ciTF = new twoFuncs; + $ciTF = new twoFuncs; - $oScript = new COM("MSScriptControl.ScriptControl"); - $oScript->Language = "VBScript"; + $oScript = new COM("MSScriptControl.ScriptControl"); + $oScript->Language = "VBScript"; - $oScript->AddObject ("tfA", $ciTF, true); - foreach (array(1,2) as $i) { - $oScript->ExecuteStatement ("tfA.func$i"); - $oScript->ExecuteStatement ("func$i"); - } - $oScript->AddObject ("tfB", $ciTF); - foreach (array(1,2) as $i) { - $oScript->ExecuteStatement ("tfB.func$i"); - } + $oScript->AddObject ("tfA", $ciTF, true); + foreach (array(1,2) as $i) { + $oScript->ExecuteStatement ("tfA.func$i"); + $oScript->ExecuteStatement ("func$i"); + } + $oScript->AddObject ("tfB", $ciTF); + foreach (array(1,2) as $i) { + $oScript->ExecuteStatement ("tfB.func$i"); + } } catch (Exception $e) { - print $e; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug34272.phpt b/ext/com_dotnet/tests/bug34272.phpt index feb63c93c359..ce8a552dfd91 100644 --- a/ext/com_dotnet/tests/bug34272.phpt +++ b/ext/com_dotnet/tests/bug34272.phpt @@ -8,13 +8,13 @@ if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; error_reporting(E_ALL); try { - $dict = new COM("Scripting.Dictionary"); - $dict->add('foo', array()); - print sizeof($dict['foo'])."\n"; - $dict->add('bar', array(23)); - print sizeof($dict['bar'])." \n"; + $dict = new COM("Scripting.Dictionary"); + $dict->add('foo', array()); + print sizeof($dict['foo'])."\n"; + $dict->add('bar', array(23)); + print sizeof($dict['bar'])." \n"; } catch (Exception $e) { - print $e; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug39596.phpt b/ext/com_dotnet/tests/bug39596.phpt index bd8932656054..1510db49cf45 100644 --- a/ext/com_dotnet/tests/bug39596.phpt +++ b/ext/com_dotnet/tests/bug39596.phpt @@ -8,13 +8,13 @@ if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; error_reporting(E_ALL); try { - $binding_string = array('aaa','bbb','ccc'); - $v = new VARIANT( $binding_string, VT_ARRAY ); - foreach ($v AS $element) { - print $element."\n"; - } + $binding_string = array('aaa','bbb','ccc'); + $v = new VARIANT( $binding_string, VT_ARRAY ); + foreach ($v AS $element) { + print $element."\n"; + } } catch (Exception $e) { - print $e; + print $e; } ?> --EXPECT-- diff --git a/ext/com_dotnet/tests/bug66431_0.phpt b/ext/com_dotnet/tests/bug66431_0.phpt index b9759f51c016..4a0062a7e13c 100644 --- a/ext/com_dotnet/tests/bug66431_0.phpt +++ b/ext/com_dotnet/tests/bug66431_0.phpt @@ -22,8 +22,8 @@ $result = ($check_text == $text); var_dump($result); if (!$result) { - echo "Expected: '$check_text'\n"; - echo "Have: '$text'\n"; + echo "Expected: '$check_text'\n"; + echo "Have: '$text'\n"; } ?> diff --git a/ext/com_dotnet/tests/bug66431_1.phpt b/ext/com_dotnet/tests/bug66431_1.phpt index 1dc208f29050..e99131d27b1e 100644 --- a/ext/com_dotnet/tests/bug66431_1.phpt +++ b/ext/com_dotnet/tests/bug66431_1.phpt @@ -40,8 +40,8 @@ $result = (trim($check_text) == $text); var_dump($result); if (!$result) { - echo "Expected: '$check_text'\n"; - echo "Have: '$text'\n"; + echo "Expected: '$check_text'\n"; + echo "Have: '$text'\n"; } ?> diff --git a/ext/com_dotnet/tests/variants.phpt b/ext/com_dotnet/tests/variants.phpt index a99e8966802a..0bcd473f610e 100644 --- a/ext/com_dotnet/tests/variants.phpt +++ b/ext/com_dotnet/tests/variants.phpt @@ -10,34 +10,34 @@ error_reporting(E_ALL); $v = new VARIANT(); if (VT_EMPTY != variant_get_type($v)) { - echo "VT_EMPTY: bork\n"; + echo "VT_EMPTY: bork\n"; } $values = array(VT_I4 => 42, VT_R8 => 3.5, VT_BSTR => "hello", VT_BOOL => false); $binary_ops = array('add', 'cat', 'sub', 'mul', 'and', 'div', - 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor'); + 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor'); foreach ($values as $t => $val) { - $v = new VARIANT($val); - if ($t != variant_get_type($v)) { - printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val); - print $v . "\n"; - } - $results = array(); - - foreach ($values as $op2) { - echo "--\n"; - foreach ($binary_ops as $op) { - try { - echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n"; - } catch (com_exception $e) { - echo "$op:\n"; - echo "\tvariant_$op($v, $op2)\n"; - echo "\texception " . $e->getMessage(); - printf("\tcode %08x\n\n", $e->getCode()); - } - } - } + $v = new VARIANT($val); + if ($t != variant_get_type($v)) { + printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val); + print $v . "\n"; + } + $results = array(); + + foreach ($values as $op2) { + echo "--\n"; + foreach ($binary_ops as $op) { + try { + echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n"; + } catch (com_exception $e) { + echo "$op:\n"; + echo "\tvariant_$op($v, $op2)\n"; + echo "\texception " . $e->getMessage(); + printf("\tcode %08x\n\n", $e->getCode()); + } + } + } } echo "OK!"; diff --git a/ext/com_dotnet/tests/variants_x64.phpt b/ext/com_dotnet/tests/variants_x64.phpt index e9e7c23b9765..88f9f3e12616 100644 --- a/ext/com_dotnet/tests/variants_x64.phpt +++ b/ext/com_dotnet/tests/variants_x64.phpt @@ -13,34 +13,34 @@ error_reporting(E_ALL); $v = new VARIANT(); if (VT_EMPTY != variant_get_type($v)) { - echo "VT_EMPTY: bork\n"; + echo "VT_EMPTY: bork\n"; } $values = array(VT_I8 => 42, VT_R8 => 3.5, VT_BSTR => "hello", VT_BOOL => false); $binary_ops = array('add', 'cat', 'sub', 'mul', 'and', 'div', - 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor'); + 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor'); foreach ($values as $t => $val) { - $v = new VARIANT($val); - if ($t != variant_get_type($v)) { - printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val); - print $v . "\n"; - } - $results = array(); - - foreach ($values as $op2) { - echo "--\n"; - foreach ($binary_ops as $op) { - try { - echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n"; - } catch (com_exception $e) { - echo "$op:\n"; - echo "\tvariant_$op($v, $op2)\n"; - echo "\texception " . $e->getMessage(); - printf("\tcode %08x\n\n", $e->getCode()); - } - } - } + $v = new VARIANT($val); + if ($t != variant_get_type($v)) { + printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val); + print $v . "\n"; + } + $results = array(); + + foreach ($values as $op2) { + echo "--\n"; + foreach ($binary_ops as $op) { + try { + echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n"; + } catch (com_exception $e) { + echo "$op:\n"; + echo "\tvariant_$op($v, $op2)\n"; + echo "\texception " . $e->getMessage(); + printf("\tcode %08x\n\n", $e->getCode()); + } + } + } } echo "OK!"; diff --git a/ext/ctype/tests/001.phpt b/ext/ctype/tests/001.phpt index edb1f52ab09d..1351faed9433 100644 --- a/ext/ctype/tests/001.phpt +++ b/ext/ctype/tests/001.phpt @@ -9,9 +9,9 @@ ctype on integers function ctype_test_001($function) { $n=0; for($a=0;$a<256;$a++) { - if($function($a)) $n++; + if($function($a)) $n++; } - echo "$function $n\n"; + echo "$function $n\n"; } ctype_test_001("ctype_lower"); ctype_test_001("ctype_upper"); diff --git a/ext/ctype/tests/002.phpt b/ext/ctype/tests/002.phpt index e949db39924f..b1dd87f306c7 100644 --- a/ext/ctype/tests/002.phpt +++ b/ext/ctype/tests/002.phpt @@ -9,15 +9,15 @@ setlocale(LC_ALL,"C"); print "LOCALE is '" . setlocale(LC_ALL,0) . "'\n"; function ctype_test_002($function) { - $n1 = $n2 = $n3 = 0; - // test portable POSIX characters 0..127 - for ($a=0;$a<128;$a++) { - $c = chr($a); - if($function($a)) $n1++; - if($function("$c$c$c")) $n2++; - if($function("1-$c$c$c-x")) $n3++; - } - print "$function $n1 $n2 $n3\n"; + $n1 = $n2 = $n3 = 0; + // test portable POSIX characters 0..127 + for ($a=0;$a<128;$a++) { + $c = chr($a); + if($function($a)) $n1++; + if($function("$c$c$c")) $n2++; + if($function("1-$c$c$c-x")) $n3++; + } + print "$function $n1 $n2 $n3\n"; } ctype_test_002("ctype_lower"); diff --git a/ext/ctype/tests/bug25745.phpt b/ext/ctype/tests/bug25745.phpt index ecacebbed6dc..3996dd8242cf 100644 --- a/ext/ctype/tests/bug25745.phpt +++ b/ext/ctype/tests/bug25745.phpt @@ -5,20 +5,20 @@ Bug #25745 (ctype functions fail with non-ascii characters) --FILE-- diff --git a/ext/ctype/tests/ctype_alnum_variation2.phpt b/ext/ctype/tests/ctype_alnum_variation2.phpt index 625c5a6d89a9..0898190d1778 100644 --- a/ext/ctype/tests/ctype_alnum_variation2.phpt +++ b/ext/ctype/tests/ctype_alnum_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_alnum() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_alnum($i)) { - echo "character code $i is alpha numeric\n"; - } + if (ctype_alnum($i)) { + echo "character code $i is alpha numeric\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_alnum_variation4.phpt b/ext/ctype/tests/ctype_alnum_variation4.phpt index 1b5bcb93ce9c..64c6175806f9 100644 --- a/ext/ctype/tests/ctype_alnum_variation4.phpt +++ b/ext/ctype/tests/ctype_alnum_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array(0x30, 0x31, 0x32, 0x33); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_alnum($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alnum($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_alnum($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alnum($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_alpha_variation1.phpt b/ext/ctype/tests/ctype_alpha_variation1.phpt index d2124975133b..e96256df98df 100644 --- a/ext/ctype/tests/ctype_alpha_variation1.phpt +++ b/ext/ctype/tests/ctype_alpha_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "abcdef"; - } + public function __toString() { + return "abcdef"; + } } // heredoc string diff --git a/ext/ctype/tests/ctype_alpha_variation2.phpt b/ext/ctype/tests/ctype_alpha_variation2.phpt index d9c1fa361a43..89777f9813b5 100644 --- a/ext/ctype/tests/ctype_alpha_variation2.phpt +++ b/ext/ctype/tests/ctype_alpha_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_alpha() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_alpha($i)) { - echo "character code $i is alphabetic\n"; - } + if (ctype_alpha($i)) { + echo "character code $i is alphabetic\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_alpha_variation4.phpt b/ext/ctype/tests/ctype_alpha_variation4.phpt index fc3cecd21be5..ba801c68456c 100644 --- a/ext/ctype/tests/ctype_alpha_variation4.phpt +++ b/ext/ctype/tests/ctype_alpha_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array (0x41, 0x42, 0x43, 0x44); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_alpha($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alpha($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_alpha($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_alpha($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_cntrl_variation2.phpt b/ext/ctype/tests/ctype_cntrl_variation2.phpt index 2a5caecca909..411666608fb2 100644 --- a/ext/ctype/tests/ctype_cntrl_variation2.phpt +++ b/ext/ctype/tests/ctype_cntrl_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_cntrl() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_cntrl($i)) { - echo "character code $i is control character\n"; - } + if (ctype_cntrl($i)) { + echo "character code $i is control character\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_cntrl_variation4.phpt b/ext/ctype/tests/ctype_cntrl_variation4.phpt index 0ec3e8f4f680..0a2e1260df95 100644 --- a/ext/ctype/tests/ctype_cntrl_variation4.phpt +++ b/ext/ctype/tests/ctype_cntrl_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array(0x1, 0x2, 0x3, 0x4); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_cntrl($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_cntrl($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_cntrl($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_cntrl($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); ?> diff --git a/ext/ctype/tests/ctype_digit_variation1.phpt b/ext/ctype/tests/ctype_digit_variation1.phpt index 8cb85ab56024..77ddc21ce402 100644 --- a/ext/ctype/tests/ctype_digit_variation1.phpt +++ b/ext/ctype/tests/ctype_digit_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "123456"; - } + public function __toString() { + return "123456"; + } } // heredoc string diff --git a/ext/ctype/tests/ctype_digit_variation2.phpt b/ext/ctype/tests/ctype_digit_variation2.phpt index cebdcd062fbb..9b5c1fb6791c 100644 --- a/ext/ctype/tests/ctype_digit_variation2.phpt +++ b/ext/ctype/tests/ctype_digit_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_digit() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_digit($i)) { - echo "character code $i is a numeric digit\n"; - } + if (ctype_digit($i)) { + echo "character code $i is a numeric digit\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_digit_variation4.phpt b/ext/ctype/tests/ctype_digit_variation4.phpt index ca89d1641f19..2c87759dddcc 100644 --- a/ext/ctype/tests/ctype_digit_variation4.phpt +++ b/ext/ctype/tests/ctype_digit_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array (0x31, 0x32, 0x33, 0x34); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_digit($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_digit($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_digit($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_digit($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_graph_variation1.phpt b/ext/ctype/tests/ctype_graph_variation1.phpt index 097c247a228a..2fb529ee88c1 100644 --- a/ext/ctype/tests/ctype_graph_variation1.phpt +++ b/ext/ctype/tests/ctype_graph_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "myClass"; - } + public function __toString() { + return "myClass"; + } } // heredoc string diff --git a/ext/ctype/tests/ctype_graph_variation2.phpt b/ext/ctype/tests/ctype_graph_variation2.phpt index 731e3ad9ac7d..3c21133279a4 100644 --- a/ext/ctype/tests/ctype_graph_variation2.phpt +++ b/ext/ctype/tests/ctype_graph_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_graph() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_graph($i)) { - echo "character code $i is a printable character\n"; - } + if (ctype_graph($i)) { + echo "character code $i is a printable character\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_graph_variation4.phpt b/ext/ctype/tests/ctype_graph_variation4.phpt index a60ee0c70d51..3b3b028002d4 100644 --- a/ext/ctype/tests/ctype_graph_variation4.phpt +++ b/ext/ctype/tests/ctype_graph_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array (0x31, 0x32, 0x33, 0x34); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_graph($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_graph($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_graph($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_graph($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_lower_variation1.phpt b/ext/ctype/tests/ctype_lower_variation1.phpt index 919995dfe4c0..94ff0f16545d 100644 --- a/ext/ctype/tests/ctype_lower_variation1.phpt +++ b/ext/ctype/tests/ctype_lower_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "class"; - } + public function __toString() { + return "class"; + } } // heredoc string @@ -89,9 +89,9 @@ $inputs = array( // loop through each element of $inputs to check the behavior of ctype_lower() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( ctype_lower($input) ); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_lower($input) ); + $iterator++; }; fclose($fp); diff --git a/ext/ctype/tests/ctype_lower_variation2.phpt b/ext/ctype/tests/ctype_lower_variation2.phpt index b225eafaff17..ca96134b88a1 100644 --- a/ext/ctype/tests/ctype_lower_variation2.phpt +++ b/ext/ctype/tests/ctype_lower_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_lower() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_lower($i)) { - echo "character code $i is a lower case character\n"; - } + if (ctype_lower($i)) { + echo "character code $i is a lower case character\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_lower_variation4.phpt b/ext/ctype/tests/ctype_lower_variation4.phpt index 8571ff033c00..a47074ed20cc 100644 --- a/ext/ctype/tests/ctype_lower_variation4.phpt +++ b/ext/ctype/tests/ctype_lower_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array (0x61, 0x62, 0x63, 0x64); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_lower($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_lower($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_lower($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_lower($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_print_variation1.phpt b/ext/ctype/tests/ctype_print_variation1.phpt index 2ce20bea8773..3e4bef3e539f 100644 --- a/ext/ctype/tests/ctype_print_variation1.phpt +++ b/ext/ctype/tests/ctype_print_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } // heredoc string diff --git a/ext/ctype/tests/ctype_print_variation2.phpt b/ext/ctype/tests/ctype_print_variation2.phpt index 8f2eb47b211b..c2151fa34c05 100644 --- a/ext/ctype/tests/ctype_print_variation2.phpt +++ b/ext/ctype/tests/ctype_print_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_print() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_print($i)) { - echo "character code $i is a printable character\n"; - } + if (ctype_print($i)) { + echo "character code $i is a printable character\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_print_variation4.phpt b/ext/ctype/tests/ctype_print_variation4.phpt index 9a0ae903233b..05cfe8fbde5e 100644 --- a/ext/ctype/tests/ctype_print_variation4.phpt +++ b/ext/ctype/tests/ctype_print_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array (0x20, 0x21, 0x23, 0x24); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_print($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_print($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_print($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_print($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); ?> diff --git a/ext/ctype/tests/ctype_punct_variation2.phpt b/ext/ctype/tests/ctype_punct_variation2.phpt index ce7270c6bd76..9fcfef0e210b 100644 --- a/ext/ctype/tests/ctype_punct_variation2.phpt +++ b/ext/ctype/tests/ctype_punct_variation2.phpt @@ -20,9 +20,9 @@ echo "*** Testing ctype_punct() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($c = 1; $c < 256; $c++) { - if (ctype_punct($c)) { - echo "character code $c is punctuation\n"; - } + if (ctype_punct($c)) { + echo "character code $c is punctuation\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_punct_variation4.phpt b/ext/ctype/tests/ctype_punct_variation4.phpt index c99f82c8495c..e96c12568ef6 100644 --- a/ext/ctype/tests/ctype_punct_variation4.phpt +++ b/ext/ctype/tests/ctype_punct_variation4.phpt @@ -24,17 +24,17 @@ $hex_values = array(0x21, 0x22, 0x23, 0x24); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_punct($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_punct($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_punct($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_punct($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_space_variation1.phpt b/ext/ctype/tests/ctype_space_variation1.phpt index d3920b69c2d5..7d16cd445efa 100644 --- a/ext/ctype/tests/ctype_space_variation1.phpt +++ b/ext/ctype/tests/ctype_space_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "\n\t\r"; - } + public function __toString() { + return "\n\t\r"; + } } // heredoc string @@ -89,9 +89,9 @@ $inputs = array( // loop through each element of $inputs to check the behavior of ctype_space() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( ctype_space($input) ); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_space($input) ); + $iterator++; } fclose($fp); diff --git a/ext/ctype/tests/ctype_space_variation2.phpt b/ext/ctype/tests/ctype_space_variation2.phpt index 901a57561177..f11611d42063 100644 --- a/ext/ctype/tests/ctype_space_variation2.phpt +++ b/ext/ctype/tests/ctype_space_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_space() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($c = 1; $c < 256; $c++) { - if (ctype_space($c)) { - echo "character code $c is a space character\n"; - } + if (ctype_space($c)) { + echo "character code $c is a space character\n"; + } } setlocale(LC_CTYPE, $orig); ?> diff --git a/ext/ctype/tests/ctype_space_variation4.phpt b/ext/ctype/tests/ctype_space_variation4.phpt index 1024bf623381..0447d4ec1fd1 100644 --- a/ext/ctype/tests/ctype_space_variation4.phpt +++ b/ext/ctype/tests/ctype_space_variation4.phpt @@ -23,17 +23,17 @@ $hex_values = array (0x9, 0xA, 0xB, 0xC, 0xD, 0x20); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_space($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_space($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_space($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_space($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); ?> diff --git a/ext/ctype/tests/ctype_upper_variation1.phpt b/ext/ctype/tests/ctype_upper_variation1.phpt index d8ea5e25137c..3cbbe33a3334 100644 --- a/ext/ctype/tests/ctype_upper_variation1.phpt +++ b/ext/ctype/tests/ctype_upper_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // get a class class classA { - public function __toString() { - return "HELLO"; - } + public function __toString() { + return "HELLO"; + } } // heredoc string @@ -89,9 +89,9 @@ $inputs = array( // loop through each element of $inputs to check the behavior of ctype_upper() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( ctype_upper($input) ); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_upper($input) ); + $iterator++; }; fclose($fp); diff --git a/ext/ctype/tests/ctype_upper_variation2.phpt b/ext/ctype/tests/ctype_upper_variation2.phpt index ad581ce1a641..645ead447111 100644 --- a/ext/ctype/tests/ctype_upper_variation2.phpt +++ b/ext/ctype/tests/ctype_upper_variation2.phpt @@ -18,9 +18,9 @@ echo "*** Testing ctype_upper() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for ($i = 0; $i < 256; $i++) { - if (ctype_upper($i)) { - echo "character code $i is a uppercase character\n"; - } + if (ctype_upper($i)) { + echo "character code $i is a uppercase character\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_upper_variation4.phpt b/ext/ctype/tests/ctype_upper_variation4.phpt index 6ac42b8674f3..28e572a7c5d4 100644 --- a/ext/ctype/tests/ctype_upper_variation4.phpt +++ b/ext/ctype/tests/ctype_upper_variation4.phpt @@ -22,17 +22,17 @@ $hex_values = array(0x41, 0x42, 0x43, 0x44); echo "\n-- Octal Values --\n"; $iterator = 1; foreach($octal_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_upper($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_upper($c)); + $iterator++; } echo "\n-- Hexadecimal Values --\n"; $iterator = 1; foreach($hex_values as $c) { - echo "-- Iteration $iterator --\n"; - var_dump(ctype_upper($c)); - $iterator++; + echo "-- Iteration $iterator --\n"; + var_dump(ctype_upper($c)); + $iterator++; } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_xdigit_variation1.phpt b/ext/ctype/tests/ctype_xdigit_variation1.phpt index aa7281a0e533..4c183ef37445 100644 --- a/ext/ctype/tests/ctype_xdigit_variation1.phpt +++ b/ext/ctype/tests/ctype_xdigit_variation1.phpt @@ -89,9 +89,9 @@ $inputs = array( // loop through each element of $inputs to check the behavior of ctype_xdigit() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( ctype_xdigit($input) ); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump( ctype_xdigit($input) ); + $iterator++; }; fclose($fp); diff --git a/ext/ctype/tests/ctype_xdigit_variation2.phpt b/ext/ctype/tests/ctype_xdigit_variation2.phpt index 7546329d9baa..bb2795c18944 100644 --- a/ext/ctype/tests/ctype_xdigit_variation2.phpt +++ b/ext/ctype/tests/ctype_xdigit_variation2.phpt @@ -19,9 +19,9 @@ echo "*** Testing ctype_xdigit() : usage variations ***\n"; $orig = setlocale(LC_CTYPE, "C"); for($c = 1; $c < 256; $c++) { - if (ctype_xdigit($c)) { - echo "character code $c is a hexadecimal 'digit'\n"; - } + if (ctype_xdigit($c)) { + echo "character code $c is a hexadecimal 'digit'\n"; + } } setlocale(LC_CTYPE, $orig); diff --git a/ext/ctype/tests/ctype_xdigit_variation4.phpt b/ext/ctype/tests/ctype_xdigit_variation4.phpt index e9f99e1f9a97..9f7a88f3abee 100644 --- a/ext/ctype/tests/ctype_xdigit_variation4.phpt +++ b/ext/ctype/tests/ctype_xdigit_variation4.phpt @@ -35,21 +35,21 @@ $hex_values2 = array(0x61, 0x62, 0x63, 0x64); echo "\n-- Octal values --\n"; echo "'Incorrect' Integers: \n"; foreach($octal_values1 as $c) { - var_dump(ctype_xdigit($c)); + var_dump(ctype_xdigit($c)); } echo "'Correct' Integers: \n"; foreach($octal_values2 as $c) { - var_dump(ctype_xdigit($c)); + var_dump(ctype_xdigit($c)); } echo "\n-- Hexadecimal values --\n"; echo "'Incorrect' Integers: \n"; foreach($hex_values1 as $c) { - var_dump(ctype_xdigit($c)); + var_dump(ctype_xdigit($c)); } echo "'Correct' Integers: \n"; foreach($hex_values2 as $c) { - var_dump(ctype_xdigit($c)); + var_dump(ctype_xdigit($c)); } setlocale(LC_CTYPE, $orig); ?> diff --git a/ext/curl/tests/bug45161.phpt b/ext/curl/tests/bug45161.phpt index 2da0b7cde82e..b93552e3ab3b 100644 --- a/ext/curl/tests/bug45161.phpt +++ b/ext/curl/tests/bug45161.phpt @@ -19,23 +19,23 @@ $fp = fopen('/dev/null', 'w'); /* $i = $start = $end = 100000.00; for ($i = 0; $i < 100; $i++) { - curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/'); - curl_setopt($ch, CURLOPT_FILE, $fp); - curl_exec($ch); + curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/'); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); } */ // Start actual test $start = memory_get_usage() + 1024; for($i = 0; $i < 1024; $i++) { - curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/'); - curl_setopt($ch, CURLOPT_FILE, $fp); - curl_exec($ch); + curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/'); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); } if ($start < memory_get_usage()) { - echo 'FAIL'; + echo 'FAIL'; } else { - echo 'PASS'; + echo 'PASS'; } echo "\n"; fclose($fp); diff --git a/ext/curl/tests/bug46711.phpt b/ext/curl/tests/bug46711.phpt index 865651329453..c46ea5331d75 100644 --- a/ext/curl/tests/bug46711.phpt +++ b/ext/curl/tests/bug46711.phpt @@ -11,14 +11,14 @@ if (!extension_loaded("curl")) { $ch = curl_init(); $opt = array( - CURLOPT_AUTOREFERER => TRUE, - CURLOPT_BINARYTRANSFER => TRUE + CURLOPT_AUTOREFERER => TRUE, + CURLOPT_BINARYTRANSFER => TRUE ); curl_setopt( $ch, CURLOPT_AUTOREFERER , TRUE ); foreach( $opt as $option => $value ) { - curl_setopt( $ch, $option, $value ); + curl_setopt( $ch, $option, $value ); } var_dump($opt); // with this bug, $opt[58] becomes NULL diff --git a/ext/curl/tests/bug48203_multi.phpt b/ext/curl/tests/bug48203_multi.phpt index 55dd36420371..7b3d05e71326 100644 --- a/ext/curl/tests/bug48203_multi.phpt +++ b/ext/curl/tests/bug48203_multi.phpt @@ -8,59 +8,59 @@ include 'skipif.inc'; 1, - $curl_option => $fp, - CURLOPT_URL => $target_url, - ); + $options = array( + CURLOPT_RETURNTRANSFER => 1, + $curl_option => $fp, + CURLOPT_URL => $target_url, + ); - // we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly - if (CURLOPT_STDERR == $curl_option) { - $options[CURLOPT_VERBOSE] = 1; - } + // we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly + if (CURLOPT_STDERR == $curl_option) { + $options[CURLOPT_VERBOSE] = 1; + } - if (CURLOPT_INFILE == $curl_option) { - $options[CURLOPT_UPLOAD] = 1; - } + if (CURLOPT_INFILE == $curl_option) { + $options[CURLOPT_UPLOAD] = 1; + } - curl_setopt_array($ch1, $options); - curl_setopt_array($ch2, $options); + curl_setopt_array($ch1, $options); + curl_setopt_array($ch2, $options); - fclose($fp); // <-- premature close of $fp caused a crash! + fclose($fp); // <-- premature close of $fp caused a crash! - $mh = curl_multi_init(); + $mh = curl_multi_init(); - curl_multi_add_handle($mh, $ch1); - curl_multi_add_handle($mh, $ch2); + curl_multi_add_handle($mh, $ch1); + curl_multi_add_handle($mh, $ch2); - $active = 0; - do { - curl_multi_exec($mh, $active); - } while ($active > 0); + $active = 0; + do { + curl_multi_exec($mh, $active); + } while ($active > 0); - curl_multi_remove_handle($mh, $ch1); - curl_multi_remove_handle($mh, $ch2); - curl_multi_close($mh); + curl_multi_remove_handle($mh, $ch1); + curl_multi_remove_handle($mh, $ch2); + curl_multi_close($mh); - // Force curl to output results - fflush(STDERR); - fflush(STDOUT); + // Force curl to output results + fflush(STDERR); + fflush(STDOUT); - echo "Ok for $description\n"; + echo "Ok for $description\n"; } $options_to_check = array( - "CURLOPT_STDERR", "CURLOPT_WRITEHEADER", "CURLOPT_FILE", "CURLOPT_INFILE" + "CURLOPT_STDERR", "CURLOPT_WRITEHEADER", "CURLOPT_FILE", "CURLOPT_INFILE" ); $target_url = curl_cli_server_start(); foreach($options_to_check as $option) { - checkForClosedFilePointer($target_url, constant($option), $option); + checkForClosedFilePointer($target_url, constant($option), $option); } ?> diff --git a/ext/curl/tests/bug54798-unix.phpt b/ext/curl/tests/bug54798-unix.phpt index 774c1be5e006..5f07b64c6fec 100644 --- a/ext/curl/tests/bug54798-unix.phpt +++ b/ext/curl/tests/bug54798-unix.phpt @@ -11,35 +11,35 @@ if(substr(PHP_OS, 0, 3) == 'WIN' ) { diff --git a/ext/curl/tests/bug54798.phpt b/ext/curl/tests/bug54798.phpt index 4a9b25cbdc7c..d2661fce8f7b 100644 --- a/ext/curl/tests/bug54798.phpt +++ b/ext/curl/tests/bug54798.phpt @@ -8,35 +8,35 @@ include 'skipif.inc'; diff --git a/ext/curl/tests/bug64267.phpt b/ext/curl/tests/bug64267.phpt index c3b04b33263b..1b85c98e17f3 100644 --- a/ext/curl/tests/bug64267.phpt +++ b/ext/curl/tests/bug64267.phpt @@ -13,18 +13,18 @@ echo "TEST\n"; $c = curl_init("http://google.com"); $f = fopen(__FILE__,"r"); var_dump(curl_setopt_array($c, [ - CURLOPT_RETURNTRANSFER => true, - CURLOPT_UPLOAD => true, - CURLOPT_INFILE => $f, - CURLOPT_INFILESIZE => filesize(__FILE__), - CURLOPT_CONNECTTIMEOUT => 3, - CURLOPT_TIMEOUT => 3, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_UPLOAD => true, + CURLOPT_INFILE => $f, + CURLOPT_INFILESIZE => filesize(__FILE__), + CURLOPT_CONNECTTIMEOUT => 3, + CURLOPT_TIMEOUT => 3, ])); fclose($f); var_dump(curl_setopt_array($c, [ - CURLOPT_UPLOAD => false, - CURLOPT_INFILE => null, - CURLOPT_INFILESIZE => 0, + CURLOPT_UPLOAD => false, + CURLOPT_INFILE => null, + CURLOPT_INFILESIZE => 0, ])); curl_exec($c); var_dump(curl_getinfo($c, CURLINFO_RESPONSE_CODE)); diff --git a/ext/curl/tests/bug67643.phpt b/ext/curl/tests/bug67643.phpt index 24cdb86a28e8..e3d090da3a15 100644 --- a/ext/curl/tests/bug67643.phpt +++ b/ext/curl/tests/bug67643.phpt @@ -6,24 +6,24 @@ if (!extension_loaded('curl')) print 'skip'; ?> --FILE-- 0); + $running = 0; + do { + curl_multi_exec($mh, $running); + } while($running > 0); - $results = curl_multi_getcontent($ch); + $results = curl_multi_getcontent($ch); - curl_multi_remove_handle($mh, $ch); - curl_multi_close($mh); + curl_multi_remove_handle($mh, $ch); + curl_multi_close($mh); - var_dump($results); + var_dump($results); ?> --EXPECT-- CURL1 diff --git a/ext/curl/tests/bug68937.phpt b/ext/curl/tests/bug68937.phpt index 4f2ed12e4271..9f2811759494 100644 --- a/ext/curl/tests/bug68937.phpt +++ b/ext/curl/tests/bug68937.phpt @@ -14,22 +14,22 @@ $url = "{$host}/get.inc"; $ch = curl_init($url); curl_setopt_array($ch, array( - CURLOPT_HEADER => false, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POST => true, - CURLOPT_INFILESIZE => 1, - CURLOPT_HTTPHEADER => array( - 'Expect:', - 'Content-Length: 1', - ), - CURLOPT_READFUNCTION => 'curl_read', - CURLOPT_CONNECTTIMEOUT=> 1, - CURLOPT_TIMEOUT=>1 + CURLOPT_HEADER => false, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => true, + CURLOPT_INFILESIZE => 1, + CURLOPT_HTTPHEADER => array( + 'Expect:', + 'Content-Length: 1', + ), + CURLOPT_READFUNCTION => 'curl_read', + CURLOPT_CONNECTTIMEOUT=> 1, + CURLOPT_TIMEOUT=>1 )); function curl_read($ch, $fp, $len) { - var_dump($fp); - exit; + var_dump($fp); + exit; } curl_exec($ch); diff --git a/ext/curl/tests/bug68937_2.phpt b/ext/curl/tests/bug68937_2.phpt index 8ebbc8eaa6fb..1ce5b5211429 100644 --- a/ext/curl/tests/bug68937_2.phpt +++ b/ext/curl/tests/bug68937_2.phpt @@ -13,23 +13,23 @@ $url = "{$host}/get.inc"; $ch = curl_init($url); curl_setopt_array($ch, array( - CURLOPT_HEADER => false, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POST => true, - CURLOPT_INFILESIZE => filesize(__FILE__), - CURLOPT_INFILE => fopen(__FILE__, 'r'), - CURLOPT_HTTPHEADER => array( - 'Expect:', - 'Content-Length: 1', - ), - CURLOPT_READFUNCTION => 'curl_read', - CURLOPT_CONNECTTIMEOUT => 1, - CURLOPT_TIMEOUT => 1 + CURLOPT_HEADER => false, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => true, + CURLOPT_INFILESIZE => filesize(__FILE__), + CURLOPT_INFILE => fopen(__FILE__, 'r'), + CURLOPT_HTTPHEADER => array( + 'Expect:', + 'Content-Length: 1', + ), + CURLOPT_READFUNCTION => 'curl_read', + CURLOPT_CONNECTTIMEOUT => 1, + CURLOPT_TIMEOUT => 1 )); function curl_read($ch, $fp, $len) { - var_dump($fp); - exit; + var_dump($fp); + exit; } curl_exec($ch); diff --git a/ext/curl/tests/bug69485.phpt b/ext/curl/tests/bug69485.phpt index 7a62589e5ea8..274cdce58247 100644 --- a/ext/curl/tests/bug69485.phpt +++ b/ext/curl/tests/bug69485.phpt @@ -6,9 +6,9 @@ Bug #69485 (Double free on zend_list_dtor) okey diff --git a/ext/curl/tests/bug76675.phpt b/ext/curl/tests/bug76675.phpt index 5e60c5c47fcc..e59aabc7c340 100644 --- a/ext/curl/tests/bug76675.phpt +++ b/ext/curl/tests/bug76675.phpt @@ -19,8 +19,8 @@ $callback = function($parent, $passed) use (&$transfers) { echo "Received ".strlen($data); return strlen($data); }); - $transfers++; - return CURL_PUSH_OK; + $transfers++; + return CURL_PUSH_OK; }; $mh = curl_multi_init(); curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); diff --git a/ext/curl/tests/bug77535.phpt b/ext/curl/tests/bug77535.phpt index b79cdb9c02e8..4505352ca8e4 100644 --- a/ext/curl/tests/bug77535.phpt +++ b/ext/curl/tests/bug77535.phpt @@ -41,7 +41,7 @@ class MyHttpClient return \strlen($data); }); curl_multi_add_handle($this->mh, $this->curl); - + $stillRunning = null; while (true) { do { diff --git a/ext/curl/tests/bug79033.phpt b/ext/curl/tests/bug79033.phpt index 98a97ed7a40d..454c3b2669df 100644 --- a/ext/curl/tests/bug79033.phpt +++ b/ext/curl/tests/bug79033.phpt @@ -8,11 +8,11 @@ include 'server.inc'; $host = curl_cli_server_start(); $ch = curl_init(); curl_setopt_array($ch, [ - CURLOPT_URL => "{$host}/get.inc?test=post", - CURLOPT_POST => true, + CURLOPT_URL => "{$host}/get.inc?test=post", + CURLOPT_POST => true, CURLOPT_POSTFIELDS => [], CURLINFO_HEADER_OUT => true, - CURLOPT_RETURNTRANSFER => true, + CURLOPT_RETURNTRANSFER => true, ]); var_dump(curl_exec($ch)); var_dump(curl_getinfo($ch)["request_header"]); diff --git a/ext/curl/tests/check_win_config.phpt b/ext/curl/tests/check_win_config.phpt index a5f116748ebd..2764a82f3816 100644 --- a/ext/curl/tests/check_win_config.phpt +++ b/ext/curl/tests/check_win_config.phpt @@ -10,13 +10,13 @@ if(substr(PHP_OS, 0, 3) != 'WIN' ) ?> --FILE-- DONE diff --git a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt index 92eba5e8c398..3d78ce60af8e 100644 --- a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt +++ b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt @@ -13,7 +13,7 @@ $ch = curl_init($host); $temp_file = __DIR__ . '/curl_file_deleted_before_curl_close.tmp'; if (file_exists($temp_file)) { - unlink($temp_file); // file should not exist before test + unlink($temp_file); // file should not exist before test } $handle = fopen($temp_file, 'w'); diff --git a/ext/curl/tests/curl_file_upload.phpt b/ext/curl/tests/curl_file_upload.phpt index 73a2f363fbbe..2c6409a25bde 100644 --- a/ext/curl/tests/curl_file_upload.phpt +++ b/ext/curl/tests/curl_file_upload.phpt @@ -7,15 +7,15 @@ CURL file uploading function testcurl($ch, $name, $mime = '', $postname = '') { - if(!empty($postname)) { - $file = new CurlFile($name, $mime, $postname); - } else if(!empty($mime)) { - $file = new CurlFile($name, $mime); - } else { - $file = new CurlFile($name); - } - curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => $file)); - var_dump(curl_exec($ch)); + if(!empty($postname)) { + $file = new CurlFile($name, $mime, $postname); + } else if(!empty($mime)) { + $file = new CurlFile($name, $mime); + } else { + $file = new CurlFile($name); + } + curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => $file)); + var_dump(curl_exec($ch)); } include 'server.inc'; diff --git a/ext/curl/tests/curl_ftp_pasv.phpt b/ext/curl/tests/curl_ftp_pasv.phpt index 39b351dd7b94..866f1a2ca618 100644 --- a/ext/curl/tests/curl_ftp_pasv.phpt +++ b/ext/curl/tests/curl_ftp_pasv.phpt @@ -23,15 +23,15 @@ if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REM // curl_setopt ( $ch , CURLOPT_VERBOSE, 1 ); /* Without enabling SKIP_PASV_IP flag, the following output will be seen.. - < 227 Entering Passive Mode (10,5,80,146,100,199) - * Trying 10.5.80.146... * connected - * Connecting to 10.5.80.146 (10.5.80.146) port 25799 + < 227 Entering Passive Mode (10,5,80,146,100,199) + * Trying 10.5.80.146... * connected + * Connecting to 10.5.80.146 (10.5.80.146) port 25799 */ /* After enabling SKIP_PASV_IP flag, the following output will be seen.. - < 227 Entering Passive Mode (10,5,80,146,50,229) - * Skips 10.5.80.146 for data connection, uses 10.5.80.146 instead - * Trying 10.5.80.146... * connected + < 227 Entering Passive Mode (10,5,80,146,50,229) + * Skips 10.5.80.146 for data connection, uses 10.5.80.146 instead + * Trying 10.5.80.146... * connected */ curl_setopt ( $ch , CURLOPT_URL, $url ); diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt index f67196d7e765..601aa17a2fee 100644 --- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt +++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt @@ -7,43 +7,43 @@ Rein Velt (rein@velt.org) --FILE-- 0); + //EXECUTE + $running=0; + do { + curl_multi_exec($mh,$running); + } while ($running>0); - $results1=curl_multi_getcontent($ch1); + $results1=curl_multi_getcontent($ch1); $results2=curl_multi_getcontent($ch2); - //CLOSE - curl_multi_remove_handle($mh,$ch1); - curl_multi_remove_handle($mh,$ch2); - curl_multi_close($mh); + //CLOSE + curl_multi_remove_handle($mh,$ch1); + curl_multi_remove_handle($mh,$ch2); + curl_multi_close($mh); - echo $results1; - echo $results2; + echo $results1; + echo $results2; ?> --EXPECT-- diff --git a/ext/curl/tests/curl_multi_segfault.phpt b/ext/curl/tests/curl_multi_segfault.phpt index c1608bf3465c..c577b045163b 100644 --- a/ext/curl/tests/curl_multi_segfault.phpt +++ b/ext/curl/tests/curl_multi_segfault.phpt @@ -32,16 +32,16 @@ if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REM $active = null; do { - $mrc = curl_multi_exec($cmh, $active); + $mrc = curl_multi_exec($cmh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) { - if (curl_multi_select($cmh) != -1) { - do { - $mrc = curl_multi_exec($cmh, $active); - } while ($mrc == CURLM_CALL_MULTI_PERFORM); - } + if (curl_multi_select($cmh) != -1) { + do { + $mrc = curl_multi_exec($cmh, $active); + } while ($mrc == CURLM_CALL_MULTI_PERFORM); + } } var_dump(is_string(curl_multi_getcontent($ch))); diff --git a/ext/curl/tests/curl_write_callback.phpt b/ext/curl/tests/curl_write_callback.phpt index c0b733ee4414..36fcf285aacc 100644 --- a/ext/curl/tests/curl_write_callback.phpt +++ b/ext/curl/tests/curl_write_callback.phpt @@ -12,8 +12,8 @@ Writes the value 'test' to a temporary file. Use curl to access this file, passi function curl_callback($curl_handle, $received_data) { - echo $received_data; - return strlen($received_data); + echo $received_data; + return strlen($received_data); } $log_file = tempnam(sys_get_temp_dir(), 'php-curl-test'); diff --git a/ext/curl/tests/curl_writeheader_callback.phpt b/ext/curl/tests/curl_writeheader_callback.phpt index 6336e14a6d99..f56adb1dc52b 100644 --- a/ext/curl/tests/curl_writeheader_callback.phpt +++ b/ext/curl/tests/curl_writeheader_callback.phpt @@ -12,8 +12,8 @@ Hit the host and determine that the headers are sent to the callback specified f function curl_header_callback($curl_handle, $data) { - if (strtolower(substr($data,0, 4)) == 'http') - echo $data; + if (strtolower(substr($data,0, 4)) == 'http') + echo $data; } include 'server.inc'; diff --git a/ext/date/tests/002.phpt b/ext/date/tests/002.phpt index adbea5e23166..36dc43d7605b 100644 --- a/ext/date/tests/002.phpt +++ b/ext/date/tests/002.phpt @@ -8,45 +8,45 @@ if (!@putenv("TZ=EST5") || getenv("TZ") != 'EST5') { ?> --FILE-- --EXPECTF-- *** GMT0 diff --git a/ext/date/tests/003.phpt b/ext/date/tests/003.phpt index 501899cc5fc4..ae7fcce23c59 100644 --- a/ext/date/tests/003.phpt +++ b/ext/date/tests/003.phpt @@ -5,7 +5,7 @@ date suffixes test date_default_timezone_set('UTC'); for ($i = 0; $i < 32; $i++) { - var_dump(date("jS", mktime(0,0,0, 1, $i, 2006))); + var_dump(date("jS", mktime(0,0,0, 1, $i, 2006))); } echo "Done\n"; diff --git a/ext/date/tests/004.phpt b/ext/date/tests/004.phpt index 986c9c917970..23cb508458d0 100644 --- a/ext/date/tests/004.phpt +++ b/ext/date/tests/004.phpt @@ -8,19 +8,19 @@ $tz = array("UTC", "Asia/Jerusalem", "America/Chicago", "Europe/London"); $t = mktime(0, 0, 0, 6, 27, 2006); foreach ($tz as $zone) { - date_default_timezone_set($zone); + date_default_timezone_set($zone); - var_dump(date("w", $t)); - var_dump(date("z", $t)); - var_dump(date("n", $t)); - var_dump(date("t", $t)); - var_dump(date("L", $t)); - var_dump(date("a", $t)); - var_dump(date("B", $t)); - var_dump(date("g", $t)); - var_dump(date("G", $t)); - var_dump(date("Z", $t)); - var_dump(date("U", $t)); + var_dump(date("w", $t)); + var_dump(date("z", $t)); + var_dump(date("n", $t)); + var_dump(date("t", $t)); + var_dump(date("L", $t)); + var_dump(date("a", $t)); + var_dump(date("B", $t)); + var_dump(date("g", $t)); + var_dump(date("G", $t)); + var_dump(date("Z", $t)); + var_dump(date("U", $t)); } echo "Done\n"; diff --git a/ext/date/tests/DateTimeZone_clone_basic1.phpt b/ext/date/tests/DateTimeZone_clone_basic1.phpt index 3587ca74bf7b..3d154512f637 100644 --- a/ext/date/tests/DateTimeZone_clone_basic1.phpt +++ b/ext/date/tests/DateTimeZone_clone_basic1.phpt @@ -18,11 +18,11 @@ var_dump($orig); var_dump($clone); if ($clone != $orig) { - echo "TEST FAILED : objects not equal\n"; + echo "TEST FAILED : objects not equal\n"; }else if ($clone === $orig) { - echo "TEST FAILED : objects identical\n"; + echo "TEST FAILED : objects identical\n"; } else { - echo "TEST PASSED : Objects equal but not indetical\n"; + echo "TEST PASSED : Objects equal but not indetical\n"; } ?> diff --git a/ext/date/tests/DateTimeZone_clone_basic2.phpt b/ext/date/tests/DateTimeZone_clone_basic2.phpt index bbda5fb4a22a..b41eeddfbdda 100644 --- a/ext/date/tests/DateTimeZone_clone_basic2.phpt +++ b/ext/date/tests/DateTimeZone_clone_basic2.phpt @@ -6,13 +6,13 @@ Testing clone on objects whose class derived from DateTimeZone class date_default_timezone_set("Europe/London"); class DateTimeZoneExt1 extends DateTimeZone { - public $property1 = 99; - public $property2 = "Hello"; + public $property1 = 99; + public $property2 = "Hello"; } class DateTimeZoneExt2 extends DateTimeZoneExt1 { - public $property3 = true; - public $property4 = 10.5; + public $property3 = true; + public $property4 = 10.5; } echo "*** Testing clone on objects whose class derived from DateTimeZone class ***\n"; diff --git a/ext/date/tests/DateTimeZone_clone_basic4.phpt b/ext/date/tests/DateTimeZone_clone_basic4.phpt index 39cea00742c0..9f99bc5b3e51 100644 --- a/ext/date/tests/DateTimeZone_clone_basic4.phpt +++ b/ext/date/tests/DateTimeZone_clone_basic4.phpt @@ -6,9 +6,9 @@ Test clone of DateTimeZone derived objects with __clone magic method date_default_timezone_set("Europe/London"); class DateTimeZoneExt1 extends DateTimeZone { - public function __clone() { - echo "-- DateTimeExt1 __clone magic method called --\n"; - } + public function __clone() { + echo "-- DateTimeExt1 __clone magic method called --\n"; + } } echo "*** Testing clone of objects derived from DateTimeZone class with __clone magic method***\n"; diff --git a/ext/date/tests/DateTimeZone_compare_basic1.phpt b/ext/date/tests/DateTimeZone_compare_basic1.phpt index 1df144840aa6..1e37178a34d4 100644 --- a/ext/date/tests/DateTimeZone_compare_basic1.phpt +++ b/ext/date/tests/DateTimeZone_compare_basic1.phpt @@ -14,8 +14,8 @@ class DateTimeZoneExt1 extends DateTimeZone { } class DateTimeZoneExt2 extends DateTimeZone{ - public $foo = "Hello"; - private $bar = 99; + public $foo = "Hello"; + private $bar = 99; } class DateTimeZoneExt3 extends DateTimeZoneExt2 { diff --git a/ext/date/tests/DateTimeZone_extends_basic1.phpt b/ext/date/tests/DateTimeZone_extends_basic1.phpt index 178970bdb9df..ace71c3ffa08 100644 --- a/ext/date/tests/DateTimeZone_extends_basic1.phpt +++ b/ext/date/tests/DateTimeZone_extends_basic1.phpt @@ -10,10 +10,10 @@ echo "*** Testing basic DateTimeZone inheritance() ***\n"; class DateTimeZoneExt extends DateTimeZone { - public function __toString() - { - return parent::getName(); - } + public function __toString() + { + return parent::getName(); + } } echo "\n-- Create an instance of DateTimeZoneExt --\n"; diff --git a/ext/date/tests/DateTimeZone_getTransitions_basic1.phpt b/ext/date/tests/DateTimeZone_getTransitions_basic1.phpt index c67cd4197714..755914346601 100644 --- a/ext/date/tests/DateTimeZone_getTransitions_basic1.phpt +++ b/ext/date/tests/DateTimeZone_getTransitions_basic1.phpt @@ -19,7 +19,7 @@ $tz = new DateTimeZone("Europe/London"); $tran = $tz->getTransitions(-306972000, -37241999); if (!is_array($tran)) { - echo "TEST FAILED: Expected an array\n"; + echo "TEST FAILED: Expected an array\n"; } echo "\n-- Total number of transitions: " . count($tran). " --\n"; diff --git a/ext/date/tests/DateTime_clone_basic2.phpt b/ext/date/tests/DateTime_clone_basic2.phpt index 944b74abcba7..261879283ed8 100644 --- a/ext/date/tests/DateTime_clone_basic2.phpt +++ b/ext/date/tests/DateTime_clone_basic2.phpt @@ -6,14 +6,14 @@ Test clone of objects whose class derived from DateTime class date_default_timezone_set("Europe/London"); class DateTimeExt1 extends DateTime { - public $property1 = 99; - public $property2 = "Hello"; + public $property1 = 99; + public $property2 = "Hello"; } class DateTimeExt2 extends DateTimeExt1 { - public $property3 = true; - public $property4 = 10.5; + public $property3 = true; + public $property4 = 10.5; } echo "*** Testing clone on objects whose class derived from DateTime class ***\n"; diff --git a/ext/date/tests/DateTime_clone_basic4.phpt b/ext/date/tests/DateTime_clone_basic4.phpt index e72f5707112b..3633cb56e0c6 100644 --- a/ext/date/tests/DateTime_clone_basic4.phpt +++ b/ext/date/tests/DateTime_clone_basic4.phpt @@ -9,9 +9,9 @@ date_default_timezone_set("Europe/London"); date_default_timezone_set("Europe/London"); class DateTimeExt1 extends DateTime { - public function __clone() { - echo "-- DateTimeExt1 __clone magic method called --\n"; - } + public function __clone() { + echo "-- DateTimeExt1 __clone magic method called --\n"; + } } echo "*** Testing clone of objects derived from DateTime class with __clone magic method***\n"; diff --git a/ext/date/tests/DateTime_compare_basic1.phpt b/ext/date/tests/DateTime_compare_basic1.phpt index 7786defb6a05..93c7b1f34e17 100644 --- a/ext/date/tests/DateTime_compare_basic1.phpt +++ b/ext/date/tests/DateTime_compare_basic1.phpt @@ -12,8 +12,8 @@ class DateTimeExt1 extends DateTime { } class DateTimeExt2 extends DateTime{ - public $foo = "Hello"; - private $bar = 99; + public $foo = "Hello"; + private $bar = 99; } class DateTimeExt3 extends DateTimeExt2 { diff --git a/ext/date/tests/DateTime_extends_basic1.phpt b/ext/date/tests/DateTime_extends_basic1.phpt index d7d236943d45..1a4c004c893e 100644 --- a/ext/date/tests/DateTime_extends_basic1.phpt +++ b/ext/date/tests/DateTime_extends_basic1.phpt @@ -11,12 +11,12 @@ echo "*** Testing basic DateTime inheritance() ***\n"; class DateTimeExt extends DateTime { - public static $format = "F j, Y, g:i:s a"; + public static $format = "F j, Y, g:i:s a"; - public function __toString() - { - return parent::format(self::$format); - } + public function __toString() + { + return parent::format(self::$format); + } } echo "\n-- Create an instance of DateTimeExt --\n"; diff --git a/ext/date/tests/DateTime_extends_basic2.phpt b/ext/date/tests/DateTime_extends_basic2.phpt index 1bfc2f1e4cde..03d1e0328339 100644 --- a/ext/date/tests/DateTime_extends_basic2.phpt +++ b/ext/date/tests/DateTime_extends_basic2.phpt @@ -10,7 +10,7 @@ echo "*** Testing new DateTime() : with user space __construct magic method ***\ class DateTimeExt extends DateTime { - public function __construct ($date = null, DateTimeZone $dtz = null) + public function __construct ($date = null, DateTimeZone $dtz = null) { if($dtz === null) { diff --git a/ext/date/tests/DateTime_extends_basic3.phpt b/ext/date/tests/DateTime_extends_basic3.phpt index 3f48cb2e2170..27fc602e0050 100644 --- a/ext/date/tests/DateTime_extends_basic3.phpt +++ b/ext/date/tests/DateTime_extends_basic3.phpt @@ -9,10 +9,10 @@ echo "*** Testing new DateTime() : with user format() method ***\n"; class DateTimeExt extends DateTime { - public function format($format = "F j, Y, g:i:s a") - { - return parent::format($format); - } + public function format($format = "F j, Y, g:i:s a") + { + return parent::format($format); + } } $d = new DateTimeExt("1967-05-01 22:30:41"); diff --git a/ext/date/tests/bug13142.phpt b/ext/date/tests/bug13142.phpt index 5550d5ce9cb1..80d4fa82fc45 100644 --- a/ext/date/tests/bug13142.phpt +++ b/ext/date/tests/bug13142.phpt @@ -15,7 +15,7 @@ if (!@putenv("TZ=US/Eastern") || getenv("TZ") != 'US/Eastern') { --EXPECT-- tStamp=Wednesday 2004-10-27 17:17:17 CEST diff --git a/ext/date/tests/bug20382-2.phpt b/ext/date/tests/bug20382-2.phpt index 2488c4729e91..d963708ce360 100644 --- a/ext/date/tests/bug20382-2.phpt +++ b/ext/date/tests/bug20382-2.phpt @@ -4,43 +4,43 @@ Bug #20382 [2] (strtotime ("Monday", $date) produces wrong result on DST changeo --EXPECTF-- diff --git a/ext/date/tests/bug21399.phpt b/ext/date/tests/bug21399.phpt index a295c8bd8b54..c7ad8caf4ab8 100644 --- a/ext/date/tests/bug21399.phpt +++ b/ext/date/tests/bug21399.phpt @@ -4,7 +4,7 @@ Bug #21399 (strtotime() request for "YYYYMMDDhhmmss [ZZZ]") date.timezone=GMT --FILE-- --EXPECT-- 2005-06-20 09:14:07 diff --git a/ext/date/tests/bug26198.phpt b/ext/date/tests/bug26198.phpt index c957bfcf7a9b..f59a628b6219 100644 --- a/ext/date/tests/bug26198.phpt +++ b/ext/date/tests/bug26198.phpt @@ -2,9 +2,9 @@ Bug #26198 (strtotime handling of "M Y" and "Y M" format) --FILE-- --EXPECT-- October 2001 (2001-10-01 00:00:00 GMT) diff --git a/ext/date/tests/bug26317.phpt b/ext/date/tests/bug26317.phpt index 652cc6787955..38c724ed5701 100644 --- a/ext/date/tests/bug26317.phpt +++ b/ext/date/tests/bug26317.phpt @@ -10,9 +10,9 @@ if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') { ?> --FILE-- --EXPECT-- 2003-11-19 16:20:42 diff --git a/ext/date/tests/bug26320.phpt b/ext/date/tests/bug26320.phpt index 48e901117c5b..563e39ab3060 100644 --- a/ext/date/tests/bug26320.phpt +++ b/ext/date/tests/bug26320.phpt @@ -10,8 +10,8 @@ if (!@putenv("TZ=GMT0") || getenv("TZ") != 'GMT0') { ?> --FILE-- --EXPECT-- 2003-11-19 12:30:42 diff --git a/ext/date/tests/bug26694.phpt b/ext/date/tests/bug26694.phpt index 939b04c1364e..a82496124ff3 100644 --- a/ext/date/tests/bug26694.phpt +++ b/ext/date/tests/bug26694.phpt @@ -4,7 +4,7 @@ Bug #26694 (strtotime() request for "Sun, 21 Dec 2003 20:38:33 +0000 GMT") date.timezone=GMT --FILE-- --EXPECT-- 2003-12-21 20:38:33 diff --git a/ext/date/tests/bug27780.phpt b/ext/date/tests/bug27780.phpt index b1cfa831a2f3..f6f21e418512 100644 --- a/ext/date/tests/bug27780.phpt +++ b/ext/date/tests/bug27780.phpt @@ -8,37 +8,37 @@ if (defined('PHP_WINDOWS_VERSION_MAJOR')) { --FILE-- --EXPECTF-- diff --git a/ext/date/tests/bug28024.phpt b/ext/date/tests/bug28024.phpt index b5f97bd5c949..8229f1cd7b5b 100644 --- a/ext/date/tests/bug28024.phpt +++ b/ext/date/tests/bug28024.phpt @@ -4,8 +4,8 @@ Bug #28024 (Changed behavior of strtotime()) date.timezone=Europe/Berlin --FILE-- --EXPECT-- 1072972800 diff --git a/ext/date/tests/bug29150.phpt b/ext/date/tests/bug29150.phpt index d91d68d91992..15edffa8980e 100644 --- a/ext/date/tests/bug29150.phpt +++ b/ext/date/tests/bug29150.phpt @@ -4,7 +4,7 @@ Bug #29150 (Roman number format for months) date.timezone=GMT --FILE-- --EXPECT-- 2005-06-20 00:00:00 diff --git a/ext/date/tests/bug30096.phpt b/ext/date/tests/bug30096.phpt index dbda97beff39..5d40aa3d34e4 100644 --- a/ext/date/tests/bug30096.phpt +++ b/ext/date/tests/bug30096.phpt @@ -19,18 +19,18 @@ gm_date_check(03,00,00,10,30,2005); gm_date_check(04,00,00,10,30,2005); function gm_date_check($hour, $minute, $second, $month, $day, $year) { - global $ts, $tsold; + global $ts, $tsold; - echo "gmmktime($hour,$minute,$second,$month,$day,$year): "; + echo "gmmktime($hour,$minute,$second,$month,$day,$year): "; - $tsold = $ts; - $ts = gmmktime($hour, $minute, $second, $month, $day, $year); + $tsold = $ts; + $ts = gmmktime($hour, $minute, $second, $month, $day, $year); - echo $ts, " | gmdate('r', $ts):", gmdate('r', $ts); - if ($tsold > 0) { - echo " | Diff: " . ($ts - $tsold); - } - echo "\n"; + echo $ts, " | gmdate('r', $ts):", gmdate('r', $ts); + if ($tsold > 0) { + echo " | Diff: " . ($ts - $tsold); + } + echo "\n"; } ?> diff --git a/ext/date/tests/bug33578.phpt b/ext/date/tests/bug33578.phpt index 4ba6df85971c..6c0d4d3bd7aa 100644 --- a/ext/date/tests/bug33578.phpt +++ b/ext/date/tests/bug33578.phpt @@ -2,14 +2,14 @@ Bug #33578 (strtotime() doesn't parse "11 Oct" format") --FILE-- --EXPECTF-- 10/11/%d diff --git a/ext/date/tests/bug33869.phpt b/ext/date/tests/bug33869.phpt index 6957a6b7e24c..8f8e957c954e 100644 --- a/ext/date/tests/bug33869.phpt +++ b/ext/date/tests/bug33869.phpt @@ -2,20 +2,20 @@ Bug #33869 (strtotime() doesn't parse "+1days" format) --FILE-- --EXPECT-- 2005-01-06T01:01:01+0000 diff --git a/ext/date/tests/bug33957.phpt b/ext/date/tests/bug33957.phpt index 43f14ee315f1..6ae97d7de8da 100644 --- a/ext/date/tests/bug33957.phpt +++ b/ext/date/tests/bug33957.phpt @@ -5,33 +5,33 @@ Bug #33957 (gmdate('W')/date('W') sometimes returns wrong week number) date_default_timezone_set("UTC"); for ($i = 14; $i <= 31; $i++) { - echo "1992-12-$i ", date("W", strtotime("1992-12-$i")), "\n"; + echo "1992-12-$i ", date("W", strtotime("1992-12-$i")), "\n"; } for ($i = 1; $i <= 8; $i++) { - echo "1993-01-$i ", date("W", strtotime("1993-01-$i")), "\n"; + echo "1993-01-$i ", date("W", strtotime("1993-01-$i")), "\n"; } echo "----\n"; echo " "; foreach (range(1992, 2019) as $year) { - echo "$year "; + echo "$year "; } echo "\n"; for ($i = 14; $i <= 31; $i++) { - echo " (12-$i) "; - foreach (range(1992, 2019) as $year) { - echo sprintf(" %02d-", date("W", strtotime("$year-12-$i"))); - echo sprintf("%04d ", date("o", strtotime("$year-12-$i"))); - } - echo "\n"; + echo " (12-$i) "; + foreach (range(1992, 2019) as $year) { + echo sprintf(" %02d-", date("W", strtotime("$year-12-$i"))); + echo sprintf("%04d ", date("o", strtotime("$year-12-$i"))); + } + echo "\n"; } for ($i = 1; $i <= 18; $i++) { - printf("+1 (01-%02d) ", $i); - foreach (range(1993, 2020) as $year) { - echo sprintf(" %02d-", date("W", strtotime("$year-1-$i"))); - echo sprintf("%04d ", date("o", strtotime("$year-1-$i"))); - } - echo "\n"; + printf("+1 (01-%02d) ", $i); + foreach (range(1993, 2020) as $year) { + echo sprintf(" %02d-", date("W", strtotime("$year-1-$i"))); + echo sprintf("%04d ", date("o", strtotime("$year-1-$i"))); + } + echo "\n"; } echo "----\n"; ?> diff --git a/ext/date/tests/bug34676.phpt b/ext/date/tests/bug34676.phpt index 6f616feb4064..ec2fcf9270a2 100644 --- a/ext/date/tests/bug34676.phpt +++ b/ext/date/tests/bug34676.phpt @@ -5,12 +5,12 @@ Bug #34676 (missing support for strtotime("midnight") and strtotime("noon")) date_default_timezone_set("UTC"); $tests = array( - 'noon', 'midnight' + 'noon', 'midnight' ); foreach ($tests as $test) { - $t = strtotime("2005-12-22 ". $test); - printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t)); + $t = strtotime("2005-12-22 ". $test); + printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t)); } ?> diff --git a/ext/date/tests/bug34771.phpt b/ext/date/tests/bug34771.phpt index a27d085a1da7..d3134d1d6b94 100644 --- a/ext/date/tests/bug34771.phpt +++ b/ext/date/tests/bug34771.phpt @@ -5,15 +5,15 @@ Bug #34771 (strtotime() fails with 1-12am/pm) date_default_timezone_set("UTC"); $tests = array( - '12am', '1am', '1pm', - '12a.m.', '1a.m.', '1p.m.', - '12:00am', '1:00am', '1:00pm', - '12:00a.m.', '1:00a.m.', '1:00p.m.' + '12am', '1am', '1pm', + '12a.m.', '1a.m.', '1p.m.', + '12:00am', '1:00am', '1:00pm', + '12:00a.m.', '1:00a.m.', '1:00p.m.' ); foreach ($tests as $test) { - $t = strtotime("2005-12-22 ". $test); - printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t)); + $t = strtotime("2005-12-22 ". $test); + printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t)); } ?> diff --git a/ext/date/tests/bug35425.phpt b/ext/date/tests/bug35425.phpt index e55a4f521917..ed9f87fd58d9 100644 --- a/ext/date/tests/bug35425.phpt +++ b/ext/date/tests/bug35425.phpt @@ -7,7 +7,7 @@ date.timezone=America/Montreal $time = mktime(1,1,1,1,1,2005); foreach (array('B','d','h','H','i','I','L','m','s','t','U','w','W','y','Y','z','Z') as $v) { - var_dump(idate($v, $time)); + var_dump(idate($v, $time)); } ?> diff --git a/ext/date/tests/bug35624.phpt b/ext/date/tests/bug35624.phpt index 722adba82353..39fe555224a1 100644 --- a/ext/date/tests/bug35624.phpt +++ b/ext/date/tests/bug35624.phpt @@ -7,9 +7,9 @@ date_default_timezone_set("UTC"); $days = array("monday","mon","tuesday","tue","wednesday","wed","thursday","thu","friday","fri","saturday","sat","sunday","sun"); foreach ($days as $day) { - echo date("D", strtotime($day)); - echo date("D", strtotime(ucfirst($day))); - echo "\n"; + echo date("D", strtotime($day)); + echo date("D", strtotime(ucfirst($day))); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/bug35885.phpt b/ext/date/tests/bug35885.phpt index b3074f7f34fa..974c2c2c85a6 100644 --- a/ext/date/tests/bug35885.phpt +++ b/ext/date/tests/bug35885.phpt @@ -12,8 +12,8 @@ $res = ($ts == $ts2); var_dump($res); if (!$res) { - var_dump($ts); - var_dump($ts2); + var_dump($ts); + var_dump($ts2); } ?> diff --git a/ext/date/tests/bug37747.phpt b/ext/date/tests/bug37747.phpt index 465f791c413d..8c3d000341f0 100644 --- a/ext/date/tests/bug37747.phpt +++ b/ext/date/tests/bug37747.phpt @@ -4,7 +4,7 @@ Bug #37747 (strtotime segfaults when given "nextyear") --EXPECT-- bool(false) diff --git a/ext/date/tests/bug42910.phpt b/ext/date/tests/bug42910.phpt index e741db2ebc3a..f93ccedeaf7e 100644 --- a/ext/date/tests/bug42910.phpt +++ b/ext/date/tests/bug42910.phpt @@ -2,18 +2,18 @@ Bug #42910 (Constructing DateTime with TimeZone Indicator invalidates DateTimeZone) --FILE-- format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n"; - print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n"; + print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n"; + print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n"; - $foo->setDate(2007, 03, 12); - $bar->setDate(2007, 03, 12); + $foo->setDate(2007, 03, 12); + $bar->setDate(2007, 03, 12); - print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n"; - print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n"; + print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n"; + print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n"; // -------------- diff --git a/ext/date/tests/bug43808.phpt b/ext/date/tests/bug43808.phpt index 74b2317a20f7..9a1c4fad1f61 100644 --- a/ext/date/tests/bug43808.phpt +++ b/ext/date/tests/bug43808.phpt @@ -5,7 +5,7 @@ Bug #43808 (date_create never fails (even when it should)) $date = date_create('asdfasdf'); if ($date instanceof DateTime) { - echo "this is wrong, should be bool"; + echo "this is wrong, should be bool"; } var_dump( $date ); diff --git a/ext/date/tests/bug44562.phpt b/ext/date/tests/bug44562.phpt index 5610474108b2..b4b721168f3e 100644 --- a/ext/date/tests/bug44562.phpt +++ b/ext/date/tests/bug44562.phpt @@ -6,11 +6,11 @@ date_default_timezone_set('Europe/Oslo'); try { - $dp = new DatePeriod('2D'); + $dp = new DatePeriod('2D'); } catch ( Exception $e ) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } $begin = new DateTime( "2008-07-20T22:44:53+0200" ); @@ -19,7 +19,7 @@ $interval = DateInterval::createFromDateString( "1 day" ); $dp = new DatePeriod( $begin, $interval, 10 ); foreach ( $dp as $d ) { - var_dump ($d->format( DATE_ISO8601 ) ); + var_dump ($d->format( DATE_ISO8601 ) ); } ?> diff --git a/ext/date/tests/bug44742.phpt b/ext/date/tests/bug44742.phpt index 48952b4e6cdc..e87c1acb06e8 100644 --- a/ext/date/tests/bug44742.phpt +++ b/ext/date/tests/bug44742.phpt @@ -4,22 +4,22 @@ Bug #44742 (timezone_offset_get() causes segmentation faults) --EXPECT-- diff --git a/ext/date/tests/bug45543.phpt b/ext/date/tests/bug45543.phpt index 42a97ab20c99..ed785a715a59 100644 --- a/ext/date/tests/bug45543.phpt +++ b/ext/date/tests/bug45543.phpt @@ -5,21 +5,21 @@ date.timezone=UTC --FILE-- format(DATE_ISO8601), PHP_EOL; - echo $d2->format(DATE_ISO8601), PHP_EOL; - $tz = $d1->getTimeZone(); - $d2->setTimeZone($tz); - echo $d1->format(DATE_ISO8601), PHP_EOL; - echo $d2->format(DATE_ISO8601), PHP_EOL; - echo PHP_EOL; + $d1 = new DateTime($test_date); + $d2 = new DateTime('2008-01-01 12:00:00 UTC'); + echo $d1->format(DATE_ISO8601), PHP_EOL; + echo $d2->format(DATE_ISO8601), PHP_EOL; + $tz = $d1->getTimeZone(); + $d2->setTimeZone($tz); + echo $d1->format(DATE_ISO8601), PHP_EOL; + echo $d2->format(DATE_ISO8601), PHP_EOL; + echo PHP_EOL; } --EXPECT-- 2008-01-01T12:00:00-0700 diff --git a/ext/date/tests/bug48476.phpt b/ext/date/tests/bug48476.phpt index 02086e0e56f9..139c2e17e2ba 100644 --- a/ext/date/tests/bug48476.phpt +++ b/ext/date/tests/bug48476.phpt @@ -3,10 +3,10 @@ Bug #48476 (cloning extended DateTime class without calling parent::__constr cra --FILE-- --EXPECT-- diff --git a/ext/date/tests/bug51096.phpt b/ext/date/tests/bug51096.phpt index 2b479a94a692..dafb60bcde9d 100644 --- a/ext/date/tests/bug51096.phpt +++ b/ext/date/tests/bug51096.phpt @@ -3,26 +3,26 @@ Bug #51096 (Test for "first day" vs "first day of") --FILE-- format( DateTime::ISO8601 ); - $date->modify( $test ); - echo ' -> ', $date->format( DateTime::ISO8601 ), "\n\n"; + $result = date_parse( $test ); + $rel = $result['relative']; + echo $test, "\n- month: ", $rel['month'], '; day: ', $rel['day'], + '; first-day-of: ', isset( $rel['first_day_of_month'] ) ? 'true' : 'false', + '; last-day-of: ', isset( $rel['last_day_of_month'] ) ? 'true' : 'false', "\n"; + $date = new DateTime( '2010-03-06 15:21 UTC' ); + echo '- ', $date->format( DateTime::ISO8601 ); + $date->modify( $test ); + echo ' -> ', $date->format( DateTime::ISO8601 ), "\n\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/bug51866.phpt b/ext/date/tests/bug51866.phpt index 9481aebe9d40..1874e32706b4 100644 --- a/ext/date/tests/bug51866.phpt +++ b/ext/date/tests/bug51866.phpt @@ -5,22 +5,22 @@ Bug #51866 (Lenient parsing with parseFromFormat) date_default_timezone_set('UTC'); $tests = array( - array( 'Y-m-d', '2001-11-29 13:20:01' ), - array( 'Y-m-d+', '2001-11-29 13:20:01' ), - array( 'Y-m-d +', '2001-11-29 13:20:01' ), - array( 'Y-m-d+', '2001-11-29' ), - array( 'Y-m-d +', '2001-11-29' ), - array( 'Y-m-d +', '2001-11-29 ' ), + array( 'Y-m-d', '2001-11-29 13:20:01' ), + array( 'Y-m-d+', '2001-11-29 13:20:01' ), + array( 'Y-m-d +', '2001-11-29 13:20:01' ), + array( 'Y-m-d+', '2001-11-29' ), + array( 'Y-m-d +', '2001-11-29' ), + array( 'Y-m-d +', '2001-11-29 ' ), ); foreach( $tests as $test ) { - list($format, $str) = $test; - var_dump($format, $str); - $d = DateTime::createFromFormat($format, $str); - var_dump($d); - var_dump(DateTime::getLastErrors()); + list($format, $str) = $test; + var_dump($format, $str); + $d = DateTime::createFromFormat($format, $str); + var_dump($d); + var_dump(DateTime::getLastErrors()); - echo "\n\n"; + echo "\n\n"; } --EXPECTF-- string(5) "Y-m-d" diff --git a/ext/date/tests/bug52808.phpt b/ext/date/tests/bug52808.phpt index 810874858f6a..10776923c094 100644 --- a/ext/date/tests/bug52808.phpt +++ b/ext/date/tests/bug52808.phpt @@ -4,22 +4,22 @@ Bug #52808 (Segfault when specifying interval as two dates) getMessage(), "\n"; + echo $e->getMessage(), "\n"; } } echo "==DONE==\n"; diff --git a/ext/date/tests/bug53437_var4.phpt b/ext/date/tests/bug53437_var4.phpt index 753401539a8e..b53483ab7fa2 100644 --- a/ext/date/tests/bug53437_var4.phpt +++ b/ext/date/tests/bug53437_var4.phpt @@ -9,15 +9,15 @@ $dt = new DateTime('2009-10-11'); $df = $dt->diff(new DateTime('2009-10-13')); var_dump($df, - $df->y, - $df->m, - $df->d, - $df->h, - $df->i, - $df->s, - $df->f, - $df->invert, - $df->days); + $df->y, + $df->m, + $df->d, + $df->h, + $df->i, + $df->s, + $df->f, + $df->invert, + $df->days); ?> --EXPECTF-- diff --git a/ext/date/tests/bug54283.phpt b/ext/date/tests/bug54283.phpt index 9a8a07ce5ab5..65669b6b39b7 100644 --- a/ext/date/tests/bug54283.phpt +++ b/ext/date/tests/bug54283.phpt @@ -4,9 +4,9 @@ Bug #54283 (new DatePeriod(NULL) causes crash) getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/date/tests/bug61642.phpt b/ext/date/tests/bug61642.phpt index 872ceb4f3e06..b8130f05aa20 100644 --- a/ext/date/tests/bug61642.phpt +++ b/ext/date/tests/bug61642.phpt @@ -12,26 +12,26 @@ $dates = array('2012-03-29', '2012-03-30', '2012-03-31', '2012-04-01', '2012-04- $header = array(); foreach ($dates as $startdate) { - $date = new DateTime($startdate); + $date = new DateTime($startdate); - $header[] = $date->format('Y-m-d D'); + $header[] = $date->format('Y-m-d D'); } echo '### ', implode(' ', $header), "\n\n"; foreach ($weekdays as $days) { - $line = array(); + $line = array(); - printf('%+3d ', $days); + printf('%+3d ', $days); - foreach ($dates as $startdate) { - $date = new DateTime($startdate); - $date->modify("{$days} weekdays"); + foreach ($dates as $startdate) { + $date = new DateTime($startdate); + $date->modify("{$days} weekdays"); - $line[] = $date->format('Y-m-d D'); - } + $line[] = $date->format('Y-m-d D'); + } - echo implode(' ', $line), "\n"; + echo implode(' ', $line), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/bug63391.phpt b/ext/date/tests/bug63391.phpt index a29d25e73065..58da985e08e6 100644 --- a/ext/date/tests/bug63391.phpt +++ b/ext/date/tests/bug63391.phpt @@ -8,7 +8,7 @@ print "Date PHP\n"; print "---------- ---\n"; $dates = array('1599-12-30', '1599-12-31', '1600-01-01', '1600-01-02'); foreach ($dates as $date) { - echo date_create($date)->format('Y-m-d D'), "\n"; + echo date_create($date)->format('Y-m-d D'), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/bug63435.phpt b/ext/date/tests/bug63435.phpt index dcec6e46e7f2..9dbc2fda1297 100644 --- a/ext/date/tests/bug63435.phpt +++ b/ext/date/tests/bug63435.phpt @@ -5,11 +5,11 @@ date.timezone=UTC --FILE-- format("u"); - if ($res != $i) { - echo "$i != $res\n"; - } + $datetime = Datetime::createFromFormat("u", sprintf("%06ld", $i)); + $res = $datetime->format("u"); + if ($res != $i) { + echo "$i != $res\n"; + } } echo "Done"; --EXPECT-- diff --git a/ext/date/tests/bug63740.phpt b/ext/date/tests/bug63740.phpt index 18c5a57d7740..d0056987cd0b 100644 --- a/ext/date/tests/bug63740.phpt +++ b/ext/date/tests/bug63740.phpt @@ -3,28 +3,28 @@ Bug #63740 (strtotime seems to use both sunday and monday as start of week) --FILE-- format( "D Y-m-d H:i" ), " → "; + echo $dt->format( "D Y-m-d H:i" ), " → "; - $dtn = $dt->modify( "this week" ); + $dtn = $dt->modify( "this week" ); - echo $dtn->format( "D Y-m-d H:i" ), "\n"; + echo $dtn->format( "D Y-m-d H:i" ), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/bug64887.phpt b/ext/date/tests/bug64887.phpt index dba1921eac1d..52c5e0fa8dc2 100644 --- a/ext/date/tests/bug64887.phpt +++ b/ext/date/tests/bug64887.phpt @@ -5,28 +5,28 @@ date.timezone=UTC --FILE-- modify( $test )->format( 'Y-m-d H:i:s.u' ), "\n"; + echo $datetime->modify( $test )->format( 'Y-m-d H:i:s.u' ), "\n"; } ?> diff --git a/ext/date/tests/bug65184.phpt b/ext/date/tests/bug65184.phpt index 62c41652bbf9..30a24f249360 100644 --- a/ext/date/tests/bug65184.phpt +++ b/ext/date/tests/bug65184.phpt @@ -10,16 +10,16 @@ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { date.timezone = UTC --FILE-- --EXPECT-- 90 85 97 6a 93 fa diff --git a/ext/date/tests/bug66985.phpt b/ext/date/tests/bug66985.phpt index 37dcd3e80d4a..2bcf97cb370d 100644 --- a/ext/date/tests/bug66985.phpt +++ b/ext/date/tests/bug66985.phpt @@ -3,18 +3,18 @@ Bug #66985 (Some timezones are no longer valid in PHP 5.5.10) --FILE-- --EXPECT-- diff --git a/ext/date/tests/bug67118.phpt b/ext/date/tests/bug67118.phpt index 5a7d2d1d076f..ee1d8efc0aa3 100644 --- a/ext/date/tests/bug67118.phpt +++ b/ext/date/tests/bug67118.phpt @@ -6,17 +6,17 @@ date.timezone=Europe/Berlin format("Y") . "\n"; - } - } + public function __construct($time = 'now', $tz = NULL, $format = NULL) + { + if (!empty($tz) && !is_object($tz)) { + $tz = new DateTimeZone($tz); + } + try { + @parent::__construct($time, $tz); + } catch (Exception $e) { + echo "Bad date" . $this->format("Y") . "\n"; + } + } }; diff --git a/ext/date/tests/bug72096.phpt b/ext/date/tests/bug72096.phpt index 1a4a21928705..4256102944dd 100644 --- a/ext/date/tests/bug72096.phpt +++ b/ext/date/tests/bug72096.phpt @@ -5,8 +5,8 @@ date.timezone=UTC --FILE-- --EXPECT-- diff --git a/ext/date/tests/bug73294.phpt b/ext/date/tests/bug73294.phpt index 493ba92dd6a0..af13cdaf40c0 100644 --- a/ext/date/tests/bug73294.phpt +++ b/ext/date/tests/bug73294.phpt @@ -4,17 +4,17 @@ Bug #73294: DateTime wrong when date string is negative format('Y-m-d H:i:s'); + $dt = new DateTime("{$i}-{$M}-{$D} 00:00:00"); + $expected = "{$i}-{$M}-{$D} 00:00:00"; + $result = $dt->format('Y-m-d H:i:s'); - if ( $expected != $result ) - { - echo "Wrong: Should have been {$expected}, was {$result}\n"; - } + if ( $expected != $result ) + { + echo "Wrong: Should have been {$expected}, was {$result}\n"; + } } ?> ==DONE== diff --git a/ext/date/tests/bug73837.phpt b/ext/date/tests/bug73837.phpt index b14feecd9326..c11aa2c56bfa 100644 --- a/ext/date/tests/bug73837.phpt +++ b/ext/date/tests/bug73837.phpt @@ -6,9 +6,9 @@ $collect = []; for ( $i = 0; $i < 1000; $i++ ) { - $a = new DateTime(); - $key = "s" . $a->format( "u" ); - $collect[$key] = true; + $a = new DateTime(); + $key = "s" . $a->format( "u" ); + $collect[$key] = true; } var_dump($n = count( $collect )); diff --git a/ext/date/tests/bug74652.phpt b/ext/date/tests/bug74652.phpt index 029464be4c15..3cff8beab039 100644 --- a/ext/date/tests/bug74652.phpt +++ b/ext/date/tests/bug74652.phpt @@ -5,19 +5,19 @@ date.timezone=UTC --FILE-- format( 'Y-m-d H:i:s' ), "\n"; + $dt = new DateTimeImmutable( $format ); + echo $dt->format( 'Y-m-d H:i:s' ), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/bug75002.phpt b/ext/date/tests/bug75002.phpt index b10e0ebe00ca..5c3085f316ae 100644 --- a/ext/date/tests/bug75002.phpt +++ b/ext/date/tests/bug75002.phpt @@ -4,13 +4,13 @@ Bug #75002 Null Pointer Dereference in timelib_time_clone diff --git a/ext/date/tests/date-time-modify-times.phpt b/ext/date/tests/date-time-modify-times.phpt index 85e0b4fdc0f2..4f26275c88de 100644 --- a/ext/date/tests/date-time-modify-times.phpt +++ b/ext/date/tests/date-time-modify-times.phpt @@ -5,31 +5,31 @@ date.timezone=Europe/London --FILE-- array( - 'october 23:00', // October 23rd, with a broken time - 'back of 4pm', - 'next week monday', - 'next week monday 10am', - 'tuesday noon', - 'first monday of January 2011', - 'first monday of January 2011 09:00', - ), - '2010-12-15 19:42:45' => array( - 'october 23:00', // October 23rd, with a broken time - 'march 28, 00:15', - 'march 28, 01:15', // doesn't exist because of DST - 'march 28, 02:15', - ), + '2010-12-15 19:42:45 UTC' => array( + 'october 23:00', // October 23rd, with a broken time + 'back of 4pm', + 'next week monday', + 'next week monday 10am', + 'tuesday noon', + 'first monday of January 2011', + 'first monday of January 2011 09:00', + ), + '2010-12-15 19:42:45' => array( + 'october 23:00', // October 23rd, with a broken time + 'march 28, 00:15', + 'march 28, 01:15', // doesn't exist because of DST + 'march 28, 02:15', + ), ); foreach ( $tests as $start => $data ) { - foreach ( $data as $test ) - { - echo date_create( $start ) - ->modify( $test ) - ->format( DateTime::RFC2822 ), "\n"; - } + foreach ( $data as $test ) + { + echo date_create( $start ) + ->modify( $test ) + ->format( DateTime::RFC2822 ), "\n"; + } } echo "\n"; ?> diff --git a/ext/date/tests/date.phpt b/ext/date/tests/date.phpt index 12bc9f0fcefb..6a371ee001a4 100644 --- a/ext/date/tests/date.phpt +++ b/ext/date/tests/date.phpt @@ -6,13 +6,13 @@ $tmp = "cr"; date_default_timezone_set('UTC'); for($a = 0;$a < strlen($tmp); $a++){ - echo $tmp[$a], ': ', date($tmp[$a], 1043324459)."\n"; + echo $tmp[$a], ': ', date($tmp[$a], 1043324459)."\n"; } date_default_timezone_set("MET"); for($a = 0;$a < strlen($tmp); $a++){ - echo $tmp[$a], ': ', date($tmp[$a], 1043324459)."\n"; + echo $tmp[$a], ': ', date($tmp[$a], 1043324459)."\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/date_add_basic.phpt b/ext/date/tests/date_add_basic.phpt index 6bfc55f8f45b..fe5c7e9c192c 100644 --- a/ext/date/tests/date_add_basic.phpt +++ b/ext/date/tests/date_add_basic.phpt @@ -17,18 +17,18 @@ echo "*** Testing date_add() : basic functionality ***\n"; $startDate = '2008-01-01 12:25'; $format = 'Y-m-d H:i:s'; $intervals = array( - 'P3Y6M4DT12H30M5S', - 'P0D', - 'P2DT1M', - 'P1Y2MT23H43M150S' + 'P3Y6M4DT12H30M5S', + 'P0D', + 'P2DT1M', + 'P1Y2MT23H43M150S' ); $d = new DateTime($startDate); var_dump( $d->format($format) ); foreach($intervals as $interval) { - date_add($d, new DateInterval($interval) ); - var_dump( $d->format($format) ); + date_add($d, new DateInterval($interval) ); + var_dump( $d->format($format) ); } ?> diff --git a/ext/date/tests/date_create-1.phpt b/ext/date/tests/date_create-1.phpt index 4b156de6e47c..aad2f3f9e242 100644 --- a/ext/date/tests/date_create-1.phpt +++ b/ext/date/tests/date_create-1.phpt @@ -26,7 +26,7 @@ $d[] = date_create("2005-07-14 22:30:41 Europe/Oslo", $tz1); $d[] = date_create("2005-07-14 22:30:41 America/Los_Angeles", $tz2); foreach($d as $date) { - echo $date->format(DateTime::ISO8601), "\n"; + echo $date->format(DateTime::ISO8601), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/date_create-relative.phpt b/ext/date/tests/date_create-relative.phpt index 5d2a4196e93b..02861242caf6 100644 --- a/ext/date/tests/date_create-relative.phpt +++ b/ext/date/tests/date_create-relative.phpt @@ -6,47 +6,47 @@ date_create() with large relative offsets date_default_timezone_set('UTC'); if (!defined('PHP_INT_MIN')) { - define('PHP_INT_MIN', intval(-PHP_INT_MAX - 1)); + define('PHP_INT_MIN', intval(-PHP_INT_MAX - 1)); } $base_time = '28 Feb 2008 12:00:00'; // Most offsets tested in strtotime-relative.phpt. These are tests for dates outside the 32-bit range. $offsets = array( - // around 10 leap year periods (4000 years) in days - '1460000 days', - '1460969 days', - '1460970 days', - '1460971 days', - '1462970 days', + // around 10 leap year periods (4000 years) in days + '1460000 days', + '1460969 days', + '1460970 days', + '1460971 days', + '1462970 days', - // around 1 leap year period in years - '398 years', - '399 years', - '400 years', - '401 years', + // around 1 leap year period in years + '398 years', + '399 years', + '400 years', + '401 years', - // around 40000 years - '39755 years', - '39999 years', - '40000 years', - '40001 years', - '41010 years', + // around 40000 years + '39755 years', + '39999 years', + '40000 years', + '40001 years', + '41010 years', - // bigger than int (32-bit) - '10000000000 seconds', - '10000000000 minutes', - '10000000000 hours', - '10000000000 days', - '10000000000 months', - '10000000000 years', + // bigger than int (32-bit) + '10000000000 seconds', + '10000000000 minutes', + '10000000000 hours', + '10000000000 days', + '10000000000 months', + '10000000000 years', ); foreach ($offsets AS $offset) { - foreach (array('+', '-') AS $direction) { - $dt = date_create("$base_time $direction$offset"); - echo "$direction$offset: " . date_format($dt, DATE_ISO8601) . "\n"; - } + foreach (array('+', '-') AS $direction) { + $dt = date_create("$base_time $direction$offset"); + echo "$direction$offset: " . date_format($dt, DATE_ISO8601) . "\n"; + } } ?> diff --git a/ext/date/tests/date_default_timezone_get-1.phpt b/ext/date/tests/date_default_timezone_get-1.phpt index ba0607643bbf..32c066c1ca7c 100644 --- a/ext/date/tests/date_default_timezone_get-1.phpt +++ b/ext/date/tests/date_default_timezone_get-1.phpt @@ -8,9 +8,9 @@ date_default_timezone_get() function [1] date.timezone= --FILE-- --EXPECT-- UTC diff --git a/ext/date/tests/date_default_timezone_get-2.phpt b/ext/date/tests/date_default_timezone_get-2.phpt index 5c835c35f3b1..cf7478c90b50 100644 --- a/ext/date/tests/date_default_timezone_get-2.phpt +++ b/ext/date/tests/date_default_timezone_get-2.phpt @@ -8,8 +8,8 @@ date_default_timezone_get() function [2] date.timezone= --FILE-- --EXPECT-- UTC diff --git a/ext/date/tests/date_default_timezone_get-3.phpt b/ext/date/tests/date_default_timezone_get-3.phpt index ffc882e6f684..6e9818724e25 100644 --- a/ext/date/tests/date_default_timezone_get-3.phpt +++ b/ext/date/tests/date_default_timezone_get-3.phpt @@ -4,10 +4,10 @@ date_default_timezone_get() function [3] date.timezone=Europe/Rome --FILE-- --EXPECT-- Europe/Rome diff --git a/ext/date/tests/date_default_timezone_get-4.phpt b/ext/date/tests/date_default_timezone_get-4.phpt index 6d1982bc13d1..f2319856d8ee 100644 --- a/ext/date/tests/date_default_timezone_get-4.phpt +++ b/ext/date/tests/date_default_timezone_get-4.phpt @@ -4,7 +4,7 @@ date_default_timezone_get() function [4] date.timezone=Incorrect/Zone --FILE-- --EXPECTF-- Warning: date_default_timezone_get(): Invalid date.timezone value 'Incorrect/Zone', we selected the timezone 'UTC' for now. in %sdate_default_timezone_get-4.php on line %d diff --git a/ext/date/tests/date_default_timezone_set-1.phpt b/ext/date/tests/date_default_timezone_set-1.phpt index 7e7ba7972f6c..54f1fa73f3b0 100644 --- a/ext/date/tests/date_default_timezone_set-1.phpt +++ b/ext/date/tests/date_default_timezone_set-1.phpt @@ -8,18 +8,18 @@ if (substr(PHP_OS, 0, 3) == 'WIN') die('skip diff TZ detection on windows.'); date.timezone= --FILE-- --EXPECT-- America/Indiana/Knox diff --git a/ext/date/tests/date_diff.phpt b/ext/date/tests/date_diff.phpt index e01a94e76791..d5cc58271c51 100644 --- a/ext/date/tests/date_diff.phpt +++ b/ext/date/tests/date_diff.phpt @@ -13,48 +13,48 @@ define( 'COUNT', 120 ); $d0 = new DateTime('2009-11-20'); for ( $i = 0; $i < COUNT * 12; $i++ ) { - $d = clone $d0; - $dates[$i] = $d->add( new DateInterval( "P{$i}D" ) ); + $d = clone $d0; + $dates[$i] = $d->add( new DateInterval( "P{$i}D" ) ); } for ( $i = 0; $i < COUNT; $i++) { // echo $dates[$i]->format( "Y-m-d\n" ); - for ( $j = 0; $j < COUNT * 12; $j++) - { - $diff = date_diff( $dates[$i], $dates[$j] ); - /* - printf( "\t%s %s %3d %s\n", - $dates[$i]->format( 'Y-m-d' ), - $dates[$j]->format( 'Y-m-d' ), - $diff->format( '%a' ), - $diff->format( '%y-%m-%d' ) - ); - */ + for ( $j = 0; $j < COUNT * 12; $j++) + { + $diff = date_diff( $dates[$i], $dates[$j] ); + /* + printf( "\t%s %s %3d %s\n", + $dates[$i]->format( 'Y-m-d' ), + $dates[$j]->format( 'Y-m-d' ), + $diff->format( '%a' ), + $diff->format( '%y-%m-%d' ) + ); + */ - $current = clone $dates[$i]; - $int = new DateInterval( $diff->format( 'P%yY%mM%dD' ) ); - if ( $current > $dates[$j] ) - { - $current->sub( $int ); - } - else - { - $current->add( $int ); - } - if ( $current != $dates[$j] ) - { - echo "FAIL: ", - $dates[$i]->format( 'Y-m-d' ), " + ", - $int->format( '%y-%m-%d' ), " = ", - $current->format( 'Y-m-d' ), " (", - $dates[$j]->format( 'Y-m-d' ), ")\n"; - } - else - { - $ok++; - } - } + $current = clone $dates[$i]; + $int = new DateInterval( $diff->format( 'P%yY%mM%dD' ) ); + if ( $current > $dates[$j] ) + { + $current->sub( $int ); + } + else + { + $current->add( $int ); + } + if ( $current != $dates[$j] ) + { + echo "FAIL: ", + $dates[$i]->format( 'Y-m-d' ), " + ", + $int->format( '%y-%m-%d' ), " = ", + $current->format( 'Y-m-d' ), " (", + $dates[$j]->format( 'Y-m-d' ), ")\n"; + } + else + { + $ok++; + } + } } echo $ok, "\n"; diff --git a/ext/date/tests/date_interval_prop_dim.phpt b/ext/date/tests/date_interval_prop_dim.phpt index 3f9af6f47219..5d33badebed7 100644 --- a/ext/date/tests/date_interval_prop_dim.phpt +++ b/ext/date/tests/date_interval_prop_dim.phpt @@ -7,8 +7,8 @@ $z = new Z('P2Y4DT6H8M'); $i = 0; $z->prop[1]=10; while ($i < 1026) { - $z->prop[$i] = $i; - $i++; + $z->prop[$i] = $i; + $i++; } ?> ==NOCRASH== diff --git a/ext/date/tests/date_period-immutable.phpt b/ext/date/tests/date_period-immutable.phpt index 0ec4b4a13025..accc1dc0a35c 100644 --- a/ext/date/tests/date_period-immutable.phpt +++ b/ext/date/tests/date_period-immutable.phpt @@ -10,18 +10,18 @@ $di = DateInterval::createFromDateString( 'first day of next month' ); foreach ( new DatePeriod( $db1, $di, $de ) as $dt ) { - echo get_class( $dt ), "\n"; - echo $dt->format( "l Y-m-d\n" ); + echo get_class( $dt ), "\n"; + echo $dt->format( "l Y-m-d\n" ); echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" ); - echo $dt->format( "l Y-m-d\n\n" ); + echo $dt->format( "l Y-m-d\n\n" ); } foreach ( new DatePeriod( $db2, $di, $de ) as $dt ) { - echo get_class( $dt ), "\n"; - echo $dt->format( "l Y-m-d\n" ); + echo get_class( $dt ), "\n"; + echo $dt->format( "l Y-m-d\n" ); echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" ); - echo $dt->format( "l Y-m-d\n\n" ); + echo $dt->format( "l Y-m-d\n\n" ); } ?> --EXPECT-- diff --git a/ext/date/tests/date_sub_basic.phpt b/ext/date/tests/date_sub_basic.phpt index eb8aeb5eb2a2..fc93919d52de 100644 --- a/ext/date/tests/date_sub_basic.phpt +++ b/ext/date/tests/date_sub_basic.phpt @@ -17,18 +17,18 @@ echo "*** Testing date_sub() : basic functionality ***\n"; $startDate = '2008-01-01 12:25'; $format = 'Y-m-d H:i:s'; $intervals = array( - 'P3Y6M4DT12H30M5S', - 'P0D', - 'P2DT1M', - 'P1Y2MT23H43M150S' + 'P3Y6M4DT12H30M5S', + 'P0D', + 'P2DT1M', + 'P1Y2MT23H43M150S' ); $d = new DateTime($startDate); var_dump( $d->format($format) ); foreach($intervals as $interval) { - date_sub($d, new DateInterval($interval) ); - var_dump( $d->format($format) ); + date_sub($d, new DateInterval($interval) ); + var_dump( $d->format($format) ); } ?> diff --git a/ext/date/tests/date_sun_info_002.phpt b/ext/date/tests/date_sun_info_002.phpt index f74f1c88def0..1ff58295e31e 100644 --- a/ext/date/tests/date_sun_info_002.phpt +++ b/ext/date/tests/date_sun_info_002.phpt @@ -6,7 +6,7 @@ date_default_timezone_set('Europe/Oslo'); $sun_info = date_sun_info(strtotime("2007-04-13 08:31:15 UTC"), 59.21, 9.61); foreach ($sun_info as $key => $elem ) { - echo date( 'Y-m-d H:i:s T', $elem ), " ", $key, "\n"; + echo date( 'Y-m-d H:i:s T', $elem ), " ", $key, "\n"; } echo "Done\n"; ?> diff --git a/ext/date/tests/date_sunrise_variation7.phpt b/ext/date/tests/date_sunrise_variation7.phpt index 90d3e2833396..9d92d1b58f3f 100644 --- a/ext/date/tests/date_sunrise_variation7.phpt +++ b/ext/date/tests/date_sunrise_variation7.phpt @@ -12,24 +12,24 @@ echo "*** Testing date_sunrise() : usage variation ***\n"; //Timezones with required data for date_sunrise $inputs = array ( - //Timezone with Latitude, Longitude and GMT offset - "Pacific/Samoa" => array ("Latitude" => -14.24, "Longitude" => -170.72, "GMT" => -11), - "US/Alaska" => array ("Latitude" => 61, "Longitude" => -150 , "GMT" => -9), - "America/Chicago" => array ("Latitude" => 41.85, "Longitude" => -87.65 , "GMT" => -5), - "America/Montevideo" => array ("Latitude" => -34.88, "Longitude" => -56.18 , "GMT" => -3), - "Africa/Casablanca" => array ("Latitude" => 33.65, "Longitude" => -7.58, "GMT" => 0), - "Europe/Moscow" => array ("Latitude" => 55.75, "Longitude" => 37.58, "GMT" => 4), - "Asia/Hong_Kong" => array ("Latitude" => 22.28, "Longitude" => 114.15 , "GMT" => 8), - "Australia/Brisbane" => array ("Latitude" => -27.46, "Longitude" => 153.2 , "GMT" => 10), - "Pacific/Wallis" => array ("Latitude" => -13.3, "Longitude" => -176.16, "GMT" => 12), + //Timezone with Latitude, Longitude and GMT offset + "Pacific/Samoa" => array ("Latitude" => -14.24, "Longitude" => -170.72, "GMT" => -11), + "US/Alaska" => array ("Latitude" => 61, "Longitude" => -150 , "GMT" => -9), + "America/Chicago" => array ("Latitude" => 41.85, "Longitude" => -87.65 , "GMT" => -5), + "America/Montevideo" => array ("Latitude" => -34.88, "Longitude" => -56.18 , "GMT" => -3), + "Africa/Casablanca" => array ("Latitude" => 33.65, "Longitude" => -7.58, "GMT" => 0), + "Europe/Moscow" => array ("Latitude" => 55.75, "Longitude" => 37.58, "GMT" => 4), + "Asia/Hong_Kong" => array ("Latitude" => 22.28, "Longitude" => 114.15 , "GMT" => 8), + "Australia/Brisbane" => array ("Latitude" => -27.46, "Longitude" => 153.2 , "GMT" => 10), + "Pacific/Wallis" => array ("Latitude" => -13.3, "Longitude" => -176.16, "GMT" => 12), ); foreach($inputs as $timezone => $value) { - date_default_timezone_set($timezone); - $time = mktime(8, 8, 8, 8, 11, 2008); - var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"] )); - $time = mktime(8, 8, 8, 8, 12, 2008); - var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"]) ); + date_default_timezone_set($timezone); + $time = mktime(8, 8, 8, 8, 11, 2008); + var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"] )); + $time = mktime(8, 8, 8, 8, 12, 2008); + var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"]) ); } ?> diff --git a/ext/date/tests/date_sunrise_variation8.phpt b/ext/date/tests/date_sunrise_variation8.phpt index 6b115c32189c..d866e3ed7b23 100644 --- a/ext/date/tests/date_sunrise_variation8.phpt +++ b/ext/date/tests/date_sunrise_variation8.phpt @@ -14,24 +14,24 @@ echo "*** Testing date_sunrise() : usage variation ***\n"; date_default_timezone_set("Africa/Casablanca"); $time_date = array ( - //Date at which Sun is up all day at North Pole - "12 Aug 2008" => mktime(8, 8, 8, 8, 12, 2008), - "13 Aug 2008" => mktime(8, 8, 8, 8, 13, 2008), + //Date at which Sun is up all day at North Pole + "12 Aug 2008" => mktime(8, 8, 8, 8, 12, 2008), + "13 Aug 2008" => mktime(8, 8, 8, 8, 13, 2008), - //Date at which Sun is up all day at South Pole - "12 Nov 2008" => mktime(8, 8, 8, 11, 12, 2008), - "13 Nov 2008" => mktime(8, 8, 8, 11, 13, 2008), + //Date at which Sun is up all day at South Pole + "12 Nov 2008" => mktime(8, 8, 8, 11, 12, 2008), + "13 Nov 2008" => mktime(8, 8, 8, 11, 13, 2008), ); //Iterate over different date and time foreach( $time_date as $date => $time ){ - echo "\n--$date--\n"; - var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, 90, 0 ) ); - var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, 90, 0 ) ); - var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, 90, 0 ) ); - var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, -90, 0 ) ); - var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, -90, 0 ) ); - var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, -90, 0 ) ); + echo "\n--$date--\n"; + var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, 90, 0 ) ); + var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, 90, 0 ) ); + var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, 90, 0 ) ); + var_dump( date_sunrise($time, SUNFUNCS_RET_STRING, -90, 0 ) ); + var_dump( date_sunrise($time, SUNFUNCS_RET_DOUBLE, -90, 0 ) ); + var_dump( date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, -90, 0 ) ); } ?> diff --git a/ext/date/tests/date_sunset_variation7.phpt b/ext/date/tests/date_sunset_variation7.phpt index 3d51a0ca26d7..380e466c0dd4 100644 --- a/ext/date/tests/date_sunset_variation7.phpt +++ b/ext/date/tests/date_sunset_variation7.phpt @@ -12,25 +12,25 @@ echo "*** Testing date_sunset() : usage variation ***\n"; //Timezones with required data for date_sunrise $inputs = array ( - //Timezone with Latitude, Longitude and GMT offset - "Pacific/Samoa" => array ("Latitude" => -14.24, "Longitude" => -170.72, "GMT" => -11), - "US/Alaska" => array ("Latitude" => 61, "Longitude" => -150 , "GMT" => -9), - "America/Chicago" => array ("Latitude" => 41.85, "Longitude" => -87.65 , "GMT" => -5), - "America/Montevideo" => array ("Latitude" => -34.88, "Longitude" => -56.18 , "GMT" => -3), - "Africa/Casablanca" => array ("Latitude" => 33.65, "Longitude" => "-7.58", "GMT" => 0), - "Europe/Moscow" => array ("Latitude" => 55.75, "Longitude" => 37.58, "GMT" => 4), - "Asia/Hong_Kong" => array ("Latitude" => 22.28, "Longitude" => 114.15 , "GMT" => 8), - "Australia/Brisbane" => array ("Latitude" => -27.46, "Longitude" => 153.2 , "GMT" => 10), - "Pacific/Wallis" => array ("Latitude" => -13.3, "Longitude" => -176.16, "GMT" => 12), + //Timezone with Latitude, Longitude and GMT offset + "Pacific/Samoa" => array ("Latitude" => -14.24, "Longitude" => -170.72, "GMT" => -11), + "US/Alaska" => array ("Latitude" => 61, "Longitude" => -150 , "GMT" => -9), + "America/Chicago" => array ("Latitude" => 41.85, "Longitude" => -87.65 , "GMT" => -5), + "America/Montevideo" => array ("Latitude" => -34.88, "Longitude" => -56.18 , "GMT" => -3), + "Africa/Casablanca" => array ("Latitude" => 33.65, "Longitude" => "-7.58", "GMT" => 0), + "Europe/Moscow" => array ("Latitude" => 55.75, "Longitude" => 37.58, "GMT" => 4), + "Asia/Hong_Kong" => array ("Latitude" => 22.28, "Longitude" => 114.15 , "GMT" => 8), + "Australia/Brisbane" => array ("Latitude" => -27.46, "Longitude" => 153.2 , "GMT" => 10), + "Pacific/Wallis" => array ("Latitude" => -13.3, "Longitude" => -176.16, "GMT" => 12), ); foreach($inputs as $timezone => $value) { - echo "\n--$timezone--\n"; - date_default_timezone_set($timezone); - $time = mktime(8, 8, 8, 8, 11, 2008); - var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"] )); - $time = mktime(8, 8, 8, 8, 12, 2008); - var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"]) ); + echo "\n--$timezone--\n"; + date_default_timezone_set($timezone); + $time = mktime(8, 8, 8, 8, 11, 2008); + var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"] )); + $time = mktime(8, 8, 8, 8, 12, 2008); + var_dump( date_sunset($time, SUNFUNCS_RET_STRING, $value["Latitude"], $value["Longitude"], 90, $value["GMT"]) ); } ?> --EXPECT-- diff --git a/ext/date/tests/date_sunset_variation8.phpt b/ext/date/tests/date_sunset_variation8.phpt index 7470a04c07c7..a5f6794f62d1 100644 --- a/ext/date/tests/date_sunset_variation8.phpt +++ b/ext/date/tests/date_sunset_variation8.phpt @@ -14,24 +14,24 @@ echo "*** Testing date_sunset() : usage variation ***\n"; date_default_timezone_set("Africa/Casablanca"); $time_date = array ( - //Date at which Sun is up all day at North Pole - "12 Aug 2008" => mktime(8, 8, 8, 8, 12, 2008), - "13 Aug 2008" => mktime(8, 8, 8, 8, 13, 2008), + //Date at which Sun is up all day at North Pole + "12 Aug 2008" => mktime(8, 8, 8, 8, 12, 2008), + "13 Aug 2008" => mktime(8, 8, 8, 8, 13, 2008), - //Date at which Sun is up all day at South Pole - "12 Nov 2008" => mktime(8, 8, 8, 11, 12, 2008), - "13 Nov 2008" => mktime(8, 8, 8, 11, 13, 2008), + //Date at which Sun is up all day at South Pole + "12 Nov 2008" => mktime(8, 8, 8, 11, 12, 2008), + "13 Nov 2008" => mktime(8, 8, 8, 11, 13, 2008), ); //Iterate over different date and time foreach( $time_date as $date => $time ){ - echo "\n--$date--\n"; - var_dump( date_sunset($time, SUNFUNCS_RET_STRING, 90, 0 ) ); - var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, 90, 0 ) ); - var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, 90, 0 ) ); - var_dump( date_sunset($time, SUNFUNCS_RET_STRING, -90, 0 ) ); - var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, -90, 0 ) ); - var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, -90, 0 ) ); + echo "\n--$date--\n"; + var_dump( date_sunset($time, SUNFUNCS_RET_STRING, 90, 0 ) ); + var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, 90, 0 ) ); + var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, 90, 0 ) ); + var_dump( date_sunset($time, SUNFUNCS_RET_STRING, -90, 0 ) ); + var_dump( date_sunset($time, SUNFUNCS_RET_DOUBLE, -90, 0 ) ); + var_dump( date_sunset($time, SUNFUNCS_RET_TIMESTAMP, -90, 0 ) ); } ?> diff --git a/ext/date/tests/date_time_immutable.phpt b/ext/date/tests/date_time_immutable.phpt index b4a576570e22..a7e0348288fa 100644 --- a/ext/date/tests/date_time_immutable.phpt +++ b/ext/date/tests/date_time_immutable.phpt @@ -9,9 +9,9 @@ $current = "2012-12-27 16:24:08"; function dump($a, $b, $c) { - echo 'orig: ', $a->format('Y-m-d H:i:s e'), "\n"; - echo 'copy: ', $b->format('Y-m-d H:i:s e'), "\n"; - echo 'changed: ', $c->format('Y-m-d H:i:s e'), "\n"; + echo 'orig: ', $a->format('Y-m-d H:i:s e'), "\n"; + echo 'copy: ', $b->format('Y-m-d H:i:s e'), "\n"; + echo 'changed: ', $c->format('Y-m-d H:i:s e'), "\n"; } echo "modify():\n"; diff --git a/ext/date/tests/default-timezone-1.phpt b/ext/date/tests/default-timezone-1.phpt index a53d370afbc8..6435f85c4298 100644 --- a/ext/date/tests/default-timezone-1.phpt +++ b/ext/date/tests/default-timezone-1.phpt @@ -3,8 +3,8 @@ date.timezone setting [1] --FILE-- --EXPECT-- 1119132944 diff --git a/ext/date/tests/default-timezone-2.phpt b/ext/date/tests/default-timezone-2.phpt index b414eb2af3f5..722334038896 100644 --- a/ext/date/tests/default-timezone-2.phpt +++ b/ext/date/tests/default-timezone-2.phpt @@ -3,8 +3,8 @@ date.timezone setting [2] --FILE-- --EXPECT-- 1119125744 diff --git a/ext/date/tests/examine_diff.inc b/ext/date/tests/examine_diff.inc index c3dcba93884f..8c305f1d36ee 100644 --- a/ext/date/tests/examine_diff.inc +++ b/ext/date/tests/examine_diff.inc @@ -33,47 +33,47 @@ define('PHPT_DATETIME_SHOW_SUB', 4); * @return void */ function examine_diff($end_date, $start_date, $expect_spec, $expect_days, $absolute = false) { - if (is_string($start_date)) { - $start = new DateTime($start_date); - } else { - $start = $start_date; - } - $start_date = $start->format('Y-m-d H:i:s T'); + if (is_string($start_date)) { + $start = new DateTime($start_date); + } else { + $start = $start_date; + } + $start_date = $start->format('Y-m-d H:i:s T'); - if (is_string($end_date)) { - $end = new DateTime($end_date); - } else { - $end = $end_date; - } - $end_date = $end->format('Y-m-d H:i:s T'); + if (is_string($end_date)) { + $end = new DateTime($end_date); + } else { + $end = $end_date; + } + $end_date = $end->format('Y-m-d H:i:s T'); - $expect_interval = new DateInterval('P' . substr($expect_spec, 2)); - if (substr($expect_spec, 1, 1) == '-') { - $expect_interval->invert = true; - } + $expect_interval = new DateInterval('P' . substr($expect_spec, 2)); + if (substr($expect_spec, 1, 1) == '-') { + $expect_interval->invert = true; + } - if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_DIFF) { - $result_interval = $start->diff($end, $absolute); - $result_spec = $result_interval->format('P%R%yY%mM%dDT%hH%iM%sS'); - echo "DIFF: $end_date - $start_date = **$result_spec**\n"; - // echo "DIFF: $end_date - $start_date = **$expect_spec**\n"; - } - if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_DAYS) { - $result_interval = $start->diff($end, $absolute); - $result_days = $result_interval->format('%a'); - echo "DAYS: **$result_days**\n"; - // echo "DAYS: **$expect_days**\n"; - } - if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_ADD) { - $start->add($expect_interval); - $result_end_date = $start->format('Y-m-d H:i:s T'); - echo "ADD: $start_date + $expect_spec = **$result_end_date**\n"; - // echo "ADD: $start_date + $expect_spec = **$end_date**\n"; - } - if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_SUB) { - $end->sub($expect_interval); - $result_start_date = $end->format('Y-m-d H:i:s T'); - echo "SUB: $end_date - $expect_spec = **$result_start_date**\n"; - // echo "SUB: $end_date - $expect_spec = **$start_date**\n"; - } + if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_DIFF) { + $result_interval = $start->diff($end, $absolute); + $result_spec = $result_interval->format('P%R%yY%mM%dDT%hH%iM%sS'); + echo "DIFF: $end_date - $start_date = **$result_spec**\n"; + // echo "DIFF: $end_date - $start_date = **$expect_spec**\n"; + } + if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_DAYS) { + $result_interval = $start->diff($end, $absolute); + $result_days = $result_interval->format('%a'); + echo "DAYS: **$result_days**\n"; + // echo "DAYS: **$expect_days**\n"; + } + if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_ADD) { + $start->add($expect_interval); + $result_end_date = $start->format('Y-m-d H:i:s T'); + echo "ADD: $start_date + $expect_spec = **$result_end_date**\n"; + // echo "ADD: $start_date + $expect_spec = **$end_date**\n"; + } + if (PHPT_DATETIME_SHOW == PHPT_DATETIME_SHOW_SUB) { + $end->sub($expect_interval); + $result_start_date = $end->format('Y-m-d H:i:s T'); + echo "SUB: $end_date - $expect_spec = **$result_start_date**\n"; + // echo "SUB: $end_date - $expect_spec = **$start_date**\n"; + } } diff --git a/ext/date/tests/format-negative-timestamp.phpt b/ext/date/tests/format-negative-timestamp.phpt index 5fd6a65897b6..d8268ddc6804 100644 --- a/ext/date/tests/format-negative-timestamp.phpt +++ b/ext/date/tests/format-negative-timestamp.phpt @@ -9,13 +9,13 @@ $max = getrandmax(); $max_2 = $max / 2; while($i--) { - $new_tm = rand(1, $max); - if ($new_tm > $max_2) - $new_tm *= -1; + $new_tm = rand(1, $max); + if ($new_tm > $max_2) + $new_tm *= -1; - if (strtotime("@$new_tm") != $new_tm) { - echo "Error when parsing: @$new_tm\n"; - } + if (strtotime("@$new_tm") != $new_tm) { + echo "Error when parsing: @$new_tm\n"; + } } echo "done!"; diff --git a/ext/date/tests/getdate_variation2.phpt b/ext/date/tests/getdate_variation2.phpt index 0d4cb114cdc5..2081e31762e6 100644 --- a/ext/date/tests/getdate_variation2.phpt +++ b/ext/date/tests/getdate_variation2.phpt @@ -16,10 +16,10 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - //octal values - 'octal 05' => 05, - 'octal 010' => 010, - 'octal -010' => -010, + //octal values + 'octal 05' => 05, + 'octal 010' => 010, + 'octal -010' => -010, ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/getdate_variation3.phpt b/ext/date/tests/getdate_variation3.phpt index 1c4891ee6ba7..ebcc3bf23fd6 100644 --- a/ext/date/tests/getdate_variation3.phpt +++ b/ext/date/tests/getdate_variation3.phpt @@ -16,10 +16,10 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - //octal values - 'hexadcimal 0x5' => 0x5, - 'hexadcimal 0xCAFE' => 0xCAFE, - 'octal -0xCAFE' => -0xCAFE, + //octal values + 'hexadcimal 0x5' => 0x5, + 'hexadcimal 0xCAFE' => 0xCAFE, + 'octal -0xCAFE' => -0xCAFE, ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/getdate_variation4.phpt b/ext/date/tests/getdate_variation4.phpt index b2b0019204c8..48bcc1fd8d28 100644 --- a/ext/date/tests/getdate_variation4.phpt +++ b/ext/date/tests/getdate_variation4.phpt @@ -16,11 +16,11 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - //Year wise time stamps - '01 Jan 1970' => 0, - '01 Jan 1971' => 31536000, - '01 Jan 1972' => 63072000, - '01 Jan 1973' => 94694400, + //Year wise time stamps + '01 Jan 1970' => 0, + '01 Jan 1971' => 31536000, + '01 Jan 1972' => 63072000, + '01 Jan 1973' => 94694400, ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/getdate_variation5.phpt b/ext/date/tests/getdate_variation5.phpt index 2bd00ac3a757..8c61c5bb61d1 100644 --- a/ext/date/tests/getdate_variation5.phpt +++ b/ext/date/tests/getdate_variation5.phpt @@ -12,20 +12,20 @@ echo "*** Testing getdate() : usage variation ***\n"; //Timezones with required data for date_sunrise $inputs = array ( - //GMT-11 - "Pacific/Samoa", - //GMT-9 - "US/Alaska", - //GMT-0 - "Africa/Casablanca", - //GMT+4 - "Europe/Moscow", - //GMT+8 - "Asia/Hong_Kong", - //GMT+10 - "Australia/Brisbane", - //GMT+12 - "Pacific/Wallis", + //GMT-11 + "Pacific/Samoa", + //GMT-9 + "US/Alaska", + //GMT-0 + "Africa/Casablanca", + //GMT+4 + "Europe/Moscow", + //GMT+8 + "Asia/Hong_Kong", + //GMT+10 + "Australia/Brisbane", + //GMT+12 + "Pacific/Wallis", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/getdate_variation6.phpt b/ext/date/tests/getdate_variation6.phpt index cb7ca9a9a391..e5a98ac1a64d 100644 --- a/ext/date/tests/getdate_variation6.phpt +++ b/ext/date/tests/getdate_variation6.phpt @@ -14,9 +14,9 @@ date_default_timezone_set("Asia/Calcutta"); //Timezones with required data for date_sunrise $inputs = array ( - 'String 0' => '0', - 'String 10.5' => "10.5", - 'String -10.5' => '-10.5', + 'String 0' => '0', + 'String 10.5' => "10.5", + 'String -10.5' => '-10.5', ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmdate_variation13.phpt b/ext/date/tests/gmdate_variation13.phpt index 17b4f43b05d6..877671b9260c 100644 --- a/ext/date/tests/gmdate_variation13.phpt +++ b/ext/date/tests/gmdate_variation13.phpt @@ -17,22 +17,22 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); $inputs = array( // Predefined Date constants 'DATE_ATOM Constant' => DATE_ATOM, - 'DATE_COOKIE Constant' => DATE_COOKIE, - 'DATE_RFC822 Constant' => DATE_RFC822, - 'DATE_RFC850 Constant' => DATE_RFC850, - 'DATE_RFC1036 Constant' => DATE_RFC1036, - 'DATE_RFC1123 Constant' => DATE_RFC1123, - 'DATE_RFC2822 Constant' => DATE_RFC2822, - 'DATE_RFC3339 Constant' => DATE_RFC3339, - 'DATE_RSS Constant' => DATE_RSS, - 'DATE_W3C Constant' => DATE_W3C, + 'DATE_COOKIE Constant' => DATE_COOKIE, + 'DATE_RFC822 Constant' => DATE_RFC822, + 'DATE_RFC850 Constant' => DATE_RFC850, + 'DATE_RFC1036 Constant' => DATE_RFC1036, + 'DATE_RFC1123 Constant' => DATE_RFC1123, + 'DATE_RFC2822 Constant' => DATE_RFC2822, + 'DATE_RFC3339 Constant' => DATE_RFC3339, + 'DATE_RSS Constant' => DATE_RSS, + 'DATE_W3C Constant' => DATE_W3C, ); // loop through each element of the array for format foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( gmdate($value, $timestamp) ); - var_dump( gmdate($value) ); + var_dump( gmdate($value, $timestamp) ); + var_dump( gmdate($value) ); }; ?> diff --git a/ext/date/tests/gmdate_variation3.phpt b/ext/date/tests/gmdate_variation3.phpt index bc3ce652be81..c9ee7654761b 100644 --- a/ext/date/tests/gmdate_variation3.phpt +++ b/ext/date/tests/gmdate_variation3.phpt @@ -17,11 +17,11 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Day with leading zeros' => 'd', - 'Day without leading zeros' => 'j', - 'ISO representation' => 'N', - 'Numeric representation of day' => 'w', - 'Day of the year' => 'z' + 'Day with leading zeros' => 'd', + 'Day without leading zeros' => 'j', + 'ISO representation' => 'N', + 'Numeric representation of day' => 'w', + 'Day of the year' => 'z' ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmdate_variation9.phpt b/ext/date/tests/gmdate_variation9.phpt index 17eb1df80694..cd43217d0891 100644 --- a/ext/date/tests/gmdate_variation9.phpt +++ b/ext/date/tests/gmdate_variation9.phpt @@ -17,21 +17,21 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); $time_formats = array( 'Lowercase Ante meridiem and post meridiem' => 'a', - 'Uppercase Ante meridiem and post meridiem' => 'a', - 'Swatch Internet time' => 'B', - '12-hour format without leading zeros' => 'g', - '24-hour format without leading zeros' => 'G', - '12-hour format with leading zeros' => 'h', - '24-hour format with leading zeros' => 'H', - 'Minutes with leading zeros' => 'i', - 'Seconds with leading zeros' => 's', - 'Milliseconds' => 'u', + 'Uppercase Ante meridiem and post meridiem' => 'a', + 'Swatch Internet time' => 'B', + '12-hour format without leading zeros' => 'g', + '24-hour format without leading zeros' => 'G', + '12-hour format with leading zeros' => 'h', + '24-hour format with leading zeros' => 'H', + 'Minutes with leading zeros' => 'i', + 'Seconds with leading zeros' => 's', + 'Milliseconds' => 'u', ); foreach($time_formats as $key =>$value) { echo "\n--$key--\n"; - var_dump( gmdate($value) ); - var_dump( gmdate($value, $timestamp) ); + var_dump( gmdate($value) ); + var_dump( gmdate($value, $timestamp) ); } ?> diff --git a/ext/date/tests/gmmktime_variation9.phpt b/ext/date/tests/gmmktime_variation9.phpt index 549b9d88fafc..40c4d3a39d3a 100644 --- a/ext/date/tests/gmmktime_variation9.phpt +++ b/ext/date/tests/gmmktime_variation9.phpt @@ -20,7 +20,7 @@ $year = 2008; $inputs = array( - 'float 123456' => 123456, + 'float 123456' => 123456, 'float -123456' => -123456, 'float -10.5' => -10.5, ); @@ -28,11 +28,11 @@ $inputs = array( // loop through each element of the array for min foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) ); - var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) ); - var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) ); - var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) ); - var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) ); + var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) ); + var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) ); + var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) ); + var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) ); + var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) ); } ?> --EXPECTREGEX-- diff --git a/ext/date/tests/gmstrftime_variation10.phpt b/ext/date/tests/gmstrftime_variation10.phpt index 842490ab4f20..b20a3ecbe7d5 100644 --- a/ext/date/tests/gmstrftime_variation10.phpt +++ b/ext/date/tests/gmstrftime_variation10.phpt @@ -23,8 +23,8 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'The ISO 8601:1988 week number' => "%V", - 'Weekday as decimal' => "%u", + 'The ISO 8601:1988 week number' => "%V", + 'Weekday as decimal' => "%u", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation13.phpt b/ext/date/tests/gmstrftime_variation13.phpt index ef2026d56236..a237e9dc8b6f 100644 --- a/ext/date/tests/gmstrftime_variation13.phpt +++ b/ext/date/tests/gmstrftime_variation13.phpt @@ -17,10 +17,10 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Century number' => "%C", - 'Month Date Year' => "%D", - 'Year with century' => "%G", - 'Year without century' => "%g", + 'Century number' => "%C", + 'Month Date Year' => "%D", + 'Year with century' => "%G", + 'Year without century' => "%g", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation14.phpt b/ext/date/tests/gmstrftime_variation14.phpt index eb774af09bc6..c53f5ea2f0eb 100644 --- a/ext/date/tests/gmstrftime_variation14.phpt +++ b/ext/date/tests/gmstrftime_variation14.phpt @@ -23,10 +23,10 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Century number' => "%C", - 'Month Date Year' => "%D", - 'Year with century' => "%G", - 'Year without century' => "%g", + 'Century number' => "%C", + 'Month Date Year' => "%D", + 'Year with century' => "%G", + 'Year without century' => "%g", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation15.phpt b/ext/date/tests/gmstrftime_variation15.phpt index cc956a9ba1d0..02907f846cb7 100644 --- a/ext/date/tests/gmstrftime_variation15.phpt +++ b/ext/date/tests/gmstrftime_variation15.phpt @@ -17,9 +17,9 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Time in a.m/p.m notation' => "%r", - 'Time in 24 hour notation' => "%R", - 'Current time %H:%M:%S format' => "%T", + 'Time in a.m/p.m notation' => "%r", + 'Time in 24 hour notation' => "%R", + 'Current time %H:%M:%S format' => "%T", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation16.phpt b/ext/date/tests/gmstrftime_variation16.phpt index 2f2018579381..74be81747a17 100644 --- a/ext/date/tests/gmstrftime_variation16.phpt +++ b/ext/date/tests/gmstrftime_variation16.phpt @@ -23,9 +23,9 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Time in a.m/p.m notation' => "%r", - 'Time in 24 hour notation' => "%R", - 'Current time %H:%M:%S format' => "%T", + 'Time in a.m/p.m notation' => "%r", + 'Time in 24 hour notation' => "%R", + 'Current time %H:%M:%S format' => "%T", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation19.phpt b/ext/date/tests/gmstrftime_variation19.phpt index 9c84901acf75..8dc692392331 100644 --- a/ext/date/tests/gmstrftime_variation19.phpt +++ b/ext/date/tests/gmstrftime_variation19.phpt @@ -17,8 +17,8 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Newline character' => "%n", - 'Tab character' => "%t" + 'Newline character' => "%n", + 'Tab character' => "%t" ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation20.phpt b/ext/date/tests/gmstrftime_variation20.phpt index 12be1e8b1fe4..2c6ab0236422 100644 --- a/ext/date/tests/gmstrftime_variation20.phpt +++ b/ext/date/tests/gmstrftime_variation20.phpt @@ -23,8 +23,8 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Newline character' => "%n", - 'Tab character' => "%t" + 'Newline character' => "%n", + 'Tab character' => "%t" ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation21.phpt b/ext/date/tests/gmstrftime_variation21.phpt index 840e467ea739..9ffbf82b24f1 100644 --- a/ext/date/tests/gmstrftime_variation21.phpt +++ b/ext/date/tests/gmstrftime_variation21.phpt @@ -18,8 +18,8 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( 'Preferred date and time representation' => "%c", - 'Preferred date representation' => "%x", - 'Preferred time representation' => "%X", + 'Preferred date representation' => "%x", + 'Preferred time representation' => "%X", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation22.phpt b/ext/date/tests/gmstrftime_variation22.phpt index 207a77db98d5..e90725422793 100644 --- a/ext/date/tests/gmstrftime_variation22.phpt +++ b/ext/date/tests/gmstrftime_variation22.phpt @@ -28,8 +28,8 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( 'Preferred date and time representation' => "%c", - 'Preferred date representation' => "%x", - 'Preferred time representation' => "%X", + 'Preferred date representation' => "%x", + 'Preferred time representation' => "%X", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation3.phpt b/ext/date/tests/gmstrftime_variation3.phpt index fc4120c8ec19..b33e543e12dd 100644 --- a/ext/date/tests/gmstrftime_variation3.phpt +++ b/ext/date/tests/gmstrftime_variation3.phpt @@ -17,8 +17,8 @@ $timestamp = gmmktime(8, 8, 8, 8, 8, 2008); $inputs = array( 'Abbreviated weekday name' => "%a", 'Full weekday name' => "%A", - 'Week number of the year' => "%U", - 'Week number of the year in decimal number' => "%W", + 'Week number of the year' => "%U", + 'Week number of the year in decimal number' => "%W", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation4.phpt b/ext/date/tests/gmstrftime_variation4.phpt index daf35af5ab8f..97ffb8f75f3c 100644 --- a/ext/date/tests/gmstrftime_variation4.phpt +++ b/ext/date/tests/gmstrftime_variation4.phpt @@ -17,7 +17,7 @@ $timestamp = gmmktime(8, 8, 8, 8, 8, 2008); $inputs = array( 'Abbreviated month name' => "%b", 'Full month name' => "%B", - 'Month as decimal' => "%m", + 'Month as decimal' => "%m", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation5.phpt b/ext/date/tests/gmstrftime_variation5.phpt index 7a8f58713f5a..ca4c9e5e6466 100644 --- a/ext/date/tests/gmstrftime_variation5.phpt +++ b/ext/date/tests/gmstrftime_variation5.phpt @@ -18,10 +18,10 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Year as decimal number without a century' => "%y", - 'Year as decimal number including the century' => "%Y", - 'Time zone offset' => "%Z", - 'Time zone offset' => "%z", + 'Year as decimal number without a century' => "%y", + 'Year as decimal number including the century' => "%Y", + 'Time zone offset' => "%Z", + 'Time zone offset' => "%z", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation6.phpt b/ext/date/tests/gmstrftime_variation6.phpt index 055cf2362c95..a00d27af5c8b 100644 --- a/ext/date/tests/gmstrftime_variation6.phpt +++ b/ext/date/tests/gmstrftime_variation6.phpt @@ -17,11 +17,11 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Hour as decimal by 24-hour format' => "%H", - 'Hour as decimal by 12-hour format' => "%I", - 'Minute as decimal number' => "%M", - 'AM/PM format for a time' => "%p", - 'Second as decimal number' => "%S", + 'Hour as decimal by 24-hour format' => "%H", + 'Hour as decimal by 12-hour format' => "%I", + 'Minute as decimal number' => "%M", + 'AM/PM format for a time' => "%p", + 'Second as decimal number' => "%S", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation7.phpt b/ext/date/tests/gmstrftime_variation7.phpt index 5a1a70024a16..4f2c5876f24a 100644 --- a/ext/date/tests/gmstrftime_variation7.phpt +++ b/ext/date/tests/gmstrftime_variation7.phpt @@ -17,9 +17,9 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Day of the month as a decimal number' => "%d", - 'Day of the year as a decimal number' => "%j", - 'Day of the week as a decimal number' => "%w" + 'Day of the month as a decimal number' => "%d", + 'Day of the year as a decimal number' => "%j", + 'Day of the week as a decimal number' => "%w" ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation8.phpt b/ext/date/tests/gmstrftime_variation8.phpt index c78218352771..26ba201039e9 100644 --- a/ext/date/tests/gmstrftime_variation8.phpt +++ b/ext/date/tests/gmstrftime_variation8.phpt @@ -17,7 +17,7 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'A literal % character' => "%%", + 'A literal % character' => "%%", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/gmstrftime_variation9.phpt b/ext/date/tests/gmstrftime_variation9.phpt index dbc3f47f9414..a6910675dc04 100644 --- a/ext/date/tests/gmstrftime_variation9.phpt +++ b/ext/date/tests/gmstrftime_variation9.phpt @@ -17,8 +17,8 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'The ISO 8601:1988 week number' => "%V", - 'Weekday as decimal' => "%u", + 'The ISO 8601:1988 week number' => "%V", + 'Weekday as decimal' => "%u", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/idate_variation4.phpt b/ext/date/tests/idate_variation4.phpt index 4f95e7bd8b53..8d928c9d5671 100644 --- a/ext/date/tests/idate_variation4.phpt +++ b/ext/date/tests/idate_variation4.phpt @@ -16,15 +16,15 @@ date_default_timezone_set("Asia/Calcutta"); //array of values to iterate over $inputs = array( - 'Day of the month' => 'd', - 'Leap Year' =>'L', - 'Month number' => 'm', - 'Days in the month' => 't', - 'Day of the week' => 'w', - 'ISO-8601 week number' => 'W', - 'Year (1 or 2 digits)' => 'y', - 'Year 4 digits' => 'Y', - 'Day of the year' => 'z', + 'Day of the month' => 'd', + 'Leap Year' =>'L', + 'Month number' => 'm', + 'Days in the month' => 't', + 'Day of the week' => 'w', + 'ISO-8601 week number' => 'W', + 'Year (1 or 2 digits)' => 'y', + 'Year 4 digits' => 'Y', + 'Day of the year' => 'z', ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/idate_variation5.phpt b/ext/date/tests/idate_variation5.phpt index b72f7274d796..246e5f38a041 100644 --- a/ext/date/tests/idate_variation5.phpt +++ b/ext/date/tests/idate_variation5.phpt @@ -17,13 +17,13 @@ date_default_timezone_set("Asia/Calcutta"); $inputs = array( 'Internet Time' => 'B', - '12 hour format' => 'h', - '24 hour format' => 'H', - 'Minutes' => 'i', - 'DST Activated' => 'I', - 'Seconds' => 's', - 'Seconds since Unix Epoch' => 'U', - 'Time zone offset' => 'Z' + '12 hour format' => 'h', + '24 hour format' => 'H', + 'Minutes' => 'i', + 'DST Activated' => 'I', + 'Seconds' => 's', + 'Seconds since Unix Epoch' => 'U', + 'Time zone offset' => 'Z' ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/localtime_variation4.phpt b/ext/date/tests/localtime_variation4.phpt index d5062ee6a1af..089854730244 100644 --- a/ext/date/tests/localtime_variation4.phpt +++ b/ext/date/tests/localtime_variation4.phpt @@ -19,14 +19,14 @@ $is_associative = true; $inputs = array( 'Octal 0' => 00, - 'Octal 10' => 012, - 'Octal -10' => -012 + 'Octal 10' => 012, + 'Octal -10' => -012 ); foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( localtime($value) ); - var_dump( localtime($value, $is_associative) ); + var_dump( localtime($value) ); + var_dump( localtime($value, $is_associative) ); } ?> diff --git a/ext/date/tests/localtime_variation5.phpt b/ext/date/tests/localtime_variation5.phpt index 3e974e2d88bc..b7d9e1ae6305 100644 --- a/ext/date/tests/localtime_variation5.phpt +++ b/ext/date/tests/localtime_variation5.phpt @@ -19,14 +19,14 @@ $is_associative = true; $inputs = array( 'Hexa-decimal 0' => 0x0, - 'Hexa-decimal 10' => 0xA, - 'Hexa-decimal -10' => -0XA + 'Hexa-decimal 10' => 0xA, + 'Hexa-decimal -10' => -0XA ); foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( localtime($value) ); - var_dump( localtime($value, $is_associative) ); + var_dump( localtime($value) ); + var_dump( localtime($value, $is_associative) ); } ?> diff --git a/ext/date/tests/microtime_error.phpt b/ext/date/tests/microtime_error.phpt index 151bead6def2..0736d3cf2499 100644 --- a/ext/date/tests/microtime_error.phpt +++ b/ext/date/tests/microtime_error.phpt @@ -10,19 +10,19 @@ Test wrong number of arguments for microtime() echo "\n-- Bad Arg types --\n"; $bad_args = array(null, - 1.5, - "hello", - array('k'=>'v', array(0)), - new stdClass, - 1); + 1.5, + "hello", + array('k'=>'v', array(0)), + new stdClass, + 1); foreach ($bad_args as $bad_arg) { - echo "\n--> bad arg: "; - var_dump($bad_arg); - try { - var_dump(microtime($bad_arg)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } + echo "\n--> bad arg: "; + var_dump($bad_arg); + try { + var_dump(microtime($bad_arg)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } } ?> diff --git a/ext/date/tests/mktime-3-64bit.phpt b/ext/date/tests/mktime-3-64bit.phpt index f415cbf2d6c5..5d06f9393f6a 100644 --- a/ext/date/tests/mktime-3-64bit.phpt +++ b/ext/date/tests/mktime-3-64bit.phpt @@ -10,18 +10,18 @@ $tzs = array("America/Toronto", "Europe/Oslo"); $years = array(0, 69, 70, 71, 99, 100, 101, 105, 110, 1900, 1901, 1902, 1999, 2000, 2001); foreach ($tzs as $tz) { - echo $tz, "\n"; - date_default_timezone_set($tz); - foreach ($years as $year) { - printf("Y: %4d - ", $year); - $ret = mktime(1, 1, 1, 1, 1, $year); - if ($ret == FALSE) { - echo "out of range\n"; - } else { - echo date("F ".DATE_ISO8601, $ret), "\n"; - } - } - echo "\n"; + echo $tz, "\n"; + date_default_timezone_set($tz); + foreach ($years as $year) { + printf("Y: %4d - ", $year); + $ret = mktime(1, 1, 1, 1, 1, $year); + if ($ret == FALSE) { + echo "out of range\n"; + } else { + echo date("F ".DATE_ISO8601, $ret), "\n"; + } + } + echo "\n"; } ?> --EXPECTF-- diff --git a/ext/date/tests/mktime-3.phpt b/ext/date/tests/mktime-3.phpt index de60a6eba0c4..b054efd076ef 100644 --- a/ext/date/tests/mktime-3.phpt +++ b/ext/date/tests/mktime-3.phpt @@ -10,18 +10,18 @@ $tzs = array("America/Toronto", "Europe/Oslo"); $years = array(0, 69, 70, 71, 99, 100, 105, 1900, 1901, 1902, 1999, 2000, 2001); foreach ($tzs as $tz) { - echo $tz, "\n"; - date_default_timezone_set($tz); - foreach ($years as $year) { - printf("Y: %4d - ", $year); - $ret = mktime(1, 1, 1, 1, 1, $year); - if ($ret == FALSE) { - echo "out of range\n"; - } else { - echo date("F ".DATE_ISO8601, $ret), "\n"; - } - } - echo "\n"; + echo $tz, "\n"; + date_default_timezone_set($tz); + foreach ($years as $year) { + printf("Y: %4d - ", $year); + $ret = mktime(1, 1, 1, 1, 1, $year); + if ($ret == FALSE) { + echo "out of range\n"; + } else { + echo date("F ".DATE_ISO8601, $ret), "\n"; + } + } + echo "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/oo_001.phpt b/ext/date/tests/oo_001.phpt index 111364ec8336..1d8af7f933b2 100644 --- a/ext/date/tests/oo_001.phpt +++ b/ext/date/tests/oo_001.phpt @@ -4,12 +4,12 @@ date OO interface format("Y-m-d H:i:s")); } catch (Error $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } try { - new DateTime("1am todax"); + new DateTime("1am todax"); } catch (Exception $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } $t = new DateTimeZone("UTC"); @@ -35,13 +35,13 @@ try { $t = new _t; var_dump($t->getName()); } catch (Error $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } try { - new DateTimeZone("GottaFindThisOne"); + new DateTimeZone("GottaFindThisOne"); } catch (Exception $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } echo "DONE\n"; diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt index c297608913a3..4c92f4618dc0 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt @@ -16,37 +16,37 @@ $interval_format = 'P%dDT%hH'; $end = new DateTime('2010-03-14 03:00:00 -0400'); $start = new DateTime('2010-03-14 01:59:59 -0500'); echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; + . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; $end = new DateTime('2010-03-14 04:30:00 -0400'); $start = new DateTime('2010-03-13 04:30:00 -0500'); echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 -0400'); $start = new DateTime('2010-03-13 04:30:00 -0500'); echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 -0500'); $start = new DateTime('2010-03-13 04:30:00 -0500'); echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 -0500'); $start = new DateTime('2010-03-13 01:30:00 -0500'); echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 -0400'); $start = new DateTime('2010-03-13 03:30:00 -0500'); echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 -0400'); $start = new DateTime('2010-03-13 02:30:00 -0500'); echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; echo "\n"; @@ -58,37 +58,37 @@ $start = new DateTime('2010-03-14 01:59:59 -0500'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00 -0500'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00 -0500'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 01:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 02:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; echo "\n"; @@ -100,43 +100,43 @@ $end = new DateTime('2010-03-14 03:00:00 -0400'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 04:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 -0400'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 -0500'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-15 03:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-15 02:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; echo "\n"; @@ -147,42 +147,42 @@ echo "\n"; $end = new DateTime('2010-11-07 01:00:00 -0500'); $start = new DateTime('2010-11-07 01:59:59 -0400'); echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; + . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; $end = new DateTime('2010-11-07 04:30:00 -0500'); $start = new DateTime('2010-11-06 04:30:00 -0400'); echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00 -0500'); $start = new DateTime('2010-11-06 04:30:00 -0400'); echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00 -0500'); $start = new DateTime('2010-11-06 04:30:00 -0400'); echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0500'); $start = new DateTime('2010-11-06 04:30:00 -0400'); echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0400'); $start = new DateTime('2010-11-06 04:30:00 -0400'); echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0400'); $start = new DateTime('2010-11-06 01:30:00 -0400'); echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0500'); $start = new DateTime('2010-11-06 01:30:00 -0400'); echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; echo "\n"; @@ -194,67 +194,67 @@ $start = new DateTime('2010-11-07 01:59:59 -0400'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 -0400'); $interval_spec = 'PT24H'; $interval = new DateInterval($interval_spec); echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 -0400'); $interval_spec = 'PT23H'; $interval = new DateInterval($interval_spec); echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 -0400'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 -0400'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 01:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 01:30:00 -0400'); $interval_spec = 'P1DT1H'; $interval = new DateInterval($interval_spec); echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 -0400'); $interval_spec = 'PT25H'; $interval = new DateInterval($interval_spec); echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 03:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 02:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; echo "\n"; @@ -266,61 +266,61 @@ $end = new DateTime('2010-11-07 01:00:00 -0500'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 04:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00 -0500'); $interval_spec = 'PT24H'; $interval = new DateInterval($interval_spec); echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00 -0500'); $interval_spec = 'PT23H'; $interval = new DateInterval($interval_spec); echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0500'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0400'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0400'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 -0500'); $interval_spec = 'P1DT1H'; $interval = new DateInterval($interval_spec); echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00 -0500'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; ?> --EXPECT-- diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt index 72585125ea6d..d969f72a0038 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt @@ -16,37 +16,37 @@ $interval_format = 'P%dDT%hH'; $end = new DateTime('2010-03-14 03:00:00 EDT'); $start = new DateTime('2010-03-14 01:59:59 EST'); echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; + . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; $end = new DateTime('2010-03-14 04:30:00 EDT'); $start = new DateTime('2010-03-13 04:30:00 EST'); echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 EDT'); $start = new DateTime('2010-03-13 04:30:00 EST'); echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 EST'); $start = new DateTime('2010-03-13 04:30:00 EST'); echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 EST'); $start = new DateTime('2010-03-13 01:30:00 EST'); echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 EDT'); $start = new DateTime('2010-03-13 03:30:00 EST'); echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 EDT'); $start = new DateTime('2010-03-13 02:30:00 EST'); echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; echo "\n"; @@ -58,37 +58,37 @@ $start = new DateTime('2010-03-14 01:59:59 EST'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00 EST'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00 EST'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 01:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 02:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; echo "\n"; @@ -100,43 +100,43 @@ $end = new DateTime('2010-03-14 03:00:00 EDT'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 04:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00 EDT'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 EST'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-15 03:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-15 02:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; echo "\n"; @@ -147,42 +147,42 @@ echo "\n"; $end = new DateTime('2010-11-07 01:00:00 EST'); $start = new DateTime('2010-11-07 01:59:59 EDT'); echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; + . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; $end = new DateTime('2010-11-07 04:30:00 EST'); $start = new DateTime('2010-11-06 04:30:00 EDT'); echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00 EST'); $start = new DateTime('2010-11-06 04:30:00 EDT'); echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00 EST'); $start = new DateTime('2010-11-06 04:30:00 EDT'); echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $start = new DateTime('2010-11-06 04:30:00 EDT'); echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EDT'); $start = new DateTime('2010-11-06 04:30:00 EDT'); echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EDT'); $start = new DateTime('2010-11-06 01:30:00 EDT'); echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $start = new DateTime('2010-11-06 01:30:00 EDT'); echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; echo "\n"; @@ -194,67 +194,67 @@ $start = new DateTime('2010-11-07 01:59:59 EDT'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 EDT'); $interval_spec = 'PT24H'; $interval = new DateInterval($interval_spec); echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 EDT'); $interval_spec = 'PT23H'; $interval = new DateInterval($interval_spec); echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 EDT'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 EDT'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 01:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 01:30:00 EDT'); $interval_spec = 'P1DT1H'; $interval = new DateInterval($interval_spec); echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00 EDT'); $interval_spec = 'PT25H'; $interval = new DateInterval($interval_spec); echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 03:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 02:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; echo "\n"; @@ -266,61 +266,61 @@ $end = new DateTime('2010-11-07 01:00:00 EST'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 04:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00 EST'); $interval_spec = 'PT24H'; $interval = new DateInterval($interval_spec); echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00 EST'); $interval_spec = 'PT23H'; $interval = new DateInterval($interval_spec); echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EDT'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EDT'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $interval_spec = 'P1DT1H'; $interval = new DateInterval($interval_spec); echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00 EST'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; ?> --EXPECT-- diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt index fdbe96d7d08c..0326b4382418 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt @@ -17,67 +17,67 @@ $start = new DateTime('2010-11-07 01:59:59'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00'); $interval_spec = 'PT24H'; $interval = new DateInterval($interval_spec); echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00'); $interval_spec = 'PT23H'; $interval = new DateInterval($interval_spec); echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 01:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 01:30:00'); $interval_spec = 'P1DT1H'; $interval = new DateInterval($interval_spec); echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 04:30:00'); $interval_spec = 'PT25H'; $interval = new DateInterval($interval_spec); echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 03:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-11-06 02:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; echo "\n"; diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt index 824959993197..8222e75f15a1 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt @@ -16,27 +16,27 @@ $interval_format = 'P%dDT%hH'; $end = new DateTime('2010-11-07 05:30:00'); $start = new DateTime('2010-11-06 04:30:00'); echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 04:30:00'); $start = new DateTime('2010-11-06 04:30:00'); echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00'); $start = new DateTime('2010-11-06 04:30:00'); echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00'); $start = new DateTime('2010-11-06 04:30:00'); echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00'); $start = new DateTime('2010-11-06 01:30:00'); echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; echo "\n"; ?> diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt index fe2e79b3b9d6..80e3321ed6a1 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt @@ -27,25 +27,25 @@ $end = new DateTime('2010-11-07 05:30:00'); $end->setTimeZone($tz); $start = new DateTime('2010-11-06 04:30:59'); echo 'bd0 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format('P%dDT%hH%iM%sS') . "\n"; + . ' = ' . $start->diff($end)->format('P%dDT%hH%iM%sS') . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $end->setTimeZone($tz); $start = new DateTime('2010-11-06 04:30:00'); echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EDT'); $end->setTimeZone($tz); $start = new DateTime('2010-11-06 04:30:00'); echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $end->setTimeZone($tz); $start = new DateTime('2010-11-06 01:30:00'); echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; echo "\n"; ?> diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt index 138c68f3a9b4..d195cb2f758a 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt @@ -19,64 +19,64 @@ $end->setTimeZone($tz); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 04:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00'); $interval_spec = 'PT24H'; $interval = new DateInterval($interval_spec); echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00'); $interval_spec = 'PT23H'; $interval = new DateInterval($interval_spec); echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $end->setTimeZone($tz); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EDT'); $end->setTimeZone($tz); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 01:30:00 EST'); $end->setTimeZone($tz); $interval_spec = 'P1DT1H'; $interval = new DateInterval($interval_spec); echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 03:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-11-07 02:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; ?> --EXPECT-- diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt index 9fa493f578c8..df67b5a89db7 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt @@ -17,37 +17,37 @@ $start = new DateTime('2010-03-14 01:59:59'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 04:30:00'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 01:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; $start = new DateTime('2010-03-13 02:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = " - . $start->add($interval)->format($date_format) . "\n"; + . $start->add($interval)->format($date_format) . "\n"; ?> --EXPECT-- fa1 2010-03-14 01:59:59 EST America/New_York + PT1S = 2010-03-14 03:00:00 EDT America/New_York diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt index ae7060be0b3a..1a60f7b57b84 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt @@ -16,37 +16,37 @@ $interval_format = 'P%dDT%hH'; $end = new DateTime('2010-03-14 03:00:00'); $start = new DateTime('2010-03-14 01:59:59'); echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; + . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n"; $end = new DateTime('2010-03-14 04:30:00'); $start = new DateTime('2010-03-13 04:30:00'); echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00'); $start = new DateTime('2010-03-13 04:30:00'); echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00'); $start = new DateTime('2010-03-13 04:30:00'); echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00'); $start = new DateTime('2010-03-13 01:30:00'); echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00'); $start = new DateTime('2010-03-13 03:30:00'); echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00'); $start = new DateTime('2010-03-13 02:30:00'); echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format) - . ' = ' . $start->diff($end)->format($interval_format) . "\n"; + . ' = ' . $start->diff($end)->format($interval_format) . "\n"; ?> --EXPECT-- fd1 2010-03-14 03:00:00 EDT America/New_York - 2010-03-14 01:59:59 EST America/New_York = PT0H0M1S diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt index 72351d37e158..aa1c2687045c 100644 --- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt +++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt @@ -19,43 +19,43 @@ $end = new DateTime('2010-03-14 03:00:00'); $interval_spec = 'PT1S'; $interval = new DateInterval($interval_spec); echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 04:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 03:30:00'); $interval_spec = 'PT22H'; $interval = new DateInterval($interval_spec); echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00'); $interval_spec = 'PT21H'; $interval = new DateInterval($interval_spec); echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-14 01:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-15 03:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; $end = new DateTime('2010-03-15 02:30:00'); $interval_spec = 'P1D'; $interval = new DateInterval($interval_spec); echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = " - . $end->sub($interval)->format($date_format) . "\n"; + . $end->sub($interval)->format($date_format) . "\n"; ?> --EXPECT-- fs1 2010-03-14 03:00:00 EDT America/New_York - PT1S = 2010-03-14 01:59:59 EST America/New_York diff --git a/ext/date/tests/strftime_variation10.phpt b/ext/date/tests/strftime_variation10.phpt index 79f99370daa7..108dcffc54f3 100644 --- a/ext/date/tests/strftime_variation10.phpt +++ b/ext/date/tests/strftime_variation10.phpt @@ -23,16 +23,16 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'The ISO 8601:1988 week number' => "%V", - 'Weekday as decimal' => "%u", + 'The ISO 8601:1988 week number' => "%V", + 'Weekday as decimal' => "%u", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { - echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + echo "\n--$key--\n"; + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation13.phpt b/ext/date/tests/strftime_variation13.phpt index 59aef31c298e..0ebfa5502d1a 100644 --- a/ext/date/tests/strftime_variation13.phpt +++ b/ext/date/tests/strftime_variation13.phpt @@ -17,18 +17,18 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Century number' => "%C", - 'Month Date Year' => "%D", - 'Year with century' => "%G", - 'Year without century' => "%g", + 'Century number' => "%C", + 'Month Date Year' => "%D", + 'Year with century' => "%G", + 'Year without century' => "%g", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation14.phpt b/ext/date/tests/strftime_variation14.phpt index eff0389174de..b209d91adf33 100644 --- a/ext/date/tests/strftime_variation14.phpt +++ b/ext/date/tests/strftime_variation14.phpt @@ -23,18 +23,18 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Century number' => "%C", - 'Month Date Year' => "%D", - 'Year with century' => "%G", - 'Year without century' => "%g", + 'Century number' => "%C", + 'Month Date Year' => "%D", + 'Year with century' => "%G", + 'Year without century' => "%g", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation15.phpt b/ext/date/tests/strftime_variation15.phpt index 301cafc01884..38826b65289e 100644 --- a/ext/date/tests/strftime_variation15.phpt +++ b/ext/date/tests/strftime_variation15.phpt @@ -17,17 +17,17 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Time in a.m/p.m notation' => "%r", - 'Time in 24 hour notation' => "%R", - 'Current time %H:%M:%S format' => "%T", + 'Time in a.m/p.m notation' => "%r", + 'Time in 24 hour notation' => "%R", + 'Current time %H:%M:%S format' => "%T", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation16.phpt b/ext/date/tests/strftime_variation16.phpt index 2d0b40a57ea0..5791c128385a 100644 --- a/ext/date/tests/strftime_variation16.phpt +++ b/ext/date/tests/strftime_variation16.phpt @@ -23,17 +23,17 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Time in a.m/p.m notation' => "%r", - 'Time in 24 hour notation' => "%R", - 'Current time %H:%M:%S format' => "%T", + 'Time in a.m/p.m notation' => "%r", + 'Time in 24 hour notation' => "%R", + 'Current time %H:%M:%S format' => "%T", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation19.phpt b/ext/date/tests/strftime_variation19.phpt index 13575811d208..852b95fbe9d0 100644 --- a/ext/date/tests/strftime_variation19.phpt +++ b/ext/date/tests/strftime_variation19.phpt @@ -17,16 +17,16 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Newline character' => "%n", - 'Tab character' => "%t" + 'Newline character' => "%n", + 'Tab character' => "%t" ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation20.phpt b/ext/date/tests/strftime_variation20.phpt index d6bbab12ca6a..19875760d5c6 100644 --- a/ext/date/tests/strftime_variation20.phpt +++ b/ext/date/tests/strftime_variation20.phpt @@ -23,16 +23,16 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Newline character' => "%n", - 'Tab character' => "%t" + 'Newline character' => "%n", + 'Tab character' => "%t" ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation21.phpt b/ext/date/tests/strftime_variation21.phpt index 5e0cf423c5d0..164e5e304b17 100644 --- a/ext/date/tests/strftime_variation21.phpt +++ b/ext/date/tests/strftime_variation21.phpt @@ -18,16 +18,16 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( 'Preferred date and time representation' => "%c", - 'Preferred date representation' => "%x", - 'Preferred time representation' => "%X", + 'Preferred date representation' => "%x", + 'Preferred time representation' => "%X", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation22.phpt b/ext/date/tests/strftime_variation22.phpt index 0148223802f9..900cde2fca4b 100644 --- a/ext/date/tests/strftime_variation22.phpt +++ b/ext/date/tests/strftime_variation22.phpt @@ -28,16 +28,16 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( 'Preferred date and time representation' => "%c", - 'Preferred date representation' => "%x", - 'Preferred time representation' => "%X", + 'Preferred date representation' => "%x", + 'Preferred time representation' => "%X", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { echo "\n--$key--\n"; - var_dump( $value ); - var_dump( strftime($value, $timestamp) ); + var_dump( $value ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strftime_variation3.phpt b/ext/date/tests/strftime_variation3.phpt index a23402be9644..90771973a91f 100644 --- a/ext/date/tests/strftime_variation3.phpt +++ b/ext/date/tests/strftime_variation3.phpt @@ -18,8 +18,8 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); $inputs = array( 'Abbreviated weekday name' => "%a", 'Full weekday name' => "%A", - 'Week number of the year' => "%U", - 'Week number of the year in decimal number' => "%W", + 'Week number of the year' => "%U", + 'Week number of the year in decimal number' => "%W", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/strftime_variation4.phpt b/ext/date/tests/strftime_variation4.phpt index 2152ddda40f7..461da2669da7 100644 --- a/ext/date/tests/strftime_variation4.phpt +++ b/ext/date/tests/strftime_variation4.phpt @@ -18,7 +18,7 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); $inputs = array( 'Abbreviated month name' => "%b", 'Full month name' => "%B", - 'Month as decimal' => "%m", + 'Month as decimal' => "%m", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/strftime_variation5.phpt b/ext/date/tests/strftime_variation5.phpt index 7af084b34c3a..31cc9705642b 100644 --- a/ext/date/tests/strftime_variation5.phpt +++ b/ext/date/tests/strftime_variation5.phpt @@ -17,10 +17,10 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Year as decimal number without a century' => "%y", - 'Year as decimal number including the century' => "%Y", - 'Time zone offset' => "%Z", - 'Time zone offset' => "%z", + 'Year as decimal number without a century' => "%y", + 'Year as decimal number including the century' => "%Y", + 'Time zone offset' => "%Z", + 'Time zone offset' => "%z", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/strftime_variation6.phpt b/ext/date/tests/strftime_variation6.phpt index eadf0d05def8..1460f70b3005 100644 --- a/ext/date/tests/strftime_variation6.phpt +++ b/ext/date/tests/strftime_variation6.phpt @@ -18,11 +18,11 @@ $timestamp = mktime(18, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Hour as decimal by 24-hour format' => "%H", - 'Hour as decimal by 12-hour format' => "%I", - 'Minute as decimal number' => "%M", - 'AM/PM format for a time' => "%p", - 'Second as decimal number' => "%S", + 'Hour as decimal by 24-hour format' => "%H", + 'Hour as decimal by 12-hour format' => "%I", + 'Minute as decimal number' => "%M", + 'AM/PM format for a time' => "%p", + 'Second as decimal number' => "%S", ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/strftime_variation7.phpt b/ext/date/tests/strftime_variation7.phpt index 63a3d10808a3..b8cc2de847a3 100644 --- a/ext/date/tests/strftime_variation7.phpt +++ b/ext/date/tests/strftime_variation7.phpt @@ -18,9 +18,9 @@ $timestamp = mktime(18, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'Day of the month as a decimal number' => "%d", - 'Day of the year as a decimal number' => "%j", - 'Day of the week as a decimal number' => "%w" + 'Day of the month as a decimal number' => "%d", + 'Day of the year as a decimal number' => "%j", + 'Day of the week as a decimal number' => "%w" ); // loop through each element of the array for timestamp diff --git a/ext/date/tests/strftime_variation9.phpt b/ext/date/tests/strftime_variation9.phpt index 0d2502834c7a..82a060b66d28 100644 --- a/ext/date/tests/strftime_variation9.phpt +++ b/ext/date/tests/strftime_variation9.phpt @@ -17,16 +17,16 @@ $timestamp = mktime(8, 8, 8, 8, 8, 2008); //array of values to iterate over $inputs = array( - 'The ISO 8601:1988 week number' => "%V", - 'Weekday as decimal' => "%u", + 'The ISO 8601:1988 week number' => "%V", + 'Weekday as decimal' => "%u", ); // loop through each element of the array for timestamp foreach($inputs as $key =>$value) { - echo "\n--$key--\n"; - var_dump( strftime($value) ); - var_dump( strftime($value, $timestamp) ); + echo "\n--$key--\n"; + var_dump( strftime($value) ); + var_dump( strftime($value, $timestamp) ); } ?> diff --git a/ext/date/tests/strtotime-mysql-64bit.phpt b/ext/date/tests/strtotime-mysql-64bit.phpt index 356e4859498d..ddf1dfff3fdf 100644 --- a/ext/date/tests/strtotime-mysql-64bit.phpt +++ b/ext/date/tests/strtotime-mysql-64bit.phpt @@ -12,13 +12,13 @@ $d[] = '20001231185859'; $d[] = '20800410101010'; // overflow.. foreach($d as $date) { - $time = strtotime($date); + $time = strtotime($date); - if (is_integer($time)) { - var_dump(date('r', $time)); - } else { - var_dump($time); - } + if (is_integer($time)) { + var_dump(date('r', $time)); + } else { + var_dump($time); + } } ?> --EXPECT-- diff --git a/ext/date/tests/strtotime-mysql.phpt b/ext/date/tests/strtotime-mysql.phpt index 5b0192880b2f..c9502e1d3e17 100644 --- a/ext/date/tests/strtotime-mysql.phpt +++ b/ext/date/tests/strtotime-mysql.phpt @@ -12,13 +12,13 @@ $d[] = '20001231185859'; $d[] = '20800410101010'; // overflow.. foreach($d as $date) { - $time = strtotime($date); + $time = strtotime($date); - if (is_integer($time)) { - var_dump(date('r', $time)); - } else { - var_dump($time); - } + if (is_integer($time)) { + var_dump(date('r', $time)); + } else { + var_dump($time); + } } ?> --EXPECT-- diff --git a/ext/date/tests/strtotime-relative.phpt b/ext/date/tests/strtotime-relative.phpt index 293223bb2dd1..f5cd014a6d0e 100644 --- a/ext/date/tests/strtotime-relative.phpt +++ b/ext/date/tests/strtotime-relative.phpt @@ -8,44 +8,44 @@ date_default_timezone_set('UTC'); $base_time = 1204200000; // 28 Feb 2008 12:00:00 $offsets = array( - // offset around a day - '80412 seconds', - '86399 seconds', - '86400 seconds', - '86401 seconds', - '112913 seconds', + // offset around a day + '80412 seconds', + '86399 seconds', + '86400 seconds', + '86401 seconds', + '112913 seconds', - // offset around 7 days - '134 hours', - '167 hours', - '168 hours', - '169 hours', - '183 hours', + // offset around 7 days + '134 hours', + '167 hours', + '168 hours', + '169 hours', + '183 hours', - // offset around 6 months - '178 days', - '179 days', - '180 days', - '183 days', - '184 days', + // offset around 6 months + '178 days', + '179 days', + '180 days', + '183 days', + '184 days', - // offset around 10 years - '115 months', - '119 months', - '120 months', - '121 months', - '128 months', + // offset around 10 years + '115 months', + '119 months', + '120 months', + '121 months', + '128 months', - // offset around 25 years (can't do much more reliably with strtotime) - '24 years', - '25 years', - '26 years' + // offset around 25 years (can't do much more reliably with strtotime) + '24 years', + '25 years', + '26 years' ); foreach ($offsets AS $offset) { - foreach (array('+', '-') AS $direction) { - echo "$direction$offset: " . date(DATE_ISO8601, strtotime("$direction$offset", $base_time)) . "\n"; - } + foreach (array('+', '-') AS $direction) { + echo "$direction$offset: " . date(DATE_ISO8601, strtotime("$direction$offset", $base_time)) . "\n"; + } } ?> diff --git a/ext/date/tests/strtotime.phpt b/ext/date/tests/strtotime.phpt index aef7d68dcdae..f55765fa801e 100644 --- a/ext/date/tests/strtotime.phpt +++ b/ext/date/tests/strtotime.phpt @@ -10,7 +10,7 @@ $d[] = strtotime("@1121373041"); $d[] = strtotime("@1121373041 CEST"); foreach($d as $date) { - echo date(DATE_ISO8601, $date), "\n"; + echo date(DATE_ISO8601, $date), "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/strtotime2.phpt b/ext/date/tests/strtotime2.phpt index b8b605923dbc..c9b83838d1a0 100644 --- a/ext/date/tests/strtotime2.phpt +++ b/ext/date/tests/strtotime2.phpt @@ -7,23 +7,23 @@ date_default_timezone_set("Europe/Oslo"); $time = time(); $constants = array( - 'DATE_ATOM', - 'DATE_COOKIE', - 'DATE_ISO8601', - 'DATE_RFC822', - 'DATE_RFC850', - 'DATE_RFC1036', - 'DATE_RFC1123', - 'DATE_RFC2822', - 'DATE_RFC3339', - 'DATE_RSS', - 'DATE_W3C' + 'DATE_ATOM', + 'DATE_COOKIE', + 'DATE_ISO8601', + 'DATE_RFC822', + 'DATE_RFC850', + 'DATE_RFC1036', + 'DATE_RFC1123', + 'DATE_RFC2822', + 'DATE_RFC3339', + 'DATE_RSS', + 'DATE_W3C' ); foreach ($constants as $const) { - echo "$const:\t"; - echo ((strtotime(date(constant($const), $time)) === $time) ? "OK" : "FAIL") . "\n"; + echo "$const:\t"; + echo ((strtotime(date(constant($const), $time)) === $time) ? "OK" : "FAIL") . "\n"; } ?> --EXPECT-- diff --git a/ext/date/tests/strtotime3-64bit.phpt b/ext/date/tests/strtotime3-64bit.phpt index 52c4edd63bb2..c4f87c3b1a6a 100644 --- a/ext/date/tests/strtotime3-64bit.phpt +++ b/ext/date/tests/strtotime3-64bit.phpt @@ -8,39 +8,39 @@ date_default_timezone_set('Europe/Lisbon'); $time = 1150494719; // 16/June/2006 $strs = array( - '', - " \t\r\n000", - 'yesterday', - '22:49:12', - '22:49:12 bogusTZ', - '22.49.12.42GMT', - '22.49.12.42bogusTZ', - 't0222', - 't0222 t0222', - '022233', - '022233 bogusTZ', - '2-3-2004', - '2.3.2004', - '20060212T23:12:23UTC', - '20060212T23:12:23 bogusTZ', - '2006167', //pgydotd - 'Jan-15-2006', //pgtextshort - '2006-Jan-15', //pgtextreverse - '10/Oct/2000:13:55:36 +0100', //clf - '10/Oct/2000:13:55:36 +00100', //clf - '2006', - '1986', // year - 'JAN', - 'January', + '', + " \t\r\n000", + 'yesterday', + '22:49:12', + '22:49:12 bogusTZ', + '22.49.12.42GMT', + '22.49.12.42bogusTZ', + 't0222', + 't0222 t0222', + '022233', + '022233 bogusTZ', + '2-3-2004', + '2.3.2004', + '20060212T23:12:23UTC', + '20060212T23:12:23 bogusTZ', + '2006167', //pgydotd + 'Jan-15-2006', //pgtextshort + '2006-Jan-15', //pgtextreverse + '10/Oct/2000:13:55:36 +0100', //clf + '10/Oct/2000:13:55:36 +00100', //clf + '2006', + '1986', // year + 'JAN', + 'January', ); foreach ($strs as $str) { - $t = strtotime($str, $time); - if (is_integer($t)) { - var_dump(date(DATE_RFC2822, $t)); - } else { - var_dump($t); - } + $t = strtotime($str, $time); + if (is_integer($t)) { + var_dump(date(DATE_RFC2822, $t)); + } else { + var_dump($t); + } } ?> diff --git a/ext/date/tests/strtotime3.phpt b/ext/date/tests/strtotime3.phpt index 97161f9dfe08..f01af27a4378 100644 --- a/ext/date/tests/strtotime3.phpt +++ b/ext/date/tests/strtotime3.phpt @@ -8,39 +8,39 @@ date_default_timezone_set('Europe/Lisbon'); $time = 1150494719; // 16/June/2006 $strs = array( - '', - " \t\r\n000", - 'yesterday', - '22:49:12', - '22:49:12 bogusTZ', - '22.49.12.42GMT', - '22.49.12.42bogusTZ', - 't0222', - 't0222 t0222', - '022233', - '022233 bogusTZ', - '2-3-2004', - '2.3.2004', - '20060212T23:12:23UTC', - '20060212T23:12:23 bogusTZ', - '2006167', //pgydotd - 'Jan-15-2006', //pgtextshort - '2006-Jan-15', //pgtextreverse - '10/Oct/2000:13:55:36 +0100', //clf - '10/Oct/2000:13:55:36 +00100', //clf - '2006', - '1986', // year - 'JAN', - 'January', + '', + " \t\r\n000", + 'yesterday', + '22:49:12', + '22:49:12 bogusTZ', + '22.49.12.42GMT', + '22.49.12.42bogusTZ', + 't0222', + 't0222 t0222', + '022233', + '022233 bogusTZ', + '2-3-2004', + '2.3.2004', + '20060212T23:12:23UTC', + '20060212T23:12:23 bogusTZ', + '2006167', //pgydotd + 'Jan-15-2006', //pgtextshort + '2006-Jan-15', //pgtextreverse + '10/Oct/2000:13:55:36 +0100', //clf + '10/Oct/2000:13:55:36 +00100', //clf + '2006', + '1986', // year + 'JAN', + 'January', ); foreach ($strs as $str) { - $t = strtotime($str, $time); - if (is_integer($t)) { - var_dump(date(DATE_RFC2822, $t)); - } else { - var_dump($t); - } + $t = strtotime($str, $time); + if (is_integer($t)) { + var_dump(date(DATE_RFC2822, $t)); + } else { + var_dump($t); + } } ?> diff --git a/ext/date/tests/strtotime_variation_scottish.phpt b/ext/date/tests/strtotime_variation_scottish.phpt index 740583a78e5b..ee2ff5f098c5 100644 --- a/ext/date/tests/strtotime_variation_scottish.phpt +++ b/ext/date/tests/strtotime_variation_scottish.phpt @@ -2,11 +2,11 @@ Checking whisky time --FILE-- --EXPECT-- string(8) "07:15:00" diff --git a/ext/date/tests/sunfuncts.phpt b/ext/date/tests/sunfuncts.phpt index 672b3affe2b6..6859aadc4422 100644 --- a/ext/date/tests/sunfuncts.phpt +++ b/ext/date/tests/sunfuncts.phpt @@ -6,13 +6,13 @@ precision=13 --EXPECTF-- diff --git a/ext/date/tests/test-parse-from-format.phpt b/ext/date/tests/test-parse-from-format.phpt index ee0bd68d6b2a..670a31685937 100644 --- a/ext/date/tests/test-parse-from-format.phpt +++ b/ext/date/tests/test-parse-from-format.phpt @@ -4,20 +4,20 @@ date_create_from_format() and date_parse_from_format(). format( $format ) ; - $date2 = date_create_from_format( $format, $formatted ); - var_dump( $format, $formatted, $date2 ); - echo "\n"; - if ( $date2 === false ) - { - var_dump(date_parse_from_format( $format, $formatted ) ); - } + $date = new DateTime( "2008-07-08T22:14:12+02:00" ); + $formatted = $date->format( $format ) ; + $date2 = date_create_from_format( $format, $formatted ); + var_dump( $format, $formatted, $date2 ); + echo "\n"; + if ( $date2 === false ) + { + var_dump(date_parse_from_format( $format, $formatted ) ); + } } ?> --EXPECT-- diff --git a/ext/date/tests/timezone-configuration.phpt b/ext/date/tests/timezone-configuration.phpt index b39585303301..3e4340c38c5b 100644 --- a/ext/date/tests/timezone-configuration.phpt +++ b/ext/date/tests/timezone-configuration.phpt @@ -4,14 +4,14 @@ timezone configuration [1] date.timezone=GMT --FILE-- --EXPECT-- 1119125744 diff --git a/ext/date/tests/timezone_offset_get_error.phpt b/ext/date/tests/timezone_offset_get_error.phpt index 07bcf895ddf5..69e81cb8461d 100644 --- a/ext/date/tests/timezone_offset_get_error.phpt +++ b/ext/date/tests/timezone_offset_get_error.phpt @@ -18,47 +18,47 @@ echo "*** Testing timezone_offset_get() : error conditions ***\n"; echo "\n-- Testing timezone_offset_get() function with an invalid values for \$object argument --\n"; $invalid_obj = new stdClass(); try { - var_dump( timezone_offset_get($invalid_obj, $date) ); + var_dump( timezone_offset_get($invalid_obj, $date) ); } catch (Error $ex) { - var_dump($ex->getMessage()); - echo "\n"; + var_dump($ex->getMessage()); + echo "\n"; } $invalid_obj = 10; try { - var_dump( timezone_offset_get($invalid_obj, $date) ); + var_dump( timezone_offset_get($invalid_obj, $date) ); } catch (Error $ex) { - var_dump($ex->getMessage()); - echo "\n"; + var_dump($ex->getMessage()); + echo "\n"; } $invalid_obj = null; try { - var_dump( timezone_offset_get($invalid_obj, $date) ); + var_dump( timezone_offset_get($invalid_obj, $date) ); } catch (Error $ex) { - var_dump($ex->getMessage()); - echo "\n"; + var_dump($ex->getMessage()); + echo "\n"; } echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n"; $invalid_obj = new stdClass(); try { - var_dump( timezone_offset_get($tz, $invalid_obj) ); + var_dump( timezone_offset_get($tz, $invalid_obj) ); } catch (Error $ex) { - var_dump($ex->getMessage()); - echo "\n"; + var_dump($ex->getMessage()); + echo "\n"; } $invalid_obj = 10; try { - var_dump( timezone_offset_get($tz, $invalid_obj) ); + var_dump( timezone_offset_get($tz, $invalid_obj) ); } catch (Error $ex) { - var_dump($ex->getMessage()); - echo "\n"; + var_dump($ex->getMessage()); + echo "\n"; } $invalid_obj = null; try { - var_dump( timezone_offset_get($tz, $invalid_obj) ); + var_dump( timezone_offset_get($tz, $invalid_obj) ); } catch (Error $ex) { - var_dump($ex->getMessage()); - echo "\n"; + var_dump($ex->getMessage()); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/dba/tests/bug38698.phpt b/ext/dba/tests/bug38698.phpt index 9630af639d79..fe4c68aa80fe 100644 --- a/ext/dba/tests/bug38698.phpt +++ b/ext/dba/tests/bug38698.phpt @@ -15,15 +15,15 @@ function isLittleEndian() { $db_file = __DIR__ .'/129php.cdb'; if (($db_make=dba_open($db_file, "n", 'cdb_make'))!==FALSE) { - if (isLittleEndian() === FALSE) { + if (isLittleEndian() === FALSE) { dba_insert(pack('V',129), "Booo!", $db_make); - } else{ - dba_insert(pack('i',129), "Booo!", $db_make); - } - dba_close($db_make); - // write md5 checksum of generated database file - var_dump(md5_file($db_file)); - @unlink($db_file); + } else{ + dba_insert(pack('i',129), "Booo!", $db_make); + } + dba_close($db_make); + // write md5 checksum of generated database file + var_dump(md5_file($db_file)); + @unlink($db_file); } else { echo "Error creating database\n"; } diff --git a/ext/dba/tests/bug62490.phpt b/ext/dba/tests/bug62490.phpt index a0fc64aafaec..3e5c1e82ca33 100644 --- a/ext/dba/tests/bug62490.phpt +++ b/ext/dba/tests/bug62490.phpt @@ -11,10 +11,10 @@ $handler = "inifile"; include "test.inc"; $dba = dba_open($db_filename, "n", $handler) - or die; + or die; for ($i = 0; $i < 3; ++$i) { - echo "insert $i:"; - var_dump(dba_insert("a", $i, $dba)); + echo "insert $i:"; + var_dump(dba_insert("a", $i, $dba)); } echo "exists:"; diff --git a/ext/dba/tests/clean.inc b/ext/dba/tests/clean.inc index 9f6d539a1953..83c867de642f 100644 --- a/ext/dba/tests/clean.inc +++ b/ext/dba/tests/clean.inc @@ -1,6 +1,6 @@ diff --git a/ext/dba/tests/dba001.phpt b/ext/dba/tests/dba001.phpt index 836d03da741a..79ebb2d23771 100644 --- a/ext/dba/tests/dba001.phpt +++ b/ext/dba/tests/dba001.phpt @@ -7,13 +7,13 @@ DBA File Creation Test ?> --FILE-- --CLEAN-- diff --git a/ext/dba/tests/dba002.phpt b/ext/dba/tests/dba002.phpt index 73b2d42df981..c0432c4599bc 100644 --- a/ext/dba/tests/dba002.phpt +++ b/ext/dba/tests/dba002.phpt @@ -7,15 +7,15 @@ DBA Insert/Fetch Test ?> --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECT-- database handler: cdb diff --git a/ext/dba/tests/dba_db1.phpt b/ext/dba/tests/dba_db1.phpt index a08809c0e7e5..26711c9d5e5c 100644 --- a/ext/dba/tests/dba_db1.phpt +++ b/ext/dba/tests/dba_db1.phpt @@ -7,9 +7,9 @@ DBA DB1 handler test ?> --FILE-- --EXPECT-- database handler: db1 diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt index ef48664762f5..013813062a4a 100644 --- a/ext/dba/tests/dba_db2.phpt +++ b/ext/dba/tests/dba_db2.phpt @@ -7,9 +7,9 @@ DBA DB2 handler test ?> --FILE-- --EXPECT-- database handler: db2 diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt index a07780ea3479..f3c2061414ca 100644 --- a/ext/dba/tests/dba_db3.phpt +++ b/ext/dba/tests/dba_db3.phpt @@ -7,9 +7,9 @@ DBA DB3 handler test ?> --FILE-- --EXPECT-- database handler: db3 diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt index be9c98843386..47bbae28c075 100644 --- a/ext/dba/tests/dba_dbm.phpt +++ b/ext/dba/tests/dba_dbm.phpt @@ -7,9 +7,9 @@ DBA DBM handler test ?> --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECTF-- database handler: gdbm diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc index 51f27050ca80..9b9d030c39b9 100644 --- a/ext/dba/tests/dba_handler.inc +++ b/ext/dba/tests/dba_handler.inc @@ -3,96 +3,96 @@ echo "database handler: $handler\n"; do { - if (($db_file = dba_open($db_filename, 'n'.$lock_flag, $handler))!==FALSE) { - dba_insert("key1", "Content String 1", $db_file); - dba_insert("key2", "Content String 2", $db_file); - dba_insert("key3", "Third Content String", $db_file); - dba_insert("key4", "Another Content String", $db_file); - dba_insert("key5", "The last content string", $db_file); - if ($handler != 'cdb') { - dba_delete("key3", $db_file); - dba_delete("key1", $db_file); - } else { - dba_close($db_file); - if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))===FALSE) { - echo "Error reopening database\n"; - } - } - $a = dba_firstkey($db_file); - $i=0; - while($a) { - $a = dba_nextkey($db_file); - $i++; - } - echo $i; - for ($i=1; $i<6; $i++) { - echo dba_exists("key$i", $db_file) ? "Y" : "N"; - } - echo "\n"; - echo dba_fetch("key2", $db_file)."\n"; - if ($handler != 'cdb') { - dba_replace("key2", "Content 2 replaced", $db_file); - echo dba_fetch("key2", $db_file)."\n"; - } - dba_close($db_file); - } else { - echo "Error creating database\n"; - } - if ($handler != 'cdb') { - $db_writer = dba_open($db_filename, 'c'.$lock_flag, $handler); - if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.'t', $handler))===false) { - echo "Read during write: not allowed\n"; - } else { - echo "Read during write: allowed\n"; - } - if ($db_writer!==FALSE) { - if (dba_insert("key number 6", "The 6th value", $db_writer)) { - echo '"key number 6" written' . "\n"; - } else { - echo 'Failed to write "key number 6"' . "\n"; - } - if (dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer)) { - echo '"key number 6" written 2nd time' . "\n"; - } else { - echo 'Failed to write "key number 6" 2nd time' . "\n"; - } - dba_replace("key2", "Content 2 replaced 2nd time", $db_writer); - dba_delete("key4", $db_writer); - echo dba_fetch("key2", $db_writer)."\n"; - echo dba_fetch("key number 6", $db_writer)."\n"; - dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io. - } else { - die("Error reopening database\n"); - } - } - if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))!==FALSE) { - $key = dba_firstkey($db_file); - $res = array(); - while($key) { - $res[$key] = dba_fetch($key, $db_file); - $key = dba_nextkey($db_file); - } - ksort($res); - var_dump($res); - dba_close($db_file); - } else { - echo "Error reading database\n"; - } - if (!empty($dba_reader)) { - dba_close($dba_reader); - } - if (($db_file = dba_popen($db_filename, 'r'.($lock_flag==''?'':'-'), $handler))!==FALSE) { - if ($handler == 'dbm' || $handler == "tcadb") { - dba_close($db_file); - } - } + if (($db_file = dba_open($db_filename, 'n'.$lock_flag, $handler))!==FALSE) { + dba_insert("key1", "Content String 1", $db_file); + dba_insert("key2", "Content String 2", $db_file); + dba_insert("key3", "Third Content String", $db_file); + dba_insert("key4", "Another Content String", $db_file); + dba_insert("key5", "The last content string", $db_file); + if ($handler != 'cdb') { + dba_delete("key3", $db_file); + dba_delete("key1", $db_file); + } else { + dba_close($db_file); + if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))===FALSE) { + echo "Error reopening database\n"; + } + } + $a = dba_firstkey($db_file); + $i=0; + while($a) { + $a = dba_nextkey($db_file); + $i++; + } + echo $i; + for ($i=1; $i<6; $i++) { + echo dba_exists("key$i", $db_file) ? "Y" : "N"; + } + echo "\n"; + echo dba_fetch("key2", $db_file)."\n"; + if ($handler != 'cdb') { + dba_replace("key2", "Content 2 replaced", $db_file); + echo dba_fetch("key2", $db_file)."\n"; + } + dba_close($db_file); + } else { + echo "Error creating database\n"; + } + if ($handler != 'cdb') { + $db_writer = dba_open($db_filename, 'c'.$lock_flag, $handler); + if (($dba_reader = @dba_open($db_filename, 'r'.$lock_flag.'t', $handler))===false) { + echo "Read during write: not allowed\n"; + } else { + echo "Read during write: allowed\n"; + } + if ($db_writer!==FALSE) { + if (dba_insert("key number 6", "The 6th value", $db_writer)) { + echo '"key number 6" written' . "\n"; + } else { + echo 'Failed to write "key number 6"' . "\n"; + } + if (dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer)) { + echo '"key number 6" written 2nd time' . "\n"; + } else { + echo 'Failed to write "key number 6" 2nd time' . "\n"; + } + dba_replace("key2", "Content 2 replaced 2nd time", $db_writer); + dba_delete("key4", $db_writer); + echo dba_fetch("key2", $db_writer)."\n"; + echo dba_fetch("key number 6", $db_writer)."\n"; + dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io. + } else { + die("Error reopening database\n"); + } + } + if (($db_file = dba_open($db_filename, 'r'.$lock_flag, $handler))!==FALSE) { + $key = dba_firstkey($db_file); + $res = array(); + while($key) { + $res[$key] = dba_fetch($key, $db_file); + $key = dba_nextkey($db_file); + } + ksort($res); + var_dump($res); + dba_close($db_file); + } else { + echo "Error reading database\n"; + } + if (!empty($dba_reader)) { + dba_close($dba_reader); + } + if (($db_file = dba_popen($db_filename, 'r'.($lock_flag==''?'':'-'), $handler))!==FALSE) { + if ($handler == 'dbm' || $handler == "tcadb") { + dba_close($db_file); + } + } - if ($lock_flag == '') { - break; - } else { - echo "--NO-LOCK--\n"; - $lock_flag = ''; - } + if ($lock_flag == '') { + break; + } else { + echo "--NO-LOCK--\n"; + $lock_flag = ''; + } } while(1); ?> diff --git a/ext/dba/tests/dba_inifile.phpt b/ext/dba/tests/dba_inifile.phpt index cbcd6c1e8d9a..e9bc185bf48e 100644 --- a/ext/dba/tests/dba_inifile.phpt +++ b/ext/dba/tests/dba_inifile.phpt @@ -7,9 +7,9 @@ DBA INIFILE handler test ?> --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECT-- database handler: ndbm diff --git a/ext/dba/tests/dba_qdbm.phpt b/ext/dba/tests/dba_qdbm.phpt index a864121a1db4..efe34653b3f5 100644 --- a/ext/dba/tests/dba_qdbm.phpt +++ b/ext/dba/tests/dba_qdbm.phpt @@ -7,10 +7,10 @@ DBA QDBM handler test ?> --FILE-- --CLEAN-- --CLEAN-- diff --git a/ext/dba/tests/test.inc b/ext/dba/tests/test.inc index 7c4e207b8247..458c4399e957 100644 --- a/ext/dba/tests/test.inc +++ b/ext/dba/tests/test.inc @@ -1,7 +1,7 @@ diff --git a/ext/dom/tests/DOMCDATASection_construct_error_001.phpt b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt index 215401614281..ab7149cd879d 100644 --- a/ext/dom/tests/DOMCDATASection_construct_error_001.phpt +++ b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt @@ -7,11 +7,11 @@ Nic Rosental nicrosental@gmail.com --FILE-- getMessage(); - } + try { + $section = new DOMCDataSection(); + } catch (TypeError $e) { + echo $e->getMessage(); + } ?> --EXPECT-- DOMCdataSection::__construct() expects exactly 1 parameter, 0 given diff --git a/ext/dom/tests/DOMDocument_createAttribute_error.phpt b/ext/dom/tests/DOMDocument_createAttribute_error.phpt index a395ba9579a4..b9b310827dba 100644 --- a/ext/dom/tests/DOMDocument_createAttribute_error.phpt +++ b/ext/dom/tests/DOMDocument_createAttribute_error.phpt @@ -7,19 +7,19 @@ Test DOMDocument::createAttribute() for expected exception thrown when wrong par $dom = new DOMDocument(); try { - $attr = $dom->createAttribute(0); + $attr = $dom->createAttribute(0); } catch(DOMException $e) { - $code = $e->getCode(); - if(DOM_INVALID_CHARACTER_ERR === $code) { - echo "PASS"; - } - else { - echo 'Wrong exception code'; - } + $code = $e->getCode(); + if(DOM_INVALID_CHARACTER_ERR === $code) { + echo "PASS"; + } + else { + echo 'Wrong exception code'; + } } catch(Exception $e) { - echo 'Wrong exception thrown'; + echo 'Wrong exception thrown'; } ?> diff --git a/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt b/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt index fa777f8ce523..93d0a13c7731 100644 --- a/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt +++ b/ext/dom/tests/DOMDocument_relaxNGValidateSource_basic.phpt @@ -10,22 +10,22 @@ require_once('skipif.inc'); - - - - - - - - + + + + + + + + RNG; $good_xml = <<< GOOD_XML - - Pear + + Pear GOOD_XML; diff --git a/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt index a277a30a2d66..91b76344af59 100644 --- a/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt +++ b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error1.phpt @@ -10,23 +10,23 @@ require_once('skipif.inc'); - - - - - - - - + + + + + + + + RNG; $bad_xml = <<< BAD_XML - - Pear - Pear + + Pear + Pear BAD_XML; diff --git a/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt index b11dc63f7e44..658bc7ffca22 100644 --- a/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt +++ b/ext/dom/tests/DOMDocument_relaxNGValidateSource_error2.phpt @@ -10,10 +10,10 @@ require_once('skipif.inc'); - - + @@ -21,7 +21,7 @@ RNG; $xml = <<< XML - + Pear XML; diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt b/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt index e4b784e37683..80645f5c74c4 100644 --- a/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt +++ b/ext/dom/tests/DOMDocument_relaxNGValidate_basic.phpt @@ -11,8 +11,8 @@ require_once('skipif.inc'); $rng = __DIR__.'/DOMDocument_relaxNGValidate_basic.rng'; $xml = <<< XML - - Pear + + Pear XML; $doc = new DOMDocument(); diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt b/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt index ab6befa3b112..cbdab1cbd5b1 100644 --- a/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt +++ b/ext/dom/tests/DOMDocument_relaxNGValidate_error1.phpt @@ -11,9 +11,9 @@ require_once('skipif.inc'); $rng = __DIR__.'/DOMDocument_relaxNGValidate_basic.rng'; $xml = <<< XML - - Pear - Pear + + Pear + Pear XML; $doc = new DOMDocument(); diff --git a/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt b/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt index cdd6e64194c2..3aa6a3b31894 100644 --- a/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt +++ b/ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt @@ -11,9 +11,9 @@ require_once('skipif.inc'); $rng = __DIR__.'/foo.rng'; $xml = <<< XML - - Pear - Pear + + Pear + Pear XML; $doc = new DOMDocument(); diff --git a/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt b/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt index 3d99e0eb7033..47f557920025 100644 --- a/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt +++ b/ext/dom/tests/DOMDocument_strictErrorChecking_variation.phpt @@ -18,12 +18,12 @@ var_dump($doc->strictErrorChecking); echo "Should throw DOMException when strictErrorChecking is on\n"; try { - $attr = $doc->createAttribute(0); + $attr = $doc->createAttribute(0); } catch (DOMException $e) { - echo "GOOD. DOMException thrown\n"; - echo $e->getMessage() ."\n"; + echo "GOOD. DOMException thrown\n"; + echo $e->getMessage() ."\n"; } catch (Exception $e) { - echo "OOPS. Other exception thrown\n"; + echo "OOPS. Other exception thrown\n"; } @@ -35,12 +35,12 @@ var_dump($doc->strictErrorChecking); echo "Should raise PHP error because strictErrorChecking is off\n"; try { - $attr = $doc->createAttribute(0); + $attr = $doc->createAttribute(0); } catch (DOMException $e) { - echo "OOPS. DOMException thrown\n"; - echo $e->getMessage() ."\n"; + echo "OOPS. DOMException thrown\n"; + echo $e->getMessage() ."\n"; } catch (Exception $e) { - echo "OOPS. Other exception thrown\n"; + echo "OOPS. Other exception thrown\n"; } ?> diff --git a/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt b/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt index 06ae48e93dd5..ddce93052ce8 100644 --- a/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt +++ b/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt @@ -8,8 +8,8 @@ include('skipif.inc'); createDocumentType("html", - "-//W3C//DTD XHTML 1.0 Strict//EN", - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); + "-//W3C//DTD XHTML 1.0 Strict//EN", + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); $doc = $imp->createDocument(null, 'html', $doctype); echo $doc->saveHTML(); ?> diff --git a/ext/dom/tests/DOMNode_cloneNode_basic.phpt b/ext/dom/tests/DOMNode_cloneNode_basic.phpt index d0503630f3b9..9fec109a7410 100644 --- a/ext/dom/tests/DOMNode_cloneNode_basic.phpt +++ b/ext/dom/tests/DOMNode_cloneNode_basic.phpt @@ -28,9 +28,9 @@ $xml = <<< EOXML EOXML; function dumpcourse($current) { - $title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title"; - echo "Course: $title:";echo(get_class($current)), "\n"; - echo "~";var_dump($current->textContent); + $title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title"; + echo "Course: $title:";echo(get_class($current)), "\n"; + echo "~";var_dump($current->textContent); } $dom = new DOMDocument(); @@ -41,10 +41,10 @@ $root = $dom->documentElement; $children = $root->childNodes; $len = $children->length; for ($index = $children->length - 1; $index >=0; $index--) { - $current = $children->item($index); - if ($current->nodeType == XML_TEXT_NODE) { - $noderemoved = $root->removeChild($current); - } + $current = $children->item($index); + if ($current->nodeType == XML_TEXT_NODE) { + $noderemoved = $root->removeChild($current); + } } echo "Start cloneNode test\n"; @@ -68,8 +68,8 @@ $root->appendChild($cloned_first_course_false); $children = $root->childNodes; for ($index = 0; $index < $children->length; $index++) { - echo "node $index\n"; - dumpcourse($children->item($index)); + echo "node $index\n"; + dumpcourse($children->item($index)); } --EXPECT-- Start cloneNode test diff --git a/ext/dom/tests/DOMNode_getLineNo_basic.phpt b/ext/dom/tests/DOMNode_getLineNo_basic.phpt index 655b7513556e..79d3c5a700f0 100644 --- a/ext/dom/tests/DOMNode_getLineNo_basic.phpt +++ b/ext/dom/tests/DOMNode_getLineNo_basic.phpt @@ -11,7 +11,7 @@ $doc = new DOMDocument(); $doc->load($file); $nodes = $doc->getElementsByTagName('title'); foreach($nodes as $node) { - var_dump($node->getLineNo()); + var_dump($node->getLineNo()); } ?> --EXPECT-- diff --git a/ext/dom/tests/DOMNode_getNodePath_basic.phpt b/ext/dom/tests/DOMNode_getNodePath_basic.phpt index c490e0941f7c..9e791939aec0 100644 --- a/ext/dom/tests/DOMNode_getNodePath_basic.phpt +++ b/ext/dom/tests/DOMNode_getNodePath_basic.phpt @@ -11,7 +11,7 @@ $doc = new DOMDocument(); $doc->load($file); $nodes = $doc->getElementsByTagName('title'); foreach($nodes as $node) { - var_dump($node->getNodePath()); + var_dump($node->getNodePath()); } ?> --EXPECT-- diff --git a/ext/dom/tests/DOMNode_insertBefore_error1.phpt b/ext/dom/tests/DOMNode_insertBefore_error1.phpt index 72c1a5ba5cf6..4ce2ecb843bd 100644 --- a/ext/dom/tests/DOMNode_insertBefore_error1.phpt +++ b/ext/dom/tests/DOMNode_insertBefore_error1.phpt @@ -14,9 +14,9 @@ $node_in_doc1 = $doc1->createElement("foo"); $node_in_doc2 = $doc2->createElement("bar"); try { - $node_in_doc2->insertBefore($node_in_doc1); + $node_in_doc2->insertBefore($node_in_doc1); } catch(DOMException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/dom/tests/DOMNode_insertBefore_error2.phpt b/ext/dom/tests/DOMNode_insertBefore_error2.phpt index e951cd237a4f..39d461096fb3 100644 --- a/ext/dom/tests/DOMNode_insertBefore_error2.phpt +++ b/ext/dom/tests/DOMNode_insertBefore_error2.phpt @@ -30,7 +30,7 @@ $ref_node = $dom->getElementsByTagName("book")->item(1); try { $parent_node->insertBefore($new_node, $ref_node); } catch(DOMException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/dom/tests/DOMNode_insertBefore_error3.phpt b/ext/dom/tests/DOMNode_insertBefore_error3.phpt index 6e5137798cd9..bf323a2d48c2 100644 --- a/ext/dom/tests/DOMNode_insertBefore_error3.phpt +++ b/ext/dom/tests/DOMNode_insertBefore_error3.phpt @@ -31,7 +31,7 @@ assert(!is_null($ref_node)); try { $parent_node->insertBefore($new_node, $ref_node); } catch(DOMException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/dom/tests/DOMNode_insertBefore_error4.phpt b/ext/dom/tests/DOMNode_insertBefore_error4.phpt index 84fbcd82ddc1..4b20a6d8046e 100644 --- a/ext/dom/tests/DOMNode_insertBefore_error4.phpt +++ b/ext/dom/tests/DOMNode_insertBefore_error4.phpt @@ -30,7 +30,7 @@ $ref_node = $dom->createElement('newnode2'); try { $parent_node->insertBefore($new_node, $ref_node); } catch(DOMException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/dom/tests/DOMNode_insertBefore_error5.phpt b/ext/dom/tests/DOMNode_insertBefore_error5.phpt index e9dac3a459c4..e50dffcb4441 100644 --- a/ext/dom/tests/DOMNode_insertBefore_error5.phpt +++ b/ext/dom/tests/DOMNode_insertBefore_error5.phpt @@ -32,7 +32,7 @@ $dom->saveXML(); try { $parent_node->insertBefore($new_node, $ref_node); } catch(DOMException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/dom/tests/DOMNode_insertBefore_error6.phpt b/ext/dom/tests/DOMNode_insertBefore_error6.phpt index 6027d4414041..bc026f5ccbd7 100644 --- a/ext/dom/tests/DOMNode_insertBefore_error6.phpt +++ b/ext/dom/tests/DOMNode_insertBefore_error6.phpt @@ -27,7 +27,7 @@ assert($new_node !== false); try { $parent_node->insertBefore($new_node, $ref_node); } catch(DOMException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/dom/tests/DOMNode_issamenode_basic.phpt b/ext/dom/tests/DOMNode_issamenode_basic.phpt index f0bbff1c04d6..6dff0977b3d0 100644 --- a/ext/dom/tests/DOMNode_issamenode_basic.phpt +++ b/ext/dom/tests/DOMNode_issamenode_basic.phpt @@ -18,16 +18,16 @@ if(!$dom) { $node = $dom->documentElement; if($node->isSameNode($node)) - echo "EXPECTING SAME NODE, PASSED\n" ; + echo "EXPECTING SAME NODE, PASSED\n" ; else - echo "EXPECTING SAME NODE, FAILED\n" ; + echo "EXPECTING SAME NODE, FAILED\n" ; $nodelist=$dom->getElementsByTagName('tbody') ; if($nodelist->item(0)->isSameNode($node)) - echo "EXPECTING NOT SAME NODE, FAILED\n" ; + echo "EXPECTING NOT SAME NODE, FAILED\n" ; else - echo "EXPECTING NOT SAME NODE, PASSED\n" ; + echo "EXPECTING NOT SAME NODE, PASSED\n" ; ?> --EXPECT-- diff --git a/ext/dom/tests/DOMNode_removeChild_basic.phpt b/ext/dom/tests/DOMNode_removeChild_basic.phpt index 8dcecb52c850..e9c3e13a8134 100644 --- a/ext/dom/tests/DOMNode_removeChild_basic.phpt +++ b/ext/dom/tests/DOMNode_removeChild_basic.phpt @@ -28,9 +28,9 @@ $xml = <<< EOXML EOXML; function dumpcourse($current) { - $title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title"; - echo "Course: $title:";echo get_class($current), "\n"; - echo "~";var_dump($current->textContent); + $title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title"; + echo "Course: $title:";echo get_class($current), "\n"; + echo "~";var_dump($current->textContent); } $dom = new DOMDocument(); @@ -41,20 +41,20 @@ $children = $root->childNodes; $len = $children->length; echo "original has $len nodes\n"; for ($index = $children->length - 1; $index >=0; $index--) { - echo "node $index\n"; - $current = $children->item($index); - dumpcourse($current); - if ($current->nodeType == XML_TEXT_NODE) { - $noderemoved = $root->removeChild($current); - } + echo "node $index\n"; + $current = $children->item($index); + dumpcourse($current); + if ($current->nodeType == XML_TEXT_NODE) { + $noderemoved = $root->removeChild($current); + } } $children = $root->childNodes; $len = $children->length; echo "after text removed it now has $len nodes\n"; for ($index = 0; $index < $children->length; $index++) { - echo "node $index\n"; - $current = $children->item($index); - dumpcourse($current); + echo "node $index\n"; + $current = $children->item($index); + dumpcourse($current); } --EXPECT-- original has 5 nodes diff --git a/ext/dom/tests/bug28817.phpt b/ext/dom/tests/bug28817.phpt index 50d81b1aa7e2..6d1d12a53843 100644 --- a/ext/dom/tests/bug28817.phpt +++ b/ext/dom/tests/bug28817.phpt @@ -6,18 +6,18 @@ Bug #28817 (properties in extended class) p_array[] = 'bonus'; - $this->p_array[] = 'vir'; - $this->p_array[] = 'semper'; - $this->p_array[] = 'tiro'; + function __construct(){ + $this->p_array[] = 'bonus'; + $this->p_array[] = 'vir'; + $this->p_array[] = 'semper'; + $this->p_array[] = 'tiro'; - $this->p_variable = 'Cessante causa cessat effectus'; - } + $this->p_variable = 'Cessante causa cessat effectus'; + } } $z=new z(); diff --git a/ext/dom/tests/bug34276.phpt b/ext/dom/tests/bug34276.phpt index 6959d90a92e2..54c832033d3f 100644 --- a/ext/dom/tests/bug34276.phpt +++ b/ext/dom/tests/bug34276.phpt @@ -11,10 +11,10 @@ $xml = <<nodeName); - dump($elem->childNodes); - } + foreach ($elems as $elem) { + var_dump($elem->nodeName); + dump($elem->childNodes); + } } $dom = new DOMDocument(); diff --git a/ext/dom/tests/bug38474.phpt b/ext/dom/tests/bug38474.phpt index 9c694c432eb0..6e30d0988dd2 100644 --- a/ext/dom/tests/bug38474.phpt +++ b/ext/dom/tests/bug38474.phpt @@ -9,7 +9,7 @@ if (version_compare(LIBXML_DOTTED_VERSION, "2.6.20", "<")) { ?> --FILE-- '; $dom = new DomDocument(); diff --git a/ext/dom/tests/bug67081.phpt b/ext/dom/tests/bug67081.phpt index e9156f770ea2..b541df1b413a 100644 --- a/ext/dom/tests/bug67081.phpt +++ b/ext/dom/tests/bug67081.phpt @@ -6,25 +6,25 @@ require_once('skipif.inc'); ?> --FILE-- substituteEntities = true; - $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "bug67081_0.xml"); - var_dump($domDocument->doctype->internalSubset); + $domDocument = new DOMDocument(); + $domDocument->substituteEntities = true; + $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "bug67081_0.xml"); + var_dump($domDocument->doctype->internalSubset); - $domDocument = new DOMDocument(); - $domDocument->substituteEntities = true; - $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "bug67081_1.xml"); - var_dump($domDocument->doctype->internalSubset); + $domDocument = new DOMDocument(); + $domDocument->substituteEntities = true; + $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "bug67081_1.xml"); + var_dump($domDocument->doctype->internalSubset); - $domDocument = new DOMDocument(); - $domDocument->substituteEntities = true; - $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "bug67081_2.xml"); - var_dump($domDocument->doctype->internalSubset); + $domDocument = new DOMDocument(); + $domDocument->substituteEntities = true; + $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "bug67081_2.xml"); + var_dump($domDocument->doctype->internalSubset); - $domDocument = new DOMDocument(); - $domDocument->substituteEntities = true; - $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "dom.xml"); - var_dump($domDocument->doctype->internalSubset); + $domDocument = new DOMDocument(); + $domDocument->substituteEntities = true; + $domDocument->load(__DIR__ . DIRECTORY_SEPARATOR . "dom.xml"); + var_dump($domDocument->doctype->internalSubset); ?> --EXPECT-- string(19) " diff --git a/ext/dom/tests/bug69373.phpt b/ext/dom/tests/bug69373.phpt index ce4510082e68..4cb929d1ca8b 100644 --- a/ext/dom/tests/bug69373.phpt +++ b/ext/dom/tests/bug69373.phpt @@ -6,10 +6,10 @@ Bug #69373 References to deleted XPath query results loadXML(""); - $xpath = new DOMXpath($doc); - $all = $xpath->query('//*'); - $doc->firstChild->nodeValue = ''; + $doc->loadXML(""); + $xpath = new DOMXpath($doc); + $all = $xpath->query('//*'); + $doc->firstChild->nodeValue = ''; } echo 'DONE', PHP_EOL; ?> diff --git a/ext/dom/tests/bug70558.phpt b/ext/dom/tests/bug70558.phpt index c2d53d893d08..9ad8fa05968d 100644 --- a/ext/dom/tests/bug70558.phpt +++ b/ext/dom/tests/bug70558.phpt @@ -7,9 +7,9 @@ Bug #70558 ("Couldn't fetch" error in DOMDocument::registerNodeClass()) class X extends \DOMDocument { - public function __clone() { - var_dump($this->registerNodeClass('DOMDocument', 'X')); - } + public function __clone() { + var_dump($this->registerNodeClass('DOMDocument', 'X')); + } } $dom = clone (new X()); diff --git a/ext/dom/tests/bug75451.phpt b/ext/dom/tests/bug75451.phpt index dae7cde98b55..a34915bb172f 100644 --- a/ext/dom/tests/bug75451.phpt +++ b/ext/dom/tests/bug75451.phpt @@ -10,7 +10,7 @@ $dom = new DOMDocument(); $dom->loadXML(''); $xpath = new DOMXpath($dom); foreach($xpath->query('/root/noexist') as $child) { - var_dump($child); + var_dump($child); } ?> okey diff --git a/ext/dom/tests/dom002.phpt b/ext/dom/tests/dom002.phpt index 3343a1774ef9..044e5eab1cf9 100644 --- a/ext/dom/tests/dom002.phpt +++ b/ext/dom/tests/dom002.phpt @@ -16,10 +16,10 @@ $xml = <<nodeName); - dump($elem->childNodes); - } + foreach ($elems as $elem) { + var_dump($elem->nodeName); + dump($elem->childNodes); + } } $dom = new DOMDocument(); diff --git a/ext/dom/tests/dom003.phpt b/ext/dom/tests/dom003.phpt index 05d23cd792bc..20db09d40eb3 100644 --- a/ext/dom/tests/dom003.phpt +++ b/ext/dom/tests/dom003.phpt @@ -12,11 +12,11 @@ print "--- Catch exception with try/catch\n"; try { $rootNode->appendChild($rootNode); } catch (domexception $e) { - ob_start(); + ob_start(); var_dump($e); - $contents = ob_get_contents(); - ob_end_clean(); - echo preg_replace('/object\(DOMElement\).+\{.*?\}/s', 'DOMElement', $contents); + $contents = ob_get_contents(); + ob_end_clean(); + echo preg_replace('/object\(DOMElement\).+\{.*?\}/s', 'DOMElement', $contents); } print "--- Don't catch exception with try/catch\n"; $rootNode->appendChild($rootNode); diff --git a/ext/dom/tests/dom007.phpt b/ext/dom/tests/dom007.phpt index b0062e8e4ac4..2ed232a3c0f2 100644 --- a/ext/dom/tests/dom007.phpt +++ b/ext/dom/tests/dom007.phpt @@ -47,11 +47,11 @@ $length = $nots->length; echo "Length: ".$length."\n"; foreach ($nots AS $key=>$node) { - echo "Key $key: ".$node->nodeName." (".$node->systemId.") (".$node->publicId.")\n"; + echo "Key $key: ".$node->nodeName." (".$node->systemId.") (".$node->publicId.")\n"; } print "\n"; for($x=0; $x < $length; $x++) { - echo "Index $x: ".$nots->item($x)->nodeName." (".$nots->item($x)->systemId.") (".$nots->item($x)->publicId.")\n"; + echo "Index $x: ".$nots->item($x)->nodeName." (".$nots->item($x)->systemId.") (".$nots->item($x)->publicId.")\n"; } echo "\n"; @@ -66,21 +66,21 @@ echo "Length: ".$length."\n"; $xkeys = array(); foreach ($ents AS $key=>$node) { - $xkeys[] = "Key: $key Name: ".$node->nodeName."\n"; + $xkeys[] = "Key: $key Name: ".$node->nodeName."\n"; } sort($xkeys); // fix inconsistent output ordering (bug #61810) foreach ($xkeys as $key => $node) { - echo $node; + echo $node; } echo "\n"; $xkeys = array(); for($x=0; $x < $length; $x++) { - $xkeys[] = "Index: ".$ents->item($x)->nodeName."\n"; + $xkeys[] = "Index: ".$ents->item($x)->nodeName."\n"; } sort($xkeys); // fix inconsistent output ordering (bug #61810) foreach ($xkeys as $key => $node) { - echo $node; + echo $node; } echo "\n"; diff --git a/ext/dom/tests/dom_comment_basic.phpt b/ext/dom/tests/dom_comment_basic.phpt index 7c436a747a36..4533fcc6e20f 100644 --- a/ext/dom/tests/dom_comment_basic.phpt +++ b/ext/dom/tests/dom_comment_basic.phpt @@ -21,10 +21,10 @@ var_dump($root->hasChildNodes()); $children = $root->childNodes; for ($index = 0; $index < $children->length; $index++) { - echo "--- child $index ---\n"; - $current = $children->item($index); - echo get_class($current), "\n"; - var_dump($current->textContent); + echo "--- child $index ---\n"; + $current = $children->item($index); + echo get_class($current), "\n"; + var_dump($current->textContent); } --EXPECT-- bool(true) diff --git a/ext/dom/tests/dom_comment_variation.phpt b/ext/dom/tests/dom_comment_variation.phpt index 8982f34abe6e..713c6a73cb53 100644 --- a/ext/dom/tests/dom_comment_variation.phpt +++ b/ext/dom/tests/dom_comment_variation.phpt @@ -18,10 +18,10 @@ var_dump($root->hasChildNodes()); $children = $root->childNodes; for ($index = 0; $index < $children->length; $index++) { - echo "--- child $index ---\n"; - $current = $children->item($index); - echo get_class($current), "\n"; - var_dump($current->textContent); + echo "--- child $index ---\n"; + $current = $children->item($index); + echo get_class($current), "\n"; + var_dump($current->textContent); } --EXPECT-- bool(true) diff --git a/ext/dom/tests/dom_set_attr_node.phpt b/ext/dom/tests/dom_set_attr_node.phpt index 677dfa5e70e1..6160cd48f211 100644 --- a/ext/dom/tests/dom_set_attr_node.phpt +++ b/ext/dom/tests/dom_set_attr_node.phpt @@ -24,13 +24,13 @@ $dom2 = new DOMDocument(); $dom2->loadXML($xml2); $root2 = $dom2->documentElement; try { - $root2->setAttributeNode($attr); + $root2->setAttributeNode($attr); } catch (domexception $e) { ob_start(); - var_dump($e); - $contents = ob_get_contents(); - ob_end_clean(); - echo preg_replace('/object\(DOMAttr\).+\{.*?\}/s', 'DOMAttr', $contents); + var_dump($e); + $contents = ob_get_contents(); + ob_end_clean(); + echo preg_replace('/object\(DOMAttr\).+\{.*?\}/s', 'DOMAttr', $contents); } ?> diff --git a/ext/dom/tests/dom_xinclude.phpt b/ext/dom/tests/dom_xinclude.phpt index a698895c60a5..2f4bbf3e1aea 100644 --- a/ext/dom/tests/dom_xinclude.phpt +++ b/ext/dom/tests/dom_xinclude.phpt @@ -12,7 +12,7 @@ $dom = new domdocument; $data = file_get_contents(__DIR__."/xinclude.xml"); $reldir = str_replace(getcwd(),".",__DIR__); if (DIRECTORY_SEPARATOR == '\\') { - $reldir = str_replace('\\',"/", $reldir); + $reldir = str_replace('\\',"/", $reldir); } $data = str_replace('compress.zlib://ext/dom/tests/','compress.zlib://'.$reldir."/", $data); @@ -21,7 +21,7 @@ $dom->loadXML($data); $dom->xinclude(); print $dom->saveXML()."\n"; foreach ($dom->documentElement->childNodes as $node) { - print $node->nodeName."\n"; + print $node->nodeName."\n"; } ?> --EXPECTF-- diff --git a/ext/dom/tests/domdocument_createentityreference_001.phpt b/ext/dom/tests/domdocument_createentityreference_001.phpt index 63a352dad1df..b168ad90937a 100644 --- a/ext/dom/tests/domdocument_createentityreference_001.phpt +++ b/ext/dom/tests/domdocument_createentityreference_001.phpt @@ -6,10 +6,10 @@ Clint Priest @ PhpTek09 --FILE-- createEntityReference('Test'); - echo $objRef->nodeName . "\n"; + $objRef = $objDoc->createEntityReference('Test'); + echo $objRef->nodeName . "\n"; ?> --EXPECT-- Test diff --git a/ext/dom/tests/domelement.phpt b/ext/dom/tests/domelement.phpt index 43a6e9860358..2b669f29c8b5 100644 --- a/ext/dom/tests/domelement.phpt +++ b/ext/dom/tests/domelement.phpt @@ -67,9 +67,9 @@ $node->setAttribute('idatt', 'n1'); $node->setIdAttribute('idatt', TRUE); for ($x = 0; $x < $mylen; $x++) { - $current = $myelements->item($x); - $current->setAttributeNS('urn::dummyns', 'newns:idatt', 'n'.($x+2))."\n"; - $current->setIdAttributeNS('urn::dummyns', 'idatt', TRUE); + $current = $myelements->item($x); + $current->setAttributeNS('urn::dummyns', 'newns:idatt', 'n'.($x+2))."\n"; + $current->setIdAttributeNS('urn::dummyns', 'idatt', TRUE); } echo 'Element Name: '.(($elem = $dom->getElementByID('n1'))?$elem->localName:'Not Found')."\n"; @@ -79,8 +79,8 @@ echo 'Element Name: '.(($elem = $dom->getElementByID('n1'))?$elem->localName:'No echo 'Element Name: '.(($elem = $dom->getElementByID('n3'))?$elem->nodeName:'Not Found')."\n"; for ($x = 0; $x < $mylen; $x++) { - $node = $myelements->item($x); - $node->setIdAttributeNS('urn::dummyns', 'idatt', FALSE); + $node = $myelements->item($x); + $node->setIdAttributeNS('urn::dummyns', 'idatt', FALSE); } echo 'Element Name: '.(($elem = $dom->getElementByID('n3'))?$elem->nodeName:'Not Found')."\n"; ?> diff --git a/ext/dom/tests/domxpath.phpt b/ext/dom/tests/domxpath.phpt index da91142ef551..f67b2584aacb 100644 --- a/ext/dom/tests/domxpath.phpt +++ b/ext/dom/tests/domxpath.phpt @@ -7,17 +7,17 @@ DOMXPath Tests require_once("dom_test.inc"); function MyAverage($nodelist) { - $count = 0; - $val = 0; - foreach ($nodelist AS $node) { - $count++; - $val += $node->textContent; - } - if ($val > 0) { - return $val/$count; - } else { - return 0; - } + $count = 0; + $val = 0; + foreach ($nodelist AS $node) { + $count++; + $val += $node->textContent; + } + if ($val > 0) { + return $val/$count; + } else { + return 0; + } } $dom = new DOMDocument; @@ -31,7 +31,7 @@ $xpath->registerNamespace("php", "http://php.net/xpath"); $xpath->registerNamespace("def", "urn::default"); $nodelist = $xpath->query("//def:child"); if ($node = $nodelist->item(0)) { - print $node->textContent."\n"; + print $node->textContent."\n"; } $count = $xpath->evaluate("count(//def:child)"); diff --git a/ext/enchant/tests/broker_describe.phpt b/ext/enchant/tests/broker_describe.phpt index a25a77bd8e0e..11adb1397d56 100644 --- a/ext/enchant/tests/broker_describe.phpt +++ b/ext/enchant/tests/broker_describe.phpt @@ -36,13 +36,13 @@ if($broker) { if (is_array($provider)) { echo("OK\n"); - if ((isset($provider[$counter]['name']) && isset($provider[$counter]['desc']) && isset($provider[$counter]['file']))) { - echo("OK\n"); + if ((isset($provider[$counter]['name']) && isset($provider[$counter]['desc']) && isset($provider[$counter]['file']))) { + echo("OK\n"); - } else { - echo("failed, broker describe\n"); + } else { + echo("failed, broker describe\n"); - } + } } else { echo "failed, brocker describe array \n"; } diff --git a/ext/enchant/tests/bug13181.phpt b/ext/enchant/tests/bug13181.phpt index 742e0c79fe6f..881318cb339e 100644 --- a/ext/enchant/tests/bug13181.phpt +++ b/ext/enchant/tests/bug13181.phpt @@ -26,8 +26,8 @@ enchant_broker_free($broker); --FILE-- --EXPECTF-- Warning: exif_read_data(%s): Thumbnail goes IFD boundary or end of file reached in %sbug72627.php on line %d diff --git a/ext/exif/tests/bug72735/bug72682.phpt b/ext/exif/tests/bug72735/bug72682.phpt index 42a80b2eea73..cc3faaa10131 100644 --- a/ext/exif/tests/bug72735/bug72682.phpt +++ b/ext/exif/tests/bug72735/bug72682.phpt @@ -5,10 +5,10 @@ Bug #72735 MakerNote regression --FILE-- --EXPECT-- diff --git a/ext/exif/tests/bug72735/bug72735.phpt b/ext/exif/tests/bug72735/bug72735.phpt index 082f3e6153a1..1efd4ba4570a 100644 --- a/ext/exif/tests/bug72735/bug72735.phpt +++ b/ext/exif/tests/bug72735/bug72735.phpt @@ -5,17 +5,17 @@ Bug #72735 (Samsung picture thumb not read (zero size)) --FILE-- --EXPECT-- diff --git a/ext/exif/tests/bug73737.phpt b/ext/exif/tests/bug73737.phpt index a37b3c9583d4..a46020f468f6 100644 --- a/ext/exif/tests/bug73737.phpt +++ b/ext/exif/tests/bug73737.phpt @@ -4,8 +4,8 @@ Bug #73737 (Crash when parsing a tag format) --FILE-- --EXPECTF-- Warning: exif_thumbnail(bug73737.tiff): Process tag(x0100=ImageWidth): Cannot be empty in %s on line %d diff --git a/ext/exif/tests/sony.phpt b/ext/exif/tests/sony.phpt index 8c2bf7c58cfb..0111a82e1fce 100644 --- a/ext/exif/tests/sony.phpt +++ b/ext/exif/tests/sony.phpt @@ -7,14 +7,14 @@ Sony test $data = exif_read_data(__DIR__ . DIRECTORY_SEPARATOR . 'sony.jpg'); if (!$data) { - exit('Error: Unable to parse EXIF data'); + exit('Error: Unable to parse EXIF data'); } // Perhaps we should just test for SonyModelID since it seems to be // the most specific tag name that should be found in any Sony generated // picture foreach (['SonyModelID', 'Panorama', 'AntiBlur'] as $sony_tag) { - printf('%s was %sfound' . PHP_EOL, $sony_tag, (!isset($data[$sony_tag]) ? 'NOT ' : '')); + printf('%s was %sfound' . PHP_EOL, $sony_tag, (!isset($data[$sony_tag]) ? 'NOT ' : '')); } ?> --EXPECT-- diff --git a/ext/ffi/tests/002.phpt b/ext/ffi/tests/002.phpt index 62cb9182c4bf..353f36139c12 100644 --- a/ext/ffi/tests/002.phpt +++ b/ext/ffi/tests/002.phpt @@ -14,117 +14,117 @@ echo " ok\n"; echo "Various declarations\n"; $ffi = FFI::cdef(<<new("struct _b")); var_dump($ffi->new("c")); var_dump($ffi->new("d")); try { - var_dump($ffi->new("struct _e")); + var_dump($ffi->new("struct _e")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump($ffi->new("f")); + var_dump($ffi->new("f")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } echo "ok\n"; ?> diff --git a/ext/ffi/tests/004.phpt b/ext/ffi/tests/004.phpt index 7d265bfa68db..f5ad02098c01 100644 --- a/ext/ffi/tests/004.phpt +++ b/ext/ffi/tests/004.phpt @@ -25,10 +25,10 @@ enum _f; typedef enum _f f; enum _g { - _c1, - _c2, - _c3 = 1, - _c4, + _c1, + _c2, + _c3 = 1, + _c4, }; EOF ); @@ -40,14 +40,14 @@ var_dump($ffi->new("int[_c2]")); var_dump($ffi->new("int[_c3]")); var_dump($ffi->new("int[_c4]")); try { - var_dump($ffi->new("enum _e")); + var_dump($ffi->new("enum _e")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump($ffi->new("f")); + var_dump($ffi->new("f")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } echo "ok\n"; ?> diff --git a/ext/ffi/tests/008.phpt b/ext/ffi/tests/008.phpt index fa3991abeea7..602468d1e596 100644 --- a/ext/ffi/tests/008.phpt +++ b/ext/ffi/tests/008.phpt @@ -11,22 +11,22 @@ $a[1] = 10; $a[2] = 20; var_dump(count($a)); foreach ($a as $key => $val) { - echo "$key => $val\n"; + echo "$key => $val\n"; } $a = FFI::new("struct {int x,y;}"); try { - var_dump(count($a)); + var_dump(count($a)); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - foreach ($a as $key => $val) { - echo "$key => $val\n"; - } + foreach ($a as $key => $val) { + echo "$key => $val\n"; + } } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/ffi/tests/012.phpt b/ext/ffi/tests/012.phpt index 35686191e10f..6623bf7368fb 100644 --- a/ext/ffi/tests/012.phpt +++ b/ext/ffi/tests/012.phpt @@ -7,9 +7,9 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/ffi/tests/013.phpt b/ext/ffi/tests/013.phpt index b95acfbe4088..cfc1e85eb03a 100644 --- a/ext/ffi/tests/013.phpt +++ b/ext/ffi/tests/013.phpt @@ -12,45 +12,45 @@ var_dump(count($a[0])); var_dump(count($a[0][0])); try { - var_dump(FFI::new("void")); + var_dump(FFI::new("void")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::new("void[1]")); + var_dump(FFI::new("void[1]")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("static int foo(int)[5];"); - echo "ok\n"; + FFI::cdef("static int foo(int)[5];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("static int foo[5](int);"); - echo "ok\n"; + FFI::cdef("static int foo[5](int);"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("static int foo(int)(int);"); - echo "ok\n"; + FFI::cdef("static int foo(int)(int);"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("typedef int foo[2][];"); - echo "ok\n"; + FFI::cdef("typedef int foo[2][];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("typedef int foo[][2];"); - echo "ok\n"; + FFI::cdef("typedef int foo[][2];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/ffi/tests/015.phpt b/ext/ffi/tests/015.phpt index 5143bea109af..7b710c1dc038 100644 --- a/ext/ffi/tests/015.phpt +++ b/ext/ffi/tests/015.phpt @@ -7,52 +7,52 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; static struct DIR *ptr;"); - echo "ok\n"; + FFI::cdef("struct DIR; static struct DIR *ptr;"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR dir;"); - echo "ok\n"; + FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR dir;"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR *ptr;"); - echo "ok\n"; + FFI::cdef("struct DIR; typedef struct DIR DIR; static DIR *ptr;"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; static struct DIR foo();"); - echo "ok\n"; + FFI::cdef("struct DIR; static struct DIR foo();"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; static struct DIR* foo();"); - echo "ok\n"; + FFI::cdef("struct DIR; static struct DIR* foo();"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; static void foo(struct DIR);"); - echo "ok\n"; + FFI::cdef("struct DIR; static void foo(struct DIR);"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct DIR; static void foo(struct DIR*);"); - echo "ok\n"; + FFI::cdef("struct DIR; static void foo(struct DIR*);"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> ok diff --git a/ext/ffi/tests/016.phpt b/ext/ffi/tests/016.phpt index 89d765de03fb..2ca8363fbd9c 100644 --- a/ext/ffi/tests/016.phpt +++ b/ext/ffi/tests/016.phpt @@ -7,22 +7,22 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct X {struct X x;};"); - echo "ok\n"; + FFI::cdef("struct X {struct X x;};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct X {struct X *ptr;};"); - echo "ok\n"; + FFI::cdef("struct X {struct X *ptr;};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> ok diff --git a/ext/ffi/tests/017.phpt b/ext/ffi/tests/017.phpt index cd64a85efcdf..02b917ff2b5f 100644 --- a/ext/ffi/tests/017.phpt +++ b/ext/ffi/tests/017.phpt @@ -7,19 +7,19 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::new("struct X {struct X x;}")); + var_dump(FFI::new("struct X {struct X x;}")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::new("struct X {struct X *ptr;}")); + var_dump(FFI::new("struct X {struct X *ptr;}")); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> ok diff --git a/ext/ffi/tests/018.phpt b/ext/ffi/tests/018.phpt index 14905e74f630..f48367bc7107 100644 --- a/ext/ffi/tests/018.phpt +++ b/ext/ffi/tests/018.phpt @@ -7,16 +7,16 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct X {struct X *ptr[2];};"); - echo "ok\n"; + FFI::cdef("struct X {struct X *ptr[2];};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> ok diff --git a/ext/ffi/tests/019.phpt b/ext/ffi/tests/019.phpt index 792db2ef56be..80dcfa0ff9e8 100644 --- a/ext/ffi/tests/019.phpt +++ b/ext/ffi/tests/019.phpt @@ -7,16 +7,16 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("static int foo(int bar(int));"); - echo "ok\n"; + FFI::cdef("static int foo(int bar(int));"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> ok diff --git a/ext/ffi/tests/020.phpt b/ext/ffi/tests/020.phpt index 15660250cc6d..7aca9425a861 100644 --- a/ext/ffi/tests/020.phpt +++ b/ext/ffi/tests/020.phpt @@ -7,56 +7,56 @@ ffi.enable=1 --FILE-- x = 1; - $p->y = 1; - echo "ok\n"; + $p = FFI::new("struct {int x; const int y;}"); + $p->x = 1; + $p->y = 1; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $p = FFI::new("struct {const int x; int y;}"); - $p->y = 1; - $p->x = 1; - echo "ok\n"; + $p = FFI::new("struct {const int x; int y;}"); + $p->y = 1; + $p->x = 1; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $p = FFI::new("const struct {int x; int y;}"); - $p->x = 1; - echo "ok\n"; + $p = FFI::new("const struct {int x; int y;}"); + $p->x = 1; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $p = FFI::new("const int[10]"); - $p[1] = 1; - echo "ok\n"; + $p = FFI::new("const int[10]"); + $p[1] = 1; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $p = FFI::new("const int * [1]"); - $p[0] = null; - echo "ok\n"; + $p = FFI::new("const int * [1]"); + $p[0] = null; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $p = FFI::new("int * const [1]"); - $p[0] = null; - echo "ok\n"; + $p = FFI::new("int * const [1]"); + $p[0] = null; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $f = FFI::cdef("typedef int * const t[1];"); - $p = $f->new("t"); - $p[0] = null; - echo "ok\n"; + $f = FFI::cdef("typedef int * const t[1];"); + $p = $f->new("t"); + $p[0] = null; + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> ok diff --git a/ext/ffi/tests/021.phpt b/ext/ffi/tests/021.phpt index c76a1daf7585..d02836c5f44e 100644 --- a/ext/ffi/tests/021.phpt +++ b/ext/ffi/tests/021.phpt @@ -7,9 +7,9 @@ ffi.enable=1 --FILE-- ok --EXPECT-- diff --git a/ext/ffi/tests/024.phpt b/ext/ffi/tests/024.phpt index 95867b4e456b..f1286e49ac0d 100644 --- a/ext/ffi/tests/024.phpt +++ b/ext/ffi/tests/024.phpt @@ -6,26 +6,26 @@ FFI 024: anonymous struct/union ffi.enable=1 --FILE-- a = 1; - $p->b = 2; - $p->c = 3; - $p->d = 4; - $p->f = 5; - var_dump($p); + $p = FFI::new(" + struct { + int a; + struct { + int b; + int c; + }; + union { + int d; + uint32_t e; + }; + int f; + }"); + var_dump(FFI::sizeof($p)); + $p->a = 1; + $p->b = 2; + $p->c = 3; + $p->d = 4; + $p->f = 5; + var_dump($p); ?> --EXPECTF-- int(20) diff --git a/ext/ffi/tests/025.phpt b/ext/ffi/tests/025.phpt index d1182c485482..0abef88db88f 100644 --- a/ext/ffi/tests/025.phpt +++ b/ext/ffi/tests/025.phpt @@ -6,21 +6,21 @@ FFI 025: direct work with primitive types ffi.enable=1 --FILE-- cdata = 5; - var_dump($x); - $x->cdata += 2; - var_dump($x); - echo "$x\n\n"; - unset($x); + $x = FFI::new("int"); + $x->cdata = 5; + var_dump($x); + $x->cdata += 2; + var_dump($x); + echo "$x\n\n"; + unset($x); - $x = FFI::new("char"); - $x->cdata = 'a'; - var_dump($x); - $x->cdata++; - var_dump($x); - echo "$x\n\n"; - unset($x); + $x = FFI::new("char"); + $x->cdata = 'a'; + var_dump($x); + $x->cdata++; + var_dump($x); + echo "$x\n\n"; + unset($x); ?> --EXPECTF-- object(FFI\CData:int32_t)#%d (1) { diff --git a/ext/ffi/tests/026.phpt b/ext/ffi/tests/026.phpt index 5e4356041f7d..1c5081c188b0 100644 --- a/ext/ffi/tests/026.phpt +++ b/ext/ffi/tests/026.phpt @@ -11,7 +11,7 @@ $a[1] = 10; $a[2] = 20; var_dump($a); foreach ($a as &$val) { - $val->cdata += 5; + $val->cdata += 5; } var_dump($a); ?> diff --git a/ext/ffi/tests/027.phpt b/ext/ffi/tests/027.phpt index 14c51f77e426..aa4afe970a37 100644 --- a/ext/ffi/tests/027.phpt +++ b/ext/ffi/tests/027.phpt @@ -7,73 +7,73 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("static int (*foo)[*];"); - echo "ok\n"; + FFI::cdef("static int (*foo)[*];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("typedef int foo[*];"); - echo "ok\n"; + FFI::cdef("typedef int foo[*];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("static void foo(int[*][*]);"); - echo "ok\n"; + FFI::cdef("static void foo(int[*][*]);"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::sizeof(FFI::new("int[0]"))); + var_dump(FFI::sizeof(FFI::new("int[0]"))); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::sizeof(FFI::new("int[]"))); + var_dump(FFI::sizeof(FFI::new("int[]"))); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]")))); + var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]")))); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct _x {int a; int b[];};"); - echo "ok\n"; + FFI::cdef("struct _x {int a; int b[];};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $f = FFI::cdef("typedef int(*foo)[];"); - echo "ok\n"; + $f = FFI::cdef("typedef int(*foo)[];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $f = FFI::cdef("typedef int foo[][2];"); - echo "ok\n"; + $f = FFI::cdef("typedef int foo[][2];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $f = FFI::cdef("typedef int foo[];"); - echo "ok\n"; + $f = FFI::cdef("typedef int foo[];"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - $f = FFI::cdef("static int foo(int[]);"); - echo "ok\n"; + $f = FFI::cdef("static int foo(int[]);"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/ffi/tests/028.phpt b/ext/ffi/tests/028.phpt index 3015f784c6b8..5d1be7c8dcc1 100644 --- a/ext/ffi/tests/028.phpt +++ b/ext/ffi/tests/028.phpt @@ -7,40 +7,40 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct _x {int a; int b[];};"); - echo "ok\n"; + FFI::cdef("struct _x {int a; int b[];};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct _x {int a[0]; int b;};"); - echo "ok\n"; + FFI::cdef("struct _x {int a[0]; int b;};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct _x {int a[]; int b;};"); - echo "ok\n"; + FFI::cdef("struct _x {int a[]; int b;};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("struct _x { struct {int a; int b[];}; int c;};"); - echo "ok\n"; + FFI::cdef("struct _x { struct {int a; int b[];}; int c;};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - FFI::cdef("union _x {int a; int b[];};"); - echo "ok\n"; + FFI::cdef("union _x {int a; int b[];};"); + echo "ok\n"; } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/ffi/tests/029.phpt b/ext/ffi/tests/029.phpt index bda59788fb59..095180930684 100644 --- a/ext/ffi/tests/029.phpt +++ b/ext/ffi/tests/029.phpt @@ -7,8 +7,8 @@ ffi.enable=1 --FILE-- new("struct {char a; t1 b;}"))); var_dump(FFI::sizeof($ffi->new("struct {char a; t2 b;}"))); diff --git a/ext/ffi/tests/031.phpt b/ext/ffi/tests/031.phpt index 3298df496106..c97368a89a58 100644 --- a/ext/ffi/tests/031.phpt +++ b/ext/ffi/tests/031.phpt @@ -7,14 +7,14 @@ ffi.enable=1 --FILE-- " . get_class($e) . ": " . $e->getMessage()."\n"; - } + try { + $size = FFI::sizeof(FFI::new($type)); + if ($size !== $expected_size) { + echo "FAIL: sizeof($type) != $expected_size ($size)\n"; + } + } catch (Throwable $e) { + echo $type . "=>" . get_class($e) . ": " . $e->getMessage()."\n"; + } } test_size( 4, "struct {int a:2; int b:2;}"); diff --git a/ext/ffi/tests/032.phpt b/ext/ffi/tests/032.phpt index d785d037de3c..ade848188c50 100644 --- a/ext/ffi/tests/032.phpt +++ b/ext/ffi/tests/032.phpt @@ -7,20 +7,20 @@ ffi.enable=1 --FILE-- s->c = $i; - $p->s->d = $i; - echo "$i => 3-bit int {$p->s->c}, 3-bit uint {$p->s->d}\n"; + $p->s->c = $i; + $p->s->d = $i; + echo "$i => 3-bit int {$p->s->c}, 3-bit uint {$p->s->d}\n"; } $p->s->a = 0; $p->s->c = 0; @@ -28,7 +28,7 @@ $p->s->d = 0; $p->s->b = 0x7fffffff; echo "0x"; for ($i = 9; $i > 0;) { - printf("%02x", $p->i[--$i]); + printf("%02x", $p->i[--$i]); } echo "\n"; ?> diff --git a/ext/ffi/tests/035.phpt b/ext/ffi/tests/035.phpt index fc42f16e888a..ed98839c6e5c 100644 --- a/ext/ffi/tests/035.phpt +++ b/ext/ffi/tests/035.phpt @@ -11,9 +11,9 @@ var_dump($p); FFI::free($p); try { - var_dump($p); + var_dump($p); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECTF-- diff --git a/ext/ffi/tests/036.phpt b/ext/ffi/tests/036.phpt index 5c4e0600b832..1e989285ff67 100644 --- a/ext/ffi/tests/036.phpt +++ b/ext/ffi/tests/036.phpt @@ -9,12 +9,12 @@ ffi.enable=1 $type = FFI::type("int*"); function foo($ptr) { - global $type; - //$buf = FFI::new("int*[1]"); /* this loses type and crash */ - $buf = FFI::new(FFI::arrayType($type, [1])); - $buf[0] = $ptr; - //... - return $buf[0]; + global $type; + //$buf = FFI::new("int*[1]"); /* this loses type and crash */ + $buf = FFI::new(FFI::arrayType($type, [1])); + $buf[0] = $ptr; + //... + return $buf[0]; } $int = FFI::new("int"); diff --git a/ext/ffi/tests/037.phpt b/ext/ffi/tests/037.phpt index 0b67e4a4dae1..d8f0a88afa2f 100644 --- a/ext/ffi/tests/037.phpt +++ b/ext/ffi/tests/037.phpt @@ -7,10 +7,10 @@ ffi.enable=1 --FILE-- getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } try { - var_dump(FFI::isNull(FFI::new("int[0]"))); + var_dump(FFI::isNull(FFI::new("int[0]"))); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage()."\n"; + echo get_class($e) . ": " . $e->getMessage()."\n"; } ?> --EXPECTF-- diff --git a/ext/ffi/tests/100.phpt b/ext/ffi/tests/100.phpt index 63fae8c21555..27b6d0be0876 100644 --- a/ext/ffi/tests/100.phpt +++ b/ext/ffi/tests/100.phpt @@ -15,19 +15,19 @@ ffi.enable=1 get_zend_version())[0])); diff --git a/ext/ffi/tests/200.phpt b/ext/ffi/tests/200.phpt index fb041022ea58..69d0aafd0417 100644 --- a/ext/ffi/tests/200.phpt +++ b/ext/ffi/tests/200.phpt @@ -15,19 +15,19 @@ opcache.jit=0 --FILE-- zend_write; $zend->zend_write = function($str, $len) { - global $orig_zend_write; - $orig_zend_write("{\n\t", 3); - $ret = $orig_zend_write($str, $len); - $orig_zend_write("}\n", 2); - return $ret; + global $orig_zend_write; + $orig_zend_write("{\n\t", 3); + $ret = $orig_zend_write($str, $len); + $orig_zend_write("}\n", 2); + return $ret; }; echo "Hello World!\n"; $zend->zend_write = $orig_zend_write; diff --git a/ext/ffi/tests/301-win32.phpt b/ext/ffi/tests/301-win32.phpt index 1d0d27ffa611..82737e2e0e32 100644 --- a/ext/ffi/tests/301-win32.phpt +++ b/ext/ffi/tests/301-win32.phpt @@ -9,10 +9,10 @@ ffi.enable=1 time(); + $ffi->time(); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage() . "\n"; + echo get_class($e) . ": " . $e->getMessage() . "\n"; } try { - $ffi->time(null, null); + $ffi->time(null, null); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage() . "\n"; + echo get_class($e) . ": " . $e->getMessage() . "\n"; } try { - $ffi->fprintf($ffi->stdout); + $ffi->fprintf($ffi->stdout); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage() . "\n"; + echo get_class($e) . ": " . $e->getMessage() . "\n"; } try { - $ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World"); + $ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World"); } catch (Throwable $e) { - echo get_class($e) . ": " . $e->getMessage() . "\n"; + echo get_class($e) . ": " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/ffi/tests/bug79096.phpt b/ext/ffi/tests/bug79096.phpt index c495efc92e5a..d8d89f05bcbc 100644 --- a/ext/ffi/tests/bug79096.phpt +++ b/ext/ffi/tests/bug79096.phpt @@ -9,8 +9,8 @@ if (!extension_loaded('zend-test')) die('skip zend-test extension not available' new("dlist", false)); - $node->data = 0; - $node->next = $node; - $node->prev = $node; - $this->root = $node; - } + function __construct() { + if (is_null(self::$ffi)) { + self::$ffi = + FFI::cdef(" + typedef struct _dlist dlist; + struct _dlist { + int data; + dlist *prev; + dlist *next; + }; + "); + } + $node = FFI::addr(self::$ffi->new("dlist", false)); + $node->data = 0; + $node->next = $node; + $node->prev = $node; + $this->root = $node; + } - function __destruct() { - $root = $this->root; - $node = $root->next; - while ($node != $root) { - $prev = $node; - $node = $node->next; - FFI::free($prev); - } - FFI::free($root); - } + function __destruct() { + $root = $this->root; + $node = $root->next; + while ($node != $root) { + $prev = $node; + $node = $node->next; + FFI::free($prev); + } + FFI::free($root); + } - function add(int $data) { - $node = FFI::addr(self::$ffi->new("dlist", false)); - $node->data = $data; - $node->next = $this->root; - $node->prev = $this->root->prev; - $this->root->prev->next = $node; - $this->root->prev = $node; - } + function add(int $data) { + $node = FFI::addr(self::$ffi->new("dlist", false)); + $node->data = $data; + $node->next = $this->root; + $node->prev = $this->root->prev; + $this->root->prev->next = $node; + $this->root->prev = $node; + } - function del(int $data) { - $root = $this->root; - $node = $root->next; - while ($node != $root) { - if ($node->data == $data) { - $node->prev->next = $node->next; - $node->next->prev = $node->prev; - FFI::free($node); - break; - } - $node = $node->next; - } - } + function del(int $data) { + $root = $this->root; + $node = $root->next; + while ($node != $root) { + if ($node->data == $data) { + $node->prev->next = $node->next; + $node->next->prev = $node->prev; + FFI::free($node); + break; + } + $node = $node->next; + } + } - function print() { - echo "["; - $first = true; - $root = $this->root; - $node = $root->next; - while ($node != $root) { - if (!$first) { - echo ", "; - } else { - $first = false; - } - echo $node->data; - $node = $node->next; - } - echo "]\n"; - } + function print() { + echo "["; + $first = true; + $root = $this->root; + $node = $root->next; + while ($node != $root) { + if (!$first) { + echo ", "; + } else { + $first = false; + } + echo $node->data; + $node = $node->next; + } + echo "]\n"; + } } $dlist = new Dlist; diff --git a/ext/ffi/tests/preload.inc b/ext/ffi/tests/preload.inc index b1358de6976c..529d27c83cbb 100644 --- a/ext/ffi/tests/preload.inc +++ b/ext/ffi/tests/preload.inc @@ -1,14 +1,14 @@ file($filename)); + $finfo = new finfo(FILEINFO_MIME); + var_dump($finfo->file($filename)); - $finfo2 = new finfo(); - var_dump($finfo2->file($filename, FILEINFO_MIME)); + $finfo2 = new finfo(); + var_dump($finfo2->file($filename, FILEINFO_MIME)); } ?> diff --git a/ext/fileinfo/tests/bug67647-mb.phpt b/ext/fileinfo/tests/bug67647-mb.phpt index 310b9f2fad8f..c5ce8f9dc175 100644 --- a/ext/fileinfo/tests/bug67647-mb.phpt +++ b/ext/fileinfo/tests/bug67647-mb.phpt @@ -17,9 +17,9 @@ $f_base = "67647ç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™.mov"; $f = __DIR__ . DIRECTORY_SEPARATOR . $f_base; /* Streams mb path support is tested a lot elsewhere. Copy the existing file - therefore, avoid duplication in the repo. */ + therefore, avoid duplication in the repo. */ if (!copy($src, $f) || empty(glob($f))) { - die("failed to copy '$src' to '$f'"); + die("failed to copy '$src' to '$f'"); } $fi = new finfo(FILEINFO_MIME_TYPE); diff --git a/ext/fileinfo/tests/bug68731.phpt b/ext/fileinfo/tests/bug68731.phpt index 43083c9eec0b..c15b83c951f1 100644 --- a/ext/fileinfo/tests/bug68731.phpt +++ b/ext/fileinfo/tests/bug68731.phpt @@ -6,9 +6,9 @@ if (!class_exists('finfo')) die('skip no fileinfo extension'); --FILE-- --EXPECT-- image/gif diff --git a/ext/fileinfo/tests/bug68735.phpt b/ext/fileinfo/tests/bug68735.phpt index 7a27b995eddc..2197b2196eb3 100644 --- a/ext/fileinfo/tests/bug68735.phpt +++ b/ext/fileinfo/tests/bug68735.phpt @@ -4,10 +4,10 @@ Bug #68735 fileinfo out-of-bounds memory access --FILE-- file($test_file)); + var_dump($f->file($test_file)); ?> --EXPECTF-- diff --git a/ext/fileinfo/tests/bug71527-mb.phpt b/ext/fileinfo/tests/bug71527-mb.phpt index 91bc0510bdce..272cdba702fb 100644 --- a/ext/fileinfo/tests/bug71527-mb.phpt +++ b/ext/fileinfo/tests/bug71527-mb.phpt @@ -8,7 +8,7 @@ if (!class_exists('finfo')) USE_ZEND_ALLOC=0 --FILE-- --EXPECTF-- diff --git a/ext/fileinfo/tests/bug71527.phpt b/ext/fileinfo/tests/bug71527.phpt index 74bf9839d534..e6289b73fdee 100644 --- a/ext/fileinfo/tests/bug71527.phpt +++ b/ext/fileinfo/tests/bug71527.phpt @@ -8,7 +8,7 @@ if (!class_exists('finfo')) USE_ZEND_ALLOC=0 --FILE-- --EXPECTF-- diff --git a/ext/fileinfo/tests/cve-2014-3538-mb.phpt b/ext/fileinfo/tests/cve-2014-3538-mb.phpt index cc9084dc79d1..626c7571444b 100644 --- a/ext/fileinfo/tests/cve-2014-3538-mb.phpt +++ b/ext/fileinfo/tests/cve-2014-3538-mb.phpt @@ -21,9 +21,9 @@ var_dump(finfo_file($fi, $fd)); $t = microtime(true) - $t; finfo_close($fi); if ($t < 3) { - echo "Ok\n"; + echo "Ok\n"; } else { - printf("Failed, time=%.2f\n", $t); + printf("Failed, time=%.2f\n", $t); } ?> diff --git a/ext/fileinfo/tests/cve-2014-3538-nojit.phpt b/ext/fileinfo/tests/cve-2014-3538-nojit.phpt index 0072ab204709..02b314cbb12a 100644 --- a/ext/fileinfo/tests/cve-2014-3538-nojit.phpt +++ b/ext/fileinfo/tests/cve-2014-3538-nojit.phpt @@ -25,9 +25,9 @@ var_dump(finfo_file($fi, $fd)); $t = microtime(true) - $t; finfo_close($fi); if ($t < 1) { - echo "Ok\n"; + echo "Ok\n"; } else { - printf("Failed, time=%.2f\n", $t); + printf("Failed, time=%.2f\n", $t); } ?> diff --git a/ext/fileinfo/tests/cve-2014-3538.phpt b/ext/fileinfo/tests/cve-2014-3538.phpt index 718457442ade..a52386118674 100644 --- a/ext/fileinfo/tests/cve-2014-3538.phpt +++ b/ext/fileinfo/tests/cve-2014-3538.phpt @@ -21,9 +21,9 @@ var_dump(finfo_file($fi, $fd)); $t = microtime(true) - $t; finfo_close($fi); if ($t < 1) { - echo "Ok\n"; + echo "Ok\n"; } else { - printf("Failed, time=%.2f\n", $t); + printf("Failed, time=%.2f\n", $t); } ?> diff --git a/ext/fileinfo/tests/finfo_buffer_basic-mb.phpt b/ext/fileinfo/tests/finfo_buffer_basic-mb.phpt index ab6f042a0ba7..1c9f0d1de218 100644 --- a/ext/fileinfo/tests/finfo_buffer_basic-mb.phpt +++ b/ext/fileinfo/tests/finfo_buffer_basic-mb.phpt @@ -13,27 +13,27 @@ Test finfo_buffer() function : basic functionality $magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magicç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™'; $options = array( - FILEINFO_NONE, - FILEINFO_MIME, + FILEINFO_NONE, + FILEINFO_MIME, ); $buffers = array( - "Regular string here", - "\177ELF", - "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", - "\x55\x7A\x6E\x61", - "id=ImageMagick", - "RIFFüîò^BAVI LISTv", + "Regular string here", + "\177ELF", + "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", + "\x55\x7A\x6E\x61", + "id=ImageMagick", + "RIFFüîò^BAVI LISTv", ); echo "*** Testing finfo_buffer() : basic functionality ***\n"; foreach( $options as $option ) { - $finfo = finfo_open( $option, $magicFile ); - foreach( $buffers as $string ) { - var_dump( finfo_buffer( $finfo, $string, $option ) ); - } - finfo_close( $finfo ); + $finfo = finfo_open( $option, $magicFile ); + foreach( $buffers as $string ) { + var_dump( finfo_buffer( $finfo, $string, $option ) ); + } + finfo_close( $finfo ); } ?> diff --git a/ext/fileinfo/tests/finfo_buffer_basic.phpt b/ext/fileinfo/tests/finfo_buffer_basic.phpt index 2aeb9eb36bb6..d69d153f0d2b 100644 --- a/ext/fileinfo/tests/finfo_buffer_basic.phpt +++ b/ext/fileinfo/tests/finfo_buffer_basic.phpt @@ -13,27 +13,27 @@ Test finfo_buffer() function : basic functionality $magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magic'; $options = array( - FILEINFO_NONE, - FILEINFO_MIME, + FILEINFO_NONE, + FILEINFO_MIME, ); $buffers = array( - "Regular string here", - "\177ELF", - "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", - "\x55\x7A\x6E\x61", - "id=ImageMagick", - "RIFFüîò^BAVI LISTv", + "Regular string here", + "\177ELF", + "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", + "\x55\x7A\x6E\x61", + "id=ImageMagick", + "RIFFüîò^BAVI LISTv", ); echo "*** Testing finfo_buffer() : basic functionality ***\n"; foreach( $options as $option ) { - $finfo = finfo_open( $option, $magicFile ); - foreach( $buffers as $string ) { - var_dump( finfo_buffer( $finfo, $string, $option ) ); - } - finfo_close( $finfo ); + $finfo = finfo_open( $option, $magicFile ); + foreach( $buffers as $string ) { + var_dump( finfo_buffer( $finfo, $string, $option ) ); + } + finfo_close( $finfo ); } ?> diff --git a/ext/fileinfo/tests/finfo_buffer_variation1-mb.phpt b/ext/fileinfo/tests/finfo_buffer_variation1-mb.phpt index 4560aeabe6ab..8f26d80b92c0 100644 --- a/ext/fileinfo/tests/finfo_buffer_variation1-mb.phpt +++ b/ext/fileinfo/tests/finfo_buffer_variation1-mb.phpt @@ -13,26 +13,26 @@ Test finfo_buffer() function : basic functionality $magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magicç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™'; $options = array( - FILEINFO_NONE, - FILEINFO_MIME, + FILEINFO_NONE, + FILEINFO_MIME, ); $buffers = array( - "Regular string here", - "\177ELF", - "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", - "\x55\x7A\x6E\x61", - "id=ImageMagick", - "RIFFüîò^BAVI LISTv", + "Regular string here", + "\177ELF", + "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", + "\x55\x7A\x6E\x61", + "id=ImageMagick", + "RIFFüîò^BAVI LISTv", ); echo "*** Testing finfo_buffer() : variation functionality with oo interface ***\n"; foreach( $options as $option ) { - $finfo = new finfo( $option, $magicFile ); - foreach( $buffers as $string ) { - var_dump( $finfo->buffer( $string, $option ) ); - } + $finfo = new finfo( $option, $magicFile ); + foreach( $buffers as $string ) { + var_dump( $finfo->buffer( $string, $option ) ); + } } ?> diff --git a/ext/fileinfo/tests/finfo_buffer_variation1.phpt b/ext/fileinfo/tests/finfo_buffer_variation1.phpt index 75c0099f2007..fafaaa9376da 100644 --- a/ext/fileinfo/tests/finfo_buffer_variation1.phpt +++ b/ext/fileinfo/tests/finfo_buffer_variation1.phpt @@ -13,26 +13,26 @@ Test finfo_buffer() function : basic functionality $magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magic'; $options = array( - FILEINFO_NONE, - FILEINFO_MIME, + FILEINFO_NONE, + FILEINFO_MIME, ); $buffers = array( - "Regular string here", - "\177ELF", - "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", - "\x55\x7A\x6E\x61", - "id=ImageMagick", - "RIFFüîò^BAVI LISTv", + "Regular string here", + "\177ELF", + "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003", + "\x55\x7A\x6E\x61", + "id=ImageMagick", + "RIFFüîò^BAVI LISTv", ); echo "*** Testing finfo_buffer() : variation functionality with oo interface ***\n"; foreach( $options as $option ) { - $finfo = new finfo( $option, $magicFile ); - foreach( $buffers as $string ) { - var_dump( $finfo->buffer( $string, $option ) ); - } + $finfo = new finfo( $option, $magicFile ); + foreach( $buffers as $string ) { + var_dump( $finfo->buffer( $string, $option ) ); + } } ?> diff --git a/ext/fileinfo/tests/finfo_file_002.phpt b/ext/fileinfo/tests/finfo_file_002.phpt index aa870cdfab1e..4d5348e346d6 100644 --- a/ext/fileinfo/tests/finfo_file_002.phpt +++ b/ext/fileinfo/tests/finfo_file_002.phpt @@ -9,9 +9,9 @@ $fp = finfo_open(FILEINFO_MIME_TYPE); $results = array(); foreach (glob(__DIR__ . "/resources/*") as $filename) { - if (is_file($filename)) { - $results["$filename"] = finfo_file($fp, $filename); - } + if (is_file($filename)) { + $results["$filename"] = finfo_file($fp, $filename); + } } ksort($results); diff --git a/ext/fileinfo/tests/skipif.inc b/ext/fileinfo/tests/skipif.inc index 97b254680971..3a0642a7b30c 100644 --- a/ext/fileinfo/tests/skipif.inc +++ b/ext/fileinfo/tests/skipif.inc @@ -1,7 +1,7 @@ diff --git a/ext/filter/tests/014.phpt b/ext/filter/tests/014.phpt index 6b34a19b77e0..e79fcb017843 100644 --- a/ext/filter/tests/014.phpt +++ b/ext/filter/tests/014.phpt @@ -7,9 +7,9 @@ filter_var() and FILTER_VALIDATE_BOOLEAN class test { - function __toString() { - return "blah"; - } + function __toString() { + return "blah"; + } } $t = new test; diff --git a/ext/filter/tests/015.phpt b/ext/filter/tests/015.phpt index f9c190a0d07e..07a18745608f 100644 --- a/ext/filter/tests/015.phpt +++ b/ext/filter/tests/015.phpt @@ -50,7 +50,7 @@ array(), "http://example.com:65537", ); foreach ($values as $value) { - var_dump(filter_var($value, FILTER_VALIDATE_URL)); + var_dump(filter_var($value, FILTER_VALIDATE_URL)); } diff --git a/ext/filter/tests/016.phpt b/ext/filter/tests/016.phpt index c614903f6370..a5a58164593e 100644 --- a/ext/filter/tests/016.phpt +++ b/ext/filter/tests/016.phpt @@ -22,7 +22,7 @@ $values = Array( 'foo@bar.-' ); foreach ($values as $value) { - var_dump(filter_var($value, FILTER_VALIDATE_EMAIL)); + var_dump(filter_var($value, FILTER_VALIDATE_EMAIL)); } echo "Done\n"; diff --git a/ext/filter/tests/029.phpt b/ext/filter/tests/029.phpt index 14b516c35a8b..2c5d64cbb23b 100644 --- a/ext/filter/tests/029.phpt +++ b/ext/filter/tests/029.phpt @@ -7,7 +7,7 @@ filter_var() and FILTER_CALLBACK /* Simple callback function */ function test($var) { - return strtoupper($var); + return strtoupper($var); } var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test"))); @@ -19,9 +19,9 @@ var_dump(filter_var("qwe", FILTER_CALLBACK)); /* Simple class method callback */ class test_class { - static function test ($var) { - return strtolower($var); - } + static function test ($var) { + return strtolower($var); + } } var_dump(filter_var("dAtA", FILTER_CALLBACK, array("options"=>array("test_class", "test")))); @@ -38,7 +38,7 @@ var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test1"))); /* attempting to change data by reference */ function test2(&$var) { - $var = 1; + $var = 1; } var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test2"))); @@ -47,7 +47,7 @@ var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test2"))); /* unsetting data */ function test3(&$var) { - unset($var); + unset($var); } var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test3"))); @@ -56,21 +56,21 @@ var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test3"))); /* unset data and return value */ function test4(&$var) { - unset($var); - return 1; + unset($var); + return 1; } var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test4"))); /* thrown exception in the callback */ function test5(&$var) { - throw new Exception("test"); + throw new Exception("test"); } try { - var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test5"))); + var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test5"))); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } echo "Done\n"; diff --git a/ext/filter/tests/030.phpt b/ext/filter/tests/030.phpt index c8e7d4b6ef17..405a73335a9e 100644 --- a/ext/filter/tests/030.phpt +++ b/ext/filter/tests/030.phpt @@ -5,23 +5,23 @@ filter_var() and IPv6 --FILE-- true, - "FF01::101:127.0.1" => false, - "FF01:0:0:0:101:127.0.1.1" => false, - "FF01:0:0:0:237:101:127.0.1.1" => true, - "FF01::101" => true, - "A1080::8:800:200C:417A" => false, - "1080::8:Z00:200C:417A" => false, - "FF01::101::1" => false, - "1080::8:800:200C:417A" => true, - "1080:0:0:0:8:800:200C:417A" => true, - "2001:ec8:1:1:1:1:1:1" => true, - "ffff::FFFF:129.144.52.38" => true, - "::ffff:1.2.3.4" => true, - "0:0:0:0:0:FFFF:129.144.52.38" => true, - "0:0:0:0:0:0:13.1.68.3" => true, + "::127.0.0.1" => true, + "FF01::101:127.0.1" => false, + "FF01:0:0:0:101:127.0.1.1" => false, + "FF01:0:0:0:237:101:127.0.1.1" => true, + "FF01::101" => true, + "A1080::8:800:200C:417A" => false, + "1080::8:Z00:200C:417A" => false, + "FF01::101::1" => false, + "1080::8:800:200C:417A" => true, + "1080:0:0:0:8:800:200C:417A" => true, + "2001:ec8:1:1:1:1:1:1" => true, + "ffff::FFFF:129.144.52.38" => true, + "::ffff:1.2.3.4" => true, + "0:0:0:0:0:FFFF:129.144.52.38" => true, + "0:0:0:0:0:0:13.1.68.3" => true, "0:0:0:0:0:0:0:13.1.68.3" => false, - "::13.1.68.3" => true, + "::13.1.68.3" => true, "::FFFF:129.144.52.38" => true, "1:2:3:4:5:6::129.144.52.38" => false, @@ -50,12 +50,12 @@ $ipv6_test = array( '0:0:0::255.255.255.255' => true, ); foreach ($ipv6_test as $ip => $exp) { - $out = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); - $out = $out !== false; - if ($exp != $out) { - echo "$ip failed (expected ", $exp?"true":"false", ", got ", + $out = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); + $out = $out !== false; + if ($exp != $out) { + echo "$ip failed (expected ", $exp?"true":"false", ", got ", $out?"true":"false", ")\n"; - } + } } echo "Ok\n"; diff --git a/ext/filter/tests/031.phpt b/ext/filter/tests/031.phpt index e45e484bd450..2968decafc76 100644 --- a/ext/filter/tests/031.phpt +++ b/ext/filter/tests/031.phpt @@ -19,8 +19,8 @@ $floats = array( ); foreach ($floats as $float) { - $out = filter_var($float, FILTER_VALIDATE_FLOAT); - var_dump($out); + $out = filter_var($float, FILTER_VALIDATE_FLOAT); + var_dump($out); } $floats = array( @@ -33,8 +33,8 @@ $floats = array( echo "\ncustom decimal:\n"; foreach ($floats as $float => $dec) { - $out = filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec))); - var_dump($out); + $out = filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec))); + var_dump($out); } ?> diff --git a/ext/filter/tests/033_run.inc b/ext/filter/tests/033_run.inc index 30a7a82a011c..75ce12786836 100644 --- a/ext/filter/tests/033_run.inc +++ b/ext/filter/tests/033_run.inc @@ -6,35 +6,35 @@ function test($data) { } $data = array( - "PHP", - "1", - "foo@bar.com", - "http://a.b.c", - "1.2.3.4", - "123", - "123abc<>()", - "O'Henry", - "하í¼", - "aa:bb:cc:dd:ee:ff", + "PHP", + "1", + "foo@bar.com", + "http://a.b.c", + "1.2.3.4", + "123", + "123abc<>()", + "O'Henry", + "하í¼", + "aa:bb:cc:dd:ee:ff", ); foreach(filter_list() as $filter) { - if($filter=="validate_regexp") { - foreach($data as $k=>$d) $result[$k] = filter_var($d,filter_id($filter),array("options"=>array("regexp"=>'/^O.*/'))); - } else { - foreach($data as $k=>$d) $result[$k] = filter_var($d,filter_id($filter),array("options"=>"test")); - } - printf("%-20s",$filter); - printf("%-5s",$result[0]); - printf("%-3s",$result[1]); - printf("%-15s",$result[2]); - printf("%-20s",$result[3]); - printf("%-10s",$result[4]); - printf("%-5s",$result[5]); - printf("%-20s",$result[6]); - printf("%-15s",$result[7]); - printf("%-10s",$result[8]); - printf("%-10s\n",$result[9]); + if($filter=="validate_regexp") { + foreach($data as $k=>$d) $result[$k] = filter_var($d,filter_id($filter),array("options"=>array("regexp"=>'/^O.*/'))); + } else { + foreach($data as $k=>$d) $result[$k] = filter_var($d,filter_id($filter),array("options"=>"test")); + } + printf("%-20s",$filter); + printf("%-5s",$result[0]); + printf("%-3s",$result[1]); + printf("%-15s",$result[2]); + printf("%-20s",$result[3]); + printf("%-10s",$result[4]); + printf("%-5s",$result[5]); + printf("%-20s",$result[6]); + printf("%-15s",$result[7]); + printf("%-10s",$result[8]); + printf("%-10s\n",$result[9]); } ?> diff --git a/ext/filter/tests/034.phpt b/ext/filter/tests/034.phpt index 759420af41b3..ae0a18ee66a1 100644 --- a/ext/filter/tests/034.phpt +++ b/ext/filter/tests/034.phpt @@ -23,7 +23,7 @@ $booleans = array( foreach($booleans as $val=>$exp) { $res =filter_var($val, FILTER_VALIDATE_BOOLEAN); - if ($res !== $exp) { + if ($res !== $exp) { echo "$val failed,'$exp' expect, '$res' received.\n"; } } diff --git a/ext/filter/tests/037.phpt b/ext/filter/tests/037.phpt index e9f02afca435..431d3a724385 100644 --- a/ext/filter/tests/037.phpt +++ b/ext/filter/tests/037.phpt @@ -7,7 +7,7 @@ a=1&b=2 --FILE-- 'myfunc')); echo "\n"; @@ -19,13 +19,13 @@ echo filter_var($data, FILTER_CALLBACK, array("options"=>'myfunc')); echo "\n"; $res = filter_input_array(INPUT_GET, array( - 'a' => array( - 'filter' => FILTER_CALLBACK, - 'options' => 'myfunc' - ), - 'b' => FILTER_VALIDATE_INT - ) - ); + 'a' => array( + 'filter' => FILTER_CALLBACK, + 'options' => 'myfunc' + ), + 'b' => FILTER_VALIDATE_INT + ) + ); var_dump($res); ?> diff --git a/ext/filter/tests/043.phpt b/ext/filter/tests/043.phpt index b889e354765d..3d1e8ae140c8 100644 --- a/ext/filter/tests/043.phpt +++ b/ext/filter/tests/043.phpt @@ -7,7 +7,7 @@ Character encoding test $flags = FILTER_FLAG_ENCODE_AMP|FILTER_FLAG_ENCODE_LOW|FILTER_FLAG_ENCODE_HIGH; for ($i = 0; $i < 256; $i++) { - var_dump(filter_var(chr($i), FILTER_SANITIZE_STRING, array("flags" => $flags))); + var_dump(filter_var(chr($i), FILTER_SANITIZE_STRING, array("flags" => $flags))); } ?> --EXPECT-- diff --git a/ext/filter/tests/044.phpt b/ext/filter/tests/044.phpt index c456d473bbce..95a2f3312b4d 100644 --- a/ext/filter/tests/044.phpt +++ b/ext/filter/tests/044.phpt @@ -7,7 +7,7 @@ precision=14 --FILE-- --EXPECT-- diff --git a/ext/filter/tests/046.phpt b/ext/filter/tests/046.phpt index bc454420ad61..dc67255a7de2 100644 --- a/ext/filter/tests/046.phpt +++ b/ext/filter/tests/046.phpt @@ -7,25 +7,25 @@ Integer overflow $max = sprintf("%d", PHP_INT_MAX); switch($max) { case "2147483647": /* 32-bit systems */ - $min = "-2147483648"; - $overflow = "2147483648"; - $underflow = "-2147483649"; - break; + $min = "-2147483648"; + $overflow = "2147483648"; + $underflow = "-2147483649"; + break; case "9223372036854775807": /* 64-bit systems */ - $min = "-9223372036854775808"; - $overflow = "9223372036854775808"; - $underflow = "-9223372036854775809"; - break; + $min = "-9223372036854775808"; + $overflow = "9223372036854775808"; + $underflow = "-9223372036854775809"; + break; default: - die("failed: unknown value for PHP_MAX_INT"); - break; + die("failed: unknown value for PHP_MAX_INT"); + break; } function test_validation($val, $msg) { - $f = filter_var($val, FILTER_VALIDATE_INT); - echo "$msg filtered: "; var_dump($f); // filtered value (or false) - echo "$msg is_long: "; var_dump(is_long($f)); // test validation - echo "$msg equal: "; var_dump($val == $f); // test equality of result + $f = filter_var($val, FILTER_VALIDATE_INT); + echo "$msg filtered: "; var_dump($f); // filtered value (or false) + echo "$msg is_long: "; var_dump(is_long($f)); // test validation + echo "$msg equal: "; var_dump($val == $f); // test equality of result } // PHP_INT_MAX diff --git a/ext/filter/tests/047.phpt b/ext/filter/tests/047.phpt index cc41eabd3d97..d5566ce14d5e 100644 --- a/ext/filter/tests/047.phpt +++ b/ext/filter/tests/047.phpt @@ -5,16 +5,16 @@ Octal integer overflow --FILE-- 0) { - $len--; - if ($s[$len] != '7') { - $s[$len] = $s[$len] + 1; - return $s; - } - $s[$len] = '0'; - } - return '1'.$s; + $len = strlen($s); + while ($len > 0) { + $len--; + if ($s[$len] != '7') { + $s[$len] = $s[$len] + 1; + return $s; + } + $s[$len] = '0'; + } + return '1'.$s; } diff --git a/ext/filter/tests/048.phpt b/ext/filter/tests/048.phpt index 92ab6908c711..6edea3fd9e1b 100644 --- a/ext/filter/tests/048.phpt +++ b/ext/filter/tests/048.phpt @@ -5,20 +5,20 @@ Hex integer overflow --FILE-- 0) { - $len--; - if ($s[$len] != 'f') { - if ($s[$len] == '9') { - $s[$len] = 'a'; - } else { - $s[$len] = $s[$len] + 1; - } - return $s; - } - $s[$len] = '0'; - } - return '1'.$s; + $len = strlen($s); + while ($len > 0) { + $len--; + if ($s[$len] != 'f') { + if ($s[$len] == '9') { + $s[$len] = 'a'; + } else { + $s[$len] = $s[$len] + 1; + } + return $s; + } + $s[$len] = '0'; + } + return '1'.$s; } diff --git a/ext/filter/tests/049.phpt b/ext/filter/tests/049.phpt index 5a9977b8ff3c..0d8f0bc8c216 100644 --- a/ext/filter/tests/049.phpt +++ b/ext/filter/tests/049.phpt @@ -5,27 +5,27 @@ filter_var() and doubles with thousend separators --FILE-- 0.0, - '12345678900.1234567165' => 12345678900.1234567165, - '1,234,567,890.1234567165' => 1234567890.1234567165, - '-1,234,567,890.1234567165' => -1234567890.1234567165, - '1234,567,890.1234567165' => false, - '1,234,567,89.1234567165' => false, - '1,234,567,8900.1234567165' => false, - '1.234.567.890.1234567165' => false, - '1,234,567,8900.123,456' => false, + '0' => 0.0, + '12345678900.1234567165' => 12345678900.1234567165, + '1,234,567,890.1234567165' => 1234567890.1234567165, + '-1,234,567,890.1234567165' => -1234567890.1234567165, + '1234,567,890.1234567165' => false, + '1,234,567,89.1234567165' => false, + '1,234,567,8900.1234567165' => false, + '1.234.567.890.1234567165' => false, + '1,234,567,8900.123,456' => false, ); foreach ($test as $src => $dst) { - $out = filter_var($src, FILTER_VALIDATE_FLOAT, array("flags"=>FILTER_FLAG_ALLOW_THOUSAND)); - if ($dst !== $out) { - if ($out === false) { - echo "$src -> false != $dst\n"; - } elseif ($dst === false) { - echo "$src -> $out != false\n"; - } else { - echo "$src -> $out != $dst\n"; - } - } + $out = filter_var($src, FILTER_VALIDATE_FLOAT, array("flags"=>FILTER_FLAG_ALLOW_THOUSAND)); + if ($dst !== $out) { + if ($out === false) { + echo "$src -> false != $dst\n"; + } elseif ($dst === false) { + echo "$src -> $out != false\n"; + } else { + echo "$src -> $out != $dst\n"; + } + } } echo "Ok\n"; diff --git a/ext/filter/tests/050.phpt b/ext/filter/tests/050.phpt index 69a269f11f41..b23d0a466ec9 100644 --- a/ext/filter/tests/050.phpt +++ b/ext/filter/tests/050.phpt @@ -5,22 +5,22 @@ filter_var() and double overflow/underflow --FILE-- 1e+308, - '1e+309' => false, - '1e-323' => 1e-323, - '1e-324' => false, + '1e+308' => 1e+308, + '1e+309' => false, + '1e-323' => 1e-323, + '1e-324' => false, ); foreach ($test as $src => $dst) { - $out = filter_var($src, FILTER_VALIDATE_FLOAT); - if ($dst !== $out) { - if ($out === false) { - echo "$src -> false != $dst\n"; - } elseif ($dst === false) { - echo "$src -> $out != false\n"; - } else { - echo "$src -> $out != $dst\n"; - } - } + $out = filter_var($src, FILTER_VALIDATE_FLOAT); + if ($dst !== $out) { + if ($out === false) { + echo "$src -> false != $dst\n"; + } elseif ($dst === false) { + echo "$src -> $out != false\n"; + } else { + echo "$src -> $out != $dst\n"; + } + } } echo "Ok\n"; diff --git a/ext/filter/tests/054.phpt b/ext/filter/tests/054.phpt index c8a5dad755fe..2b6f3000dac4 100644 --- a/ext/filter/tests/054.phpt +++ b/ext/filter/tests/054.phpt @@ -8,8 +8,8 @@ filter_var_array() - using the add_empty option $data = array('foo' => 123); var_dump( - filter_var_array($data, array('foo' => array('filter' => FILTER_DEFAULT), 'bar' => array('filter' => FILTER_DEFAULT)), false), - filter_var_array($data, array('foo' => array('filter' => FILTER_DEFAULT), 'bar' => array('filter' => FILTER_DEFAULT))) + filter_var_array($data, array('foo' => array('filter' => FILTER_DEFAULT), 'bar' => array('filter' => FILTER_DEFAULT)), false), + filter_var_array($data, array('foo' => array('filter' => FILTER_DEFAULT), 'bar' => array('filter' => FILTER_DEFAULT))) ); ?> diff --git a/ext/filter/tests/055.phpt b/ext/filter/tests/055.phpt index 28f94fe40819..896dda833825 100644 --- a/ext/filter/tests/055.phpt +++ b/ext/filter/tests/055.phpt @@ -5,23 +5,23 @@ filter_var() and FILTER_VALIDATE_MAC --FILE-- array("separator" => "-"))), - array("01-23-45-67-89-ab", array("options" => array("separator" => "."))), - array("01-23-45-67-89-ab", array("options" => array("separator" => ":"))), - array("01-23-45-67-89-AB", null), - array("01-23-45-67-89-aB", null), - array("01:23:45:67:89:ab", null), - array("01:23:45:67:89:AB", null), - array("01:23:45:67:89:aB", null), - array("01:23:45-67:89:aB", null), - array("xx:23:45:67:89:aB", null), - array("0123.4567.89ab", null), - array("01-23-45-67-89-ab", array("options" => array("separator" => "--"))), - array("01-23-45-67-89-ab", array("options" => array("separator" => ""))), + array("01-23-45-67-89-ab", null), + array("01-23-45-67-89-ab", array("options" => array("separator" => "-"))), + array("01-23-45-67-89-ab", array("options" => array("separator" => "."))), + array("01-23-45-67-89-ab", array("options" => array("separator" => ":"))), + array("01-23-45-67-89-AB", null), + array("01-23-45-67-89-aB", null), + array("01:23:45:67:89:ab", null), + array("01:23:45:67:89:AB", null), + array("01:23:45:67:89:aB", null), + array("01:23:45-67:89:aB", null), + array("xx:23:45:67:89:aB", null), + array("0123.4567.89ab", null), + array("01-23-45-67-89-ab", array("options" => array("separator" => "--"))), + array("01-23-45-67-89-ab", array("options" => array("separator" => ""))), ); foreach ($values as $value) { - var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); + var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); } echo "Done\n"; diff --git a/ext/filter/tests/056.phpt b/ext/filter/tests/056.phpt index e3a4570ea786..b3ba455a4d14 100644 --- a/ext/filter/tests/056.phpt +++ b/ext/filter/tests/056.phpt @@ -25,7 +25,7 @@ array(), '\r\n', ); foreach ($values as $value) { - var_dump(filter_var($value, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)); + var_dump(filter_var($value, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)); } var_dump(filter_var('_example.com', FILTER_VALIDATE_DOMAIN)); diff --git a/ext/filter/tests/058.phpt b/ext/filter/tests/058.phpt index f3fa483ed90d..ee7965c2718b 100644 --- a/ext/filter/tests/058.phpt +++ b/ext/filter/tests/058.phpt @@ -28,7 +28,7 @@ $values = Array( 'DžǼ੧ఘⅧ⒇৪@example.com', ); foreach ($values as $value) { - var_dump(filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)); + var_dump(filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)); } echo "Done\n"; ?> diff --git a/ext/filter/tests/061.phpt b/ext/filter/tests/061.phpt index b8b3a5186ac4..77e1f5fe17d2 100644 --- a/ext/filter/tests/061.phpt +++ b/ext/filter/tests/061.phpt @@ -7,9 +7,9 @@ filter_var() and FILTER_VALIDATE_BOOL class test { - function __toString() { - return "blah"; - } + function __toString() { + return "blah"; + } } $t = new test; diff --git a/ext/filter/tests/PMOPB45.phpt b/ext/filter/tests/PMOPB45.phpt index a403b3c6e7db..477e653e48fe 100644 --- a/ext/filter/tests/PMOPB45.phpt +++ b/ext/filter/tests/PMOPB45.phpt @@ -4,8 +4,8 @@ PMOPB-45-2007:PHP ext/filter Email Validation Vulnerability --FILE-- --EXPECT-- bool(false) diff --git a/ext/filter/tests/bug52209.phpt b/ext/filter/tests/bug52209.phpt index 3035784147b6..255197c79824 100644 --- a/ext/filter/tests/bug52209.phpt +++ b/ext/filter/tests/bug52209.phpt @@ -13,7 +13,7 @@ if (empty($_ENV['PWD'])) die('skip PWD is empty'); variables_order=GPCSE --FILE-- --EXPECTF-- string(%d) "%s" diff --git a/ext/filter/tests/bug53037.phpt b/ext/filter/tests/bug53037.phpt index 82ecc7a75e6b..053786f9cd9a 100644 --- a/ext/filter/tests/bug53037.phpt +++ b/ext/filter/tests/bug53037.phpt @@ -5,7 +5,7 @@ Bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented) --FILE-- FILTER_FLAG_EMPTY_STRING_NULL)) ); ?> diff --git a/ext/filter/tests/bug7715.phpt b/ext/filter/tests/bug7715.phpt index 2f7766587dd8..0bb412c90a49 100644 --- a/ext/filter/tests/bug7715.phpt +++ b/ext/filter/tests/bug7715.phpt @@ -7,18 +7,18 @@ precision=14 --FILE-- diff --git a/ext/filter/tests/bug7733.phpt b/ext/filter/tests/bug7733.phpt index 11fce1123262..62421b3b90f9 100644 --- a/ext/filter/tests/bug7733.phpt +++ b/ext/filter/tests/bug7733.phpt @@ -5,12 +5,12 @@ filter_var() Float exponential weird result --FILE-- diff --git a/ext/filter/tests/callback_closure.phpt b/ext/filter/tests/callback_closure.phpt index 0ece4ab2851d..2c18abefde1b 100644 --- a/ext/filter/tests/callback_closure.phpt +++ b/ext/filter/tests/callback_closure.phpt @@ -5,7 +5,7 @@ callback function is a closure --FILE-- $callback))); diff --git a/ext/filter/tests/callback_non_modified_var.phpt b/ext/filter/tests/callback_non_modified_var.phpt index e546fcc89de6..22dc8b36de4f 100644 --- a/ext/filter/tests/callback_non_modified_var.phpt +++ b/ext/filter/tests/callback_non_modified_var.phpt @@ -5,7 +5,7 @@ callback function returns non modified value --FILE-- 'callback'))); diff --git a/ext/filter/tests/filter_ipv4_rfc6890.phpt b/ext/filter/tests/filter_ipv4_rfc6890.phpt index a55bb36c30d8..a8edb048f6af 100644 --- a/ext/filter/tests/filter_ipv4_rfc6890.phpt +++ b/ext/filter/tests/filter_ipv4_rfc6890.phpt @@ -20,10 +20,10 @@ $privateRanges['172.16.0.0/12'] = array('172.16.0.0', '172.31.0.0'); $privateRanges['192.168.0.0/16'] = array('192.168.0.0', '192.168.255.255'); foreach ($privateRanges as $key => $range) { - list($min, $max) = $range; - var_dump($key); - var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)); - var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)); + list($min, $max) = $range; + var_dump($key); + var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)); + var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE)); } $reservedRanges = array(); @@ -74,10 +74,10 @@ $reservedRanges['203.0.113.0/24'] = array('203.0.113.0', '203.0.113.255'); $reservedRanges['240.0.0.0/4'] = array('224.0.0.0', '255.255.255.255'); foreach ($reservedRanges as $key => $range) { - list($min, $max) = $range; - var_dump($key); - var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE)); - var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE)); + list($min, $max) = $range; + var_dump($key); + var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE)); + var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE)); } ?> diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index ed21843f431e..38599391d616 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -5,551 +5,551 @@ $errno = 0; $context = stream_context_create(array('ssl' => array('local_cert' => dirname(__FILE__).'/cert.pem'))); for ($i=0; $i<10 && !$socket; ++$i) { - $port = rand(50000, 65535); + $port = rand(50000, 65535); - $socket = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context); + $socket = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context); } //set anther random port that is not the same as $port do{ - $pasv_port = rand(50000, 65535); + $pasv_port = rand(50000, 65535); }while($pasv_port == $port); if (!$socket) { - echo "$errstr ($errno)\n"; - die("could not start/bind the ftp server\n"); + echo "$errstr ($errno)\n"; + die("could not start/bind the ftp server\n"); } $pid = pcntl_fork(); function pasv_listen($action){ - global $pasv_port, $tmp_file; - $tmp_file = 'nm2.php'; - $pid = pcntl_fork(); - if($pid === 0){ - $soc = stream_socket_server("tcp://127.0.0.1:$pasv_port"); - $fs = stream_socket_accept($soc, 3); - switch ($action) { - case 'fget': - case 'get': - //listen for 3 seconds 3 seconds - fputs($fs, "I am passive.\r\n"); - break; - case 'put': - file_put_contents($tmp_file, stream_get_contents($fs)); - break; - case 'list': - fputs($fs, "drwxr-x--- 3 owner group 4096 Jul 12 12:16 .\r\n"); - fputs($fs, "drwxr-x--- 3 owner group 4096 Jul 12 12:16 ..\r\n"); - fputs($fs, "drwxr-x--- 3 owner group 4096 Jul 12 12:16 public_ftp\r\n"); - break; - case 'list_null': - fputs($fs, "\r\n"); - break; - } - fclose($fs); - exit; - } + global $pasv_port, $tmp_file; + $tmp_file = 'nm2.php'; + $pid = pcntl_fork(); + if($pid === 0){ + $soc = stream_socket_server("tcp://127.0.0.1:$pasv_port"); + $fs = stream_socket_accept($soc, 3); + switch ($action) { + case 'fget': + case 'get': + //listen for 3 seconds 3 seconds + fputs($fs, "I am passive.\r\n"); + break; + case 'put': + file_put_contents($tmp_file, stream_get_contents($fs)); + break; + case 'list': + fputs($fs, "drwxr-x--- 3 owner group 4096 Jul 12 12:16 .\r\n"); + fputs($fs, "drwxr-x--- 3 owner group 4096 Jul 12 12:16 ..\r\n"); + fputs($fs, "drwxr-x--- 3 owner group 4096 Jul 12 12:16 public_ftp\r\n"); + break; + case 'list_null': + fputs($fs, "\r\n"); + break; + } + fclose($fs); + exit; + } } if ($pid) { - function dump_and_exit($buf) - { - var_dump($buf); - fclose($GLOBALS['s']); - exit; - } - - function anonymous() - { - return $GLOBALS['user'] === 'anonymous'; - } - - /* quick&dirty realpath() like function */ - function change_dir($dir) - { - global $cwd; - - if ($dir[0] == '/') { - $cwd = $dir; - return; - } - - $cwd = "$cwd/$dir"; - - do { - $old = $cwd; - $cwd = preg_replace('@/?[^/]+/\.\.@', '', $cwd); - } while ($old != $cwd); - - $cwd = strtr($cwd, array('//' => '/')); - if (!$cwd) $cwd = '/'; - } - - $s = stream_socket_accept($socket); - - if (!$s) die("Error accepting a new connection\n"); - - fputs($s, "220----- PHP FTP server 0.3 -----\r\n220 Service ready\r\n"); - $buf = fread($s, 2048); - - - function user_auth($buf) { - global $user, $s, $ssl, $bug37799; - - if (!empty($ssl)) { - if ($buf !== "AUTH TLS\r\n") { - fputs($s, "500 Syntax error, command unrecognized.\r\n"); - dump_and_exit($buf); - } - - if (empty($bug37799)) { - fputs($s, "234 auth type accepted\r\n"); - } else { - fputs($s, "666 dummy\r\n"); - fputs($s, "666 bogus msg\r\n"); - exit; - } - - if (!stream_socket_enable_crypto($s, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER)) { - die("SSLv23 handshake failed.\n"); - } - - if (!preg_match('/^PBSZ \d+\r\n$/', $buf = fread($s, 2048))) { - fputs($s, "501 bogus data\r\n"); - dump_and_exit($buf); - } - - fputs($s, "200 OK\r\n"); - $buf = fread($s, 2048); - - if ($buf !== "PROT P\r\n") { - fputs($s, "504 Wrong protection.\r\n"); - dump_and_exit($buf); - } - - fputs($s, "200 OK\r\n"); - - $buf = fread($s, 2048); - } - - if ($buf == "AUTH TLS\r\n") { - fputs($s, "500 not supported.\r\n"); - return ; - } else if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) { - fputs($s, "500 Syntax error, command unrecognized.\r\n"); - dump_and_exit($buf); - } - $user = $m[1]; - if ($user !== 'user' && $user !== 'anonymous') { - fputs($s, "530 Not logged in.\r\n"); - fclose($s); - exit; - } - - if (anonymous()) { - fputs($s, "230 Anonymous user logged in\r\n"); - - } else { - fputs($s, "331 User name ok, need password\r\n"); - - if (!preg_match('/^PASS (\w+)\r\n$/', $buf = fread($s, 100), $m)) { - fputs($s, "500 Syntax error, command unrecognized.\r\n"); - dump_and_exit($buf); - } - - $pass = $m[1]; - if ($pass === 'pass') { - fputs($s, "230 User logged in\r\n"); - } else { - fputs($s, "530 Not logged in.\r\n"); - fclose($s); - exit; - } - } - } - - user_auth($buf); - - $cwd = '/'; - $num_bogus_cmds = 0; - - while($buf = fread($s, 4098)) { - if (!empty($bogus)) { - fputs($s, "502 Command not implemented (".$num_bogus_cmds++.").\r\n"); - - } else if ($buf === "HELP\r\n") { - fputs($s, "214-There is help available for the following commands:\r\n"); - fputs($s, " USER\r\n"); - fputs($s, " HELP\r\n"); - fputs($s, "214 end of list\r\n"); - - } elseif ($buf === "HELP HELP\r\n") { - fputs($s, "214 Syntax: HELP [ ] \r\n"); - - } elseif ($buf === "PWD\r\n") { - fputs($s, "257 \"$cwd\" is current directory.\r\n"); - - } elseif ($buf === "CDUP\r\n") { - change_dir('..'); - fputs($s, "250 CDUP command successful.\r\n"); - - } elseif ($buf === "SYST\r\n") { - if (isset($bug27809)) { - fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n"); - } else { - fputs($s, "215 UNIX Type: L8.\r\n"); - } - - } elseif ($buf === "TYPE A\r\n") { - $ascii = true; - fputs($s, "200 OK\r\n"); - - } elseif ($buf === "AUTH SSL\r\n") { - $ascii = true; - fputs($s, "500 not supported\r\n"); - - } elseif ($buf === "TYPE I\r\n") { - $ascii = false; - fputs($s, "200 OK\r\n"); - - } elseif ($buf === "QUIT\r\n") { - break; - - } elseif (preg_match("~^PORT (\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\r\n$~", $buf, $m)) { - $host = "$m[1].$m[2].$m[3].$m[4]"; - $port = ((int)$m[5] << 8) + (int)$m[6]; - fputs($s, "200 OK.\r\n"); - - } elseif (preg_match("~^STOR ([\w/.-]+)\r\n$~", $buf, $m)) { - fputs($s, "150 File status okay; about to open data connection\r\n"); - - if(empty($pasv)) - { - if (!$fs = stream_socket_client("tcp://$host:$port")) { - fputs($s, "425 Can't open data connection\r\n"); - continue; - } - - $data = stream_get_contents($fs); - $orig = file_get_contents(dirname(__FILE__).'/'.$m[1]); - - - if (isset($ascii) && !$ascii && $orig === $data) { - fputs($s, "226 Closing data Connection.\r\n"); - - } elseif ((!empty($ascii) || isset($bug39583)) && $data === strtr($orig, array("\r\n" => "\n", "\r" => "\n", "\n" => "\r\n"))) { - fputs($s, "226 Closing data Connection.\r\n"); - - } else { - var_dump($data); - var_dump($orig); - fputs($s, "552 Requested file action aborted.\r\n"); - } - fclose($fs); - }else{ - $data = file_get_contents('nm2.php'); - $orig = file_get_contents(dirname(__FILE__).'/'.$m[1]); - if ( $orig === $data) { - fputs($s, "226 Closing data Connection.\r\n"); - - } else { - var_dump($data); - var_dump($orig); - fputs($s, "552 Requested file action aborted.\r\n"); - } - } - - } elseif (preg_match("~^APPE ([\w/.-]+)\r\n$~", $buf, $m)) { - fputs($s, "150 File status okay; about to open data connection\r\n"); - - if(empty($pasv)) - { - if (!$fs = stream_socket_client("tcp://$host:$port")) { - fputs($s, "425 Can't open data connection\r\n"); - continue; - } - - $data = stream_get_contents($fs); - file_put_contents(__DIR__.'/'.$m[1], $data, FILE_APPEND); - fputs($s, "226 Closing data Connection.\r\n"); - fclose($fs); - }else{ - $data = stream_get_contents($fs); - file_put_contents(__DIR__.'/'.$m[1], $data, FILE_APPEND); - fputs($s, "226 Closing data Connection.\r\n"); - fclose($fs); - } - - }elseif (preg_match("~^CWD ([A-Za-z./]+)\r\n$~", $buf, $m)) { - if (isset($bug77680)) { - fputs($s, "550 Directory change to $m[1] failed: file does not exist\r\n"); - var_dump($buf); - } else { - change_dir($m[1]); - fputs($s, "250 CWD command successful.\r\n"); - } - - } elseif (preg_match("~^NLST(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) { - - if (isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) { - fputs($s, "250 $m[1]: No such file or directory\r\n"); - continue; - } - - // there are some servers that don't open the ftp-data socket if there's nothing to send - if (isset($bug39458) && isset($m[1]) && $m[1] === 'emptydir') { - fputs($s, "226 Transfer complete.\r\n"); - continue; - } - - if (empty($pasv)) { - fputs($s, "150 File status okay; about to open data connection\r\n"); - if (!$fs = stream_socket_client("tcp://$host:$port")) { - fputs($s, "425 Can't open data connection\r\n"); - continue; - } - } else { - fputs($s, "125 Data connection already open; transfer starting.\r\n"); - $fs=$pasvs; - } - - - if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) { - die("SSLv23 handshake failed.\n"); - } - - if (empty($m[1]) || $m[1] !== 'emptydir') { - fputs($fs, "file1\r\nfile1\r\nfile\nb0rk\r\n"); - } - - fputs($s, "226 Closing data Connection.\r\n"); - fclose($fs); - - } elseif (preg_match("~^MKD ([A-Za-z./]+)\r\n$~", $buf, $m)) { - if (isset($bug7216)) { - fputs($s, "257 OK.\r\n"); - } else { - if (isset($bug77680)) { - var_dump($buf); - } - fputs($s, "257 \"/path/to/ftproot$cwd$m[1]\" created.\r\n"); - } - - } elseif (preg_match('/^USER /', $buf)) { - user_auth($buf); - - } elseif (preg_match('/^MDTM ([\w\h]+)/', $buf, $matches)) { - switch ($matches [1]){ - case "A": - fputs($s, "213 19980615100045.014\r\n"); - break; - case "B": - fputs($s, "213 19980615100045.014\r\n"); - break; - case "C": - fputs($s, "213 19980705132316\r\n"); - break; - case "19990929043300 File6": - fputs($s, "213 19991005213102\r\n"); - break; - default : - fputs($s, "550 No file named \"{$matches [1]}\"\r\n"); - break; - } - }elseif (preg_match('/^RETR ([\/]*[\w\h]+)/', $buf, $matches)) { - if(!empty($pasv)){ - ; - } - else if (!$fs = stream_socket_client("tcp://$host:$port")) { - fputs($s, "425 Can't open data connection\r\n"); - continue; - } - - switch($matches[1]){ - - case "pasv": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - //the data connection is handled in another forked process - // called from outside this while loop - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "a story": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - fputs($fs, "For sale: baby shoes, never worn.\r\n"); - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "binary data": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - $transfer_type = $ascii? 'ASCII' : 'BINARY' ; - fputs($fs, $transfer_type."Foo\0Bar\r\n"); - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "fget": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - $transfer_type = $ascii? 'ASCII' : 'BINARY' ; - fputs($fs, $transfer_type."FooBar\r\n"); - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "fgetresume": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - $transfer_type = $ascii? 'ASCII' : 'BINARY' ; - fputs($fs, "Bar\r\n"); - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "fget_large": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - $transfer_type = $ascii? 'ASCII' : 'BINARY' ; - if ($GLOBALS['rest_pos'] == '5368709119') { - fputs($fs, "X"); - } else { - fputs($fs, "Y"); - } - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "mediumfile": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - for($i = 0; $i < 150; $i++){ - fputs($fs, "This is line $i of the test data.\n"); - } - fputs($s, "226 Closing data Connection.\r\n"); - break; - case "/bug73457": - fputs($s, "150 File status okay; about to open data connection.\r\n"); - break; - - default: - fputs($s, "550 {$matches[1]}: No such file or directory \r\n"); - break; - } - if(isset($fs)) - fclose($fs); - - - }elseif (preg_match('/^PASV/', $buf, $matches)) { - $pasv=true; - $host = "127.0.0.1"; - $i=0; - - if (empty($bug73457)) { - do { - if (!empty($ssl)) { - $soc = @stream_socket_server("tcp://127.0.0.1:$pasv_port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context); - } else { - $soc = @stream_socket_server("tcp://127.0.0.1:$pasv_port"); - } - /* Could bind port, Try another port */ - if (!$soc) { - $pasv_port = rand(50000, 65535); - } - $i++; - } while ($i<10 && !$soc); - - if (!$soc) { - echo "$errstr ($errno)\n"; - die("could not bind passive port\n"); - } - } else { - $pasv_port=1234; - } - - $p2 = $pasv_port % ((int) 1 << 8); - $p1 = ($pasv_port-$p2)/((int) 1 << 8); - fputs($s, "227 Entering Passive Mode. (127,0,0,1,{$p1},{$p2})\r\n"); + function dump_and_exit($buf) + { + var_dump($buf); + fclose($GLOBALS['s']); + exit; + } + + function anonymous() + { + return $GLOBALS['user'] === 'anonymous'; + } + + /* quick&dirty realpath() like function */ + function change_dir($dir) + { + global $cwd; + + if ($dir[0] == '/') { + $cwd = $dir; + return; + } + + $cwd = "$cwd/$dir"; + + do { + $old = $cwd; + $cwd = preg_replace('@/?[^/]+/\.\.@', '', $cwd); + } while ($old != $cwd); + + $cwd = strtr($cwd, array('//' => '/')); + if (!$cwd) $cwd = '/'; + } + + $s = stream_socket_accept($socket); + + if (!$s) die("Error accepting a new connection\n"); + + fputs($s, "220----- PHP FTP server 0.3 -----\r\n220 Service ready\r\n"); + $buf = fread($s, 2048); + + + function user_auth($buf) { + global $user, $s, $ssl, $bug37799; + + if (!empty($ssl)) { + if ($buf !== "AUTH TLS\r\n") { + fputs($s, "500 Syntax error, command unrecognized.\r\n"); + dump_and_exit($buf); + } + + if (empty($bug37799)) { + fputs($s, "234 auth type accepted\r\n"); + } else { + fputs($s, "666 dummy\r\n"); + fputs($s, "666 bogus msg\r\n"); + exit; + } + + if (!stream_socket_enable_crypto($s, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER)) { + die("SSLv23 handshake failed.\n"); + } + + if (!preg_match('/^PBSZ \d+\r\n$/', $buf = fread($s, 2048))) { + fputs($s, "501 bogus data\r\n"); + dump_and_exit($buf); + } + + fputs($s, "200 OK\r\n"); + $buf = fread($s, 2048); + + if ($buf !== "PROT P\r\n") { + fputs($s, "504 Wrong protection.\r\n"); + dump_and_exit($buf); + } + + fputs($s, "200 OK\r\n"); + + $buf = fread($s, 2048); + } + + if ($buf == "AUTH TLS\r\n") { + fputs($s, "500 not supported.\r\n"); + return ; + } else if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) { + fputs($s, "500 Syntax error, command unrecognized.\r\n"); + dump_and_exit($buf); + } + $user = $m[1]; + if ($user !== 'user' && $user !== 'anonymous') { + fputs($s, "530 Not logged in.\r\n"); + fclose($s); + exit; + } + + if (anonymous()) { + fputs($s, "230 Anonymous user logged in\r\n"); + + } else { + fputs($s, "331 User name ok, need password\r\n"); + + if (!preg_match('/^PASS (\w+)\r\n$/', $buf = fread($s, 100), $m)) { + fputs($s, "500 Syntax error, command unrecognized.\r\n"); + dump_and_exit($buf); + } + + $pass = $m[1]; + if ($pass === 'pass') { + fputs($s, "230 User logged in\r\n"); + } else { + fputs($s, "530 Not logged in.\r\n"); + fclose($s); + exit; + } + } + } + + user_auth($buf); + + $cwd = '/'; + $num_bogus_cmds = 0; + + while($buf = fread($s, 4098)) { + if (!empty($bogus)) { + fputs($s, "502 Command not implemented (".$num_bogus_cmds++.").\r\n"); + + } else if ($buf === "HELP\r\n") { + fputs($s, "214-There is help available for the following commands:\r\n"); + fputs($s, " USER\r\n"); + fputs($s, " HELP\r\n"); + fputs($s, "214 end of list\r\n"); + + } elseif ($buf === "HELP HELP\r\n") { + fputs($s, "214 Syntax: HELP [ ] \r\n"); + + } elseif ($buf === "PWD\r\n") { + fputs($s, "257 \"$cwd\" is current directory.\r\n"); + + } elseif ($buf === "CDUP\r\n") { + change_dir('..'); + fputs($s, "250 CDUP command successful.\r\n"); + + } elseif ($buf === "SYST\r\n") { + if (isset($bug27809)) { + fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n"); + } else { + fputs($s, "215 UNIX Type: L8.\r\n"); + } + + } elseif ($buf === "TYPE A\r\n") { + $ascii = true; + fputs($s, "200 OK\r\n"); + + } elseif ($buf === "AUTH SSL\r\n") { + $ascii = true; + fputs($s, "500 not supported\r\n"); + + } elseif ($buf === "TYPE I\r\n") { + $ascii = false; + fputs($s, "200 OK\r\n"); + + } elseif ($buf === "QUIT\r\n") { + break; + + } elseif (preg_match("~^PORT (\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\r\n$~", $buf, $m)) { + $host = "$m[1].$m[2].$m[3].$m[4]"; + $port = ((int)$m[5] << 8) + (int)$m[6]; + fputs($s, "200 OK.\r\n"); + + } elseif (preg_match("~^STOR ([\w/.-]+)\r\n$~", $buf, $m)) { + fputs($s, "150 File status okay; about to open data connection\r\n"); + + if(empty($pasv)) + { + if (!$fs = stream_socket_client("tcp://$host:$port")) { + fputs($s, "425 Can't open data connection\r\n"); + continue; + } + + $data = stream_get_contents($fs); + $orig = file_get_contents(dirname(__FILE__).'/'.$m[1]); + + + if (isset($ascii) && !$ascii && $orig === $data) { + fputs($s, "226 Closing data Connection.\r\n"); + + } elseif ((!empty($ascii) || isset($bug39583)) && $data === strtr($orig, array("\r\n" => "\n", "\r" => "\n", "\n" => "\r\n"))) { + fputs($s, "226 Closing data Connection.\r\n"); + + } else { + var_dump($data); + var_dump($orig); + fputs($s, "552 Requested file action aborted.\r\n"); + } + fclose($fs); + }else{ + $data = file_get_contents('nm2.php'); + $orig = file_get_contents(dirname(__FILE__).'/'.$m[1]); + if ( $orig === $data) { + fputs($s, "226 Closing data Connection.\r\n"); + + } else { + var_dump($data); + var_dump($orig); + fputs($s, "552 Requested file action aborted.\r\n"); + } + } + + } elseif (preg_match("~^APPE ([\w/.-]+)\r\n$~", $buf, $m)) { + fputs($s, "150 File status okay; about to open data connection\r\n"); + + if(empty($pasv)) + { + if (!$fs = stream_socket_client("tcp://$host:$port")) { + fputs($s, "425 Can't open data connection\r\n"); + continue; + } + + $data = stream_get_contents($fs); + file_put_contents(__DIR__.'/'.$m[1], $data, FILE_APPEND); + fputs($s, "226 Closing data Connection.\r\n"); + fclose($fs); + }else{ + $data = stream_get_contents($fs); + file_put_contents(__DIR__.'/'.$m[1], $data, FILE_APPEND); + fputs($s, "226 Closing data Connection.\r\n"); + fclose($fs); + } + + }elseif (preg_match("~^CWD ([A-Za-z./]+)\r\n$~", $buf, $m)) { + if (isset($bug77680)) { + fputs($s, "550 Directory change to $m[1] failed: file does not exist\r\n"); + var_dump($buf); + } else { + change_dir($m[1]); + fputs($s, "250 CWD command successful.\r\n"); + } + + } elseif (preg_match("~^NLST(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) { + + if (isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) { + fputs($s, "250 $m[1]: No such file or directory\r\n"); + continue; + } + + // there are some servers that don't open the ftp-data socket if there's nothing to send + if (isset($bug39458) && isset($m[1]) && $m[1] === 'emptydir') { + fputs($s, "226 Transfer complete.\r\n"); + continue; + } + + if (empty($pasv)) { + fputs($s, "150 File status okay; about to open data connection\r\n"); + if (!$fs = stream_socket_client("tcp://$host:$port")) { + fputs($s, "425 Can't open data connection\r\n"); + continue; + } + } else { + fputs($s, "125 Data connection already open; transfer starting.\r\n"); + $fs=$pasvs; + } + + + if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) { + die("SSLv23 handshake failed.\n"); + } + + if (empty($m[1]) || $m[1] !== 'emptydir') { + fputs($fs, "file1\r\nfile1\r\nfile\nb0rk\r\n"); + } + + fputs($s, "226 Closing data Connection.\r\n"); + fclose($fs); + + } elseif (preg_match("~^MKD ([A-Za-z./]+)\r\n$~", $buf, $m)) { + if (isset($bug7216)) { + fputs($s, "257 OK.\r\n"); + } else { + if (isset($bug77680)) { + var_dump($buf); + } + fputs($s, "257 \"/path/to/ftproot$cwd$m[1]\" created.\r\n"); + } + + } elseif (preg_match('/^USER /', $buf)) { + user_auth($buf); + + } elseif (preg_match('/^MDTM ([\w\h]+)/', $buf, $matches)) { + switch ($matches [1]){ + case "A": + fputs($s, "213 19980615100045.014\r\n"); + break; + case "B": + fputs($s, "213 19980615100045.014\r\n"); + break; + case "C": + fputs($s, "213 19980705132316\r\n"); + break; + case "19990929043300 File6": + fputs($s, "213 19991005213102\r\n"); + break; + default : + fputs($s, "550 No file named \"{$matches [1]}\"\r\n"); + break; + } + }elseif (preg_match('/^RETR ([\/]*[\w\h]+)/', $buf, $matches)) { + if(!empty($pasv)){ + ; + } + else if (!$fs = stream_socket_client("tcp://$host:$port")) { + fputs($s, "425 Can't open data connection\r\n"); + continue; + } + + switch($matches[1]){ + + case "pasv": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + //the data connection is handled in another forked process + // called from outside this while loop + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "a story": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + fputs($fs, "For sale: baby shoes, never worn.\r\n"); + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "binary data": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + $transfer_type = $ascii? 'ASCII' : 'BINARY' ; + fputs($fs, $transfer_type."Foo\0Bar\r\n"); + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "fget": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + $transfer_type = $ascii? 'ASCII' : 'BINARY' ; + fputs($fs, $transfer_type."FooBar\r\n"); + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "fgetresume": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + $transfer_type = $ascii? 'ASCII' : 'BINARY' ; + fputs($fs, "Bar\r\n"); + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "fget_large": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + $transfer_type = $ascii? 'ASCII' : 'BINARY' ; + if ($GLOBALS['rest_pos'] == '5368709119') { + fputs($fs, "X"); + } else { + fputs($fs, "Y"); + } + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "mediumfile": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + for($i = 0; $i < 150; $i++){ + fputs($fs, "This is line $i of the test data.\n"); + } + fputs($s, "226 Closing data Connection.\r\n"); + break; + case "/bug73457": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + break; + + default: + fputs($s, "550 {$matches[1]}: No such file or directory \r\n"); + break; + } + if(isset($fs)) + fclose($fs); + + + }elseif (preg_match('/^PASV/', $buf, $matches)) { + $pasv=true; + $host = "127.0.0.1"; + $i=0; + + if (empty($bug73457)) { + do { + if (!empty($ssl)) { + $soc = @stream_socket_server("tcp://127.0.0.1:$pasv_port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context); + } else { + $soc = @stream_socket_server("tcp://127.0.0.1:$pasv_port"); + } + /* Could bind port, Try another port */ + if (!$soc) { + $pasv_port = rand(50000, 65535); + } + $i++; + } while ($i<10 && !$soc); + + if (!$soc) { + echo "$errstr ($errno)\n"; + die("could not bind passive port\n"); + } + } else { + $pasv_port=1234; + } + + $p2 = $pasv_port % ((int) 1 << 8); + $p1 = ($pasv_port-$p2)/((int) 1 << 8); + fputs($s, "227 Entering Passive Mode. (127,0,0,1,{$p1},{$p2})\r\n"); if (empty($bug73457)) { $pasvs = stream_socket_accept($soc,10); } - } elseif (preg_match('/^EPSV/', $buf, $matches)) { - fputs($s, "550 Extended passsive mode not supported.\r\n"); - } elseif (preg_match('/^SITE EXEC/', $buf, $matches)) { - fputs($s, "200 OK\r\n"); - - } elseif (preg_match('/^RMD/', $buf, $matches)) { - fputs($s, "250 OK\r\n"); - - } elseif (preg_match('/^SITE CHMOD/', $buf, $matches)) { - fputs($s, "200 OK\r\n"); - - } elseif (preg_match('/^DELE ([\w\h]+)/', $buf, $matches)) { - if (isset($matches[1]) && in_array($matches[1], ['file1', "file\nb0rk"])){ - fputs($s, "250 Delete successful\r\n"); - } else { - fputs($s, "550 No such file or directory\r\n"); - } - } elseif (preg_match('/^ALLO (\d+)/', $buf, $matches)) { - fputs($s, "200 " . $matches[1] . " bytes allocated\r\n"); - - }elseif (preg_match('/^LIST www\//', $buf, $matches)) { - fputs($s, "226 Transfer complete\r\n"); - - }elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) { - fputs($s, "425 Error establishing connection\r\n"); - - }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { - $GLOBALS['rest_pos'] = $matches[1]; - fputs($s, "350 OK\r\n"); - }elseif (preg_match('/^SIZE largefile/', $buf)) { - fputs($s, "213 5368709120\r\n"); - }elseif (preg_match('/^RNFR existing_file/', $buf, $matches)) { - fputs($s, "350 File or directory exists, ready for destination name\r\n"); - }elseif (preg_match('/^RNFR nonexisting_file/', $buf, $matches)) { - fputs($s, "550 No such file or directory\r\n"); - }elseif (preg_match('/^RNTO nonexisting_file/', $buf, $matches)) { - fputs($s, "250 Rename successful\r\n"); - }elseif (preg_match('/^MLSD no_exists\//', $buf, $matches)) { - fputs($s, "425 Error establishing connection\r\n"); - }elseif (preg_match("~^MLSD(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) { - - if(isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) { - fputs($s, "250 $m[1]: No such file or directory\r\n"); - continue; - } - - // there are some servers that don't open the ftp-data socket if there's nothing to send - if(isset($bug39458) && isset($m[1]) && $m[1] === 'emptydir') { - fputs($s, "226 Transfer complete.\r\n"); - continue; - } - - if(empty($pasv)) { - fputs($s, "150 File status okay; about to open data connection\r\n"); - if(!$fs = stream_socket_client("tcp://$host:$port")) { - fputs($s, "425 Can't open data connection\r\n"); - continue; - } - } else { - fputs($s, "125 Data connection already open; transfer starting.\r\n"); - $fs = $pasvs; - } - - if((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, TRUE, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) { - die("SSLv23 handshake failed.\n"); - } - - if(empty($m[1]) || $m[1] !== 'emptydir') { - fputs($fs, "modify=20170127230002;perm=flcdmpe;type=cdir;unique=811U4340002;UNIX.group=33;UNIX.mode=0755;UNIX.owner=33; .\r\n"); - fputs($fs, "modify=20170127230002;perm=flcdmpe;type=pdir;unique=811U4340002;UNIX.group=33;UNIX.mode=0755;UNIX.owner=33; ..\r\n"); - fputs($fs, "modify=20170126121225;perm=adfrw;size=4729;type=file;unique=811U4340CB9;UNIX.group=33;UNIX.mode=0644;UNIX.owner=33; foobar\r\n"); - fputs($fs, "fact=val=ue;empty=; path;name\r\n"); - fputs($fs, "no_space\r\n"); - fputs($fs, "no_semi pathname\r\n"); - fputs($fs, "no_eq; pathname\r\n"); - } - - fputs($s, "226 Closing data Connection.\r\n"); - fclose($fs); - }elseif (preg_match('/^SIZE \/bug73457/', $buf)) { - fputs($s, "213 10\r\n"); - }elseif (preg_match("/^SITE/", $buf)) { - fputs($s, "500 Syntax error, command unrecognized.\r\n"); - }else { - dump_and_exit($buf); - } - } - fclose($s); - exit; + } elseif (preg_match('/^EPSV/', $buf, $matches)) { + fputs($s, "550 Extended passsive mode not supported.\r\n"); + } elseif (preg_match('/^SITE EXEC/', $buf, $matches)) { + fputs($s, "200 OK\r\n"); + + } elseif (preg_match('/^RMD/', $buf, $matches)) { + fputs($s, "250 OK\r\n"); + + } elseif (preg_match('/^SITE CHMOD/', $buf, $matches)) { + fputs($s, "200 OK\r\n"); + + } elseif (preg_match('/^DELE ([\w\h]+)/', $buf, $matches)) { + if (isset($matches[1]) && in_array($matches[1], ['file1', "file\nb0rk"])){ + fputs($s, "250 Delete successful\r\n"); + } else { + fputs($s, "550 No such file or directory\r\n"); + } + } elseif (preg_match('/^ALLO (\d+)/', $buf, $matches)) { + fputs($s, "200 " . $matches[1] . " bytes allocated\r\n"); + + }elseif (preg_match('/^LIST www\//', $buf, $matches)) { + fputs($s, "226 Transfer complete\r\n"); + + }elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) { + fputs($s, "425 Error establishing connection\r\n"); + + }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { + $GLOBALS['rest_pos'] = $matches[1]; + fputs($s, "350 OK\r\n"); + }elseif (preg_match('/^SIZE largefile/', $buf)) { + fputs($s, "213 5368709120\r\n"); + }elseif (preg_match('/^RNFR existing_file/', $buf, $matches)) { + fputs($s, "350 File or directory exists, ready for destination name\r\n"); + }elseif (preg_match('/^RNFR nonexisting_file/', $buf, $matches)) { + fputs($s, "550 No such file or directory\r\n"); + }elseif (preg_match('/^RNTO nonexisting_file/', $buf, $matches)) { + fputs($s, "250 Rename successful\r\n"); + }elseif (preg_match('/^MLSD no_exists\//', $buf, $matches)) { + fputs($s, "425 Error establishing connection\r\n"); + }elseif (preg_match("~^MLSD(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) { + + if(isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) { + fputs($s, "250 $m[1]: No such file or directory\r\n"); + continue; + } + + // there are some servers that don't open the ftp-data socket if there's nothing to send + if(isset($bug39458) && isset($m[1]) && $m[1] === 'emptydir') { + fputs($s, "226 Transfer complete.\r\n"); + continue; + } + + if(empty($pasv)) { + fputs($s, "150 File status okay; about to open data connection\r\n"); + if(!$fs = stream_socket_client("tcp://$host:$port")) { + fputs($s, "425 Can't open data connection\r\n"); + continue; + } + } else { + fputs($s, "125 Data connection already open; transfer starting.\r\n"); + $fs = $pasvs; + } + + if((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, TRUE, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) { + die("SSLv23 handshake failed.\n"); + } + + if(empty($m[1]) || $m[1] !== 'emptydir') { + fputs($fs, "modify=20170127230002;perm=flcdmpe;type=cdir;unique=811U4340002;UNIX.group=33;UNIX.mode=0755;UNIX.owner=33; .\r\n"); + fputs($fs, "modify=20170127230002;perm=flcdmpe;type=pdir;unique=811U4340002;UNIX.group=33;UNIX.mode=0755;UNIX.owner=33; ..\r\n"); + fputs($fs, "modify=20170126121225;perm=adfrw;size=4729;type=file;unique=811U4340CB9;UNIX.group=33;UNIX.mode=0644;UNIX.owner=33; foobar\r\n"); + fputs($fs, "fact=val=ue;empty=; path;name\r\n"); + fputs($fs, "no_space\r\n"); + fputs($fs, "no_semi pathname\r\n"); + fputs($fs, "no_eq; pathname\r\n"); + } + + fputs($s, "226 Closing data Connection.\r\n"); + fclose($fs); + }elseif (preg_match('/^SIZE \/bug73457/', $buf)) { + fputs($s, "213 10\r\n"); + }elseif (preg_match("/^SITE/", $buf)) { + fputs($s, "500 Syntax error, command unrecognized.\r\n"); + }else { + dump_and_exit($buf); + } + } + fclose($s); + exit; } fclose($socket); diff --git a/ext/gd/tests/bug22544-mb.phpt b/ext/gd/tests/bug22544-mb.phpt index 0847214dc3a9..ae347edd70f2 100644 --- a/ext/gd/tests/bug22544-mb.phpt +++ b/ext/gd/tests/bug22544-mb.phpt @@ -8,13 +8,13 @@ Bug #22544 (TrueColor transparency in PNG images). ?> --FILE-- --EXPECT-- The images are equal. diff --git a/ext/gd/tests/bug22544.phpt b/ext/gd/tests/bug22544.phpt index 3d4335d46150..c7b1e91966d6 100644 --- a/ext/gd/tests/bug22544.phpt +++ b/ext/gd/tests/bug22544.phpt @@ -8,13 +8,13 @@ Bug #22544 (TrueColor transparency in PNG images). ?> --FILE-- --EXPECT-- The images are equal. diff --git a/ext/gd/tests/bug24155.phpt b/ext/gd/tests/bug24155.phpt index 43d34b7177ba..ff4f40fdeced 100644 --- a/ext/gd/tests/bug24155.phpt +++ b/ext/gd/tests/bug24155.phpt @@ -9,22 +9,22 @@ Bug #24155 (gdImageRotate270 rotation problem). ?> --FILE-- --EXPECT-- 16776960 diff --git a/ext/gd/tests/bug24594.phpt b/ext/gd/tests/bug24594.phpt index f4006497c60f..138258cbbc74 100644 --- a/ext/gd/tests/bug24594.phpt +++ b/ext/gd/tests/bug24594.phpt @@ -8,74 +8,74 @@ Bug #24594 (Filling an area using tiles). ?> --FILE-- --EXPECT-- 000000111111101010 diff --git a/ext/gd/tests/bug42434.phpt b/ext/gd/tests/bug42434.phpt index 8f5205d9366e..3db42a228e0e 100644 --- a/ext/gd/tests/bug42434.phpt +++ b/ext/gd/tests/bug42434.phpt @@ -15,9 +15,9 @@ imageantialias($im, true); imageline($im, 0, 0, 10, 0, 0x000000); if (imagecolorat($im, 9, 0) == 0x000000) { - echo 'DONE'; + echo 'DONE'; } else { - echo 'Bugged'; + echo 'Bugged'; } imagedestroy($im); diff --git a/ext/gd/tests/bug43073.phpt b/ext/gd/tests/bug43073.phpt index c52bdad5bedf..74641496de97 100644 --- a/ext/gd/tests/bug43073.phpt +++ b/ext/gd/tests/bug43073.phpt @@ -8,22 +8,22 @@ Bug #43073 (TrueType bounding box is wrong for angle<>0) --FILE-- = $exp[$i][$j] - 1 && $bbox[$j] <= $exp[$i][$j] + 1) { - echo '.'; - } else { - echo "(expected $exp[$i][$j], got $bbox[$j])"; - } + if ($bbox[$j] >= $exp[$i][$j] - 1 && $bbox[$j] <= $exp[$i][$j] + 1) { + echo '.'; + } else { + echo "(expected $exp[$i][$j], got $bbox[$j])"; + } } echo "\n"; $temp = $cos_t * $x + $sin_t * $y; diff --git a/ext/gd/tests/bug43475.phpt b/ext/gd/tests/bug43475.phpt index f0302d45efc6..9264299181c2 100644 --- a/ext/gd/tests/bug43475.phpt +++ b/ext/gd/tests/bug43475.phpt @@ -13,22 +13,22 @@ require_once __DIR__ . '/similarity.inc'; function setStyleAndThickness($im, $color, $thickness) { - $style = array(); - $i = 0; - while ($i < 16 * $thickness) { - $style[$i++] = $color; - } - while ($i < 20 * $thickness) { - $style[$i++] = IMG_COLOR_TRANSPARENT; - } - while ($i < 28 * $thickness) { - $style[$i++] = $color; - } - while ($i < 32 * $thickness) { - $style[$i++] = IMG_COLOR_TRANSPARENT; - } - imagesetstyle($im, $style); - imagesetthickness($im, $thickness); + $style = array(); + $i = 0; + while ($i < 16 * $thickness) { + $style[$i++] = $color; + } + while ($i < 20 * $thickness) { + $style[$i++] = IMG_COLOR_TRANSPARENT; + } + while ($i < 28 * $thickness) { + $style[$i++] = $color; + } + while ($i < 32 * $thickness) { + $style[$i++] = IMG_COLOR_TRANSPARENT; + } + imagesetstyle($im, $style); + imagesetthickness($im, $thickness); } $im = imagecreate(800, 800); diff --git a/ext/gd/tests/bug44849.phpt b/ext/gd/tests/bug44849.phpt index 368a08a2422d..22e8a65ec45b 100644 --- a/ext/gd/tests/bug44849.phpt +++ b/ext/gd/tests/bug44849.phpt @@ -6,7 +6,7 @@ Bug #44849 (imagecolorclosesthwb is not available on Windows) ?> --FILE-- --EXPECT-- bool(true) diff --git a/ext/gd/tests/bug49600.phpt b/ext/gd/tests/bug49600.phpt index 25fae3ca374c..79830be71f96 100644 --- a/ext/gd/tests/bug49600.phpt +++ b/ext/gd/tests/bug49600.phpt @@ -15,7 +15,7 @@ $color = imagecolorallocate($image, 255, 255, 255); foreach (array("E", "I", "P", "g", "i", "q") as $c) { $x = imagettftext($image, 32, 0, 0, 0, $color, $font, $c); - $y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c); + $y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c); if ( abs($x[0] - $y[0]) > 1 || abs($x[2] - $y[2]) > 1 || abs($x[4] - $y[4]) > 1 diff --git a/ext/gd/tests/bug53504.phpt b/ext/gd/tests/bug53504.phpt index c44e4ef0f81b..11e7a8af57f2 100644 --- a/ext/gd/tests/bug53504.phpt +++ b/ext/gd/tests/bug53504.phpt @@ -51,16 +51,16 @@ $tests = [ foreach ($tests as $testnum => $test) { $bbox = imageftbbox($test['fontSize'], $test['angle'], $font, $test['text']); - printf('%2d: ', $testnum); - for ($i = 0; $i < 8; $i++) { - $exp = $test['exp'][$i]; - if ($bbox[$i] >= $exp - 2 && $bbox[$i] <= $exp + 2) { - echo '.'; - } else { - echo "(expected $exp, got $bbox[$i])"; - } - } - echo "\n"; + printf('%2d: ', $testnum); + for ($i = 0; $i < 8; $i++) { + $exp = $test['exp'][$i]; + if ($bbox[$i] >= $exp - 2 && $bbox[$i] <= $exp + 2) { + echo '.'; + } else { + echo "(expected $exp, got $bbox[$i])"; + } + } + echo "\n"; $bboxDrawn = imagefttext($g, $test['fontSize'], $test['angle'], $test['x'], $test['y'], $black, $font, $test['text']); diff --git a/ext/gd/tests/bug64641.phpt b/ext/gd/tests/bug64641.phpt index 2d5768eece80..4eb2e28730c7 100644 --- a/ext/gd/tests/bug64641.phpt +++ b/ext/gd/tests/bug64641.phpt @@ -14,24 +14,24 @@ require_once __DIR__ . '/similarity.inc'; $im = imagecreatetruecolor(640, 480); $points = array( - 100, 100, - 100, 200, - 100, 300 + 100, 100, + 100, 200, + 100, 300 ); imagefilledpolygon($im, $points, 0xFFFF00); $points = array( - 300, 200, - 400, 200, - 500, 200 + 300, 200, + 400, 200, + 500, 200 ); imagefilledpolygon($im, $points, 0xFFFF00); $ex = imagecreatefrompng(__DIR__ . '/bug64641.png'); if (($diss = calc_image_dissimilarity($ex, $im)) < 1e-5) { - echo "IDENTICAL"; + echo "IDENTICAL"; } else { - echo "DISSIMILARITY: $diss"; + echo "DISSIMILARITY: $diss"; } imagedestroy($ex); diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt index c9a9588343ee..c5b54354f140 100644 --- a/ext/gd/tests/bug67248.phpt +++ b/ext/gd/tests/bug67248.phpt @@ -10,7 +10,7 @@ Bug #67248 (imageaffinematrixget missing check of parameters) require __DIR__ . '/func.inc'; for($i=0;$i<7;$i++) { - trycatch_dump( + trycatch_dump( fn() => imageaffinematrixget($i) ); } diff --git a/ext/gd/tests/bug72339.phpt b/ext/gd/tests/bug72339.phpt index 5b5fdb6ee657..bd8054cced24 100644 --- a/ext/gd/tests/bug72339.phpt +++ b/ext/gd/tests/bug72339.phpt @@ -26,7 +26,7 @@ fclose($fh); $im = imagecreatefromgd2($fname); if ($im) { - imagedestroy($im); + imagedestroy($im); } unlink($fname); diff --git a/ext/gd/tests/bug72709.phpt b/ext/gd/tests/bug72709.phpt index 2963f1c1041d..a5b0463f6270 100644 --- a/ext/gd/tests/bug72709.phpt +++ b/ext/gd/tests/bug72709.phpt @@ -8,7 +8,7 @@ if (!extension_loaded('gd')) die('skip ext/gd not available'); --EXPECT-- diff --git a/ext/gd/tests/copypalette.phpt b/ext/gd/tests/copypalette.phpt index 3e29b42a4344..747011e69a10 100644 --- a/ext/gd/tests/copypalette.phpt +++ b/ext/gd/tests/copypalette.phpt @@ -9,18 +9,18 @@ imagepalettecopy $failed = false; $im = imagecreate(1,1); for ($i=0; $i<256; $i++) { - imagecolorallocate($im, $i, $i, $i); + imagecolorallocate($im, $i, $i, $i); } $im2 = imagecreate(1,1); imagepalettecopy($im2, $im); for ($i=0; $i<256; $i++) { - $c = imagecolorsforindex($im2, $i); - if ($c['red']!=$i || $c['green']!=$i || $c['blue']!=$i) { - $failed = true; - break; - } + $c = imagecolorsforindex($im2, $i); + if ($c['red']!=$i || $c['green']!=$i || $c['blue']!=$i) { + $failed = true; + break; + } } echo "copy palette 255 colors: "; echo $failed ? 'failed' : 'ok'; @@ -33,7 +33,7 @@ imagecolorallocatealpha($im, 0,0,0,100); imagepalettecopy($im2, $im); $c = imagecolorsforindex($im2, 0); if ($c['red']!=0 || $c['green']!=0 || $c['blue']!=0 || $c['alpha']!=100) { - $failed = true; + $failed = true; } echo 'copy palette 1 color and alpha: '; echo $failed ? 'failed' : 'ok'; diff --git a/ext/gd/tests/copyresized.phpt b/ext/gd/tests/copyresized.phpt index df4996332dcf..2af9cc9682f4 100644 --- a/ext/gd/tests/copyresized.phpt +++ b/ext/gd/tests/copyresized.phpt @@ -8,32 +8,32 @@ imagecopyresized "); + exit("Failed to create <$filename>"); } //write header @@ -34,7 +34,7 @@ fputs($fp, chr($c), 1); /*write some data to cause overflow*/ for ($i=0; $i<10000; $i++) { - fwrite($fp, chr($c), 1); + fwrite($fp, chr($c), 1); } fclose($fp); diff --git a/ext/gd/tests/createfromwbmp2_extern.phpt b/ext/gd/tests/createfromwbmp2_extern.phpt index 0aff8d8b9311..ad7a130c18df 100644 --- a/ext/gd/tests/createfromwbmp2_extern.phpt +++ b/ext/gd/tests/createfromwbmp2_extern.phpt @@ -10,7 +10,7 @@ imagecreatefromwbmp with invalid wbmp $filename = __DIR__ . '/_tmp.wbmp'; $fp = fopen($filename,"wb"); if (!$fp) { - exit("Failed to create <$filename>"); + exit("Failed to create <$filename>"); } //write header @@ -34,7 +34,7 @@ fputs($fp, chr($c), 1); /*write some data to cause overflow*/ for ($i=0; $i<10000; $i++) { - fwrite($fp, chr($c), 1); + fwrite($fp, chr($c), 1); } fclose($fp); diff --git a/ext/gd/tests/dashedlines.phpt b/ext/gd/tests/dashedlines.phpt index b6d4892c8858..bcf17174ccb1 100644 --- a/ext/gd/tests/dashedlines.phpt +++ b/ext/gd/tests/dashedlines.phpt @@ -26,7 +26,7 @@ $p5 = imagecolorat($im, 5,5) == $b; if ($p1 && $p2 && $p3 && $p4 && $p5) { - echo "Horizontal: ok\n"; + echo "Horizontal: ok\n"; } imagedestroy($im); @@ -46,7 +46,7 @@ $p5 = imagecolorat($im, 2,4) == $r; $p6 = imagecolorat($im, 2,5) == $b; if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { - echo "Vertical: ok\n"; + echo "Vertical: ok\n"; } imagedestroy($im); @@ -66,7 +66,7 @@ $p5 = imagecolorat($im, 4,4) == $r; $p6 = imagecolorat($im, 5,5) == $b; if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { - echo "Diagonal: ok\n"; + echo "Diagonal: ok\n"; } imagedestroy($im); diff --git a/ext/gd/tests/func.inc b/ext/gd/tests/func.inc index faa0b0681622..5273f998300b 100644 --- a/ext/gd/tests/func.inc +++ b/ext/gd/tests/func.inc @@ -2,61 +2,61 @@ function get_gd_version() { - return GD_VERSION; + return GD_VERSION; } function get_php_info() { - ob_start(); - phpinfo(); - $info = ob_get_contents(); - ob_end_clean(); + ob_start(); + phpinfo(); + $info = ob_get_contents(); + ob_end_clean(); - return $info; + return $info; } function get_freetype_version() { - $version = 0; + $version = 0; - if (preg_match(',FreeType Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) { - $version = $match[1]; - } + if (preg_match(',FreeType Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) { + $version = $match[1]; + } - return $version; + return $version; } function get_libjpeg_version() { - $version = 0; + $version = 0; - if (preg_match(',libJPEG Version => ([a-z0-9]+),s', get_php_info(), $match)) { - $version = $match[1]; - } + if (preg_match(',libJPEG Version => ([a-z0-9]+),s', get_php_info(), $match)) { + $version = $match[1]; + } - return $version; + return $version; } function get_libpng_version() { - $version = 0; + $version = 0; - if (preg_match(',libPNG Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) { - $version = $match[1]; - } + if (preg_match(',libPNG Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) { + $version = $match[1]; + } - return $version; + return $version; } function get_libxpm_version() { - $version = 0; + $version = 0; - if (preg_match(',libXpm Version => (\d+),s', get_php_info(), $match)) { - $version = $match[1]; - } + if (preg_match(',libXpm Version => (\d+),s', get_php_info(), $match)) { + $version = $match[1]; + } - return $version; + return $version; } /** @@ -77,39 +77,39 @@ function get_libxpm_version() */ function test_image_equals_file($filename, $actual) { - if (!file_exists($filename)) { - echo "The expected image does not exist.\n"; - save_actual_image($actual); - return; - } - $actual = test_to_truecolor($actual); - $expected = imagecreatefrompng($filename); - $expected = test_to_truecolor($expected); - $exp_x = imagesx($expected); - $exp_y = imagesy($expected); - $act_x = imagesx($actual); - $act_y = imagesy($actual); - if ($exp_x != $act_x || $exp_y != $act_y) { - echo "The image size differs: expected {$exp_x}x{$exp_y}, got {$act_x}x{$act_y}.\n"; - save_actual_image($actual); - return; - } - $pixels_changed = 0; - for ($y = 0; $y < $exp_y; $y++) { - for ($x = 0; $x < $exp_x; $x ++) { - $exp_c = imagecolorat($expected, $x, $y); - $act_c = imagecolorat($actual, $x, $y); - if ($exp_c != $act_c) { - $pixels_changed++; - } - } - } - if (!$pixels_changed) { - echo "The images are equal.\n"; - } else { - echo "The images differ in {$pixels_changed} pixels.\n"; - save_actual_image($actual); - } + if (!file_exists($filename)) { + echo "The expected image does not exist.\n"; + save_actual_image($actual); + return; + } + $actual = test_to_truecolor($actual); + $expected = imagecreatefrompng($filename); + $expected = test_to_truecolor($expected); + $exp_x = imagesx($expected); + $exp_y = imagesy($expected); + $act_x = imagesx($actual); + $act_y = imagesy($actual); + if ($exp_x != $act_x || $exp_y != $act_y) { + echo "The image size differs: expected {$exp_x}x{$exp_y}, got {$act_x}x{$act_y}.\n"; + save_actual_image($actual); + return; + } + $pixels_changed = 0; + for ($y = 0; $y < $exp_y; $y++) { + for ($x = 0; $x < $exp_x; $x ++) { + $exp_c = imagecolorat($expected, $x, $y); + $act_c = imagecolorat($actual, $x, $y); + if ($exp_c != $act_c) { + $pixels_changed++; + } + } + } + if (!$pixels_changed) { + echo "The images are equal.\n"; + } else { + echo "The images differ in {$pixels_changed} pixels.\n"; + save_actual_image($actual); + } } /** @@ -120,15 +120,15 @@ function test_image_equals_file($filename, $actual) */ function test_to_truecolor($image) { - if (imageistruecolor($image)) { - return $image; - } else { - $width = imagesx($image); - $height = imagesy($image); - $result = imagecreatetruecolor($width, $height); - imagecopy($result, $image, 0,0, 0,0, $width, $height); - return $result; - } + if (imageistruecolor($image)) { + return $image; + } else { + $width = imagesx($image); + $height = imagesy($image); + $result = imagecreatetruecolor($width, $height); + imagecopy($result, $image, 0,0, 0,0, $width, $height); + return $result; + } } /** @@ -142,9 +142,9 @@ function test_to_truecolor($image) */ function save_actual_image($image) { - $pathinfo = pathinfo($_SERVER['SCRIPT_FILENAME']); - $filename = "{$pathinfo['dirname']}/{$pathinfo['filename']}.out.png"; - imagepng($image, $filename); + $pathinfo = pathinfo($_SERVER['SCRIPT_FILENAME']); + $filename = "{$pathinfo['dirname']}/{$pathinfo['filename']}.out.png"; + imagepng($image, $filename); } /** diff --git a/ext/gd/tests/gd_info_basic.phpt b/ext/gd/tests/gd_info_basic.phpt index b027462a41b8..99102168f109 100644 --- a/ext/gd/tests/gd_info_basic.phpt +++ b/ext/gd/tests/gd_info_basic.phpt @@ -14,11 +14,11 @@ gd_info() * Source code: ext/standard/image.c * Alias to functions: */ - echo "basic test of gd_info() function\n"; + echo "basic test of gd_info() function\n"; - var_dump(gd_info()); + var_dump(gd_info()); - echo "\nDone\n"; + echo "\nDone\n"; ?> --EXPECTF-- basic test of gd_info() function diff --git a/ext/gd/tests/gdimage_prevent_serialization.phpt b/ext/gd/tests/gdimage_prevent_serialization.phpt index ef08444d37d7..e1e33127d1d3 100644 --- a/ext/gd/tests/gdimage_prevent_serialization.phpt +++ b/ext/gd/tests/gdimage_prevent_serialization.phpt @@ -11,7 +11,7 @@ if(!extension_loaded('gd')) { $img_src = imagecreatetruecolor(32, 32); var_dump(serialize($img_src)); - + ?> --EXPECTF-- Fatal error: Uncaught Exception: Serialization of 'GdImage' is not allowed in %s:%d diff --git a/ext/gd/tests/gif.phpt b/ext/gd/tests/gif.phpt index 39ade092c20c..8315fb0dbc3b 100644 --- a/ext/gd/tests/gif.phpt +++ b/ext/gd/tests/gif.phpt @@ -13,34 +13,34 @@ gif in/out 0) { - $r_min = $r - $error; $r_max = $r + $error; - $g_min = $g - $error; $g_max = $g + $error; - $b_min = $b - $error; $b_max = $b + $error; - - if ( - ($c['red'] >= $r_min || $c['red'] <= $r_max) - && - ($c['green'] >= $g_min || $c['green'] <= $g_max) - && - ($c['blue'] >= $b_min || $c['blue'] <= $b_max) - ) { - return true; - } else { - return false; - } - } else { - if ($c['red']==$r && $c['green']==$g && $c['blue']==$b) { - return true; - } else { - return false; - } - } + $cwd = __DIR__; + $im2 = imagecreatefromgif($cwd . '/test_gif.gif'); + + $c = imagecolorsforindex($im2, imagecolorat($im2, 8,8)); + + if ($error>0) { + $r_min = $r - $error; $r_max = $r + $error; + $g_min = $g - $error; $g_max = $g + $error; + $b_min = $b - $error; $b_max = $b + $error; + + if ( + ($c['red'] >= $r_min || $c['red'] <= $r_max) + && + ($c['green'] >= $g_min || $c['green'] <= $g_max) + && + ($c['blue'] >= $b_min || $c['blue'] <= $b_max) + ) { + return true; + } else { + return false; + } + } else { + if ($c['red']==$r && $c['green']==$g && $c['blue']==$b) { + return true; + } else { + return false; + } + } } $cwd = __DIR__; @@ -49,76 +49,76 @@ $c = imagecolorallocate($im, 255,255,255); imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); if (check_box(255,255,255)) { - echo "<4 cols: ok\n"; + echo "<4 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<7; $i++) { - $c = imagecolorallocate($im, $i,$i,$i); + $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { - echo "<8 cols: ok\n"; + echo "<8 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<15; $i++) { - $c = imagecolorallocate($im, $i,$i,$i); + $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { - echo "<16 cols: ok\n"; + echo "<16 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<31; $i++) { - $c = imagecolorallocate($im, $i,$i,$i); + $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { - echo "<32 cols: ok\n"; + echo "<32 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<63; $i++) { - $c = imagecolorallocate($im, $i,$i,$i); + $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { - echo "<64 cols: ok\n"; + echo "<64 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<127; $i++) { - $c = imagecolorallocate($im, $i,$i,$i); + $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { - echo "<128 cols: ok\n"; + echo "<128 cols: ok\n"; } $im = imagecreate(10,10); for ($i=0; $i<255; $i++) { - $c = imagecolorallocate($im, $i,$i,$i); + $c = imagecolorallocate($im, $i,$i,$i); } imagefilledrectangle($im, 5,5, 10,10, $c); imagegif($im, $cwd . '/test_gif.gif'); $i--; if (check_box($i,$i,$i)) { - echo "<256 cols: ok\n"; + echo "<256 cols: ok\n"; } @@ -128,7 +128,7 @@ imagegif($im, $cwd . '/test_gif.gif'); imagegif($im, $cwd . '/test_gif_2.gif'); if (check_box(255,255,255, 10)) { - echo ">256 cols: ok\n"; + echo ">256 cols: ok\n"; } @unlink($cwd . "/test_gif.gif"); diff --git a/ext/gd/tests/gif2gd.phpt b/ext/gd/tests/gif2gd.phpt index 3fe9397fb6a1..a741cadb2651 100644 --- a/ext/gd/tests/gif2gd.phpt +++ b/ext/gd/tests/gif2gd.phpt @@ -12,18 +12,18 @@ gif --> gd1/gd2 conversion test ?> --FILE-- --EXPECT-- GIF to GD1 conversion: ok diff --git a/ext/gd/tests/gif2jpg.phpt b/ext/gd/tests/gif2jpg.phpt index 38d8963271fd..b0ce474886ab 100644 --- a/ext/gd/tests/gif2jpg.phpt +++ b/ext/gd/tests/gif2jpg.phpt @@ -15,13 +15,13 @@ gif --> jpeg conversion test ?> --FILE-- --EXPECT-- GIF to JPEG conversion: ok diff --git a/ext/gd/tests/gif2png.phpt b/ext/gd/tests/gif2png.phpt index 27aac9cdd8dc..295a80944c90 100644 --- a/ext/gd/tests/gif2png.phpt +++ b/ext/gd/tests/gif2png.phpt @@ -15,13 +15,13 @@ gif --> png conversion test ?> --FILE-- --EXPECT-- GIF to PNG conversion: ok diff --git a/ext/gd/tests/imagefilter.phpt b/ext/gd/tests/imagefilter.phpt index a46cc1476e31..f040c5cac449 100644 --- a/ext/gd/tests/imagefilter.phpt +++ b/ext/gd/tests/imagefilter.phpt @@ -10,88 +10,88 @@ imagefilter() function test --FILE-- --EXPECT-- IMG_FILTER_NEGATE success diff --git a/ext/gd/tests/imagefttext.phpt b/ext/gd/tests/imagefttext.phpt index 85bca4d545fa..d140af858e97 100644 --- a/ext/gd/tests/imagefttext.phpt +++ b/ext/gd/tests/imagefttext.phpt @@ -11,41 +11,41 @@ imagefttext() function test ?> --FILE-- --EXPECT-- bool(true) diff --git a/ext/gd/tests/imageinterpolation_basic.phpt b/ext/gd/tests/imageinterpolation_basic.phpt index 80e88647d868..4f01f9b0f2ef 100644 --- a/ext/gd/tests/imageinterpolation_basic.phpt +++ b/ext/gd/tests/imageinterpolation_basic.phpt @@ -7,32 +7,32 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); --FILE-- --EXPECT-- diff --git a/ext/gd/tests/imagewbmp-mb.phpt b/ext/gd/tests/imagewbmp-mb.phpt index fefbb066c70a..664f42c4e3b9 100644 --- a/ext/gd/tests/imagewbmp-mb.phpt +++ b/ext/gd/tests/imagewbmp-mb.phpt @@ -18,9 +18,9 @@ echo 'test create wbmp: '; $c = imagecolorsforindex($im2, imagecolorat($im2, 3,3)); $failed = false; foreach ($c as $v) { - if ($v != 0) { - $failed = true; - } + if ($v != 0) { + $failed = true; + } } echo !$failed ? 'ok' : 'failed'; echo "\n"; diff --git a/ext/gd/tests/imagewbmp.phpt b/ext/gd/tests/imagewbmp.phpt index 27491bb42e0f..ee5dd5c6e2a6 100644 --- a/ext/gd/tests/imagewbmp.phpt +++ b/ext/gd/tests/imagewbmp.phpt @@ -18,9 +18,9 @@ echo 'test create wbmp: '; $c = imagecolorsforindex($im2, imagecolorat($im2, 3,3)); $failed = false; foreach ($c as $v) { - if ($v != 0) { - $failed = true; - } + if ($v != 0) { + $failed = true; + } } echo !$failed ? 'ok' : 'failed'; echo "\n"; diff --git a/ext/gd/tests/jpeg2png.phpt b/ext/gd/tests/jpeg2png.phpt index 8d14b33e3adc..dfcd1ef1a264 100644 --- a/ext/gd/tests/jpeg2png.phpt +++ b/ext/gd/tests/jpeg2png.phpt @@ -15,28 +15,28 @@ jpeg <--> png conversion test ?> --FILE-- --EXPECT-- PNG to JPEG conversion: ok diff --git a/ext/gd/tests/jpg2gd-mb.phpt b/ext/gd/tests/jpg2gd-mb.phpt index b7c0b98ab492..8cf4ffd28399 100644 --- a/ext/gd/tests/jpg2gd-mb.phpt +++ b/ext/gd/tests/jpg2gd-mb.phpt @@ -12,28 +12,28 @@ jpeg <--> gd1/gd2 conversion test ?> --FILE-- --EXPECT-- JPEG to GD1 conversion: ok diff --git a/ext/gd/tests/jpg2gd.phpt b/ext/gd/tests/jpg2gd.phpt index 6ec714ef279d..da671e01ac05 100644 --- a/ext/gd/tests/jpg2gd.phpt +++ b/ext/gd/tests/jpg2gd.phpt @@ -12,28 +12,28 @@ jpeg <--> gd1/gd2 conversion test ?> --FILE-- --EXPECT-- JPEG to GD1 conversion: ok diff --git a/ext/gd/tests/libgd00106.phpt b/ext/gd/tests/libgd00106.phpt index 65e4692ea391..d651b0bb1f6f 100644 --- a/ext/gd/tests/libgd00106.phpt +++ b/ext/gd/tests/libgd00106.phpt @@ -13,9 +13,9 @@ $c2 = imagecolorat($im, 1,2); $c3 = imagecolorat($im, 2,1); $c4 = imagecolorat($im, 2,2); if ($c1 == 0xFFFFFF && $c2 == 0 && $c3 == 0 && $c4 == 0) { - echo "Ok"; + echo "Ok"; } else { - echo "failed"; + echo "failed"; } ?> --EXPECT-- diff --git a/ext/gd/tests/libgd00191.phpt b/ext/gd/tests/libgd00191.phpt index 6e3ffd51b177..983b93e180e1 100644 --- a/ext/gd/tests/libgd00191.phpt +++ b/ext/gd/tests/libgd00191.phpt @@ -14,9 +14,9 @@ imagefilledellipse($im, 30, 50, 20, 20, imagecolorallocate($im, 0, 0, 0)); $index = imagecolorat($im, 12, 28); $arr = imagecolorsforindex($im, $index); if ($arr['red'] == 255 && $arr['green'] == 255 && $arr['blue'] == 255) { - echo "Ok"; + echo "Ok"; } else { - echo "failed"; + echo "failed"; } ?> --EXPECT-- diff --git a/ext/gd/tests/lines.phpt b/ext/gd/tests/lines.phpt index 9401b6c82d20..34e8304dcdb4 100644 --- a/ext/gd/tests/lines.phpt +++ b/ext/gd/tests/lines.phpt @@ -16,10 +16,10 @@ $p1 = imagecolorat($im, 0,5)==0x00ff00; $p2 = imagecolorat($im, 5,5)==0x00ff00; $p3 = true; for ($x=1; $x<5; $x++) { - $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00); + $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00); } if ($p1 && $p2 && $p3) { - echo "Horizontal: ok\n"; + echo "Horizontal: ok\n"; } $im = imagecreatetruecolor(6,6); @@ -30,11 +30,11 @@ $p1 = imagecolorat($im, 0,0)==0x00ff00; $p2 = imagecolorat($im, 0,5)==0x00ff00; $p3 = true; for ($y=1; $y<5; $y++) { - $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00); + $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00); } if ($p1 && $p2 && $p3) { - echo "Vertical: ok\n"; + echo "Vertical: ok\n"; } @@ -50,12 +50,12 @@ $x=1; $p3 = true; for ($y=1; $y<5; $y++) { - $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); - $x++; + $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); + $x++; } if ($p1 && $p2 && $p3) { - echo "Diagonal: ok\n"; + echo "Diagonal: ok\n"; } // Outside @@ -64,12 +64,12 @@ imagefill($im, 0,0, 0xffffff); imageline($im, 12, 12, 23,23, 0x00ff00); $p3 = true; for ($x=0; $x<6; $x++) { - for ($y=0; $y<6; $y++) { - $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); - } + for ($y=0; $y<6; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); + } } if ($p3) { - echo "Outside 1: ok\n"; + echo "Outside 1: ok\n"; } $im = imagecreatetruecolor(6,6); @@ -77,12 +77,12 @@ imagefill($im, 0,0, 0xffffff); imageline($im, -12, -12, -23,-23, 0x00ff00); $p3 = true; for ($x=0; $x<6; $x++) { - for ($y=0; $y<6; $y++) { - $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); - } + for ($y=0; $y<6; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); + } } if ($p3) { - echo "Outside 2: ok\n"; + echo "Outside 2: ok\n"; } $im = imagecreatetruecolor(6,6); @@ -90,12 +90,12 @@ imagefill($im, 0,0, 0xffffff); imageline($im, -1, -1, 4,4, 0x00ff00); $p3 = true; for ($x=0; $x<5; $x++) { - for ($y=0; $y<5; $y++) { - $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); - } + for ($y=0; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); + } } if ($p3) { - echo "Outside 2: ok\n"; + echo "Outside 2: ok\n"; } diff --git a/ext/gd/tests/png2gd.phpt b/ext/gd/tests/png2gd.phpt index ea70298292c9..850cdd0be2f7 100644 --- a/ext/gd/tests/png2gd.phpt +++ b/ext/gd/tests/png2gd.phpt @@ -12,28 +12,28 @@ png <--> gd1/gd2 conversion test ?> --FILE-- --EXPECT-- PNG to GD1 conversion: ok diff --git a/ext/gd/tests/pngcomp.phpt b/ext/gd/tests/pngcomp.phpt index aa663a6dd219..f9065ea82add 100644 --- a/ext/gd/tests/pngcomp.phpt +++ b/ext/gd/tests/pngcomp.phpt @@ -12,9 +12,9 @@ png compression test ?> --FILE-- --EXPECT-- PNG compression test: ok diff --git a/ext/gd/tests/types.phpt b/ext/gd/tests/types.phpt index 246e3ba7d21e..7510ba17c612 100644 --- a/ext/gd/tests/types.phpt +++ b/ext/gd/tests/types.phpt @@ -9,23 +9,23 @@ imagetypes $flags = imagetypes(); if ($flags&0x1 && !function_exists("imagegif")) { - echo "gif failed\n"; + echo "gif failed\n"; } if ($flags&0x2 && !function_exists("imagejpeg")) { - echo "jpeg failed\n"; + echo "jpeg failed\n"; } if ($flags&0x4 && !function_exists("imagepng")) { - echo "png failed\n"; + echo "png failed\n"; } if ($flags&0x8 && !function_exists("imagewbmp")) { - echo "wbmp failed\n"; + echo "wbmp failed\n"; } if ($flags&16 && !function_exists("imagecreatefromxpm")) { - echo "xom failed\n"; + echo "xom failed\n"; } echo "ok\n"; ?> diff --git a/ext/gd/tests/xbm2png.phpt b/ext/gd/tests/xbm2png.phpt index 8dcd07bc4ae4..9b1b4013c89e 100644 --- a/ext/gd/tests/xbm2png.phpt +++ b/ext/gd/tests/xbm2png.phpt @@ -14,13 +14,13 @@ xbm --> png conversion test ?> --FILE-- --EXPECT-- XBM to PNG conversion: ok diff --git a/ext/gd/tests/xpm2gd.phpt b/ext/gd/tests/xpm2gd.phpt index f48dcb2b3bba..dba9f03ec8e2 100644 --- a/ext/gd/tests/xpm2gd.phpt +++ b/ext/gd/tests/xpm2gd.phpt @@ -12,18 +12,18 @@ xpm --> gd1/gd2 conversion test ?> --FILE-- --EXPECT-- XPM to GD1 conversion: ok diff --git a/ext/gd/tests/xpm2jpg.phpt b/ext/gd/tests/xpm2jpg.phpt index 92cab3e5fa23..6491b8564655 100644 --- a/ext/gd/tests/xpm2jpg.phpt +++ b/ext/gd/tests/xpm2jpg.phpt @@ -15,13 +15,13 @@ xpm --> jpeg conversion test ?> --FILE-- --EXPECT-- XPM to JPEG conversion: ok diff --git a/ext/gd/tests/xpm2png.phpt b/ext/gd/tests/xpm2png.phpt index e473cfb31c04..602fc72a7cff 100644 --- a/ext/gd/tests/xpm2png.phpt +++ b/ext/gd/tests/xpm2png.phpt @@ -15,13 +15,13 @@ xpm --> png conversion test ?> --FILE-- --EXPECT-- XPM to PNG conversion: ok diff --git a/ext/gettext/tests/bug66267.phpt b/ext/gettext/tests/bug66267.phpt index 30a839390bab..749f4cd1a2fe 100644 --- a/ext/gettext/tests/bug66267.phpt +++ b/ext/gettext/tests/bug66267.phpt @@ -27,17 +27,17 @@ $domain = 'domain'; $loc = ["de_DE", "fr_FR", "en_US"]; foreach ($loc as $l) { - putenv("LC_ALL=$l"); - setlocale(LC_ALL, $l); + putenv("LC_ALL=$l"); + setlocale(LC_ALL, $l); - $path = realpath(__DIR__ . DIRECTORY_SEPARATOR . "66265"); - bindtextdomain($domain, $path); - bind_textdomain_codeset($domain, "UTF-8"); - textdomain($domain); + $path = realpath(__DIR__ . DIRECTORY_SEPARATOR . "66265"); + bindtextdomain($domain, $path); + bind_textdomain_codeset($domain, "UTF-8"); + textdomain($domain); - echo 'LC_ALL=', getenv('LC_ALL'), "\n"; - echo 'hello=', _('hello'), "\n"; - echo "\n"; + echo 'LC_ALL=', getenv('LC_ALL'), "\n"; + echo 'hello=', _('hello'), "\n"; + echo "\n"; } ?> diff --git a/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt index 822e412d83ce..498568294ad9 100644 --- a/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt +++ b/ext/gettext/tests/gettext_bind_textdomain_codeset-retval.phpt @@ -8,10 +8,10 @@ test if bind_textdomain_codeset() returns correct value ?> --FILE-- --EXPECT-- bool(false) diff --git a/ext/gmp/tests/bug52906.phpt b/ext/gmp/tests/bug52906.phpt index e00080d7ab26..7172ec3b4ec5 100644 --- a/ext/gmp/tests/bug52906.phpt +++ b/ext/gmp/tests/bug52906.phpt @@ -6,21 +6,21 @@ Bug #52906 gmp_mod returns negative result when non-negative is expected diff --git a/ext/gmp/tests/bug70284.phpt b/ext/gmp/tests/bug70284.phpt index 49df5d035981..7dd2e37512ee 100644 --- a/ext/gmp/tests/bug70284.phpt +++ b/ext/gmp/tests/bug70284.phpt @@ -18,7 +18,7 @@ $fakezval .= "\x00"; $fakezval .= "\x00\x00"; for ($i = 0; $i < 5; $i++) { - $v[$i] = $fakezval.$i; + $v[$i] = $fakezval.$i; } var_dump($data); @@ -26,11 +26,11 @@ var_dump($data); function ptr2str($ptr) { $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/gmp/tests/gmp_gcdext.phpt b/ext/gmp/tests/gmp_gcdext.phpt index d02f341129c3..9a923fcd4eb1 100644 --- a/ext/gmp/tests/gmp_gcdext.phpt +++ b/ext/gmp/tests/gmp_gcdext.phpt @@ -10,23 +10,23 @@ $n = gmp_init("34293864345"); $n1 = gmp_init("23434293864345"); $a = array( - array(123,45), - array(4341,9734), - array(23487,333), - array(-234234,-123123), - array(-100,-2234), - array(345,"34587345"), - array(345,"0"), - array("345556456",345873), - array("34545345556456","323432445873"), - array($n, $n1), - ); + array(123,45), + array(4341,9734), + array(23487,333), + array(-234234,-123123), + array(-100,-2234), + array(345,"34587345"), + array(345,"0"), + array("345556456",345873), + array("34545345556456","323432445873"), + array($n, $n1), + ); foreach ($a as $val) { - $r = gmp_gcdext($val[0],$val[1]); - $check = gmp_add(gmp_mul($val[0],$r['s']), gmp_mul($val[1],$r['t'])); - var_dump(gmp_strval($r['g'])); - var_dump(gmp_strval($check)); + $r = gmp_gcdext($val[0],$val[1]); + $check = gmp_add(gmp_mul($val[0],$r['s']), gmp_mul($val[1],$r['t'])); + var_dump(gmp_strval($r['g'])); + var_dump(gmp_strval($check)); } var_dump(gmp_gcdext($val[0],array())); diff --git a/ext/gmp/tests/gmp_jacobi.phpt b/ext/gmp/tests/gmp_jacobi.phpt index 2040b666f6a3..adf3f6a0b235 100644 --- a/ext/gmp/tests/gmp_jacobi.phpt +++ b/ext/gmp/tests/gmp_jacobi.phpt @@ -6,7 +6,7 @@ gmp_jacobi() basic tests $limit) { - print "RANGE VIOLATION\n"; - var_dump($result); - break 2; - } - } + for ($i = 0; $i < 5000; $i++) { + $result = gmp_random_bits(30); + if ($result < 0 || $result > $limit) { + print "RANGE VIOLATION\n"; + var_dump($result); + break 2; + } + } - if (microtime(true) - $start > 0.5) { - break; - } + if (microtime(true) - $start > 0.5) { + break; + } } echo "Done\n"; diff --git a/ext/gmp/tests/gmp_random_range.phpt b/ext/gmp/tests/gmp_random_range.phpt index fec82741674f..7ff6c546b40e 100644 --- a/ext/gmp/tests/gmp_random_range.phpt +++ b/ext/gmp/tests/gmp_random_range.phpt @@ -31,32 +31,32 @@ gmp_random_range($minusTen, $plusTen); // 0.5 seconds to make sure the numbers stay in range $start = microtime(true); while (1) { - for ($i = 0; $i < 5000; $i++) { - $result = gmp_random_range(0, 1000); - if ($result < 0 || $result > 1000) { - print "RANGE VIOLATION 1\n"; - var_dump($result); - break 2; - } + for ($i = 0; $i < 5000; $i++) { + $result = gmp_random_range(0, 1000); + if ($result < 0 || $result > 1000) { + print "RANGE VIOLATION 1\n"; + var_dump($result); + break 2; + } - $result = gmp_random_range(-1000, 0); - if ($result < -1000 || $result > 0) { - print "RANGE VIOLATION 2\n"; - var_dump($result); - break 2; - } + $result = gmp_random_range(-1000, 0); + if ($result < -1000 || $result > 0) { + print "RANGE VIOLATION 2\n"; + var_dump($result); + break 2; + } - $result = gmp_random_range(-500, 500); - if ($result < -500 || $result > 500) { - print "RANGE VIOLATION 3\n"; - var_dump($result); - break 2; - } - } + $result = gmp_random_range(-500, 500); + if ($result < -500 || $result > 500) { + print "RANGE VIOLATION 3\n"; + var_dump($result); + break 2; + } + } - if (microtime(true) - $start > 0.5) { - break; - } + if (microtime(true) - $start > 0.5) { + break; + } } echo "Done\n"; diff --git a/ext/gmp/tests/gmp_setbit_long.phpt b/ext/gmp/tests/gmp_setbit_long.phpt index ce4e42713220..d7f56767d8a4 100644 --- a/ext/gmp/tests/gmp_setbit_long.phpt +++ b/ext/gmp/tests/gmp_setbit_long.phpt @@ -25,7 +25,7 @@ gmp_setbit() with large index $n = gmp_init("227200"); for($a = 1<<30; $a > 0 && $a < 0x8000000000; $a <<= 2) { - $i = $a - 1; + $i = $a - 1; printf("%X\n", $i); gmp_setbit($n, $i, 1); } diff --git a/ext/hash/tests/fnv132.phpt b/ext/hash/tests/fnv132.phpt index 914ce46f354c..37618819bd6f 100644 --- a/ext/hash/tests/fnv132.phpt +++ b/ext/hash/tests/fnv132.phpt @@ -4,192 +4,192 @@ Hash: FNV132 algorithm /\\../\\", "995fa9c4" ), - array( "chongo /\\../\\\0", "35983f8c" ), - array( "chongo (Landon Curt Noll) /\\../\\", "5036a251" ), - array( "chongo (Landon Curt Noll) /\\../\\\0", "97018583" ), - array( "http://antwrp.gsfc.nasa.gov/apod/astropix.html", "b4448d60" ), - array( "http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash", "025dfe59" ), - array( "http://epod.usra.edu/", "c5eab3af" ), - array( "http://exoplanet.eu/", "7d21ba1e" ), - array( "http://hvo.wr.usgs.gov/cam3/", "7704cddb" ), - array( "http://hvo.wr.usgs.gov/cams/HMcam/", "d0071bfe" ), - array( "http://hvo.wr.usgs.gov/kilauea/update/deformation.html", "0ff3774c" ), - array( "http://hvo.wr.usgs.gov/kilauea/update/images.html", "b0fea0ea" ), - array( "http://hvo.wr.usgs.gov/kilauea/update/maps.html", "58177303" ), - array( "http://hvo.wr.usgs.gov/volcanowatch/current_issue.html", "4f599cda" ), - array( "http://neo.jpl.nasa.gov/risk/", "3e590a47" ), - array( "http://norvig.com/21-days.html", "965595f8" ), - array( "http://primes.utm.edu/curios/home.php", "c37f178d" ), - array( "http://slashdot.org/", "9711dd26" ), - array( "http://tux.wr.usgs.gov/Maps/155.25-19.5.html", "23c99b7f" ), - array( "http://volcano.wr.usgs.gov/kilaueastatus.php", "6e568b17" ), - array( "http://www.avo.alaska.edu/activity/Redoubt.php", "43f0245b" ), - array( "http://www.dilbert.com/fast/", "bcb7a001" ), - array( "http://www.fourmilab.ch/gravitation/orbits/", "12e6dffe" ), - array( "http://www.fpoa.net/", "0792f2d6" ), - array( "http://www.ioccc.org/index.html", "b966936b" ), - array( "http://www.isthe.com/cgi-bin/number.cgi", "46439ac5" ), - array( "http://www.isthe.com/chongo/bio.html", "728d49af" ), - array( "http://www.isthe.com/chongo/index.html", "d33745c9" ), - array( "http://www.isthe.com/chongo/src/calc/lucas-calc", "bc382a57" ), - array( "http://www.isthe.com/chongo/tech/astro/venus2004.html", "4bda1d31" ), - array( "http://www.isthe.com/chongo/tech/astro/vita.html", "ce35ccae" ), - array( "http://www.isthe.com/chongo/tech/comp/c/expert.html", "3b6eed94" ), - array( "http://www.isthe.com/chongo/tech/comp/calc/index.html", "445c9c58" ), - array( "http://www.isthe.com/chongo/tech/comp/fnv/index.html", "3db8bf9d" ), - array( "http://www.isthe.com/chongo/tech/math/number/howhigh.html", "2dee116d" ), - array( "http://www.isthe.com/chongo/tech/math/number/number.html", "c18738da" ), - array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html", "5b156176" ), - array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest", "2aa7d593" ), - array( "http://www.lavarnd.org/cgi-bin/corpspeak.cgi", "b2409658" ), - array( "http://www.lavarnd.org/cgi-bin/haiku.cgi", "e1489528" ), - array( "http://www.lavarnd.org/cgi-bin/rand-none.cgi", "fe1ee07e" ), - array( "http://www.lavarnd.org/cgi-bin/randdist.cgi", "e8842315" ), - array( "http://www.lavarnd.org/index.html", "3a6a63a2" ), - array( "http://www.lavarnd.org/what/nist-test.html", "06d2c18c" ), - array( "http://www.macosxhints.com/", "f8ef7225" ), - array( "http://www.mellis.com/", "843d3300" ), - array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm", "bb24f7ae" ), - array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm", "878c0ec9" ), - array( "http://www.paulnoll.com/", "b557810f" ), - array( "http://www.pepysdiary.com/", "57423246" ), - array( "http://www.sciencenews.org/index/home/activity/view", "87f7505e" ), - array( "http://www.skyandtelescope.com/", "bb809f20" ), - array( "http://www.sput.nl/~rob/sirius.html", "8932abb5" ), - array( "http://www.systemexperts.com/", "0a9b3aa0" ), - array( "http://www.tq-international.com/phpBB3/index.php", "b8682a24" ), - array( "http://www.travelquesttours.com/index.htm", "a7ac1c56" ), - array( "http://www.wunderground.com/global/stations/89606.html", "11409252" ), - array( R10("21701"), "a987f517" ), - array( R10("M21701"), "f309e7ed" ), - array( R10("2^21701-1"), "c9e8f417" ), - array( R10("\x54\xc5"), "7f447bdd" ), - array( R10("\xc5\x54"), "b929adc5" ), - array( R10("23209"), "57022879" ), - array( R10("M23209"), "dcfd2c49" ), - array( R10("2^23209-1"), "6edafff5" ), - array( R10("\x5a\xa9"), "f04fb1f1" ), - array( R10("\xa9\x5a"), "fb7de8b9" ), - array( R10("391581216093"), "c5f1d7e9" ), - array( R10("391581*2^216093-1"), "32c1f439" ), - array( R10("\x05\xf9\x9d\x03\x4c\x81"), "7fd3eb7d" ), - array( R10("FEDCBA9876543210"), "81597da5" ), - array( R10("\xfe\xdc\xba\x98\x76\x54\x32\x10"), "05eb7a25" ), - array( R10("EFCDAB8967452301"), "9c0fa1b5" ), - array( R10("\xef\xcd\xab\x89\x67\x45\x23\x01"), "53ccb1c5" ), - array( R10("0123456789ABCDEF"), "fabece15" ), - array( R10("\x01\x23\x45\x67\x89\xab\xcd\xef"), "4ad745a5" ), - array( R10("1032547698BADCFE"), "e5bdc495" ), - array( R10("\x10\x32\x54\x76\x98\xba\xdc\xfe"), "23b3c0a5" ), - array( R500("\x00"), "fa823dd5" ), - array( R500("\x07"), "0c6c58b9" ), - array( R500("~"), "e2dbccd5" ), - array( R500("\x7f"), "db7f50f9" ), + array( "", "811c9dc5" ), + array( "a", "050c5d7e" ), + array( "b", "050c5d7d" ), + array( "c", "050c5d7c" ), + array( "d", "050c5d7b" ), + array( "e", "050c5d7a" ), + array( "f", "050c5d79" ), + array( "fo", "6b772514" ), + array( "foo", "408f5e13" ), + array( "foob", "b4b1178b" ), + array( "fooba", "fdc80fb0" ), + array( "foobar", "31f0b262" ), + array( "\0", "050c5d1f" ), + array( "a\0", "70772d5a" ), + array( "b\0", "6f772bc7" ), + array( "c\0", "6e772a34" ), + array( "d\0", "6d7728a1" ), + array( "e\0", "6c77270e" ), + array( "f\0", "6b77257b" ), + array( "fo\0", "408f5e7c" ), + array( "foo\0", "b4b117e9" ), + array( "foob\0", "fdc80fd1" ), + array( "fooba\0", "31f0b210" ), + array( "foobar\0", "ffe8d046" ), + array( "ch", "6e772a5c" ), + array( "cho", "4197aebb" ), + array( "chon", "fcc8100f" ), + array( "chong", "fdf147fa" ), + array( "chongo", "bcd44ee1" ), + array( "chongo ", "23382c13" ), + array( "chongo w", "846d619e" ), + array( "chongo wa", "1630abdb" ), + array( "chongo was", "c99e89b2" ), + array( "chongo was ", "1692c316" ), + array( "chongo was h", "9f091bca" ), + array( "chongo was he", "2556be9b" ), + array( "chongo was her", "628e0e73" ), + array( "chongo was here", "98a0bf6c" ), + array( "chongo was here!", "b10d5725" ), + array( "chongo was here!\n", "dd002f35" ), + array( "ch\0", "4197aed4" ), + array( "cho\0", "fcc81061" ), + array( "chon\0", "fdf1479d" ), + array( "chong\0", "bcd44e8e" ), + array( "chongo\0", "23382c33" ), + array( "chongo \0", "846d61e9" ), + array( "chongo w\0", "1630abba" ), + array( "chongo wa\0", "c99e89c1" ), + array( "chongo was\0", "1692c336" ), + array( "chongo was \0", "9f091ba2" ), + array( "chongo was h\0", "2556befe" ), + array( "chongo was he\0", "628e0e01" ), + array( "chongo was her\0", "98a0bf09" ), + array( "chongo was here\0", "b10d5704" ), + array( "chongo was here!\0", "dd002f3f" ), + array( "chongo was here!\n\0", "1c4a506f" ), + array( "cu", "6e772a41" ), + array( "cur", "26978421" ), + array( "curd", "e184ff97" ), + array( "curds", "9b5e5ac6" ), + array( "curds ", "5b88e592" ), + array( "curds a", "aa8164b7" ), + array( "curds an", "20b18c7b" ), + array( "curds and", "f28025c5" ), + array( "curds and ", "84bb753f" ), + array( "curds and w", "3219925a" ), + array( "curds and wh", "384163c6" ), + array( "curds and whe", "54f010d7" ), + array( "curds and whey", "8cea820c" ), + array( "curds and whey\n", "e12ab8ee" ), + array( "cu\0", "26978453" ), + array( "cur\0", "e184fff3" ), + array( "curd\0", "9b5e5ab5" ), + array( "curds\0", "5b88e5b2" ), + array( "curds \0", "aa8164d6" ), + array( "curds a\0", "20b18c15" ), + array( "curds an\0", "f28025a1" ), + array( "curds and\0", "84bb751f" ), + array( "curds and \0", "3219922d" ), + array( "curds and w\0", "384163ae" ), + array( "curds and wh\0", "54f010b2" ), + array( "curds and whe\0", "8cea8275" ), + array( "curds and whey\0", "e12ab8e4" ), + array( "curds and whey\n\0", "64411eaa" ), + array( "line 1\nline 2\nline 3", "31ae8f83" ), + array( "chongo /\\../\\", "995fa9c4" ), + array( "chongo /\\../\\\0", "35983f8c" ), + array( "chongo (Landon Curt Noll) /\\../\\", "5036a251" ), + array( "chongo (Landon Curt Noll) /\\../\\\0", "97018583" ), + array( "http://antwrp.gsfc.nasa.gov/apod/astropix.html", "b4448d60" ), + array( "http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash", "025dfe59" ), + array( "http://epod.usra.edu/", "c5eab3af" ), + array( "http://exoplanet.eu/", "7d21ba1e" ), + array( "http://hvo.wr.usgs.gov/cam3/", "7704cddb" ), + array( "http://hvo.wr.usgs.gov/cams/HMcam/", "d0071bfe" ), + array( "http://hvo.wr.usgs.gov/kilauea/update/deformation.html", "0ff3774c" ), + array( "http://hvo.wr.usgs.gov/kilauea/update/images.html", "b0fea0ea" ), + array( "http://hvo.wr.usgs.gov/kilauea/update/maps.html", "58177303" ), + array( "http://hvo.wr.usgs.gov/volcanowatch/current_issue.html", "4f599cda" ), + array( "http://neo.jpl.nasa.gov/risk/", "3e590a47" ), + array( "http://norvig.com/21-days.html", "965595f8" ), + array( "http://primes.utm.edu/curios/home.php", "c37f178d" ), + array( "http://slashdot.org/", "9711dd26" ), + array( "http://tux.wr.usgs.gov/Maps/155.25-19.5.html", "23c99b7f" ), + array( "http://volcano.wr.usgs.gov/kilaueastatus.php", "6e568b17" ), + array( "http://www.avo.alaska.edu/activity/Redoubt.php", "43f0245b" ), + array( "http://www.dilbert.com/fast/", "bcb7a001" ), + array( "http://www.fourmilab.ch/gravitation/orbits/", "12e6dffe" ), + array( "http://www.fpoa.net/", "0792f2d6" ), + array( "http://www.ioccc.org/index.html", "b966936b" ), + array( "http://www.isthe.com/cgi-bin/number.cgi", "46439ac5" ), + array( "http://www.isthe.com/chongo/bio.html", "728d49af" ), + array( "http://www.isthe.com/chongo/index.html", "d33745c9" ), + array( "http://www.isthe.com/chongo/src/calc/lucas-calc", "bc382a57" ), + array( "http://www.isthe.com/chongo/tech/astro/venus2004.html", "4bda1d31" ), + array( "http://www.isthe.com/chongo/tech/astro/vita.html", "ce35ccae" ), + array( "http://www.isthe.com/chongo/tech/comp/c/expert.html", "3b6eed94" ), + array( "http://www.isthe.com/chongo/tech/comp/calc/index.html", "445c9c58" ), + array( "http://www.isthe.com/chongo/tech/comp/fnv/index.html", "3db8bf9d" ), + array( "http://www.isthe.com/chongo/tech/math/number/howhigh.html", "2dee116d" ), + array( "http://www.isthe.com/chongo/tech/math/number/number.html", "c18738da" ), + array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html", "5b156176" ), + array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest", "2aa7d593" ), + array( "http://www.lavarnd.org/cgi-bin/corpspeak.cgi", "b2409658" ), + array( "http://www.lavarnd.org/cgi-bin/haiku.cgi", "e1489528" ), + array( "http://www.lavarnd.org/cgi-bin/rand-none.cgi", "fe1ee07e" ), + array( "http://www.lavarnd.org/cgi-bin/randdist.cgi", "e8842315" ), + array( "http://www.lavarnd.org/index.html", "3a6a63a2" ), + array( "http://www.lavarnd.org/what/nist-test.html", "06d2c18c" ), + array( "http://www.macosxhints.com/", "f8ef7225" ), + array( "http://www.mellis.com/", "843d3300" ), + array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm", "bb24f7ae" ), + array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm", "878c0ec9" ), + array( "http://www.paulnoll.com/", "b557810f" ), + array( "http://www.pepysdiary.com/", "57423246" ), + array( "http://www.sciencenews.org/index/home/activity/view", "87f7505e" ), + array( "http://www.skyandtelescope.com/", "bb809f20" ), + array( "http://www.sput.nl/~rob/sirius.html", "8932abb5" ), + array( "http://www.systemexperts.com/", "0a9b3aa0" ), + array( "http://www.tq-international.com/phpBB3/index.php", "b8682a24" ), + array( "http://www.travelquesttours.com/index.htm", "a7ac1c56" ), + array( "http://www.wunderground.com/global/stations/89606.html", "11409252" ), + array( R10("21701"), "a987f517" ), + array( R10("M21701"), "f309e7ed" ), + array( R10("2^21701-1"), "c9e8f417" ), + array( R10("\x54\xc5"), "7f447bdd" ), + array( R10("\xc5\x54"), "b929adc5" ), + array( R10("23209"), "57022879" ), + array( R10("M23209"), "dcfd2c49" ), + array( R10("2^23209-1"), "6edafff5" ), + array( R10("\x5a\xa9"), "f04fb1f1" ), + array( R10("\xa9\x5a"), "fb7de8b9" ), + array( R10("391581216093"), "c5f1d7e9" ), + array( R10("391581*2^216093-1"), "32c1f439" ), + array( R10("\x05\xf9\x9d\x03\x4c\x81"), "7fd3eb7d" ), + array( R10("FEDCBA9876543210"), "81597da5" ), + array( R10("\xfe\xdc\xba\x98\x76\x54\x32\x10"), "05eb7a25" ), + array( R10("EFCDAB8967452301"), "9c0fa1b5" ), + array( R10("\xef\xcd\xab\x89\x67\x45\x23\x01"), "53ccb1c5" ), + array( R10("0123456789ABCDEF"), "fabece15" ), + array( R10("\x01\x23\x45\x67\x89\xab\xcd\xef"), "4ad745a5" ), + array( R10("1032547698BADCFE"), "e5bdc495" ), + array( R10("\x10\x32\x54\x76\x98\xba\xdc\xfe"), "23b3c0a5" ), + array( R500("\x00"), "fa823dd5" ), + array( R500("\x07"), "0c6c58b9" ), + array( R500("~"), "e2dbccd5" ), + array( R500("\x7f"), "db7f50f9" ), ); $i = 0; $pass = true; foreach($tests as $test) { - $result = hash('fnv132', $test[0]); - if ($result != $test[1]) { - echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n"; + $result = hash('fnv132', $test[0]); + if ($result != $test[1]) { + echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n"; $pass = false; - } - $i++; + } + $i++; } if($pass) { diff --git a/ext/hash/tests/fnv164.phpt b/ext/hash/tests/fnv164.phpt index 8ff7304a7bfc..9795524a69e1 100644 --- a/ext/hash/tests/fnv164.phpt +++ b/ext/hash/tests/fnv164.phpt @@ -4,192 +4,192 @@ Hash: FNV164 algorithm /\\../\\", "8fd0680da3088a04" ), - array( "chongo /\\../\\\0", "67aad32c078284cc" ), - array( "chongo (Landon Curt Noll) /\\../\\", "b37d55d81c57b331" ), - array( "chongo (Landon Curt Noll) /\\../\\\0", "55ac0f3829057c43" ), - array( "http://antwrp.gsfc.nasa.gov/apod/astropix.html", "cb27f4b8e1b6cc20" ), - array( "http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash", "26caf88bcbef2d19" ), - array( "http://epod.usra.edu/", "8e6e063b97e61b8f" ), - array( "http://exoplanet.eu/", "b42750f7f3b7c37e" ), - array( "http://hvo.wr.usgs.gov/cam3/", "f3c6ba64cf7ca99b" ), - array( "http://hvo.wr.usgs.gov/cams/HMcam/", "ebfb69b427ea80fe" ), - array( "http://hvo.wr.usgs.gov/kilauea/update/deformation.html", "39b50c3ed970f46c" ), - array( "http://hvo.wr.usgs.gov/kilauea/update/images.html", "5b9b177aa3eb3e8a" ), - array( "http://hvo.wr.usgs.gov/kilauea/update/maps.html", "6510063ecf4ec903" ), - array( "http://hvo.wr.usgs.gov/volcanowatch/current_issue.html", "2b3bbd2c00797c7a" ), - array( "http://neo.jpl.nasa.gov/risk/", "f1d6204ff5cb4aa7" ), - array( "http://norvig.com/21-days.html", "4836e27ccf099f38" ), - array( "http://primes.utm.edu/curios/home.php", "82efbb0dd073b44d" ), - array( "http://slashdot.org/", "4a80c282ffd7d4c6" ), - array( "http://tux.wr.usgs.gov/Maps/155.25-19.5.html", "305d1a9c9ee43bdf" ), - array( "http://volcano.wr.usgs.gov/kilaueastatus.php", "15c366948ffc6997" ), - array( "http://www.avo.alaska.edu/activity/Redoubt.php", "80153ae218916e7b" ), - array( "http://www.dilbert.com/fast/", "fa23e2bdf9e2a9e1" ), - array( "http://www.fourmilab.ch/gravitation/orbits/", "d47e8d8a2333c6de" ), - array( "http://www.fpoa.net/", "7e128095f688b056" ), - array( "http://www.ioccc.org/index.html", "2f5356890efcedab" ), - array( "http://www.isthe.com/cgi-bin/number.cgi", "95c2b383014f55c5" ), - array( "http://www.isthe.com/chongo/bio.html", "4727a5339ce6070f" ), - array( "http://www.isthe.com/chongo/index.html", "b0555ecd575108e9" ), - array( "http://www.isthe.com/chongo/src/calc/lucas-calc", "48d785770bb4af37" ), - array( "http://www.isthe.com/chongo/tech/astro/venus2004.html", "09d4701c12af02b1" ), - array( "http://www.isthe.com/chongo/tech/astro/vita.html", "79f031e78f3cf62e" ), - array( "http://www.isthe.com/chongo/tech/comp/c/expert.html", "52a1ee85db1b5a94" ), - array( "http://www.isthe.com/chongo/tech/comp/calc/index.html", "6bd95b2eb37fa6b8" ), - array( "http://www.isthe.com/chongo/tech/comp/fnv/index.html", "74971b7077aef85d" ), - array( "http://www.isthe.com/chongo/tech/math/number/howhigh.html", "b4e4fae2ffcc1aad" ), - array( "http://www.isthe.com/chongo/tech/math/number/number.html", "2bd48bd898b8f63a" ), - array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html", "e9966ac1556257f6" ), - array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest", "92a3d1cd078ba293" ), - array( "http://www.lavarnd.org/cgi-bin/corpspeak.cgi", "f81175a482e20ab8" ), - array( "http://www.lavarnd.org/cgi-bin/haiku.cgi", "5bbb3de722e73048" ), - array( "http://www.lavarnd.org/cgi-bin/rand-none.cgi", "6b4f363492b9f2be" ), - array( "http://www.lavarnd.org/cgi-bin/randdist.cgi", "c2d559df73d59875" ), - array( "http://www.lavarnd.org/index.html", "f75f62284bc7a8c2" ), - array( "http://www.lavarnd.org/what/nist-test.html", "da8dd8e116a9f1cc" ), - array( "http://www.macosxhints.com/", "bdc1e6ab76057885" ), - array( "http://www.mellis.com/", "fec6a4238a1224a0" ), - array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm", "c03f40f3223e290e" ), - array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm", "1ed21673466ffda9" ), - array( "http://www.paulnoll.com/", "df70f906bb0dd2af" ), - array( "http://www.pepysdiary.com/", "f3dcda369f2af666" ), - array( "http://www.sciencenews.org/index/home/activity/view", "9ebb11573cdcebde" ), - array( "http://www.skyandtelescope.com/", "81c72d9077fedca0" ), - array( "http://www.sput.nl/~rob/sirius.html", "0ec074a31be5fb15" ), - array( "http://www.systemexperts.com/", "2a8b3280b6c48f20" ), - array( "http://www.tq-international.com/phpBB3/index.php", "fd31777513309344" ), - array( "http://www.travelquesttours.com/index.htm", "194534a86ad006b6" ), - array( "http://www.wunderground.com/global/stations/89606.html", "3be6fdf46e0cfe12" ), - array( R10("21701"), "017cc137a07eb057" ), - array( R10("M21701"), "9428fc6e7d26b54d" ), - array( R10("2^21701-1"), "9aaa2e3603ef8ad7" ), - array( R10("\x54\xc5"), "82c6d3f3a0ccdf7d" ), - array( R10("\xc5\x54"), "c86eeea00cf09b65" ), - array( R10("23209"), "705f8189dbb58299" ), - array( R10("M23209"), "415a7f554391ca69" ), - array( R10("2^23209-1"), "cfe3d49fa2bdc555" ), - array( R10("\x5a\xa9"), "f0f9c56039b25191" ), - array( R10("\xa9\x5a"), "7075cb6abd1d32d9" ), - array( R10("391581216093"), "43c94e2c8b277509" ), - array( R10("391581*2^216093-1"), "3cbfd4e4ea670359" ), - array( R10("\x05\xf9\x9d\x03\x4c\x81"), "c05887810f4d019d" ), - array( R10("FEDCBA9876543210"), "14468ff93ac22dc5" ), - array( R10("\xfe\xdc\xba\x98\x76\x54\x32\x10"), "ebed699589d99c05" ), - array( R10("EFCDAB8967452301"), "6d99f6df321ca5d5" ), - array( R10("\xef\xcd\xab\x89\x67\x45\x23\x01"), "0cd410d08c36d625" ), - array( R10("0123456789ABCDEF"), "ef1b2a2c86831d35" ), - array( R10("\x01\x23\x45\x67\x89\xab\xcd\xef"), "3b349c4d69ee5f05" ), - array( R10("1032547698BADCFE"), "55248ce88f45f035" ), - array( R10("\x10\x32\x54\x76\x98\xba\xdc\xfe"), "aa69ca6a18a4c885" ), - array( R500("\x00"), "1fe3fce62bd816b5" ), - array( R500("\x07"), "0289a488a8df69d9" ), - array( R500("~"), "15e96e1613df98b5" ), - array( R500("\x7f"), "e6be57375ad89b99" ), + array( "", "cbf29ce484222325" ), + array( "a", "af63bd4c8601b7be" ), + array( "b", "af63bd4c8601b7bd" ), + array( "c", "af63bd4c8601b7bc" ), + array( "d", "af63bd4c8601b7bb" ), + array( "e", "af63bd4c8601b7ba" ), + array( "f", "af63bd4c8601b7b9" ), + array( "fo", "08326207b4eb2f34" ), + array( "foo", "d8cbc7186ba13533" ), + array( "foob", "0378817ee2ed65cb" ), + array( "fooba", "d329d59b9963f790" ), + array( "foobar", "340d8765a4dda9c2" ), + array( "\0", "af63bd4c8601b7df" ), + array( "a\0", "08326707b4eb37da" ), + array( "b\0", "08326607b4eb3627" ), + array( "c\0", "08326507b4eb3474" ), + array( "d\0", "08326407b4eb32c1" ), + array( "e\0", "08326307b4eb310e" ), + array( "f\0", "08326207b4eb2f5b" ), + array( "fo\0", "d8cbc7186ba1355c" ), + array( "foo\0", "0378817ee2ed65a9" ), + array( "foob\0", "d329d59b9963f7f1" ), + array( "fooba\0", "340d8765a4dda9b0" ), + array( "foobar\0", "50a6d3b724a774a6" ), + array( "ch", "08326507b4eb341c" ), + array( "cho", "d8d5c8186ba98bfb" ), + array( "chon", "1ccefc7ef118dbef" ), + array( "chong", "0c92fab3ad3db77a" ), + array( "chongo", "9b77794f5fdec421" ), + array( "chongo ", "0ac742dfe7874433" ), + array( "chongo w", "d7dad5766ad8e2de" ), + array( "chongo wa", "a1bb96378e897f5b" ), + array( "chongo was", "5b3f9b6733a367d2" ), + array( "chongo was ", "b07ce25cbea969f6" ), + array( "chongo was h", "8d9e9997f9df0d6a" ), + array( "chongo was he", "838c673d9603cb7b" ), + array( "chongo was her", "8b5ee8a5e872c273" ), + array( "chongo was here", "4507c4e9fb00690c" ), + array( "chongo was here!", "4c9ca59581b27f45" ), + array( "chongo was here!\n", "e0aca20b624e4235" ), + array( "ch\0", "d8d5c8186ba98b94" ), + array( "cho\0", "1ccefc7ef118db81" ), + array( "chon\0", "0c92fab3ad3db71d" ), + array( "chong\0", "9b77794f5fdec44e" ), + array( "chongo\0", "0ac742dfe7874413" ), + array( "chongo \0", "d7dad5766ad8e2a9" ), + array( "chongo w\0", "a1bb96378e897f3a" ), + array( "chongo wa\0", "5b3f9b6733a367a1" ), + array( "chongo was\0", "b07ce25cbea969d6" ), + array( "chongo was \0", "8d9e9997f9df0d02" ), + array( "chongo was h\0", "838c673d9603cb1e" ), + array( "chongo was he\0", "8b5ee8a5e872c201" ), + array( "chongo was her\0", "4507c4e9fb006969" ), + array( "chongo was here\0", "4c9ca59581b27f64" ), + array( "chongo was here!\0", "e0aca20b624e423f" ), + array( "chongo was here!\n\0", "13998e580afa800f" ), + array( "cu", "08326507b4eb3401" ), + array( "cur", "d8d5ad186ba95dc1" ), + array( "curd", "1c72e17ef0ca4e97" ), + array( "curds", "2183c1b327c38ae6" ), + array( "curds ", "b66d096c914504f2" ), + array( "curds a", "404bf57ad8476757" ), + array( "curds an", "887976bd815498bb" ), + array( "curds and", "3afd7f02c2bf85a5" ), + array( "curds and ", "fc4476b0eb70177f" ), + array( "curds and w", "186d2da00f77ecba" ), + array( "curds and wh", "f97140fa48c74066" ), + array( "curds and whe", "a2b1cf49aa926d37" ), + array( "curds and whey", "0690712cd6cf940c" ), + array( "curds and whey\n", "f7045b3102b8906e" ), + array( "cu\0", "d8d5ad186ba95db3" ), + array( "cur\0", "1c72e17ef0ca4ef3" ), + array( "curd\0", "2183c1b327c38a95" ), + array( "curds\0", "b66d096c914504d2" ), + array( "curds \0", "404bf57ad8476736" ), + array( "curds a\0", "887976bd815498d5" ), + array( "curds an\0", "3afd7f02c2bf85c1" ), + array( "curds and\0", "fc4476b0eb70175f" ), + array( "curds and \0", "186d2da00f77eccd" ), + array( "curds and w\0", "f97140fa48c7400e" ), + array( "curds and wh\0", "a2b1cf49aa926d52" ), + array( "curds and whe\0", "0690712cd6cf9475" ), + array( "curds and whey\0", "f7045b3102b89064" ), + array( "curds and whey\n\0", "74f762479f9d6aea" ), + array( "line 1\nline 2\nline 3", "a64e5f36c9e2b0e3" ), + array( "chongo /\\../\\", "8fd0680da3088a04" ), + array( "chongo /\\../\\\0", "67aad32c078284cc" ), + array( "chongo (Landon Curt Noll) /\\../\\", "b37d55d81c57b331" ), + array( "chongo (Landon Curt Noll) /\\../\\\0", "55ac0f3829057c43" ), + array( "http://antwrp.gsfc.nasa.gov/apod/astropix.html", "cb27f4b8e1b6cc20" ), + array( "http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash", "26caf88bcbef2d19" ), + array( "http://epod.usra.edu/", "8e6e063b97e61b8f" ), + array( "http://exoplanet.eu/", "b42750f7f3b7c37e" ), + array( "http://hvo.wr.usgs.gov/cam3/", "f3c6ba64cf7ca99b" ), + array( "http://hvo.wr.usgs.gov/cams/HMcam/", "ebfb69b427ea80fe" ), + array( "http://hvo.wr.usgs.gov/kilauea/update/deformation.html", "39b50c3ed970f46c" ), + array( "http://hvo.wr.usgs.gov/kilauea/update/images.html", "5b9b177aa3eb3e8a" ), + array( "http://hvo.wr.usgs.gov/kilauea/update/maps.html", "6510063ecf4ec903" ), + array( "http://hvo.wr.usgs.gov/volcanowatch/current_issue.html", "2b3bbd2c00797c7a" ), + array( "http://neo.jpl.nasa.gov/risk/", "f1d6204ff5cb4aa7" ), + array( "http://norvig.com/21-days.html", "4836e27ccf099f38" ), + array( "http://primes.utm.edu/curios/home.php", "82efbb0dd073b44d" ), + array( "http://slashdot.org/", "4a80c282ffd7d4c6" ), + array( "http://tux.wr.usgs.gov/Maps/155.25-19.5.html", "305d1a9c9ee43bdf" ), + array( "http://volcano.wr.usgs.gov/kilaueastatus.php", "15c366948ffc6997" ), + array( "http://www.avo.alaska.edu/activity/Redoubt.php", "80153ae218916e7b" ), + array( "http://www.dilbert.com/fast/", "fa23e2bdf9e2a9e1" ), + array( "http://www.fourmilab.ch/gravitation/orbits/", "d47e8d8a2333c6de" ), + array( "http://www.fpoa.net/", "7e128095f688b056" ), + array( "http://www.ioccc.org/index.html", "2f5356890efcedab" ), + array( "http://www.isthe.com/cgi-bin/number.cgi", "95c2b383014f55c5" ), + array( "http://www.isthe.com/chongo/bio.html", "4727a5339ce6070f" ), + array( "http://www.isthe.com/chongo/index.html", "b0555ecd575108e9" ), + array( "http://www.isthe.com/chongo/src/calc/lucas-calc", "48d785770bb4af37" ), + array( "http://www.isthe.com/chongo/tech/astro/venus2004.html", "09d4701c12af02b1" ), + array( "http://www.isthe.com/chongo/tech/astro/vita.html", "79f031e78f3cf62e" ), + array( "http://www.isthe.com/chongo/tech/comp/c/expert.html", "52a1ee85db1b5a94" ), + array( "http://www.isthe.com/chongo/tech/comp/calc/index.html", "6bd95b2eb37fa6b8" ), + array( "http://www.isthe.com/chongo/tech/comp/fnv/index.html", "74971b7077aef85d" ), + array( "http://www.isthe.com/chongo/tech/math/number/howhigh.html", "b4e4fae2ffcc1aad" ), + array( "http://www.isthe.com/chongo/tech/math/number/number.html", "2bd48bd898b8f63a" ), + array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html", "e9966ac1556257f6" ), + array( "http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest", "92a3d1cd078ba293" ), + array( "http://www.lavarnd.org/cgi-bin/corpspeak.cgi", "f81175a482e20ab8" ), + array( "http://www.lavarnd.org/cgi-bin/haiku.cgi", "5bbb3de722e73048" ), + array( "http://www.lavarnd.org/cgi-bin/rand-none.cgi", "6b4f363492b9f2be" ), + array( "http://www.lavarnd.org/cgi-bin/randdist.cgi", "c2d559df73d59875" ), + array( "http://www.lavarnd.org/index.html", "f75f62284bc7a8c2" ), + array( "http://www.lavarnd.org/what/nist-test.html", "da8dd8e116a9f1cc" ), + array( "http://www.macosxhints.com/", "bdc1e6ab76057885" ), + array( "http://www.mellis.com/", "fec6a4238a1224a0" ), + array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/havoalert.cfm", "c03f40f3223e290e" ), + array( "http://www.nature.nps.gov/air/webcams/parks/havoso2alert/timelines_24.cfm", "1ed21673466ffda9" ), + array( "http://www.paulnoll.com/", "df70f906bb0dd2af" ), + array( "http://www.pepysdiary.com/", "f3dcda369f2af666" ), + array( "http://www.sciencenews.org/index/home/activity/view", "9ebb11573cdcebde" ), + array( "http://www.skyandtelescope.com/", "81c72d9077fedca0" ), + array( "http://www.sput.nl/~rob/sirius.html", "0ec074a31be5fb15" ), + array( "http://www.systemexperts.com/", "2a8b3280b6c48f20" ), + array( "http://www.tq-international.com/phpBB3/index.php", "fd31777513309344" ), + array( "http://www.travelquesttours.com/index.htm", "194534a86ad006b6" ), + array( "http://www.wunderground.com/global/stations/89606.html", "3be6fdf46e0cfe12" ), + array( R10("21701"), "017cc137a07eb057" ), + array( R10("M21701"), "9428fc6e7d26b54d" ), + array( R10("2^21701-1"), "9aaa2e3603ef8ad7" ), + array( R10("\x54\xc5"), "82c6d3f3a0ccdf7d" ), + array( R10("\xc5\x54"), "c86eeea00cf09b65" ), + array( R10("23209"), "705f8189dbb58299" ), + array( R10("M23209"), "415a7f554391ca69" ), + array( R10("2^23209-1"), "cfe3d49fa2bdc555" ), + array( R10("\x5a\xa9"), "f0f9c56039b25191" ), + array( R10("\xa9\x5a"), "7075cb6abd1d32d9" ), + array( R10("391581216093"), "43c94e2c8b277509" ), + array( R10("391581*2^216093-1"), "3cbfd4e4ea670359" ), + array( R10("\x05\xf9\x9d\x03\x4c\x81"), "c05887810f4d019d" ), + array( R10("FEDCBA9876543210"), "14468ff93ac22dc5" ), + array( R10("\xfe\xdc\xba\x98\x76\x54\x32\x10"), "ebed699589d99c05" ), + array( R10("EFCDAB8967452301"), "6d99f6df321ca5d5" ), + array( R10("\xef\xcd\xab\x89\x67\x45\x23\x01"), "0cd410d08c36d625" ), + array( R10("0123456789ABCDEF"), "ef1b2a2c86831d35" ), + array( R10("\x01\x23\x45\x67\x89\xab\xcd\xef"), "3b349c4d69ee5f05" ), + array( R10("1032547698BADCFE"), "55248ce88f45f035" ), + array( R10("\x10\x32\x54\x76\x98\xba\xdc\xfe"), "aa69ca6a18a4c885" ), + array( R500("\x00"), "1fe3fce62bd816b5" ), + array( R500("\x07"), "0289a488a8df69d9" ), + array( R500("~"), "15e96e1613df98b5" ), + array( R500("\x7f"), "e6be57375ad89b99" ), ); $i = 0; $pass = true; foreach($tests as $test) { - $result = hash('fnv164', $test[0]); - if ($result != $test[1]) { - echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n"; + $result = hash('fnv164', $test[0]); + if ($result != $test[1]) { + echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n"; $pass = false; - } - $i++; + } + $i++; } if($pass) { diff --git a/ext/hash/tests/fnv1a32.phpt b/ext/hash/tests/fnv1a32.phpt index d2e01f799875..af12a2de3761 100644 --- a/ext/hash/tests/fnv1a32.phpt +++ b/ext/hash/tests/fnv1a32.phpt @@ -4,321 +4,321 @@ Hash: FNV1a32 algorithm g# $a', 'ae428052' ), - array( '07*tZ8', 'ed8d23f4' ), - array( ',YEF5u', 'faf2b057' ), - array( 'Q3K2.6', '44f076e4' ), - array( 'ti(0aT', '29d6e513' ), - array( 'U OJ', '9fee418c' ), - array( 'fa^z}tJc-v', '42d4d075' ), - array( '>3K/./J_b9', 'd9e15b05' ), - array( 'EVmRXE&LdV', '1ccbc7ba' ), - array( 'wK9WG7LqzYi', 'fc482f42' ), - array( '9m5I|Es\\(."', '43fc2be7' ), - array( '^{U8B\\d(4\\T', 'af371347' ), - array( 'M4{eanatG"$Y@@d', 'e67f32fc' ), - array( '1\\LL_,R/kCU]%e', '563251e6' ), - array( 'w.=)F]t\\|i% n^', '10a0ae81' ), - array( 'A0DRlp~L|Q\\it2', '2f5d78ca' ), - array( 'Gzw@)6IPt?-q*3', '228eab51' ), - array( 'rxq4*6fw(eE%8"n', '843e8340' ), - array( '.57).W3D"d9Ar,K', '9cc1aba3' ), - array( '&~Ex3O0yH8_m=xo', 'c1a72c91' ), - array( '-\'&D14{EX}*r@}~', 'f0b627fc' ), - array( 'k$}2}1b.,+Flyde', '2255bec4' ), - array( 'iqmp6~%3D]2OPRNO', '95cb7153' ), - array( '?RNRQ`5_lA\'Y;k@&', '98f1390e' ), - array( '^.vu.{)SZ<#+nQ[/', '2f89dc6c' ), - array( '%+aVkw7Y9>3U+T\\j', '15c1ec76' ), - array( 'bS`pPjD+\'H7vzs\'!', 'b732fff0' ), - array( '~hWkaoE{.YQ:..%qb', 'a53c7189' ), - array( 'eb3Q(?XQWPLKWMKA&', '3bf2f0e8' ), - array( '7#u]~%7Q?E_D7C+zW', 'f5038551' ), - array( '\\$w5UOf#{>PH_W`cN', 'c3b89ba6' ), - array( '>bSU4rzt839C.p 2h', '00cf8218' ), - array( '5h9|k6;=^{t?`C]Cv4', '855c27e9' ), - array( 'Xj0N#CgFRYFeC\\N]Z;', 'caae0fcf' ), - array( 'suXRrNrTrPwjeQUu!Y', 'e2ac5b6c' ), - array( ':i lDGSg%#E_>:VwlJ', '0648058a' ), - array( 'F_~91w$vIZmK4(55tY', '11c2fffb' ), - array( '\\HBbLhBj#ybpD*PCCb;', 'b32cc782' ), - array( 'HZe#H27PGLF"*oEl<.0', '86a137c7' ), - array( '\'1*j"NtSr87/aqtd;\'|', 'f40113e8' ), - array( 'kOI3RT#wB?&RF8]2;,\'', '0096ffab' ), - array( 'n @\'/"y$g5,d"\\/5/c9', '8b7ec669' ), - array( '\'&X.Y F72aD:QDZYS]SX', '26b51c68' ), - array( 'Eid*lB9#Q}i*4y"_/ ],59', '9354bdac' ), - array( '^#:yWG#Mm/u2Xx\\vcg+]', '4debf08a' ), - array( 'iHI)(X)ee> DB;?zbCIPS', '312f5ce8' ), - array( '@c,9A$|)/[sX%|`]&GDEG', '8793f867' ), - array( 'ihc)cFL-w!M[-g|1d\'A@z', '57a03ef9' ), - array( 'yFw[%~#IDK3.0=qVj OkN', 'a435237b' ), - array( '+x6)+{0M=+Hc$$h#(3HTF', 'f7f3fb17' ), - array( 'VdcI', '6ec48f20' ), - array( 'mmLv[=ya\\b k8/tS|\' Pwl[f', '9fb5d98f' ), - array( '?4/lO2,>!X5]u/?Sr@@,O5_M', 'b476c549' ), - array( '=_~5M[|lo,Z?>f]@?s}6$>iw', '621bbc86' ), - array( '^+$/@c]^C\\sp9p^)|9I@;eQy)Ns1F -q1}<_L\\U', 'c5960f99' ), - array( 'B\\_sx\\@r%71FRvwM!FA3lA@_S?', '51be9eb7' ), - array( '{4lXj05K$.)D".\\3T0+L]-r @`', 'e8525ded' ), - array( 'Aa@u"=+nvu -A$;JI>X&R.7^[uk', '0510b06f' ), - array( 'Nu,08nQ.pn9`e0`rQd/{.MU5 cL', '43c2c9c8' ), - array( '^?BKn8X~QGP_8@yx&*Zy[@)XOV.', '39874c53' ), - array( 'dWr273Ub"n;"@bS!{szuz&Ptbp~', 'c81fe453' ), - array( '<@VJ&.>8ERn)U]DW~(, $!{y|"K', 'dc0d68d2' ), - array( 'qek&sJKLITYIYZET', '90be4d50' ), - array( 'WH J.=;0zc]_;J\\8hI?]sk+=@dfy', '5e1e1340' ), - array( '?-OwUOBcm^tiCRI^}\'wfP7ED#PaC', 'f03345c0' ), - array( '5I>UWmM->pq,Pgus:?S9FK!wbF9+', '547a6b68' ), - array( 'eUq]U{k~EP!]b04f2v;{Qd!Ka?l+^', 'e777322d' ), - array( '&6D[)#2&n1L?2*#C?iU7&RhkS4Nr!', '4a78ebdf' ), - array( 'YR\'ovcyyu i\'L*:W-^vw5.}gvj<+9', 'f83d06fa' ), - array( '0-rb4cZw]Um^?u+J1bWpZO&hNn`:,', '7f314445' ), - array( 'lS', '831a8450' ), - array( 'lr+A0&h05sk=^{4\'M#\\H"t{sh kESS', '0c39d6ad' ), - array( 'cAFobWuKh,@TJ Q_(~bdHeYEYCEEhx', '12b2879c' ), - array( 'xM;@=}x4JaAk7kkhLsh/Y2t4WOW}uA', '81c3b55c' ), - array( 'von21-1*B[lcH$P4m|)V-bi#wARO?I', '0d5d6b27' ), - array( 'p79`JKn[V18Cu`GGu5D lQbVTZx(+8', '0fd3c926' ), - array( 'Q{Pk]z7LWn^o2UQZ|HpAH]s,5If/QrG', '0f36a996' ), - array( '$oxoMs(zLvY=*/nd,8UN`4ClJlTY>G"', '80b38386' ), - array( 'C7z4do<_<4:Y?JI$WaZ\'BoJ0;7dtV,w', '9874d3b3' ), - array( 'yDr.*cKj `%Z P$%(f`/*PY:kq~aH,Y', 'ab5089b4' ), - array( 'BQMQ[1|F1]Lk]|pc&WD5buo|ab|D+*}', '5d600f5e' ), - array( 'N[K 7\\|^n[+[9(L}.%BDg85ezwc?$m>R', '1966e89b' ), - array( 'JjRaGPA7,LrFU?EcEg).!?t{7X<;F[mp', '908106a1' ), - array( 'FASnrt& BxGw9l\\_TemV%bR=GH{qF^!x_L;9Z*;?k(,', '36f68af8' ), - array( '/Qx;Y\'*gOtgn<0j/WI1Q)]lC9w_Xcges:', '885fad78' ), - array( '^0tf:\\60E%MVp].:n_DMMgfEH?*0%}Kd.', '7f86cff2' ), - array( '@LI}cZCi)yZg)tVi:%8#k^K,h\\2g(vvIC', '3dd2e16e' ), - array( '@G\'{jp&eLmoBEY\\Jq_6Q,B:hT#pLy:p;a', '03b92168' ), - array( 'x8Mj>47,$YQ^6{Qv2##U>l+A]WD:C~l"6hS-{W1Qu}]8\\6TU_,2#|<0+', 'b86f1510' ), - array( '[UF~U3"k|Vyx.+K$*)J=,[1#6v]2L^7}#yx:pdN', '800e955f' ), - array( '{}f:~r7{0UGNa$_e:WCM$#d"&_{AQ`pN^Wh', 'fa87c111' ), - array( '^K [\\U$+8)k~CCBqGEWJL7Fnh(_7g7!Fc!"', 'f0d49ddf' ), - array( '@W\'Kp08oT[3F$Y}N\'6uu ~U8fm9-Q;0qs8>', 'bbc8b16a' ), - array( 'eHVU|2iD7CCfJY]@Y\\vqCd,Q6Gb);zG!D}WB', 'b4c1dc4c' ), - array( '1BfIe+01dmR?JI2n.>@Ef#N#~u%Dt\\f\' NPe', '7c98ca04' ), - array( 'Y`w?NJ_ysqh#1)Hw-w{-m!Qc^9j^g;EB{=bK', '79ccb205' ), - array( 'gBF\\5/_F9)?G!;Un=\'S{A>[)Y!LV>/#\'QIcg', 'ba719e14' ), - array( 'YC.rLN;Mjp=(xp%:0`DjbpB! E(Rol:I0I=]', 'ce2a6b64' ), - array( 'xY,cJIlC;r]KT"77sY9t~BGo/b:@-X}&2*j\\T', '87e2ae2a' ), - array( 'X!pK_=!bT8V.RL.ts}$W8DdqCk$NVa$0ct\\C2', '380f7299' ), - array( ']\'gv^uI+%> #CW]k', '4b7036db' ), - array( 'e`4n5`9-iXvNV^rcGZE_V)1U>-!pL_]2@q"UR;', '2ef7953e' ), - array( 'b=sYlK9_/`;TAr^SH|aJm.+K@K>C"p^d/S?{~X', '58f87a0f' ), - array( '\\/:wc\\jC04@q_. jZA7xd9jD}zw>vwwS\'3Lko8', '924bf023' ), - array( '/ MOr.^rx9503yI~>Hy7gp/_E6rr#c,2cYbWhA', 'd2c773bf' ), - array( 'Ja[`ro[=nzeh2MZB.!Y"t\\e!oJ[R"DtM\'P.yAi', '59761485' ), - array( '70d}ywLU:ZVs]LQCMAn*sqOh@V:NQ[9il~hgw5=', '1616e5d5' ), - array( '2pt\'NAXroybznTJXt"rDTO^>=^(%V=Bi/8q^ZJR', '2b93c8c6' ), - array( 'JE5E5jpm_r`%G1cfNBnSy-vd=0V{j!N5Gc[\\NMJ', '22863e0e' ), - array( '/@,4h=xPl<@@7N8{kHRg3T7I{z&YJS%Zt2o^Oi/', 'ce54d2ce' ), - array( '<&O]=~v9j?lRSAi}>e%w1X}lN0\\-`G=}Mm[klS&', '925e90a6' ), - array( 'Wsr+G4tFS[KLm%JZTZ8a<_ :.mvyZJ!3>s>f)3-]', 'b47ebcb9' ), - array( 'oY*]^T830PuL1uf?d^9?);RG0q.9&_5OV|n;[)ZdE.-U .$;}?w', '2fb33679' ), - array( '(z]M*j#+\'r2_Z0/Da3e!"n_O.mTJltBto CzkF&r', '569492ba' ), - array( ':9SuIb:+v!-xplI~[}JHrm>cna^Z)eND~":IeUT]', 'b9cb09fa' ), - array( 'WbVHP!H- rVratWPW7+a}Y&|\\AFBw{!O_Ww0YA>Y5', '26b7c332' ), - array( 'tMvi&HB=S$;.+9jL`.D]/t=gmNB/l{EbIi`@#d$C4z\'t~~(', 'fa5a6693' ), - array( '$3h4_}Mw6?-Im\\E&z/g<2M@Va<^W<]_@pITQH#J^BW', '5db013f4' ), - array( '(14N80^ LqNmH0+\'hGeIhWr>*Xb)FmR,laznl:H^V?FKLC4z|9}{|`z<:^F`Lxm', 'c04f1349' ), - array( ':[h*I#R(ZrO\'?r<;oU:lS{ho6G6vt0e/kN:6Rl>._m5', '48c23cac' ), - array( ' aQ$n?eA[9I3X&faRP', 'a53ac530' ), - array( '262W+Y.kP}b{[wTz|D:bev{0*U7p7iBJ!T#,.1w_/Z[k', '05d91499' ), - array( 'S1gPU"4-I1.[XKr1u!UcF`M#3-=@|#9et]Tt', 'bd458351' ), - array( ';r#d$1A]\\4nR6E6\\&d_:q}Zn"tUwR*lm}oS#!u`^+P1Au', 'f8e9f1d5' ), - array( 'H}|-^7 ]ro_gEW;PD*N5]Q7S3u^c\' YP~W^^n^(33lef0\'yo,\\L]6\\u6e ,}ZI\\9CW\\]udq)QWpb_jRlH~', 'e9d8fa86' ), - array( 'J^[@tB@!A{K~5oVqNLW@V*xGlY3@F[@q;|21?S3aO_`eP8', '104537ea' ), - array( 'X~e0@<;:d)swI;Ti-pg@"(s6iDuK*GcbFIsgf/"K9vCb2x', '7c5f8020' ), - array( 'M?i5_l=T#(xyT$A9fhb[QJkSu%K:h]46}}L^kj3os-iH1,', 'ab2ee1ee' ), - array( 'axuETGoA{fFG"0&6G$4sb!_upS#[{5h^.^$c\'t%#[LK]\\Q', '8520630b' ), - array( 't$U)x8*X/{,3W)H@hW m;\'bA+?mV}K(rP^|Iw("\'$/;\\9d', '5ec32f02' ), - array( '|"<|oX%Sz0rifq5oeeNb0Fk2NpBiM[OK^lINFN#A^u+FhA7', 'b5b5f4e5' ), - array( 'N(e18-}K[nmF=own-#B.lVM_n`5p!F];5zJ}ZLF.("MFrE6!', '8f9e0173' ), - array( 'IX/60]v~>,p@RO[hJ\'f%S.4[1a#$\'9%Qr5g#r_#1ktQ>D.(', 'f4e44d2d' ), - array( 'n5oth}*E/kH4sb:FVO.ZBn]TZR\'yv5"fJq\\4ofZ S#4HfNn>', '51b1ae3d' ), - array( '}}xAlVvH*}B"4Eh_7Fs(.N(aR=+:lyXkxQ.f)%/3#R57w~v/', '0d3e9950' ), - array( 'Ek7S;@6m^A)L;Tv|Y.>C$|JY{f/Y9dsgdpT3+zpddRfI;NXtg>iP#Z%6', '3e4eb24d' ), - array( 'e \'KeZg_,\'St6-=\'K%QfS+\\;IFkL!qcgrk3XF{9R$lG;yeBFjs', '69476a97' ), - array( '.? j[I2Hv4:Z{-F0fm, A0mhLhOn0:c>Zc*6.=^%Qy`M(\']nuj', '9097fe8e' ), - array( 'n7{]!HFP7Vk{uF`!]n>=to7U>?]{.Sg}kc\\l,#>DZ*@QQ"R/qq', 'cbee4ea9' ), - array( 'Mfbd5jf3"y#NWB~R-kJGcr[Oog6Am;', '9cb72621' ), - array( '}%3`DHK+\\N&_|^#|10h[WLO4|?{4ajP_pc@5-lAi&tUbc', 'e4bd2dd7' ), - array( '*f|xrd 8,(Qi^1sbVGHC.@9y1W &.cj9Kh2>M2VZ:)Dy;9\\r`%6', '5efb3af6' ), - array( 'oFOiW(j^7NIPy2b9`uo;1y`+6zh)\\n@L5p6mx!L0OvaJ)Dci;T&', '05e74ead' ), - array( 'LNfXdaAn>0/jF "5y#b+SYl}b2bMM7Sze:SK|u:<&J(MJ*bD.EOb', '17cbb538' ), - array( ' PAXMi[e#*S0sPGjCUIsHk=JI=^td4A#eb\\3M8yQBMb7~+', '50438792' ), - array( '#CaM8*9UUbs5XXIy[/]8B+P=]sjA+jL./.\\G9u|oYp%2JO,&_i?"up?', '5a10e446' ), - array( 'Td+upvB~&Q\\NkRL[->`?h1Lop7/s- 4ad@XU7zU>M2l9e9trWV3Ag_1', 'b41de8a2' ), - array( 'Xw@L&@ah&"A\\9<3WjEE$,_y 8P3Y9sjrk,@rM"[S$|1>:Du%j<*v{$v', '3d1d96c3' ), - array( '4T+nn~Yake"^4$;g)8xGR>>X)Zb Wfwk<#Z+#5mo{oO0tjx}#rEV1c/', '021cf019' ), - array( ':?r;vZ3cv7?#:Tq+QaZaWE[UHN{ ``0{ #7v]KZUbyX}OJ)!-ccd*?;', 'a52533a0' ), - array( 'Sn8SOxcLxfcpE0KzsFTqu~{w-`[rj{/>jGr;@Vg:>L+c]W_Q}4Dt4@lA', 'eacea244' ), - array( '"I5lED,1k~M-V6GtcRYA*9s)N8}bYk%[6;I\\_UnLUxK6F6\\-~eLSuI@AnhMk!\'>V:}_P_~<~', '7481744d' ), - array( 'xh5@~qM}XzRODrq4\\? ^F>6aw>"*z', 'c6ec7195' ), - array( 'b#+VG+SGvOUM:, $CTKUj*Nq~mi=os9SwD+?O_gG0>tJKtOnJ{E6&s(&a', '6976d3a8' ), - array( 'rCRg\\\'`"2!Qriy#(nNTd~C/ziE"]N(@AKr))zj+.k]!UW$^FR3,QW;MA`', '57543a3a' ), - array( 'O /X@Q%4[.0F:>2w?hPDGvwZ$J3?wT!HT0!ub&+>4;dOZwGy`w?)o7dsa', '5e4ad807' ), - array( 'w4ZM5##F%x)+%G@A-o{%8vf06p!NUu1N*k{?o~etxn }7A?D1;JI32ZI#', 'c01f194b' ), - array( '\\wXR)(]u$|e#cZ|SZzj{;/.WZXjl45op-ID7Q"-U rYcMV7)R#&n35Fmm', '4e92f8a5' ), - array( '2Z"GJsUt8lF;z|;mV <.8F`;MPNbw>PgsSmSJvFNfC=:4E\\e.Q9{&crL2YpPs.%_ K4 ', '11032641' ), - array( '_;-^N4}bZ[Hh-ae3EX`X3R)(`/h`[|a;9nzg$xK^UsHcV.w{gXUz,^$lnm', '9298d67e' ), - array( 'MKj/f%~bl#\\9b2-+vc:n`"H6}Tu#Aepo1\\ xa~[O#8hfKvrBZ-2.l*LIU{%gL^f["(&Da/}Ij QpEnUQrQ]YI0OE*q', '3bec6d86' ), - array( ':pe]c9t5o(L2n&Nv68lvDgW`bGX)fbz"Sa_8zTNk]z}L"LC8e10*ygk\\0Dfv', 'fef9aa77' ), + array( 'l', 'e90c310b' ), + array( 'b', 'e70c2de5' ), + array( 'a', 'e40c292c' ), + array( 'd', 'e10c2473' ), + array( 'Z', 'df0c214d' ), + array( '0K', '66eddeec' ), + array( 'cp', '47297986' ), + array( 'UY', '6bf399cb' ), + array( 'RS', '6e04e612' ), + array( '+`', '47dc64fe' ), + array( 'Q: ', '1c02a1d6' ), + array( ' Mu', 'c5c8a3f9' ), + array( 'jS0', '1819afae' ), + array( 'cRZ', 'd9f699ae' ), + array( ' "]', 'ee32d84e' ), + array( 'Bo@$', '1544a53a' ), + array( 'U{5"', '08f0b60a' ), + array( '`&W;', '300ba78d' ), + array( 'Y+F;', '12d960fe' ), + array( '\\a<]', '7596c231' ), + array( '/2HcC', '4ee26872' ), + array( '-7}-:', '5e0b1ab7' ), + array( '[O*|T', 'c259a137' ), + array( '_yib[', '6cc9d49b' ), + array( 'p:vKE', 'becd7e8f' ), + array( '>g# $a', 'ae428052' ), + array( '07*tZ8', 'ed8d23f4' ), + array( ',YEF5u', 'faf2b057' ), + array( 'Q3K2.6', '44f076e4' ), + array( 'ti(0aT', '29d6e513' ), + array( 'U OJ', '9fee418c' ), + array( 'fa^z}tJc-v', '42d4d075' ), + array( '>3K/./J_b9', 'd9e15b05' ), + array( 'EVmRXE&LdV', '1ccbc7ba' ), + array( 'wK9WG7LqzYi', 'fc482f42' ), + array( '9m5I|Es\\(."', '43fc2be7' ), + array( '^{U8B\\d(4\\T', 'af371347' ), + array( 'M4{eanatG"$Y@@d', 'e67f32fc' ), + array( '1\\LL_,R/kCU]%e', '563251e6' ), + array( 'w.=)F]t\\|i% n^', '10a0ae81' ), + array( 'A0DRlp~L|Q\\it2', '2f5d78ca' ), + array( 'Gzw@)6IPt?-q*3', '228eab51' ), + array( 'rxq4*6fw(eE%8"n', '843e8340' ), + array( '.57).W3D"d9Ar,K', '9cc1aba3' ), + array( '&~Ex3O0yH8_m=xo', 'c1a72c91' ), + array( '-\'&D14{EX}*r@}~', 'f0b627fc' ), + array( 'k$}2}1b.,+Flyde', '2255bec4' ), + array( 'iqmp6~%3D]2OPRNO', '95cb7153' ), + array( '?RNRQ`5_lA\'Y;k@&', '98f1390e' ), + array( '^.vu.{)SZ<#+nQ[/', '2f89dc6c' ), + array( '%+aVkw7Y9>3U+T\\j', '15c1ec76' ), + array( 'bS`pPjD+\'H7vzs\'!', 'b732fff0' ), + array( '~hWkaoE{.YQ:..%qb', 'a53c7189' ), + array( 'eb3Q(?XQWPLKWMKA&', '3bf2f0e8' ), + array( '7#u]~%7Q?E_D7C+zW', 'f5038551' ), + array( '\\$w5UOf#{>PH_W`cN', 'c3b89ba6' ), + array( '>bSU4rzt839C.p 2h', '00cf8218' ), + array( '5h9|k6;=^{t?`C]Cv4', '855c27e9' ), + array( 'Xj0N#CgFRYFeC\\N]Z;', 'caae0fcf' ), + array( 'suXRrNrTrPwjeQUu!Y', 'e2ac5b6c' ), + array( ':i lDGSg%#E_>:VwlJ', '0648058a' ), + array( 'F_~91w$vIZmK4(55tY', '11c2fffb' ), + array( '\\HBbLhBj#ybpD*PCCb;', 'b32cc782' ), + array( 'HZe#H27PGLF"*oEl<.0', '86a137c7' ), + array( '\'1*j"NtSr87/aqtd;\'|', 'f40113e8' ), + array( 'kOI3RT#wB?&RF8]2;,\'', '0096ffab' ), + array( 'n @\'/"y$g5,d"\\/5/c9', '8b7ec669' ), + array( '\'&X.Y F72aD:QDZYS]SX', '26b51c68' ), + array( 'Eid*lB9#Q}i*4y"_/ ],59', '9354bdac' ), + array( '^#:yWG#Mm/u2Xx\\vcg+]', '4debf08a' ), + array( 'iHI)(X)ee> DB;?zbCIPS', '312f5ce8' ), + array( '@c,9A$|)/[sX%|`]&GDEG', '8793f867' ), + array( 'ihc)cFL-w!M[-g|1d\'A@z', '57a03ef9' ), + array( 'yFw[%~#IDK3.0=qVj OkN', 'a435237b' ), + array( '+x6)+{0M=+Hc$$h#(3HTF', 'f7f3fb17' ), + array( 'VdcI', '6ec48f20' ), + array( 'mmLv[=ya\\b k8/tS|\' Pwl[f', '9fb5d98f' ), + array( '?4/lO2,>!X5]u/?Sr@@,O5_M', 'b476c549' ), + array( '=_~5M[|lo,Z?>f]@?s}6$>iw', '621bbc86' ), + array( '^+$/@c]^C\\sp9p^)|9I@;eQy)Ns1F -q1}<_L\\U', 'c5960f99' ), + array( 'B\\_sx\\@r%71FRvwM!FA3lA@_S?', '51be9eb7' ), + array( '{4lXj05K$.)D".\\3T0+L]-r @`', 'e8525ded' ), + array( 'Aa@u"=+nvu -A$;JI>X&R.7^[uk', '0510b06f' ), + array( 'Nu,08nQ.pn9`e0`rQd/{.MU5 cL', '43c2c9c8' ), + array( '^?BKn8X~QGP_8@yx&*Zy[@)XOV.', '39874c53' ), + array( 'dWr273Ub"n;"@bS!{szuz&Ptbp~', 'c81fe453' ), + array( '<@VJ&.>8ERn)U]DW~(, $!{y|"K', 'dc0d68d2' ), + array( 'qek&sJKLITYIYZET', '90be4d50' ), + array( 'WH J.=;0zc]_;J\\8hI?]sk+=@dfy', '5e1e1340' ), + array( '?-OwUOBcm^tiCRI^}\'wfP7ED#PaC', 'f03345c0' ), + array( '5I>UWmM->pq,Pgus:?S9FK!wbF9+', '547a6b68' ), + array( 'eUq]U{k~EP!]b04f2v;{Qd!Ka?l+^', 'e777322d' ), + array( '&6D[)#2&n1L?2*#C?iU7&RhkS4Nr!', '4a78ebdf' ), + array( 'YR\'ovcyyu i\'L*:W-^vw5.}gvj<+9', 'f83d06fa' ), + array( '0-rb4cZw]Um^?u+J1bWpZO&hNn`:,', '7f314445' ), + array( 'lS', '831a8450' ), + array( 'lr+A0&h05sk=^{4\'M#\\H"t{sh kESS', '0c39d6ad' ), + array( 'cAFobWuKh,@TJ Q_(~bdHeYEYCEEhx', '12b2879c' ), + array( 'xM;@=}x4JaAk7kkhLsh/Y2t4WOW}uA', '81c3b55c' ), + array( 'von21-1*B[lcH$P4m|)V-bi#wARO?I', '0d5d6b27' ), + array( 'p79`JKn[V18Cu`GGu5D lQbVTZx(+8', '0fd3c926' ), + array( 'Q{Pk]z7LWn^o2UQZ|HpAH]s,5If/QrG', '0f36a996' ), + array( '$oxoMs(zLvY=*/nd,8UN`4ClJlTY>G"', '80b38386' ), + array( 'C7z4do<_<4:Y?JI$WaZ\'BoJ0;7dtV,w', '9874d3b3' ), + array( 'yDr.*cKj `%Z P$%(f`/*PY:kq~aH,Y', 'ab5089b4' ), + array( 'BQMQ[1|F1]Lk]|pc&WD5buo|ab|D+*}', '5d600f5e' ), + array( 'N[K 7\\|^n[+[9(L}.%BDg85ezwc?$m>R', '1966e89b' ), + array( 'JjRaGPA7,LrFU?EcEg).!?t{7X<;F[mp', '908106a1' ), + array( 'FASnrt& BxGw9l\\_TemV%bR=GH{qF^!x_L;9Z*;?k(,', '36f68af8' ), + array( '/Qx;Y\'*gOtgn<0j/WI1Q)]lC9w_Xcges:', '885fad78' ), + array( '^0tf:\\60E%MVp].:n_DMMgfEH?*0%}Kd.', '7f86cff2' ), + array( '@LI}cZCi)yZg)tVi:%8#k^K,h\\2g(vvIC', '3dd2e16e' ), + array( '@G\'{jp&eLmoBEY\\Jq_6Q,B:hT#pLy:p;a', '03b92168' ), + array( 'x8Mj>47,$YQ^6{Qv2##U>l+A]WD:C~l"6hS-{W1Qu}]8\\6TU_,2#|<0+', 'b86f1510' ), + array( '[UF~U3"k|Vyx.+K$*)J=,[1#6v]2L^7}#yx:pdN', '800e955f' ), + array( '{}f:~r7{0UGNa$_e:WCM$#d"&_{AQ`pN^Wh', 'fa87c111' ), + array( '^K [\\U$+8)k~CCBqGEWJL7Fnh(_7g7!Fc!"', 'f0d49ddf' ), + array( '@W\'Kp08oT[3F$Y}N\'6uu ~U8fm9-Q;0qs8>', 'bbc8b16a' ), + array( 'eHVU|2iD7CCfJY]@Y\\vqCd,Q6Gb);zG!D}WB', 'b4c1dc4c' ), + array( '1BfIe+01dmR?JI2n.>@Ef#N#~u%Dt\\f\' NPe', '7c98ca04' ), + array( 'Y`w?NJ_ysqh#1)Hw-w{-m!Qc^9j^g;EB{=bK', '79ccb205' ), + array( 'gBF\\5/_F9)?G!;Un=\'S{A>[)Y!LV>/#\'QIcg', 'ba719e14' ), + array( 'YC.rLN;Mjp=(xp%:0`DjbpB! E(Rol:I0I=]', 'ce2a6b64' ), + array( 'xY,cJIlC;r]KT"77sY9t~BGo/b:@-X}&2*j\\T', '87e2ae2a' ), + array( 'X!pK_=!bT8V.RL.ts}$W8DdqCk$NVa$0ct\\C2', '380f7299' ), + array( ']\'gv^uI+%> #CW]k', '4b7036db' ), + array( 'e`4n5`9-iXvNV^rcGZE_V)1U>-!pL_]2@q"UR;', '2ef7953e' ), + array( 'b=sYlK9_/`;TAr^SH|aJm.+K@K>C"p^d/S?{~X', '58f87a0f' ), + array( '\\/:wc\\jC04@q_. jZA7xd9jD}zw>vwwS\'3Lko8', '924bf023' ), + array( '/ MOr.^rx9503yI~>Hy7gp/_E6rr#c,2cYbWhA', 'd2c773bf' ), + array( 'Ja[`ro[=nzeh2MZB.!Y"t\\e!oJ[R"DtM\'P.yAi', '59761485' ), + array( '70d}ywLU:ZVs]LQCMAn*sqOh@V:NQ[9il~hgw5=', '1616e5d5' ), + array( '2pt\'NAXroybznTJXt"rDTO^>=^(%V=Bi/8q^ZJR', '2b93c8c6' ), + array( 'JE5E5jpm_r`%G1cfNBnSy-vd=0V{j!N5Gc[\\NMJ', '22863e0e' ), + array( '/@,4h=xPl<@@7N8{kHRg3T7I{z&YJS%Zt2o^Oi/', 'ce54d2ce' ), + array( '<&O]=~v9j?lRSAi}>e%w1X}lN0\\-`G=}Mm[klS&', '925e90a6' ), + array( 'Wsr+G4tFS[KLm%JZTZ8a<_ :.mvyZJ!3>s>f)3-]', 'b47ebcb9' ), + array( 'oY*]^T830PuL1uf?d^9?);RG0q.9&_5OV|n;[)ZdE.-U .$;}?w', '2fb33679' ), + array( '(z]M*j#+\'r2_Z0/Da3e!"n_O.mTJltBto CzkF&r', '569492ba' ), + array( ':9SuIb:+v!-xplI~[}JHrm>cna^Z)eND~":IeUT]', 'b9cb09fa' ), + array( 'WbVHP!H- rVratWPW7+a}Y&|\\AFBw{!O_Ww0YA>Y5', '26b7c332' ), + array( 'tMvi&HB=S$;.+9jL`.D]/t=gmNB/l{EbIi`@#d$C4z\'t~~(', 'fa5a6693' ), + array( '$3h4_}Mw6?-Im\\E&z/g<2M@Va<^W<]_@pITQH#J^BW', '5db013f4' ), + array( '(14N80^ LqNmH0+\'hGeIhWr>*Xb)FmR,laznl:H^V?FKLC4z|9}{|`z<:^F`Lxm', 'c04f1349' ), + array( ':[h*I#R(ZrO\'?r<;oU:lS{ho6G6vt0e/kN:6Rl>._m5', '48c23cac' ), + array( ' aQ$n?eA[9I3X&faRP', 'a53ac530' ), + array( '262W+Y.kP}b{[wTz|D:bev{0*U7p7iBJ!T#,.1w_/Z[k', '05d91499' ), + array( 'S1gPU"4-I1.[XKr1u!UcF`M#3-=@|#9et]Tt', 'bd458351' ), + array( ';r#d$1A]\\4nR6E6\\&d_:q}Zn"tUwR*lm}oS#!u`^+P1Au', 'f8e9f1d5' ), + array( 'H}|-^7 ]ro_gEW;PD*N5]Q7S3u^c\' YP~W^^n^(33lef0\'yo,\\L]6\\u6e ,}ZI\\9CW\\]udq)QWpb_jRlH~', 'e9d8fa86' ), + array( 'J^[@tB@!A{K~5oVqNLW@V*xGlY3@F[@q;|21?S3aO_`eP8', '104537ea' ), + array( 'X~e0@<;:d)swI;Ti-pg@"(s6iDuK*GcbFIsgf/"K9vCb2x', '7c5f8020' ), + array( 'M?i5_l=T#(xyT$A9fhb[QJkSu%K:h]46}}L^kj3os-iH1,', 'ab2ee1ee' ), + array( 'axuETGoA{fFG"0&6G$4sb!_upS#[{5h^.^$c\'t%#[LK]\\Q', '8520630b' ), + array( 't$U)x8*X/{,3W)H@hW m;\'bA+?mV}K(rP^|Iw("\'$/;\\9d', '5ec32f02' ), + array( '|"<|oX%Sz0rifq5oeeNb0Fk2NpBiM[OK^lINFN#A^u+FhA7', 'b5b5f4e5' ), + array( 'N(e18-}K[nmF=own-#B.lVM_n`5p!F];5zJ}ZLF.("MFrE6!', '8f9e0173' ), + array( 'IX/60]v~>,p@RO[hJ\'f%S.4[1a#$\'9%Qr5g#r_#1ktQ>D.(', 'f4e44d2d' ), + array( 'n5oth}*E/kH4sb:FVO.ZBn]TZR\'yv5"fJq\\4ofZ S#4HfNn>', '51b1ae3d' ), + array( '}}xAlVvH*}B"4Eh_7Fs(.N(aR=+:lyXkxQ.f)%/3#R57w~v/', '0d3e9950' ), + array( 'Ek7S;@6m^A)L;Tv|Y.>C$|JY{f/Y9dsgdpT3+zpddRfI;NXtg>iP#Z%6', '3e4eb24d' ), + array( 'e \'KeZg_,\'St6-=\'K%QfS+\\;IFkL!qcgrk3XF{9R$lG;yeBFjs', '69476a97' ), + array( '.? j[I2Hv4:Z{-F0fm, A0mhLhOn0:c>Zc*6.=^%Qy`M(\']nuj', '9097fe8e' ), + array( 'n7{]!HFP7Vk{uF`!]n>=to7U>?]{.Sg}kc\\l,#>DZ*@QQ"R/qq', 'cbee4ea9' ), + array( 'Mfbd5jf3"y#NWB~R-kJGcr[Oog6Am;', '9cb72621' ), + array( '}%3`DHK+\\N&_|^#|10h[WLO4|?{4ajP_pc@5-lAi&tUbc', 'e4bd2dd7' ), + array( '*f|xrd 8,(Qi^1sbVGHC.@9y1W &.cj9Kh2>M2VZ:)Dy;9\\r`%6', '5efb3af6' ), + array( 'oFOiW(j^7NIPy2b9`uo;1y`+6zh)\\n@L5p6mx!L0OvaJ)Dci;T&', '05e74ead' ), + array( 'LNfXdaAn>0/jF "5y#b+SYl}b2bMM7Sze:SK|u:<&J(MJ*bD.EOb', '17cbb538' ), + array( ' PAXMi[e#*S0sPGjCUIsHk=JI=^td4A#eb\\3M8yQBMb7~+', '50438792' ), + array( '#CaM8*9UUbs5XXIy[/]8B+P=]sjA+jL./.\\G9u|oYp%2JO,&_i?"up?', '5a10e446' ), + array( 'Td+upvB~&Q\\NkRL[->`?h1Lop7/s- 4ad@XU7zU>M2l9e9trWV3Ag_1', 'b41de8a2' ), + array( 'Xw@L&@ah&"A\\9<3WjEE$,_y 8P3Y9sjrk,@rM"[S$|1>:Du%j<*v{$v', '3d1d96c3' ), + array( '4T+nn~Yake"^4$;g)8xGR>>X)Zb Wfwk<#Z+#5mo{oO0tjx}#rEV1c/', '021cf019' ), + array( ':?r;vZ3cv7?#:Tq+QaZaWE[UHN{ ``0{ #7v]KZUbyX}OJ)!-ccd*?;', 'a52533a0' ), + array( 'Sn8SOxcLxfcpE0KzsFTqu~{w-`[rj{/>jGr;@Vg:>L+c]W_Q}4Dt4@lA', 'eacea244' ), + array( '"I5lED,1k~M-V6GtcRYA*9s)N8}bYk%[6;I\\_UnLUxK6F6\\-~eLSuI@AnhMk!\'>V:}_P_~<~', '7481744d' ), + array( 'xh5@~qM}XzRODrq4\\? ^F>6aw>"*z', 'c6ec7195' ), + array( 'b#+VG+SGvOUM:, $CTKUj*Nq~mi=os9SwD+?O_gG0>tJKtOnJ{E6&s(&a', '6976d3a8' ), + array( 'rCRg\\\'`"2!Qriy#(nNTd~C/ziE"]N(@AKr))zj+.k]!UW$^FR3,QW;MA`', '57543a3a' ), + array( 'O /X@Q%4[.0F:>2w?hPDGvwZ$J3?wT!HT0!ub&+>4;dOZwGy`w?)o7dsa', '5e4ad807' ), + array( 'w4ZM5##F%x)+%G@A-o{%8vf06p!NUu1N*k{?o~etxn }7A?D1;JI32ZI#', 'c01f194b' ), + array( '\\wXR)(]u$|e#cZ|SZzj{;/.WZXjl45op-ID7Q"-U rYcMV7)R#&n35Fmm', '4e92f8a5' ), + array( '2Z"GJsUt8lF;z|;mV <.8F`;MPNbw>PgsSmSJvFNfC=:4E\\e.Q9{&crL2YpPs.%_ K4 ', '11032641' ), + array( '_;-^N4}bZ[Hh-ae3EX`X3R)(`/h`[|a;9nzg$xK^UsHcV.w{gXUz,^$lnm', '9298d67e' ), + array( 'MKj/f%~bl#\\9b2-+vc:n`"H6}Tu#Aepo1\\ xa~[O#8hfKvrBZ-2.l*LIU{%gL^f["(&Da/}Ij QpEnUQrQ]YI0OE*q', '3bec6d86' ), + array( ':pe]c9t5o(L2n&Nv68lvDgW`bGX)fbz"Sa_8zTNk]z}L"LC8e10*ygk\\0Dfv', 'fef9aa77' ), ); $i = 0; $pass = true; foreach($tests as $test) { - $result = hash('fnv1a32', $test[0]); - if ($result != $test[1]) { - echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n"; - $pass = false; - } - $i++; + $result = hash('fnv1a32', $test[0]); + if ($result != $test[1]) { + echo "Iteration " . $i . " failed - expected '" . $test[1] . "', got '" . $result . "' for '" . $test[1] . "'\n"; + $pass = false; + } + $i++; } if($pass) { - echo "PASS"; + echo "PASS"; } ?> --EXPECT-- diff --git a/ext/hash/tests/fnv1a64.phpt b/ext/hash/tests/fnv1a64.phpt index 870c6ced0cc5..1393fc1b808a 100644 --- a/ext/hash/tests/fnv1a64.phpt +++ b/ext/hash/tests/fnv1a64.phpt @@ -4,321 +4,321 @@ Hash: FNV1a64 algorithm qH0a', '370b9a8e5a2329eb' ), - array( '*fSR/', 'f78a85007841cb19' ), - array( '3;$tS', '94b935103cc08938' ), - array( ' \'7AS}', 'd81e3aef0fde6ad8' ), - array( 'ou9vPc', '549f05284ed347f7' ), - array( ':u]S4O', '31b0206c95a52e7d' ), - array( '{D2\',e', '3a68240ea9539e62' ), - array( 'Y;yt@n', 'afdae733c98065a2' ), - array( 'IAu`bI_', 'c311eb3e8f9f51c4' ), - array( 'R@xIq]d', '3fa1984555c55e46' ), - array( 'g;8{k5@', '9e9c5e80cdc3d58e' ), - array( '}vD&MVMJ', '1f4fd77c72b6004b' ), - array( 'd//546~,-$', '159ef268adc718d9' ), - array( '4~.{E/s*p6', '31a60e2db942bc67' ), - array( 'F#&dyJkG!:q', '33b8c68aed55c285' ), - array( 'eI"{^9zjG ', 'b42c013a2028584a' ), - array( 'F/|k>pv/(=3', '671c9537b41d76fe' ), - array( '.#-XoUZ*HAT', '84e0630a952577f4' ), - array( 'K>4d:~-: SI', '57deb72cc24c6bad' ), - array( '|@hn8xvV,%Y:', '157fda2502fe1297' ), - array( '^Jp:T9\\*ez>K', 'f784c17d1a2d1bd2' ), - array( '5>XP>-z^K\\JTT', 'dd737d6771e9cd69' ), - array( 'P>vGAoX"qP]3s', '0375e65060074988' ), - array( 'Nrooqy-.Q.Upm', '135d77993c647f43' ), - array( '"M8W"huy18ij:', 'aedeb2565e1c29f7' ), - array( '\\;wo0Gb!8UzEc', '59ae633a0b17a945' ), - array( 'LS:=B0\\7 l^cmw:', 'f21c8cb206540a2e' ), - array( 'h=}6q8T4U@nJ/3', 'b258eae8a4671c77' ), - array( '6wi:L*Y\\gp]UPB', 'bff5f2c9ed84bce5' ), - array( 'CH\\-fZDXsxlJ9\\', '298d4e05d5a47c45' ), - array( 'uIp,BZFne!KMr*#', '8641dfc04c9fb552' ), - array( 'CLGl)USdy-Yry$-', '3ab1497c481f22ab' ), - array( 'WyVH\'y#NhhO57B?', '8dea1d032c597f60' ), - array( ';fkbSt8(Z264&09', '4b875649e7cfa1a9' ), - array( '4g3k1:e4iN}9c6[', 'd33acc8fe01b77fd' ), - array( '$QBo4veM @`6UgGn', 'c4b17749dca1aa6a' ), - array( '{0#gA>MV(|TAaj}e', '067ae9cfff2cd6ea' ), - array( '=AVR8< 9]aO3Iw#E', '02bad50d48a8e564' ), - array( '(&-JD[!LYVm)kd2', '9f7776edcdaf2937' ), - array( 'qq]6N_c)7REY?H:M"', '1899eee357e747b4' ), - array( 'Mtx`VNVg7uq#Z%uMc', '8eb7e5a4bb9fb739' ), - array( '-{Cp%ZCK5ctO2v}\'p', '58ebf399369565ce' ), - array( '^^@6GW,9[f?Q4#^1G', '76ab1ea61d68a738' ), - array( 'P7#tb9XWhjOgrAGQa', '29294a2d4b758119' ), - array( ']x9i3uPSGeW\'v~W.#L', '508d3356f8ec886b' ), - array( 'p<&I&pxmd:57{r06\\D', '4660b5543de2afdc' ), - array( ',.wTsO[jO4xSajog4u', '6d85fca5fba07683' ), - array( 'Y.c?HyVElg\\J,hY%>N', '01e82905c1f66c8f' ), - array( 'Uy:&/4Yq~IZ4@5B%Tk', 'a05cc808b297050e' ), - array( '~+1lrm8 Wr&uA[p[a!o', '22783c7a8fbe4826' ), - array( 'aFyS#\\TsxGc_uhf', 'a8cfc6804bc24e1d' ), - array( 'X0rpD~5iwL|*dh/#KU|', '17b538fc3a531c98' ), - array( '~YZSMS{14qzzK,n=PmR', '47a7dd2be021ae55' ), - array( ':f 8pd!!hMWeL1A!^u|p', '4c9d34c81b647804' ), - array( '*ol&`_h', '25484f299d38dc95' ), - array( 'DmMn{K+oKILw?oqGTl/0', '8ecc9d0f58ead225' ), - array( 'eguN-bTLC55h$cX!0cq[', 'b3e4439d186da97b' ), - array( '.?TN/Fvd4&uznlJ{O~Is5', '983efebee9945885' ), - array( '_\\9C5;Sy-0)LdW[,NAAU7', 'c01a00203768a32c' ), - array( '"}7jD^t,\\80', 'f83a6970b348b383' ), - array( ' _{e\\N6#|2Nb~7y/6orUrq', '26006911a7c5d137' ), - array( 'l]6LRC)jS*KPo)~&,{9Z^9', 'd848d0547a41bac1' ), - array( 'rXH)I;^<.KyExMh"9=-em|', 'ad7ca21d760bab1f' ), - array( 'nl$zh>UHWH" RL<1hJ]coV', '87be1c6aab3568a9' ), - array( '2XYKuf1cd Qhz;\'Qc^zf^M', 'fcb5e375b267b232' ), - array( '3z_|F>`6usoP?e8QJ|R{fM7', 'd6cd721ef468a686' ), - array( 'm {Mzc-Iv(*tOIVe@JVpj=*', '5ea4e77a701e1fd9' ), - array( 'O7fR|<39XmSsb;K>P9ymY', 'a30084c8ebfe7959' ), - array( '5sl-b@H)T7d>,@^v6r;crU', 'ef8377919e2a1bad' ), - array( 'o', '99a9a1a21c2ee2ec' ), - array( '31FOsL%pG%Yz}CQnMH\'`tWY`5r+i', '887cd200603d7a11' ), - array( 'BJZV["&PN+Bv1{q0@C~mk\'Oa_*Bt|', 'faad097477f65bd7' ), - array( 'N_@x:wU=}&l*IcI2_;#$T]j3*^CqF@:WX*-Vxm', '05994a3217bb26d8' ), - array( 'oj#WqZv;lWVp[,OF?Y&cLM%f%]q24j', '151f45373d53bd27' ), - array( '!%U$]H_UcL-;>iGm0gH7KtdP\\i.N|C', '0b91af28a642cac4' ), - array( '9}Io#(8b]|0k8NU`=fIe}t[bF8MUfJ', 'fd58c24dc342b56c' ), - array( 'y ICoML(0+%Av>pM .4Is2?OufhC*+z6GAQLfDoF\'S#jk', '97ef2b6a27cfe08b' ), - array( '@c3q]dx(b_/e3Mp?H\'gjX4Q}$w%X{pE<', '8a65a0d9c497dca7' ), - array( 'TY/3>(;"hJg{wYvS/|1]-|#r3-E0S&lj$Db#m>}<', 'b3fb4982abc0e4c0' ), - array( 'e(\'l!/C?-T|:Q -d.SuaZcM^)1bvOa36i', '031098cfb4e50d1f' ), - array( ';$jKG+X{(sN)"48U+z1oHoxYSo*5$@ ?D', 'd2ee11dc187ad41e' ), - array( 'kjlvDi 89*:MBpY="IfrB@G3J\\7k\\W1HB', 'fee80db84822febc' ), - array( '}@gh@ "K:Pm,*,.Tr"w4I+_\'CKcz]->\\N', '849ddd5ac8830991' ), - array( '&En&G;Aw*M#6\\W*_O?)[~0~Kty)#9eQ?+A', '58f765bdd716e1c2' ), - array( 'FS\\hLf6O}s\')SWH]3Hn3sc.|gGc:go[/C9', '1ef7be10e1e94525' ), - array( 'wo!/@ #H)W R54z$GnhVlP}QkfAGueamVc', 'fb192bd95f5f88b2' ), - array( '|vc!?mX?@mT-\\8Yj&5TeLxZZLB=T3MK>', '9207d0b883378aaa' ), - array( '/%JBFoOM n[]\'5H-K}swvORCqpx%>EDNKnp', '34c18ad3e2030b27' ), - array( 'q_A@_0{>82gF]e:V]j*!\\zza:@&hkuZ^U{ ', 'ff47e63839babc22' ), - array( '6,|UD/=jm$&DapOcNJ^0e 7Nl.*Ld&Lz3IP', '8fc04f6e48534104' ), - array( 'WYnCGrJlT<<8jgw{Mx4|eB\'2\'._#A)SybC>+', '444cf38629f9f5e6' ), - array( '6hxk&5$p}|lKu!I\\DQoK_ON!X#{Y@$B~\\zte{:`St.\'cu\'fL+1I\'q9p{%/V', '1a0c38f41c1826e8' ), - array( 'E4yEpu:WqU8FJGM/=Uvja(4hyMYvSiNx}H>o?YH', '75024234e0476c05' ), - array( '2/`XZ(\'jF\\a1?iF(dtb\\HM+BLTaOm#EP`n}l1JBsg70M>[t~bDfU;-)DqGt_K', 'bda836f33c0092dc' ), - array( ':1-)0y;ZlYfa:2|K?&\\:B7V', '16e6a228513a03c4' ), - array( 'QZ+qL}m3oM?Ibf1!Tjh6&z4R;;/V]F-0"8#O6pc\'', 'd272ca04df7d0554' ), - array( '?#P"jb$?MlVThj\'%&6[d]it`#w19itA)wr,bU1##', 'c1b2b80d012bdf50' ), - array( '}ZXgE_lLvI1T3\'67 GQis*G', '166ff835024396df' ), - array( 'n&:O=pqGrBsQ^g2J>RJ=_0c[ i->]8eL?!|\\qo$e3', 'bd73d9e41ae5c6d8' ), - array( 'w7q_J<~|g=]w!9wjF7I^}v}~s[pc_VvXnh9:&87mV', '81bed0679537a583' ), - array( 'ueW/^CUul5tc4sXoe6e {]:R', '01e47424ff38f337' ), - array( 'C}P)IHP3V]|bI!BQx[rOaUO*+f&bvz!:yQDCzuVRTT', '55e116dfbdeaffb3' ), - array( '5}VWPO4D vzO!&7(h.#jI|=nA8dxj9M 8$XhTm.Td)', '5ccd76496410ea5e' ), - array( '%f0', '42c09c31678d6f41' ), - array( '+nZLj`!dUNmXe}4Yz@zfb|[dk^+#urB!a|NM^P25 !m', '7c2bc1c66d9f0223' ), - array( 'e~#?zD:a\'8=l${w(qkKsNIC{(s/=t0,Z0/z+T6l\\N+I', '8b024f00082671f5' ), - array( 'S\'B\\y/(n]Q3ZY(jv|{$W,3S8hi&E91ol92I3BR# $6[', 'f90f149aea3b4fff' ), - array( ']?FU`,@EZc],)yt*t|QFB*)4([ZJw-(P[I-[b\\-A}}aM/GV&kl%+w/? jyJc(', '7a9e26e4aeb98fc9' ), - array( 'R5c|B@_~N"}McK\\,#cxpi%hxDhd?3HHf^,c!MD!{F I+', '4f0136432df156d5' ), - array( 'L\'8Oj1@U6)N[r4z\'\\Cm;PR=}v?z>?EIkLa;8s\\m+f=fZ', 'c2587023e1d5b660' ), - array( 'Qaa/&PKV#iTz)P9Huc4CFP\\:-KEth,O;n1JtavKe`!ai', '50683e95eabc367d' ), - array( 'R{2H_Fl\'vIA%tgy^tJyd\\EY><&%}(fgZby#CApJ8:l>0U', 'f16422882c0082cc' ), - array( '9nJci0@/i_LoeJxL2S0-WTNH gbl&rC?bn$L~E[h%)YkS', 'b8c4873ffdaf0fac' ), - array( 'R8f\'Is^}C\'}+jk2^/QA}Vm|{If"SAm\'t\'m{PbZO&bN2M:', '948738b38e532172' ), - array( 'D,JvNIMcU2', 'f0fa521206e1c67b' ), - array( '0y(aIa*~F_#HY~f+fu^4@)Ot>B!P$HK:B:jk13?(bqGG^hEVCk\'#:E)y K):+89Pt7~8 BTfzs.Y\\T0 ', 'a4dcad2a3d27a8c5' ), - array( '@8#[^-U_Y^ydw45lL5%LXZ3SNB.,v?,8X0t7>Jvw*q\\"\'rn', '5fce337a1b15535d' ), - array( 'S)t aO46}VD*Nd7g=H\\Uf\'M^2?;4F/$y8xzzH/1GfVR5;j}', 'd650a004f4a4a934' ), - array( 'X3Z.yb[Xt{t*C$.>=\'98PHJx0!KF<6DuI~%Dba|X^rb"wp@5', '26f61f52e18a413f' ), - array( 'xYNI#xB4ynZ7& .P 3tbtr;Te}V^nwshRC2VQazW@J7&;x~ycSgnG\'\\6~jP/ \'f\'G395q', 'b52ab992b89a25eb' ), - array( 'wni%9(@3(:v["e#*B:)-j8-r 5:4OO&G?oLXxll!(c]*Ja4l{', '05178f3f6d1bd723' ), - array( '>zgV)ZW?tknEq6dbb>[P+]Xoh6]', '2d02887219c5f7ba' ), - array( 'Efi$@Y@$s?||:4!}$/q%M.', '7402cada54c164fc' ), - array( 'P*^."grN1A085Z)-DSF3s~ 0r!Nd\'{sW&Rf);ZWL{hd2Cn?hBf', '7d506df1306b7bd3' ), - array( '|6e|GY~v?\'s3^zeE%"!\\N|F40j#OSE7Q\\|N%VN{vUo*5jpZor\\', '2f6a27e5596405bc' ), - array( 'MBYtVj_Y:4 Qe]O5b\'d_};O)P;y,,mhZ0COf.0AIEB{, KBcS\'', '584088c026129ecb' ), - array( 'CRCr[s/V ;EivU-F=;W_e|"a*".LeaT*5w|pk-HlImW@Ddga!?', '52d26109c3976242' ), - array( 'Bf=DIGGWt.:I8OA6@.ChzmWR.{8v^:7!!TEJ|m#q{=;5l]K.kow', '0664b26c38a5d953' ), - array( 'g]O;lKSc*mz+oPQ;N@>A<[]RI;}W\'mOnL *9K^}VLxb=J4XyTw;', '614bf3c3f15ec6d4' ), - array( 'qTxD}4CV;2\'+^\'5xStv*Apl_<"96W1QIeKnd`3;|EC(%J>~~3u)', '75c7984cbfee5c09' ), - array( 'Ugv5$xN;P`mzF9j,y}HvDk I7>H6Q??((6=-0lH`M7\\tPG!KFIC', '08249b54b4e80e4a' ), - array( 'j6C5Mb^d5~%=\'<[5LH].vtkkF3mrZ86FNZ[|=;bR:gpB$LWQu6`', 'd86b2b1dc38a51fe' ), - array( 'l,LYR_GF;_\\a/8=-VYo*sXz7\\Hn/>%o+1kwP9[vOw', 'af6317fd2ec74937' ), - array( 'cS!+[7nnxu?o^qXqJb\\LZakFY=_54/.xc/%?Gs/@iN1H@j;kNw9)Z%', '176ecfc36ff0fb5e' ), - array( 'O4B0JW@XP$hUC1IRR4"d\\BOw/~pH(KMX`ph,H)ex-OOQ`x%4.\'xkJI', '2e7bda1a61ef9b56' ), - array( 'cYHU#Q"P*bBroj|Uc+%4]f-c{hQq[JO6[%D$', '62a5e1665612c6c0' ), - array( '*jnc]YX*)eN\' qjh!(g?p:2LdacAf)Fqt6URp.]yt-!t~l] tF@faR4', '547b12c39bb0fdf3' ), - array( 'G4wh{"0mvFCI7R(1G53=4 {5tBV\\%)pL>h6:jF)blM,% 57HJJe_Jau', 'c22639e2811d6816' ), - array( '@%L|*VnWtWm0C49\'"f4\'fI>0tiuU4XKU]xShOB@Ez.U?CnFFUZM=%lM', '37b9a926337766d3' ), - array( 'yVDOk|{BZtuDE9dj4s@S80z^fV-%[zRUQw&>t"`PwWt=pZ)%NJYgZUF', 'cc6ba46fb041513c' ), - array( 'B,TGgOz>"rD@gG"9?Y/]JigP92+!m`H0m|XUMStOF9o/`qH!KX^vBFG', 'a4c997dd620f2ff9' ), - array( '\\YS^H4(Y"&2XSeM#,gs**aQR>+&|S;%-=,?v_&Db2-VNV=4!P', 'a07bd8ec425f5a4f' ), - array( 'S+[5\\.Sh4Q=PWKnckeCq+\'%8^Tn|hpM={)RY8\'CMX`}1,luxR:j^Aov!', '84b7e4acb0c0a79a' ), - array( 'Df}.WLKTV~/o&R=^3;p@)f9[!%;Cu2E:yCIRpu\'Ht68ziVZ|qL>z3WW5', 'e0f646c8b28fd049' ), - array( ']rYS&~n!C8S5/[]%rv!\\M[Z@)x<g+#b,Fb!`dSIB_R*ex/=4e%8JO,9LqX4|\\v*#Z+d?', 'd416e24b2f0208f8' ), - array( '^.b?`m&Z|DncI(.y4HG\'"[%^S/b/;GOzU3:7!Ar~eac0iq*~;Q\'=.,|b;', '3927892869e71809' ), - array( '_qW(AR^UmvV/iVtL:&7-06Hb>fqJdTfEG>Miq,?_#vomMe:hkQu|h?_\'\'', '6642fa162be3f787' ), - array( 'RQk\'91OW^9IkX*oOz]}`xfLJ]I3}*;%]mpd\'"5^aN)M(4>X/{Vpu>=@|g', 'bc2d4f3aa4d38015' ), - array( 'Tzro P]q6esKDVzN%#cC[r@3c6R"WOj,K]|K/[=EA2qfil5npy3LlT_Qj', 'f8e6d9128469532b' ), - array( '2SCb?P.|MZ-*xSK,E3u3He$BxQ0N1b9D6]\'U.6S[p`fi52uZElnnRs2LE', '7277ce5e05c03037' ), - array( 'CzW&5{=r$s!;H],*Dv?Wmz}Zim-] Z$DU[KjXh]\\\\_w&>%0b{O;iJ9E5\'S', 'f52c0085314b0fd8' ), - array( 'r(.wMcSxN,a-i?maF,gVnd&+NQDtfLHZUVR#:&|i3_v| e_FqG|`,$k[U1', '69e03fdc5e6ef8b3' ), - array( 'P=^xx4PK8jR6TeuLcu2C<%j9ew>RStd%2D}+YNWr:+)oq~=UtPx1UdK<\\i', 'ad82f3fd37f369cc' ), - array( 'o0^U5qy4|ScUF~`OnRN-)D]"V3g"PDl@ULuk>o 3eR{', 'a0a8ea76841101cb' ), - array( 'h#@VDv#;bB,c_PHR<-\'W`/BA@R`T83P"7pX\\h\\wK~$/_TX2qe:IGIlhi?I', 'cc3c875a245445bb' ), - array( '>X]n[t`4QIqJuqN%Q$^cuD}@kH.U2M Q\']@bS"w&KiPA[~G.$&rzKq<8:Jn', '36b37774404085a2' ), - array( 'Mxn~ M?c!B[\'mFX0#XX1\\_%W,vtD2?4_8#^9P}|RAYZ0!3@$ky6HYEBjP=9C', 'a93c088a44fbfc35' ), - array( 'L]B!9a\\DE{8~ r!)m\'G+C;oaa3M3QfV}Ex _[\\%"Y>!Z1#c *+,MG|0)0^<', '4c23bc673f998d50' ), - array( 'bEs`kmaLI?RKxpMT"P8#[D/)k,:u=x2!?&a,tDX>c+j]|82~iK"Eo2O\\?iR', '68fc83d0d7fbfe26' ), - array( '\\ce]$k@0aei Iuk\'r$:qnet4V(d3GOf%3Lb79$Gzi2{4(gcotkU)3', '1154a4047a591047' ), - array( '%o88={PV!xQk+M 35=/"t}]3aN(M$2a)"zB?vrvxkHdwvd,-#<0w:n+{=4JB', '4241c775b22008a8' ), - array( 'F-LI(oi b`xO*]H"CT0Fp@>,/J)M^Sp&a>Oi.:iq{bB\'@j)d@9+2ZJ>itG8T', 'd8a203d84a6e0ad0' ), - array( '{)[]G+GVF2HBtjI6USzvm\')HRG2HnK|kTXI|dqS,${Nygx0>M,5;4>cffv/V', '71228d8490cbb004' ), - array( 'B-BwfkuK]IXbF\'\\/!mMNybi/"NuhE&@g3b`yOVF.! pH(MW);&X6iCEkqqH0a', '370b9a8e5a2329eb' ), + array( '*fSR/', 'f78a85007841cb19' ), + array( '3;$tS', '94b935103cc08938' ), + array( ' \'7AS}', 'd81e3aef0fde6ad8' ), + array( 'ou9vPc', '549f05284ed347f7' ), + array( ':u]S4O', '31b0206c95a52e7d' ), + array( '{D2\',e', '3a68240ea9539e62' ), + array( 'Y;yt@n', 'afdae733c98065a2' ), + array( 'IAu`bI_', 'c311eb3e8f9f51c4' ), + array( 'R@xIq]d', '3fa1984555c55e46' ), + array( 'g;8{k5@', '9e9c5e80cdc3d58e' ), + array( '}vD&MVMJ', '1f4fd77c72b6004b' ), + array( 'd//546~,-$', '159ef268adc718d9' ), + array( '4~.{E/s*p6', '31a60e2db942bc67' ), + array( 'F#&dyJkG!:q', '33b8c68aed55c285' ), + array( 'eI"{^9zjG ', 'b42c013a2028584a' ), + array( 'F/|k>pv/(=3', '671c9537b41d76fe' ), + array( '.#-XoUZ*HAT', '84e0630a952577f4' ), + array( 'K>4d:~-: SI', '57deb72cc24c6bad' ), + array( '|@hn8xvV,%Y:', '157fda2502fe1297' ), + array( '^Jp:T9\\*ez>K', 'f784c17d1a2d1bd2' ), + array( '5>XP>-z^K\\JTT', 'dd737d6771e9cd69' ), + array( 'P>vGAoX"qP]3s', '0375e65060074988' ), + array( 'Nrooqy-.Q.Upm', '135d77993c647f43' ), + array( '"M8W"huy18ij:', 'aedeb2565e1c29f7' ), + array( '\\;wo0Gb!8UzEc', '59ae633a0b17a945' ), + array( 'LS:=B0\\7 l^cmw:', 'f21c8cb206540a2e' ), + array( 'h=}6q8T4U@nJ/3', 'b258eae8a4671c77' ), + array( '6wi:L*Y\\gp]UPB', 'bff5f2c9ed84bce5' ), + array( 'CH\\-fZDXsxlJ9\\', '298d4e05d5a47c45' ), + array( 'uIp,BZFne!KMr*#', '8641dfc04c9fb552' ), + array( 'CLGl)USdy-Yry$-', '3ab1497c481f22ab' ), + array( 'WyVH\'y#NhhO57B?', '8dea1d032c597f60' ), + array( ';fkbSt8(Z264&09', '4b875649e7cfa1a9' ), + array( '4g3k1:e4iN}9c6[', 'd33acc8fe01b77fd' ), + array( '$QBo4veM @`6UgGn', 'c4b17749dca1aa6a' ), + array( '{0#gA>MV(|TAaj}e', '067ae9cfff2cd6ea' ), + array( '=AVR8< 9]aO3Iw#E', '02bad50d48a8e564' ), + array( '(&-JD[!LYVm)kd2', '9f7776edcdaf2937' ), + array( 'qq]6N_c)7REY?H:M"', '1899eee357e747b4' ), + array( 'Mtx`VNVg7uq#Z%uMc', '8eb7e5a4bb9fb739' ), + array( '-{Cp%ZCK5ctO2v}\'p', '58ebf399369565ce' ), + array( '^^@6GW,9[f?Q4#^1G', '76ab1ea61d68a738' ), + array( 'P7#tb9XWhjOgrAGQa', '29294a2d4b758119' ), + array( ']x9i3uPSGeW\'v~W.#L', '508d3356f8ec886b' ), + array( 'p<&I&pxmd:57{r06\\D', '4660b5543de2afdc' ), + array( ',.wTsO[jO4xSajog4u', '6d85fca5fba07683' ), + array( 'Y.c?HyVElg\\J,hY%>N', '01e82905c1f66c8f' ), + array( 'Uy:&/4Yq~IZ4@5B%Tk', 'a05cc808b297050e' ), + array( '~+1lrm8 Wr&uA[p[a!o', '22783c7a8fbe4826' ), + array( 'aFyS#\\TsxGc_uhf', 'a8cfc6804bc24e1d' ), + array( 'X0rpD~5iwL|*dh/#KU|', '17b538fc3a531c98' ), + array( '~YZSMS{14qzzK,n=PmR', '47a7dd2be021ae55' ), + array( ':f 8pd!!hMWeL1A!^u|p', '4c9d34c81b647804' ), + array( '*ol&`_h', '25484f299d38dc95' ), + array( 'DmMn{K+oKILw?oqGTl/0', '8ecc9d0f58ead225' ), + array( 'eguN-bTLC55h$cX!0cq[', 'b3e4439d186da97b' ), + array( '.?TN/Fvd4&uznlJ{O~Is5', '983efebee9945885' ), + array( '_\\9C5;Sy-0)LdW[,NAAU7', 'c01a00203768a32c' ), + array( '"}7jD^t,\\80', 'f83a6970b348b383' ), + array( ' _{e\\N6#|2Nb~7y/6orUrq', '26006911a7c5d137' ), + array( 'l]6LRC)jS*KPo)~&,{9Z^9', 'd848d0547a41bac1' ), + array( 'rXH)I;^<.KyExMh"9=-em|', 'ad7ca21d760bab1f' ), + array( 'nl$zh>UHWH" RL<1hJ]coV', '87be1c6aab3568a9' ), + array( '2XYKuf1cd Qhz;\'Qc^zf^M', 'fcb5e375b267b232' ), + array( '3z_|F>`6usoP?e8QJ|R{fM7', 'd6cd721ef468a686' ), + array( 'm {Mzc-Iv(*tOIVe@JVpj=*', '5ea4e77a701e1fd9' ), + array( 'O7fR|<39XmSsb;K>P9ymY', 'a30084c8ebfe7959' ), + array( '5sl-b@H)T7d>,@^v6r;crU', 'ef8377919e2a1bad' ), + array( 'o', '99a9a1a21c2ee2ec' ), + array( '31FOsL%pG%Yz}CQnMH\'`tWY`5r+i', '887cd200603d7a11' ), + array( 'BJZV["&PN+Bv1{q0@C~mk\'Oa_*Bt|', 'faad097477f65bd7' ), + array( 'N_@x:wU=}&l*IcI2_;#$T]j3*^CqF@:WX*-Vxm', '05994a3217bb26d8' ), + array( 'oj#WqZv;lWVp[,OF?Y&cLM%f%]q24j', '151f45373d53bd27' ), + array( '!%U$]H_UcL-;>iGm0gH7KtdP\\i.N|C', '0b91af28a642cac4' ), + array( '9}Io#(8b]|0k8NU`=fIe}t[bF8MUfJ', 'fd58c24dc342b56c' ), + array( 'y ICoML(0+%Av>pM .4Is2?OufhC*+z6GAQLfDoF\'S#jk', '97ef2b6a27cfe08b' ), + array( '@c3q]dx(b_/e3Mp?H\'gjX4Q}$w%X{pE<', '8a65a0d9c497dca7' ), + array( 'TY/3>(;"hJg{wYvS/|1]-|#r3-E0S&lj$Db#m>}<', 'b3fb4982abc0e4c0' ), + array( 'e(\'l!/C?-T|:Q -d.SuaZcM^)1bvOa36i', '031098cfb4e50d1f' ), + array( ';$jKG+X{(sN)"48U+z1oHoxYSo*5$@ ?D', 'd2ee11dc187ad41e' ), + array( 'kjlvDi 89*:MBpY="IfrB@G3J\\7k\\W1HB', 'fee80db84822febc' ), + array( '}@gh@ "K:Pm,*,.Tr"w4I+_\'CKcz]->\\N', '849ddd5ac8830991' ), + array( '&En&G;Aw*M#6\\W*_O?)[~0~Kty)#9eQ?+A', '58f765bdd716e1c2' ), + array( 'FS\\hLf6O}s\')SWH]3Hn3sc.|gGc:go[/C9', '1ef7be10e1e94525' ), + array( 'wo!/@ #H)W R54z$GnhVlP}QkfAGueamVc', 'fb192bd95f5f88b2' ), + array( '|vc!?mX?@mT-\\8Yj&5TeLxZZLB=T3MK>', '9207d0b883378aaa' ), + array( '/%JBFoOM n[]\'5H-K}swvORCqpx%>EDNKnp', '34c18ad3e2030b27' ), + array( 'q_A@_0{>82gF]e:V]j*!\\zza:@&hkuZ^U{ ', 'ff47e63839babc22' ), + array( '6,|UD/=jm$&DapOcNJ^0e 7Nl.*Ld&Lz3IP', '8fc04f6e48534104' ), + array( 'WYnCGrJlT<<8jgw{Mx4|eB\'2\'._#A)SybC>+', '444cf38629f9f5e6' ), + array( '6hxk&5$p}|lKu!I\\DQoK_ON!X#{Y@$B~\\zte{:`St.\'cu\'fL+1I\'q9p{%/V', '1a0c38f41c1826e8' ), + array( 'E4yEpu:WqU8FJGM/=Uvja(4hyMYvSiNx}H>o?YH', '75024234e0476c05' ), + array( '2/`XZ(\'jF\\a1?iF(dtb\\HM+BLTaOm#EP`n}l1JBsg70M>[t~bDfU;-)DqGt_K', 'bda836f33c0092dc' ), + array( ':1-)0y;ZlYfa:2|K?&\\:B7V', '16e6a228513a03c4' ), + array( 'QZ+qL}m3oM?Ibf1!Tjh6&z4R;;/V]F-0"8#O6pc\'', 'd272ca04df7d0554' ), + array( '?#P"jb$?MlVThj\'%&6[d]it`#w19itA)wr,bU1##', 'c1b2b80d012bdf50' ), + array( '}ZXgE_lLvI1T3\'67 GQis*G', '166ff835024396df' ), + array( 'n&:O=pqGrBsQ^g2J>RJ=_0c[ i->]8eL?!|\\qo$e3', 'bd73d9e41ae5c6d8' ), + array( 'w7q_J<~|g=]w!9wjF7I^}v}~s[pc_VvXnh9:&87mV', '81bed0679537a583' ), + array( 'ueW/^CUul5tc4sXoe6e {]:R', '01e47424ff38f337' ), + array( 'C}P)IHP3V]|bI!BQx[rOaUO*+f&bvz!:yQDCzuVRTT', '55e116dfbdeaffb3' ), + array( '5}VWPO4D vzO!&7(h.#jI|=nA8dxj9M 8$XhTm.Td)', '5ccd76496410ea5e' ), + array( '%f0', '42c09c31678d6f41' ), + array( '+nZLj`!dUNmXe}4Yz@zfb|[dk^+#urB!a|NM^P25 !m', '7c2bc1c66d9f0223' ), + array( 'e~#?zD:a\'8=l${w(qkKsNIC{(s/=t0,Z0/z+T6l\\N+I', '8b024f00082671f5' ), + array( 'S\'B\\y/(n]Q3ZY(jv|{$W,3S8hi&E91ol92I3BR# $6[', 'f90f149aea3b4fff' ), + array( ']?FU`,@EZc],)yt*t|QFB*)4([ZJw-(P[I-[b\\-A}}aM/GV&kl%+w/? jyJc(', '7a9e26e4aeb98fc9' ), + array( 'R5c|B@_~N"}McK\\,#cxpi%hxDhd?3HHf^,c!MD!{F I+', '4f0136432df156d5' ), + array( 'L\'8Oj1@U6)N[r4z\'\\Cm;PR=}v?z>?EIkLa;8s\\m+f=fZ', 'c2587023e1d5b660' ), + array( 'Qaa/&PKV#iTz)P9Huc4CFP\\:-KEth,O;n1JtavKe`!ai', '50683e95eabc367d' ), + array( 'R{2H_Fl\'vIA%tgy^tJyd\\EY><&%}(fgZby#CApJ8:l>0U', 'f16422882c0082cc' ), + array( '9nJci0@/i_LoeJxL2S0-WTNH gbl&rC?bn$L~E[h%)YkS', 'b8c4873ffdaf0fac' ), + array( 'R8f\'Is^}C\'}+jk2^/QA}Vm|{If"SAm\'t\'m{PbZO&bN2M:', '948738b38e532172' ), + array( 'D,JvNIMcU2', 'f0fa521206e1c67b' ), + array( '0y(aIa*~F_#HY~f+fu^4@)Ot>B!P$HK:B:jk13?(bqGG^hEVCk\'#:E)y K):+89Pt7~8 BTfzs.Y\\T0 ', 'a4dcad2a3d27a8c5' ), + array( '@8#[^-U_Y^ydw45lL5%LXZ3SNB.,v?,8X0t7>Jvw*q\\"\'rn', '5fce337a1b15535d' ), + array( 'S)t aO46}VD*Nd7g=H\\Uf\'M^2?;4F/$y8xzzH/1GfVR5;j}', 'd650a004f4a4a934' ), + array( 'X3Z.yb[Xt{t*C$.>=\'98PHJx0!KF<6DuI~%Dba|X^rb"wp@5', '26f61f52e18a413f' ), + array( 'xYNI#xB4ynZ7& .P 3tbtr;Te}V^nwshRC2VQazW@J7&;x~ycSgnG\'\\6~jP/ \'f\'G395q', 'b52ab992b89a25eb' ), + array( 'wni%9(@3(:v["e#*B:)-j8-r 5:4OO&G?oLXxll!(c]*Ja4l{', '05178f3f6d1bd723' ), + array( '>zgV)ZW?tknEq6dbb>[P+]Xoh6]', '2d02887219c5f7ba' ), + array( 'Efi$@Y@$s?||:4!}$/q%M.', '7402cada54c164fc' ), + array( 'P*^."grN1A085Z)-DSF3s~ 0r!Nd\'{sW&Rf);ZWL{hd2Cn?hBf', '7d506df1306b7bd3' ), + array( '|6e|GY~v?\'s3^zeE%"!\\N|F40j#OSE7Q\\|N%VN{vUo*5jpZor\\', '2f6a27e5596405bc' ), + array( 'MBYtVj_Y:4 Qe]O5b\'d_};O)P;y,,mhZ0COf.0AIEB{, KBcS\'', '584088c026129ecb' ), + array( 'CRCr[s/V ;EivU-F=;W_e|"a*".LeaT*5w|pk-HlImW@Ddga!?', '52d26109c3976242' ), + array( 'Bf=DIGGWt.:I8OA6@.ChzmWR.{8v^:7!!TEJ|m#q{=;5l]K.kow', '0664b26c38a5d953' ), + array( 'g]O;lKSc*mz+oPQ;N@>A<[]RI;}W\'mOnL *9K^}VLxb=J4XyTw;', '614bf3c3f15ec6d4' ), + array( 'qTxD}4CV;2\'+^\'5xStv*Apl_<"96W1QIeKnd`3;|EC(%J>~~3u)', '75c7984cbfee5c09' ), + array( 'Ugv5$xN;P`mzF9j,y}HvDk I7>H6Q??((6=-0lH`M7\\tPG!KFIC', '08249b54b4e80e4a' ), + array( 'j6C5Mb^d5~%=\'<[5LH].vtkkF3mrZ86FNZ[|=;bR:gpB$LWQu6`', 'd86b2b1dc38a51fe' ), + array( 'l,LYR_GF;_\\a/8=-VYo*sXz7\\Hn/>%o+1kwP9[vOw', 'af6317fd2ec74937' ), + array( 'cS!+[7nnxu?o^qXqJb\\LZakFY=_54/.xc/%?Gs/@iN1H@j;kNw9)Z%', '176ecfc36ff0fb5e' ), + array( 'O4B0JW@XP$hUC1IRR4"d\\BOw/~pH(KMX`ph,H)ex-OOQ`x%4.\'xkJI', '2e7bda1a61ef9b56' ), + array( 'cYHU#Q"P*bBroj|Uc+%4]f-c{hQq[JO6[%D$', '62a5e1665612c6c0' ), + array( '*jnc]YX*)eN\' qjh!(g?p:2LdacAf)Fqt6URp.]yt-!t~l] tF@faR4', '547b12c39bb0fdf3' ), + array( 'G4wh{"0mvFCI7R(1G53=4 {5tBV\\%)pL>h6:jF)blM,% 57HJJe_Jau', 'c22639e2811d6816' ), + array( '@%L|*VnWtWm0C49\'"f4\'fI>0tiuU4XKU]xShOB@Ez.U?CnFFUZM=%lM', '37b9a926337766d3' ), + array( 'yVDOk|{BZtuDE9dj4s@S80z^fV-%[zRUQw&>t"`PwWt=pZ)%NJYgZUF', 'cc6ba46fb041513c' ), + array( 'B,TGgOz>"rD@gG"9?Y/]JigP92+!m`H0m|XUMStOF9o/`qH!KX^vBFG', 'a4c997dd620f2ff9' ), + array( '\\YS^H4(Y"&2XSeM#,gs**aQR>+&|S;%-=,?v_&Db2-VNV=4!P', 'a07bd8ec425f5a4f' ), + array( 'S+[5\\.Sh4Q=PWKnckeCq+\'%8^Tn|hpM={)RY8\'CMX`}1,luxR:j^Aov!', '84b7e4acb0c0a79a' ), + array( 'Df}.WLKTV~/o&R=^3;p@)f9[!%;Cu2E:yCIRpu\'Ht68ziVZ|qL>z3WW5', 'e0f646c8b28fd049' ), + array( ']rYS&~n!C8S5/[]%rv!\\M[Z@)x<g+#b,Fb!`dSIB_R*ex/=4e%8JO,9LqX4|\\v*#Z+d?', 'd416e24b2f0208f8' ), + array( '^.b?`m&Z|DncI(.y4HG\'"[%^S/b/;GOzU3:7!Ar~eac0iq*~;Q\'=.,|b;', '3927892869e71809' ), + array( '_qW(AR^UmvV/iVtL:&7-06Hb>fqJdTfEG>Miq,?_#vomMe:hkQu|h?_\'\'', '6642fa162be3f787' ), + array( 'RQk\'91OW^9IkX*oOz]}`xfLJ]I3}*;%]mpd\'"5^aN)M(4>X/{Vpu>=@|g', 'bc2d4f3aa4d38015' ), + array( 'Tzro P]q6esKDVzN%#cC[r@3c6R"WOj,K]|K/[=EA2qfil5npy3LlT_Qj', 'f8e6d9128469532b' ), + array( '2SCb?P.|MZ-*xSK,E3u3He$BxQ0N1b9D6]\'U.6S[p`fi52uZElnnRs2LE', '7277ce5e05c03037' ), + array( 'CzW&5{=r$s!;H],*Dv?Wmz}Zim-] Z$DU[KjXh]\\\\_w&>%0b{O;iJ9E5\'S', 'f52c0085314b0fd8' ), + array( 'r(.wMcSxN,a-i?maF,gVnd&+NQDtfLHZUVR#:&|i3_v| e_FqG|`,$k[U1', '69e03fdc5e6ef8b3' ), + array( 'P=^xx4PK8jR6TeuLcu2C<%j9ew>RStd%2D}+YNWr:+)oq~=UtPx1UdK<\\i', 'ad82f3fd37f369cc' ), + array( 'o0^U5qy4|ScUF~`OnRN-)D]"V3g"PDl@ULuk>o 3eR{', 'a0a8ea76841101cb' ), + array( 'h#@VDv#;bB,c_PHR<-\'W`/BA@R`T83P"7pX\\h\\wK~$/_TX2qe:IGIlhi?I', 'cc3c875a245445bb' ), + array( '>X]n[t`4QIqJuqN%Q$^cuD}@kH.U2M Q\']@bS"w&KiPA[~G.$&rzKq<8:Jn', '36b37774404085a2' ), + array( 'Mxn~ M?c!B[\'mFX0#XX1\\_%W,vtD2?4_8#^9P}|RAYZ0!3@$ky6HYEBjP=9C', 'a93c088a44fbfc35' ), + array( 'L]B!9a\\DE{8~ r!)m\'G+C;oaa3M3QfV}Ex _[\\%"Y>!Z1#c *+,MG|0)0^<', '4c23bc673f998d50' ), + array( 'bEs`kmaLI?RKxpMT"P8#[D/)k,:u=x2!?&a,tDX>c+j]|82~iK"Eo2O\\?iR', '68fc83d0d7fbfe26' ), + array( '\\ce]$k@0aei Iuk\'r$:qnet4V(d3GOf%3Lb79$Gzi2{4(gcotkU)3', '1154a4047a591047' ), + array( '%o88={PV!xQk+M 35=/"t}]3aN(M$2a)"zB?vrvxkHdwvd,-#<0w:n+{=4JB', '4241c775b22008a8' ), + array( 'F-LI(oi b`xO*]H"CT0Fp@>,/J)M^Sp&a>Oi.:iq{bB\'@j)d@9+2ZJ>itG8T', 'd8a203d84a6e0ad0' ), + array( '{)[]G+GVF2HBtjI6USzvm\')HRG2HnK|kTXI|dqS,${Nygx0>M,5;4>cffv/V', '71228d8490cbb004' ), + array( 'B-BwfkuK]IXbF\'\\/!mMNybi/"NuhE&@g3b`yOVF.! pH(MW);&X6iCEkq --EXPECT-- diff --git a/ext/hash/tests/hash-clone.phpt b/ext/hash/tests/hash-clone.phpt index d5d4205354df..0ef0df444996 100644 --- a/ext/hash/tests/hash-clone.phpt +++ b/ext/hash/tests/hash-clone.phpt @@ -6,24 +6,24 @@ Hash: hash_copy() via clone $algos = hash_algos(); foreach ($algos as $algo) { - var_dump($algo); - $orig = hash_init($algo); - hash_update($orig, "I can't remember anything"); - $copy = clone $orig; - var_dump(hash_final($orig)); + var_dump($algo); + $orig = hash_init($algo); + hash_update($orig, "I can't remember anything"); + $copy = clone $orig; + var_dump(hash_final($orig)); - var_dump(hash_final($copy)); + var_dump(hash_final($copy)); } foreach ($algos as $algo) { - var_dump($algo); - $orig = hash_init($algo); - hash_update($orig, "I can't remember anything"); - $copy = clone $orig; - var_dump(hash_final($orig)); + var_dump($algo); + $orig = hash_init($algo); + hash_update($orig, "I can't remember anything"); + $copy = clone $orig; + var_dump(hash_final($orig)); - hash_update($copy, "Can’t tell if this is true or dream"); - var_dump(hash_final($copy)); + hash_update($copy, "Can’t tell if this is true or dream"); + var_dump(hash_final($copy)); } echo "Done\n"; diff --git a/ext/hash/tests/hash_copy_001.phpt b/ext/hash/tests/hash_copy_001.phpt index 8cd620e26d3f..27993b61b054 100644 --- a/ext/hash/tests/hash_copy_001.phpt +++ b/ext/hash/tests/hash_copy_001.phpt @@ -6,24 +6,24 @@ Hash: hash_copy() basic tests $algos = hash_algos(); foreach ($algos as $algo) { - var_dump($algo); - $orig = hash_init($algo); - hash_update($orig, "I can't remember anything"); - $copy = hash_copy($orig); - var_dump(hash_final($orig)); + var_dump($algo); + $orig = hash_init($algo); + hash_update($orig, "I can't remember anything"); + $copy = hash_copy($orig); + var_dump(hash_final($orig)); - var_dump(hash_final($copy)); + var_dump(hash_final($copy)); } foreach ($algos as $algo) { - var_dump($algo); - $orig = hash_init($algo); - hash_update($orig, "I can't remember anything"); - $copy = hash_copy($orig); - var_dump(hash_final($orig)); + var_dump($algo); + $orig = hash_init($algo); + hash_update($orig, "I can't remember anything"); + $copy = hash_copy($orig); + var_dump(hash_final($orig)); - hash_update($copy, "Can’t tell if this is true or dream"); - var_dump(hash_final($copy)); + hash_update($copy, "Can’t tell if this is true or dream"); + var_dump(hash_final($copy)); } echo "Done\n"; diff --git a/ext/hash/tests/hash_file_basic1.phpt b/ext/hash/tests/hash_file_basic1.phpt index 59db6961129d..df55cd483734 100644 --- a/ext/hash/tests/hash_file_basic1.phpt +++ b/ext/hash/tests/hash_file_basic1.phpt @@ -14,7 +14,7 @@ echo "*** Testing hash_file() : basic functionality ***\n"; $file = __DIR__ . "hash_file.txt"; /* Creating a temporary file file */ if (($fp = fopen( $file, "w+")) == FALSE) { - echo "Cannot create file ($file)"; + echo "Cannot create file ($file)"; exit; } diff --git a/ext/hash/tests/hash_hkdf_edges.phpt b/ext/hash/tests/hash_hkdf_edges.phpt index debd166cfda4..4a69c7c13419 100644 --- a/ext/hash/tests/hash_hkdf_edges.phpt +++ b/ext/hash/tests/hash_hkdf_edges.phpt @@ -17,7 +17,7 @@ echo 'Length % digestSize != 0: ', bin2hex(hash_hkdf('md5', $ikm, 17)), "\n"; echo 'Algo name case-sensitivity: ', (bin2hex(hash_hkdf('Md5', $ikm, 7)) === '98b16391063ece' ? 'true' : 'false'), "\n"; echo "Non-crypto algo name case-sensitivity:\n"; -try { +try { var_dump(hash_hkdf('jOaAt', $ikm)); } catch (\Error $e) { diff --git a/ext/hash/tests/hash_hkdf_rfc5869.phpt b/ext/hash/tests/hash_hkdf_rfc5869.phpt index 26a0139f89a1..63c65f0a7d9d 100644 --- a/ext/hash/tests/hash_hkdf_rfc5869.phpt +++ b/ext/hash/tests/hash_hkdf_rfc5869.phpt @@ -10,60 +10,60 @@ Hash: hash_hkdf() function: RFC 5869 test vectors echo "*** Testing hash_hkdf(): RFC 5869 test vectors ***\n"; echo "Test case 1 (SHA-256): ", - bin2hex(hash_hkdf( - 'sha256', - "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", - 42, - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9", - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c" - )), "\n"; + bin2hex(hash_hkdf( + 'sha256', + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", + 42, + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c" + )), "\n"; echo "Test case 2 (SHA-256 with longer inputs/outputs): ", - bin2hex(hash_hkdf( - 'sha256', - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f", - 82, - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - )), "\n"; + bin2hex(hash_hkdf( + 'sha256', + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f", + 82, + "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", + "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" + )), "\n"; echo "Test case 3 (SHA-256 with zero-length salt, info): ", - bin2hex(hash_hkdf( - 'sha256', - "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", - 42, - '', - '' - )), "\n"; + bin2hex(hash_hkdf( + 'sha256', + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", + 42, + '', + '' + )), "\n"; echo "Test case 4 (SHA-1): ", - bin2hex(hash_hkdf( - 'sha1', - "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", - 42, - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9", - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c" - )), "\n"; + bin2hex(hash_hkdf( + 'sha1', + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", + 42, + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9", + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c" + )), "\n"; echo "Test case 5 (SHA-1 with longer inputs/outputs): ", - bin2hex(hash_hkdf( - 'sha1', - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f", - 82, - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - )), "\n"; + bin2hex(hash_hkdf( + 'sha1', + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f", + 82, + "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", + "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" + )), "\n"; echo "Test case 6 (SHA-1 with zero-length salt, info): ", - bin2hex(hash_hkdf( - 'sha1', - "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", - 42, - '', - '' - )), "\n"; + bin2hex(hash_hkdf( + 'sha1', + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", + 42, + '', + '' + )), "\n"; echo "Test case 7 (SHA-1 with zero-length info, salt not provided): ", - bin2hex(hash_hkdf( - 'sha1', - "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", - 42, - '' - )), "\n"; + bin2hex(hash_hkdf( + 'sha1', + "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", + 42, + '' + )), "\n"; ?> --EXPECT-- *** Testing hash_hkdf(): RFC 5869 test vectors *** diff --git a/ext/hash/tests/hash_hmac_error.phpt b/ext/hash/tests/hash_hmac_error.phpt index cadbf23d1a43..3b14243fb292 100644 --- a/ext/hash/tests/hash_hmac_error.phpt +++ b/ext/hash/tests/hash_hmac_error.phpt @@ -21,7 +21,7 @@ catch (\Error $e) { } echo "\n-- Testing hash_hmac() function with non-cryptographic hash algorithm --\n"; -try { +try { var_dump(hash_hmac('crc32', $data, $key)); } catch (\Error $e) { diff --git a/ext/hash/tests/hash_hmac_file_basic.phpt b/ext/hash/tests/hash_hmac_file_basic.phpt index 32bc95fdbc5a..4569c46c3511 100644 --- a/ext/hash/tests/hash_hmac_file_basic.phpt +++ b/ext/hash/tests/hash_hmac_file_basic.phpt @@ -15,7 +15,7 @@ echo "*** Testing hash_hmac_file() : basic functionality ***\n"; $file = __DIR__ . "hash_hmac_file.txt"; /* Creating a temporary file file */ if (($fp = fopen( $file, "w+")) == FALSE) { - echo "Cannot create file ($file)"; + echo "Cannot create file ($file)"; exit; } diff --git a/ext/hash/tests/hash_hmac_file_error.phpt b/ext/hash/tests/hash_hmac_file_error.phpt index 5207b74d9dfe..f23d33569922 100644 --- a/ext/hash/tests/hash_hmac_file_error.phpt +++ b/ext/hash/tests/hash_hmac_file_error.phpt @@ -15,7 +15,7 @@ $file = __DIR__ . "hash_file.txt"; $key = 'secret'; echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n"; -try { +try { var_dump(hash_hmac_file('foo', $file, $key, TRUE)); } catch (\Error $e) { diff --git a/ext/hash/tests/hash_init_error.phpt b/ext/hash/tests/hash_init_error.phpt index a68a8fc088d0..f9d0362dd2b8 100644 --- a/ext/hash/tests/hash_init_error.phpt +++ b/ext/hash/tests/hash_init_error.phpt @@ -21,14 +21,14 @@ catch (\Error $e) { } echo "\n-- Testing hash_init() function with HASH_HMAC and no key --\n"; -try { +try { var_dump(hash_init('md5', HASH_HMAC)); } catch (\Error $e) { echo $e->getMessage() . "\n"; } -try { +try { var_dump(hash_init('md5', HASH_HMAC, null)); } catch (\Error $e) { diff --git a/ext/hash/tests/hash_pbkdf2_error.phpt b/ext/hash/tests/hash_pbkdf2_error.phpt index 02d48f1ac6d1..795dea1ce316 100644 --- a/ext/hash/tests/hash_pbkdf2_error.phpt +++ b/ext/hash/tests/hash_pbkdf2_error.phpt @@ -13,7 +13,7 @@ $password = 'password'; $salt = 'salt'; echo "\n-- Testing hash_pbkdf2() function with invalid hash algorithm --\n"; -try { +try { var_dump(hash_pbkdf2('foo', $password, $salt, 1)); } catch (\Error $e) { @@ -22,7 +22,7 @@ catch (\Error $e) { echo "\n-- Testing hash_pbkdf2() function with non-cryptographic hash algorithm --\n"; -try { +try { var_dump(hash_pbkdf2('crc32', $password, $salt, 1)); } catch (\Error $e) { @@ -30,14 +30,14 @@ catch (\Error $e) { } echo "\n-- Testing hash_pbkdf2() function with invalid iterations --\n"; -try { +try { var_dump(hash_pbkdf2('md5', $password, $salt, 0)); } catch (\Error $e) { echo $e->getMessage() . "\n"; } -try { +try { var_dump(hash_pbkdf2('md5', $password, $salt, -1)); } catch (\Error $e) { @@ -45,7 +45,7 @@ catch (\Error $e) { } echo "\n-- Testing hash_pbkdf2() function with invalid length --\n"; -try { +try { var_dump(hash_pbkdf2('md5', $password, $salt, 1, -1)); } catch (\Error $e) { diff --git a/ext/hash/tests/haval.phpt b/ext/hash/tests/haval.phpt index b01abdb8efc0..514fc7c97b26 100644 --- a/ext/hash/tests/haval.phpt +++ b/ext/hash/tests/haval.phpt @@ -4,24 +4,24 @@ Hash: haval algorithm (multi-vector, multi-pass, multi-width) $wanted) { - $result = mhash(constant($hash), $data); - if (bin2hex($result)==$wanted) { - echo "$hash\nok\n"; - } else { - echo "$hash: "; - var_dump($wanted); - echo "$hash: "; - var_dump(bin2hex($result)); - } - echo "\n"; + $result = mhash(constant($hash), $data); + if (bin2hex($result)==$wanted) { + echo "$hash\nok\n"; + } else { + echo "$hash: "; + var_dump($wanted); + echo "$hash: "; + var_dump(bin2hex($result)); + } + echo "\n"; } ?> --EXPECT-- diff --git a/ext/hash/tests/mhash_002.phpt b/ext/hash/tests/mhash_002.phpt index 231847091994..fdf886a71e70 100644 --- a/ext/hash/tests/mhash_002.phpt +++ b/ext/hash/tests/mhash_002.phpt @@ -29,16 +29,16 @@ $hc = mhash_count() + 1; $known_hash_al = array(); for ($i=0; $i < $hc; $i++) { - $known_hash_al[mhash_get_hash_name($i)] = $i; + $known_hash_al[mhash_get_hash_name($i)] = $i; } foreach ($supported_hash_al as $name => $len) { - if (array_key_exists($name, $known_hash_al)) { - $len = mhash_get_block_size($known_hash_al[$name]); - echo "$name = $len\n"; - } else { - echo "$name ? $len\n"; - } + if (array_key_exists($name, $known_hash_al)) { + $len = mhash_get_block_size($known_hash_al[$name]); + echo "$name = $len\n"; + } else { + echo "$name ? $len\n"; + } } ?> --EXPECTREGEX-- diff --git a/ext/hash/tests/mhash_003.phpt b/ext/hash/tests/mhash_003.phpt index a4d43eb8d530..99436b9ece9f 100644 --- a/ext/hash/tests/mhash_003.phpt +++ b/ext/hash/tests/mhash_003.phpt @@ -20,18 +20,18 @@ $supported_hash_al = array( ); foreach ($supported_hash_al as $hash=>$wanted) { - $passwd = str_repeat($hash, 10); - $salt = str_repeat($hash, 2); - $result = mhash_keygen_s2k(constant($hash), $passwd, $salt, 100); - if (!strcmp(bin2hex($result), $wanted)) { - echo "$hash\nok\n"; - } else { - echo "$hash: "; - var_dump($wanted); - echo "$hash: "; - var_dump(bin2hex($result)); - } - echo "\n"; + $passwd = str_repeat($hash, 10); + $salt = str_repeat($hash, 2); + $result = mhash_keygen_s2k(constant($hash), $passwd, $salt, 100); + if (!strcmp(bin2hex($result), $wanted)) { + echo "$hash\nok\n"; + } else { + echo "$hash: "; + var_dump($wanted); + echo "$hash: "; + var_dump(bin2hex($result)); + } + echo "\n"; } ?> --EXPECT-- diff --git a/ext/hash/tests/reuse.phpt b/ext/hash/tests/reuse.phpt index 54ef56f08f4c..78df4b41afea 100644 --- a/ext/hash/tests/reuse.phpt +++ b/ext/hash/tests/reuse.phpt @@ -5,7 +5,7 @@ Hash: Attempt to reuse a closed hash context $h = hash_init('md5'); hash_final($h); -try { +try { hash_update($h, 'foo'); } catch (\Error $e) { diff --git a/ext/iconv/tests/bug37773.phpt b/ext/iconv/tests/bug37773.phpt index f9a1d3470eeb..e2fb6a55e6a8 100644 --- a/ext/iconv/tests/bug37773.phpt +++ b/ext/iconv/tests/bug37773.phpt @@ -12,7 +12,7 @@ if ($test === false) { ?> --FILE-- --EXPECT-- string(1) "x" diff --git a/ext/iconv/tests/bug63839.phpt b/ext/iconv/tests/bug63839.phpt index 99d1a20cc605..e137a0cb4be4 100644 --- a/ext/iconv/tests/bug63839.phpt +++ b/ext/iconv/tests/bug63839.phpt @@ -13,7 +13,7 @@ Date: Sat, 22 Dec 2012 Message-ID: <006f01cde00e$d9f79da0$8de6d8e0> MIME-Version: 1.0 Content-Type: multipart/alternative; - boundary="----=_NextPart_000_0070_01CDE03C.F3AFD9A0" + boundary="----=_NextPart_000_0070_01CDE03C.F3AFD9A0" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac3gDtcH2huHjzYcQVmFJPPoWjJogA== Content-Language: en-us diff --git a/ext/iconv/tests/bug76249.phpt b/ext/iconv/tests/bug76249.phpt index 25bbf2a41f29..9d8a0f3e9f34 100644 --- a/ext/iconv/tests/bug76249.phpt +++ b/ext/iconv/tests/bug76249.phpt @@ -8,7 +8,7 @@ $fh = fopen('php://memory', 'rw'); fwrite($fh, "abc"); rewind($fh); if (false === @stream_filter_append($fh, 'convert.iconv.ucs-2/utf8//IGNORE', STREAM_FILTER_READ, [])) { - stream_filter_append($fh, 'convert.iconv.ucs-2/utf-8//IGNORE', STREAM_FILTER_READ, []); + stream_filter_append($fh, 'convert.iconv.ucs-2/utf-8//IGNORE', STREAM_FILTER_READ, []); } var_dump(stream_get_contents($fh)); ?> diff --git a/ext/iconv/tests/eucjp2iso2022jp.phpt b/ext/iconv/tests/eucjp2iso2022jp.phpt index 6700ac91979c..aacdc238c65c 100644 --- a/ext/iconv/tests/eucjp2iso2022jp.phpt +++ b/ext/iconv/tests/eucjp2iso2022jp.phpt @@ -9,11 +9,11 @@ error_reporting=2039 /* charset=EUC-JP */ function hexdump($str) { - $len = strlen($str); - for ($i = 0; $i < $len; ++$i) { - printf("%02x", ord($str{$i})); - } - print "\n"; + $len = strlen($str); + for ($i = 0; $i < $len; ++$i) { + printf("%02x", ord($str{$i})); + } + print "\n"; } $str = str_repeat("ÆüËÜ¸ì¥Æ¥­¥¹¥È¤È English text", 30); diff --git a/ext/iconv/tests/iconv003.phpt b/ext/iconv/tests/iconv003.phpt index 690c1569f98d..94ed39f3f6ad 100644 --- a/ext/iconv/tests/iconv003.phpt +++ b/ext/iconv/tests/iconv003.phpt @@ -5,9 +5,9 @@ iconv() test 3 --FILE-- diff --git a/ext/iconv/tests/iconv_default_charset.phpt b/ext/iconv/tests/iconv_default_charset.phpt index 4b44c1266e25..e0874820b25e 100644 --- a/ext/iconv/tests/iconv_default_charset.phpt +++ b/ext/iconv/tests/iconv_default_charset.phpt @@ -20,34 +20,34 @@ echo "*** Testing default_charset handling ***\n"; echo "--- Get php.ini values ---\n"; var_dump(ini_get('default_charset'), - ini_get('internal_encoding'), - ini_get('input_encoding'), - ini_get('output_encoding'), - ini_get('iconv.internal_encoding'), - ini_get('iconv.input_encoding'), - ini_get('iconv.output_encoding')); + ini_get('internal_encoding'), + ini_get('input_encoding'), + ini_get('output_encoding'), + ini_get('iconv.internal_encoding'), + ini_get('iconv.input_encoding'), + ini_get('iconv.output_encoding')); echo "\n--- Altering encodings ---\n"; var_dump(ini_set('default_charset', 'ISO-8859-1')); echo "\n--- results of alterations ---\n"; var_dump(ini_get('default_charset'), - ini_get('internal_encoding'), - ini_get('input_encoding'), - ini_get('output_encoding'), - ini_get('iconv.internal_encoding'), - ini_get('iconv.input_encoding'), - ini_get('iconv.output_encoding')); + ini_get('internal_encoding'), + ini_get('input_encoding'), + ini_get('output_encoding'), + ini_get('iconv.internal_encoding'), + ini_get('iconv.input_encoding'), + ini_get('iconv.output_encoding')); /* echo "\n--- Altering encodings ---\n"; var_dump(ini_set('default_charset', 'ISO-8859-1'), - ini_set('internal_encoding'), - ini_set('input_encoding'), - ini_set('output_encoding'), - ini_set('iconv.internal_encoding'), - ini_set('iconv.input_encoding'), - ini_set('iconv.output_encoding')); + ini_set('internal_encoding'), + ini_set('input_encoding'), + ini_set('output_encoding'), + ini_set('iconv.internal_encoding'), + ini_set('iconv.input_encoding'), + ini_set('iconv.output_encoding')); */ echo "Done"; diff --git a/ext/iconv/tests/iconv_mime_decode.phpt b/ext/iconv/tests/iconv_mime_decode.phpt index b5dee827dfa1..35144b5707ab 100644 --- a/ext/iconv/tests/iconv_mime_decode.phpt +++ b/ext/iconv/tests/iconv_mime_decode.phpt @@ -8,39 +8,39 @@ iconv.internal_charset=iso-8859-1 -Received: from pb1.pair.com (pb1.pair.com [16.92.131.4]) by ***.example.com +Received: from pb1.pair.com (pb1.pair.com [16.92.131.4]) by ***.example.com (8.12.10/8.12.10/1970-09-30) with SMTP id hALLmpea023899 for <***@***.example.com>; Sat, 22 Jan 1970 06:48:51 +0900 (JST) (envelope-from @@ -25,7 +25,7 @@ Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Date: Thu, 1 Jan 1970 00:00:00 -0000 (GMT) From: *** *** *** <***@***.example.com> -X-X-Sender: ***@***.example.com +X-X-Sender: ***@***.example.com To: internals@lists.php.net Message-Id: MIME-Version: 1.0 diff --git a/ext/iconv/tests/iconv_mime_encode.phpt b/ext/iconv/tests/iconv_mime_encode.phpt index e4be7999159d..6f4ba1c7a9bb 100644 --- a/ext/iconv/tests/iconv_mime_encode.phpt +++ b/ext/iconv/tests/iconv_mime_encode.phpt @@ -8,27 +8,27 @@ iconv.internal_charset=iso-8859-1 "B", - "output-charset" => "ISO-2022-JP", - "input-charset" => "EUC-JP", - "line-break-chars" => "\n" + "scheme" => "B", + "output-charset" => "ISO-2022-JP", + "input-charset" => "EUC-JP", + "line-break-chars" => "\n" ); for ($line_len= 0; $line_len < 80; ++$line_len) { - print "-------- line length=$line_len\n"; - $preference["line-length"] = $line_len; - $result = iconv_mime_encode("From", "¥µ¥ó¥×¥ëʸ»úÎó¥µ¥ó¥×¥ëʸ»úÎóÆüËÜ¸ì¥Æ¥­¥¹¥È", $preference); - var_dump($result); - if ($result !== false) { + print "-------- line length=$line_len\n"; + $preference["line-length"] = $line_len; + $result = iconv_mime_encode("From", "¥µ¥ó¥×¥ëʸ»úÎó¥µ¥ó¥×¥ëʸ»úÎóÆüËÜ¸ì¥Æ¥­¥¹¥È", $preference); + var_dump($result); + if ($result !== false) { $max = max(array_map("strlen", explode("\n", $result))); - print "-------- "; - var_dump(($max <= $line_len)); - } else { - print "-------- \n"; - } + print "-------- "; + var_dump(($max <= $line_len)); + } else { + print "-------- \n"; + } } ?> --EXPECTF-- diff --git a/ext/iconv/tests/iconv_strlen.phpt b/ext/iconv/tests/iconv_strlen.phpt index 2c815f4f310d..7984798f5778 100644 --- a/ext/iconv/tests/iconv_strlen.phpt +++ b/ext/iconv/tests/iconv_strlen.phpt @@ -5,8 +5,8 @@ iconv_strlen() --FILE-- getMessage() . "\n"; - } - if ($to_charset !== false) { - var_dump(iconv_strpos($haystk, $needle, $offset, $to_charset)); - } else { - var_dump(iconv_strpos($haystk, $needle, $offset)); - } + if ($from_charset !== false) { + $haystk = iconv($from_charset, $to_charset, $haystk); + } + try { + var_dump(strpos($haystk, $needle, $offset)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + if ($to_charset !== false) { + var_dump(iconv_strpos($haystk, $needle, $offset, $to_charset)); + } else { + var_dump(iconv_strpos($haystk, $needle, $offset)); + } } foo("abecdbcdabef", "bcd", -1); foo("abecdbcdabef", "bcd", -7); diff --git a/ext/iconv/tests/iconv_strpos_variation5.phpt b/ext/iconv/tests/iconv_strpos_variation5.phpt index 1daedd146deb..f89307b03ae9 100644 --- a/ext/iconv/tests/iconv_strpos_variation5.phpt +++ b/ext/iconv/tests/iconv_strpos_variation5.phpt @@ -35,11 +35,11 @@ $needle_mb = base64_decode('44CC'); * 60 is larger than *BYTE* count for $string_mb */ for ($i = -30; $i <= 60; $i += 10) { - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; - var_dump(iconv_strpos($string_ascii, $needle_ascii, $i)); - echo "--Multibyte String --\n"; - var_dump(iconv_strpos($string_mb, $needle_mb, $i, 'UTF-8')); + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + var_dump(iconv_strpos($string_ascii, $needle_ascii, $i)); + echo "--Multibyte String --\n"; + var_dump(iconv_strpos($string_mb, $needle_mb, $i, 'UTF-8')); } echo "Done"; diff --git a/ext/iconv/tests/iconv_strrpos.phpt b/ext/iconv/tests/iconv_strrpos.phpt index 76b8323d8989..1e5b5fb960ff 100644 --- a/ext/iconv/tests/iconv_strrpos.phpt +++ b/ext/iconv/tests/iconv_strrpos.phpt @@ -8,29 +8,29 @@ iconv.internal_charset=ISO-8859-1 --FILE-- '; + $envelope["from"] = 'Santa '; $envelope["to"] = 'The bad smurf '; $envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500'; diff --git a/ext/imap/tests/bug44098.phpt b/ext/imap/tests/bug44098.phpt index c424f05f547b..2a0f5cef44ab 100644 --- a/ext/imap/tests/bug44098.phpt +++ b/ext/imap/tests/bug44098.phpt @@ -11,9 +11,9 @@ Bug #44098 (imap_utf8() returns only capital letters) $exp = 'Luzon®14 dot CoM'; $res = imap_utf8('=?iso-8859-1?b?THV6b26uMTQ=?= dot CoM'); if ($res != $exp) { - echo "failed: got <$res>, expected \n"; + echo "failed: got <$res>, expected \n"; } else { - echo "ok"; + echo "ok"; } ?> --EXPECT-- diff --git a/ext/imap/tests/bug75774.phpt b/ext/imap/tests/bug75774.phpt index 686ffe75b85a..42f5a842c346 100644 --- a/ext/imap/tests/bug75774.phpt +++ b/ext/imap/tests/bug75774.phpt @@ -11,9 +11,9 @@ $fn = __DIR__ . DIRECTORY_SEPARATOR . "foo75774"; $var1=fopen($fn, "w"); try { - imap_append($var1, "", "", "", ""); + imap_append($var1, "", "", "", ""); } catch (Throwable $e) { - echo "\nException: " . $e->getMessage() . "\n"; + echo "\nException: " . $e->getMessage() . "\n"; } fclose($var1); diff --git a/ext/imap/tests/clean.inc b/ext/imap/tests/clean.inc index 4f381bf893b0..8bc566ba3233 100644 --- a/ext/imap/tests/clean.inc +++ b/ext/imap/tests/clean.inc @@ -6,19 +6,19 @@ $imap_stream = imap_open($default_mailbox, $username, $password); // delete all msgs in default mailbox, i.e INBOX $check = imap_check($imap_stream); for ($i = 1; $i <= $check->Nmsgs; $i++) { - imap_delete($imap_stream, $i); + imap_delete($imap_stream, $i); } $mailboxes = imap_getmailboxes($imap_stream, $server, '*'); foreach($mailboxes as $value) { - // Only delete mailboxes with our prefix - if (preg_match('/\{.*?\}INBOX\.(.+)/', $value->name, $match) == 1) { - if (strlen($match[1]) >= strlen($mailbox_prefix) - && substr_compare($match[1], $mailbox_prefix, 0, strlen($mailbox_prefix)) == 0) { - imap_deletemailbox($imap_stream, $value->name); - } - } + // Only delete mailboxes with our prefix + if (preg_match('/\{.*?\}INBOX\.(.+)/', $value->name, $match) == 1) { + if (strlen($match[1]) >= strlen($mailbox_prefix) + && substr_compare($match[1], $mailbox_prefix, 0, strlen($mailbox_prefix)) == 0) { + imap_deletemailbox($imap_stream, $value->name); + } + } } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/imap/tests/imap_append_basic.phpt b/ext/imap/tests/imap_append_basic.phpt index 499a05cc4d55..807c30c8696c 100644 --- a/ext/imap/tests/imap_append_basic.phpt +++ b/ext/imap/tests/imap_append_basic.phpt @@ -18,7 +18,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Create a new mailbox for test\n"; $imap_stream = setup_test_mailbox("", 0); if (!is_resource($imap_stream)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } $mb_details = imap_mailboxmsginfo($imap_stream); diff --git a/ext/imap/tests/imap_base64_basic.phpt b/ext/imap/tests/imap_base64_basic.phpt index a01545ceba6a..e5063f2c1c17 100644 --- a/ext/imap/tests/imap_base64_basic.phpt +++ b/ext/imap/tests/imap_base64_basic.phpt @@ -16,25 +16,25 @@ echo "*** Testing imap_base64() : basic functionality ***\n"; $str = 'This is an example string to be base 64 encoded'; $base64 = base64_encode($str); if (imap_base64($base64) == $str) { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } else { - echo "TEST FAILED"; + echo "TEST FAILED"; } $str = '!£$%^&*()_+-={][];;@~#?/>.<,'; $base64 = base64_encode($str); if (imap_base64($base64) == $str) { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } else { - echo "TEST FAILED"; + echo "TEST FAILED"; } $hex = 'x00\x01\x02\x03\x04\x05\x06\xFA\xFB\xFC\xFD\xFE\xFF'; $base64 = base64_encode($hex); if (imap_base64($base64) == $hex) { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } else { - echo "TEST FAILED"; + echo "TEST FAILED"; } ?> diff --git a/ext/imap/tests/imap_body.phpt b/ext/imap/tests/imap_body.phpt index de5f7f286c85..a4e8069d040d 100644 --- a/ext/imap/tests/imap_body.phpt +++ b/ext/imap/tests/imap_body.phpt @@ -17,7 +17,7 @@ imap_body(''); imap_body(false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_body($stream_id); imap_body($stream_id,-1); imap_body($stream_id,1,-1); diff --git a/ext/imap/tests/imap_body_basic.phpt b/ext/imap/tests/imap_body_basic.phpt index b3dcfa105e18..ecc1da3ec6b1 100644 --- a/ext/imap/tests/imap_body_basic.phpt +++ b/ext/imap/tests/imap_body_basic.phpt @@ -18,7 +18,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Create a new mailbox for test\n"; $imap_stream = setup_test_mailbox("", 1); if (!is_resource($imap_stream)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } $check = imap_check($imap_stream); diff --git a/ext/imap/tests/imap_bodystruct_basic.phpt b/ext/imap/tests/imap_bodystruct_basic.phpt index c278c4c2af9c..9504f9acab2c 100644 --- a/ext/imap/tests/imap_bodystruct_basic.phpt +++ b/ext/imap/tests/imap_bodystruct_basic.phpt @@ -17,7 +17,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Create a new mailbox for test and add a multipart msgs\n"; $imap_stream = setup_test_mailbox("", 1, $mailbox, "multipart"); if (!is_resource($imap_stream)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } echo "\nGet and validate structure of body part 1\n"; diff --git a/ext/imap/tests/imap_clearflag_full_basic.phpt b/ext/imap/tests/imap_clearflag_full_basic.phpt index 08416281ec03..3afc105d5ad7 100644 --- a/ext/imap/tests/imap_clearflag_full_basic.phpt +++ b/ext/imap/tests/imap_clearflag_full_basic.phpt @@ -18,7 +18,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Create a new mailbox for test\n"; $imap_stream = setup_test_mailbox("", 10); if (!is_resource($imap_stream)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } $check = imap_check($imap_stream); diff --git a/ext/imap/tests/imap_close_basic.phpt b/ext/imap/tests/imap_close_basic.phpt index 0eb6d74f064b..9e275aa4d068 100644 --- a/ext/imap/tests/imap_close_basic.phpt +++ b/ext/imap/tests/imap_close_basic.phpt @@ -22,7 +22,7 @@ $options = CL_EXPUNGE; // mark messages in inbox for deletion for ($i = 1; $i < 4; $i++) { - imap_delete($stream_id, $i); + imap_delete($stream_id, $i); } // Calling imap_close() with all possible arguments diff --git a/ext/imap/tests/imap_close_variation4.phpt b/ext/imap/tests/imap_close_variation4.phpt index f45d34845cb5..28a37ebb1112 100644 --- a/ext/imap/tests/imap_close_variation4.phpt +++ b/ext/imap/tests/imap_close_variation4.phpt @@ -28,33 +28,33 @@ $stream_id = setup_test_mailbox('', 3, $mailbox); // set up temp mailbox with 3 $iterator = 1; foreach($inputs as $input) { - // mark added messages for deletion - for ($i = 1; $i < 4; $i++) { - imap_delete($stream_id, $i); - } - echo "\n-- Iteration $iterator --\n"; - var_dump( $check = imap_close($stream_id, $input) ); - - // check that imap_close was successful, if not call imap_close and explicitly set CL_EXPUNGE - if(false === $check) { - imap_close($stream_id, CL_EXPUNGE); - } else { - // if imap_close was successful test whether CL_EXPUNGE was set by doing a message count - $imap_stream = imap_open($mailbox, $username, $password); - $num_msg = imap_num_msg($imap_stream); - if ($num_msg != 0) { - echo "CL_EXPUNGE was not set, $num_msg msgs in mailbox\n"; - } else { - echo "CL_EXPUNGE was set\n"; - } - // call imap_close with CL_EXPUNGE explicitly set in case mailbox not empty - imap_close($imap_stream, CL_EXPUNGE); - } - $iterator++; - - // get $stream_id for next iteration - $stream_id = imap_open($mailbox, $username, $password); - populate_mailbox($stream_id, $mailbox, 3); + // mark added messages for deletion + for ($i = 1; $i < 4; $i++) { + imap_delete($stream_id, $i); + } + echo "\n-- Iteration $iterator --\n"; + var_dump( $check = imap_close($stream_id, $input) ); + + // check that imap_close was successful, if not call imap_close and explicitly set CL_EXPUNGE + if(false === $check) { + imap_close($stream_id, CL_EXPUNGE); + } else { + // if imap_close was successful test whether CL_EXPUNGE was set by doing a message count + $imap_stream = imap_open($mailbox, $username, $password); + $num_msg = imap_num_msg($imap_stream); + if ($num_msg != 0) { + echo "CL_EXPUNGE was not set, $num_msg msgs in mailbox\n"; + } else { + echo "CL_EXPUNGE was set\n"; + } + // call imap_close with CL_EXPUNGE explicitly set in case mailbox not empty + imap_close($imap_stream, CL_EXPUNGE); + } + $iterator++; + + // get $stream_id for next iteration + $stream_id = imap_open($mailbox, $username, $password); + populate_mailbox($stream_id, $mailbox, 3); }; ?> diff --git a/ext/imap/tests/imap_createmailbox_basic.phpt b/ext/imap/tests/imap_createmailbox_basic.phpt index 89e262ed8467..b522e80dfb28 100644 --- a/ext/imap/tests/imap_createmailbox_basic.phpt +++ b/ext/imap/tests/imap_createmailbox_basic.phpt @@ -16,7 +16,7 @@ echo "*** Testing imap_createmailbox() : basic functionality ***\n"; require_once(__DIR__.'/imap_include.inc'); $imap_stream = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); $newname = "phpnewbox"; @@ -25,8 +25,8 @@ echo "Newname will be '$newname'\n"; $newbox = imap_utf7_encode($server.$newname); if (imap_createmailbox($imap_stream, $newbox)) { - echo "Add a couple of msgs to '$newname' mailbox\n"; - populate_mailbox($imap_stream, $newbox, 2); + echo "Add a couple of msgs to '$newname' mailbox\n"; + populate_mailbox($imap_stream, $newbox, 2); $status = imap_status($imap_stream, $newbox, SA_ALL); if ($status) { diff --git a/ext/imap/tests/imap_fetch_overview_variation3.phpt b/ext/imap/tests/imap_fetch_overview_variation3.phpt index 3bfb627d406c..9e99dc2a0f59 100644 --- a/ext/imap/tests/imap_fetch_overview_variation3.phpt +++ b/ext/imap/tests/imap_fetch_overview_variation3.phpt @@ -38,13 +38,13 @@ $options = array ('1', $iterator = 1; imap_check($stream_id); foreach($options as $option) { - echo "\nTesting with option value:"; - var_dump($option); - $overview = imap_fetch_overview($stream_id, $msg_uid, $option); - if ($overview) { + echo "\nTesting with option value:"; + var_dump($option); + $overview = imap_fetch_overview($stream_id, $msg_uid, $option); + if ($overview) { echo "imap_fetch_overview() returns an object\n"; } - $iterator++; + $iterator++; } ?> diff --git a/ext/imap/tests/imap_fetch_overview_variation5.phpt b/ext/imap/tests/imap_fetch_overview_variation5.phpt index eecb6f0b7773..e06d3f5ef232 100644 --- a/ext/imap/tests/imap_fetch_overview_variation5.phpt +++ b/ext/imap/tests/imap_fetch_overview_variation5.phpt @@ -27,15 +27,15 @@ $sequences = array (0, 4, '4', // out of range '1:3'); // pass uid without setting FT_UID option foreach($sequences as $msg_no) { - echo "\n-- \$msg_no is $msg_no --\n"; + echo "\n-- \$msg_no is $msg_no --\n"; $overview = imap_fetch_overview($stream_id, $msg_no); - if (!$overview) { - echo imap_last_error() . "\n"; + if (!$overview) { + echo imap_last_error() . "\n"; } else { - foreach($overview as $ov) { - echo "\n"; - displayOverviewFields($ov); - } + foreach($overview as $ov) { + echo "\n"; + displayOverviewFields($ov); + } } } diff --git a/ext/imap/tests/imap_fetch_overview_variation6.phpt b/ext/imap/tests/imap_fetch_overview_variation6.phpt index 1ca9fd51dae2..90bff01cea78 100644 --- a/ext/imap/tests/imap_fetch_overview_variation6.phpt +++ b/ext/imap/tests/imap_fetch_overview_variation6.phpt @@ -40,48 +40,48 @@ displayOverviewFields($a[0]); * @param string $mailbox */ function create_multipart_message($imap_stream, $mailbox) { - global $users, $domain; - $envelope["from"]= "foo@anywhere.com"; - $envelope["to"] = "$users[0]@$domain"; - $envelope["subject"] = "Test msg 1"; - - $part1["type"] = TYPEMULTIPART; - $part1["subtype"] = "mixed"; - - $part2["type"] = TYPETEXT; - $part2["subtype"] = "plain"; - $part2["description"] = "imap_mail_compose() function"; - $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; - - $part3["type"] = TYPETEXT; - $part3["subtype"] = "plain"; - $part3["description"] = "Example"; - $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; - - $file_handle = fopen(__FILE__, 'r+'); - $file_size = 1; - - $part4["type"] = TYPEAPPLICATION; - $part4["encoding"] = ENCBASE64; - $part4["subtype"] = "octet-stream"; - $part4["description"] = 'Test'; - $part4['disposition.type'] = 'attachment'; - $part4['disposition'] = array ('filename' => 'Test'); - $part4['type.parameters'] = array('name' => 'Test'); - $part4["contents.data"] = base64_encode(fread($file_handle, 1)); - - $body[1] = $part1; - $body[2] = $part2; - $body[3] = $part3; - $body[4] = $part4; - - $msg = imap_mail_compose($envelope, $body); - - if (imap_append($imap_stream, $mailbox, $msg) === false) { - echo imap_last_error() . "\n"; - echo "TEST FAILED : could not append new message to mailbox '$mailbox'\n"; - exit; - } + global $users, $domain; + $envelope["from"]= "foo@anywhere.com"; + $envelope["to"] = "$users[0]@$domain"; + $envelope["subject"] = "Test msg 1"; + + $part1["type"] = TYPEMULTIPART; + $part1["subtype"] = "mixed"; + + $part2["type"] = TYPETEXT; + $part2["subtype"] = "plain"; + $part2["description"] = "imap_mail_compose() function"; + $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; + + $part3["type"] = TYPETEXT; + $part3["subtype"] = "plain"; + $part3["description"] = "Example"; + $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; + + $file_handle = fopen(__FILE__, 'r+'); + $file_size = 1; + + $part4["type"] = TYPEAPPLICATION; + $part4["encoding"] = ENCBASE64; + $part4["subtype"] = "octet-stream"; + $part4["description"] = 'Test'; + $part4['disposition.type'] = 'attachment'; + $part4['disposition'] = array ('filename' => 'Test'); + $part4['type.parameters'] = array('name' => 'Test'); + $part4["contents.data"] = base64_encode(fread($file_handle, 1)); + + $body[1] = $part1; + $body[2] = $part2; + $body[3] = $part3; + $body[4] = $part4; + + $msg = imap_mail_compose($envelope, $body); + + if (imap_append($imap_stream, $mailbox, $msg) === false) { + echo imap_last_error() . "\n"; + echo "TEST FAILED : could not append new message to mailbox '$mailbox'\n"; + exit; + } } ?> diff --git a/ext/imap/tests/imap_fetchbody_basic.phpt b/ext/imap/tests/imap_fetchbody_basic.phpt index 797ec08bf528..597b3b71b60f 100644 --- a/ext/imap/tests/imap_fetchbody_basic.phpt +++ b/ext/imap/tests/imap_fetchbody_basic.phpt @@ -27,26 +27,26 @@ $options = array ('FT_UID' => FT_UID, 'FT_PEEK' => FT_PEEK, 'FT_INTERNAL' => FT_ // Calling imap_fetchbody() with all possible arguments echo "\n-- All possible arguments --\n"; foreach ($options as $key => $option) { - echo "-- Option is $key --\n"; - switch ($key) { + echo "-- Option is $key --\n"; + switch ($key) { - case 'FT_UID'; - $msg_uid = imap_uid($stream_id, $msg_no); - var_dump( imap_fetchbody($stream_id, $msg_uid, $section, $option) ); - break; + case 'FT_UID'; + $msg_uid = imap_uid($stream_id, $msg_no); + var_dump( imap_fetchbody($stream_id, $msg_uid, $section, $option) ); + break; - case 'FT_PEEK'; - var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) ); - $overview = imap_fetch_overview($stream_id, 1); - echo "Seen Flag: "; - var_dump( $overview[0]->seen ); - break; + case 'FT_PEEK'; + var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) ); + $overview = imap_fetch_overview($stream_id, 1); + echo "Seen Flag: "; + var_dump( $overview[0]->seen ); + break; - case 'FT_INTERNAL'; - var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) ); - break; + case 'FT_INTERNAL'; + var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) ); + break; - } + } } // Calling imap_fetchbody() with mandatory arguments diff --git a/ext/imap/tests/imap_fetchbody_variation4.phpt b/ext/imap/tests/imap_fetchbody_variation4.phpt index 8648115896ec..b4b8afa92d9d 100644 --- a/ext/imap/tests/imap_fetchbody_variation4.phpt +++ b/ext/imap/tests/imap_fetchbody_variation4.phpt @@ -35,13 +35,13 @@ $options = array ('1', true, $iterator = 1; imap_check($stream_id); foreach($options as $option) { - echo "\n-- Iteration $iterator --\n"; - if(is_string(imap_fetchbody($stream_id, $msg_uid, $section, $option))) { - echo "FT_UID valid\n"; - } else { + echo "\n-- Iteration $iterator --\n"; + if(is_string(imap_fetchbody($stream_id, $msg_uid, $section, $option))) { + echo "FT_UID valid\n"; + } else { echo "FT_UID not valid\n"; } - $iterator++; + $iterator++; } ?> diff --git a/ext/imap/tests/imap_fetchbody_variation6.phpt b/ext/imap/tests/imap_fetchbody_variation6.phpt index 1f179633ef2e..2090bf37925c 100644 --- a/ext/imap/tests/imap_fetchbody_variation6.phpt +++ b/ext/imap/tests/imap_fetchbody_variation6.phpt @@ -29,11 +29,11 @@ $sequences = array (0, 4, // out of range ); foreach($sequences as $msg_no) { - echo "\n-- \$msg_no is $msg_no --\n"; - var_dump($overview = imap_fetchbody($stream_id, $msg_no, $section)); - if (!$overview) { - echo imap_last_error() . "\n"; - } + echo "\n-- \$msg_no is $msg_no --\n"; + var_dump($overview = imap_fetchbody($stream_id, $msg_no, $section)); + if (!$overview) { + echo imap_last_error() . "\n"; + } } ?> --CLEAN-- diff --git a/ext/imap/tests/imap_fetchheader_basic.phpt b/ext/imap/tests/imap_fetchheader_basic.phpt index fd43ceec9418..7da2a1b78cb6 100644 --- a/ext/imap/tests/imap_fetchheader_basic.phpt +++ b/ext/imap/tests/imap_fetchheader_basic.phpt @@ -23,13 +23,13 @@ $options = array('FT_UID' => FT_UID, 'FT_INTERNAL' => FT_INTERNAL, // Calling imap_fetchheader() with all possible arguments echo "\n-- All possible arguments --\n"; foreach ($options as $key => $option) { - echo "-- Option is $key --\n"; - if ($key == 'FT_UID') { - $msg_uid = imap_uid($stream_id, $msg_no); - var_dump(imap_fetchheader($stream_id, $msg_uid, $option)); - } else { - var_dump(imap_fetchheader($stream_id, $msg_no, $option)); - } + echo "-- Option is $key --\n"; + if ($key == 'FT_UID') { + $msg_uid = imap_uid($stream_id, $msg_no); + var_dump(imap_fetchheader($stream_id, $msg_uid, $option)); + } else { + var_dump(imap_fetchheader($stream_id, $msg_no, $option)); + } } // Calling imap_fetchheader() with mandatory arguments diff --git a/ext/imap/tests/imap_fetchheader_variation3.phpt b/ext/imap/tests/imap_fetchheader_variation3.phpt index 073e9e7eca7f..3430409fcbc0 100644 --- a/ext/imap/tests/imap_fetchheader_variation3.phpt +++ b/ext/imap/tests/imap_fetchheader_variation3.phpt @@ -34,13 +34,13 @@ $options = array ('1', true, $iterator = 1; imap_check($stream_id); foreach($options as $option) { - echo "\n-- Iteration $iterator --\n"; - if(is_string(imap_fetchheader($stream_id, $msg_uid, $option))) { - echo "FT_UID valid\n"; - } else { + echo "\n-- Iteration $iterator --\n"; + if(is_string(imap_fetchheader($stream_id, $msg_uid, $option))) { + echo "FT_UID valid\n"; + } else { echo "FT_UID not valid\n"; } - $iterator++; + $iterator++; } ?> --CLEAN-- diff --git a/ext/imap/tests/imap_fetchheader_variation5.phpt b/ext/imap/tests/imap_fetchheader_variation5.phpt index 77e334b6a118..548aac89357f 100644 --- a/ext/imap/tests/imap_fetchheader_variation5.phpt +++ b/ext/imap/tests/imap_fetchheader_variation5.phpt @@ -27,11 +27,11 @@ $sequences = array (0, 4, // out of range ); foreach($sequences as $msg_no) { - echo "\n-- \$msg_no is $msg_no --\n"; - var_dump($overview = imap_fetchheader($stream_id, $msg_no)); - if (!$overview) { - echo imap_last_error() . "\n"; - } + echo "\n-- \$msg_no is $msg_no --\n"; + var_dump($overview = imap_fetchheader($stream_id, $msg_no)); + if (!$overview) { + echo imap_last_error() . "\n"; + } } // clear error stack diff --git a/ext/imap/tests/imap_fetchstructure_basic.phpt b/ext/imap/tests/imap_fetchstructure_basic.phpt index 5d83a2742721..0ff266a390c8 100644 --- a/ext/imap/tests/imap_fetchstructure_basic.phpt +++ b/ext/imap/tests/imap_fetchstructure_basic.phpt @@ -28,7 +28,7 @@ $fields = array('type','encoding','ifsubtype','subtype', 'ifdescription','lines','bytes','parameters'); foreach ($fields as $key) { - var_dump(isset($z->$key)); + var_dump(isset($z->$key)); } var_dump($z->type); var_dump($z->encoding); diff --git a/ext/imap/tests/imap_gc_error.phpt b/ext/imap/tests/imap_gc_error.phpt index ee13f45ce702..9606c1ae2db9 100644 --- a/ext/imap/tests/imap_gc_error.phpt +++ b/ext/imap/tests/imap_gc_error.phpt @@ -18,7 +18,7 @@ imap_gc(false, false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_gc($stream_id, -1); ?> diff --git a/ext/imap/tests/imap_getsubscribed_basic.phpt b/ext/imap/tests/imap_getsubscribed_basic.phpt index 666203a8c217..8995eadd0528 100644 --- a/ext/imap/tests/imap_getsubscribed_basic.phpt +++ b/ext/imap/tests/imap_getsubscribed_basic.phpt @@ -17,7 +17,7 @@ imap_getsubscribed(false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_getsubscribed($stream_id); imap_getsubscribed($stream_id,$default_mailbox); diff --git a/ext/imap/tests/imap_headerinfo_basic.phpt b/ext/imap/tests/imap_headerinfo_basic.phpt index c13e62f8bfa0..056a46523c95 100644 --- a/ext/imap/tests/imap_headerinfo_basic.phpt +++ b/ext/imap/tests/imap_headerinfo_basic.phpt @@ -16,14 +16,14 @@ $z = imap_headerinfo($stream_id, 1); $fields = array ('toaddress','to','fromaddress','from', 'reply_toaddress','reply_to', - 'senderaddress', 'sender', + 'senderaddress', 'sender', 'subject','Subject', - 'Recent','Unseen','Flagged','Answered','Deleted','Draft', - 'Msgno','MailDate','Size','udate'); + 'Recent','Unseen','Flagged','Answered','Deleted','Draft', + 'Msgno','MailDate','Size','udate'); echo "Check general fields\n"; foreach ($fields as $key) { - var_dump(isset($z->$key)); + var_dump(isset($z->$key)); } echo "Check type\n"; @@ -35,44 +35,44 @@ var_dump($z->subject); var_dump($z->Subject); if ($z->Recent == 'R' || $z->Recent == 'N' || $z->Recent == ' ') { - echo "Recent: OK"; + echo "Recent: OK"; } else { - echo "Recent: error: ".$z->Recent; + echo "Recent: error: ".$z->Recent; } echo "\n"; if ($z->Unseen == 'U' || $z->Unseen == ' ') { - echo "Unseen: OK"; + echo "Unseen: OK"; } else { - echo "Unseen: error: ".$z->Unseen; + echo "Unseen: error: ".$z->Unseen; } echo "\n"; if ($z->Flagged == 'F' || $z->Flagged == ' ') { - echo "Flagged: OK"; + echo "Flagged: OK"; } else { - echo "Flagged: error: ".$z->Flagged; + echo "Flagged: error: ".$z->Flagged; } echo "\n"; if ($z->Answered == 'A' || $z->Answered == ' ') { - echo "Answered: OK"; + echo "Answered: OK"; } else { - echo "Answered: error"; + echo "Answered: error"; } echo "\n"; if ($z->Deleted == 'D' || $z->Deleted == ' ') { - echo "Deleted: OK"; + echo "Deleted: OK"; } else { - echo "Deleted: error"; + echo "Deleted: error"; } echo "\n"; if ($z->Draft == 'X' || $z->Draft == ' ') { - echo "Draft: OK"; + echo "Draft: OK"; } else { - echo "Draft: error"; + echo "Draft: error"; } echo "\n"; diff --git a/ext/imap/tests/imap_headerinfo_error.phpt b/ext/imap/tests/imap_headerinfo_error.phpt index 8d67b7013008..3f3c593d06a5 100644 --- a/ext/imap/tests/imap_headerinfo_error.phpt +++ b/ext/imap/tests/imap_headerinfo_error.phpt @@ -17,7 +17,7 @@ imap_headerinfo(false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_headerinfo($stream_id); diff --git a/ext/imap/tests/imap_include.inc b/ext/imap/tests/imap_include.inc index 47ac081c9f77..7de634075a29 100644 --- a/ext/imap/tests/imap_include.inc +++ b/ext/imap/tests/imap_include.inc @@ -64,32 +64,32 @@ function displayOverviewFields($resp, $fields=null) { * @return IMAP stream to new mailbox on success; FALSE on failure */ function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = null, $msg_type = "simple"){ - global $server, $default_mailbox, $username, $password; + global $server, $default_mailbox, $username, $password; - // open a stream to default mailbox - $imap_stream = imap_open($default_mailbox, $username, $password); + // open a stream to default mailbox + $imap_stream = imap_open($default_mailbox, $username, $password); - if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; - } + if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; + } - echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; - $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); - if ($new_mailbox === false) { - echo "Can't create a temporary mailbox: " . imap_last_error(). "\n"; - return false; - } + echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; + $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); + if ($new_mailbox === false) { + echo "Can't create a temporary mailbox: " . imap_last_error(). "\n"; + return false; + } - echo ".. mailbox '$new_mailbox' created\n"; + echo ".. mailbox '$new_mailbox' created\n"; - // reopen stream to new mailbox - if (imap_reopen($imap_stream, $new_mailbox) === false) { - echo "can't re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; - return false; - } + // reopen stream to new mailbox + if (imap_reopen($imap_stream, $new_mailbox) === false) { + echo "can't re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; + return false; + } - return $imap_stream; + return $imap_stream; } /** @@ -99,30 +99,30 @@ function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = nul * @param string $mailbox */ function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type= "simple"){ - global $default_mailbox, $mailbox_prefix; - $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; - - $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); - - // check mailbox does not already exist - if ($mailboxes) { - foreach($mailboxes as $value) { - if ($value->name == $mailbox) { - exit ("TEST FAILED : Mailbox '$mailbox' already exists\n"); - } - } - } - - if (imap_createmailbox($imap_stream, $mailbox) === false) { - return false; - } - - // Add number of test msgs requested - if ($message_count > 0) { - populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type); - } - - return $mailbox; + global $default_mailbox, $mailbox_prefix; + $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; + + $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); + + // check mailbox does not already exist + if ($mailboxes) { + foreach($mailboxes as $value) { + if ($value->name == $mailbox) { + exit ("TEST FAILED : Mailbox '$mailbox' already exists\n"); + } + } + } + + if (imap_createmailbox($imap_stream, $mailbox) === false) { + return false; + } + + // Add number of test msgs requested + if ($message_count > 0) { + populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type); + } + + return $mailbox; } /** @@ -133,48 +133,48 @@ function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type */ function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "simple"){ - global $users, $domain; - - for($i = 1; $i <= $message_count; $i++) { - if ($msg_type == "simple") { - $msg = "From: foo@anywhere.com\r\n" - . "To: $users[0]@$domain\r\n" - . "Subject: test$i\r\n" - . "\r\n" - . "$i: this is a test message, please ignore\r\n"; - } else { - $envelope["from"]= "foo@anywhere.com"; - $envelope["to"] = "$users[0]@$domain"; - $envelope["subject"] = "Test msg $i"; - - $part1["type"] = TYPEMULTIPART; - $part1["subtype"] = "mixed"; - - $part2["type"] = TYPETEXT; - $part2["subtype"] = "plain"; - $part2["description"] = "imap_mail_compose() function"; - $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; - - $part3["type"] = TYPETEXT; - $part3["subtype"] = "plain"; - $part3["description"] = "Example"; - $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; - - $part4["type"] = TYPETEXT; - $part4["subtype"] = "plain"; - $part4["description"] = "Return Values"; - $part4["contents.data"] = "message 3:zzzzzzzzzzzzzzzzzzzzzzzzzz"; - - $body[1] = $part1; - $body[2] = $part2; - $body[3] = $part3; - $body[4] = $part4; - - $msg = imap_mail_compose($envelope, $body); - } - - imap_append($imap_stream, $mailbox, $msg); - } + global $users, $domain; + + for($i = 1; $i <= $message_count; $i++) { + if ($msg_type == "simple") { + $msg = "From: foo@anywhere.com\r\n" + . "To: $users[0]@$domain\r\n" + . "Subject: test$i\r\n" + . "\r\n" + . "$i: this is a test message, please ignore\r\n"; + } else { + $envelope["from"]= "foo@anywhere.com"; + $envelope["to"] = "$users[0]@$domain"; + $envelope["subject"] = "Test msg $i"; + + $part1["type"] = TYPEMULTIPART; + $part1["subtype"] = "mixed"; + + $part2["type"] = TYPETEXT; + $part2["subtype"] = "plain"; + $part2["description"] = "imap_mail_compose() function"; + $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; + + $part3["type"] = TYPETEXT; + $part3["subtype"] = "plain"; + $part3["description"] = "Example"; + $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; + + $part4["type"] = TYPETEXT; + $part4["subtype"] = "plain"; + $part4["description"] = "Return Values"; + $part4["contents.data"] = "message 3:zzzzzzzzzzzzzzzzzzzzzzzzzz"; + + $body[1] = $part1; + $body[2] = $part2; + $body[3] = $part3; + $body[4] = $part4; + + $msg = imap_mail_compose($envelope, $body); + } + + imap_append($imap_stream, $mailbox, $msg); + } } /** @@ -185,12 +185,12 @@ function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "s */ function get_mailbox_name($mailbox){ - if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { - echo "Unrecpognized mailbox name\n"; - return false; - } + if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { + echo "Unrecpognized mailbox name\n"; + return false; + } - return $match[1]; + return $match[1]; } ?> diff --git a/ext/imap/tests/imap_list_basic.phpt b/ext/imap/tests/imap_list_basic.phpt index 21f8a63894af..77df74af2b2a 100644 --- a/ext/imap/tests/imap_list_basic.phpt +++ b/ext/imap/tests/imap_list_basic.phpt @@ -17,7 +17,7 @@ imap_list(false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_list($stream_id); imap_list($stream_id,$default_mailbox); diff --git a/ext/imap/tests/imap_lsub_basic.phpt b/ext/imap/tests/imap_lsub_basic.phpt index 638479ca80b9..591a023ed869 100644 --- a/ext/imap/tests/imap_lsub_basic.phpt +++ b/ext/imap/tests/imap_lsub_basic.phpt @@ -17,7 +17,7 @@ imap_lsub(false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_lsub($stream_id); imap_lsub($stream_id,$default_mailbox); diff --git a/ext/imap/tests/imap_mail_copy.phpt b/ext/imap/tests/imap_mail_copy.phpt index 92025561694f..c82a003a5950 100644 --- a/ext/imap/tests/imap_mail_copy.phpt +++ b/ext/imap/tests/imap_mail_copy.phpt @@ -23,7 +23,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Test with IMAP server\n"; $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); var_dump(imap_mail_copy($stream_id)); var_dump(imap_mail_copy($stream_id,-1)); diff --git a/ext/imap/tests/imap_mail_copy_basic.phpt b/ext/imap/tests/imap_mail_copy_basic.phpt index 7b8c69f1042e..335b4218e6c1 100644 --- a/ext/imap/tests/imap_mail_copy_basic.phpt +++ b/ext/imap/tests/imap_mail_copy_basic.phpt @@ -21,7 +21,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Create a new mailbox for test\n"; $imap_stream = setup_test_mailbox("", 1); if (!is_resource($imap_stream)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } $check = imap_check($imap_stream); diff --git a/ext/imap/tests/imap_mail_move.phpt b/ext/imap/tests/imap_mail_move.phpt index 3406288b2706..d6d874b80de2 100644 --- a/ext/imap/tests/imap_mail_move.phpt +++ b/ext/imap/tests/imap_mail_move.phpt @@ -23,7 +23,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Test with IMAP server\n"; $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); var_dump(imap_mail_move($stream_id)); var_dump(imap_mail_move($stream_id,-1)); diff --git a/ext/imap/tests/imap_mail_move_basic.phpt b/ext/imap/tests/imap_mail_move_basic.phpt index 390ec710c52a..555d6e7a183e 100644 --- a/ext/imap/tests/imap_mail_move_basic.phpt +++ b/ext/imap/tests/imap_mail_move_basic.phpt @@ -21,7 +21,7 @@ require_once(__DIR__.'/imap_include.inc'); echo "Create a new mailbox for test\n"; $imap_stream = setup_test_mailbox("", 1); if (!is_resource($imap_stream)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } $check = imap_check($imap_stream); diff --git a/ext/imap/tests/imap_renamemailbox_basic.phpt b/ext/imap/tests/imap_renamemailbox_basic.phpt index 91f99d13e35f..ee5ccb2be723 100644 --- a/ext/imap/tests/imap_renamemailbox_basic.phpt +++ b/ext/imap/tests/imap_renamemailbox_basic.phpt @@ -21,7 +21,7 @@ require_once(__DIR__.'/imap_include.inc'); $stream_id = setup_test_mailbox('', 1); if (!is_resource($stream_id)) { - exit("TEST FAILED: Unable to create test mailbox\n"); + exit("TEST FAILED: Unable to create test mailbox\n"); } $newbox = $default_mailbox . "." . $mailbox_prefix; diff --git a/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt b/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt index 36fcc7f0778b..87dc4aaf05b7 100644 --- a/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt +++ b/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt @@ -16,14 +16,14 @@ $z = imap_headerinfo($stream_id, 1); $fields = array ('toaddress','to','fromaddress','from', 'reply_toaddress','reply_to', - 'senderaddress', 'sender', + 'senderaddress', 'sender', 'subject','Subject', - 'MailDate','Size','udate'); + 'MailDate','Size','udate'); echo "Check general fields\n"; foreach ($fields as $key) { - var_dump(isset($z->$key)); + var_dump(isset($z->$key)); } echo "Check type\n"; @@ -35,44 +35,44 @@ var_dump($z->subject); var_dump($z->Subject); if ($z->Recent == 'R' || $z->Recent == 'N' || $z->Recent == ' ') { - echo "Recent: OK"; + echo "Recent: OK"; } else { - echo "Recent: error"; + echo "Recent: error"; } echo "\n"; if ($z->Unseen == 'U' || $z->Unseen == ' ') { - echo "Unseen: OK"; + echo "Unseen: OK"; } else { - echo "Unseen: error"; + echo "Unseen: error"; } echo "\n"; if ($z->Flagged == 'F' || $z->Flagged == ' ') { - echo "Flagged: OK"; + echo "Flagged: OK"; } else { - echo "Flagged: error"; + echo "Flagged: error"; } echo "\n"; if ($z->Answered == 'A' || $z->Answered == ' ') { - echo "Answered: OK"; + echo "Answered: OK"; } else { - echo "Answered: error"; + echo "Answered: error"; } echo "\n"; if ($z->Deleted == 'D' || $z->Deleted == ' ') { - echo "Deleted: OK"; + echo "Deleted: OK"; } else { - echo "Deleted: error"; + echo "Deleted: error"; } echo "\n"; if ($z->Draft == 'X' || $z->Draft == ' ') { - echo "Draft: OK"; + echo "Draft: OK"; } else { - echo "Draft: error"; + echo "Draft: error"; } echo "\n"; diff --git a/ext/imap/tests/imap_undelete_error.phpt b/ext/imap/tests/imap_undelete_error.phpt index 0eae8033eb0f..972c8140c63d 100644 --- a/ext/imap/tests/imap_undelete_error.phpt +++ b/ext/imap/tests/imap_undelete_error.phpt @@ -17,7 +17,7 @@ imap_undelete(false); require_once(__DIR__.'/imap_include.inc'); $stream_id = imap_open($default_mailbox, $username, $password) or - die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); imap_undelete($stream_id); diff --git a/ext/imap/tests/skipif.inc b/ext/imap/tests/skipif.inc index 12b14086349b..2820bff5c69f 100644 --- a/ext/imap/tests/skipif.inc +++ b/ext/imap/tests/skipif.inc @@ -10,7 +10,7 @@ $retries = 0; // don't retry connect on failure $mbox = @imap_open($mailbox, $username, $password, $options, $retries); if (!$mbox) { - die("skip could not connect to mailbox $mailbox"); + die("skip could not connect to mailbox $mailbox"); } imap_close($mbox); ?> diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt index c3d7a331c2c6..3cc04dbf6435 100644 --- a/ext/intl/tests/badargs.phpt +++ b/ext/intl/tests/badargs.phpt @@ -14,13 +14,13 @@ foreach($funcs as $func) { continue; } - try { - $res = $func($arg); - } catch (Exception $e) { - continue; - } catch (Error $e) { - continue; - } + try { + $res = $func($arg); + } catch (Exception $e) { + continue; + } catch (Error $e) { + continue; + } if($res != false) { echo "$func: "; var_dump($res); diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt index 595c6b283a83..8b36b4a7cf75 100644 --- a/ext/intl/tests/breakiter___construct_error.phpt +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -7,34 +7,34 @@ IntlRuleBasedBreakIterator::__construct(): arg errors ini_set("intl.error_level", E_WARNING); function print_exception($e) { - echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; } //missing ; at the end: try { - var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+')); + var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+')); } catch (IntlException $e) { - print_exception($e); + print_exception($e); } try { - var_dump(new IntlRuleBasedBreakIterator()); + var_dump(new IntlRuleBasedBreakIterator()); } catch (TypeError $e) { - print_exception($e); + print_exception($e); } try { - var_dump(new IntlRuleBasedBreakIterator(1,2,3)); + var_dump(new IntlRuleBasedBreakIterator(1,2,3)); } catch (TypeError $e) { - print_exception($e); + print_exception($e); } try { - var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array())); + var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array())); } catch (TypeError $e) { - print_exception($e); + print_exception($e); } try { - var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true)); + var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true)); } catch (IntlException $e) { - print_exception($e); + print_exception($e); } --EXPECTF-- Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d diff --git a/ext/intl/tests/breakiter_factories_basic.phpt b/ext/intl/tests/breakiter_factories_basic.phpt index 4d05792c0e9f..ac7b17505dd1 100644 --- a/ext/intl/tests/breakiter_factories_basic.phpt +++ b/ext/intl/tests/breakiter_factories_basic.phpt @@ -10,17 +10,17 @@ ini_set("intl.error_level", E_WARNING); ini_set("intl.default_locale", "ja"); $m = array('createWordInstance', 'createLineInstance', 'createCharacterInstance', - 'createSentenceInstance', 'createTitleInstance'); + 'createSentenceInstance', 'createTitleInstance'); $t = 'Frase 1... Frase 2'; foreach ($m as $method) { - echo "===== $method =====\n"; - $o1 = IntlBreakIterator::$method('ja'); - $o2 = IntlBreakIterator::$method(NULL); - $o3 = IntlBreakIterator::$method(); - var_dump($o1 == $o2 && $o2 == $o3); - echo "\n"; + echo "===== $method =====\n"; + $o1 = IntlBreakIterator::$method('ja'); + $o2 = IntlBreakIterator::$method(NULL); + $o3 = IntlBreakIterator::$method(); + var_dump($o1 == $o2 && $o2 == $o3); + echo "\n"; } --EXPECT-- ===== createWordInstance ===== diff --git a/ext/intl/tests/bug12887.phpt b/ext/intl/tests/bug12887.phpt index e2fc19494413..36d8e2f320d1 100644 --- a/ext/intl/tests/bug12887.phpt +++ b/ext/intl/tests/bug12887.phpt @@ -7,13 +7,13 @@ locale_get_keywords() bug #12887 function ut_main() { - $res_str = ''; - $keywords_arr = ut_loc_get_keywords( 'de_DE@currency=EUR;collation=PHONEBOOK;sort=PHONEBOOK' ); - if ($keywords_arr) { - foreach( $keywords_arr as $key => $value){ - $res_str .= "$key = $value\n"; - } - } + $res_str = ''; + $keywords_arr = ut_loc_get_keywords( 'de_DE@currency=EUR;collation=PHONEBOOK;sort=PHONEBOOK' ); + if ($keywords_arr) { + foreach( $keywords_arr as $key => $value){ + $res_str .= "$key = $value\n"; + } + } $res_str .= "\n"; return $res_str; diff --git a/ext/intl/tests/bug14562.phpt b/ext/intl/tests/bug14562.phpt index 7cf927f7e7a7..ec9a046b75de 100644 --- a/ext/intl/tests/bug14562.phpt +++ b/ext/intl/tests/bug14562.phpt @@ -7,17 +7,17 @@ Bug #14562 NumberFormatter breaks when locale changes function ut_main() { - $res_str = ""; - $de_locale="de_DE.UTF-8"; - $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL ); - $numeric = $fmt->parse("1234,56"); - $res_str .= "$numeric\n"; - setlocale(LC_ALL, $de_locale); - $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL ); - $numeric = $fmt->parse("1234,56"); - setlocale(LC_ALL, "C"); // reset for printing - $res_str .= "$numeric\n"; - return $res_str; + $res_str = ""; + $de_locale="de_DE.UTF-8"; + $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL ); + $numeric = $fmt->parse("1234,56"); + $res_str .= "$numeric\n"; + setlocale(LC_ALL, $de_locale); + $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL ); + $numeric = $fmt->parse("1234,56"); + setlocale(LC_ALL, "C"); // reset for printing + $res_str .= "$numeric\n"; + return $res_str; } include_once( 'ut_common.inc' ); diff --git a/ext/intl/tests/bug53512.phpt b/ext/intl/tests/bug53512.phpt index 872e5987be0d..af2dda8f6948 100644 --- a/ext/intl/tests/bug53512.phpt +++ b/ext/intl/tests/bug53512.phpt @@ -10,9 +10,9 @@ if (PHP_INT_SIZE != 8) die('skip 64-bit only'); $badvals = array(4294901761, 2147483648, -2147483648, -1); foreach ($badvals as $val) { - $x = numfmt_create("en", NumberFormatter::PATTERN_DECIMAL); - var_dump(numfmt_set_symbol($x, $val, "")); - var_dump(intl_get_error_message()); + $x = numfmt_create("en", NumberFormatter::PATTERN_DECIMAL); + var_dump(numfmt_set_symbol($x, $val, "")); + var_dump(intl_get_error_message()); } ?> diff --git a/ext/intl/tests/bug58756_MessageFormatter.phpt b/ext/intl/tests/bug58756_MessageFormatter.phpt index 13b51ec6cead..01673b8c485c 100644 --- a/ext/intl/tests/bug58756_MessageFormatter.phpt +++ b/ext/intl/tests/bug58756_MessageFormatter.phpt @@ -26,7 +26,7 @@ echo "msgf: " . $msgf->format(array($time)) . "\n"; '{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; + $msgf->format(array($time, 'time')), "\n"; */ ?> diff --git a/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt b/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt index a6a58906ccc1..790033c95b57 100644 --- a/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt +++ b/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt @@ -26,7 +26,7 @@ echo "msgf: " . $msgf->format(array($time)) . "\n"; '{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; + $msgf->format(array($time, 'time')), "\n"; */ ?> diff --git a/ext/intl/tests/bug60192-compare.phpt b/ext/intl/tests/bug60192-compare.phpt index 096b57558f13..bd5faa11edff 100644 --- a/ext/intl/tests/bug60192-compare.phpt +++ b/ext/intl/tests/bug60192-compare.phpt @@ -7,9 +7,9 @@ Bug #60192 (SegFault when Collator not constructed properly) --FILE-- getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL; + echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL; } --EXPECTF-- Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d diff --git a/ext/intl/tests/bug62915-2.phpt b/ext/intl/tests/bug62915-2.phpt index 8dc3bd1512c8..a10b476ab472 100644 --- a/ext/intl/tests/bug62915-2.phpt +++ b/ext/intl/tests/bug62915-2.phpt @@ -9,24 +9,24 @@ if (!class_exists('Spoofchecker')) --FILE-- newInstanceArgs($subclass::$ARGS); - $clone = clone $obj; - var_dump(get_class($clone)); + $rc = new ReflectionClass($subclass); + $obj = $rc->newInstanceArgs($subclass::$ARGS); + $clone = clone $obj; + var_dump(get_class($clone)); } --EXPECT-- string(1) "A" diff --git a/ext/intl/tests/bug62915.phpt b/ext/intl/tests/bug62915.phpt index 2277cde9d5c6..45d2dea5e912 100644 --- a/ext/intl/tests/bug62915.phpt +++ b/ext/intl/tests/bug62915.phpt @@ -8,17 +8,17 @@ if (!extension_loaded('intl')) getMessage()); + var_dump($e->getMessage()); } --EXPECT-- string(39) "Cannot clone unconstructed IntlTimeZone" diff --git a/ext/intl/tests/bug71020.phpt b/ext/intl/tests/bug71020.phpt index 9f9b8eede336..582275967ffa 100644 --- a/ext/intl/tests/bug71020.phpt +++ b/ext/intl/tests/bug71020.phpt @@ -7,7 +7,7 @@ Bug #71020 (Use after free in Collator::sortWithSortKeys) $var_3=new Collator("Whatever"); for($x=0;$x<0xbb;$x++) - $myarray[substr(md5(microtime()),rand(0,26),9) . strval($x)]= substr(md5(microtime()),rand(0,26),9) . strval($x); + $myarray[substr(md5(microtime()),rand(0,26),9) . strval($x)]= substr(md5(microtime()),rand(0,26),9) . strval($x); $var_3->sortWithSortKeys($myarray); ?> okey diff --git a/ext/intl/tests/bug72533.phpt b/ext/intl/tests/bug72533.phpt index 1faf08c28719..bf48c83c70cd 100644 --- a/ext/intl/tests/bug72533.phpt +++ b/ext/intl/tests/bug72533.phpt @@ -9,15 +9,15 @@ function ut_main() { $ret = var_export(ut_loc_accept_http(str_repeat('x', 256)), true); $ret .= "\n"; - if(intl_is_failure(intl_get_error_code())) { - $ret .= var_export(intl_get_error_message(), true); - } + if(intl_is_failure(intl_get_error_code())) { + $ret .= var_export(intl_get_error_message(), true); + } $ret .= "\n"; $ret .= var_export(ut_loc_accept_http(str_repeat('en,', 256)), true); $ret .= "\n"; - if(intl_is_failure(intl_get_error_code())) { - $ret .= var_export(intl_get_error_message(), true); - } + if(intl_is_failure(intl_get_error_code())) { + $ret .= var_export(intl_get_error_message(), true); + } return $ret; } diff --git a/ext/intl/tests/bug72639.phpt b/ext/intl/tests/bug72639.phpt index 2c94dcc06f94..ca9b21971563 100644 --- a/ext/intl/tests/bug72639.phpt +++ b/ext/intl/tests/bug72639.phpt @@ -6,7 +6,7 @@ Bug #72639 (Segfault when instantiating class that extends IntlCalendar and adds diff --git a/ext/intl/tests/calendar_add_basic.phpt b/ext/intl/tests/calendar_add_basic.phpt index 4d333594a10c..3e8ed55579b7 100644 --- a/ext/intl/tests/calendar_add_basic.phpt +++ b/ext/intl/tests/calendar_add_basic.phpt @@ -22,8 +22,8 @@ $intlcal->add(IntlCalendar::FIELD_MINUTE, 6); intlcal_add($intlcal, IntlCalendar::FIELD_SECOND, 7); var_dump( - (float)$time2*1000, - $intlcal->getTime()); + (float)$time2*1000, + $intlcal->getTime()); ?> --EXPECT-- diff --git a/ext/intl/tests/calendar_before_after_error.phpt b/ext/intl/tests/calendar_before_after_error.phpt index 4d34ae77f5df..66fb62f22472 100644 --- a/ext/intl/tests/calendar_before_after_error.phpt +++ b/ext/intl/tests/calendar_before_after_error.phpt @@ -18,47 +18,47 @@ echo "error: $errno, $errstr\n"; set_error_handler('eh'); try { - var_dump($c->after()); + var_dump($c->after()); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->before()); + var_dump($c->before()); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->after(1)); + var_dump($c->after(1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->before(1)); + var_dump($c->before(1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try{ - var_dump($c->after($c, 1)); + var_dump($c->after($c, 1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->before($c, 1)); + var_dump($c->before($c, 1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_after($c)); + var_dump(intlcal_after($c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_before($c)); + var_dump(intlcal_before($c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } --EXPECT-- error: 0, IntlCalendar::after() expects exactly 1 parameter, 0 given diff --git a/ext/intl/tests/calendar_clear_basic.phpt b/ext/intl/tests/calendar_clear_basic.phpt index 221eec9ff032..1c4b40f424cc 100644 --- a/ext/intl/tests/calendar_clear_basic.phpt +++ b/ext/intl/tests/calendar_clear_basic.phpt @@ -12,13 +12,13 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); var_dump($intlcal->clear()); var_dump( - $intlcal->get(IntlCalendar::FIELD_YEAR), - $intlcal->get(IntlCalendar::FIELD_MONTH), - $intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH), - $intlcal->get(IntlCalendar::FIELD_HOUR), - $intlcal->get(IntlCalendar::FIELD_MINUTE), - $intlcal->get(IntlCalendar::FIELD_SECOND), - $intlcal->get(IntlCalendar::FIELD_MILLISECOND) + $intlcal->get(IntlCalendar::FIELD_YEAR), + $intlcal->get(IntlCalendar::FIELD_MONTH), + $intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->get(IntlCalendar::FIELD_HOUR), + $intlcal->get(IntlCalendar::FIELD_MINUTE), + $intlcal->get(IntlCalendar::FIELD_SECOND), + $intlcal->get(IntlCalendar::FIELD_MILLISECOND) ); $intlcal2 = IntlCalendar::createInstance('Europe/Amsterdam'); diff --git a/ext/intl/tests/calendar_clear_variation1.phpt b/ext/intl/tests/calendar_clear_variation1.phpt index 7b5033167f5d..6bc97b6c71b0 100644 --- a/ext/intl/tests/calendar_clear_variation1.phpt +++ b/ext/intl/tests/calendar_clear_variation1.phpt @@ -19,8 +19,8 @@ var_dump($intlcal->clear(IntlCalendar::FIELD_MONTH)); var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH)); //print_R($intlcal); var_dump( - $intlcal->getTime(), - strtotime('2012-01-29 05:06:07 +0000') * 1000. + $intlcal->getTime(), + strtotime('2012-01-29 05:06:07 +0000') * 1000. ); ?> --EXPECT-- diff --git a/ext/intl/tests/calendar_equals_error.phpt b/ext/intl/tests/calendar_equals_error.phpt index 4e6f40b43d4c..04896458b241 100644 --- a/ext/intl/tests/calendar_equals_error.phpt +++ b/ext/intl/tests/calendar_equals_error.phpt @@ -18,31 +18,31 @@ echo "error: $errno, $errstr\n"; set_error_handler('eh'); try { - var_dump($c->equals()); + var_dump($c->equals()); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->equals(new stdclass)); + var_dump($c->equals(new stdclass)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->equals(1, 2)); + var_dump($c->equals(1, 2)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_equals($c, array())); + var_dump(intlcal_equals($c, array())); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_equals(1, $c)); + var_dump(intlcal_equals(1, $c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } --EXPECT-- error: 0, IntlCalendar::equals() expects exactly 1 parameter, 0 given diff --git a/ext/intl/tests/calendar_fieldDifference_basic.phpt b/ext/intl/tests/calendar_fieldDifference_basic.phpt index a7202e9bee37..918f279fb159 100644 --- a/ext/intl/tests/calendar_fieldDifference_basic.phpt +++ b/ext/intl/tests/calendar_fieldDifference_basic.phpt @@ -14,18 +14,18 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); var_dump( - $intlcal->fieldDifference( - strtotime('2012-02-29 06:06:08 +0000') * 1000, - IntlCalendar::FIELD_SECOND), - $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY)); + $intlcal->fieldDifference( + strtotime('2012-02-29 06:06:08 +0000') * 1000, + IntlCalendar::FIELD_SECOND), + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY)); $intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); var_dump( - intlcal_field_difference( - $intlcal, - strtotime('2012-02-29 06:07:08 +0000') * 1000, - IntlCalendar::FIELD_MINUTE)); + intlcal_field_difference( + $intlcal, + strtotime('2012-02-29 06:07:08 +0000') * 1000, + IntlCalendar::FIELD_MINUTE)); ?> --EXPECT-- int(3601) diff --git a/ext/intl/tests/calendar_fromDateTime_basic.phpt b/ext/intl/tests/calendar_fromDateTime_basic.phpt index 0c7e471454c2..dcbd4e1c61d4 100644 --- a/ext/intl/tests/calendar_fromDateTime_basic.phpt +++ b/ext/intl/tests/calendar_fromDateTime_basic.phpt @@ -12,28 +12,28 @@ date_default_timezone_set('Europe/Lisbon'); $cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00 Europe/Rome'); var_dump( - $cal->getTime(), - strtotime('2012-01-01 00:00:00 Europe/Rome') * 1000., - $cal->getTimeZone()->getID(), - $cal->getLocale(1) + $cal->getTime(), + strtotime('2012-01-01 00:00:00 Europe/Rome') * 1000., + $cal->getTimeZone()->getID(), + $cal->getLocale(1) ); echo "\n"; $cal = IntlCalendar::fromDateTime(new DateTime('2012-01-01 00:00:00 PST'), "pt_PT"); var_dump( - $cal->getTime(), - strtotime('2012-01-01 00:00:00 PST') * 1000., - $cal->getTimeZone()->getID(), - $cal->getLocale(1) + $cal->getTime(), + strtotime('2012-01-01 00:00:00 PST') * 1000., + $cal->getTimeZone()->getID(), + $cal->getLocale(1) ); echo "\n"; $cal = intlcal_from_date_time(new DateTime('2012-01-01 00:00:00 +03:40')); var_dump( - $cal->getTime(), - strtotime('2012-01-01 00:00:00 +03:40') * 1000., - $cal->getTimeZone()->getID() + $cal->getTime(), + strtotime('2012-01-01 00:00:00 +03:40') * 1000., + $cal->getTimeZone()->getID() ); --EXPECTF-- float(1325372400000) diff --git a/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt index 7a9c8afa9457..c525dca988ba 100644 --- a/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt +++ b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt @@ -16,11 +16,11 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000); var_dump( - intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) + intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) ); ?> diff --git a/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt b/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt index 1dc4bb90a64b..982eaf4251b8 100644 --- a/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt +++ b/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt @@ -16,11 +16,11 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000); var_dump( - intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) + intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) ); ?> diff --git a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt index 233ca30b260e..2bd97330edf0 100644 --- a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt +++ b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt @@ -13,19 +13,19 @@ ini_set("intl.default_locale", "nl"); $intlcal = new IntlGregorianCalendar(2012, 1, 29); var_dump( - $intlcal->getErrorCode(), - intlcal_get_error_code($intlcal), - $intlcal->getErrorMessage(), - intlcal_get_error_message($intlcal) + $intlcal->getErrorCode(), + intlcal_get_error_code($intlcal), + $intlcal->getErrorMessage(), + intlcal_get_error_message($intlcal) ); $intlcal->add(IntlCalendar::FIELD_SECOND, 2147483647); $intlcal->fieldDifference(-PHP_INT_MAX, IntlCalendar::FIELD_SECOND); var_dump( - $intlcal->getErrorCode(), - intlcal_get_error_code($intlcal), - $intlcal->getErrorMessage(), - intlcal_get_error_message($intlcal) + $intlcal->getErrorCode(), + intlcal_get_error_code($intlcal), + $intlcal->getErrorMessage(), + intlcal_get_error_message($intlcal) ); ?> --EXPECTF-- diff --git a/ext/intl/tests/calendar_getXMaximum_basic.phpt b/ext/intl/tests/calendar_getXMaximum_basic.phpt index d9591c632aae..82e77b8c8eb3 100644 --- a/ext/intl/tests/calendar_getXMaximum_basic.phpt +++ b/ext/intl/tests/calendar_getXMaximum_basic.phpt @@ -14,12 +14,12 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); var_dump( - $intlcal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), - intlcal_get_least_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), - $intlcal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), - intlcal_get_actual_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), - $intlcal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), - intlcal_get_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) + $intlcal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_least_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_actual_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) ); ?> diff --git a/ext/intl/tests/calendar_getXMinimum_basic.phpt b/ext/intl/tests/calendar_getXMinimum_basic.phpt index f8f951ed9d56..a1f52b361d29 100644 --- a/ext/intl/tests/calendar_getXMinimum_basic.phpt +++ b/ext/intl/tests/calendar_getXMinimum_basic.phpt @@ -14,12 +14,12 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); var_dump( - $intlcal->getGreatestMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), - intlcal_get_greatest_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), - $intlcal->getActualMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), - intlcal_get_actual_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), - $intlcal->getMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), - intlcal_get_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) + $intlcal->getGreatestMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_greatest_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getActualMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_actual_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) ); ?> diff --git a/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt index 828f6a71d0b4..211636cd63e5 100644 --- a/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt +++ b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt @@ -28,24 +28,24 @@ echo "error: $errno, $errstr\n"; set_error_handler('eh'); try { - var_dump(intlcal_get_least_maximum(1, 1)); + var_dump(intlcal_get_least_maximum(1, 1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_maximum(1, 1)); + var_dump(intlcal_get_maximum(1, 1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_greatest_minimum(1, -1)); + var_dump(intlcal_get_greatest_minimum(1, -1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_minimum(1, -1)); + var_dump(intlcal_get_minimum(1, -1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } --EXPECTF-- Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: invalid field in %s on line %d diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt index 22a4b859ab1b..5921d0c0d38b 100644 --- a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt +++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt @@ -18,67 +18,67 @@ echo "error: $errno, $errstr\n"; set_error_handler('eh'); try { - var_dump(intlcal_get($c)); + var_dump(intlcal_get($c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_maximum($c)); + var_dump(intlcal_get_actual_maximum($c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_minimum($c)); + var_dump(intlcal_get_actual_minimum($c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get($c, -1)); + var_dump(intlcal_get($c, -1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_maximum($c, -1)); + var_dump(intlcal_get_actual_maximum($c, -1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_minimum($c, -1)); + var_dump(intlcal_get_actual_minimum($c, -1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get($c, "s")); + var_dump(intlcal_get($c, "s")); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_maximum($c, "s")); + var_dump(intlcal_get_actual_maximum($c, "s")); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_minimum($c, "s")); + var_dump(intlcal_get_actual_minimum($c, "s")); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get(1)); + var_dump(intlcal_get(1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_maximum(1)); + var_dump(intlcal_get_actual_maximum(1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_get_actual_minimum(1)); + var_dump(intlcal_get_actual_minimum(1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } --EXPECT-- error: 0, intlcal_get() expects exactly 2 parameters, 1 given diff --git a/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt index e789840e007d..83e6b846453f 100644 --- a/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt +++ b/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt @@ -18,8 +18,8 @@ var_dump($intlcal->getRepeatedWallTimeOption()); $intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); $intlcal->set(IntlCalendar::FIELD_MINUTE, 30); var_dump( - strtotime('2012-10-28 02:30:00 +0100'), - (int)($intlcal->getTime() /1000) + strtotime('2012-10-28 02:30:00 +0100'), + (int)($intlcal->getTime() /1000) ); var_dump(intlcal_set_repeated_wall_time_option($intlcal, IntlCalendar::WALLTIME_FIRST)); @@ -27,8 +27,8 @@ var_dump(intlcal_get_repeated_wall_time_option($intlcal)); $intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); $intlcal->set(IntlCalendar::FIELD_MINUTE, 30); var_dump( - strtotime('2012-10-28 02:30:00 +0200'), - (int)($intlcal->getTime() /1000) + strtotime('2012-10-28 02:30:00 +0200'), + (int)($intlcal->getTime() /1000) ); ?> diff --git a/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt index 4cefc4126ca0..2f96aaf96df3 100644 --- a/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt +++ b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt @@ -18,8 +18,8 @@ $intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); $intlcal->set(IntlCalendar::FIELD_MINUTE, 30); echo "Should be 3h30\n"; var_dump( - $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), - $intlcal->get(IntlCalendar::FIELD_MINUTE) + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) ); var_dump($intlcal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST)); @@ -28,8 +28,8 @@ $intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); $intlcal->set(IntlCalendar::FIELD_MINUTE, 30); echo "Should be 1h30\n"; var_dump( - $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), - $intlcal->get(IntlCalendar::FIELD_MINUTE) + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) ); var_dump(intlcal_set_skipped_wall_time_option($intlcal, IntlCalendar::WALLTIME_NEXT_VALID)); @@ -38,8 +38,8 @@ $intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); $intlcal->set(IntlCalendar::FIELD_MINUTE, 30); echo "Should be 3h00\n"; var_dump( - $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), - $intlcal->get(IntlCalendar::FIELD_MINUTE) + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) ); diff --git a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt index f856f6a2ad7f..5e78c0b92c75 100644 --- a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt +++ b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt @@ -16,14 +16,14 @@ $intlcal4 = IntlCalendar::createInstance('Europe/Amsterdam'); $intlcal4->roll(IntlCalendar::FIELD_MONTH, true); var_dump( - "1 - 1", - $intlcal1->isEquivalentTo($intlcal1), - "1 - 2", - $intlcal1->isEquivalentTo($intlcal2), - "1 - 3", - $intlcal1->isEquivalentTo($intlcal3), - "1 - 4", - $intlcal1->isEquivalentTo($intlcal4) + "1 - 1", + $intlcal1->isEquivalentTo($intlcal1), + "1 - 2", + $intlcal1->isEquivalentTo($intlcal2), + "1 - 3", + $intlcal1->isEquivalentTo($intlcal3), + "1 - 4", + $intlcal1->isEquivalentTo($intlcal4) ); ?> diff --git a/ext/intl/tests/calendar_isEquivalentTo_error.phpt b/ext/intl/tests/calendar_isEquivalentTo_error.phpt index 9faecdd7e109..ce1536f92021 100644 --- a/ext/intl/tests/calendar_isEquivalentTo_error.phpt +++ b/ext/intl/tests/calendar_isEquivalentTo_error.phpt @@ -18,35 +18,35 @@ echo "error: $errno, $errstr\n"; set_error_handler('eh'); try { - var_dump($c->isEquivalentTo(0)); + var_dump($c->isEquivalentTo(0)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->isEquivalentTo($c, 1)); + var_dump($c->isEquivalentTo($c, 1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->isEquivalentTo(1)); + var_dump($c->isEquivalentTo(1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_is_equivalent_to($c)); + var_dump(intlcal_is_equivalent_to($c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_is_equivalent_to($c, 1)); + var_dump(intlcal_is_equivalent_to($c, 1)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump(intlcal_is_equivalent_to(1, $c)); + var_dump(intlcal_is_equivalent_to(1, $c)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } --EXPECT-- error: 0, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, int given diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt index d2e0867c29cc..5ca4afc918f4 100644 --- a/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt +++ b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt @@ -11,11 +11,11 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); var_dump( - IntlCalendar::DOW_TUESDAY, - $intlcal->setFirstDayOfWeek(IntlCalendar::DOW_TUESDAY), - $intlcal->getFirstDayOfWeek(), - intlcal_set_first_day_of_week($intlcal, IntlCalendar::DOW_WEDNESDAY), - $intlcal->getFirstDayOfWeek() + IntlCalendar::DOW_TUESDAY, + $intlcal->setFirstDayOfWeek(IntlCalendar::DOW_TUESDAY), + $intlcal->getFirstDayOfWeek(), + intlcal_set_first_day_of_week($intlcal, IntlCalendar::DOW_WEDNESDAY), + $intlcal->getFirstDayOfWeek() ); ?> --EXPECT-- diff --git a/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt b/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt index 455bd8436892..e2566085310c 100644 --- a/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt +++ b/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt @@ -11,10 +11,10 @@ ini_set("intl.default_locale", "nl"); $intlcal = IntlCalendar::createInstance('UTC'); var_dump( - $intlcal->setMinimalDaysInFirstWeek(6), - $intlcal->getMinimalDaysInFirstWeek(), - intlcal_set_minimal_days_in_first_week($intlcal, 5), - $intlcal->getMinimalDaysInFirstWeek() + $intlcal->setMinimalDaysInFirstWeek(6), + $intlcal->getMinimalDaysInFirstWeek(), + intlcal_set_minimal_days_in_first_week($intlcal, 5), + $intlcal->getMinimalDaysInFirstWeek() ); ?> --EXPECT-- diff --git a/ext/intl/tests/calendar_setTimeZone_basic.phpt b/ext/intl/tests/calendar_setTimeZone_basic.phpt index bfd4f43a42fd..7e52589b81b3 100644 --- a/ext/intl/tests/calendar_setTimeZone_basic.phpt +++ b/ext/intl/tests/calendar_setTimeZone_basic.phpt @@ -20,7 +20,7 @@ echo "\n"; var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); intlcal_set_time_zone($intlcal, - IntlTimeZone::createTimeZone('GMT+05:30')); + IntlTimeZone::createTimeZone('GMT+05:30')); print_r($intlcal->getTimeZone()->getID()); echo "\n"; var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); diff --git a/ext/intl/tests/calendar_setTimeZone_error.phpt b/ext/intl/tests/calendar_setTimeZone_error.phpt index 3f5e479e7957..c44208d1cef1 100644 --- a/ext/intl/tests/calendar_setTimeZone_error.phpt +++ b/ext/intl/tests/calendar_setTimeZone_error.phpt @@ -20,25 +20,25 @@ echo "error: $errno, $errstr\n"; set_error_handler('eh'); try { - var_dump($c->setTimeZone($gmt, 2)); + var_dump($c->setTimeZone($gmt, 2)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try { - var_dump($c->setTimeZone()); + var_dump($c->setTimeZone()); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try{ - var_dump(intlcal_set_time_zone($c, 1, 2)); + var_dump(intlcal_set_time_zone($c, 1, 2)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } try{ - var_dump(intlcal_set_time_zone(1, $gmt)); + var_dump(intlcal_set_time_zone(1, $gmt)); } catch (Error $ex) { - echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; + echo "error: " . $ex->getCode() . ", " . $ex->getMessage() . "\n\n"; } --EXPECT-- error: 0, IntlCalendar::setTimeZone() expects exactly 1 parameter, 2 given diff --git a/ext/intl/tests/calendar_setTime_basic.phpt b/ext/intl/tests/calendar_setTime_basic.phpt index 91ccc10fad71..075ecaabb529 100644 --- a/ext/intl/tests/calendar_setTime_basic.phpt +++ b/ext/intl/tests/calendar_setTime_basic.phpt @@ -17,8 +17,8 @@ $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->setTime($time * 1000); var_dump( - (float)$time*1000, - $intlcal->getTime()); + (float)$time*1000, + $intlcal->getTime()); $intlcal = IntlCalendar::createInstance('UTC'); intlcal_set_time($intlcal,$time * 1000); diff --git a/ext/intl/tests/calendar_set_variation1.phpt b/ext/intl/tests/calendar_set_variation1.phpt index 8738d30711a5..6a78cf213c03 100644 --- a/ext/intl/tests/calendar_set_variation1.phpt +++ b/ext/intl/tests/calendar_set_variation1.phpt @@ -15,16 +15,16 @@ $intlcal = IntlCalendar::createInstance('UTC'); $intlcal->clear(); var_dump($intlcal->set(2012, 1, 29)); var_dump($intlcal->getTime(), - strtotime('2012-02-29 00:00:00 +0000') * 1000.); + strtotime('2012-02-29 00:00:00 +0000') * 1000.); //two minutes to midnight! var_dump($intlcal->set(2012, 1, 29, 23, 58)); var_dump($intlcal->getTime(), - strtotime('2012-02-29 23:58:00 +0000') * 1000.); + strtotime('2012-02-29 23:58:00 +0000') * 1000.); var_dump($intlcal->set(2012, 1, 29, 23, 58, 31)); var_dump($intlcal->getTime(), - strtotime('2012-02-29 23:58:31 +0000') * 1000.); + strtotime('2012-02-29 23:58:31 +0000') * 1000.); ?> --EXPECT-- diff --git a/ext/intl/tests/collator_asort.phpt b/ext/intl/tests/collator_asort.phpt index 0b3d0ee79585..7f0af9507976 100644 --- a/ext/intl/tests/collator_asort.phpt +++ b/ext/intl/tests/collator_asort.phpt @@ -31,7 +31,7 @@ function sort_arrays( $locale, $test_arrays, $sort_flag = Collator::SORT_REGULAR $res_dump = "\n" . dump( $test_array ) . "\n Result: " . dump( $res_val ); - // Preppend test signature to output string + // Preppend test signature to output string $md5 = md5( $res_dump ); global $test_num; diff --git a/ext/intl/tests/collator_asort_variant2.phpt b/ext/intl/tests/collator_asort_variant2.phpt index 08725095b526..a5a16e5aeba5 100644 --- a/ext/intl/tests/collator_asort_variant2.phpt +++ b/ext/intl/tests/collator_asort_variant2.phpt @@ -31,7 +31,7 @@ function sort_arrays( $locale, $test_arrays, $sort_flag = Collator::SORT_REGULAR $res_dump = "\n" . dump( $test_array ) . "\n Result: " . dump( $res_val ); - // Preppend test signature to output string + // Preppend test signature to output string $md5 = md5( $res_dump ); global $test_num; diff --git a/ext/intl/tests/collator_create2.phpt b/ext/intl/tests/collator_create2.phpt index 292e3cebb5d5..27f0381992d3 100644 --- a/ext/intl/tests/collator_create2.phpt +++ b/ext/intl/tests/collator_create2.phpt @@ -22,7 +22,7 @@ function ut_main() '', 'root', 'uk@currency=EURO', - '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' + '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' ); foreach( $locales as $locale ) diff --git a/ext/intl/tests/collator_create3.phpt b/ext/intl/tests/collator_create3.phpt index 8d9308aca183..1060c7232664 100644 --- a/ext/intl/tests/collator_create3.phpt +++ b/ext/intl/tests/collator_create3.phpt @@ -23,7 +23,7 @@ function ut_main() '', 'root', 'uk@currency=EURO', - '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' + '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' ); foreach( $locales as $locale ) diff --git a/ext/intl/tests/collator_create4.phpt b/ext/intl/tests/collator_create4.phpt index 509a89913bca..dafeaf4e87cb 100644 --- a/ext/intl/tests/collator_create4.phpt +++ b/ext/intl/tests/collator_create4.phpt @@ -22,7 +22,7 @@ function ut_main() '', 'root', 'uk@currency=EURO', - '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' + '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' ); foreach( $locales as $locale ) diff --git a/ext/intl/tests/collator_get_sort_key.phpt b/ext/intl/tests/collator_get_sort_key.phpt index 62cc3a7b113f..b7cd8bb5ec0e 100644 --- a/ext/intl/tests/collator_get_sort_key.phpt +++ b/ext/intl/tests/collator_get_sort_key.phpt @@ -16,11 +16,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -32,9 +32,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -42,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_get_sort_key_variant2.phpt b/ext/intl/tests/collator_get_sort_key_variant2.phpt index 3c526fbc3cec..ab3fc64e327c 100644 --- a/ext/intl/tests/collator_get_sort_key_variant2.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant2.phpt @@ -16,11 +16,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -32,9 +32,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -42,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_get_sort_key_variant3.phpt b/ext/intl/tests/collator_get_sort_key_variant3.phpt index f4cb88e3e7ac..9e84ad4168de 100644 --- a/ext/intl/tests/collator_get_sort_key_variant3.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant3.phpt @@ -16,11 +16,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -32,9 +32,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -42,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_get_sort_key_variant4.phpt b/ext/intl/tests/collator_get_sort_key_variant4.phpt index bd7af6a284e4..078a385d5cdb 100644 --- a/ext/intl/tests/collator_get_sort_key_variant4.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant4.phpt @@ -16,11 +16,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -32,9 +32,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -42,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_get_sort_key_variant5.phpt b/ext/intl/tests/collator_get_sort_key_variant5.phpt index c7717389b7e0..38d96cf2d8be 100644 --- a/ext/intl/tests/collator_get_sort_key_variant5.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant5.phpt @@ -16,11 +16,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -32,9 +32,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -42,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_get_sort_key_variant6.phpt b/ext/intl/tests/collator_get_sort_key_variant6.phpt index 78c74f546a4c..54e7486816e4 100644 --- a/ext/intl/tests/collator_get_sort_key_variant6.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant6.phpt @@ -16,11 +16,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -32,9 +32,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -42,7 +42,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_get_sort_key_variant7.phpt b/ext/intl/tests/collator_get_sort_key_variant7.phpt index e009d0e66388..8ac0154d4fcf 100644 --- a/ext/intl/tests/collator_get_sort_key_variant7.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant7.phpt @@ -15,11 +15,11 @@ function sort_arrays( $locale, $data ) $coll = ut_coll_create( $locale ); - foreach($data as $value) { - $res_val = ut_coll_get_sort_key( $coll, $value ); - $res_str .= "source: ".$value."\n". - "key: ".bin2hex($res_val)."\n"; - } + foreach($data as $value) { + $res_val = ut_coll_get_sort_key( $coll, $value ); + $res_str .= "source: ".$value."\n". + "key: ".bin2hex($res_val)."\n"; + } return $res_str; } @@ -31,9 +31,9 @@ function ut_main() // Regular strings keys $test_params = array( - 'abc', 'abd', 'aaa', - 'аа', 'а', 'z', - '', null , '3', + 'abc', 'abd', 'aaa', + 'аа', 'а', 'z', + '', null , '3', 'y' , 'i' , 'k' ); @@ -41,7 +41,7 @@ function ut_main() // Sort a non-ASCII array using ru_RU locale. $test_params = array( - 'абг', 'абв', 'жжж', 'ÑÑŽÑ' + 'абг', 'абв', 'жжж', 'ÑÑŽÑ' ); $res_str .= sort_arrays( 'ru_RU', $test_params ); diff --git a/ext/intl/tests/collator_sort.phpt b/ext/intl/tests/collator_sort.phpt index 4f7a12352a37..1c4cb78cc8bc 100644 --- a/ext/intl/tests/collator_sort.phpt +++ b/ext/intl/tests/collator_sort.phpt @@ -32,7 +32,7 @@ function sort_arrays( $locale, $arrays, $sort_flag = Collator::SORT_REGULAR ) $res_dump = "\n" . dump( $array ) . "\n Result: " . dump( $res_val ); - // Preppend test signature to output string + // Preppend test signature to output string $md5 = md5( $res_dump ); global $test_num; diff --git a/ext/intl/tests/collator_sort_variant2.phpt b/ext/intl/tests/collator_sort_variant2.phpt index abb302eda653..3838c881add8 100644 --- a/ext/intl/tests/collator_sort_variant2.phpt +++ b/ext/intl/tests/collator_sort_variant2.phpt @@ -32,7 +32,7 @@ function sort_arrays( $locale, $arrays, $sort_flag = Collator::SORT_REGULAR ) $res_dump = "\n" . dump( $array ) . "\n Result: " . dump( $res_val ); - // Preppend test signature to output string + // Preppend test signature to output string $md5 = md5( $res_dump ); global $test_num; diff --git a/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt b/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt index 08aa01e90bd4..a1c33cf230ef 100644 --- a/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt +++ b/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt @@ -20,25 +20,25 @@ var_dump($codepoint_it->getLastCodePoint()); //before the last read codepoint is moving backwards $p = $codepoint_it->first(); while ($p != IntlBreakIterator::DONE) { - $c = $codepoint_it->getLastCodePoint(); - if ($c > 0) - var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); - else - var_dump($c); - //it's a post-increment operation as to the codepoint, i.e., it gives the codepoint - //starting at the initial position and only then moves the pointer forward - $p = $codepoint_it->next(); + $c = $codepoint_it->getLastCodePoint(); + if ($c > 0) + var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); + else + var_dump($c); + //it's a post-increment operation as to the codepoint, i.e., it gives the codepoint + //starting at the initial position and only then moves the pointer forward + $p = $codepoint_it->next(); } echo "Now backwards\n"; $p = $codepoint_it->last(); while ($p != IntlBreakIterator::DONE) { - $c = $codepoint_it->getLastCodePoint(); - if ($c > 0) - var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); - else - var_dump($c); - $p = $codepoint_it->previous(); + $c = $codepoint_it->getLastCodePoint(); + if ($c > 0) + var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); + else + var_dump($c); + $p = $codepoint_it->previous(); } diff --git a/ext/intl/tests/cpbi_parts_iterator.phpt b/ext/intl/tests/cpbi_parts_iterator.phpt index 82fea6f6e1e7..329c88c8b9eb 100644 --- a/ext/intl/tests/cpbi_parts_iterator.phpt +++ b/ext/intl/tests/cpbi_parts_iterator.phpt @@ -15,8 +15,8 @@ $it = IntlBreakIterator::createCodePointInstance()->getPartsIterator(); $it->getBreakIterator()->setText($text); foreach ($it as $k => $v) { - echo "$k. $v (" . sprintf("U+%04X", $it->getBreakIterator()->getLastCodePoint()) . - ") at {$it->getBreakIterator()->current()}\r\n"; + echo "$k. $v (" . sprintf("U+%04X", $it->getBreakIterator()->getLastCodePoint()) . + ") at {$it->getBreakIterator()->current()}\r\n"; } ?> diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt index 1b346abf6767..086bc013402b 100644 --- a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt +++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt @@ -11,23 +11,23 @@ ini_set("intl.default_locale", "pt_PT"); ini_set("date.timezone", 'Atlantic/Azores'); function print_exception($e) { - echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; + echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; } try { - var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone')); + var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone')); } catch (IntlException $e) { - print_exception($e); + print_exception($e); } try { - var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3)); + var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3)); } catch (IntlException $e) { - print_exception($e); + print_exception($e); } try { - var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass)); + var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass)); } catch (IntlException $e) { - print_exception($e); + print_exception($e); } ?> --EXPECTF-- diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt index 83c256b71362..1483f6105855 100644 --- a/ext/intl/tests/dateformat_calendars.phpt +++ b/ext/intl/tests/dateformat_calendars.phpt @@ -11,29 +11,29 @@ if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> ini_set("intl.error_level", E_WARNING); $fmt1 = new IntlDateFormatter('en_US', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::TRADITIONAL); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); $fmt2 = new IntlDateFormatter('en_US', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::GREGORIAN); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::GREGORIAN); $fmt3 = new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::TRADITIONAL); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + -1); ?> ==DONE== --EXPECTF-- diff --git a/ext/intl/tests/dateformat_calendars_variant2.phpt b/ext/intl/tests/dateformat_calendars_variant2.phpt index 8d051abe59e3..895d39094ab7 100644 --- a/ext/intl/tests/dateformat_calendars_variant2.phpt +++ b/ext/intl/tests/dateformat_calendars_variant2.phpt @@ -12,29 +12,29 @@ if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> ini_set("intl.error_level", E_WARNING); $fmt1 = new IntlDateFormatter('en_US', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::TRADITIONAL); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); $fmt2 = new IntlDateFormatter('en_US', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::GREGORIAN); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::GREGORIAN); $fmt3 = new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::TRADITIONAL); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + -1); ?> ==DONE== --EXPECTF-- diff --git a/ext/intl/tests/dateformat_calendars_variant3.phpt b/ext/intl/tests/dateformat_calendars_variant3.phpt index 65597d6b45ae..99e153e29087 100644 --- a/ext/intl/tests/dateformat_calendars_variant3.phpt +++ b/ext/intl/tests/dateformat_calendars_variant3.phpt @@ -11,29 +11,29 @@ if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?> ini_set("intl.error_level", E_WARNING); $fmt1 = new IntlDateFormatter('en_US', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::TRADITIONAL); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); $fmt2 = new IntlDateFormatter('en_US', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::GREGORIAN); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::GREGORIAN); $fmt3 = new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - IntlDateFormatter::TRADITIONAL); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + IntlDateFormatter::TRADITIONAL); var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'GMT+05:12', + -1); ?> ==DONE== --EXPECTF-- diff --git a/ext/intl/tests/dateformat_clone_bad_obj.phpt b/ext/intl/tests/dateformat_clone_bad_obj.phpt index f9791004f3c2..3425a1b0f808 100644 --- a/ext/intl/tests/dateformat_clone_bad_obj.phpt +++ b/ext/intl/tests/dateformat_clone_bad_obj.phpt @@ -6,14 +6,14 @@ Cloning unconstructed IntlDateFormatter getMessage()); + var_dump($e->getMessage()); } --EXPECTF-- string(%s) "Cannot clone unconstructed IntlDateFormatter" diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index 5b121558a0d4..9cdb69b848c0 100644 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt @@ -15,13 +15,13 @@ datefmt_format_code() function ut_main() { - $timezone = 'GMT-10:00'; + $timezone = 'GMT-10:00'; - $locale_arr = array ( - 'en_US' - ); + $locale_arr = array ( + 'en_US' + ); - $datetype_arr = array ( + $datetype_arr = array ( IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, @@ -32,34 +32,34 @@ function ut_main() $res_str = ''; - $time_arr = array ( - 0, - -1200000, - 1200000, - 2200000000.0, - -2200000000.0, - 90099999, - 3600, - -3600 - ); - - $localtime_arr1 = array ( - 'tm_sec' => 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 4, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( + $time_arr = array ( + 0, + -1200000, + 1200000, + 2200000000.0, + -2200000000.0, + 90099999, + 3600, + -3600 + ); + + $localtime_arr1 = array ( + 'tm_sec' => 24 , + 'tm_min' => 3, + 'tm_hour' => 19, + 'tm_mday' => 3, + 'tm_mon' => 3, + 'tm_year' => 105, + ); + $localtime_arr2 = array ( + 'tm_sec' => 21, + 'tm_min' => 5, + 'tm_hour' => 7, + 'tm_mday' => 13, + 'tm_mon' => 4, + 'tm_year' => 205, + ); + $localtime_arr3 = array ( 'tm_sec' => 11, 'tm_min' => 13, 'tm_hour' => 0, @@ -68,80 +68,80 @@ function ut_main() 'tm_year' => -5 ); - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); - $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); - $d2->setTimezone(new DateTimeZone("PDT")); - $dates = array( - $d1, - $d2, - new StdClass(), - ); - - //Test format with input as a timestamp : integer - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - } - } - } - - //Test format with input as a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ + $localtime_arr = array ( + $localtime_arr1, + $localtime_arr2, + $localtime_arr3 + ); + + $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); + $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); + $d2->setTimezone(new DateTimeZone("PDT")); + $dates = array( + $d1, + $d2, + new StdClass(), + ); + + //Test format with input as a timestamp : integer + foreach( $time_arr as $timestamp_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput timestamp is : $timestamp_entry"; + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); + $formatted = ut_datefmt_format( $fmt , $timestamp_entry); + $res_str .= "\nFormatted timestamp is : $formatted"; + } + } + } + + //Test format with input as a localtime :array + foreach( $localtime_arr as $localtime_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput localtime is : "; + foreach( $localtime_entry as $key => $value){ $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - foreach($dates as $date_entry) { - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\n------------"; - $res_str .= "\nDate is: ".var_export($date_entry, true); - $res_str .= "\n------------"; - - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $date_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted DateTime is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - return $res_str; + } + + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted localtime_array is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + } + } + } + + foreach($dates as $date_entry) { + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\n------------"; + $res_str .= "\nDate is: ".var_export($date_entry, true); + $res_str .= "\n------------"; + + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $date_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted DateTime is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + } + } + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt index 68f54eb7e705..ac7c5f8df9c5 100644 --- a/ext/intl/tests/dateformat_format_parse.phpt +++ b/ext/intl/tests/dateformat_format_parse.phpt @@ -13,13 +13,13 @@ datefmt_format_code() and datefmt_parse_code() function ut_main() { - $timezone = 'GMT+05:00'; + $timezone = 'GMT+05:00'; - $locale_arr = array ( - 'en_US' - ); + $locale_arr = array ( + 'en_US' + ); - $datetype_arr = array ( + $datetype_arr = array ( IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM @@ -28,34 +28,34 @@ function ut_main() $res_str = ''; - $time_arr = array ( - 0, - -1200000, - 1200000, - 2200000000, - -2200000000, - 90099999, - 3600, - -3600 - ); - - $localtime_arr1 = array ( - 'tm_sec' => 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 7, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( + $time_arr = array ( + 0, + -1200000, + 1200000, + 2200000000, + -2200000000, + 90099999, + 3600, + -3600 + ); + + $localtime_arr1 = array ( + 'tm_sec' => 24 , + 'tm_min' => 3, + 'tm_hour' => 19, + 'tm_mday' => 3, + 'tm_mon' => 3, + 'tm_year' => 105, + ); + $localtime_arr2 = array ( + 'tm_sec' => 21, + 'tm_min' => 5, + 'tm_hour' => 7, + 'tm_mday' => 13, + 'tm_mon' => 7, + 'tm_year' => 205, + ); + $localtime_arr3 = array ( 'tm_sec' => 11, 'tm_min' => 13, 'tm_hour' => 0, @@ -64,72 +64,72 @@ function ut_main() 'tm_year' => -5 ); - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - //Test format and parse with a timestamp : long - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - $parsed = ut_datefmt_parse( $fmt , $formatted); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nParsed timestamp is : $parsed"; - }else{ - $res_str .= "\nError while parsing as: '".intl_get_error_message()."'"; - } - } - } - } - - //Test format and parse with a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ + $localtime_arr = array ( + $localtime_arr1, + $localtime_arr2, + $localtime_arr3 + ); + + //Test format and parse with a timestamp : long + foreach( $time_arr as $timestamp_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput timestamp is : $timestamp_entry"; + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); + $formatted = ut_datefmt_format( $fmt , $timestamp_entry); + $res_str .= "\nFormatted timestamp is : $formatted"; + $parsed = ut_datefmt_parse( $fmt , $formatted); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nParsed timestamp is : $parsed"; + }else{ + $res_str .= "\nError while parsing as: '".intl_get_error_message()."'"; + } + } + } + } + + //Test format and parse with a localtime :array + foreach( $localtime_arr as $localtime_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput localtime is : "; + foreach( $localtime_entry as $key => $value){ $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - //Parsing - $parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 ); - - if( $parsed_arr){ - $res_str .= "\nParsed array is: "; - foreach( $parsed_arr as $key => $value){ - $res_str .= "$key : '$value' , "; - } - } + } + + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); + $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted localtime_array is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + //Parsing + $parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 ); + + if( $parsed_arr){ + $res_str .= "\nParsed array is: "; + foreach( $parsed_arr as $key => $value){ + $res_str .= "$key : '$value' , "; + } + } /* - else{ - //$res_str .= "No values found from LocaleTime parsing."; - $res_str .= "\tError : '".intl_get_error_message()."'"; - } + else{ + //$res_str .= "No values found from LocaleTime parsing."; + $res_str .= "\tError : '".intl_get_error_message()."'"; + } */ - } - } - } + } + } + } - return $res_str; + return $res_str; } diff --git a/ext/intl/tests/dateformat_format_parse_version2.phpt b/ext/intl/tests/dateformat_format_parse_version2.phpt index f672cd6d2213..1820e52e91b5 100644 --- a/ext/intl/tests/dateformat_format_parse_version2.phpt +++ b/ext/intl/tests/dateformat_format_parse_version2.phpt @@ -13,13 +13,13 @@ datefmt_format_code() and datefmt_parse_code() function ut_main() { - $timezone = 'GMT+05:00'; + $timezone = 'GMT+05:00'; - $locale_arr = array ( - 'en_US' - ); + $locale_arr = array ( + 'en_US' + ); - $datetype_arr = array ( + $datetype_arr = array ( IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM @@ -28,34 +28,34 @@ function ut_main() $res_str = ''; - $time_arr = array ( - 0, - -1200000, - 1200000, - 2200000000, - -2200000000, - 90099999, - 3600, - -3600 - ); - - $localtime_arr1 = array ( - 'tm_sec' => 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 7, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( + $time_arr = array ( + 0, + -1200000, + 1200000, + 2200000000, + -2200000000, + 90099999, + 3600, + -3600 + ); + + $localtime_arr1 = array ( + 'tm_sec' => 24 , + 'tm_min' => 3, + 'tm_hour' => 19, + 'tm_mday' => 3, + 'tm_mon' => 3, + 'tm_year' => 105, + ); + $localtime_arr2 = array ( + 'tm_sec' => 21, + 'tm_min' => 5, + 'tm_hour' => 7, + 'tm_mday' => 13, + 'tm_mon' => 7, + 'tm_year' => 205, + ); + $localtime_arr3 = array ( 'tm_sec' => 11, 'tm_min' => 13, 'tm_hour' => 0, @@ -64,72 +64,72 @@ function ut_main() 'tm_year' => -5 ); - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - //Test format and parse with a timestamp : long - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - $parsed = ut_datefmt_parse( $fmt , $formatted); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nParsed timestamp is : $parsed"; - }else{ - $res_str .= "\nError while parsing as: '".intl_get_error_message()."'"; - } - } - } - } - - //Test format and parse with a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ + $localtime_arr = array ( + $localtime_arr1, + $localtime_arr2, + $localtime_arr3 + ); + + //Test format and parse with a timestamp : long + foreach( $time_arr as $timestamp_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput timestamp is : $timestamp_entry"; + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); + $formatted = ut_datefmt_format( $fmt , $timestamp_entry); + $res_str .= "\nFormatted timestamp is : $formatted"; + $parsed = ut_datefmt_parse( $fmt , $formatted); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nParsed timestamp is : $parsed"; + }else{ + $res_str .= "\nError while parsing as: '".intl_get_error_message()."'"; + } + } + } + } + + //Test format and parse with a localtime :array + foreach( $localtime_arr as $localtime_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput localtime is : "; + foreach( $localtime_entry as $key => $value){ $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - //Parsing - $parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 ); - - if( $parsed_arr){ - $res_str .= "\nParsed array is: "; - foreach( $parsed_arr as $key => $value){ - $res_str .= "$key : '$value' , "; - } - } + } + + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); + $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted localtime_array is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + //Parsing + $parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 ); + + if( $parsed_arr){ + $res_str .= "\nParsed array is: "; + foreach( $parsed_arr as $key => $value){ + $res_str .= "$key : '$value' , "; + } + } /* - else{ - //$res_str .= "No values found from LocaleTime parsing."; - $res_str .= "\tError : '".intl_get_error_message()."'"; - } + else{ + //$res_str .= "No values found from LocaleTime parsing."; + $res_str .= "\tError : '".intl_get_error_message()."'"; + } */ - } - } - } + } + } + } - return $res_str; + return $res_str; } diff --git a/ext/intl/tests/dateformat_format_variant2.phpt b/ext/intl/tests/dateformat_format_variant2.phpt index d61b20b03a3a..b02cfcd9e62b 100644 --- a/ext/intl/tests/dateformat_format_variant2.phpt +++ b/ext/intl/tests/dateformat_format_variant2.phpt @@ -15,13 +15,13 @@ datefmt_format_code() function ut_main() { - $timezone = 'GMT-10:00'; + $timezone = 'GMT-10:00'; - $locale_arr = array ( - 'en_US' - ); + $locale_arr = array ( + 'en_US' + ); - $datetype_arr = array ( + $datetype_arr = array ( IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, @@ -32,34 +32,34 @@ function ut_main() $res_str = ''; - $time_arr = array ( - 0, - -1200000, - 1200000, - 2200000000.0, - -2200000000.0, - 90099999, - 3600, - -3600 - ); - - $localtime_arr1 = array ( - 'tm_sec' => 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 4, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( + $time_arr = array ( + 0, + -1200000, + 1200000, + 2200000000.0, + -2200000000.0, + 90099999, + 3600, + -3600 + ); + + $localtime_arr1 = array ( + 'tm_sec' => 24 , + 'tm_min' => 3, + 'tm_hour' => 19, + 'tm_mday' => 3, + 'tm_mon' => 3, + 'tm_year' => 105, + ); + $localtime_arr2 = array ( + 'tm_sec' => 21, + 'tm_min' => 5, + 'tm_hour' => 7, + 'tm_mday' => 13, + 'tm_mon' => 4, + 'tm_year' => 205, + ); + $localtime_arr3 = array ( 'tm_sec' => 11, 'tm_min' => 13, 'tm_hour' => 0, @@ -68,80 +68,80 @@ function ut_main() 'tm_year' => -5 ); - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); - $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); - $d2->setTimezone(new DateTimeZone("PDT")); - $dates = array( - $d1, - $d2, - new StdClass(), - ); - - //Test format with input as a timestamp : integer - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - } - } - } - - //Test format with input as a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ + $localtime_arr = array ( + $localtime_arr1, + $localtime_arr2, + $localtime_arr3 + ); + + $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); + $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); + $d2->setTimezone(new DateTimeZone("PDT")); + $dates = array( + $d1, + $d2, + new StdClass(), + ); + + //Test format with input as a timestamp : integer + foreach( $time_arr as $timestamp_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput timestamp is : $timestamp_entry"; + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); + $formatted = ut_datefmt_format( $fmt , $timestamp_entry); + $res_str .= "\nFormatted timestamp is : $formatted"; + } + } + } + + //Test format with input as a localtime :array + foreach( $localtime_arr as $localtime_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput localtime is : "; + foreach( $localtime_entry as $key => $value){ $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - foreach($dates as $date_entry) { - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\n------------"; - $res_str .= "\nDate is: ".var_export($date_entry, true); - $res_str .= "\n------------"; - - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $date_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted DateTime is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - return $res_str; + } + + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted localtime_array is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + } + } + } + + foreach($dates as $date_entry) { + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\n------------"; + $res_str .= "\nDate is: ".var_export($date_entry, true); + $res_str .= "\n------------"; + + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $date_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted DateTime is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + } + } + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_format_variant3.phpt b/ext/intl/tests/dateformat_format_variant3.phpt index e2f9ec81b0a5..52705a3f03f0 100644 --- a/ext/intl/tests/dateformat_format_variant3.phpt +++ b/ext/intl/tests/dateformat_format_variant3.phpt @@ -15,13 +15,13 @@ datefmt_format_code() function ut_main() { - $timezone = 'GMT-10:00'; + $timezone = 'GMT-10:00'; - $locale_arr = array ( - 'en_US' - ); + $locale_arr = array ( + 'en_US' + ); - $datetype_arr = array ( + $datetype_arr = array ( IntlDateFormatter::FULL, IntlDateFormatter::LONG, IntlDateFormatter::MEDIUM, @@ -32,34 +32,34 @@ function ut_main() $res_str = ''; - $time_arr = array ( - 0, - -1200000, - 1200000, - 2200000000.0, - -2200000000.0, - 90099999, - 3600, - -3600 - ); - - $localtime_arr1 = array ( - 'tm_sec' => 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 4, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( + $time_arr = array ( + 0, + -1200000, + 1200000, + 2200000000.0, + -2200000000.0, + 90099999, + 3600, + -3600 + ); + + $localtime_arr1 = array ( + 'tm_sec' => 24 , + 'tm_min' => 3, + 'tm_hour' => 19, + 'tm_mday' => 3, + 'tm_mon' => 3, + 'tm_year' => 105, + ); + $localtime_arr2 = array ( + 'tm_sec' => 21, + 'tm_min' => 5, + 'tm_hour' => 7, + 'tm_mday' => 13, + 'tm_mon' => 4, + 'tm_year' => 205, + ); + $localtime_arr3 = array ( 'tm_sec' => 11, 'tm_min' => 13, 'tm_hour' => 0, @@ -68,80 +68,80 @@ function ut_main() 'tm_year' => -5 ); - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); - $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); - $d2->setTimezone(new DateTimeZone("PDT")); - $dates = array( - $d1, - $d2, - new StdClass(), - ); - - //Test format with input as a timestamp : integer - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - } - } - } - - //Test format with input as a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ + $localtime_arr = array ( + $localtime_arr1, + $localtime_arr2, + $localtime_arr3 + ); + + $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); + $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); + $d2->setTimezone(new DateTimeZone("PDT")); + $dates = array( + $d1, + $d2, + new StdClass(), + ); + + //Test format with input as a timestamp : integer + foreach( $time_arr as $timestamp_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput timestamp is : $timestamp_entry"; + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); + $formatted = ut_datefmt_format( $fmt , $timestamp_entry); + $res_str .= "\nFormatted timestamp is : $formatted"; + } + } + } + + //Test format with input as a localtime :array + foreach( $localtime_arr as $localtime_entry){ + $res_str .= "\n------------\n"; + $res_str .= "\nInput localtime is : "; + foreach( $localtime_entry as $key => $value){ $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - foreach($dates as $date_entry) { - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\n------------"; - $res_str .= "\nDate is: ".var_export($date_entry, true); - $res_str .= "\n------------"; - - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $date_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted DateTime is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - return $res_str; + } + + $res_str .= "\n------------\n"; + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted localtime_array is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + } + } + } + + foreach($dates as $date_entry) { + foreach( $locale_arr as $locale_entry ){ + foreach( $datetype_arr as $datetype_entry ) { + $res_str .= "\n------------"; + $res_str .= "\nDate is: ".var_export($date_entry, true); + $res_str .= "\n------------"; + + $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); + $formatted1 = ut_datefmt_format( $fmt , $date_entry); + if( intl_get_error_code() == U_ZERO_ERROR){ + $res_str .= "\nFormatted DateTime is : $formatted1"; + }else{ + $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; + } + } + } + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_get_datetype.phpt b/ext/intl/tests/dateformat_get_datetype.phpt index ec03bb68f489..27c9188d1034 100644 --- a/ext/intl/tests/dateformat_get_datetype.phpt +++ b/ext/intl/tests/dateformat_get_datetype.phpt @@ -12,26 +12,26 @@ datefmt_get_datetype_code() function ut_main() { - $datetype_arr = array ( - IntlDateFormatter::FULL, - IntlDateFormatter::LONG, - IntlDateFormatter::MEDIUM, - IntlDateFormatter::SHORT, - IntlDateFormatter::NONE - ); - - $res_str = ''; - - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nCreating IntlDateFormatter with date_type = $datetype_entry"; - $fmt = ut_datefmt_create( "de-DE", $datetype_entry , IntlDateFormatter::SHORT,'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); - $date_type = ut_datefmt_get_datetype( $fmt); - $res_str .= "\nAfter call to get_datetype : datetype= $date_type"; - $res_str .= "\n"; - } - - return $res_str; + $datetype_arr = array ( + IntlDateFormatter::FULL, + IntlDateFormatter::LONG, + IntlDateFormatter::MEDIUM, + IntlDateFormatter::SHORT, + IntlDateFormatter::NONE + ); + + $res_str = ''; + + foreach( $datetype_arr as $datetype_entry ) + { + $res_str .= "\nCreating IntlDateFormatter with date_type = $datetype_entry"; + $fmt = ut_datefmt_create( "de-DE", $datetype_entry , IntlDateFormatter::SHORT,'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); + $date_type = ut_datefmt_get_datetype( $fmt); + $res_str .= "\nAfter call to get_datetype : datetype= $date_type"; + $res_str .= "\n"; + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_get_locale.phpt b/ext/intl/tests/dateformat_get_locale.phpt index aa7a0a46c3f2..2078c7b6dbb7 100644 --- a/ext/intl/tests/dateformat_get_locale.phpt +++ b/ext/intl/tests/dateformat_get_locale.phpt @@ -14,31 +14,31 @@ if (PHP_INT_SIZE != 8) die('skip 64-bit only'); function ut_main() { - $locale_arr = array ( - 'de-DE', - 'sl-IT-nedis', - 'en_UK', - 'hi' - ); - - $res_str = ''; - - foreach( $locale_arr as $locale_entry ) - { - $res_str .= "\nCreating IntlDateFormatter with locale = $locale_entry"; - $fmt = ut_datefmt_create( $locale_entry , IntlDateFormatter::SHORT,IntlDateFormatter::SHORT,'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); - $locale = ut_datefmt_get_locale( $fmt , 1); - $res_str .= "\nAfter call to get_locale : locale= $locale"; - $res_str .= "\n"; - } - $badvals = array(100, -1, 4294901761); - foreach($badvals as $badval) { - if(ut_datefmt_get_locale($fmt, $badval)) { - $res_str .= "datefmt_get_locale should return false for bad argument $badval\n"; - } - } - - return $res_str; + $locale_arr = array ( + 'de-DE', + 'sl-IT-nedis', + 'en_UK', + 'hi' + ); + + $res_str = ''; + + foreach( $locale_arr as $locale_entry ) + { + $res_str .= "\nCreating IntlDateFormatter with locale = $locale_entry"; + $fmt = ut_datefmt_create( $locale_entry , IntlDateFormatter::SHORT,IntlDateFormatter::SHORT,'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); + $locale = ut_datefmt_get_locale( $fmt , 1); + $res_str .= "\nAfter call to get_locale : locale= $locale"; + $res_str .= "\n"; + } + $badvals = array(100, -1, 4294901761); + foreach($badvals as $badval) { + if(ut_datefmt_get_locale($fmt, $badval)) { + $res_str .= "datefmt_get_locale should return false for bad argument $badval\n"; + } + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_get_set_pattern2.phpt b/ext/intl/tests/dateformat_get_set_pattern2.phpt index b741906ad6d4..11a5899883e6 100644 --- a/ext/intl/tests/dateformat_get_set_pattern2.phpt +++ b/ext/intl/tests/dateformat_get_set_pattern2.phpt @@ -14,7 +14,7 @@ function ut_main() { $pattern_arr = array ( 'DD-MM-YYYY hh:mm:ss', - 'yyyy-DDD.hh:mm:ss z', + 'yyyy-DDD.hh:mm:ss z', "yyyy/MM/dd", "yyyyMMdd" ); @@ -27,8 +27,8 @@ function ut_main() $fmt = ut_datefmt_create( "en-US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN , $start_pattern ); $pattern = ut_datefmt_get_pattern( $fmt); $res_str .= "\nAfter call to get_pattern : pattern= $pattern"; - $formatted = ut_datefmt_format($fmt,0); - $res_str .= "\nResult of formatting timestamp=0 is : \n$formatted"; + $formatted = ut_datefmt_format($fmt,0); + $res_str .= "\nResult of formatting timestamp=0 is : \n$formatted"; foreach( $pattern_arr as $pattern_entry ) @@ -38,7 +38,7 @@ function ut_main() ut_datefmt_set_pattern( $fmt , $pattern_entry ); $pattern = ut_datefmt_get_pattern( $fmt); $res_str .= "\nAfter call to get_pattern : pattern= $pattern"; - $formatted = ut_datefmt_format($fmt,0); + $formatted = ut_datefmt_format($fmt,0); $res_str .= "\nResult of formatting timestamp=0 with the new pattern is : \n$formatted"; $res_str .= "\n"; diff --git a/ext/intl/tests/dateformat_get_timetype.phpt b/ext/intl/tests/dateformat_get_timetype.phpt index cca3c6f96a32..59a8f5e11218 100644 --- a/ext/intl/tests/dateformat_get_timetype.phpt +++ b/ext/intl/tests/dateformat_get_timetype.phpt @@ -12,26 +12,26 @@ datefmt_get_timetype_code() function ut_main() { - $timetype_arr = array ( - IntlDateFormatter::FULL, - IntlDateFormatter::LONG, - IntlDateFormatter::MEDIUM, - IntlDateFormatter::SHORT, - IntlDateFormatter::NONE - ); - - $res_str = ''; - - foreach( $timetype_arr as $timetype_entry ) - { - $res_str .= "\nCreating IntlDateFormatter with time_type = $timetype_entry"; - $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, $timetype_entry ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); - $time_type = ut_datefmt_get_timetype( $fmt); - $res_str .= "\nAfter call to get_timetype : timetype= $time_type"; - $res_str .= "\n"; - } - - return $res_str; + $timetype_arr = array ( + IntlDateFormatter::FULL, + IntlDateFormatter::LONG, + IntlDateFormatter::MEDIUM, + IntlDateFormatter::SHORT, + IntlDateFormatter::NONE + ); + + $res_str = ''; + + foreach( $timetype_arr as $timetype_entry ) + { + $res_str .= "\nCreating IntlDateFormatter with time_type = $timetype_entry"; + $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, $timetype_entry ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); + $time_type = ut_datefmt_get_timetype( $fmt); + $res_str .= "\nAfter call to get_timetype : timetype= $time_type"; + $res_str .= "\n"; + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt index f529614f213c..2df0ba40b154 100644 --- a/ext/intl/tests/dateformat_get_timezone_id.phpt +++ b/ext/intl/tests/dateformat_get_timezone_id.phpt @@ -15,24 +15,24 @@ intl.error_level=E_WARNING function ut_main() { - $timezone_id_arr = array ( - 'America/New_York', - 'US/Pacific', - 'US/Central' - ); - - $res_str = ''; - - foreach( $timezone_id_arr as $timezone_id_entry ) - { - $res_str .= "\nCreating IntlDateFormatter with timezone_id = $timezone_id_entry"; - $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, $timezone_id_entry , IntlDateFormatter::GREGORIAN ); - $timezone_id = ut_datefmt_get_timezone_id( $fmt); - $res_str .= "\nAfter call to get_timezone_id : timezone_id= $timezone_id"; - $res_str .= "\n"; - } - - return $res_str; + $timezone_id_arr = array ( + 'America/New_York', + 'US/Pacific', + 'US/Central' + ); + + $res_str = ''; + + foreach( $timezone_id_arr as $timezone_id_entry ) + { + $res_str .= "\nCreating IntlDateFormatter with timezone_id = $timezone_id_entry"; + $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, $timezone_id_entry , IntlDateFormatter::GREGORIAN ); + $timezone_id = ut_datefmt_get_timezone_id( $fmt); + $res_str .= "\nAfter call to get_timezone_id : timezone_id= $timezone_id"; + $res_str .= "\n"; + } + + return $res_str; } diff --git a/ext/intl/tests/dateformat_is_set_lenient.phpt b/ext/intl/tests/dateformat_is_set_lenient.phpt index b78396b77fca..4725ff8cb6a6 100644 --- a/ext/intl/tests/dateformat_is_set_lenient.phpt +++ b/ext/intl/tests/dateformat_is_set_lenient.phpt @@ -15,54 +15,54 @@ function ut_main() $res_str = ''; - //Create + //Create $fmt = ut_datefmt_create( "en-US", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT , 'America/New_York', IntlDateFormatter::GREGORIAN ); $res_str .= "\nIntlDateFormatter Created.\n"; $resLenient1 = ut_datefmt_is_lenient( $fmt); $res_str .= "After call to get_lenient : lenient= "; - if( $resLenient1){ - $res_str .= "TRUE\n"; - }else{ - $res_str .= "FALSE\n"; - } + if( $resLenient1){ + $res_str .= "TRUE\n"; + }else{ + $res_str .= "FALSE\n"; + } - //Set and test + //Set and test $res_str .= "--------------------\n"; $isLenient = TRUE; - $res_str .= "Setting IntlDateFormatter with lenient = "; - if( $isLenient){ - $res_str .= "TRUE\n"; - }else{ - $res_str .= "FALSE\n"; - } - ut_datefmt_set_lenient( $fmt , $isLenient ); - $resLenient = ut_datefmt_is_lenient( $fmt); - $res_str .= "After call to is_lenient : lenient= "; - if( $resLenient){ - $res_str .= "TRUE\n"; - }else{ - $res_str .= "FALSE\n"; - } + $res_str .= "Setting IntlDateFormatter with lenient = "; + if( $isLenient){ + $res_str .= "TRUE\n"; + }else{ + $res_str .= "FALSE\n"; + } + ut_datefmt_set_lenient( $fmt , $isLenient ); + $resLenient = ut_datefmt_is_lenient( $fmt); + $res_str .= "After call to is_lenient : lenient= "; + if( $resLenient){ + $res_str .= "TRUE\n"; + }else{ + $res_str .= "FALSE\n"; + } - //Set and test + //Set and test $res_str .= "--------------------\n"; $isLenient = FALSE; - $res_str .= "Setting IntlDateFormatter with lenient ="; - if( $isLenient){ - $res_str .= "TRUE\n"; - }else{ - $res_str .= "FALSE\n"; - } - ut_datefmt_set_lenient( $fmt , $isLenient); - $resLenient = ut_datefmt_is_lenient( $fmt); - $res_str .= "After call to is_lenient : lenient= "; - if( $resLenient){ - $res_str .= "TRUE\n"; - }else{ - $res_str .= "FALSE\n"; - } + $res_str .= "Setting IntlDateFormatter with lenient ="; + if( $isLenient){ + $res_str .= "TRUE\n"; + }else{ + $res_str .= "FALSE\n"; + } + ut_datefmt_set_lenient( $fmt , $isLenient); + $resLenient = ut_datefmt_is_lenient( $fmt); + $res_str .= "After call to is_lenient : lenient= "; + if( $resLenient){ + $res_str .= "TRUE\n"; + }else{ + $res_str .= "FALSE\n"; + } $res_str .= "--------------------\n"; diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt index 4f1724520c3c..b1fc00b87547 100644 --- a/ext/intl/tests/dateformat_set_timezone_id2.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt @@ -17,37 +17,37 @@ ini_set("intl.error_level", E_WARNING); function ut_main() { - $timezone_id_arr = array ( - 'America/New_York', - 'America/Los_Angeles', - 'America/Chicago', - 'CN' - ); - $timestamp_entry = 0; + $timezone_id_arr = array ( + 'America/New_York', + 'America/Los_Angeles', + 'America/Chicago', + 'CN' + ); + $timestamp_entry = 0; - $res_str = ''; + $res_str = ''; - $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN ); - $timezone_id = ut_datefmt_get_timezone_id( $fmt ); - $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; + $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN ); + $timezone_id = ut_datefmt_get_timezone_id( $fmt ); + $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; - foreach( $timezone_id_arr as $timezone_id_entry ) - { + foreach( $timezone_id_arr as $timezone_id_entry ) + { - $res_str .= "-----------"; - $res_str .= "\nTrying to set timezone_id= $timezone_id_entry"; - ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ); - $timezone_id = ut_datefmt_get_timezone_id( $fmt ); - $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id"; - $formatted = ut_datefmt_format( $fmt, 0); - $res_str .= "\nFormatting timestamp=0 resulted in $formatted"; - $formatted = ut_datefmt_format( $fmt, 3600); - $res_str .= "\nFormatting timestamp=3600 resulted in $formatted"; - $res_str .= "\n"; + $res_str .= "-----------"; + $res_str .= "\nTrying to set timezone_id= $timezone_id_entry"; + ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ); + $timezone_id = ut_datefmt_get_timezone_id( $fmt ); + $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id"; + $formatted = ut_datefmt_format( $fmt, 0); + $res_str .= "\nFormatting timestamp=0 resulted in $formatted"; + $formatted = ut_datefmt_format( $fmt, 3600); + $res_str .= "\nFormatting timestamp=3600 resulted in $formatted"; + $res_str .= "\n"; - } + } - return $res_str; + return $res_str; } diff --git a/ext/intl/tests/dateformat_set_timezone_id3.phpt b/ext/intl/tests/dateformat_set_timezone_id3.phpt index 0970089bed6f..4eb963e1862f 100644 --- a/ext/intl/tests/dateformat_set_timezone_id3.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id3.phpt @@ -17,37 +17,37 @@ ini_set("intl.error_level", E_WARNING); function ut_main() { - $timezone_id_arr = array ( - 'America/New_York', - 'America/Los_Angeles', - 'America/Chicago', - 'CN' - ); - $timestamp_entry = 0; + $timezone_id_arr = array ( + 'America/New_York', + 'America/Los_Angeles', + 'America/Chicago', + 'CN' + ); + $timestamp_entry = 0; - $res_str = ''; + $res_str = ''; - $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN ); - $timezone_id = ut_datefmt_get_timezone_id( $fmt ); - $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; + $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN ); + $timezone_id = ut_datefmt_get_timezone_id( $fmt ); + $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; - foreach( $timezone_id_arr as $timezone_id_entry ) - { + foreach( $timezone_id_arr as $timezone_id_entry ) + { - $res_str .= "-----------"; - $res_str .= "\nTrying to set timezone_id= $timezone_id_entry"; - ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ); - $timezone_id = ut_datefmt_get_timezone_id( $fmt ); - $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id"; - $formatted = ut_datefmt_format( $fmt, 0); - $res_str .= "\nFormatting timestamp=0 resulted in $formatted"; - $formatted = ut_datefmt_format( $fmt, 3600); - $res_str .= "\nFormatting timestamp=3600 resulted in $formatted"; - $res_str .= "\n"; + $res_str .= "-----------"; + $res_str .= "\nTrying to set timezone_id= $timezone_id_entry"; + ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ); + $timezone_id = ut_datefmt_get_timezone_id( $fmt ); + $res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id"; + $formatted = ut_datefmt_format( $fmt, 0); + $res_str .= "\nFormatting timestamp=0 resulted in $formatted"; + $formatted = ut_datefmt_format( $fmt, 3600); + $res_str .= "\nFormatting timestamp=3600 resulted in $formatted"; + $res_str .= "\n"; - } + } - return $res_str; + return $res_str; } diff --git a/ext/intl/tests/formatter_clone.phpt b/ext/intl/tests/formatter_clone.phpt index d474eb2b70cc..4ca2d44dc949 100644 --- a/ext/intl/tests/formatter_clone.phpt +++ b/ext/intl/tests/formatter_clone.phpt @@ -17,7 +17,7 @@ $fmt_clone = clone $fmt; $res = $fmt->setPattern("0.0" ); if( $res === false ) - $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n"; + $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n"; $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; $res_str .= "Formatted(clone) number: " . ut_nfmt_format( $fmt_clone, $test_value ) . "\n"; diff --git a/ext/intl/tests/formatter_clone_bad_obj.phpt b/ext/intl/tests/formatter_clone_bad_obj.phpt index 53a715e6a7cf..d27024cb3925 100644 --- a/ext/intl/tests/formatter_clone_bad_obj.phpt +++ b/ext/intl/tests/formatter_clone_bad_obj.phpt @@ -6,14 +6,14 @@ Cloning unconstructed numfmt getMessage()); + var_dump($e->getMessage()); } --EXPECT-- string(42) "Cannot clone unconstructed NumberFormatter" diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 0a8d7f398b2e..4bce9184cc63 100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt @@ -6,82 +6,82 @@ numfmt creation failures getMessage() + echo "\n" . get_class($e) . ": " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; } function crt($t, $l, $s) { - switch(true) { - case $t == "O": - try { - return new NumberFormatter($l, $s); - } catch (Throwable $e) { - print_exception($e); - return null; - } - break; - case $t == "C": - try { - return NumberFormatter::create($l, $s); - } catch (Throwable $e) { - print_exception($e); - return null; - } - break; - case $t == "P": - try { - return numfmt_create($l, $s); - } catch (Throwable $e) { - print_exception($e); - return null; - } - break; - } + switch(true) { + case $t == "O": + try { + return new NumberFormatter($l, $s); + } catch (Throwable $e) { + print_exception($e); + return null; + } + break; + case $t == "C": + try { + return NumberFormatter::create($l, $s); + } catch (Throwable $e) { + print_exception($e); + return null; + } + break; + case $t == "P": + try { + return numfmt_create($l, $s); + } catch (Throwable $e) { + print_exception($e); + return null; + } + break; + } } $args = array( - array(null, null), - array("whatever", 1234567), - array(array(), array()), - array("en", -1), - array("en_US", NumberFormatter::PATTERN_RULEBASED), + array(null, null), + array("whatever", 1234567), + array(array(), array()), + array("en", -1), + array("en_US", NumberFormatter::PATTERN_RULEBASED), ); try { - $fmt = new NumberFormatter(); + $fmt = new NumberFormatter(); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = numfmt_create(); + $fmt = numfmt_create(); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = NumberFormatter::create(); + $fmt = NumberFormatter::create(); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); foreach($args as $arg) { - $fmt = crt("O", $arg[0], $arg[1]); - err($fmt); - $fmt = crt("C", $arg[0], $arg[1]); - err($fmt); - $fmt = crt("P", $arg[0], $arg[1]); - err($fmt); + $fmt = crt("O", $arg[0], $arg[1]); + err($fmt); + $fmt = crt("C", $arg[0], $arg[1]); + err($fmt); + $fmt = crt("P", $arg[0], $arg[1]); + err($fmt); } ?> diff --git a/ext/intl/tests/formatter_format2.phpt b/ext/intl/tests/formatter_format2.phpt index 26ef060ea029..d6e06cb57ca2 100644 --- a/ext/intl/tests/formatter_format2.phpt +++ b/ext/intl/tests/formatter_format2.phpt @@ -52,10 +52,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_format3.phpt b/ext/intl/tests/formatter_format3.phpt index b9d6eb5c3d5f..19512acc414f 100644 --- a/ext/intl/tests/formatter_format3.phpt +++ b/ext/intl/tests/formatter_format3.phpt @@ -53,10 +53,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_format4.phpt b/ext/intl/tests/formatter_format4.phpt index 96dd7be53eea..0cc086b31ed3 100644 --- a/ext/intl/tests/formatter_format4.phpt +++ b/ext/intl/tests/formatter_format4.phpt @@ -53,10 +53,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_format5.phpt b/ext/intl/tests/formatter_format5.phpt index 0bc4a6679b1e..8399af112997 100644 --- a/ext/intl/tests/formatter_format5.phpt +++ b/ext/intl/tests/formatter_format5.phpt @@ -53,10 +53,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_format6.phpt b/ext/intl/tests/formatter_format6.phpt index 70703785c140..6244a7f290d6 100644 --- a/ext/intl/tests/formatter_format6.phpt +++ b/ext/intl/tests/formatter_format6.phpt @@ -53,10 +53,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_format7.phpt b/ext/intl/tests/formatter_format7.phpt index 13d58bdd5113..453a16e2b54c 100644 --- a/ext/intl/tests/formatter_format7.phpt +++ b/ext/intl/tests/formatter_format7.phpt @@ -53,10 +53,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_format8.phpt b/ext/intl/tests/formatter_format8.phpt index 3aad6bced1f7..dcf8d8bca9e2 100644 --- a/ext/intl/tests/formatter_format8.phpt +++ b/ext/intl/tests/formatter_format8.phpt @@ -52,10 +52,10 @@ function ut_main() { $fmt = ut_nfmt_create( $locale, $style, $pattern ); - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } + if(!$fmt) { + $str_res .= "Bad formatter!\n"; + continue; + } $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; } } diff --git a/ext/intl/tests/formatter_get_set_pattern.phpt b/ext/intl/tests/formatter_get_set_pattern.phpt index 66d6837d758f..441a8ecb1527 100644 --- a/ext/intl/tests/formatter_get_set_pattern.phpt +++ b/ext/intl/tests/formatter_get_set_pattern.phpt @@ -33,8 +33,8 @@ function ut_main() $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; - ut_nfmt_set_pattern($fmt, str_repeat('@', 200)); - $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; + ut_nfmt_set_pattern($fmt, str_repeat('@', 200)); + $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; return $res_str; diff --git a/ext/intl/tests/formatter_get_set_pattern2.phpt b/ext/intl/tests/formatter_get_set_pattern2.phpt index b1d1ad0c4879..f15c3bf75cbf 100644 --- a/ext/intl/tests/formatter_get_set_pattern2.phpt +++ b/ext/intl/tests/formatter_get_set_pattern2.phpt @@ -33,8 +33,8 @@ function ut_main() $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; - ut_nfmt_set_pattern($fmt, str_repeat('@', 200)); - $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; + ut_nfmt_set_pattern($fmt, str_repeat('@', 200)); + $res_str .= "New pattern: '" . ut_nfmt_get_pattern( $fmt ) . "'\n"; $res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n"; return $res_str; diff --git a/ext/intl/tests/formatter_get_set_symbol2.phpt b/ext/intl/tests/formatter_get_set_symbol2.phpt index 201a4f687236..f4435c278a10 100644 --- a/ext/intl/tests/formatter_get_set_symbol2.phpt +++ b/ext/intl/tests/formatter_get_set_symbol2.phpt @@ -13,7 +13,7 @@ numfmt_get/set_symbol() icu >= 4.8 function ut_main() { - $longstr = str_repeat("blah", 10); + $longstr = str_repeat("blah", 10); $symbols = array( 'DECIMAL_SEPARATOR_SYMBOL' => array( NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, '_._', 12345.123456, NumberFormatter::DECIMAL ), 'GROUPING_SEPARATOR_SYMBOL' => array( NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '_,_', 12345.123456, NumberFormatter::DECIMAL ), @@ -33,8 +33,8 @@ function ut_main() 'NAN_SYMBOL' => array( NumberFormatter::NAN_SYMBOL, '_N_', 12345.123456, NumberFormatter::DECIMAL ), 'SIGNIFICANT_DIGIT_SYMBOL' => array( NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL, '_SD_', 12345.123456, NumberFormatter::DECIMAL ), 'MONETARY_GROUPING_SEPARATOR_SYMBOL' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, '_MG_', 12345.123456, NumberFormatter::CURRENCY ), - 'MONETARY_GROUPING_SEPARATOR_SYMBOL-2' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, " ", 12345.123456, NumberFormatter::CURRENCY ), - 'MONETARY_GROUPING_SEPARATOR_SYMBOL-3' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, $longstr, 12345.123456, NumberFormatter::CURRENCY ), + 'MONETARY_GROUPING_SEPARATOR_SYMBOL-2' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, " ", 12345.123456, NumberFormatter::CURRENCY ), + 'MONETARY_GROUPING_SEPARATOR_SYMBOL-3' => array( NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL, $longstr, 12345.123456, NumberFormatter::CURRENCY ), ); $res_str = ''; @@ -76,9 +76,9 @@ function ut_main() } $badvals = array(2147483648, -2147483648, -1, 4294901761); foreach($badvals as $badval) { - if(ut_nfmt_get_symbol( $fmt, 2147483648 )) { - $res_str .= "Bad value $badval should return false!\n"; - } + if(ut_nfmt_get_symbol( $fmt, 2147483648 )) { + $res_str .= "Bad value $badval should return false!\n"; + } } return $res_str; } diff --git a/ext/intl/tests/formatter_get_set_text_attribute.phpt b/ext/intl/tests/formatter_get_set_text_attribute.phpt index dea3c2d36ff1..b3ae867b24e0 100644 --- a/ext/intl/tests/formatter_get_set_text_attribute.phpt +++ b/ext/intl/tests/formatter_get_set_text_attribute.phpt @@ -14,14 +14,14 @@ numfmt_get/set_text_attribute() ICU < 56.1 function ut_main() { // Array with data for testing - $long_str = str_repeat('blah', 100); + $long_str = str_repeat('blah', 100); $attributes = array( 'POSITIVE_PREFIX' => array( NumberFormatter::POSITIVE_PREFIX, '_+_', 12345.1234 ), 'POSITIVE_SUFFIX' => array( NumberFormatter::POSITIVE_SUFFIX, '_+_', 12345.1234 ), 'NEGATIVE_PREFIX' => array( NumberFormatter::NEGATIVE_PREFIX, '_-_', -12345.1234 ), 'NEGATIVE_SUFFIX' => array( NumberFormatter::NEGATIVE_SUFFIX, '_-_', -12345.1234 ), 'PADDING_CHARACTER' => array( NumberFormatter::PADDING_CHARACTER, '^', 12345.1234 ), - 'POSITIVE_PREFIX-2' => array( NumberFormatter::POSITIVE_PREFIX, $long_str, 12345.1234 ), + 'POSITIVE_PREFIX-2' => array( NumberFormatter::POSITIVE_PREFIX, $long_str, 12345.1234 ), // 'CURRENCY_CODE' => array( NumberFormatter::CURRENCY_CODE, '_C_', 12345.1234 ) // 'DEFAULT_RULESET' => array( NumberFormatter::DEFAULT_RULESET, '_DR_', 12345.1234 ), // 'PUBLIC_RULESETS' => array( NumberFormatter::PUBLIC_RULESETS, '_PR_', 12345.1234 ) diff --git a/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt b/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt index 260e33a350b2..3819de6ddef9 100644 --- a/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt +++ b/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt @@ -14,14 +14,14 @@ numfmt_get/set_text_attribute() ICU >= 56.1 function ut_main() { // Array with data for testing - $long_str = str_repeat('blah', 100); + $long_str = str_repeat('blah', 100); $attributes = array( 'POSITIVE_PREFIX' => array( NumberFormatter::POSITIVE_PREFIX, '_+_', 12345.1234 ), 'POSITIVE_SUFFIX' => array( NumberFormatter::POSITIVE_SUFFIX, '_+_', 12345.1234 ), 'NEGATIVE_PREFIX' => array( NumberFormatter::NEGATIVE_PREFIX, '_-_', -12345.1234 ), 'NEGATIVE_SUFFIX' => array( NumberFormatter::NEGATIVE_SUFFIX, '_-_', -12345.1234 ), 'PADDING_CHARACTER' => array( NumberFormatter::PADDING_CHARACTER, '^', 12345.1234 ), - 'POSITIVE_PREFIX-2' => array( NumberFormatter::POSITIVE_PREFIX, $long_str, 12345.1234 ), + 'POSITIVE_PREFIX-2' => array( NumberFormatter::POSITIVE_PREFIX, $long_str, 12345.1234 ), // 'CURRENCY_CODE' => array( NumberFormatter::CURRENCY_CODE, '_C_', 12345.1234 ) // 'DEFAULT_RULESET' => array( NumberFormatter::DEFAULT_RULESET, '_DR_', 12345.1234 ), // 'PUBLIC_RULESETS' => array( NumberFormatter::PUBLIC_RULESETS, '_PR_', 12345.1234 ) diff --git a/ext/intl/tests/grapheme.phpt b/ext/intl/tests/grapheme.phpt index 9e14d9cc141e..be82abf71809 100644 --- a/ext/intl/tests/grapheme.phpt +++ b/ext/intl/tests/grapheme.phpt @@ -12,772 +12,772 @@ grapheme() function ut_main() { - $res_str = ''; - - $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) - $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) - $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) - $char_O_diaeresis = "\xC3\x96"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) - - $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) - $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) - - $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) - $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) - - $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) - - $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) - - $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) - - // the word 'hindi' using Devanagari characters: - $hindi = "\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80"; - - $char_a_ring_nfd = "a\xCC\x8A"; - $char_A_ring_nfd = "A\xCC\x8A"; - $char_o_diaeresis_nfd = "o\xCC\x88"; - $char_O_diaeresis_nfd = "O\xCC\x88"; - $char_diaeresis = "\xCC\x88"; - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strlen($string) {}' . "\n\n"; - - - $res_str .= "\"hindi\" in devanagari strlen " . grapheme_strlen($hindi) . "\n"; - $res_str .= "\"ab\" + \"hindi\" + \"cde\" strlen " . grapheme_strlen('ab' . $hindi . 'cde') . "\n"; - $res_str .= "\"\" strlen " . grapheme_strlen("") . "\n"; - $res_str .= "char_a_ring_nfd strlen " . grapheme_strlen($char_a_ring_nfd) . "\n"; - $res_str .= "char_a_ring_nfd + \"bc\" strlen " . grapheme_strlen($char_a_ring_nfd . 'bc') . "\n"; - $res_str .= "\"abc\" strlen " . grapheme_strlen('abc') . "\n"; - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strpos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( "abc", "d", "false" ), - array( "abc", "c", 2 ), - array( "abc", "b", 1 ), - array( "abc", "a", 0 ), - array( "abc", "a", 0, 0 ), - array( "abc", "a", 1, "false" ), - array( "abc", "a", -1, "false" ), - array( "ababc", "a", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -1, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -5, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, -4, 3 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "bc", "false" ), - array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), - array( "abc", "defghijklmnopq", "false" ), - array( "abc", "ab", 0 ), - array( "abc", "bc", 1 ), - array( "abc", "abc", 0 ), - array( "abc", "abcd", "false" ), - array( "abc", "ab", 0, 0 ), - array( "abc", "abc", 0, 0 ), - array( "abc", "abc", 1, "false" ), - array( "ababc", "ab", 1, 2 ), - array( "ababc", "abc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", -8, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strpos"; - if ( 3 == count( $test ) ) { - $result = grapheme_strpos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_strpos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_stripos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - $tests = array( - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Oo", "o", -6, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, -1, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), - array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "Abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "A", "false" ), - array( "abc", "D", "false" ), - array( "abC", "c", 2 ), - array( "abc", "B", 1 ), - array( "Abc", "a", 0 ), - array( "abc", "A", 0, 0 ), - array( "Abc", "a", 1, "false" ), - array( "ababc", "A", 1, 2 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "BC", "false" ), - array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), - array( "aBC", "Defghijklmnopq", "false" ), - array( "abC", "Ab", 0 ), - array( "aBC", "bc", 1 ), - array( "abC", "Abc", 0 ), - array( "abC", "aBcd", "false" ), - array( "ABc", "ab", 0, 0 ), - array( "aBc", "abC", 0, 0 ), - array( "abc", "aBc", 1, "false" ), - array( "ABabc", "AB", 1, 2 ), - array( "ABabc", "AB", -4, 2 ), - array( "abaBc", "aBc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stripos"; - if ( 3 == count( $test ) ) { - $result = grapheme_stripos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_stripos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strrpos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( "abc", "d", "false" ), - array( "abc", "c", 2 ), - array( "abc", "b", 1 ), - array( "abc", "a", 0 ), - array( "abc", "a", 0, 0 ), - array( "abc", "a", 1, "false" ), - array( "ababc", "a", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "bc", "false" ), - array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), - array( "abc", "defghijklmnopq", "false" ), - array( "abc", "ab", 0 ), - array( "abc", "bc", 1 ), - array( "abc", "abc", 0 ), - array( "abc", "abcd", "false" ), - array( "abc", "ab", 0, 0 ), - array( "abc", "abc", 0, 0 ), - array( "abc", "abc", 1, "false" ), - array( "ababc", "ab", 1, 2 ), - array( "ababc", "abc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strrpos"; - if ( 3 == count( $test ) ) { - $result = grapheme_strrpos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_strrpos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strripos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - $tests = array( - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), - array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "Abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "A", "false" ), - array( "abc", "D", "false" ), - array( "abC", "c", 2 ), - array( "abc", "B", 1 ), - array( "Abc", "a", 0 ), - array( "abc", "A", 0, 0 ), - array( "Abc", "a", 1, "false" ), - array( "ababc", "A", 1, 2 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "BC", "false" ), - array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), - array( "aBC", "Defghijklmnopq", "false" ), - array( "abC", "Ab", 0 ), - array( "aBC", "bc", 1 ), - array( "abC", "Abc", 0 ), - array( "abC", "aBcd", "false" ), - array( "ABc", "ab", 0, 0 ), - array( "aBc", "abC", 0, 0 ), - array( "abc", "aBc", 1, "false" ), - array( "ABabc", "AB", 1, 2 ), - array( "abaBc", "aBc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strripos"; - if ( 3 == count( $test ) ) { - $result = grapheme_strripos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_strripos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_substr($string, $start, $length = -1) {}' . "\n\n"; - - $tests = array( - - array( "abc", 3, "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 2, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", 2, "a" . $char_A_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 5, "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, 4, $char_O_diaeresis_nfd ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "bc" ), - array( "a" . $char_A_ring_nfd . "bc", 1, $char_A_ring_nfd . "bc" ), - array( "Abc", -5, "false" ), - array( $char_a_ring_nfd . "bc", 3, "false" ), - array( "abc", 4, "false" ), - array( "abC", 2, "C" ), - array( "abc", 1, "bc" ), - array( "Abc", 1, 1, "b" ), - array( "abc", 0, 2, "ab" ), - array( "Abc", -4, 1, "false" ), - array( "ababc", 1, 2, "ba" ), - array( "ababc", 0, 10, "ababc" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -3, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -4, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -4, "a" . $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -5, "a" . $char_a_ring_nfd . "b" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -6, "a" . $char_a_ring_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -7, "a" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -8, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -9, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -7, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -6, "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -5, "c" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -4, $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -3, "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -2, "pq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -1, "q" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -999, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 7, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 6, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 5, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 4, "a" . $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 3, "a" . $char_a_ring_nfd . "b" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 2, "a" . $char_a_ring_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 1, "a" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 0, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -999, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -4, "a" . $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -5, "a" . $char_a_ring_nfd . "b" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -6, "a" . $char_a_ring_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -7, "a" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -8, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -9, "false" ), - - ); - - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr"; - if ( 3 == count( $test ) ) { - $result = grapheme_substr($test[0], $test[1]); - } - else { - $res_str .= " with length $test[2]"; - $result = grapheme_substr($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", "o" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, $char_o_diaeresis_nfd ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( "abc", "d", "false" ), - array( "abc", "c", "c" ), - array( "abc", "b", "bc" ), - array( "abc", "a", "abc" ), - array( "abc", "ab", "abc" ), - array( "abc", "abc", "abc" ), - array( "abc", "bc", "bc" ), - array( "abc", "a", FALSE, "abc" ), - array( "abc", "a", TRUE, "" ), - array( "abc", "b", TRUE, "a" ), - array( "abc", "c", TRUE, "ab" ), - array( "ababc", "bab", TRUE, "a" ), - array( "ababc", "abc", TRUE, "ab" ), - array( "ababc", "abc", FALSE, "abc" ), - - array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), - array( "bc" . $char_a_ring_nfd . "a", "a", "a" ), - array( "a" . $char_a_ring_nfd . "bc", "b", "bc" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( $char_a_ring_nfd . "abc", "ab", "abc" ), - array( "abc" . $char_a_ring_nfd, "abc", "abc" . $char_a_ring_nfd), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_a_ring_nfd . "bc"), - array( "a" . $char_a_ring_nfd . "bc", "a", TRUE, "" ), - array( $char_a_ring_nfd . "abc", "b", TRUE, $char_a_ring_nfd . "a" ), - array( "ab" . $char_a_ring_nfd . "c", "c", TRUE, "ab" . $char_a_ring_nfd ), - array( "aba" . $char_a_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), - array( "ababc" . $char_a_ring_nfd, "abc" . $char_a_ring_nfd, TRUE, "ab" ), - array( "abab" . $char_a_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "ab" . $char_a_ring_nfd . "c" ), - - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr"; - if ( 3 == count( $test ) ) { - $result = grapheme_strstr($test[0], $test[1]); - } - else { - $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); - $result = grapheme_strstr($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd, $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), - array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, $char_a_ring_nfd . "bc"), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "A", "false" ), - array( "abc", "d", "false" ), - array( "abc", "C", "c" ), - array( "aBc", "b", "Bc" ), - array( "abc", "A", "abc" ), - array( "abC", "ab", "abC" ), - array( "abc", "aBc", "abc" ), - array( "abC", "bc", "bC" ), - array( "abc", "A", FALSE, "abc" ), - array( "abc", "a", TRUE, "" ), - array( "aBc", "b", TRUE, "a" ), - array( "abc", "C", TRUE, "ab" ), - array( "aBabc", "bab", TRUE, "a" ), - array( "ababc", "aBc", TRUE, "ab" ), - array( "ababc", "abC", FALSE, "abc" ), - - array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), - array( "bc" . $char_a_ring_nfd . "A", "a", "A" ), - array( "a" . $char_a_ring_nfd . "bc", "B", "bc" ), - array( $char_A_ring_nfd . "bc", "a", "false" ), - array( $char_a_ring_nfd . "abc", "Ab", "abc" ), - array( "abc" . $char_A_ring_nfd, "abc", "abc" . $char_A_ring_nfd), - array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), - array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_A_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc", "A", TRUE, "" ), - array( $char_a_ring_nfd . "aBc", "b", TRUE, $char_a_ring_nfd . "a" ), - array( "ab" . $char_a_ring_nfd . "c", "C", TRUE, "ab" . $char_a_ring_nfd ), - array( "aba" . $char_A_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), - array( "ababc" . $char_a_ring_nfd, "aBc" . $char_A_ring_nfd, TRUE, "ab" ), - array( "abAB" . $char_A_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "AB" . $char_A_ring_nfd . "c" ), - - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stristr"; - if ( 3 == count( $test ) ) { - $result = grapheme_stristr($test[0], $test[1]); - } - else { - $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); - $result = grapheme_stristr($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])' . "\n\n"; - - $tests = array( - // haystack, count, [[offset], [next]], result - array( "abc", 3, "abc" ), - array( "abc", 2, "ab" ), - array( "abc", 1, "a" ), - array( "abc", 0, "" ), - array( "abc", 1, 0, "a" ), - array( "abc", 1, 1, "b" ), - array( "abc", 1, 2, "c" ), - array( "abc", 0, 2, "" ), - - array( "abc", 3, 0, 3, "abc" ), - array( "abc", 2, 0, 2, "ab" ), - array( "abc", 1, 0, 1, "a" ), - array( "abc", 0, 0, 0, "" ), - array( "abc", 1, 0, 1, "a" ), - array( "abc", 1, 1, 2, "b" ), - array( "abc", 1, 2, 3, "c" ), - array( "abc", 1, -2, 2, "b" ), - array( "abc", 0, 2, 2, "" ), + $res_str = ''; + + $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) + $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) + $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) + $char_O_diaeresis = "\xC3\x96"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) + + $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) + $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) + + $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) + $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) + + $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) + + $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) + + $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) + + // the word 'hindi' using Devanagari characters: + $hindi = "\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80"; + + $char_a_ring_nfd = "a\xCC\x8A"; + $char_A_ring_nfd = "A\xCC\x8A"; + $char_o_diaeresis_nfd = "o\xCC\x88"; + $char_O_diaeresis_nfd = "O\xCC\x88"; + $char_diaeresis = "\xCC\x88"; + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strlen($string) {}' . "\n\n"; + + + $res_str .= "\"hindi\" in devanagari strlen " . grapheme_strlen($hindi) . "\n"; + $res_str .= "\"ab\" + \"hindi\" + \"cde\" strlen " . grapheme_strlen('ab' . $hindi . 'cde') . "\n"; + $res_str .= "\"\" strlen " . grapheme_strlen("") . "\n"; + $res_str .= "char_a_ring_nfd strlen " . grapheme_strlen($char_a_ring_nfd) . "\n"; + $res_str .= "char_a_ring_nfd + \"bc\" strlen " . grapheme_strlen($char_a_ring_nfd . 'bc') . "\n"; + $res_str .= "\"abc\" strlen " . grapheme_strlen('abc') . "\n"; + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strpos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( "abc", "d", "false" ), + array( "abc", "c", 2 ), + array( "abc", "b", 1 ), + array( "abc", "a", 0 ), + array( "abc", "a", 0, 0 ), + array( "abc", "a", 1, "false" ), + array( "abc", "a", -1, "false" ), + array( "ababc", "a", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -1, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -5, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, -4, 3 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "bc", "false" ), + array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), + array( "abc", "defghijklmnopq", "false" ), + array( "abc", "ab", 0 ), + array( "abc", "bc", 1 ), + array( "abc", "abc", 0 ), + array( "abc", "abcd", "false" ), + array( "abc", "ab", 0, 0 ), + array( "abc", "abc", 0, 0 ), + array( "abc", "abc", 1, "false" ), + array( "ababc", "ab", 1, 2 ), + array( "ababc", "abc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", -8, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strpos"; + if ( 3 == count( $test ) ) { + $result = grapheme_strpos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_strpos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_stripos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + $tests = array( + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Oo", "o", -6, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, -1, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), + array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "Abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "A", "false" ), + array( "abc", "D", "false" ), + array( "abC", "c", 2 ), + array( "abc", "B", 1 ), + array( "Abc", "a", 0 ), + array( "abc", "A", 0, 0 ), + array( "Abc", "a", 1, "false" ), + array( "ababc", "A", 1, 2 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "BC", "false" ), + array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), + array( "aBC", "Defghijklmnopq", "false" ), + array( "abC", "Ab", 0 ), + array( "aBC", "bc", 1 ), + array( "abC", "Abc", 0 ), + array( "abC", "aBcd", "false" ), + array( "ABc", "ab", 0, 0 ), + array( "aBc", "abC", 0, 0 ), + array( "abc", "aBc", 1, "false" ), + array( "ABabc", "AB", 1, 2 ), + array( "ABabc", "AB", -4, 2 ), + array( "abaBc", "aBc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stripos"; + if ( 3 == count( $test ) ) { + $result = grapheme_stripos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_stripos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strrpos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( "abc", "d", "false" ), + array( "abc", "c", 2 ), + array( "abc", "b", 1 ), + array( "abc", "a", 0 ), + array( "abc", "a", 0, 0 ), + array( "abc", "a", 1, "false" ), + array( "ababc", "a", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "bc", "false" ), + array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), + array( "abc", "defghijklmnopq", "false" ), + array( "abc", "ab", 0 ), + array( "abc", "bc", 1 ), + array( "abc", "abc", 0 ), + array( "abc", "abcd", "false" ), + array( "abc", "ab", 0, 0 ), + array( "abc", "abc", 0, 0 ), + array( "abc", "abc", 1, "false" ), + array( "ababc", "ab", 1, 2 ), + array( "ababc", "abc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strrpos"; + if ( 3 == count( $test ) ) { + $result = grapheme_strrpos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_strrpos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strripos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + $tests = array( + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), + array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "Abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "A", "false" ), + array( "abc", "D", "false" ), + array( "abC", "c", 2 ), + array( "abc", "B", 1 ), + array( "Abc", "a", 0 ), + array( "abc", "A", 0, 0 ), + array( "Abc", "a", 1, "false" ), + array( "ababc", "A", 1, 2 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "BC", "false" ), + array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), + array( "aBC", "Defghijklmnopq", "false" ), + array( "abC", "Ab", 0 ), + array( "aBC", "bc", 1 ), + array( "abC", "Abc", 0 ), + array( "abC", "aBcd", "false" ), + array( "ABc", "ab", 0, 0 ), + array( "aBc", "abC", 0, 0 ), + array( "abc", "aBc", 1, "false" ), + array( "ABabc", "AB", 1, 2 ), + array( "abaBc", "aBc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strripos"; + if ( 3 == count( $test ) ) { + $result = grapheme_strripos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_strripos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_substr($string, $start, $length = -1) {}' . "\n\n"; + + $tests = array( + + array( "abc", 3, "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 2, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", 2, "a" . $char_A_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 5, "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, 4, $char_O_diaeresis_nfd ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "bc" ), + array( "a" . $char_A_ring_nfd . "bc", 1, $char_A_ring_nfd . "bc" ), + array( "Abc", -5, "false" ), + array( $char_a_ring_nfd . "bc", 3, "false" ), + array( "abc", 4, "false" ), + array( "abC", 2, "C" ), + array( "abc", 1, "bc" ), + array( "Abc", 1, 1, "b" ), + array( "abc", 0, 2, "ab" ), + array( "Abc", -4, 1, "false" ), + array( "ababc", 1, 2, "ba" ), + array( "ababc", 0, 10, "ababc" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -3, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -4, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -4, "a" . $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -5, "a" . $char_a_ring_nfd . "b" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -6, "a" . $char_a_ring_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -7, "a" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -8, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -9, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -7, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -6, "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -5, "c" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -4, $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -3, "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -2, "pq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -1, "q" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -999, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 7, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 6, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 5, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 4, "a" . $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 3, "a" . $char_a_ring_nfd . "b" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 2, "a" . $char_a_ring_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 1, "a" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 0, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -999, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -4, "a" . $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -5, "a" . $char_a_ring_nfd . "b" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -6, "a" . $char_a_ring_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -7, "a" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -8, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -9, "false" ), + + ); + + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr"; + if ( 3 == count( $test ) ) { + $result = grapheme_substr($test[0], $test[1]); + } + else { + $res_str .= " with length $test[2]"; + $result = grapheme_substr($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", "o" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, $char_o_diaeresis_nfd ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( "abc", "d", "false" ), + array( "abc", "c", "c" ), + array( "abc", "b", "bc" ), + array( "abc", "a", "abc" ), + array( "abc", "ab", "abc" ), + array( "abc", "abc", "abc" ), + array( "abc", "bc", "bc" ), + array( "abc", "a", FALSE, "abc" ), + array( "abc", "a", TRUE, "" ), + array( "abc", "b", TRUE, "a" ), + array( "abc", "c", TRUE, "ab" ), + array( "ababc", "bab", TRUE, "a" ), + array( "ababc", "abc", TRUE, "ab" ), + array( "ababc", "abc", FALSE, "abc" ), + + array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), + array( "bc" . $char_a_ring_nfd . "a", "a", "a" ), + array( "a" . $char_a_ring_nfd . "bc", "b", "bc" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( $char_a_ring_nfd . "abc", "ab", "abc" ), + array( "abc" . $char_a_ring_nfd, "abc", "abc" . $char_a_ring_nfd), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_a_ring_nfd . "bc"), + array( "a" . $char_a_ring_nfd . "bc", "a", TRUE, "" ), + array( $char_a_ring_nfd . "abc", "b", TRUE, $char_a_ring_nfd . "a" ), + array( "ab" . $char_a_ring_nfd . "c", "c", TRUE, "ab" . $char_a_ring_nfd ), + array( "aba" . $char_a_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), + array( "ababc" . $char_a_ring_nfd, "abc" . $char_a_ring_nfd, TRUE, "ab" ), + array( "abab" . $char_a_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "ab" . $char_a_ring_nfd . "c" ), + + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr"; + if ( 3 == count( $test ) ) { + $result = grapheme_strstr($test[0], $test[1]); + } + else { + $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); + $result = grapheme_strstr($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd, $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), + array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, $char_a_ring_nfd . "bc"), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "A", "false" ), + array( "abc", "d", "false" ), + array( "abc", "C", "c" ), + array( "aBc", "b", "Bc" ), + array( "abc", "A", "abc" ), + array( "abC", "ab", "abC" ), + array( "abc", "aBc", "abc" ), + array( "abC", "bc", "bC" ), + array( "abc", "A", FALSE, "abc" ), + array( "abc", "a", TRUE, "" ), + array( "aBc", "b", TRUE, "a" ), + array( "abc", "C", TRUE, "ab" ), + array( "aBabc", "bab", TRUE, "a" ), + array( "ababc", "aBc", TRUE, "ab" ), + array( "ababc", "abC", FALSE, "abc" ), + + array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), + array( "bc" . $char_a_ring_nfd . "A", "a", "A" ), + array( "a" . $char_a_ring_nfd . "bc", "B", "bc" ), + array( $char_A_ring_nfd . "bc", "a", "false" ), + array( $char_a_ring_nfd . "abc", "Ab", "abc" ), + array( "abc" . $char_A_ring_nfd, "abc", "abc" . $char_A_ring_nfd), + array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), + array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_A_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc", "A", TRUE, "" ), + array( $char_a_ring_nfd . "aBc", "b", TRUE, $char_a_ring_nfd . "a" ), + array( "ab" . $char_a_ring_nfd . "c", "C", TRUE, "ab" . $char_a_ring_nfd ), + array( "aba" . $char_A_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), + array( "ababc" . $char_a_ring_nfd, "aBc" . $char_A_ring_nfd, TRUE, "ab" ), + array( "abAB" . $char_A_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "AB" . $char_A_ring_nfd . "c" ), + + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stristr"; + if ( 3 == count( $test ) ) { + $result = grapheme_stristr($test[0], $test[1]); + } + else { + $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); + $result = grapheme_stristr($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])' . "\n\n"; + + $tests = array( + // haystack, count, [[offset], [next]], result + array( "abc", 3, "abc" ), + array( "abc", 2, "ab" ), + array( "abc", 1, "a" ), + array( "abc", 0, "" ), + array( "abc", 1, 0, "a" ), + array( "abc", 1, 1, "b" ), + array( "abc", 1, 2, "c" ), + array( "abc", 0, 2, "" ), + + array( "abc", 3, 0, 3, "abc" ), + array( "abc", 2, 0, 2, "ab" ), + array( "abc", 1, 0, 1, "a" ), + array( "abc", 0, 0, 0, "" ), + array( "abc", 1, 0, 1, "a" ), + array( "abc", 1, 1, 2, "b" ), + array( "abc", 1, 2, 3, "c" ), + array( "abc", 1, -2, 2, "b" ), + array( "abc", 0, 2, 2, "" ), array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ), - array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ), - array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bc", 1, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . "bc", 3, 0, 5, $char_a_ring_nfd . "bc" ), - array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ), - array( $char_a_ring_nfd . "bcde", 2, -4, 5, "bc" ), - array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ), - array( $char_a_ring_nfd . "bcde", 2, -7, 4, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ), - array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, -6, 11, "de" . $char_a_ring_nfd . "f" ), - - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 1, $char_a_ring_nfd . "" ), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 0, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 2, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 3, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 4, $char_diaeresis), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 4, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 7, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 8, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), - - ); - - $next = -1; - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract"; - if ( 3 == count( $test ) ) { - $result = grapheme_extract($test[0], $test[1]); - } - elseif ( 4 == count ( $test ) ) { - $res_str .= " starting at byte position $test[2]"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2]); - } - else { - $res_str .= " starting at byte position $test[2] with \$next"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2], $next); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]); - if ( 5 == count ( $test ) ) { - $res_str .= " \$next=$next == $test[3] "; - if ( $next != $test[3] ) { - $res_str .= "***FAILED***"; - } - } - $res_str .= "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)' . "\n\n"; - - $tests = array( - array( "abc", 3, "abc" ), - array( "abc", 2, "ab" ), - array( "abc", 1, "a" ), - array( "abc", 0, "" ), - array( $char_a_ring_nfd . "bc", 5, $char_a_ring_nfd . "bc" ), - array( $char_a_ring_nfd . "bc", 4, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bc", 1, "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 9, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 10, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 11, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 3, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 4, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 5, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 7, $char_a_ring_nfd . $char_o_diaeresis_nfd . "c" ), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 0, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 2, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 3, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 4, $char_diaeresis), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 4, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 7, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 8, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), - - ); - - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES"; - if ( 3 == count( $test ) ) { - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES); - } - else { - $res_str .= " starting at byte position $test[2]"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES, $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)' . "\n\n"; - - $tests = array( - array( "abc", 3, "abc" ), - array( "abc", 2, "ab" ), - array( "abc", 1, "a" ), - array( "abc", 0, "" ), - array( "abc" . $char_o_diaeresis_nfd, 0, "" ), - array( "abc" . $char_o_diaeresis_nfd, 1, "a" ), - array( "abc" . $char_o_diaeresis_nfd, 2, "ab" ), - array( "abc" . $char_o_diaeresis_nfd, 3, "abc" ), - array( "abc" . $char_o_diaeresis_nfd, 4, "abc" ), - array( "abc" . $char_o_diaeresis_nfd, 5, "abc" . $char_o_diaeresis_nfd), - array( "abc" . $char_o_diaeresis_nfd, 6, "abc" . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . "abc", 0, "" ), - array( $char_o_diaeresis_nfd . "abc", 1, "" ), - array( $char_o_diaeresis_nfd . "abc", 2, $char_o_diaeresis_nfd ), - array( $char_o_diaeresis_nfd . "abc", 3, $char_o_diaeresis_nfd . "a" ), - array( $char_o_diaeresis_nfd . "abc", 4, $char_o_diaeresis_nfd . "ab" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 5, $char_o_diaeresis_nfd . "abc" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 6, $char_o_diaeresis_nfd . "abc" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 7, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), - - array( "abc", 3, 0, "abc" ), - array( "abc", 2, 1, "bc" ), - array( "abc", 1, 2, "c" ), - array( "abc", 0, 3, "false" ), - array( "abc", 1, 3, "false" ), - array( "abc", 1, 999, "false" ), - array( $char_o_diaeresis_nfd . "abc", 1, 6, "false" ), - array( $char_o_diaeresis_nfd . "abc", 1, 999, "false" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 0, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 1, $char_diaeresis . "abc" . $char_a_ring_nfd . "xy" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 2, "abc" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 3, "abc" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 4, "bc" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 5, "c" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 6, $char_a_ring_nfd . "xyz" ), - - ); - - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS"; - if ( 3 == count( $test ) ) { - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS); - } - else { - $res_str .= " starting at byte position $test[2]"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS, $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - - return $res_str; + array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ), + array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bc", 1, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . "bc", 3, 0, 5, $char_a_ring_nfd . "bc" ), + array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ), + array( $char_a_ring_nfd . "bcde", 2, -4, 5, "bc" ), + array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ), + array( $char_a_ring_nfd . "bcde", 2, -7, 4, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ), + array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, -6, 11, "de" . $char_a_ring_nfd . "f" ), + + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 1, $char_a_ring_nfd . "" ), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 0, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 2, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 3, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 4, $char_diaeresis), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 4, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 7, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 8, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), + + ); + + $next = -1; + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract"; + if ( 3 == count( $test ) ) { + $result = grapheme_extract($test[0], $test[1]); + } + elseif ( 4 == count ( $test ) ) { + $res_str .= " starting at byte position $test[2]"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2]); + } + else { + $res_str .= " starting at byte position $test[2] with \$next"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2], $next); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]); + if ( 5 == count ( $test ) ) { + $res_str .= " \$next=$next == $test[3] "; + if ( $next != $test[3] ) { + $res_str .= "***FAILED***"; + } + } + $res_str .= "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)' . "\n\n"; + + $tests = array( + array( "abc", 3, "abc" ), + array( "abc", 2, "ab" ), + array( "abc", 1, "a" ), + array( "abc", 0, "" ), + array( $char_a_ring_nfd . "bc", 5, $char_a_ring_nfd . "bc" ), + array( $char_a_ring_nfd . "bc", 4, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bc", 1, "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 9, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 10, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 11, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 3, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 4, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 5, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 7, $char_a_ring_nfd . $char_o_diaeresis_nfd . "c" ), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 0, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 2, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 3, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 4, $char_diaeresis), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 4, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 7, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 8, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), + + ); + + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES"; + if ( 3 == count( $test ) ) { + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES); + } + else { + $res_str .= " starting at byte position $test[2]"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES, $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)' . "\n\n"; + + $tests = array( + array( "abc", 3, "abc" ), + array( "abc", 2, "ab" ), + array( "abc", 1, "a" ), + array( "abc", 0, "" ), + array( "abc" . $char_o_diaeresis_nfd, 0, "" ), + array( "abc" . $char_o_diaeresis_nfd, 1, "a" ), + array( "abc" . $char_o_diaeresis_nfd, 2, "ab" ), + array( "abc" . $char_o_diaeresis_nfd, 3, "abc" ), + array( "abc" . $char_o_diaeresis_nfd, 4, "abc" ), + array( "abc" . $char_o_diaeresis_nfd, 5, "abc" . $char_o_diaeresis_nfd), + array( "abc" . $char_o_diaeresis_nfd, 6, "abc" . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . "abc", 0, "" ), + array( $char_o_diaeresis_nfd . "abc", 1, "" ), + array( $char_o_diaeresis_nfd . "abc", 2, $char_o_diaeresis_nfd ), + array( $char_o_diaeresis_nfd . "abc", 3, $char_o_diaeresis_nfd . "a" ), + array( $char_o_diaeresis_nfd . "abc", 4, $char_o_diaeresis_nfd . "ab" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 5, $char_o_diaeresis_nfd . "abc" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 6, $char_o_diaeresis_nfd . "abc" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 7, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), + + array( "abc", 3, 0, "abc" ), + array( "abc", 2, 1, "bc" ), + array( "abc", 1, 2, "c" ), + array( "abc", 0, 3, "false" ), + array( "abc", 1, 3, "false" ), + array( "abc", 1, 999, "false" ), + array( $char_o_diaeresis_nfd . "abc", 1, 6, "false" ), + array( $char_o_diaeresis_nfd . "abc", 1, 999, "false" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 0, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 1, $char_diaeresis . "abc" . $char_a_ring_nfd . "xy" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 2, "abc" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 3, "abc" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 4, "bc" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 5, "c" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 6, $char_a_ring_nfd . "xyz" ), + + ); + + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS"; + if ( 3 == count( $test ) ) { + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS); + } + else { + $res_str .= " starting at byte position $test[2]"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS, $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + + return $res_str; } echo ut_main(); function check_result($result, $expected) { - if ( $result === false ) { - $result = 'false'; - } + if ( $result === false ) { + $result = 'false'; + } - if ( strcmp($result, $expected) != 0 ) { - return " **FAILED** "; - } + if ( strcmp($result, $expected) != 0 ) { + return " **FAILED** "; + } - return ""; + return ""; } ?> diff --git a/ext/intl/tests/grapheme2.phpt b/ext/intl/tests/grapheme2.phpt index e17b53b0940a..4595b781286e 100644 --- a/ext/intl/tests/grapheme2.phpt +++ b/ext/intl/tests/grapheme2.phpt @@ -12,772 +12,772 @@ grapheme() function ut_main() { - $res_str = ''; - - $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) - $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) - $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) - $char_O_diaeresis = "\xC3\x96"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) - - $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) - $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) - - $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) - $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) - - $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) - - $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) - - $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) - - // the word 'hindi' using Devanagari characters: - $hindi = "\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80"; - - $char_a_ring_nfd = "a\xCC\x8A"; - $char_A_ring_nfd = "A\xCC\x8A"; - $char_o_diaeresis_nfd = "o\xCC\x88"; - $char_O_diaeresis_nfd = "O\xCC\x88"; - $char_diaeresis = "\xCC\x88"; - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strlen($string) {}' . "\n\n"; - - - $res_str .= "\"hindi\" in devanagari strlen " . grapheme_strlen($hindi) . "\n"; - $res_str .= "\"ab\" + \"hindi\" + \"cde\" strlen " . grapheme_strlen('ab' . $hindi . 'cde') . "\n"; - $res_str .= "\"\" strlen " . grapheme_strlen("") . "\n"; - $res_str .= "char_a_ring_nfd strlen " . grapheme_strlen($char_a_ring_nfd) . "\n"; - $res_str .= "char_a_ring_nfd + \"bc\" strlen " . grapheme_strlen($char_a_ring_nfd . 'bc') . "\n"; - $res_str .= "\"abc\" strlen " . grapheme_strlen('abc') . "\n"; - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strpos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( "abc", "d", "false" ), - array( "abc", "c", 2 ), - array( "abc", "b", 1 ), - array( "abc", "a", 0 ), - array( "abc", "a", 0, 0 ), - array( "abc", "a", 1, "false" ), - array( "abc", "a", -1, "false" ), - array( "ababc", "a", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -1, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -5, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, -4, 3 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "bc", "false" ), - array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), - array( "abc", "defghijklmnopq", "false" ), - array( "abc", "ab", 0 ), - array( "abc", "bc", 1 ), - array( "abc", "abc", 0 ), - array( "abc", "abcd", "false" ), - array( "abc", "ab", 0, 0 ), - array( "abc", "abc", 0, 0 ), - array( "abc", "abc", 1, "false" ), - array( "ababc", "ab", 1, 2 ), - array( "ababc", "abc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", -8, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strpos"; - if ( 3 == count( $test ) ) { - $result = grapheme_strpos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_strpos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_stripos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - $tests = array( - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Oo", "o", -6, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, -1, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), - array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "Abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "A", "false" ), - array( "abc", "D", "false" ), - array( "abC", "c", 2 ), - array( "abc", "B", 1 ), - array( "Abc", "a", 0 ), - array( "abc", "A", 0, 0 ), - array( "Abc", "a", 1, "false" ), - array( "ababc", "A", 1, 2 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "BC", "false" ), - array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), - array( "aBC", "Defghijklmnopq", "false" ), - array( "abC", "Ab", 0 ), - array( "aBC", "bc", 1 ), - array( "abC", "Abc", 0 ), - array( "abC", "aBcd", "false" ), - array( "ABc", "ab", 0, 0 ), - array( "aBc", "abC", 0, 0 ), - array( "abc", "aBc", 1, "false" ), - array( "ABabc", "AB", 1, 2 ), - array( "ABabc", "AB", -4, 2 ), - array( "abaBc", "aBc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stripos"; - if ( 3 == count( $test ) ) { - $result = grapheme_stripos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_stripos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strrpos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( "abc", "d", "false" ), - array( "abc", "c", 2 ), - array( "abc", "b", 1 ), - array( "abc", "a", 0 ), - array( "abc", "a", 0, 0 ), - array( "abc", "a", 1, "false" ), - array( "ababc", "a", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "bc", "false" ), - array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), - array( "abc", "defghijklmnopq", "false" ), - array( "abc", "ab", 0 ), - array( "abc", "bc", 1 ), - array( "abc", "abc", 0 ), - array( "abc", "abcd", "false" ), - array( "abc", "ab", 0, 0 ), - array( "abc", "abc", 0, 0 ), - array( "abc", "abc", 1, "false" ), - array( "ababc", "ab", 1, 2 ), - array( "ababc", "abc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strrpos"; - if ( 3 == count( $test ) ) { - $result = grapheme_strrpos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_strrpos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strripos($haystack, $needle, $offset = 0) {}' . "\n\n"; - - $tests = array( - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), - array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), - array( "Abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "A", "false" ), - array( "abc", "D", "false" ), - array( "abC", "c", 2 ), - array( "abc", "B", 1 ), - array( "Abc", "a", 0 ), - array( "abc", "A", 0, 0 ), - array( "Abc", "a", 1, "false" ), - array( "ababc", "A", 1, 2 ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), - array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), - array( "abc", $char_a_ring_nfd . "BC", "false" ), - array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), - array( "aBC", "Defghijklmnopq", "false" ), - array( "abC", "Ab", 0 ), - array( "aBC", "bc", 1 ), - array( "abC", "Abc", 0 ), - array( "abC", "aBcd", "false" ), - array( "ABc", "ab", 0, 0 ), - array( "aBc", "abC", 0, 0 ), - array( "abc", "aBc", 1, "false" ), - array( "ABabc", "AB", 1, 2 ), - array( "abaBc", "aBc", 1, 2 ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strripos"; - if ( 3 == count( $test ) ) { - $result = grapheme_strripos($test[0], $test[1]); - } - else { - $res_str .= " from $test[2]"; - $result = grapheme_strripos($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= $result; - } - $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_substr($string, $start, $length = -1) {}' . "\n\n"; - - $tests = array( - - array( "abc", 3, "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), - array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 2, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", 2, "a" . $char_A_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 5, "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, 4, $char_O_diaeresis_nfd ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "bc" ), - array( "a" . $char_A_ring_nfd . "bc", 1, $char_A_ring_nfd . "bc" ), - array( "Abc", -5, "false" ), - array( $char_a_ring_nfd . "bc", 3, "false" ), - array( "abc", 4, "false" ), - array( "abC", 2, "C" ), - array( "abc", 1, "bc" ), - array( "Abc", 1, 1, "b" ), - array( "abc", 0, 2, "ab" ), - array( "Abc", -4, 1, "false" ), - array( "ababc", 1, 2, "ba" ), - array( "ababc", 0, 10, "ababc" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -3, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -4, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -4, "a" . $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -5, "a" . $char_a_ring_nfd . "b" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -6, "a" . $char_a_ring_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -7, "a" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -8, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -9, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -7, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -6, "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -5, "c" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -4, $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -3, "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -2, "pq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -1, "q" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -999, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 7, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 6, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 5, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 4, "a" . $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 3, "a" . $char_a_ring_nfd . "b" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 2, "a" . $char_a_ring_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 1, "a" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 0, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -999, "false" ), - - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -4, "a" . $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -5, "a" . $char_a_ring_nfd . "b" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -6, "a" . $char_a_ring_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -7, "a" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -8, "" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -9, "false" ), - - ); - - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr"; - if ( 3 == count( $test ) ) { - $result = grapheme_substr($test[0], $test[1]); - } - else { - $res_str .= " with length $test[2]"; - $result = grapheme_substr($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", "o" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, $char_o_diaeresis_nfd ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( "abc", "d", "false" ), - array( "abc", "c", "c" ), - array( "abc", "b", "bc" ), - array( "abc", "a", "abc" ), - array( "abc", "ab", "abc" ), - array( "abc", "abc", "abc" ), - array( "abc", "bc", "bc" ), - array( "abc", "a", FALSE, "abc" ), - array( "abc", "a", TRUE, "" ), - array( "abc", "b", TRUE, "a" ), - array( "abc", "c", TRUE, "ab" ), - array( "ababc", "bab", TRUE, "a" ), - array( "ababc", "abc", TRUE, "ab" ), - array( "ababc", "abc", FALSE, "abc" ), - - array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), - array( "bc" . $char_a_ring_nfd . "a", "a", "a" ), - array( "a" . $char_a_ring_nfd . "bc", "b", "bc" ), - array( $char_a_ring_nfd . "bc", "a", "false" ), - array( $char_a_ring_nfd . "abc", "ab", "abc" ), - array( "abc" . $char_a_ring_nfd, "abc", "abc" . $char_a_ring_nfd), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_a_ring_nfd . "bc"), - array( "a" . $char_a_ring_nfd . "bc", "a", TRUE, "" ), - array( $char_a_ring_nfd . "abc", "b", TRUE, $char_a_ring_nfd . "a" ), - array( "ab" . $char_a_ring_nfd . "c", "c", TRUE, "ab" . $char_a_ring_nfd ), - array( "aba" . $char_a_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), - array( "ababc" . $char_a_ring_nfd, "abc" . $char_a_ring_nfd, TRUE, "ab" ), - array( "abab" . $char_a_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "ab" . $char_a_ring_nfd . "c" ), - - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr"; - if ( 3 == count( $test ) ) { - $result = grapheme_strstr($test[0], $test[1]); - } - else { - $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); - $result = grapheme_strstr($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; - - $tests = array( - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd, $char_o_diaeresis_nfd ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", "O" ), - array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), - array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), - array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, $char_a_ring_nfd . "bc"), - array( "abc", $char_a_ring_nfd, "false" ), - array( $char_a_ring_nfd . "bc", "A", "false" ), - array( "abc", "d", "false" ), - array( "abc", "C", "c" ), - array( "aBc", "b", "Bc" ), - array( "abc", "A", "abc" ), - array( "abC", "ab", "abC" ), - array( "abc", "aBc", "abc" ), - array( "abC", "bc", "bC" ), - array( "abc", "A", FALSE, "abc" ), - array( "abc", "a", TRUE, "" ), - array( "aBc", "b", TRUE, "a" ), - array( "abc", "C", TRUE, "ab" ), - array( "aBabc", "bab", TRUE, "a" ), - array( "ababc", "aBc", TRUE, "ab" ), - array( "ababc", "abC", FALSE, "abc" ), - - array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), - array( "bc" . $char_a_ring_nfd . "A", "a", "A" ), - array( "a" . $char_a_ring_nfd . "bc", "B", "bc" ), - array( $char_A_ring_nfd . "bc", "a", "false" ), - array( $char_a_ring_nfd . "abc", "Ab", "abc" ), - array( "abc" . $char_A_ring_nfd, "abc", "abc" . $char_A_ring_nfd), - array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), - array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_A_ring_nfd . "bc" ), - array( "a" . $char_a_ring_nfd . "bc", "A", TRUE, "" ), - array( $char_a_ring_nfd . "aBc", "b", TRUE, $char_a_ring_nfd . "a" ), - array( "ab" . $char_a_ring_nfd . "c", "C", TRUE, "ab" . $char_a_ring_nfd ), - array( "aba" . $char_A_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), - array( "ababc" . $char_a_ring_nfd, "aBc" . $char_A_ring_nfd, TRUE, "ab" ), - array( "abAB" . $char_A_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "AB" . $char_A_ring_nfd . "c" ), - - ); - - foreach( $tests as $test ) { - $arg1 = urlencode($test[1]); - $arg0 = urlencode($test[0]); - $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stristr"; - if ( 3 == count( $test ) ) { - $result = grapheme_stristr($test[0], $test[1]); - } - else { - $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); - $result = grapheme_stristr($test[0], $test[1], $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])' . "\n\n"; - - $tests = array( - // haystack, count, [[offset], [next]], result - array( "abc", 3, "abc" ), - array( "abc", 2, "ab" ), - array( "abc", 1, "a" ), - array( "abc", 0, "" ), - array( "abc", 1, 0, "a" ), - array( "abc", 1, 1, "b" ), - array( "abc", 1, 2, "c" ), - array( "abc", 0, 2, "" ), - - array( "abc", 3, 0, 3, "abc" ), - array( "abc", 2, 0, 2, "ab" ), - array( "abc", 1, 0, 1, "a" ), - array( "abc", 0, 0, 0, "" ), - array( "abc", 1, 0, 1, "a" ), - array( "abc", 1, 1, 2, "b" ), - array( "abc", 1, 2, 3, "c" ), - array( "abc", 1, -2, 2, "b" ), - array( "abc", 0, 2, 2, "" ), + $res_str = ''; + + $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) + $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) + $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) + $char_O_diaeresis = "\xC3\x96"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) + + $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) + $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) + + $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) + $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) + + $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) + + $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) + + $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) + + // the word 'hindi' using Devanagari characters: + $hindi = "\xe0\xa4\xb9\xe0\xa4\xbf\xe0\xa4\xa8\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x80"; + + $char_a_ring_nfd = "a\xCC\x8A"; + $char_A_ring_nfd = "A\xCC\x8A"; + $char_o_diaeresis_nfd = "o\xCC\x88"; + $char_O_diaeresis_nfd = "O\xCC\x88"; + $char_diaeresis = "\xCC\x88"; + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strlen($string) {}' . "\n\n"; + + + $res_str .= "\"hindi\" in devanagari strlen " . grapheme_strlen($hindi) . "\n"; + $res_str .= "\"ab\" + \"hindi\" + \"cde\" strlen " . grapheme_strlen('ab' . $hindi . 'cde') . "\n"; + $res_str .= "\"\" strlen " . grapheme_strlen("") . "\n"; + $res_str .= "char_a_ring_nfd strlen " . grapheme_strlen($char_a_ring_nfd) . "\n"; + $res_str .= "char_a_ring_nfd + \"bc\" strlen " . grapheme_strlen($char_a_ring_nfd . 'bc') . "\n"; + $res_str .= "\"abc\" strlen " . grapheme_strlen('abc') . "\n"; + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strpos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( "abc", "d", "false" ), + array( "abc", "c", 2 ), + array( "abc", "b", 1 ), + array( "abc", "a", 0 ), + array( "abc", "a", 0, 0 ), + array( "abc", "a", 1, "false" ), + array( "abc", "a", -1, "false" ), + array( "ababc", "a", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -1, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", -5, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, -4, 3 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "bc", "false" ), + array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), + array( "abc", "defghijklmnopq", "false" ), + array( "abc", "ab", 0 ), + array( "abc", "bc", 1 ), + array( "abc", "abc", 0 ), + array( "abc", "abcd", "false" ), + array( "abc", "ab", 0, 0 ), + array( "abc", "abc", 0, 0 ), + array( "abc", "abc", 1, "false" ), + array( "ababc", "ab", 1, 2 ), + array( "ababc", "abc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", -8, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strpos"; + if ( 3 == count( $test ) ) { + $result = grapheme_strpos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_strpos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_stripos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + $tests = array( + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Oo", "o", -6, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, -1, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), + array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "Abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "A", "false" ), + array( "abc", "D", "false" ), + array( "abC", "c", 2 ), + array( "abc", "B", 1 ), + array( "Abc", "a", 0 ), + array( "abc", "A", 0, 0 ), + array( "Abc", "a", 1, "false" ), + array( "ababc", "A", 1, 2 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "BC", "false" ), + array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), + array( "aBC", "Defghijklmnopq", "false" ), + array( "abC", "Ab", 0 ), + array( "aBC", "bc", 1 ), + array( "abC", "Abc", 0 ), + array( "abC", "aBcd", "false" ), + array( "ABc", "ab", 0, 0 ), + array( "aBc", "abC", 0, 0 ), + array( "abc", "aBc", 1, "false" ), + array( "ABabc", "AB", 1, 2 ), + array( "ABabc", "AB", -4, 2 ), + array( "abaBc", "aBc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stripos"; + if ( 3 == count( $test ) ) { + $result = grapheme_stripos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_stripos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strrpos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( "abc", "d", "false" ), + array( "abc", "c", 2 ), + array( "abc", "b", 1 ), + array( "abc", "a", 0 ), + array( "abc", "a", 0, 0 ), + array( "abc", "a", 1, "false" ), + array( "ababc", "a", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "op", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "opq", "opq", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "bc", "false" ), + array( $char_a_ring_nfd . "bc", "abcdefg", "false" ), + array( "abc", "defghijklmnopq", "false" ), + array( "abc", "ab", 0 ), + array( "abc", "bc", 1 ), + array( "abc", "abc", 0 ), + array( "abc", "abcd", "false" ), + array( "abc", "ab", 0, 0 ), + array( "abc", "abc", 0, 0 ), + array( "abc", "abc", 1, "false" ), + array( "ababc", "ab", 1, 2 ), + array( "ababc", "abc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_a_ring_nfd . "bc", "o" . $char_a_ring_nfd . "bc", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_a_ring_nfd . "bc" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strrpos"; + if ( 3 == count( $test ) ) { + $result = grapheme_strrpos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_strrpos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strripos($haystack, $needle, $offset = 0) {}' . "\n\n"; + + $tests = array( + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 2, 3 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "O", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, 2 ), + array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, 1 ), + array( "Abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "A", "false" ), + array( "abc", "D", "false" ), + array( "abC", "c", 2 ), + array( "abc", "B", 1 ), + array( "Abc", "a", 0 ), + array( "abc", "A", 0, 0 ), + array( "Abc", "a", 1, "false" ), + array( "ababc", "A", 1, 2 ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "oP", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", "opQ", 5 ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "abc", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "bC" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd . "bc" . $char_o_diaeresis_nfd, 4 ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "Bc", $char_A_ring_nfd . "bc", 2 ), + array( "a" . $char_a_ring_nfd . "BC", $char_a_ring_nfd . "bc", 1 ), + array( "abc", $char_a_ring_nfd . "BC", "false" ), + array( $char_a_ring_nfd . "BC", "aBCdefg", "false" ), + array( "aBC", "Defghijklmnopq", "false" ), + array( "abC", "Ab", 0 ), + array( "aBC", "bc", 1 ), + array( "abC", "Abc", 0 ), + array( "abC", "aBcd", "false" ), + array( "ABc", "ab", 0, 0 ), + array( "aBc", "abC", 0, 0 ), + array( "abc", "aBc", 1, "false" ), + array( "ABabc", "AB", 1, 2 ), + array( "abaBc", "aBc", 1, 2 ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o" . $char_A_ring_nfd . "bC", "O" . $char_a_ring_nfd . "bC", 2, 6 ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bC" . $char_a_ring_nfd . "def", $char_a_ring_nfd . "Bc" . $char_a_ring_nfd, 2, 3 ), + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strripos"; + if ( 3 == count( $test ) ) { + $result = grapheme_strripos($test[0], $test[1]); + } + else { + $res_str .= " from $test[2]"; + $result = grapheme_strripos($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= $result; + } + $res_str .= " == " . $test[count($test)-1] . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_substr($string, $start, $length = -1) {}' . "\n\n"; + + $tests = array( + + array( "abc", 3, "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), + array( "ao" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 2, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( $char_o_diaeresis_nfd . $char_a_ring_nfd . "a" . $char_A_ring_nfd . "bc", 2, "a" . $char_A_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", 5, "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, 5, "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_O_diaeresis_nfd, 4, $char_O_diaeresis_nfd ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "bc" ), + array( "a" . $char_A_ring_nfd . "bc", 1, $char_A_ring_nfd . "bc" ), + array( "Abc", -5, "false" ), + array( $char_a_ring_nfd . "bc", 3, "false" ), + array( "abc", 4, "false" ), + array( "abC", 2, "C" ), + array( "abc", 1, "bc" ), + array( "Abc", 1, 1, "b" ), + array( "abc", 0, 2, "ab" ), + array( "Abc", -4, 1, "false" ), + array( "ababc", 1, 2, "ba" ), + array( "ababc", 0, 10, "ababc" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, 10 , "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -1, "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -2, "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -3, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 5, -4, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -4, "a" . $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -5, "a" . $char_a_ring_nfd . "b" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -6, "a" . $char_a_ring_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -7, "a" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -8, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", 0, -9, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -7, $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -6, "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -5, "c" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -4, $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -3, "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -2, "pq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -1, "q" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -999, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 8, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 7, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 6, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 5, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 4, "a" . $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 3, "a" . $char_a_ring_nfd . "b" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 2, "a" . $char_a_ring_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 1, "a" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, 0, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -999, "false" ), + + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -1, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Op" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -2, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -3, "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -4, "a" . $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -5, "a" . $char_a_ring_nfd . "b" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -6, "a" . $char_a_ring_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -7, "a" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -8, "" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "Opq", -8, -9, "false" ), + + ); + + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "substring of \"$arg0\" from \"$test[1]\" - grapheme_substr"; + if ( 3 == count( $test ) ) { + $result = grapheme_substr($test[0], $test[1]); + } + else { + $res_str .= " with length $test[2]"; + $result = grapheme_substr($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "o", "o", "o" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_o_diaeresis_nfd, $char_o_diaeresis_nfd ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( "abc", "d", "false" ), + array( "abc", "c", "c" ), + array( "abc", "b", "bc" ), + array( "abc", "a", "abc" ), + array( "abc", "ab", "abc" ), + array( "abc", "abc", "abc" ), + array( "abc", "bc", "bc" ), + array( "abc", "a", FALSE, "abc" ), + array( "abc", "a", TRUE, "" ), + array( "abc", "b", TRUE, "a" ), + array( "abc", "c", TRUE, "ab" ), + array( "ababc", "bab", TRUE, "a" ), + array( "ababc", "abc", TRUE, "ab" ), + array( "ababc", "abc", FALSE, "abc" ), + + array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), + array( "bc" . $char_a_ring_nfd . "a", "a", "a" ), + array( "a" . $char_a_ring_nfd . "bc", "b", "bc" ), + array( $char_a_ring_nfd . "bc", "a", "false" ), + array( $char_a_ring_nfd . "abc", "ab", "abc" ), + array( "abc" . $char_a_ring_nfd, "abc", "abc" . $char_a_ring_nfd), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_a_ring_nfd . "bc"), + array( "a" . $char_a_ring_nfd . "bc", "a", TRUE, "" ), + array( $char_a_ring_nfd . "abc", "b", TRUE, $char_a_ring_nfd . "a" ), + array( "ab" . $char_a_ring_nfd . "c", "c", TRUE, "ab" . $char_a_ring_nfd ), + array( "aba" . $char_a_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), + array( "ababc" . $char_a_ring_nfd, "abc" . $char_a_ring_nfd, TRUE, "ab" ), + array( "abab" . $char_a_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "ab" . $char_a_ring_nfd . "c" ), + + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_strstr"; + if ( 3 == count( $test ) ) { + $result = grapheme_strstr($test[0], $test[1]); + } + else { + $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); + $result = grapheme_strstr($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {}' . "\n\n"; + + $tests = array( + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, $char_O_diaeresis_nfd, $char_o_diaeresis_nfd ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd . "O", "o", "O" ), + array( "a" . $char_a_ring_nfd . "bc" . $char_o_diaeresis_nfd, "o", "false" ), + array( $char_o_diaeresis_nfd . "a" . $char_a_ring_nfd . "bc", $char_a_ring_nfd, $char_a_ring_nfd . "bc"), + array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd, $char_a_ring_nfd . "bc"), + array( "abc", $char_a_ring_nfd, "false" ), + array( $char_a_ring_nfd . "bc", "A", "false" ), + array( "abc", "d", "false" ), + array( "abc", "C", "c" ), + array( "aBc", "b", "Bc" ), + array( "abc", "A", "abc" ), + array( "abC", "ab", "abC" ), + array( "abc", "aBc", "abc" ), + array( "abC", "bc", "bC" ), + array( "abc", "A", FALSE, "abc" ), + array( "abc", "a", TRUE, "" ), + array( "aBc", "b", TRUE, "a" ), + array( "abc", "C", TRUE, "ab" ), + array( "aBabc", "bab", TRUE, "a" ), + array( "ababc", "aBc", TRUE, "ab" ), + array( "ababc", "abC", FALSE, "abc" ), + + array( "ab" . $char_a_ring_nfd . "c", "d", "false" ), + array( "bc" . $char_a_ring_nfd . "A", "a", "A" ), + array( "a" . $char_a_ring_nfd . "bc", "B", "bc" ), + array( $char_A_ring_nfd . "bc", "a", "false" ), + array( $char_a_ring_nfd . "abc", "Ab", "abc" ), + array( "abc" . $char_A_ring_nfd, "abc", "abc" . $char_A_ring_nfd), + array( "a" . $char_a_ring_nfd . "bc", $char_A_ring_nfd . "bc", $char_a_ring_nfd . "bc" ), + array( "a" . $char_A_ring_nfd . "bc", $char_a_ring_nfd, FALSE, $char_A_ring_nfd . "bc" ), + array( "a" . $char_a_ring_nfd . "bc", "A", TRUE, "" ), + array( $char_a_ring_nfd . "aBc", "b", TRUE, $char_a_ring_nfd . "a" ), + array( "ab" . $char_a_ring_nfd . "c", "C", TRUE, "ab" . $char_a_ring_nfd ), + array( "aba" . $char_A_ring_nfd . "bc", "ba" . $char_a_ring_nfd . "b", TRUE, "a" ), + array( "ababc" . $char_a_ring_nfd, "aBc" . $char_A_ring_nfd, TRUE, "ab" ), + array( "abAB" . $char_A_ring_nfd . "c", "ab" . $char_a_ring_nfd . "c", FALSE, "AB" . $char_A_ring_nfd . "c" ), + + ); + + foreach( $tests as $test ) { + $arg1 = urlencode($test[1]); + $arg0 = urlencode($test[0]); + $res_str .= "find \"$arg1\" in \"$arg0\" - grapheme_stristr"; + if ( 3 == count( $test ) ) { + $result = grapheme_stristr($test[0], $test[1]); + } + else { + $res_str .= " before flag is " . ( $test[2] ? "TRUE" : "FALSE" ); + $result = grapheme_stristr($test[0], $test[1], $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0[, $next])' . "\n\n"; + + $tests = array( + // haystack, count, [[offset], [next]], result + array( "abc", 3, "abc" ), + array( "abc", 2, "ab" ), + array( "abc", 1, "a" ), + array( "abc", 0, "" ), + array( "abc", 1, 0, "a" ), + array( "abc", 1, 1, "b" ), + array( "abc", 1, 2, "c" ), + array( "abc", 0, 2, "" ), + + array( "abc", 3, 0, 3, "abc" ), + array( "abc", 2, 0, 2, "ab" ), + array( "abc", 1, 0, 1, "a" ), + array( "abc", 0, 0, 0, "" ), + array( "abc", 1, 0, 1, "a" ), + array( "abc", 1, 1, 2, "b" ), + array( "abc", 1, 2, 3, "c" ), + array( "abc", 1, -2, 2, "b" ), + array( "abc", 0, 2, 2, "" ), array( "http://news.bbc.co.uk/2/hi/middle_east/7831588.stm", 48, 48 , 50 , "tm" ), - array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ), - array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bc", 1, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . "bc", 3, 0, 5, $char_a_ring_nfd . "bc" ), - array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ), - array( $char_a_ring_nfd . "bcde", 2, -4, 5, "bc" ), - array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ), - array( $char_a_ring_nfd . "bcde", 2, -7, 4, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ), - array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, -6, 11, "de" . $char_a_ring_nfd . "f" ), - - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 1, $char_a_ring_nfd . "" ), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 0, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 2, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 3, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 4, $char_diaeresis), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 4, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 7, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 8, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), - - ); - - $next = -1; - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract"; - if ( 3 == count( $test ) ) { - $result = grapheme_extract($test[0], $test[1]); - } - elseif ( 4 == count ( $test ) ) { - $res_str .= " starting at byte position $test[2]"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2]); - } - else { - $res_str .= " starting at byte position $test[2] with \$next"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2], $next); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]); - if ( 5 == count ( $test ) ) { - $res_str .= " \$next=$next == $test[3] "; - if ( $next != $test[3] ) { - $res_str .= "***FAILED***"; - } - } - $res_str .= "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)' . "\n\n"; - - $tests = array( - array( "abc", 3, "abc" ), - array( "abc", 2, "ab" ), - array( "abc", 1, "a" ), - array( "abc", 0, "" ), - array( $char_a_ring_nfd . "bc", 5, $char_a_ring_nfd . "bc" ), - array( $char_a_ring_nfd . "bc", 4, $char_a_ring_nfd . "b" ), - array( $char_a_ring_nfd . "bc", 1, "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 9, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 10, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 11, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 3, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 4, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 5, $char_a_ring_nfd . "" ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), - array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 7, $char_a_ring_nfd . $char_o_diaeresis_nfd . "c" ), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 0, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 2, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 3, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 4, $char_diaeresis), - - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 4, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 7, $char_diaeresis . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 8, $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), - array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), - - ); - - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES"; - if ( 3 == count( $test ) ) { - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES); - } - else { - $res_str .= " starting at byte position $test[2]"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES, $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)' . "\n\n"; - - $tests = array( - array( "abc", 3, "abc" ), - array( "abc", 2, "ab" ), - array( "abc", 1, "a" ), - array( "abc", 0, "" ), - array( "abc" . $char_o_diaeresis_nfd, 0, "" ), - array( "abc" . $char_o_diaeresis_nfd, 1, "a" ), - array( "abc" . $char_o_diaeresis_nfd, 2, "ab" ), - array( "abc" . $char_o_diaeresis_nfd, 3, "abc" ), - array( "abc" . $char_o_diaeresis_nfd, 4, "abc" ), - array( "abc" . $char_o_diaeresis_nfd, 5, "abc" . $char_o_diaeresis_nfd), - array( "abc" . $char_o_diaeresis_nfd, 6, "abc" . $char_o_diaeresis_nfd), - array( $char_o_diaeresis_nfd . "abc", 0, "" ), - array( $char_o_diaeresis_nfd . "abc", 1, "" ), - array( $char_o_diaeresis_nfd . "abc", 2, $char_o_diaeresis_nfd ), - array( $char_o_diaeresis_nfd . "abc", 3, $char_o_diaeresis_nfd . "a" ), - array( $char_o_diaeresis_nfd . "abc", 4, $char_o_diaeresis_nfd . "ab" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 5, $char_o_diaeresis_nfd . "abc" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 6, $char_o_diaeresis_nfd . "abc" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 7, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), - - array( "abc", 3, 0, "abc" ), - array( "abc", 2, 1, "bc" ), - array( "abc", 1, 2, "c" ), - array( "abc", 0, 3, "false" ), - array( "abc", 1, 3, "false" ), - array( "abc", 1, 999, "false" ), - array( $char_o_diaeresis_nfd . "abc", 1, 6, "false" ), - array( $char_o_diaeresis_nfd . "abc", 1, 999, "false" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 0, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 1, $char_diaeresis . "abc" . $char_a_ring_nfd . "xy" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 2, "abc" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 3, "abc" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 4, "bc" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 5, "c" . $char_a_ring_nfd . "xyz" ), - array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 6, $char_a_ring_nfd . "xyz" ), - - ); - - foreach( $tests as $test ) { - $arg0 = urlencode($test[0]); - $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS"; - if ( 3 == count( $test ) ) { - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS); - } - else { - $res_str .= " starting at byte position $test[2]"; - $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS, $test[2]); - } - $res_str .= " = "; - if ( $result === false ) { - $res_str .= 'false'; - } - else { - $res_str .= urlencode($result); - } - $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; - } - - - //===================================================================================== - - return $res_str; + array( $char_a_ring_nfd . "bc", 3, $char_a_ring_nfd . "bc" ), + array( $char_a_ring_nfd . "bc", 2, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bc", 1, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . "bc", 3, 0, 5, $char_a_ring_nfd . "bc" ), + array( $char_a_ring_nfd . "bc", 2, 0, 4, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bc", 1, 0, 3, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . "bcde", 2, 3, 5, "bc" ), + array( $char_a_ring_nfd . "bcde", 2, -4, 5, "bc" ), + array( $char_a_ring_nfd . "bcde", 2, 4, 6, "cd" ), + array( $char_a_ring_nfd . "bcde", 2, -7, 4, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, 5, 11, "de" . $char_a_ring_nfd . "f" ), + array( $char_a_ring_nfd . "bcde" . $char_a_ring_nfd . "f", 4, -6, 11, "de" . $char_a_ring_nfd . "f" ), + + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, $char_a_ring_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 1, $char_a_ring_nfd . "" ), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 0, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 2, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 3, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 1, 4, $char_diaeresis), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 4, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 7, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 8, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), + + ); + + $next = -1; + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract"; + if ( 3 == count( $test ) ) { + $result = grapheme_extract($test[0], $test[1]); + } + elseif ( 4 == count ( $test ) ) { + $res_str .= " starting at byte position $test[2]"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2]); + } + else { + $res_str .= " starting at byte position $test[2] with \$next"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_COUNT, $test[2], $next); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]); + if ( 5 == count ( $test ) ) { + $res_str .= " \$next=$next == $test[3] "; + if ( $next != $test[3] ) { + $res_str .= "***FAILED***"; + } + } + $res_str .= "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXBYTES, $start = 0)' . "\n\n"; + + $tests = array( + array( "abc", 3, "abc" ), + array( "abc", 2, "ab" ), + array( "abc", 1, "a" ), + array( "abc", 0, "" ), + array( $char_a_ring_nfd . "bc", 5, $char_a_ring_nfd . "bc" ), + array( $char_a_ring_nfd . "bc", 4, $char_a_ring_nfd . "b" ), + array( $char_a_ring_nfd . "bc", 1, "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 9, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 10, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 11, $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 3, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 4, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 5, $char_a_ring_nfd . "" ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 6, $char_a_ring_nfd . $char_o_diaeresis_nfd ), + array( $char_a_ring_nfd . $char_o_diaeresis_nfd . "c", 7, $char_a_ring_nfd . $char_o_diaeresis_nfd . "c" ), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 0, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 2, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 3, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 4, $char_diaeresis), + + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 0, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 2, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 6, 3, $char_o_diaeresis_nfd . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 4, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 5, 7, $char_diaeresis . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 3, 8, $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 10, $char_diaeresis), + array( $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd . $char_o_diaeresis_nfd, 2, 11, "false"), + + ); + + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXBYTES"; + if ( 3 == count( $test ) ) { + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES); + } + else { + $res_str .= " starting at byte position $test[2]"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXBYTES, $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + $res_str .= "\n" . 'function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_MAXCHARS, $start = 0)' . "\n\n"; + + $tests = array( + array( "abc", 3, "abc" ), + array( "abc", 2, "ab" ), + array( "abc", 1, "a" ), + array( "abc", 0, "" ), + array( "abc" . $char_o_diaeresis_nfd, 0, "" ), + array( "abc" . $char_o_diaeresis_nfd, 1, "a" ), + array( "abc" . $char_o_diaeresis_nfd, 2, "ab" ), + array( "abc" . $char_o_diaeresis_nfd, 3, "abc" ), + array( "abc" . $char_o_diaeresis_nfd, 4, "abc" ), + array( "abc" . $char_o_diaeresis_nfd, 5, "abc" . $char_o_diaeresis_nfd), + array( "abc" . $char_o_diaeresis_nfd, 6, "abc" . $char_o_diaeresis_nfd), + array( $char_o_diaeresis_nfd . "abc", 0, "" ), + array( $char_o_diaeresis_nfd . "abc", 1, "" ), + array( $char_o_diaeresis_nfd . "abc", 2, $char_o_diaeresis_nfd ), + array( $char_o_diaeresis_nfd . "abc", 3, $char_o_diaeresis_nfd . "a" ), + array( $char_o_diaeresis_nfd . "abc", 4, $char_o_diaeresis_nfd . "ab" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 5, $char_o_diaeresis_nfd . "abc" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 6, $char_o_diaeresis_nfd . "abc" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 7, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), + + array( "abc", 3, 0, "abc" ), + array( "abc", 2, 1, "bc" ), + array( "abc", 1, 2, "c" ), + array( "abc", 0, 3, "false" ), + array( "abc", 1, 3, "false" ), + array( "abc", 1, 999, "false" ), + array( $char_o_diaeresis_nfd . "abc", 1, 6, "false" ), + array( $char_o_diaeresis_nfd . "abc", 1, 999, "false" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 0, $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "x" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 1, $char_diaeresis . "abc" . $char_a_ring_nfd . "xy" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 2, "abc" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 3, "abc" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 4, "bc" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 5, "c" . $char_a_ring_nfd . "xyz" ), + array( $char_o_diaeresis_nfd . "abc" . $char_a_ring_nfd . "xyz", 8, 6, $char_a_ring_nfd . "xyz" ), + + ); + + foreach( $tests as $test ) { + $arg0 = urlencode($test[0]); + $res_str .= "extract from \"$arg0\" \"$test[1]\" graphemes - grapheme_extract GRAPHEME_EXTR_MAXCHARS"; + if ( 3 == count( $test ) ) { + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS); + } + else { + $res_str .= " starting at byte position $test[2]"; + $result = grapheme_extract($test[0], $test[1], GRAPHEME_EXTR_MAXCHARS, $test[2]); + } + $res_str .= " = "; + if ( $result === false ) { + $res_str .= 'false'; + } + else { + $res_str .= urlencode($result); + } + $res_str .= " == " . urlencode($test[count($test)-1]) . check_result($result, $test[count($test)-1]) . "\n"; + } + + + //===================================================================================== + + return $res_str; } echo ut_main(); function check_result($result, $expected) { - if ( $result === false ) { - $result = 'false'; - } + if ( $result === false ) { + $result = 'false'; + } - if ( strcmp($result, $expected) != 0 ) { - return " **FAILED** "; - } + if ( strcmp($result, $expected) != 0 ) { + return " **FAILED** "; + } - return ""; + return ""; } ?> diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt index 2f468a12c5cd..41bfc4939849 100644 --- a/ext/intl/tests/gregoriancalendar___construct_error.phpt +++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt @@ -24,14 +24,14 @@ try { echo $e->getMessage(), "\n"; } try { - var_dump(new IntlGregorianCalendar(1,2,NULL,4)); + var_dump(new IntlGregorianCalendar(1,2,NULL,4)); } catch (ArgumentCountError $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } try { - var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array())); + var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array())); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } --EXPECT-- Too many arguments diff --git a/ext/intl/tests/idn_uts46_basic.phpt b/ext/intl/tests/idn_uts46_basic.phpt index 881e8311c9d1..5178c08d6cae 100644 --- a/ext/intl/tests/idn_uts46_basic.phpt +++ b/ext/intl/tests/idn_uts46_basic.phpt @@ -13,14 +13,14 @@ $asciiNonTrans = "www.xn--fuball-cta.com"; echo "all ok, no details:", "\n"; var_dump(idn_to_ascii($utf8dn, - IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46)); + IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46)); echo "all ok, no details, transitional:", "\n"; var_dump(idn_to_ascii($utf8dn, 0, INTL_IDNA_VARIANT_UTS46)); echo "all ok, with details:", "\n"; var_dump(idn_to_ascii($utf8dn, IDNA_NONTRANSITIONAL_TO_ASCII, - INTL_IDNA_VARIANT_UTS46, $info)); + INTL_IDNA_VARIANT_UTS46, $info)); var_dump($info); echo "reverse, ok, with details:", "\n"; diff --git a/ext/intl/tests/idn_uts46_errors.phpt b/ext/intl/tests/idn_uts46_errors.phpt index e468e8caf886..35aa1cb07386 100644 --- a/ext/intl/tests/idn_uts46_errors.phpt +++ b/ext/intl/tests/idn_uts46_errors.phpt @@ -22,14 +22,14 @@ var_dump(idn_to_ascii("www.fußball.com-", 0, INTL_IDNA_VARIANT_UTS46)); echo "with error, with details arg:", "\n"; var_dump(idn_to_ascii("www.fußball.com-", IDNA_NONTRANSITIONAL_TO_ASCII, - INTL_IDNA_VARIANT_UTS46, $foo)); + INTL_IDNA_VARIANT_UTS46, $foo)); var_dump($foo); echo "with error, with details arg, contextj:", "\n"; var_dump(idn_to_ascii( - html_entity_decode("www.a‍b.com", 0, "UTF-8"), - IDNA_NONTRANSITIONAL_TO_ASCII | IDNA_CHECK_CONTEXTJ, - INTL_IDNA_VARIANT_UTS46, $foo)); + html_entity_decode("www.a‍b.com", 0, "UTF-8"), + IDNA_NONTRANSITIONAL_TO_ASCII | IDNA_CHECK_CONTEXTJ, + INTL_IDNA_VARIANT_UTS46, $foo)); var_dump($foo); var_dump($foo["errors"]==IDNA_ERROR_CONTEXTJ); diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt index 36ccbcb8a0c5..8945c130eb24 100644 --- a/ext/intl/tests/ini_use_exceptions_basic.phpt +++ b/ext/intl/tests/ini_use_exceptions_basic.phpt @@ -7,9 +7,9 @@ intl.use_exceptions INI setting ini_set("intl.use_exceptions", true); $t = transliterator_create('any-hex'); try { - var_dump($t->transliterate('a', 3)); + var_dump($t->transliterate('a', 3)); } catch (IntlException $intlE) { - var_dump($intlE->getMessage()); + var_dump($intlE->getMessage()); } ini_set("intl.use_exceptions", false); ini_set("intl.error_level", E_NOTICE); diff --git a/ext/intl/tests/locale_accept.phpt b/ext/intl/tests/locale_accept.phpt index 6a29cd6723bc..ad1f64e708f1 100644 --- a/ext/intl/tests/locale_accept.phpt +++ b/ext/intl/tests/locale_accept.phpt @@ -12,19 +12,19 @@ locale_accept_from_http function ut_main() { - $res_str = ""; - $http_acc = array( - 'en-us,en;q=0.5', - 'da, en-gb;q=0.8, en;q=0.7', - 'zh, en-us;q=0.8, en;q=0.7', - 'xx, fr-FR;q=0.3, de-DE;q=0.5', - 'none', - ); + $res_str = ""; + $http_acc = array( + 'en-us,en;q=0.5', + 'da, en-gb;q=0.8, en;q=0.7', + 'zh, en-us;q=0.8, en;q=0.7', + 'xx, fr-FR;q=0.3, de-DE;q=0.5', + 'none', + ); foreach($http_acc as $http) { - $res = ut_loc_accept_http($http); - $res_str .= @"Accepting $http: $res\n"; - } + $res = ut_loc_accept_http($http); + $res_str .= @"Accepting $http: $res\n"; + } return $res_str; } diff --git a/ext/intl/tests/locale_bug72658.phpt b/ext/intl/tests/locale_bug72658.phpt index 4a68e2681b33..6ac8048406dc 100644 --- a/ext/intl/tests/locale_bug72658.phpt +++ b/ext/intl/tests/locale_bug72658.phpt @@ -6,8 +6,8 @@ Bug #72658 Locale::lookup() / locale_lookup() hangs if no match found diff --git a/ext/intl/tests/locale_compose_locale.phpt b/ext/intl/tests/locale_compose_locale.phpt index 5eef05b3e634..e09e104c850e 100644 --- a/ext/intl/tests/locale_compose_locale.phpt +++ b/ext/intl/tests/locale_compose_locale.phpt @@ -12,120 +12,120 @@ locale_compose_locale() function ut_main() { - $loc_parts_arr1 = array( - Locale::LANG_TAG =>'sl' , - Locale::SCRIPT_TAG =>'Latn' , - Locale::REGION_TAG =>'IT' - ); - $loc_parts_arr2 = array( - Locale::LANG_TAG =>'de' , - Locale::REGION_TAG =>'DE' - ); - $loc_parts_arr3 = array( - Locale::LANG_TAG =>'hi' - ); - $loc_parts_arr4 = array( - Locale::LANG_TAG =>'zh' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN' - ); - $loc_parts_arr5 = array( - Locale::LANG_TAG =>'es' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN' - ); - $loc_parts_arr6 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - Locale::VARIANT_TAG.'14' =>'rozaj' , - 'variant1'=>'nedis' - ); - $loc_parts_arr7 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - 'variant14'=>'rozaj' , - 'variant1'=>'nedis' , - 'extlang0'=>'lng' , - 'extlang1'=>'ing' - ); - $loc_parts_arr8 = array( - Locale::LANG_TAG =>'en' , - Locale::SCRIPT_TAG =>'Hans' , - Locale::REGION_TAG =>'CN', - 'variant14'=>'rozaj' , - 'variant1'=>'nedis' , - 'extlang0'=>'lng' , - 'extlang1'=>'ing', - 'private7'=>'prv1' , - 'private9'=>'prv2' - ); - $loc_parts_arr9 = array( - Locale::REGION_TAG =>'DE' - ); - $loc_parts_arr10 = array( - Locale::LANG_TAG => 45, - Locale::REGION_TAG => false, - Locale::SCRIPT_TAG => 15 - ); - $loc_parts_arr11 = array( - Locale::LANG_TAG =>'de' , - Locale::REGION_TAG =>'DE', - 'private0' => 13, - 'variant1' => array(), - 'extlang2' => false - ); + $loc_parts_arr1 = array( + Locale::LANG_TAG =>'sl' , + Locale::SCRIPT_TAG =>'Latn' , + Locale::REGION_TAG =>'IT' + ); + $loc_parts_arr2 = array( + Locale::LANG_TAG =>'de' , + Locale::REGION_TAG =>'DE' + ); + $loc_parts_arr3 = array( + Locale::LANG_TAG =>'hi' + ); + $loc_parts_arr4 = array( + Locale::LANG_TAG =>'zh' , + Locale::SCRIPT_TAG =>'Hans' , + Locale::REGION_TAG =>'CN' + ); + $loc_parts_arr5 = array( + Locale::LANG_TAG =>'es' , + Locale::SCRIPT_TAG =>'Hans' , + Locale::REGION_TAG =>'CN' + ); + $loc_parts_arr6 = array( + Locale::LANG_TAG =>'en' , + Locale::SCRIPT_TAG =>'Hans' , + Locale::REGION_TAG =>'CN', + Locale::VARIANT_TAG.'14' =>'rozaj' , + 'variant1'=>'nedis' + ); + $loc_parts_arr7 = array( + Locale::LANG_TAG =>'en' , + Locale::SCRIPT_TAG =>'Hans' , + Locale::REGION_TAG =>'CN', + 'variant14'=>'rozaj' , + 'variant1'=>'nedis' , + 'extlang0'=>'lng' , + 'extlang1'=>'ing' + ); + $loc_parts_arr8 = array( + Locale::LANG_TAG =>'en' , + Locale::SCRIPT_TAG =>'Hans' , + Locale::REGION_TAG =>'CN', + 'variant14'=>'rozaj' , + 'variant1'=>'nedis' , + 'extlang0'=>'lng' , + 'extlang1'=>'ing', + 'private7'=>'prv1' , + 'private9'=>'prv2' + ); + $loc_parts_arr9 = array( + Locale::REGION_TAG =>'DE' + ); + $loc_parts_arr10 = array( + Locale::LANG_TAG => 45, + Locale::REGION_TAG => false, + Locale::SCRIPT_TAG => 15 + ); + $loc_parts_arr11 = array( + Locale::LANG_TAG =>'de' , + Locale::REGION_TAG =>'DE', + 'private0' => 13, + 'variant1' => array(), + 'extlang2' => false + ); $loc_parts_arr12 = array( Locale::LANG_TAG =>'en' , Locale::SCRIPT_TAG =>'Hans' , Locale::REGION_TAG =>'CN', Locale::VARIANT_TAG => array('nedis', 'rozaj'), - Locale::PRIVATE_TAG => array('prv1', 'prv2'), - Locale::EXTLANG_TAG => array('lng', 'ing') + Locale::PRIVATE_TAG => array('prv1', 'prv2'), + Locale::EXTLANG_TAG => array('lng', 'ing') ); - $loc_parts_arr = array( - 'loc1' => $loc_parts_arr1 , - 'loc2' => $loc_parts_arr2 , - 'loc3' => $loc_parts_arr3 , - 'loc4' => $loc_parts_arr4 , - 'loc5' => $loc_parts_arr5 , - 'loc6' => $loc_parts_arr6 , - 'loc7' => $loc_parts_arr7 , - 'loc8' => $loc_parts_arr8 , - 'loc9' => $loc_parts_arr9 , - 'loc10' => $loc_parts_arr10 , - 'loc11' => $loc_parts_arr11 , - 'loc12' => $loc_parts_arr12 - ); + $loc_parts_arr = array( + 'loc1' => $loc_parts_arr1 , + 'loc2' => $loc_parts_arr2 , + 'loc3' => $loc_parts_arr3 , + 'loc4' => $loc_parts_arr4 , + 'loc5' => $loc_parts_arr5 , + 'loc6' => $loc_parts_arr6 , + 'loc7' => $loc_parts_arr7 , + 'loc8' => $loc_parts_arr8 , + 'loc9' => $loc_parts_arr9 , + 'loc10' => $loc_parts_arr10 , + 'loc11' => $loc_parts_arr11 , + 'loc12' => $loc_parts_arr12 + ); error_reporting( E_ERROR ); $cnt = 0; $res_str = ''; - foreach($loc_parts_arr as $key => $value ){ - $res_str .= "\n------------"; - $res_str .= "\nInput Array name is : loc".(++$cnt) ; + foreach($loc_parts_arr as $key => $value ){ + $res_str .= "\n------------"; + $res_str .= "\nInput Array name is : loc".(++$cnt) ; /* - foreach($value as $valKey => $valValue ){ - $res_str .= $valKey ."->".$valValue." " ; - } + foreach($value as $valKey => $valValue ){ + $res_str .= $valKey ."->".$valValue." " ; + } */ - $locale = ut_loc_locale_compose( $value); - $res_str .= "\n\nComposed Locale: "; - if( $locale){ - $res_str .= "$locale"; - }else{ - $res_str .= "No values found from Locale compose due to the following error:\n"; - $res_str .= intl_get_error_message() ; - } - } - - $res_str .= "\n------------"; - $res_str .= "\n"; + $locale = ut_loc_locale_compose( $value); + $res_str .= "\n\nComposed Locale: "; + if( $locale){ + $res_str .= "$locale"; + }else{ + $res_str .= "No values found from Locale compose due to the following error:\n"; + $res_str .= intl_get_error_message() ; + } + } + + $res_str .= "\n------------"; + $res_str .= "\n"; return $res_str; } diff --git a/ext/intl/tests/locale_filter_matches2.phpt b/ext/intl/tests/locale_filter_matches2.phpt index e75079deb3e2..82e16dafceba 100644 --- a/ext/intl/tests/locale_filter_matches2.phpt +++ b/ext/intl/tests/locale_filter_matches2.phpt @@ -13,60 +13,60 @@ locale_filter_matches.phpt() icu >= 4.8 && icu < 50.1.2 function ut_main() { - $loc_ranges = array( - 'de-de', - 'sl_IT', - 'sl_IT_Nedis', - 'jbo', - 'art-lojban', - 'sl_IT' - ); + $loc_ranges = array( + 'de-de', + 'sl_IT', + 'sl_IT_Nedis', + 'jbo', + 'art-lojban', + 'sl_IT' + ); - $lang_tags = array( - 'de-DEVA', - 'de-DE-1996', - 'de-DE', - 'zh_Hans', - 'de-CH-1996', - 'sl_IT', - 'sl_IT_nedis-a-kirti-x-xyz', - 'sl_IT_rozaj', - 'sl_IT_NEDIS_ROJAZ_1901', - 'i-enochian', - 'sgn-CH-de', - 'art-lojban', - 'i-lux', - 'art-lojban', - 'jbo', - 'en_sl_IT' - ); + $lang_tags = array( + 'de-DEVA', + 'de-DE-1996', + 'de-DE', + 'zh_Hans', + 'de-CH-1996', + 'sl_IT', + 'sl_IT_nedis-a-kirti-x-xyz', + 'sl_IT_rozaj', + 'sl_IT_NEDIS_ROJAZ_1901', + 'i-enochian', + 'sgn-CH-de', + 'art-lojban', + 'i-lux', + 'art-lojban', + 'jbo', + 'en_sl_IT' + ); $res_str = ''; $isCanonical = false; - foreach($loc_ranges as $loc_range){ - foreach($lang_tags as $lang_tag){ - $res_str .="--------------\n"; - $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical); - $res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? "; - if( $result){ - $res_str .= "YES\n"; - }else{ - $res_str .= "NO\n"; - } + foreach($loc_ranges as $loc_range){ + foreach($lang_tags as $lang_tag){ + $res_str .="--------------\n"; + $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical); + $res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? "; + if( $result){ + $res_str .= "YES\n"; + }else{ + $res_str .= "NO\n"; + } //canonicalized version - $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical)); - $can_loc_range = ut_loc_canonicalize($loc_range); - $can_lang_tag = ut_loc_canonicalize($lang_tag); - $res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? "; - if( $result){ - $res_str .= "YES\n"; - }else{ - $res_str .= "NO\n"; - } - } - } + $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical)); + $can_loc_range = ut_loc_canonicalize($loc_range); + $can_lang_tag = ut_loc_canonicalize($lang_tag); + $res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? "; + if( $result){ + $res_str .= "YES\n"; + }else{ + $res_str .= "NO\n"; + } + } + } - $res_str .= "\n"; + $res_str .= "\n"; return $res_str; } diff --git a/ext/intl/tests/locale_filter_matches3.phpt b/ext/intl/tests/locale_filter_matches3.phpt index 2816ba5e1220..703ba7815404 100644 --- a/ext/intl/tests/locale_filter_matches3.phpt +++ b/ext/intl/tests/locale_filter_matches3.phpt @@ -13,60 +13,60 @@ locale_filter_matches.phpt() ICU >= 51.2 function ut_main() { - $loc_ranges = array( - 'de-de', - 'sl_IT', - 'sl_IT_Nedis', - 'jbo', - 'art-lojban', - 'sl_IT' - ); + $loc_ranges = array( + 'de-de', + 'sl_IT', + 'sl_IT_Nedis', + 'jbo', + 'art-lojban', + 'sl_IT' + ); - $lang_tags = array( - 'de-DEVA', - 'de-DE-1996', - 'de-DE', - 'zh_Hans', - 'de-CH-1996', - 'sl_IT', - 'sl_IT_nedis-a-kirti-x-xyz', - 'sl_IT_rozaj', - 'sl_IT_NEDIS_ROJAZ_1901', - 'i-enochian', - 'sgn-CH-de', - 'art-lojban', - 'i-lux', - 'art-lojban', - 'jbo', - 'en_sl_IT' - ); + $lang_tags = array( + 'de-DEVA', + 'de-DE-1996', + 'de-DE', + 'zh_Hans', + 'de-CH-1996', + 'sl_IT', + 'sl_IT_nedis-a-kirti-x-xyz', + 'sl_IT_rozaj', + 'sl_IT_NEDIS_ROJAZ_1901', + 'i-enochian', + 'sgn-CH-de', + 'art-lojban', + 'i-lux', + 'art-lojban', + 'jbo', + 'en_sl_IT' + ); $res_str = ''; $isCanonical = false; - foreach($loc_ranges as $loc_range){ - foreach($lang_tags as $lang_tag){ - $res_str .="--------------\n"; - $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical); - $res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? "; - if( $result){ - $res_str .= "YES\n"; - }else{ - $res_str .= "NO\n"; - } + foreach($loc_ranges as $loc_range){ + foreach($lang_tags as $lang_tag){ + $res_str .="--------------\n"; + $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , $isCanonical); + $res_str .= "loc_range:$loc_range matches lang_tag $lang_tag ? "; + if( $result){ + $res_str .= "YES\n"; + }else{ + $res_str .= "NO\n"; + } //canonicalized version - $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical)); - $can_loc_range = ut_loc_canonicalize($loc_range); - $can_lang_tag = ut_loc_canonicalize($lang_tag); - $res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? "; - if( $result){ - $res_str .= "YES\n"; - }else{ - $res_str .= "NO\n"; - } - } - } + $result= ut_loc_locale_filter_matches( $lang_tag , $loc_range , !($isCanonical)); + $can_loc_range = ut_loc_canonicalize($loc_range); + $can_lang_tag = ut_loc_canonicalize($lang_tag); + $res_str .= "loc_range:$can_loc_range canonically matches lang_tag $can_lang_tag ? "; + if( $result){ + $res_str .= "YES\n"; + }else{ + $res_str .= "NO\n"; + } + } + } - $res_str .= "\n"; + $res_str .= "\n"; return $res_str; } diff --git a/ext/intl/tests/locale_get_all_variants.phpt b/ext/intl/tests/locale_get_all_variants.phpt index 8f2bcbfa396d..7807e2b09a6a 100644 --- a/ext/intl/tests/locale_get_all_variants.phpt +++ b/ext/intl/tests/locale_get_all_variants.phpt @@ -12,34 +12,34 @@ locale_get_all_variants.phpt() function ut_main() { - $locales = array( - 'sl_IT_nedis_KIRTI', - 'sl_IT_nedis-a-kirti-x-xyz', - 'sl_IT_rozaj', - 'sl_IT_NEDIS_ROJAZ_1901', - 'i-enochian', - 'zh-hakka', - 'zh-wuu', - 'i-tay', - 'sgn-BE-nl', - 'sgn-CH-de', - 'sl_IT_rozaj@currency=EUR' - ); + $locales = array( + 'sl_IT_nedis_KIRTI', + 'sl_IT_nedis-a-kirti-x-xyz', + 'sl_IT_rozaj', + 'sl_IT_NEDIS_ROJAZ_1901', + 'i-enochian', + 'zh-hakka', + 'zh-wuu', + 'i-tay', + 'sgn-BE-nl', + 'sgn-CH-de', + 'sl_IT_rozaj@currency=EUR' + ); $res_str = ''; - foreach($locales as $locale){ - $variants_arr = ut_loc_locale_get_all_variants( $locale); - $res_str .= "$locale : variants "; - if( $variants_arr){ - foreach($variants_arr as $variant){ - $res_str .= "'$variant',"; - } - }else{ - $res_str .= "--none"; - } - $res_str .= "\n"; - } + foreach($locales as $locale){ + $variants_arr = ut_loc_locale_get_all_variants( $locale); + $res_str .= "$locale : variants "; + if( $variants_arr){ + foreach($variants_arr as $variant){ + $res_str .= "'$variant',"; + } + }else{ + $res_str .= "--none"; + } + $res_str .= "\n"; + } - $res_str .= "\n"; + $res_str .= "\n"; return $res_str; } diff --git a/ext/intl/tests/locale_get_display_language.phpt b/ext/intl/tests/locale_get_display_language.phpt index 2df91ba71d98..e441b2efc6ed 100644 --- a/ext/intl/tests/locale_get_display_language.phpt +++ b/ext/intl/tests/locale_get_display_language.phpt @@ -14,7 +14,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'uk-ua_CALIFORNIA@currency=;currency=GRN', @@ -72,15 +72,15 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_language( $locale ,$disp_locale ); - $res_str .= "disp_locale=$disp_locale : display_language=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_language( $locale ,$disp_locale ); + $res_str .= "disp_locale=$disp_locale : display_language=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_display_name2.phpt b/ext/intl/tests/locale_get_display_name2.phpt index 313e89b3c0e8..1d16dd023b74 100644 --- a/ext/intl/tests/locale_get_display_name2.phpt +++ b/ext/intl/tests/locale_get_display_name2.phpt @@ -15,7 +15,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'sl_IT_nedis_KIRTI', @@ -83,16 +83,16 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_name( $locale ,$disp_locale ); - $scr = str_replace(array('(', ')'), '#', $scr); - $res_str .= "disp_locale=$disp_locale : display_name=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_name( $locale ,$disp_locale ); + $scr = str_replace(array('(', ')'), '#', $scr); + $res_str .= "disp_locale=$disp_locale : display_name=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_display_name3.phpt b/ext/intl/tests/locale_get_display_name3.phpt index 2052a6d45644..d0c2307288e4 100644 --- a/ext/intl/tests/locale_get_display_name3.phpt +++ b/ext/intl/tests/locale_get_display_name3.phpt @@ -15,7 +15,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'sl_IT_nedis_KIRTI', @@ -83,16 +83,16 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_name( $locale ,$disp_locale ); - $scr = str_replace(array('(', ')'), '#', $scr); - $res_str .= "disp_locale=$disp_locale : display_name=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_name( $locale ,$disp_locale ); + $scr = str_replace(array('(', ')'), '#', $scr); + $res_str .= "disp_locale=$disp_locale : display_name=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_display_name4.phpt b/ext/intl/tests/locale_get_display_name4.phpt index a0b40a4114be..e431b25151fb 100644 --- a/ext/intl/tests/locale_get_display_name4.phpt +++ b/ext/intl/tests/locale_get_display_name4.phpt @@ -16,7 +16,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'sl_IT_nedis_KIRTI', @@ -84,16 +84,16 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_name( $locale ,$disp_locale ); - $scr = str_replace(array('(', ')'), '#', $scr); - $res_str .= "disp_locale=$disp_locale : display_name=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_name( $locale ,$disp_locale ); + $scr = str_replace(array('(', ')'), '#', $scr); + $res_str .= "disp_locale=$disp_locale : display_name=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_display_name5.phpt b/ext/intl/tests/locale_get_display_name5.phpt index ac64fee02124..9f4e1b645c51 100644 --- a/ext/intl/tests/locale_get_display_name5.phpt +++ b/ext/intl/tests/locale_get_display_name5.phpt @@ -16,7 +16,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'sl_IT_nedis_KIRTI', @@ -84,16 +84,16 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_name( $locale ,$disp_locale ); - $scr = str_replace(array('(', ')'), '#', $scr); - $res_str .= "disp_locale=$disp_locale : display_name=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_name( $locale ,$disp_locale ); + $scr = str_replace(array('(', ')'), '#', $scr); + $res_str .= "disp_locale=$disp_locale : display_name=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_display_name6.phpt b/ext/intl/tests/locale_get_display_name6.phpt index 9d0542c3d412..a00464e73ea3 100644 --- a/ext/intl/tests/locale_get_display_name6.phpt +++ b/ext/intl/tests/locale_get_display_name6.phpt @@ -16,7 +16,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'sl_IT_nedis_KIRTI', @@ -84,16 +84,16 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_name( $locale ,$disp_locale ); - $scr = str_replace(array('(', ')'), '#', $scr); - $res_str .= "disp_locale=$disp_locale : display_name=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_name( $locale ,$disp_locale ); + $scr = str_replace(array('(', ')'), '#', $scr); + $res_str .= "disp_locale=$disp_locale : display_name=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_display_name7.phpt b/ext/intl/tests/locale_get_display_name7.phpt index 91e2c92e87d9..8ef0c09241ac 100644 --- a/ext/intl/tests/locale_get_display_name7.phpt +++ b/ext/intl/tests/locale_get_display_name7.phpt @@ -15,7 +15,7 @@ function ut_main() { $res_str=''; - $disp_locales=array('en','fr','de'); + $disp_locales=array('en','fr','de'); $locales = array( 'sl_IT_nedis_KIRTI', @@ -83,16 +83,16 @@ function ut_main() $res_str = ''; - foreach( $locales as $locale ) + foreach( $locales as $locale ) { - $res_str .= "locale='$locale'\n"; - foreach( $disp_locales as $disp_locale ) - { - $scr = ut_loc_get_display_name( $locale ,$disp_locale ); - $scr = str_replace(array('(', ')'), '#', $scr); - $res_str .= "disp_locale=$disp_locale : display_name=$scr"; - $res_str .= "\n"; - } + $res_str .= "locale='$locale'\n"; + foreach( $disp_locales as $disp_locale ) + { + $scr = ut_loc_get_display_name( $locale ,$disp_locale ); + $scr = str_replace(array('(', ')'), '#', $scr); + $res_str .= "disp_locale=$disp_locale : display_name=$scr"; + $res_str .= "\n"; + } $res_str .= "-----------------\n"; } diff --git a/ext/intl/tests/locale_get_keywords2.phpt b/ext/intl/tests/locale_get_keywords2.phpt index 23a099b4ede7..8d6f3d113bc6 100644 --- a/ext/intl/tests/locale_get_keywords2.phpt +++ b/ext/intl/tests/locale_get_keywords2.phpt @@ -15,12 +15,12 @@ function ut_main() $res_str = ''; $locales = array( - "de_DE@currency=EUR;collation=PHONEBOOK", + "de_DE@currency=EUR;collation=PHONEBOOK", 'uk-ua_CALIFORNIA@currency=GRN' - ); + ); $locales = array( - 'de_DE@currency=EUR;collation=PHONEBOOK', + 'de_DE@currency=EUR;collation=PHONEBOOK', 'root', 'uk@currency=EURO', 'Hindi', @@ -77,14 +77,14 @@ function ut_main() { $keywords_arr = ut_loc_get_keywords( $locale); $res_str .= "$locale: "; - if( $keywords_arr){ - foreach( $keywords_arr as $key => $value){ - $res_str .= "Key is $key and Value is $value \n"; - } - } - else{ - $res_str .= "No keywords found."; - } + if( $keywords_arr){ + foreach( $keywords_arr as $key => $value){ + $res_str .= "Key is $key and Value is $value \n"; + } + } + else{ + $res_str .= "No keywords found."; + } $res_str .= "\n"; } diff --git a/ext/intl/tests/locale_get_primary_language.phpt b/ext/intl/tests/locale_get_primary_language.phpt index 65ec3d89bcdd..69201e8de2a4 100644 --- a/ext/intl/tests/locale_get_primary_language.phpt +++ b/ext/intl/tests/locale_get_primary_language.phpt @@ -16,14 +16,14 @@ function ut_main() $locales = array( 'uk-ua_CALIFORNIA@currency=;currency=GRN', - 'root', + 'root', 'uk@currency=EURO', 'Hindi', //Simple language subtag 'de', 'fr', 'ja', - 'i-enochian', //(example of a grandfathered tag) + 'i-enochian', //(example of a grandfathered tag) //Language subtag plus Script subtag: 'zh-Hant', 'zh-Hans', diff --git a/ext/intl/tests/locale_lookup.phpt b/ext/intl/tests/locale_lookup.phpt index 9d4843038deb..da67b390fa93 100644 --- a/ext/intl/tests/locale_lookup.phpt +++ b/ext/intl/tests/locale_lookup.phpt @@ -13,39 +13,39 @@ locale_lookup.phpt() icu >= 4.8 && icu < 50.1.2 function ut_main() { - $loc_ranges = array( - 'de-de', - 'sl_IT', - 'sl_IT_Nedis', - 'jbo', - 'art-lojban' - ); - - $lang_tags = array( - 'de-DEVA', - 'de-DE-1996', - 'de-DE', - 'zh_Hans', - 'de-CH-1996', - 'sl_IT', - 'sl_IT_nedis-a-kirti-x-xyz', - 'sl_IT_rozaj', - 'sl_IT_NEDIS_ROJAZ_1901', - 'i-enochian', - 'sgn-CH-de', - 'art-lojban', - 'i-lux', - 'art-lojban', - 'jbo', - 'en_sl_IT', - 'zh-Hant-CN-x-prv1-prv2' - ); + $loc_ranges = array( + 'de-de', + 'sl_IT', + 'sl_IT_Nedis', + 'jbo', + 'art-lojban' + ); + + $lang_tags = array( + 'de-DEVA', + 'de-DE-1996', + 'de-DE', + 'zh_Hans', + 'de-CH-1996', + 'sl_IT', + 'sl_IT_nedis-a-kirti-x-xyz', + 'sl_IT_rozaj', + 'sl_IT_NEDIS_ROJAZ_1901', + 'i-enochian', + 'sgn-CH-de', + 'art-lojban', + 'i-lux', + 'art-lojban', + 'jbo', + 'en_sl_IT', + 'zh-Hant-CN-x-prv1-prv2' + ); $res_str = ''; $isCanonical = false; - foreach($loc_ranges as $loc_range){ + foreach($loc_ranges as $loc_range){ $res_str .="--------------\n"; $result= ut_loc_locale_lookup( $lang_tags , $loc_range,$isCanonical,"en_US"); $comma_arr =implode(",",$lang_tags); @@ -56,9 +56,9 @@ function ut_main() $can_loc_range = ut_loc_canonicalize($loc_range); $res_str .= "Canonical lookup result:$result\n"; - } + } - $res_str .= "\n"; + $res_str .= "\n"; return $res_str; } diff --git a/ext/intl/tests/locale_lookup_variant2.phpt b/ext/intl/tests/locale_lookup_variant2.phpt index 75a5350abfb8..7375284a0b1b 100644 --- a/ext/intl/tests/locale_lookup_variant2.phpt +++ b/ext/intl/tests/locale_lookup_variant2.phpt @@ -13,39 +13,39 @@ locale_lookup.phpt() function ut_main() { - $loc_ranges = array( - 'de-de', - 'sl_IT', - 'sl_IT_Nedis', - 'jbo', - 'art-lojban' - ); - - $lang_tags = array( - 'de-DEVA', - 'de-DE-1996', - 'de-DE', - 'zh_Hans', - 'de-CH-1996', - 'sl_IT', - 'sl_IT_nedis-a-kirti-x-xyz', - 'sl_IT_rozaj', - 'sl_IT_NEDIS_ROJAZ_1901', - 'i-enochian', - 'sgn-CH-de', - 'art-lojban', - 'i-lux', - 'art-lojban', - 'jbo', - 'en_sl_IT', - 'zh-Hant-CN-x-prv1-prv2' - ); + $loc_ranges = array( + 'de-de', + 'sl_IT', + 'sl_IT_Nedis', + 'jbo', + 'art-lojban' + ); + + $lang_tags = array( + 'de-DEVA', + 'de-DE-1996', + 'de-DE', + 'zh_Hans', + 'de-CH-1996', + 'sl_IT', + 'sl_IT_nedis-a-kirti-x-xyz', + 'sl_IT_rozaj', + 'sl_IT_NEDIS_ROJAZ_1901', + 'i-enochian', + 'sgn-CH-de', + 'art-lojban', + 'i-lux', + 'art-lojban', + 'jbo', + 'en_sl_IT', + 'zh-Hant-CN-x-prv1-prv2' + ); $res_str = ''; $isCanonical = false; - foreach($loc_ranges as $loc_range){ + foreach($loc_ranges as $loc_range){ $res_str .="--------------\n"; $result= ut_loc_locale_lookup( $lang_tags , $loc_range,$isCanonical,"en_US"); $comma_arr =implode(",",$lang_tags); @@ -56,9 +56,9 @@ function ut_main() $can_loc_range = ut_loc_canonicalize($loc_range); $res_str .= "Canonical lookup result:$result\n"; - } + } - $res_str .= "\n"; + $res_str .= "\n"; return $res_str; } diff --git a/ext/intl/tests/locale_parse_locale2.phpt b/ext/intl/tests/locale_parse_locale2.phpt index c823f8c5048b..59e0c1f67816 100644 --- a/ext/intl/tests/locale_parse_locale2.phpt +++ b/ext/intl/tests/locale_parse_locale2.phpt @@ -63,7 +63,7 @@ function ut_main() 'de-419-DE', 'a-DE', 'ar-a-aaa-b-bbb-a-ccc', - 'x-AAAAAA', + 'x-AAAAAA', ); diff --git a/ext/intl/tests/locale_set_default.phpt b/ext/intl/tests/locale_set_default.phpt index d56c9177cdeb..9f7438b98ba3 100644 --- a/ext/intl/tests/locale_set_default.phpt +++ b/ext/intl/tests/locale_set_default.phpt @@ -67,22 +67,22 @@ function ut_main() ); /* - $locales = array( - 'es' - ); + $locales = array( + 'es' + ); */ $res_str = ''; foreach( $locales as $locale ) { $isSuccessful = ut_loc_set_default( $locale); - if ($isSuccessful ){ - $lang = ut_loc_get_default( ); - $res_str .= "$locale: set locale '$lang'"; - } - else{ - $res_str .= "$locale: Error in set locale"; - } + if ($isSuccessful ){ + $lang = ut_loc_get_default( ); + $res_str .= "$locale: set locale '$lang'"; + } + else{ + $res_str .= "$locale: Error in set locale"; + } $res_str .= "\n"; } diff --git a/ext/intl/tests/msgfmt_bug70484.phpt b/ext/intl/tests/msgfmt_bug70484.phpt index f317be30dbc8..660fc92f3b22 100644 --- a/ext/intl/tests/msgfmt_bug70484.phpt +++ b/ext/intl/tests/msgfmt_bug70484.phpt @@ -12,25 +12,25 @@ $locale = array("de", "fr", "en", "ru",); $data = array(42, 42.42, 2147483643, 2147483643.12345, 5); foreach ($locale as $lc) { - echo "$lc string key\n"; - $m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); - foreach ($data as $i) { - var_dump($m->format(array("n" => $i))); - if ($m->getErrorCode()) { - echo "$lc $i ", $m->getErrorMessage(); - } - } - echo "\n"; + echo "$lc string key\n"; + $m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); + foreach ($data as $i) { + var_dump($m->format(array("n" => $i))); + if ($m->getErrorCode()) { + echo "$lc $i ", $m->getErrorMessage(); + } + } + echo "\n"; - echo "$lc numeric key\n"; - $m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); - foreach ($data as $i) { - var_dump($m->format(array($i))); - if ($m->getErrorCode()) { - echo "$lc $i ", $m->getErrorMessage(); - } - } - echo "\n"; + echo "$lc numeric key\n"; + $m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); + foreach ($data as $i) { + var_dump($m->format(array($i))); + if ($m->getErrorCode()) { + echo "$lc $i ", $m->getErrorMessage(); + } + } + echo "\n"; } ?> diff --git a/ext/intl/tests/msgfmt_clone_bad_obj.phpt b/ext/intl/tests/msgfmt_clone_bad_obj.phpt index 69105a6b0453..829cd6f1e22c 100644 --- a/ext/intl/tests/msgfmt_clone_bad_obj.phpt +++ b/ext/intl/tests/msgfmt_clone_bad_obj.phpt @@ -6,14 +6,14 @@ Cloning unconstructed MessageFormatter getMessage()); + var_dump($e->getMessage()); } --EXPECTF-- string(%d) "Cannot clone unconstructed MessageFormatter" diff --git a/ext/intl/tests/msgfmt_fail2.phpt b/ext/intl/tests/msgfmt_fail2.phpt index 688e65a861ae..060976d19ed2 100644 --- a/ext/intl/tests/msgfmt_fail2.phpt +++ b/ext/intl/tests/msgfmt_fail2.phpt @@ -6,104 +6,104 @@ msgfmt creation failures icu >= 4.8 getMessage() + echo "\n" . get_class($e) . ": " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; } function crt($t, $l, $s) { - switch(true) { - case $t == "O": - try { - return new MessageFormatter($l, $s); - } catch (Throwable $e) { - print_exception($e); - return null; - } - break; - case $t == "C": - try { - return MessageFormatter::create($l, $s); - } catch (Throwable $e) { - print_exception($e); - return null; - } - break; - case $t == "P": - try { - return msgfmt_create($l, $s); - } catch (Throwable $e) { - print_exception($e); - return null; - } - break; - } + switch(true) { + case $t == "O": + try { + return new MessageFormatter($l, $s); + } catch (Throwable $e) { + print_exception($e); + return null; + } + break; + case $t == "C": + try { + return MessageFormatter::create($l, $s); + } catch (Throwable $e) { + print_exception($e); + return null; + } + break; + case $t == "P": + try { + return msgfmt_create($l, $s); + } catch (Throwable $e) { + print_exception($e); + return null; + } + break; + } } $args = array( - array(null, null), - array("whatever", "{0,whatever}"), - array(array(), array()), - array("en", "{0,choice}"), - array("fr", "{0,"), - array("en_US", "\xD0"), + array(null, null), + array("whatever", "{0,whatever}"), + array(array(), array()), + array("en", "{0,choice}"), + array("fr", "{0,"), + array("en_US", "\xD0"), ); try { - $fmt = new MessageFormatter(); + $fmt = new MessageFormatter(); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = msgfmt_create(); + $fmt = msgfmt_create(); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = MessageFormatter::create(); + $fmt = MessageFormatter::create(); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = new MessageFormatter('en'); + $fmt = new MessageFormatter('en'); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = msgfmt_create('en'); + $fmt = msgfmt_create('en'); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); try { - $fmt = MessageFormatter::create('en'); + $fmt = MessageFormatter::create('en'); } catch (TypeError $e) { - print_exception($e); - $fmt = null; + print_exception($e); + $fmt = null; } err($fmt); foreach($args as $arg) { - $fmt = crt("O", $arg[0], $arg[1]); - err($fmt); - $fmt = crt("C", $arg[0], $arg[1]); - err($fmt); - $fmt = crt("P", $arg[0], $arg[1]); - err($fmt); + $fmt = crt("O", $arg[0], $arg[1]); + err($fmt); + $fmt = crt("C", $arg[0], $arg[1]); + err($fmt); + $fmt = crt("P", $arg[0], $arg[1]); + err($fmt); } ?> diff --git a/ext/intl/tests/msgfmt_format.phpt b/ext/intl/tests/msgfmt_format.phpt index 19581e9698d2..55f7d659062f 100644 --- a/ext/intl/tests/msgfmt_format.phpt +++ b/ext/intl/tests/msgfmt_format.phpt @@ -17,24 +17,24 @@ function ut_main() 'ru_UA' => "{0,number,integer} мавп на {1,number,integer} деревах це {2,number} мавпи на кожному деревi", 'de' => "{0,number,integer} Affen über {1,number,integer} Bäume um {2,number} Affen pro Baum", 'en_UK' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree", - 'root' => '{0,whatever} would not work!', - 'fr' => "C'est la vie!", + 'root' => '{0,whatever} would not work!', + 'fr' => "C'est la vie!", ); $str_res = ''; - $m = 4560; - $t = 123; + $m = 4560; + $t = 123; foreach( $locales as $locale => $pattern ) { $str_res .= "\nLocale is: $locale\n"; $fmt = ut_msgfmt_create( $locale, $pattern ); - if(!$fmt) { - $str_res .= dump(intl_get_error_message())."\n"; - continue; - } + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + continue; + } $str_res .= dump( ut_msgfmt_format( $fmt, array($m, $t, $m/$t) ) ) . "\n"; - $str_res .= dump( ut_msgfmt_format_message($locale, $pattern, array($m, $t, $m/$t))) . "\n"; + $str_res .= dump( ut_msgfmt_format_message($locale, $pattern, array($m, $t, $m/$t))) . "\n"; } return $str_res; } diff --git a/ext/intl/tests/msgfmt_format_intlcalendar.phpt b/ext/intl/tests/msgfmt_format_intlcalendar.phpt index 69f32e95f300..4867d767edd0 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar.phpt @@ -20,7 +20,7 @@ echo $msgf->format(array($cal)), "\n"; '{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; + $msgf->format(array($time, 'time')), "\n"; */ ?> diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt index 105792bff598..d60ce8c56665 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt @@ -20,7 +20,7 @@ echo $msgf->format(array($cal)), "\n"; '{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; + $msgf->format(array($time, 'time')), "\n"; */ ?> diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt index 505a2fdafd7a..9235a559f832 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt @@ -21,7 +21,7 @@ echo $msgf->format(array($cal)), "\n"; '{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; + $msgf->format(array($time, 'time')), "\n"; */ ?> diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt index e10a51c7b80e..c03254096a18 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt @@ -20,7 +20,7 @@ echo $msgf->format(array($cal)), "\n"; '{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; + $msgf->format(array($time, 'time')), "\n"; */ ?> diff --git a/ext/intl/tests/msgfmt_format_mixed_params.phpt b/ext/intl/tests/msgfmt_format_mixed_params.phpt index a9e403a79989..f891e973c04e 100644 --- a/ext/intl/tests/msgfmt_format_mixed_params.phpt +++ b/ext/intl/tests/msgfmt_format_mixed_params.phpt @@ -10,7 +10,7 @@ ini_set("intl.error_level", E_WARNING); //ini_set("intl.default_locale", "nl"); $mf = new MessageFormatter('en_US', - "{0,number} -- {foo,ordinal}"); + "{0,number} -- {foo,ordinal}"); var_dump($mf->format(array(2.3, "foo" => 1.3))); var_dump($mf->format(array("foo" => 1.3, 0 => 2.3))); diff --git a/ext/intl/tests/msgfmt_format_subpatterns.phpt b/ext/intl/tests/msgfmt_format_subpatterns.phpt index c18bb4be8880..50970f0b9e3f 100644 --- a/ext/intl/tests/msgfmt_format_subpatterns.phpt +++ b/ext/intl/tests/msgfmt_format_subpatterns.phpt @@ -45,10 +45,10 @@ $args = array( $str_res = ''; $fmt = ut_msgfmt_create( 'en_US', $pattern ); - if(!$fmt) { - $str_res .= dump(intl_get_error_message())."\n"; - return $str_res; - } + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + return $str_res; + } foreach ($args as $arg) { $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n"; $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n"; diff --git a/ext/intl/tests/msgfmt_format_subpatterns_named.phpt b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt index 249f73ce2c87..7b56ccb4cc7a 100644 --- a/ext/intl/tests/msgfmt_format_subpatterns_named.phpt +++ b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt @@ -45,10 +45,10 @@ $args = array( $str_res = ''; $fmt = ut_msgfmt_create( 'en_US', $pattern ); - if(!$fmt) { - $str_res .= dump(intl_get_error_message())."\n"; - return $str_res; - } + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + return $str_res; + } foreach ($args as $arg) { $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n"; $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n"; diff --git a/ext/intl/tests/msgfmt_millisecond_dates.phpt b/ext/intl/tests/msgfmt_millisecond_dates.phpt index 8fc2f04e84f9..2a5723f2e0f9 100644 --- a/ext/intl/tests/msgfmt_millisecond_dates.phpt +++ b/ext/intl/tests/msgfmt_millisecond_dates.phpt @@ -11,7 +11,7 @@ date_default_timezone_set('Europe/Lisbon'); //ignored for now, see bug #58756 $d = 1336308097.123; $mf = new MessageFormatter('en_US', - "On {0,time,yyyy-MM-dd G 'at' HH:mm:ss.SSS zzz} something odd happened"); + "On {0,time,yyyy-MM-dd G 'at' HH:mm:ss.SSS zzz} something odd happened"); var_dump($mf->format(array(1336310569.123))); diff --git a/ext/intl/tests/msgfmt_parse.phpt b/ext/intl/tests/msgfmt_parse.phpt index 95645a63a02a..962aa083fdf1 100644 --- a/ext/intl/tests/msgfmt_parse.phpt +++ b/ext/intl/tests/msgfmt_parse.phpt @@ -17,32 +17,32 @@ function ut_main() 'ru_UA' => "{0,number,integer} мавп на {1,number,integer} деревах це {2,number} мавпи на кожному деревi", 'de' => "{0,number,integer} Affen über {1,number,integer} Bäume um {2,number} Affen pro Baum", 'en_UK' => "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree", - 'root' => '{0,whatever} would not work!', - 'fr' => 'C\'est {0,number,integer}', + 'root' => '{0,whatever} would not work!', + 'fr' => 'C\'est {0,number,integer}', ); - $results = array( - 'en_US' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", - 'ru_UA' => "4 560 мавп на 123 деревах це 37,073 мавпи на кожному деревi", - 'de' => "4.560 Affen über 123 Bäume um 37,073 Affen pro Baum", - 'en_UK' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", - 'root' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", - 'fr' => "C'est 42", + $results = array( + 'en_US' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", + 'ru_UA' => "4 560 мавп на 123 деревах це 37,073 мавпи на кожному деревi", + 'de' => "4.560 Affen über 123 Bäume um 37,073 Affen pro Baum", + 'en_UK' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", + 'root' => "4,560 monkeys on 123 trees make 37.073 monkeys per tree", + 'fr' => "C'est 42", - ); + ); - $str_res = ''; + $str_res = ''; foreach( $locales as $locale => $pattern ) { $str_res .= "\nLocale is: $locale\n"; $fmt = ut_msgfmt_create( $locale, $pattern ); - if(!$fmt) { - $str_res .= dump(intl_get_error_message())."\n"; - continue; - } + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + continue; + } $str_res .= dump( ut_msgfmt_parse( $fmt, $results[$locale] ) ) . "\n"; - $str_res .= dump( ut_msgfmt_parse_message($locale, $pattern, $results[$locale])) . "\n"; + $str_res .= dump( ut_msgfmt_parse_message($locale, $pattern, $results[$locale])) . "\n"; } return $str_res; } diff --git a/ext/intl/tests/msgfmt_setPattern_cache.phpt b/ext/intl/tests/msgfmt_setPattern_cache.phpt index 7afbcbd93b5f..86fda51d4124 100644 --- a/ext/intl/tests/msgfmt_setPattern_cache.phpt +++ b/ext/intl/tests/msgfmt_setPattern_cache.phpt @@ -10,7 +10,7 @@ ini_set("intl.error_level", E_WARNING); //ini_set("intl.default_locale", "nl"); $mf = new MessageFormatter('en_US', - "{0,number} -- {1,ordinal}"); + "{0,number} -- {1,ordinal}"); var_dump($mf->format(array(1.3, 1.3))); var_dump($mf->format(array(1.3, 1.3))); diff --git a/ext/intl/tests/normalizer_get_raw_decomposition.phpt b/ext/intl/tests/normalizer_get_raw_decomposition.phpt index 63caa7d47281..590707280f62 100644 --- a/ext/intl/tests/normalizer_get_raw_decomposition.phpt +++ b/ext/intl/tests/normalizer_get_raw_decomposition.phpt @@ -13,15 +13,15 @@ normalizer_get_raw_decomposition() function ut_main() { - $result = ''; - $strings = [ - "a", + $result = ''; + $strings = [ + "a", "\u{FFDA}", "\u{FDFA}", "", "aa", "\xF5", - ]; + ]; foreach ($strings as $string) { $decomposition = ut_norm_get_raw_decomposition($string, Normalizer::FORM_KC); @@ -39,7 +39,7 @@ function ut_main() $result .= "error info: '$error_message' ($error_code)\n"; } - return $result; + return $result; } include_once( 'ut_common.inc' ); diff --git a/ext/intl/tests/normalizer_normalize.phpt b/ext/intl/tests/normalizer_normalize.phpt index 8f15ffb1d840..1a5050526efb 100644 --- a/ext/intl/tests/normalizer_normalize.phpt +++ b/ext/intl/tests/normalizer_normalize.phpt @@ -12,81 +12,81 @@ normalize() function ut_main() { - $res_str = ''; - - $forms = array( - Normalizer::FORM_C, - Normalizer::FORM_D, - Normalizer::FORM_KC, - Normalizer::FORM_KD, - ); - - $forms_str = array ( - Normalizer::FORM_C => 'UNORM_FORM_C', - Normalizer::FORM_D => 'UNORM_FORM_D', - Normalizer::FORM_KC => 'UNORM_FORM_KC', - Normalizer::FORM_KD => 'UNORM_FORM_KD', - ); - - /* just make sure all the form constants are defined as in the api spec */ - if ( Normalizer::FORM_C != Normalizer::NFC || - Normalizer::FORM_D != Normalizer::NFD || - Normalizer::FORM_KC != Normalizer::NFKC || - Normalizer::FORM_KD != Normalizer::NFKD) { - - $res_str .= "Invalid normalization form declarations!\n"; - } - - $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) - $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) - $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) - - $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) - $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) - - $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) - $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) - - $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) - - $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) - - $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) - - $strs = array( - 'ABC', - $char_a_diaeresis . '||' . $char_a_ring . '||' . $char_o_diaeresis, - $char_angstrom_sign . '||' . $char_A_ring . '||' . 'A' . $char_combining_ring_above, - $char_ohm_sign . '||' . $char_omega, - $char_fi_ligature, - $char_long_s_dot, - ); - - foreach( $forms as $form ) - { - foreach( $strs as $str ) - { - $str_norm = ut_norm_normalize( $str, $form ); - $error_code = intl_get_error_code(); - $error_message = intl_get_error_message(); - - $str_hex = urlencode($str); - $str_norm_hex = urlencode($str_norm); - $res_str .= "'$str_hex' normalized to form '{$forms_str[$form]}' is '$str_norm_hex'" - . "\terror info: '$error_message' ($error_code)\n" - . ""; - - $is_norm = ut_norm_is_normalized( $str, $form ); - $error_code = intl_get_error_code(); - $error_message = intl_get_error_message(); - - $res_str .= " is in form '{$forms_str[$form]}'? = " . ($is_norm ? "yes" : "no") - . "\terror info: '$error_message' ($error_code)\n" - . ""; - } - } - - return $res_str; + $res_str = ''; + + $forms = array( + Normalizer::FORM_C, + Normalizer::FORM_D, + Normalizer::FORM_KC, + Normalizer::FORM_KD, + ); + + $forms_str = array ( + Normalizer::FORM_C => 'UNORM_FORM_C', + Normalizer::FORM_D => 'UNORM_FORM_D', + Normalizer::FORM_KC => 'UNORM_FORM_KC', + Normalizer::FORM_KD => 'UNORM_FORM_KD', + ); + + /* just make sure all the form constants are defined as in the api spec */ + if ( Normalizer::FORM_C != Normalizer::NFC || + Normalizer::FORM_D != Normalizer::NFD || + Normalizer::FORM_KC != Normalizer::NFKC || + Normalizer::FORM_KD != Normalizer::NFKD) { + + $res_str .= "Invalid normalization form declarations!\n"; + } + + $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) + $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) + $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) + + $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) + $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) + + $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) + $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) + + $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) + + $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) + + $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) + + $strs = array( + 'ABC', + $char_a_diaeresis . '||' . $char_a_ring . '||' . $char_o_diaeresis, + $char_angstrom_sign . '||' . $char_A_ring . '||' . 'A' . $char_combining_ring_above, + $char_ohm_sign . '||' . $char_omega, + $char_fi_ligature, + $char_long_s_dot, + ); + + foreach( $forms as $form ) + { + foreach( $strs as $str ) + { + $str_norm = ut_norm_normalize( $str, $form ); + $error_code = intl_get_error_code(); + $error_message = intl_get_error_message(); + + $str_hex = urlencode($str); + $str_norm_hex = urlencode($str_norm); + $res_str .= "'$str_hex' normalized to form '{$forms_str[$form]}' is '$str_norm_hex'" + . "\terror info: '$error_message' ($error_code)\n" + . ""; + + $is_norm = ut_norm_is_normalized( $str, $form ); + $error_code = intl_get_error_code(); + $error_message = intl_get_error_message(); + + $res_str .= " is in form '{$forms_str[$form]}'? = " . ($is_norm ? "yes" : "no") + . "\terror info: '$error_message' ($error_code)\n" + . ""; + } + } + + return $res_str; } include_once( 'ut_common.inc' ); diff --git a/ext/intl/tests/normalizer_normalize_kc_cf.phpt b/ext/intl/tests/normalizer_normalize_kc_cf.phpt index c7a46e617d2e..77e8a95eaae1 100644 --- a/ext/intl/tests/normalizer_normalize_kc_cf.phpt +++ b/ext/intl/tests/normalizer_normalize_kc_cf.phpt @@ -13,72 +13,72 @@ normalize() NFKC_Casefold function ut_main() { - $res_str = ''; - - $forms = array( - Normalizer::FORM_KC_CF, - ); - - $forms_str = array ( - Normalizer::FORM_KC_CF => 'UNORM_FORM_KC_CF', - ); - - /* just make sure all the form constants are defined as in the api spec */ - if (Normalizer::FORM_C != Normalizer::NFC) { - $res_str .= "Invalid normalization form declarations!\n"; - } - - $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) - $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) - $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) - - $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) - $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) - - $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) - $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) - - $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) - - $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) - - $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) - - $strs = array( - 'ABC', - 'abc', - $char_a_diaeresis . '||' . $char_a_ring . '||' . $char_o_diaeresis, - $char_angstrom_sign . '||' . $char_A_ring . '||' . 'A' . $char_combining_ring_above, - $char_ohm_sign . '||' . $char_omega, - $char_fi_ligature, - $char_long_s_dot, - ); - - foreach( $forms as $form ) - { - foreach( $strs as $str ) - { - $str_norm = ut_norm_normalize( $str, $form ); - $error_code = intl_get_error_code(); - $error_message = intl_get_error_message(); - - $str_hex = urlencode($str); - $str_norm_hex = urlencode($str_norm); - $res_str .= "'$str_hex' normalized to form '{$forms_str[$form]}' is '$str_norm_hex'" - . "\terror info: '$error_message' ($error_code)\n" - . ""; - - $is_norm = ut_norm_is_normalized( $str, $form ); - $error_code = intl_get_error_code(); - $error_message = intl_get_error_message(); - - $res_str .= " is in form '{$forms_str[$form]}'? = " . ($is_norm ? "yes" : "no") - . "\terror info: '$error_message' ($error_code)\n" - . ""; - } - } - - return $res_str; + $res_str = ''; + + $forms = array( + Normalizer::FORM_KC_CF, + ); + + $forms_str = array ( + Normalizer::FORM_KC_CF => 'UNORM_FORM_KC_CF', + ); + + /* just make sure all the form constants are defined as in the api spec */ + if (Normalizer::FORM_C != Normalizer::NFC) { + $res_str .= "Invalid normalization form declarations!\n"; + } + + $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) + $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) + $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) + + $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) + $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) + + $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) + $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) + + $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) + + $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) + + $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) + + $strs = array( + 'ABC', + 'abc', + $char_a_diaeresis . '||' . $char_a_ring . '||' . $char_o_diaeresis, + $char_angstrom_sign . '||' . $char_A_ring . '||' . 'A' . $char_combining_ring_above, + $char_ohm_sign . '||' . $char_omega, + $char_fi_ligature, + $char_long_s_dot, + ); + + foreach( $forms as $form ) + { + foreach( $strs as $str ) + { + $str_norm = ut_norm_normalize( $str, $form ); + $error_code = intl_get_error_code(); + $error_message = intl_get_error_message(); + + $str_hex = urlencode($str); + $str_norm_hex = urlencode($str_norm); + $res_str .= "'$str_hex' normalized to form '{$forms_str[$form]}' is '$str_norm_hex'" + . "\terror info: '$error_message' ($error_code)\n" + . ""; + + $is_norm = ut_norm_is_normalized( $str, $form ); + $error_code = intl_get_error_code(); + $error_message = intl_get_error_message(); + + $res_str .= " is in form '{$forms_str[$form]}'? = " . ($is_norm ? "yes" : "no") + . "\terror info: '$error_message' ($error_code)\n" + . ""; + } + } + + return $res_str; } include_once( 'ut_common.inc' ); diff --git a/ext/intl/tests/rbbiter___construct_basic.phpt b/ext/intl/tests/rbbiter___construct_basic.phpt index 2281bb26e041..9f20806fa50a 100644 --- a/ext/intl/tests/rbbiter___construct_basic.phpt +++ b/ext/intl/tests/rbbiter___construct_basic.phpt @@ -26,9 +26,9 @@ $rbbi = new IntlRuleBasedBreakIterator($rules); var_dump(get_class($rbbi)); try { - $obj = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+', 'aoeu'); + $obj = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+', 'aoeu'); } catch (IntlException $e) { - var_dump(intl_get_error_code(), intl_get_error_message()); + var_dump(intl_get_error_code(), intl_get_error_message()); } ?> diff --git a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt index 8d689d500334..4592a62eb9c6 100644 --- a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt +++ b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt @@ -28,7 +28,7 @@ $rbbi = new IntlRuleBasedBreakIterator($rules); $rbbi->setText('sdfkjsdf88á.... ,;'); do { - var_dump($rbbi->current(), $rbbi->getRuleStatusVec()); + var_dump($rbbi->current(), $rbbi->getRuleStatusVec()); } while ($rbbi->next() != IntlBreakIterator::DONE); ?> diff --git a/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt index 2cc71f4555fe..44da76529266 100644 --- a/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt +++ b/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt @@ -26,8 +26,8 @@ $rbbi = new IntlRuleBasedBreakIterator($rules); $rbbi->setText('sdfkjsdf88á.... ,;'); do { - echo "pos : {$rbbi->current()}\n", - "rule status: {$rbbi->getRuleStatus()}\n"; + echo "pos : {$rbbi->current()}\n", + "rule status: {$rbbi->getRuleStatus()}\n"; } while ($rbbi->next() != IntlBreakIterator::DONE); ?> diff --git a/ext/intl/tests/resourcebundle.inc b/ext/intl/tests/resourcebundle.inc index a7727a3ec836..9eea8aaffbaf 100644 --- a/ext/intl/tests/resourcebundle.inc +++ b/ext/intl/tests/resourcebundle.inc @@ -2,11 +2,11 @@ define('BUNDLE', dirname(__FILE__)."/_files/resourcebundle"); function debug( $res ) { - if (is_null( $res )) { - $ret = "NULL\n"; - } - else { - $ret = print_r( $res, true ). "\n"; - } - return $ret . sprintf( "%5d: %s\n", intl_get_error_code(), intl_get_error_message() ); + if (is_null( $res )) { + $ret = "NULL\n"; + } + else { + $ret = print_r( $res, true ). "\n"; + } + return $ret . sprintf( "%5d: %s\n", intl_get_error_code(), intl_get_error_message() ); } diff --git a/ext/intl/tests/resourcebundle_arrayaccess.phpt b/ext/intl/tests/resourcebundle_arrayaccess.phpt index d035a8d30407..8eaaff3af324 100644 --- a/ext/intl/tests/resourcebundle_arrayaccess.phpt +++ b/ext/intl/tests/resourcebundle_arrayaccess.phpt @@ -4,27 +4,27 @@ Test ResourceBundle array access and count - existing/missing keys --FILE-- --EXPECT-- length: 6 diff --git a/ext/intl/tests/resourcebundle_countable.phpt b/ext/intl/tests/resourcebundle_countable.phpt index bacc18f10ce7..fb703160c9a9 100644 --- a/ext/intl/tests/resourcebundle_countable.phpt +++ b/ext/intl/tests/resourcebundle_countable.phpt @@ -4,11 +4,11 @@ Test ResourceBundle implements Countable --FILE-- --EXPECT-- bool(true) diff --git a/ext/intl/tests/resourcebundle_create.phpt b/ext/intl/tests/resourcebundle_create.phpt index 09bad4fddf3d..d7ba99d523d1 100644 --- a/ext/intl/tests/resourcebundle_create.phpt +++ b/ext/intl/tests/resourcebundle_create.phpt @@ -8,35 +8,35 @@ Test ResourceBundle::__construct() - existing/missing bundles/locales include "resourcebundle.inc"; function ut_main() { - $str_res = ''; - // all fine - $r1 = ut_resourcebundle_create( 'root', BUNDLE ); - $str_res .= debug( $r1 ); - $str_res .= print_r( $r1['teststring'], true)."\n"; - - // non-root one - $r1 = ut_resourcebundle_create( 'es', BUNDLE ); - $str_res .= debug( $r1 ); - $str_res .= print_r( $r1['teststring'], true)."\n"; - - // fall back - $r1 = ut_resourcebundle_create( 'en_US', BUNDLE ); + $str_res = ''; + // all fine + $r1 = ut_resourcebundle_create( 'root', BUNDLE ); + $str_res .= debug( $r1 ); + $str_res .= print_r( $r1['teststring'], true)."\n"; + + // non-root one + $r1 = ut_resourcebundle_create( 'es', BUNDLE ); + $str_res .= debug( $r1 ); + $str_res .= print_r( $r1['teststring'], true)."\n"; + + // fall back + $r1 = ut_resourcebundle_create( 'en_US', BUNDLE ); $str_res .= debug( $r1 ); - $str_res .= print_r( $r1['testsring'], true); + $str_res .= print_r( $r1['testsring'], true); - // fall out - $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false ); + // fall out + $r2 = ut_resourcebundle_create( 'en_US', BUNDLE, false ); $str_res .= debug( $r2 ); - // missing - $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' ); + // missing + $r3 = ut_resourcebundle_create( 'en_US', 'nonexisting' ); $str_res .= debug( $r3 ); - return $str_res; + return $str_res; } - include_once( 'ut_common.inc' ); - ut_run(); + include_once( 'ut_common.inc' ); + ut_run(); ?> --EXPECT-- ResourceBundle Object diff --git a/ext/intl/tests/resourcebundle_individual.phpt b/ext/intl/tests/resourcebundle_individual.phpt index 0fb512f8e569..46ce239e4d2a 100644 --- a/ext/intl/tests/resourcebundle_individual.phpt +++ b/ext/intl/tests/resourcebundle_individual.phpt @@ -4,34 +4,34 @@ Test ResourceBundle::get() and length() - existing/missing keys --FILE-- --EXPECT-- length: 6 diff --git a/ext/intl/tests/resourcebundle_iterator.phpt b/ext/intl/tests/resourcebundle_iterator.phpt index e0b83d8190b0..93833fdf3551 100644 --- a/ext/intl/tests/resourcebundle_iterator.phpt +++ b/ext/intl/tests/resourcebundle_iterator.phpt @@ -4,33 +4,33 @@ Test ResourceBundle iterator --FILE-- $oneval) { - echo "Here comes $onekey:\n"; - switch (gettype($oneval)) { - case 'string': - echo bin2hex( $oneval ) . "\n"; - break; + foreach ($r as $onekey => $oneval) { + echo "Here comes $onekey:\n"; + switch (gettype($oneval)) { + case 'string': + echo bin2hex( $oneval ) . "\n"; + break; - case 'integer': - echo "$oneval\n"; - break; + case 'integer': + echo "$oneval\n"; + break; - default: - print_r( $oneval ); - } - echo "\n"; - } + default: + print_r( $oneval ); + } + echo "\n"; + } - echo "Testarray Contents:\n"; - $r = $r->get( 'testarray' ); - foreach ($r as $onekey => $oneval) { - echo "$onekey => $oneval\n"; - } + echo "Testarray Contents:\n"; + $r = $r->get( 'testarray' ); + foreach ($r as $onekey => $oneval) { + echo "$onekey => $oneval\n"; + } ?> --EXPECT-- Here comes testarray: diff --git a/ext/intl/tests/resourcebundle_locales.phpt b/ext/intl/tests/resourcebundle_locales.phpt index c744e6319378..16b863d4e83a 100644 --- a/ext/intl/tests/resourcebundle_locales.phpt +++ b/ext/intl/tests/resourcebundle_locales.phpt @@ -8,15 +8,15 @@ Test ResourceBundle::getLocales include "resourcebundle.inc"; function ut_main() { - $str_res = ''; + $str_res = ''; - $str_res .= join("\n", ut_resourcebundle_locales(BUNDLE)); + $str_res .= join("\n", ut_resourcebundle_locales(BUNDLE)); - return $str_res; + return $str_res; } - include_once( 'ut_common.inc' ); - ut_run(); + include_once( 'ut_common.inc' ); + ut_run(); ?> --EXPECT-- es diff --git a/ext/intl/tests/resourcebundle_traversable.phpt b/ext/intl/tests/resourcebundle_traversable.phpt index 4aeec2330d81..93d4c2a41eed 100644 --- a/ext/intl/tests/resourcebundle_traversable.phpt +++ b/ext/intl/tests/resourcebundle_traversable.phpt @@ -4,12 +4,12 @@ Bug #55610: ResourceBundle does not implement Traversable --FILE-- get('testarray'))); + var_dump($r instanceof Traversable); + var_dump(iterator_to_array($r->get('testarray'))); ?> --EXPECT-- bool(true) diff --git a/ext/intl/tests/timezone_clone_error.phpt b/ext/intl/tests/timezone_clone_error.phpt index 40527767758e..8df6a8ffe368 100644 --- a/ext/intl/tests/timezone_clone_error.phpt +++ b/ext/intl/tests/timezone_clone_error.phpt @@ -17,7 +17,7 @@ var_dump($tz); try { var_dump(clone $tz); } catch (Exception $e) { - var_dump(get_class($e), $e->getMessage()); + var_dump(get_class($e), $e->getMessage()); } ?> diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt index 348478e39610..985957d3ca3a 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt @@ -8,15 +8,15 @@ if (!extension_loaded('intl')) --EXPECT-- diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt index 37edd7e9c77c..84711ff57f84 100644 --- a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt @@ -8,16 +8,16 @@ if (!extension_loaded('intl')) $countCanonical); var_dump($countCanonical > $countCanonicalLocation); $enum = IntlTimeZone::createTimeZoneIDEnumeration( - IntlTimeZone::TYPE_ANY, null, null); + IntlTimeZone::TYPE_ANY, null, null); $countAny2 = count(iterator_to_array($enum)); var_dump($countAny == $countAny2); $enum = IntlTimeZone::createTimeZoneIDEnumeration( - IntlTimeZone::TYPE_ANY, null, -3600000); + IntlTimeZone::TYPE_ANY, null, -3600000); $values = iterator_to_array($enum); print_r( diff --git a/ext/intl/tests/timezone_equals_error.phpt b/ext/intl/tests/timezone_equals_error.phpt index d5eeedb2d9a6..3d489d14a6f9 100644 --- a/ext/intl/tests/timezone_equals_error.phpt +++ b/ext/intl/tests/timezone_equals_error.phpt @@ -18,7 +18,7 @@ var_dump($tz, $tz2); try { var_dump($tz == $tz2); } catch (Exception $e) { - var_dump(get_class($e), $e->getMessage()); + var_dump(get_class($e), $e->getMessage()); } ?> diff --git a/ext/intl/tests/timezone_getOffset_basic.phpt b/ext/intl/tests/timezone_getOffset_basic.phpt index 7efb1967ca76..3dbf5b1ce4b3 100644 --- a/ext/intl/tests/timezone_getOffset_basic.phpt +++ b/ext/intl/tests/timezone_getOffset_basic.phpt @@ -14,12 +14,12 @@ $ams = IntlTimeZone::createTimeZone('Europe/Amsterdam'); $date = strtotime("1 July 2012 +0000"); var_dump($ams->getOffset($date *1000., true, $rawOffset, $dstOffset), - $rawOffset, $dstOffset); + $rawOffset, $dstOffset); $lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); var_dump(intltz_get_offset($lsb, $date *1000., true, $rawOffset, $dstOffset), - $rawOffset, $dstOffset); + $rawOffset, $dstOffset); ?> --EXPECT-- diff --git a/ext/intl/tests/timezone_hasSameRules_error.phpt b/ext/intl/tests/timezone_hasSameRules_error.phpt index 07aa15039ce2..e1cfb754bac9 100644 --- a/ext/intl/tests/timezone_hasSameRules_error.phpt +++ b/ext/intl/tests/timezone_hasSameRules_error.phpt @@ -10,24 +10,24 @@ ini_set("intl.error_level", E_WARNING); function error_handler($errno, $errstr, $errfile, $errline) { - var_dump($errno, $errstr); - return true; + var_dump($errno, $errstr); + return true; } set_error_handler("error_handler"); $tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); try { - var_dump($tz->hasSameRules('foo')); + var_dump($tz->hasSameRules('foo')); } catch (Error $ex) { - var_dump($ex->getCode(), $ex->getMessage()); - echo "\n"; + var_dump($ex->getCode(), $ex->getMessage()); + echo "\n"; } try { - var_dump(intltz_has_same_rules(null, $tz)); + var_dump(intltz_has_same_rules(null, $tz)); } catch (Error $ex) { - var_dump($ex->getCode(), $ex->getMessage()); - echo "\n"; + var_dump($ex->getCode(), $ex->getMessage()); + echo "\n"; } --EXPECT-- int(0) diff --git a/ext/intl/tests/timezone_toDateTimeZone_basic.phpt b/ext/intl/tests/timezone_toDateTimeZone_basic.phpt index 831bc3df1ab1..3679fe9717c9 100644 --- a/ext/intl/tests/timezone_toDateTimeZone_basic.phpt +++ b/ext/intl/tests/timezone_toDateTimeZone_basic.phpt @@ -11,12 +11,12 @@ ini_set("intl.default_locale", "nl"); date_default_timezone_set('Europe/Lisbon'); function do_test(IntlTimeZone $tz, $proc = false) { - var_dump($tz->getID(), $tz->getRawOffset()); - if (!$proc) - $dtz = $tz->toDateTimeZone(); - else - $dtz = intltz_to_date_time_zone($tz); - var_dump($dtz->getName(), $dtz->getOffset(new DateTime('2012-01-01 00:00:00'))); + var_dump($tz->getID(), $tz->getRawOffset()); + if (!$proc) + $dtz = $tz->toDateTimeZone(); + else + $dtz = intltz_to_date_time_zone($tz); + var_dump($dtz->getName(), $dtz->getOffset(new DateTime('2012-01-01 00:00:00'))); } do_test(IntlTimeZone::createTimeZone('CET')); diff --git a/ext/intl/tests/timezone_toDateTimeZone_error.phpt b/ext/intl/tests/timezone_toDateTimeZone_error.phpt index 9df2bbf70d3b..119977b12467 100644 --- a/ext/intl/tests/timezone_toDateTimeZone_error.phpt +++ b/ext/intl/tests/timezone_toDateTimeZone_error.phpt @@ -11,9 +11,9 @@ ini_set("intl.error_level", E_WARNING); $tz = IntlTimeZone::createTimeZone('Etc/Unknown'); try { - var_dump($tz->toDateTimeZone()); + var_dump($tz->toDateTimeZone()); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } var_dump(intltz_to_date_time_zone(1)); diff --git a/ext/intl/tests/ut_common.inc b/ext/intl/tests/ut_common.inc index 6398b2876f13..4a2675b01f16 100644 --- a/ext/intl/tests/ut_common.inc +++ b/ext/intl/tests/ut_common.inc @@ -234,7 +234,7 @@ function ut_loc_get_default( ) } function ut_loc_set_default( $locale ) { - return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale ); + return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale ); } function ut_loc_get_primary_language( $locale ) { @@ -297,7 +297,7 @@ function ut_loc_locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_lo return $GLOBALS['oo-mode'] ? Locale::lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ) : locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ); } function ut_loc_accept_http($http) { - return $GLOBALS['oo-mode'] ? Locale::acceptFromHttp($http):locale_accept_from_http($http); + return $GLOBALS['oo-mode'] ? Locale::acceptFromHttp($http):locale_accept_from_http($http); } /* MessageFormatter functions */ function ut_msgfmt_create( $locale, $pattern) diff --git a/ext/json/tests/bug40503.phpt b/ext/json/tests/bug40503.phpt index 10896a428e9c..17c8fbd92a65 100644 --- a/ext/json/tests/bug40503.phpt +++ b/ext/json/tests/bug40503.phpt @@ -7,7 +7,7 @@ serialize_precision=-1 --FILE-- --EXPECT-- diff --git a/ext/json/tests/bug46215.phpt b/ext/json/tests/bug46215.phpt index be3a80f8600b..eaf980d49aa3 100644 --- a/ext/json/tests/bug46215.phpt +++ b/ext/json/tests/bug46215.phpt @@ -6,7 +6,7 @@ Bug #46215 (json_encode mutates its parameter and has some class-specific state) > 2); - $second = 0x8f | ($i & 3) << 4; - $string = sprintf("aa%c%c\xbf\xbdzz", $first, $second); - echo json_encode($string) . "\n"; + $first = 0xf0 | ($i >> 2); + $second = 0x8f | ($i & 3) << 4; + $string = sprintf("aa%c%c\xbf\xbdzz", $first, $second); + echo json_encode($string) . "\n"; } diff --git a/ext/json/tests/bug47644.phpt b/ext/json/tests/bug47644.phpt index c8650958e895..b5f4880cf923 100644 --- a/ext/json/tests/bug47644.phpt +++ b/ext/json/tests/bug47644.phpt @@ -9,7 +9,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); $bad_utf8, - 'bar' => 1 + 'foo' => $bad_utf8, + 'bar' => 1 ); json_encode($c); var_dump(json_last_error(), json_last_error_msg()); diff --git a/ext/json/tests/bug61978.phpt b/ext/json/tests/bug61978.phpt index 68df624de1f6..a26341e4cccd 100644 --- a/ext/json/tests/bug61978.phpt +++ b/ext/json/tests/bug61978.phpt @@ -6,25 +6,25 @@ Bug #61978 (Object recursion not detected for classes that implement JsonSeriali test = '123'; - $this->me = $this; - } + public $test; + public $me; + public function __construct() { + $this->test = '123'; + $this->me = $this; + } } class JsonTest2 implements JsonSerializable { - public $test; - public function __construct() { - $this->test = '123'; - } - public function jsonSerialize() { - return array( - 'test' => $this->test, - 'me' => $this - ); - } + public $test; + public function __construct() { + $this->test = '123'; + } + public function jsonSerialize() { + return array( + 'test' => $this->test, + 'me' => $this + ); + } } diff --git a/ext/json/tests/bug62369.phpt b/ext/json/tests/bug62369.phpt index 6d9f58b96708..9c0be481e432 100644 --- a/ext/json/tests/bug62369.phpt +++ b/ext/json/tests/bug62369.phpt @@ -7,27 +7,27 @@ FR #62369 (Segfault on json_encode(deeply_nested_array) $array = array(); for ($i=0; $i < 550; $i++) { - $array = array($array); + $array = array($array); } json_encode($array, 0, 551); switch (json_last_error()) { - case JSON_ERROR_NONE: - echo 'OK' . PHP_EOL; - break; - case JSON_ERROR_DEPTH: - echo 'ERROR' . PHP_EOL; - break; + case JSON_ERROR_NONE: + echo 'OK' . PHP_EOL; + break; + case JSON_ERROR_DEPTH: + echo 'ERROR' . PHP_EOL; + break; } json_encode($array, 0, 540); switch (json_last_error()) { - case JSON_ERROR_NONE: - echo 'OK' . PHP_EOL; - break; - case JSON_ERROR_DEPTH: - echo 'ERROR' . PHP_EOL; - break; + case JSON_ERROR_NONE: + echo 'OK' . PHP_EOL; + break; + case JSON_ERROR_DEPTH: + echo 'ERROR' . PHP_EOL; + break; } --EXPECT-- OK diff --git a/ext/json/tests/bug63737.phpt b/ext/json/tests/bug63737.phpt index 35361d850adc..1fb06d485e3f 100644 --- a/ext/json/tests/bug63737.phpt +++ b/ext/json/tests/bug63737.phpt @@ -5,10 +5,10 @@ Bug #63737 (json_decode does not properly decode with options parameter) --FILE-- getMessage(), $e->getCode(), get_class($e)); - } while ($e = $e->getPrevious()); + printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e)); + } while ($e = $e->getPrevious()); } ?> --EXPECT-- diff --git a/ext/json/tests/bug71835.phpt b/ext/json/tests/bug71835.phpt index dbe313b70cb4..334c84c5952b 100644 --- a/ext/json/tests/bug71835.phpt +++ b/ext/json/tests/bug71835.phpt @@ -5,18 +5,18 @@ Bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSeriali --FILE-- json_decode(null, true)]; - } + function jsonSerialize() + { + return ['end' => json_decode(null, true)]; + } } $a = new A(); $toJsonData = $a->jsonSerialize(); diff --git a/ext/json/tests/bug73113.phpt b/ext/json/tests/bug73113.phpt index d45e51f68367..1bb170633155 100644 --- a/ext/json/tests/bug73113.phpt +++ b/ext/json/tests/bug73113.phpt @@ -16,9 +16,9 @@ class JsonSerializableObject implements \JsonSerializable $obj = new JsonSerializableObject(); try { - echo json_encode($obj); + echo json_encode($obj); } catch (\Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } --EXPECT-- This error is expected diff --git a/ext/json/tests/fail001.phpt b/ext/json/tests/fail001.phpt index 21dd42f8c3e9..b03b77f44db6 100644 --- a/ext/json/tests/fail001.phpt +++ b/ext/json/tests/fail001.phpt @@ -8,38 +8,38 @@ JSON (http://www.crockford.com/JSON/JSON_checker/test/fail*.json) diff --git a/ext/json/tests/json_decode_basic.phpt b/ext/json/tests/json_decode_basic.phpt index d9125ed7ad23..81501c1857ef 100644 --- a/ext/json/tests/json_decode_basic.phpt +++ b/ext/json/tests/json_decode_basic.phpt @@ -8,34 +8,34 @@ echo "*** Testing json_decode() : basic functionality ***\n"; // array with different values for $string $inputs = array ( - '0', - '123', - '-123', - '2147483647', - '-2147483648', - '123.456', - '1230', - '-1230', - 'true', - 'false', - 'null', - '"abc"', - '"Hello World\r\n"', - '[]', - '[1,2,3,4,5]', - '{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}', - '{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}', - '""', - '{}' + '0', + '123', + '-123', + '2147483647', + '-2147483648', + '123.456', + '1230', + '-1230', + 'true', + 'false', + 'null', + '"abc"', + '"Hello World\r\n"', + '[]', + '[1,2,3,4,5]', + '{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}', + '{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}', + '""', + '{}' ); // loop through with each element of the $inputs array to test json_decode() function $count = 1; foreach($inputs as $input) { - echo "-- Iteration $count --\n"; - var_dump(json_decode($input)); - var_dump(json_decode($input, true)); - $count++; + echo "-- Iteration $count --\n"; + var_dump(json_decode($input)); + var_dump(json_decode($input, true)); + $count++; } ?> diff --git a/ext/json/tests/json_decode_exceptions.phpt b/ext/json/tests/json_decode_exceptions.phpt index 14cf59fd02e0..ba1b57f5bec2 100644 --- a/ext/json/tests/json_decode_exceptions.phpt +++ b/ext/json/tests/json_decode_exceptions.phpt @@ -6,9 +6,9 @@ Test json_decode() function : JSON_THROW_ON_ERROR flag diff --git a/ext/json/tests/json_decode_invalid_utf8.phpt b/ext/json/tests/json_decode_invalid_utf8.phpt index d92f785424b6..b69400f360ff 100644 --- a/ext/json/tests/json_decode_invalid_utf8.phpt +++ b/ext/json/tests/json_decode_invalid_utf8.phpt @@ -7,14 +7,14 @@ if (!extension_loaded("json")) print "skip"; --FILE-- MyString = "Hello World"; // array with different values for $string $inputs = array ( - // integers - 0, - 123, - -123, - 2147483647, - -2147483648, - - // floats - 123.456, - 1.23E3, - -1.23E3, - - // boolean - TRUE, - true, - FALSE, - false, - - // NULL - NULL, - null, - - // strings - "abc", - 'abc', - "Hello\t\tWorld\n", - - // arrays - array(), - array(1,2,3,4,5), - array(1 => "Sun", 2 => "Mon", 3 => "Tue", 4 => "Wed", 5 => "Thur", 6 => "Fri", 7 => "Sat"), - array("Jan" => 31, "Feb" => 29, "Mar" => 31, "April" => 30, "May" => 31, "June" => 30), - - // empty data - "", - '', - - // undefined data - @$undefined_var, - - // unset data - @$unset_var, - - // resource variable - $fp, - - // object variable - $obj + // integers + 0, + 123, + -123, + 2147483647, + -2147483648, + + // floats + 123.456, + 1.23E3, + -1.23E3, + + // boolean + TRUE, + true, + FALSE, + false, + + // NULL + NULL, + null, + + // strings + "abc", + 'abc', + "Hello\t\tWorld\n", + + // arrays + array(), + array(1,2,3,4,5), + array(1 => "Sun", 2 => "Mon", 3 => "Tue", 4 => "Wed", 5 => "Thur", 6 => "Fri", 7 => "Sat"), + array("Jan" => 31, "Feb" => 29, "Mar" => 31, "April" => 30, "May" => 31, "June" => 30), + + // empty data + "", + '', + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + // resource variable + $fp, + + // object variable + $obj ); // loop through with each element of the $inputs array to test json_encode() function $count = 1; foreach($inputs as $input) { - echo "-- Iteration $count --\n"; - var_dump(json_encode($input)); - $count ++; + echo "-- Iteration $count --\n"; + var_dump(json_encode($input)); + $count ++; } ?> diff --git a/ext/json/tests/json_encode_exceptions.phpt b/ext/json/tests/json_encode_exceptions.phpt index 507f16ede932..a3d1f7ae250c 100644 --- a/ext/json/tests/json_encode_exceptions.phpt +++ b/ext/json/tests/json_encode_exceptions.phpt @@ -6,9 +6,9 @@ Test json_encode() function : JSON_THROW_ON_ERROR flag --EXPECT-- diff --git a/ext/json/tests/json_encode_pretty_print.phpt b/ext/json/tests/json_encode_pretty_print.phpt index 43b93aafe6b1..0ac4a6d3fba3 100644 --- a/ext/json/tests/json_encode_pretty_print.phpt +++ b/ext/json/tests/json_encode_pretty_print.phpt @@ -5,11 +5,11 @@ json_encode() with JSON_PRETTY_PRINT --FILE-- getCode(), PHP_EOL; + echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; } var_dump(json_last_error()); try { - json_decode("{", false, 512, JSON_THROW_ON_ERROR); + json_decode("{", false, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { - echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; + echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; } var_dump(json_last_error()); try { - json_encode(NAN, JSON_THROW_ON_ERROR); + json_encode(NAN, JSON_THROW_ON_ERROR); } catch (JsonException $e) { - echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; + echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; } var_dump(json_last_error()); diff --git a/ext/json/tests/serialize.phpt b/ext/json/tests/serialize.phpt index 1aa90750da1b..ab2f9c926d64 100644 --- a/ext/json/tests/serialize.phpt +++ b/ext/json/tests/serialize.phpt @@ -9,46 +9,46 @@ serialize_precision=-1 class NonSerializingTest { - public $data; + public $data; - public function __construct($data) - { - $this->data = $data; - } + public function __construct($data) + { + $this->data = $data; + } } class SerializingTest extends NonSerializingTest implements JsonSerializable { - public function jsonSerialize() - { - return $this->data; - } + public function jsonSerialize() + { + return $this->data; + } } class ValueSerializingTest extends SerializingTest { - public function jsonSerialize() - { - return array_values(is_array($this->data) ? $this->data : get_object_vars($this->data)); - } + public function jsonSerialize() + { + return array_values(is_array($this->data) ? $this->data : get_object_vars($this->data)); + } } class SelfSerializingTest extends SerializingTest { - public function jsonSerialize() - { - return $this; - } + public function jsonSerialize() + { + return $this; + } } $adata = array( - 'str' => 'foo', - 'int' => 1, - 'float' => 2.3, - 'bool' => false, - 'nil' => null, - 'arr' => array(1,2,3), - 'obj' => new StdClass, + 'str' => 'foo', + 'int' => 1, + 'float' => 2.3, + 'bool' => false, + 'nil' => null, + 'arr' => array(1,2,3), + 'obj' => new StdClass, ); $ndata = array_values($adata); @@ -56,10 +56,10 @@ $ndata = array_values($adata); $odata = (object)$adata; foreach(array('NonSerializingTest','SerializingTest','ValueSerializingTest','SelfSerializingTest') as $class) { - echo "==$class==\n"; - echo json_encode(new $class($adata)), "\n"; - echo json_encode(new $class($ndata)), "\n"; - echo json_encode(new $class($odata)), "\n"; + echo "==$class==\n"; + echo json_encode(new $class($adata)), "\n"; + echo json_encode(new $class($ndata)), "\n"; + echo json_encode(new $class($odata)), "\n"; } --EXPECT-- ==NonSerializingTest== diff --git a/ext/ldap/tests/bug48441.phpt b/ext/ldap/tests/bug48441.phpt index fa2f2ee023a9..c4b224c7a717 100644 --- a/ext/ldap/tests/bug48441.phpt +++ b/ext/ldap/tests/bug48441.phpt @@ -18,16 +18,16 @@ $dn = "$base"; $filter = "(objectclass=person)"; var_dump( - $result = ldap_search($link, $dn, $filter, array('sn')), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn')), + ldap_get_entries($link, $result) ); var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 1, LDAP_DEREF_ALWAYS), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 1, LDAP_DEREF_ALWAYS), + ldap_get_entries($link, $result) ); var_dump( - $result = ldap_search($link, $dn, $filter, array('sn')), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn')), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/bug73933.phpt b/ext/ldap/tests/bug73933.phpt index ac934a8dd813..8e50a750e284 100644 --- a/ext/ldap/tests/bug73933.phpt +++ b/ext/ldap/tests/bug73933.phpt @@ -10,15 +10,15 @@ require_once('skipif.inc'); $ldap = ldap_connect('127.0.0.1', 3333); ldap_mod_replace($ldap, null, array( - 'lockoutTime' => array(0), + 'lockoutTime' => array(0), )); ldap_modify_batch($ldap, null, array( [ - "attrib" => "mail", - "modtype" => LDAP_MODIFY_BATCH_ADD, - "values" => [ - "test@example.com", - "test-2@example.com", ]])); + "attrib" => "mail", + "modtype" => LDAP_MODIFY_BATCH_ADD, + "values" => [ + "test@example.com", + "test-2@example.com", ]])); ldap_close($ldap); diff --git a/ext/ldap/tests/bug77958.phpt b/ext/ldap/tests/bug77958.phpt index a19561740b96..b370b40eda8e 100644 --- a/ext/ldap/tests/bug77958.phpt +++ b/ext/ldap/tests/bug77958.phpt @@ -13,23 +13,23 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $mods = array( - array( - "attrib" => "telephoneNumber", - "modtype" => LDAP_MODIFY_BATCH_ADD, - "values" => array( - 123456 - ) - ), - array( - "attrib" => "description", - "modtype" => LDAP_MODIFY_BATCH_REMOVE_ALL - ) + array( + "attrib" => "telephoneNumber", + "modtype" => LDAP_MODIFY_BATCH_ADD, + "values" => array( + 123456 + ) + ), + array( + "attrib" => "description", + "modtype" => LDAP_MODIFY_BATCH_REMOVE_ALL + ) ); var_dump( - ldap_modify_batch($link, "cn=userA,$base", $mods), - $entry = ldap_first_entry($link, ldap_read($link, "cn=userA,$base", "(telephoneNumber=*)")), - ldap_get_values($link, $entry, "telephoneNumber") + ldap_modify_batch($link, "cn=userA,$base", $mods), + $entry = ldap_first_entry($link, ldap_read($link, "cn=userA,$base", "(telephoneNumber=*)")), + ldap_get_values($link, $entry, "telephoneNumber") ); ?> --CLEAN-- diff --git a/ext/ldap/tests/connect.inc b/ext/ldap/tests/connect.inc index de41cca63c38..bd6a144d2ebc 100644 --- a/ext/ldap/tests/connect.inc +++ b/ext/ldap/tests/connect.inc @@ -15,74 +15,74 @@ $protocol_version = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") ?: 3; $skip_on_bind_failure = getenv("LDAP_TEST_SKIP_BIND_FAILURE") ?: true; function ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version) { - $link = ldap_connect($host, $port); - ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); - ldap_bind($link, $user, $passwd); - return $link; + $link = ldap_connect($host, $port); + ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); + ldap_bind($link, $user, $passwd); + return $link; } function test_bind($host, $port, $user, $passwd, $protocol_version) { - $link = ldap_connect($host, $port); - ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); - return ldap_bind($link, $user, $passwd); + $link = ldap_connect($host, $port); + ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); + return ldap_bind($link, $user, $passwd); } function insert_dummy_data($link, $base) { - // Create root if not there - $testBase = ldap_read($link, $base, '(objectClass=*)', array('objectClass')); - if (ldap_count_entries($link, $testBase) < 1) { - ldap_add( - $link, "$base", array( - "objectClass" => array( - "top", - "organization", - "dcObject" - ), - "o" => "php ldap tests" - ) - ); - } - ldap_add($link, "o=test,$base", array( - "objectClass" => array( + // Create root if not there + $testBase = ldap_read($link, $base, '(objectClass=*)', array('objectClass')); + if (ldap_count_entries($link, $testBase) < 1) { + ldap_add( + $link, "$base", array( + "objectClass" => array( + "top", + "organization", + "dcObject" + ), + "o" => "php ldap tests" + ) + ); + } + ldap_add($link, "o=test,$base", array( + "objectClass" => array( "top", "organization"), - "o" => "test", - )); - ldap_add($link, "cn=userA,$base", array( - "objectclass" => "person", - "cn" => "userA", - "sn" => "testSN1", - "userPassword" => "oops", - "telephoneNumber" => "xx-xx-xx-xx-xx", - "description" => "user A", - )); - ldap_add($link, "cn=userB,$base", array( - "objectclass" => "person", - "cn" => "userB", - "sn" => "testSN2", - "userPassword" => "oopsIDitItAgain", - "description" => "user B", - )); - ldap_add($link, "cn=userC,cn=userB,$base", array( - "objectclass" => "person", - "cn" => "userC", - "sn" => "testSN3", - "userPassword" => "0r1g1na1 passw0rd", - )); - ldap_add($link, "o=test2,$base", array( - "objectClass" => array( + "o" => "test", + )); + ldap_add($link, "cn=userA,$base", array( + "objectclass" => "person", + "cn" => "userA", + "sn" => "testSN1", + "userPassword" => "oops", + "telephoneNumber" => "xx-xx-xx-xx-xx", + "description" => "user A", + )); + ldap_add($link, "cn=userB,$base", array( + "objectclass" => "person", + "cn" => "userB", + "sn" => "testSN2", + "userPassword" => "oopsIDitItAgain", + "description" => "user B", + )); + ldap_add($link, "cn=userC,cn=userB,$base", array( + "objectclass" => "person", + "cn" => "userC", + "sn" => "testSN3", + "userPassword" => "0r1g1na1 passw0rd", + )); + ldap_add($link, "o=test2,$base", array( + "objectClass" => array( "top", "organization"), - "o" => "test2", - "l" => array("here", "there", "Antarctica"), - )); + "o" => "test2", + "l" => array("here", "there", "Antarctica"), + )); } function remove_dummy_data($link, $base) { - ldap_delete($link, "cn=userC,cn=userB,$base"); - ldap_delete($link, "cn=userA,$base"); - ldap_delete($link, "cn=userB,$base"); - ldap_delete($link, "o=test,$base"); - ldap_delete($link, "o=test2,$base"); + ldap_delete($link, "cn=userC,cn=userB,$base"); + ldap_delete($link, "cn=userA,$base"); + ldap_delete($link, "cn=userB,$base"); + ldap_delete($link, "o=test,$base"); + ldap_delete($link, "o=test2,$base"); } ?> diff --git a/ext/ldap/tests/ldap_add_basic.phpt b/ext/ldap/tests/ldap_add_basic.phpt index 7e7a255c915a..b247901d735e 100644 --- a/ext/ldap/tests/ldap_add_basic.phpt +++ b/ext/ldap/tests/ldap_add_basic.phpt @@ -13,18 +13,18 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); var_dump( - ldap_add($link, "dc=my-domain,$base", array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", - )), - ldap_get_entries( - $link, - ldap_search($link, "$base", "(o=my-domain)") - ) + ldap_add($link, "dc=my-domain,$base", array( + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", + )), + ldap_get_entries( + $link, + ldap_search($link, "$base", "(o=my-domain)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_add_error.phpt b/ext/ldap/tests/ldap_add_error.phpt index d7271461ce29..61b4d2808df9 100644 --- a/ext/ldap/tests/ldap_add_error.phpt +++ b/ext/ldap/tests/ldap_add_error.phpt @@ -16,16 +16,16 @@ var_dump(ldap_add($link, "$base", array())); // Invalid DN var_dump( - ldap_add($link, "weirdAttribute=val", array( - "weirdAttribute" => "val", - )), - ldap_error($link), - ldap_errno($link) + ldap_add($link, "weirdAttribute=val", array( + "weirdAttribute" => "val", + )), + ldap_error($link), + ldap_errno($link) ); // Duplicate entry for ($i = 0; $i < 2; $i++) - var_dump( + var_dump( ldap_add($link, "dc=my-domain,$base", array( "objectClass" => array( "top", @@ -34,49 +34,49 @@ for ($i = 0; $i < 2; $i++) "dc" => "my-domain", "o" => "my-domain", )) - ); + ); var_dump(ldap_error($link), ldap_errno($link)); // Wrong array indexes var_dump( - ldap_add($link, "dc=my-domain2,dc=com", array( - "objectClass" => array( - 0 => "top", - 2 => "dcObject", - 5 => "organization"), - "dc" => "my-domain", - "o" => "my-domain", - )) - /* Is this correct behaviour to still have "Already exists" as error/errno? - , - ldap_error($link), - ldap_errno($link) - */ + ldap_add($link, "dc=my-domain2,dc=com", array( + "objectClass" => array( + 0 => "top", + 2 => "dcObject", + 5 => "organization"), + "dc" => "my-domain", + "o" => "my-domain", + )) + /* Is this correct behaviour to still have "Already exists" as error/errno? + , + ldap_error($link), + ldap_errno($link) + */ ); // Invalid attribute var_dump( - ldap_add($link, "$base", array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", - "weirdAttr" => "weirdVal", - )), - ldap_error($link), - ldap_errno($link) + ldap_add($link, "$base", array( + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", + "weirdAttr" => "weirdVal", + )), + ldap_error($link), + ldap_errno($link) ); var_dump( - ldap_add($link, "$base", array(array( "Oops" - ))) - /* Is this correct behaviour to still have "Undefined attribute type" as error/errno? - , - ldap_error($link), - ldap_errno($link) - */ + ldap_add($link, "$base", array(array( "Oops" + ))) + /* Is this correct behaviour to still have "Undefined attribute type" as error/errno? + , + ldap_error($link), + ldap_errno($link) + */ ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_add_ext.phpt b/ext/ldap/tests/ldap_add_ext.phpt index 7363614585a6..fbcaff523bdc 100644 --- a/ext/ldap/tests/ldap_add_ext.phpt +++ b/ext/ldap/tests/ldap_add_ext.phpt @@ -16,20 +16,20 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); var_dump( - $result = ldap_add_ext($link, "o=test_ldap_add_ext,$base", array( - "objectClass" => array( - "top", - "organization"), - "o" => "test_ldap_add_ext", - ), [['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['o']]]]), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls[LDAP_CONTROL_POST_READ], - ldap_get_entries( - $link, - ldap_search($link, "$base", "(o=test_ldap_add_ext)") - ) + $result = ldap_add_ext($link, "o=test_ldap_add_ext,$base", array( + "objectClass" => array( + "top", + "organization"), + "o" => "test_ldap_add_ext", + ), [['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['o']]]]), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls[LDAP_CONTROL_POST_READ], + ldap_get_entries( + $link, + ldap_search($link, "$base", "(o=test_ldap_add_ext)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_bind_ext.phpt b/ext/ldap/tests/ldap_bind_ext.phpt index 0e8fb52d0258..685b0588ce1d 100644 --- a/ext/ldap/tests/ldap_bind_ext.phpt +++ b/ext/ldap/tests/ldap_bind_ext.phpt @@ -17,30 +17,30 @@ $link = ldap_connect($host, $port); ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); var_dump( - $result = ldap_bind_ext($link, $user, $passwd), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls, - $result = ldap_bind_ext($link, $user, $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls + $result = ldap_bind_ext($link, $user, $passwd), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls, + $result = ldap_bind_ext($link, $user, $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls ); /* Failures */ var_dump( - $result = ldap_bind_ext($link, $user, "wrongPassword", [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls, - $result = ldap_bind_ext($link, "unexistingProperty=weirdValue,$user", $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls + $result = ldap_bind_ext($link, $user, "wrongPassword", [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls, + $result = ldap_bind_ext($link, "unexistingProperty=weirdValue,$user", $passwd, [['oid' => LDAP_CONTROL_PASSWORDPOLICYREQUEST]]), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls ); ?> --EXPECTF-- diff --git a/ext/ldap/tests/ldap_compare_basic.phpt b/ext/ldap/tests/ldap_compare_basic.phpt index a8b8c2b7b183..32f6ccf78f80 100644 --- a/ext/ldap/tests/ldap_compare_basic.phpt +++ b/ext/ldap/tests/ldap_compare_basic.phpt @@ -13,8 +13,8 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - ldap_compare($link, "cn=userA,$base", "sn", "testSN1"), - ldap_compare($link, "cn=userA,$base", "telephoneNumber", "yy-yy-yy-yy-yy") + ldap_compare($link, "cn=userA,$base", "sn", "testSN1"), + ldap_compare($link, "cn=userA,$base", "telephoneNumber", "yy-yy-yy-yy-yy") ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_compare_error.phpt b/ext/ldap/tests/ldap_compare_error.phpt index b6b85c43c29d..1b1231b6f9c2 100644 --- a/ext/ldap/tests/ldap_compare_error.phpt +++ b/ext/ldap/tests/ldap_compare_error.phpt @@ -14,9 +14,9 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - ldap_compare($link, "cn=userNotAvailable,$base", "sn", "testSN1"), - ldap_error($link), - ldap_errno($link) + ldap_compare($link, "cn=userNotAvailable,$base", "sn", "testSN1"), + ldap_error($link), + ldap_errno($link) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_control_paged_results_variation1.phpt b/ext/ldap/tests/ldap_control_paged_results_variation1.phpt index fa5af01bd665..75d147e0beb9 100644 --- a/ext/ldap/tests/ldap_control_paged_results_variation1.phpt +++ b/ext/ldap/tests/ldap_control_paged_results_variation1.phpt @@ -17,9 +17,9 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(cn=user*)"; var_dump( - ldap_control_paged_result($link, 1), - $result = ldap_search($link, $dn, $filter, array('cn')), - ldap_get_entries($link, $result) + ldap_control_paged_result($link, 1), + $result = ldap_search($link, $dn, $filter, array('cn')), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_control_paged_results_variation2.phpt b/ext/ldap/tests/ldap_control_paged_results_variation2.phpt index 02f5b9028c6c..b0b6e62aff7e 100644 --- a/ext/ldap/tests/ldap_control_paged_results_variation2.phpt +++ b/ext/ldap/tests/ldap_control_paged_results_variation2.phpt @@ -17,9 +17,9 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(cn=user*)"; var_dump( - ldap_control_paged_result($link, 2), - $result = ldap_search($link, $dn, $filter, array('cn')), - ldap_get_entries($link, $result) + ldap_control_paged_result($link, 2), + $result = ldap_search($link, $dn, $filter, array('cn')), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_control_paged_results_variation3.phpt b/ext/ldap/tests/ldap_control_paged_results_variation3.phpt index e7cc896585d3..de904f051f99 100644 --- a/ext/ldap/tests/ldap_control_paged_results_variation3.phpt +++ b/ext/ldap/tests/ldap_control_paged_results_variation3.phpt @@ -18,13 +18,13 @@ $dn = "$base"; $filter = "(cn=user*)"; $cookie = ''; var_dump( - ldap_control_paged_result($link, 2, true, $cookie), - $result = ldap_search($link, $dn, $filter, array('cn')), - ldap_get_entries($link, $result), - ldap_control_paged_result_response($link, $result, $cookie), - ldap_control_paged_result($link, 20, true, $cookie), - $result = ldap_search($link, $dn, $filter, array('cn')), - ldap_get_entries($link, $result) + ldap_control_paged_result($link, 2, true, $cookie), + $result = ldap_search($link, $dn, $filter, array('cn')), + ldap_get_entries($link, $result), + ldap_control_paged_result_response($link, $result, $cookie), + ldap_control_paged_result($link, 20, true, $cookie), + $result = ldap_search($link, $dn, $filter, array('cn')), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_controls.phpt b/ext/ldap/tests/ldap_controls.phpt index 8b2e3e817425..e6e0ab61642f 100644 --- a/ext/ldap/tests/ldap_controls.phpt +++ b/ext/ldap/tests/ldap_controls.phpt @@ -19,35 +19,35 @@ insert_dummy_data($link, $base); /* Test assertion control */ var_dump( - $result = ldap_search($link, "o=test,$base", "objectClass=*", array('o'), 0, 0, 0, LDAP_DEREF_NEVER, - [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(objectClass=organization)']]]), - ldap_get_entries($link, $result), - $result = ldap_search($link, "o=test,$base", "objectClass=*", array('o'), 0, 0, 0, LDAP_DEREF_NEVER, - [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(objectClass=organizationalUnit)']]]), - ldap_modify($link, "o=test,$base", ['description' => 'desc'], - [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(!(description=*))']]]), - $result = ldap_read($link, "o=test,$base", "objectClass=*", array('description')), - ldap_get_entries($link, $result), - ldap_modify($link, "o=test,$base", ['description' => 'desc2'], - [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(!(description=*))']]]), - $result = ldap_read($link, "o=test,$base", "objectClass=*", array('description')), - ldap_get_entries($link, $result), - ldap_delete($link, "o=test,$base", [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc2)']]]), - ldap_errno($link), - ldap_error($link), - ldap_rename($link, "o=test,$base", "o=test2", "", TRUE, [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc2)']]]), - ldap_compare($link, "o=test,$base", "o", "test"), - ldap_compare($link, "o=test,$base", "o", "test", [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc2)']]]), - ldap_compare($link, "o=test,$base", "o", "test", [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc)']]]) + $result = ldap_search($link, "o=test,$base", "objectClass=*", array('o'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(objectClass=organization)']]]), + ldap_get_entries($link, $result), + $result = ldap_search($link, "o=test,$base", "objectClass=*", array('o'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(objectClass=organizationalUnit)']]]), + ldap_modify($link, "o=test,$base", ['description' => 'desc'], + [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(!(description=*))']]]), + $result = ldap_read($link, "o=test,$base", "objectClass=*", array('description')), + ldap_get_entries($link, $result), + ldap_modify($link, "o=test,$base", ['description' => 'desc2'], + [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(!(description=*))']]]), + $result = ldap_read($link, "o=test,$base", "objectClass=*", array('description')), + ldap_get_entries($link, $result), + ldap_delete($link, "o=test,$base", [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc2)']]]), + ldap_errno($link), + ldap_error($link), + ldap_rename($link, "o=test,$base", "o=test2", "", TRUE, [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc2)']]]), + ldap_compare($link, "o=test,$base", "o", "test"), + ldap_compare($link, "o=test,$base", "o", "test", [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc2)']]]), + ldap_compare($link, "o=test,$base", "o", "test", [['oid' => LDAP_CONTROL_ASSERT, 'iscritical' => TRUE, 'value' => ['filter' => '(description=desc)']]]) ); /* Test valuesreturnfilter control */ var_dump( - $result = ldap_read($link, "o=test2,$base", "objectClass=*", ["l"]), - ldap_get_entries($link, $result)[0]['l'], - $result = ldap_read($link, "o=test2,$base", "objectClass=*", ["l"], 0, 0, 0, LDAP_DEREF_NEVER, - [['oid' => LDAP_CONTROL_VALUESRETURNFILTER, 'iscritical' => TRUE, 'value' => ['filter' => '(l=*here)']]]), - ldap_get_entries($link, $result)[0]['l'] + $result = ldap_read($link, "o=test2,$base", "objectClass=*", ["l"]), + ldap_get_entries($link, $result)[0]['l'], + $result = ldap_read($link, "o=test2,$base", "objectClass=*", ["l"], 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_VALUESRETURNFILTER, 'iscritical' => TRUE, 'value' => ['filter' => '(l=*here)']]]), + ldap_get_entries($link, $result)[0]['l'] ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_delete_basic.phpt b/ext/ldap/tests/ldap_delete_basic.phpt index 65331771fb8d..046b14140762 100644 --- a/ext/ldap/tests/ldap_delete_basic.phpt +++ b/ext/ldap/tests/ldap_delete_basic.phpt @@ -12,17 +12,17 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); ldap_add($link, "dc=my-domain,$base", array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", )); var_dump( - ldap_delete($link, "dc=my-domain,$base"), - @ldap_search($link, "dc=my-domain,$base", "(o=my-domain)") + ldap_delete($link, "dc=my-domain,$base"), + @ldap_search($link, "dc=my-domain,$base", "(o=my-domain)") ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_delete_error.phpt b/ext/ldap/tests/ldap_delete_error.phpt index 3faabcc60f46..e924c3b59a0c 100644 --- a/ext/ldap/tests/ldap_delete_error.phpt +++ b/ext/ldap/tests/ldap_delete_error.phpt @@ -14,16 +14,16 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); // Invalid DN var_dump( - ldap_delete($link, "weirdAttribute=val"), - ldap_error($link), - ldap_errno($link) + ldap_delete($link, "weirdAttribute=val"), + ldap_error($link), + ldap_errno($link) ); // Deleting unexisting data var_dump( - ldap_delete($link, "dc=my-domain,$base"), - ldap_error($link), - ldap_errno($link) + ldap_delete($link, "dc=my-domain,$base"), + ldap_error($link), + ldap_errno($link) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_delete_ext.phpt b/ext/ldap/tests/ldap_delete_ext.phpt index ab0c1baffdc9..bcdc15ba51a7 100644 --- a/ext/ldap/tests/ldap_delete_ext.phpt +++ b/ext/ldap/tests/ldap_delete_ext.phpt @@ -15,23 +15,23 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); ldap_add($link, "dc=my-domain,$base", array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", )); var_dump( - $result = ldap_delete_ext($link, "dc=my-domain,$base", - [['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['dc', 'o']]]] - ), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls[LDAP_CONTROL_PRE_READ], - @ldap_search($link, "dc=my-domain,$base", "(o=my-domain)") + $result = ldap_delete_ext($link, "dc=my-domain,$base", + [['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['dc', 'o']]]] + ), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls[LDAP_CONTROL_PRE_READ], + @ldap_search($link, "dc=my-domain,$base", "(o=my-domain)") ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_errno_basic.phpt b/ext/ldap/tests/ldap_errno_basic.phpt index 9d2099c6e3fb..535bb290acee 100644 --- a/ext/ldap/tests/ldap_errno_basic.phpt +++ b/ext/ldap/tests/ldap_errno_basic.phpt @@ -12,16 +12,16 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); @ldap_add($link, "badDN $base", array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", )); var_dump( - ldap_errno($link) + ldap_errno($link) ); ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_error_basic.phpt b/ext/ldap/tests/ldap_error_basic.phpt index 4d866d5a4457..442936c3ae36 100644 --- a/ext/ldap/tests/ldap_error_basic.phpt +++ b/ext/ldap/tests/ldap_error_basic.phpt @@ -12,16 +12,16 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); @ldap_add($link, "badDN $base", array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", )); var_dump( - ldap_error($link) + ldap_error($link) ); ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_exop.phpt b/ext/ldap/tests/ldap_exop.phpt index 7d47a9812c1a..abb63e877fd1 100644 --- a/ext/ldap/tests/ldap_exop.phpt +++ b/ext/ldap/tests/ldap_exop.phpt @@ -14,24 +14,24 @@ insert_dummy_data($link, $base); function build_reqdata_passwd($user, $oldpw, $newpw) { - // This is basic and will only work for small strings - $hex = ''; - if (!empty($user)) { - $hex .= '80'.sprintf("%'.02x", strlen($user)).bin2hex($user); - } - if (!empty($oldpw)) { - $hex .= '81'.sprintf("%'.02x", strlen($oldpw)).bin2hex($oldpw); - } - if (!empty($newpw)) { - $hex .= '82'.sprintf("%'.02x", strlen($newpw)).bin2hex($newpw); - } - return hex2bin('30'.sprintf("%'.02x", strlen($hex)/2).$hex); + // This is basic and will only work for small strings + $hex = ''; + if (!empty($user)) { + $hex .= '80'.sprintf("%'.02x", strlen($user)).bin2hex($user); + } + if (!empty($oldpw)) { + $hex .= '81'.sprintf("%'.02x", strlen($oldpw)).bin2hex($oldpw); + } + if (!empty($newpw)) { + $hex .= '82'.sprintf("%'.02x", strlen($newpw)).bin2hex($newpw); + } + return hex2bin('30'.sprintf("%'.02x", strlen($hex)/2).$hex); } function extract_genpw($retdata) { - // Only works for small strings as well - return hex2bin(substr(bin2hex($retdata), 4*2)); + // Only works for small strings as well + return hex2bin(substr(bin2hex($retdata), 4*2)); } $userAPassword = "oops"; @@ -39,20 +39,20 @@ $userAPassword = "oops"; // ldap_exop(resource link, string reqoid [, string reqdata [, array servercontrols [, string &retdata [, string &retoid]]]]) // bool ldap_parse_exop(resource link, resource result [, string &retdata [, string &retoid]]) var_dump( - ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid), - $retdata, - $retoid, - ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata), - $retdata, - $r = ldap_exop($link, LDAP_EXOP_WHO_AM_I), - ldap_parse_exop($link, $r, $retdata2), - $retdata2, - test_bind($host, $port, "cn=userA,$base", $userAPassword, $protocol_version), - $r = ldap_exop($link, LDAP_EXOP_MODIFY_PASSWD, build_reqdata_passwd("cn=userA,$base", $userAPassword, "")), - ldap_parse_exop($link, $r, $retpwdata, $retpwoid), - $genpw = extract_genpw($retpwdata), - $retpwoid, - test_bind($host, $port, "cn=userA,$base", $genpw, $protocol_version) + ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid), + $retdata, + $retoid, + ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, [['oid' => LDAP_CONTROL_PROXY_AUTHZ, 'value' => "dn:cn=userA,$base"]], $retdata), + $retdata, + $r = ldap_exop($link, LDAP_EXOP_WHO_AM_I), + ldap_parse_exop($link, $r, $retdata2), + $retdata2, + test_bind($host, $port, "cn=userA,$base", $userAPassword, $protocol_version), + $r = ldap_exop($link, LDAP_EXOP_MODIFY_PASSWD, build_reqdata_passwd("cn=userA,$base", $userAPassword, "")), + ldap_parse_exop($link, $r, $retpwdata, $retpwoid), + $genpw = extract_genpw($retpwdata), + $retpwoid, + test_bind($host, $port, "cn=userA,$base", $genpw, $protocol_version) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_exop_refresh.phpt b/ext/ldap/tests/ldap_exop_refresh.phpt index 80660499af38..b90a92bc00a6 100644 --- a/ext/ldap/tests/ldap_exop_refresh.phpt +++ b/ext/ldap/tests/ldap_exop_refresh.phpt @@ -21,12 +21,12 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); ldap_add($link, "cn=tmp,$base", array( - "objectclass" => array("person", "dynamicObject"), - "cn" => "tmp", - "sn" => "tmp" + "objectclass" => array("person", "dynamicObject"), + "cn" => "tmp", + "sn" => "tmp" )); var_dump( - ldap_exop_refresh($link, "cn=tmp,$base", 1234) + ldap_exop_refresh($link, "cn=tmp,$base", 1234) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_first_attribute_basic.phpt b/ext/ldap/tests/ldap_first_attribute_basic.phpt index e87b70c474e1..81bc538aea69 100644 --- a/ext/ldap/tests/ldap_first_attribute_basic.phpt +++ b/ext/ldap/tests/ldap_first_attribute_basic.phpt @@ -15,7 +15,7 @@ insert_dummy_data($link, $base); $result = ldap_search($link, "$base", "(objectclass=organization)", array("objectClass")); $entry = ldap_first_entry($link, $result); var_dump( - ldap_first_attribute($link, $entry) + ldap_first_attribute($link, $entry) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_first_entry_basic.phpt b/ext/ldap/tests/ldap_first_entry_basic.phpt index 99b79e4d2905..94d46d6d87e7 100644 --- a/ext/ldap/tests/ldap_first_entry_basic.phpt +++ b/ext/ldap/tests/ldap_first_entry_basic.phpt @@ -14,8 +14,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $result = ldap_search($link, "$base", "(objectclass=person)"); var_dump( - $entry = ldap_first_entry($link, $result), - ldap_get_values($link, $entry, 'sn') + $entry = ldap_first_entry($link, $result), + ldap_get_values($link, $entry, 'sn') ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_get_attributes_basic.phpt b/ext/ldap/tests/ldap_get_attributes_basic.phpt index 8cb374b27fad..0d11bce706de 100644 --- a/ext/ldap/tests/ldap_get_attributes_basic.phpt +++ b/ext/ldap/tests/ldap_get_attributes_basic.phpt @@ -15,7 +15,7 @@ insert_dummy_data($link, $base); $result = ldap_search($link, "$base", "(o=test)"); $entry = ldap_first_entry($link, $result); var_dump( - ldap_get_attributes($link, $entry) + ldap_get_attributes($link, $entry) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_get_dn_basic.phpt b/ext/ldap/tests/ldap_get_dn_basic.phpt index 0cb6c833a6f6..14865ffe3c66 100644 --- a/ext/ldap/tests/ldap_get_dn_basic.phpt +++ b/ext/ldap/tests/ldap_get_dn_basic.phpt @@ -15,7 +15,7 @@ insert_dummy_data($link, $base); $result = ldap_search($link, "$base", "(objectclass=organization)"); $entry = ldap_first_entry($link, $result); var_dump( - ldap_get_dn($link, $entry) + ldap_get_dn($link, $entry) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_get_entries_basic.phpt b/ext/ldap/tests/ldap_get_entries_basic.phpt index e1806fca690a..bba2f08c69ad 100644 --- a/ext/ldap/tests/ldap_get_entries_basic.phpt +++ b/ext/ldap/tests/ldap_get_entries_basic.phpt @@ -14,10 +14,10 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - ldap_get_entries( - $link, - ldap_search($link, "$base", "(o=test)") - ) + ldap_get_entries( + $link, + ldap_search($link, "$base", "(o=test)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_get_entries_variation.phpt b/ext/ldap/tests/ldap_get_entries_variation.phpt index 767f9dcd08f6..9dd45b628289 100644 --- a/ext/ldap/tests/ldap_get_entries_variation.phpt +++ b/ext/ldap/tests/ldap_get_entries_variation.phpt @@ -14,10 +14,10 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - ldap_get_entries( - $link, - ldap_search($link, "$base", "(o=my-unexisting-domain)") - ) + ldap_get_entries( + $link, + ldap_search($link, "$base", "(o=my-unexisting-domain)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_get_option_basic.phpt b/ext/ldap/tests/ldap_get_option_basic.phpt index 9bbaf3e41db4..e9aa7cfc4fb8 100644 --- a/ext/ldap/tests/ldap_get_option_basic.phpt +++ b/ext/ldap/tests/ldap_get_option_basic.phpt @@ -14,8 +14,8 @@ $option = null; ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); var_dump( - ldap_get_option($link, LDAP_OPT_PROTOCOL_VERSION, $option), - $option + ldap_get_option($link, LDAP_OPT_PROTOCOL_VERSION, $option), + $option ); ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_get_option_controls.phpt b/ext/ldap/tests/ldap_get_option_controls.phpt index 1a6e18c4c4c2..813f33e069da 100644 --- a/ext/ldap/tests/ldap_get_option_controls.phpt +++ b/ext/ldap/tests/ldap_get_option_controls.phpt @@ -16,46 +16,46 @@ insert_dummy_data($link, $base); function build_ctrl_paged_value($int, $cookie) { - // This is basic and will only work for small values - $hex = ''; - if (!empty($int)) { - $str = sprintf("%'.02x", $int); - $hex .= '02'.sprintf("%'.02x%s", strlen($str)/2, $str); - } - $hex .= '04'.sprintf("%'.02x", strlen($cookie)).bin2hex($cookie); - return hex2bin('30'.sprintf("%'.02x", strlen($hex)/2).$hex); + // This is basic and will only work for small values + $hex = ''; + if (!empty($int)) { + $str = sprintf("%'.02x", $int); + $hex .= '02'.sprintf("%'.02x%s", strlen($str)/2, $str); + } + $hex .= '04'.sprintf("%'.02x", strlen($cookie)).bin2hex($cookie); + return hex2bin('30'.sprintf("%'.02x", strlen($hex)/2).$hex); } $controls_set = array( - array( - 'oid' => LDAP_CONTROL_PAGEDRESULTS, - 'iscritical' => TRUE, - 'value' => build_ctrl_paged_value(1, 'opaque') - ) + array( + 'oid' => LDAP_CONTROL_PAGEDRESULTS, + 'iscritical' => TRUE, + 'value' => build_ctrl_paged_value(1, 'opaque') + ) ); $controls_set2 = array( - array( - 'oid' => LDAP_CONTROL_PAGEDRESULTS, - 'iscritical' => TRUE, - 'value' => array( - 'size' => 1, - 'cookie' => '', - ) - ) + array( + 'oid' => LDAP_CONTROL_PAGEDRESULTS, + 'iscritical' => TRUE, + 'value' => array( + 'size' => 1, + 'cookie' => '', + ) + ) ); var_dump( - bin2hex($controls_set[0]['value']), - ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get), - ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_set), - ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get), - $controls_get, - ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_set2), - ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get), - $controls_get, - $result = ldap_search($link, $base, "(objectClass=person)", array('cn')), - ldap_get_entries($link, $result)['count'], - ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, array()), - ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get) + bin2hex($controls_set[0]['value']), + ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get), + ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_set), + ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get), + $controls_get, + ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_set2), + ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get), + $controls_get, + $result = ldap_search($link, $base, "(objectClass=person)", array('cn')), + ldap_get_entries($link, $result)['count'], + ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, array()), + ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_get_option_variation.phpt b/ext/ldap/tests/ldap_get_option_variation.phpt index 6852af3b3d16..80384475b4a0 100644 --- a/ext/ldap/tests/ldap_get_option_variation.phpt +++ b/ext/ldap/tests/ldap_get_option_variation.phpt @@ -13,8 +13,8 @@ $link = ldap_connect($host, $port); $option = null; $controls = array( - array("oid" => "1.2.752.58.10.1", "iscritical" => true), - array("oid" => "1.2.752.58.1.10", "value" => "magic"), + array("oid" => "1.2.752.58.10.1", "iscritical" => true), + array("oid" => "1.2.752.58.1.10", "value" => "magic"), ); ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER); @@ -28,24 +28,24 @@ ldap_set_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls); ldap_set_option($link, LDAP_OPT_RESTART, false); var_dump( - ldap_get_option($link, LDAP_OPT_DEREF, $option), - $option, - ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option), - $option, - ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option), - $option, - ldap_get_option($link, LDAP_OPT_NETWORK_TIMEOUT, $option), - $option, - ldap_get_option($link, LDAP_OPT_TIMEOUT, $option), - $option, - ldap_get_option($link, LDAP_OPT_REFERRALS, $option), - $option, - ldap_get_option($link, LDAP_OPT_RESTART, $option), - $option, - ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $option), - $option, - ldap_get_option($link, LDAP_OPT_CLIENT_CONTROLS, $option), - $option + ldap_get_option($link, LDAP_OPT_DEREF, $option), + $option, + ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option), + $option, + ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option), + $option, + ldap_get_option($link, LDAP_OPT_NETWORK_TIMEOUT, $option), + $option, + ldap_get_option($link, LDAP_OPT_TIMEOUT, $option), + $option, + ldap_get_option($link, LDAP_OPT_REFERRALS, $option), + $option, + ldap_get_option($link, LDAP_OPT_RESTART, $option), + $option, + ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $option), + $option, + ldap_get_option($link, LDAP_OPT_CLIENT_CONTROLS, $option), + $option ); ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_get_values_len_basic.phpt b/ext/ldap/tests/ldap_get_values_len_basic.phpt index af3fcd60ced6..eaf66c0fbc66 100644 --- a/ext/ldap/tests/ldap_get_values_len_basic.phpt +++ b/ext/ldap/tests/ldap_get_values_len_basic.phpt @@ -15,7 +15,7 @@ insert_dummy_data($link, $base); $result = ldap_search($link, "$base", "(o=test)"); $entry = ldap_first_entry($link, $result); var_dump( - ldap_get_values_len($link, $entry, "o") + ldap_get_values_len($link, $entry, "o") ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_list_basic.phpt b/ext/ldap/tests/ldap_list_basic.phpt index 840183623a43..f4d8bda31bf1 100644 --- a/ext/ldap/tests/ldap_list_basic.phpt +++ b/ext/ldap/tests/ldap_list_basic.phpt @@ -16,8 +16,8 @@ include "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - $result = ldap_list($link, "$base", "(objectClass=person)"), - ldap_get_entries($link, $result) + $result = ldap_list($link, "$base", "(objectClass=person)"), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_mod_add_basic.phpt b/ext/ldap/tests/ldap_mod_add_basic.phpt index 631e57ecdd57..9096f3eb6325 100644 --- a/ext/ldap/tests/ldap_mod_add_basic.phpt +++ b/ext/ldap/tests/ldap_mod_add_basic.phpt @@ -14,15 +14,15 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $entry = array( - "description" => "Domain description", + "description" => "Domain description", ); var_dump( - ldap_mod_add($link, "o=test,$base", $entry), - ldap_get_entries( - $link, - ldap_search($link, "o=test,$base", "(Description=Domain description)") - ) + ldap_mod_add($link, "o=test,$base", $entry), + ldap_get_entries( + $link, + ldap_search($link, "o=test,$base", "(Description=Domain description)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_mod_add_error.phpt b/ext/ldap/tests/ldap_mod_add_error.phpt index 561f1633f33a..7dd26616dcd0 100644 --- a/ext/ldap/tests/ldap_mod_add_error.phpt +++ b/ext/ldap/tests/ldap_mod_add_error.phpt @@ -19,12 +19,12 @@ var_dump(ldap_mod_add($link, "dc=my-domain,$base", array())); var_dump(ldap_mod_add($link, "weirdAttribute=val", array())); $entry = array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", ); ldap_add($link, "dc=my-domain,$base", $entry); diff --git a/ext/ldap/tests/ldap_mod_del_basic.phpt b/ext/ldap/tests/ldap_mod_del_basic.phpt index fee0c8d4aa3e..bafc190968b7 100644 --- a/ext/ldap/tests/ldap_mod_del_basic.phpt +++ b/ext/ldap/tests/ldap_mod_del_basic.phpt @@ -14,15 +14,15 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $entry = array( - "description" => "user A" + "description" => "user A" ); var_dump( - ldap_mod_del($link, "cn=userA,$base", $entry), - ldap_get_entries( - $link, - ldap_search($link, "$base", "(description=user A)") - ) + ldap_mod_del($link, "cn=userA,$base", $entry), + ldap_get_entries( + $link, + ldap_search($link, "$base", "(description=user A)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_mod_ext.phpt b/ext/ldap/tests/ldap_mod_ext.phpt index f27e05100dd3..0ca091fed8c6 100644 --- a/ext/ldap/tests/ldap_mod_ext.phpt +++ b/ext/ldap/tests/ldap_mod_ext.phpt @@ -19,38 +19,38 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $entry = array( - "description" => "Domain description", + "description" => "Domain description", ); var_dump( - $result = ldap_mod_add_ext($link, "o=test,$base", $entry, - [ - ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], - ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], - ] - ), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls, - ldap_get_entries( - $link, - ldap_search($link, "o=test,$base", "(Description=Domain description)") - ), - $result = ldap_mod_del_ext($link, "o=test,$base", $entry, - [ - ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], - ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], - ] - ), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls, - ldap_get_entries( - $link, - ldap_search($link, "o=test,$base", "(Description=Domain description)") - ) + $result = ldap_mod_add_ext($link, "o=test,$base", $entry, + [ + ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], + ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], + ] + ), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls, + ldap_get_entries( + $link, + ldap_search($link, "o=test,$base", "(Description=Domain description)") + ), + $result = ldap_mod_del_ext($link, "o=test,$base", $entry, + [ + ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], + ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['description']]], + ] + ), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls, + ldap_get_entries( + $link, + ldap_search($link, "o=test,$base", "(Description=Domain description)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_mod_replace_basic.phpt b/ext/ldap/tests/ldap_mod_replace_basic.phpt index 6e47158db134..0dd9f2b1ea3c 100644 --- a/ext/ldap/tests/ldap_mod_replace_basic.phpt +++ b/ext/ldap/tests/ldap_mod_replace_basic.phpt @@ -14,15 +14,15 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $entry = array( - "description" => "user X" + "description" => "user X" ); var_dump( - ldap_mod_replace($link, "cn=userA,$base", $entry), - ldap_get_entries( - $link, - ldap_search($link, "$base", "(description=user X)", array("description")) - ) + ldap_mod_replace($link, "cn=userA,$base", $entry), + ldap_get_entries( + $link, + ldap_search($link, "$base", "(description=user X)", array("description")) + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_modify_basic.phpt b/ext/ldap/tests/ldap_modify_basic.phpt index 487ec753a058..25899531474e 100644 --- a/ext/ldap/tests/ldap_modify_basic.phpt +++ b/ext/ldap/tests/ldap_modify_basic.phpt @@ -14,19 +14,19 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $entry = array( - "objectClass" => array( - "top", - "organization"), - "o" => "test", - "description" => "Domain description", + "objectClass" => array( + "top", + "organization"), + "o" => "test", + "description" => "Domain description", ); var_dump( - ldap_modify($link, "o=test,$base", $entry), - ldap_get_entries( - $link, - ldap_search($link, "$base", "(Description=Domain description)") - ) + ldap_modify($link, "o=test,$base", $entry), + ldap_get_entries( + $link, + ldap_search($link, "$base", "(Description=Domain description)") + ) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_modify_batch_basic.phpt b/ext/ldap/tests/ldap_modify_batch_basic.phpt index 96fadb44c396..41d7c0f15f81 100644 --- a/ext/ldap/tests/ldap_modify_batch_basic.phpt +++ b/ext/ldap/tests/ldap_modify_batch_basic.phpt @@ -14,27 +14,27 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); $mods = array( - array( - "attrib" => "telephoneNumber", - "modtype" => LDAP_MODIFY_BATCH_ADD, - "values" => array( - "+1 555 5551717" - ) - ), - array( - "attrib" => "sn", - "modtype" => LDAP_MODIFY_BATCH_REPLACE, - "values" => array("Brown-Smith") - ), - array( - "attrib" => "description", - "modtype" => LDAP_MODIFY_BATCH_REMOVE_ALL - ) + array( + "attrib" => "telephoneNumber", + "modtype" => LDAP_MODIFY_BATCH_ADD, + "values" => array( + "+1 555 5551717" + ) + ), + array( + "attrib" => "sn", + "modtype" => LDAP_MODIFY_BATCH_REPLACE, + "values" => array("Brown-Smith") + ), + array( + "attrib" => "description", + "modtype" => LDAP_MODIFY_BATCH_REMOVE_ALL + ) ); var_dump( - ldap_modify_batch($link, "cn=userA,$base", $mods), - ldap_get_entries($link, ldap_search($link, "$base", "(sn=Brown-Smith)")) + ldap_modify_batch($link, "cn=userA,$base", $mods), + ldap_get_entries($link, ldap_search($link, "$base", "(sn=Brown-Smith)")) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_modify_batch_error.phpt b/ext/ldap/tests/ldap_modify_batch_error.phpt index d18bd6729d0f..627d116d97ef 100644 --- a/ext/ldap/tests/ldap_modify_batch_error.phpt +++ b/ext/ldap/tests/ldap_modify_batch_error.phpt @@ -13,11 +13,11 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); $addGivenName = array( - array( - "attrib" => "givenName", - "modtype" => LDAP_MODIFY_BATCH_ADD, - "values" => array("Jack") - ) + array( + "attrib" => "givenName", + "modtype" => LDAP_MODIFY_BATCH_ADD, + "values" => array("Jack") + ) ); // DN not found @@ -28,34 +28,34 @@ var_dump(ldap_modify_batch($link, "weirdAttribute=val", $addGivenName)); // prepare $entry = array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", ); ldap_add($link, "dc=my-domain,$base", $entry); // invalid domain $mods = array( - array( - "attrib" => "dc", - "modtype" => LDAP_MODIFY_BATCH_REPLACE, - "values" => array("Wrong Domain") - ) + array( + "attrib" => "dc", + "modtype" => LDAP_MODIFY_BATCH_REPLACE, + "values" => array("Wrong Domain") + ) ); var_dump(ldap_modify_batch($link, "dc=my-domain,$base", $mods)); // invalid attribute $mods = array( - array( - "attrib" => "weirdAttribute", - "modtype" => LDAP_MODIFY_BATCH_ADD, - "values" => array("weirdVal", "anotherWeirdval") - ) + array( + "attrib" => "weirdAttribute", + "modtype" => LDAP_MODIFY_BATCH_ADD, + "values" => array("weirdVal", "anotherWeirdval") + ) ); var_dump(ldap_modify_batch($link, "dc=my-domain,$base", $mods)); diff --git a/ext/ldap/tests/ldap_modify_error.phpt b/ext/ldap/tests/ldap_modify_error.phpt index b4e29a58c625..682abf750448 100644 --- a/ext/ldap/tests/ldap_modify_error.phpt +++ b/ext/ldap/tests/ldap_modify_error.phpt @@ -19,12 +19,12 @@ var_dump(ldap_modify($link, "cn=not-found,$base", array())); var_dump(ldap_modify($link, "weirdAttribute=val", array())); $entry = array( - "objectClass" => array( - "top", - "dcObject", - "organization"), - "dc" => "my-domain", - "o" => "my-domain", + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", ); ldap_add($link, "dc=my-domain,$base", $entry); diff --git a/ext/ldap/tests/ldap_next_attribute_basic.phpt b/ext/ldap/tests/ldap_next_attribute_basic.phpt index d6c753c4a426..4c9584ee0b92 100644 --- a/ext/ldap/tests/ldap_next_attribute_basic.phpt +++ b/ext/ldap/tests/ldap_next_attribute_basic.phpt @@ -16,10 +16,10 @@ $result = ldap_search($link, "$base", "(cn=userC)"); $entry = ldap_first_entry($link, $result); $attribute = ldap_first_attribute($link, $entry); var_dump( - ldap_next_attribute($link, $entry), - ldap_next_attribute($link, $entry), - ldap_next_attribute($link, $entry), - ldap_next_attribute($link, $entry) + ldap_next_attribute($link, $entry), + ldap_next_attribute($link, $entry), + ldap_next_attribute($link, $entry), + ldap_next_attribute($link, $entry) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_next_attribute_error.phpt b/ext/ldap/tests/ldap_next_attribute_error.phpt index 94f7cfd475f7..ffe12226268b 100644 --- a/ext/ldap/tests/ldap_next_attribute_error.phpt +++ b/ext/ldap/tests/ldap_next_attribute_error.phpt @@ -15,7 +15,7 @@ insert_dummy_data($link, $base); $result = ldap_search($link, "$base", "(objectclass=organization)"); $entry = ldap_first_entry($link, $result); var_dump( - ldap_next_attribute($link, $entry) + ldap_next_attribute($link, $entry) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_next_entry_basic.phpt b/ext/ldap/tests/ldap_next_entry_basic.phpt index 9a7cc456b169..d8f03ce29160 100644 --- a/ext/ldap/tests/ldap_next_entry_basic.phpt +++ b/ext/ldap/tests/ldap_next_entry_basic.phpt @@ -15,9 +15,9 @@ insert_dummy_data($link, $base); $result = ldap_list($link, "$base", "(objectClass=person)"); $entry = ldap_first_entry($link, $result); var_dump( - $entry = ldap_next_entry($link, $entry), - ldap_get_values($link, $entry, 'sn'), - $entry = ldap_next_entry($link, $entry) + $entry = ldap_next_entry($link, $entry), + ldap_get_values($link, $entry, 'sn'), + $entry = ldap_next_entry($link, $entry) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_parse_reference_basic.phpt b/ext/ldap/tests/ldap_parse_reference_basic.phpt index 27b43cc084b5..d5aeef8a59ea 100644 --- a/ext/ldap/tests/ldap_parse_reference_basic.phpt +++ b/ext/ldap/tests/ldap_parse_reference_basic.phpt @@ -21,8 +21,8 @@ $result = ldap_search($link, "$base", "(cn=*)"); $ref = ldap_first_reference($link, $result); $refs = null; var_dump( - ldap_parse_reference($link, $ref, $refs), - $refs + ldap_parse_reference($link, $ref, $refs), + $refs ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_parse_result_basic.phpt b/ext/ldap/tests/ldap_parse_result_basic.phpt index c9bdc6cbcafb..ed7047164be9 100644 --- a/ext/ldap/tests/ldap_parse_result_basic.phpt +++ b/ext/ldap/tests/ldap_parse_result_basic.phpt @@ -20,8 +20,8 @@ ldap_add($link, "cn=userref,$base", array( $result = ldap_search($link, "cn=userref,$base", "(cn=user*)"); $errcode = $dn = $errmsg = $refs = null; var_dump( - ldap_parse_result($link, $result, $errcode, $dn, $errmsg, $refs), - $errcode, $dn, $errmsg, $refs + ldap_parse_result($link, $result, $errcode, $dn, $errmsg, $refs), + $errcode, $dn, $errmsg, $refs ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_parse_result_controls.phpt b/ext/ldap/tests/ldap_parse_result_controls.phpt index 76dc2fcb157a..63ef9e69d772 100644 --- a/ext/ldap/tests/ldap_parse_result_controls.phpt +++ b/ext/ldap/tests/ldap_parse_result_controls.phpt @@ -19,13 +19,13 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(cn=user*)"; var_dump( - ldap_control_paged_result($link, 1), - $result = ldap_search($link, $dn, $filter, array('cn')), - ldap_parse_result($link, $result, $errcode, $dn, $errmsg, $refs, $ctrls), - $ctrls[LDAP_CONTROL_PAGEDRESULTS]['oid'], - $ctrls[LDAP_CONTROL_PAGEDRESULTS]['value']['size'], - bin2hex($ctrls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie']), - ldap_get_entries($link, $result)['count'] + ldap_control_paged_result($link, 1), + $result = ldap_search($link, $dn, $filter, array('cn')), + ldap_parse_result($link, $result, $errcode, $dn, $errmsg, $refs, $ctrls), + $ctrls[LDAP_CONTROL_PAGEDRESULTS]['oid'], + $ctrls[LDAP_CONTROL_PAGEDRESULTS]['value']['size'], + bin2hex($ctrls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie']), + ldap_get_entries($link, $result)['count'] ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_read_basic.phpt b/ext/ldap/tests/ldap_read_basic.phpt index 75d3693bce55..596c02a71e2b 100644 --- a/ext/ldap/tests/ldap_read_basic.phpt +++ b/ext/ldap/tests/ldap_read_basic.phpt @@ -16,8 +16,8 @@ include "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - $result = ldap_read($link, "o=test,$base", "(o=*)"), - ldap_get_entries($link, $result) + $result = ldap_read($link, "o=test,$base", "(o=*)"), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_rename_basic.phpt b/ext/ldap/tests/ldap_rename_basic.phpt index c083b7a03f47..f985630ac6d2 100644 --- a/ext/ldap/tests/ldap_rename_basic.phpt +++ b/ext/ldap/tests/ldap_rename_basic.phpt @@ -13,7 +13,7 @@ require "connect.inc"; $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - ldap_rename($link, "cn=userA,$base", "cn=userZ", "$base", true) + ldap_rename($link, "cn=userA,$base", "cn=userZ", "$base", true) ); $result = ldap_search($link, "$base", "(cn=userA)", array("cn", "sn")); $result = ldap_search($link, "$base", "(cn=userZ)", array("cn", "sn")); diff --git a/ext/ldap/tests/ldap_rename_ext.phpt b/ext/ldap/tests/ldap_rename_ext.phpt index 009a7f32c5d3..e4f7d8364e86 100644 --- a/ext/ldap/tests/ldap_rename_ext.phpt +++ b/ext/ldap/tests/ldap_rename_ext.phpt @@ -18,19 +18,19 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - $result = ldap_rename_ext($link, "cn=userA,$base", "cn=userZ", "$base", TRUE, - [ - ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['cn']]], - ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['cn']]] - ] - ), - ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), - $errcode, - $errmsg, - $ctrls[LDAP_CONTROL_PRE_READ], - $ctrls[LDAP_CONTROL_POST_READ], - ldap_count_entries($link, ldap_search($link, "$base", "(cn=userA)", array("cn"))), - ldap_count_entries($link, ldap_search($link, "$base", "(cn=userZ)", array("cn"))) + $result = ldap_rename_ext($link, "cn=userA,$base", "cn=userZ", "$base", TRUE, + [ + ['oid' => LDAP_CONTROL_PRE_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['cn']]], + ['oid' => LDAP_CONTROL_POST_READ, 'iscritical' => TRUE, 'value' => ['attrs' => ['cn']]] + ] + ), + ldap_parse_result($link, $result, $errcode, $matcheddn, $errmsg, $referrals, $ctrls), + $errcode, + $errmsg, + $ctrls[LDAP_CONTROL_PRE_READ], + $ctrls[LDAP_CONTROL_POST_READ], + ldap_count_entries($link, ldap_search($link, "$base", "(cn=userA)", array("cn"))), + ldap_count_entries($link, ldap_search($link, "$base", "(cn=userZ)", array("cn"))) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_basic.phpt b/ext/ldap/tests/ldap_search_basic.phpt index 8c77a63e8a36..f7ed449c1682 100644 --- a/ext/ldap/tests/ldap_search_basic.phpt +++ b/ext/ldap/tests/ldap_search_basic.phpt @@ -17,8 +17,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - $result = ldap_search($link, "$base", "(objectClass=person)"), - ldap_get_entries($link, $result) + $result = ldap_search($link, "$base", "(objectClass=person)"), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_overrides.phpt b/ext/ldap/tests/ldap_search_overrides.phpt index e2d51079f4f2..5bd351a741d2 100644 --- a/ext/ldap/tests/ldap_search_overrides.phpt +++ b/ext/ldap/tests/ldap_search_overrides.phpt @@ -20,18 +20,18 @@ ldap_set_option($link, LDAP_OPT_NETWORK_TIMEOUT, 44); insert_dummy_data($link, $base); var_dump( - $result = ldap_search($link, "$base", "(objectClass=person)", array(), null, 111, 22, LDAP_DEREF_NEVER), - ldap_get_entries($link, $result) + $result = ldap_search($link, "$base", "(objectClass=person)", array(), null, 111, 22, LDAP_DEREF_NEVER), + ldap_get_entries($link, $result) ); var_dump( - ldap_get_option($link, LDAP_OPT_DEREF, $option), - $option, - ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option), - $option, - ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option), - $option, - ldap_get_option($link, LDAP_OPT_NETWORK_TIMEOUT, $option), - $option + ldap_get_option($link, LDAP_OPT_DEREF, $option), + $option, + ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option), + $option, + ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option), + $option, + ldap_get_option($link, LDAP_OPT_NETWORK_TIMEOUT, $option), + $option ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_paged_result_controls.phpt b/ext/ldap/tests/ldap_search_paged_result_controls.phpt index 04825a9ecd0e..f60acd3e0c4d 100644 --- a/ext/ldap/tests/ldap_search_paged_result_controls.phpt +++ b/ext/ldap/tests/ldap_search_paged_result_controls.phpt @@ -19,13 +19,13 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(cn=user*)"; var_dump( - $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, - [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 2]]]), - ldap_get_entries($link, $result), - ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), - $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, - [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 20, 'cookie' => $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie']]]]), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 2]]]), + ldap_get_entries($link, $result), + ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), + $result = ldap_search($link, $dn, $filter, array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [['oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => ['size' => 20, 'cookie' => $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie']]]]), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_sort_controls.phpt b/ext/ldap/tests/ldap_search_sort_controls.phpt index b7533e54f7ab..f55faf4930d8 100644 --- a/ext/ldap/tests/ldap_search_sort_controls.phpt +++ b/ext/ldap/tests/ldap_search_sort_controls.phpt @@ -19,55 +19,55 @@ insert_dummy_data($link, $base); /* First test with only SORT control */ var_dump( - $result = ldap_search($link, $base, '(cn=*)', array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, - [ - [ - 'oid' => LDAP_CONTROL_SORTREQUEST, - 'iscritical' => TRUE, - 'value' => [ - ['attr' => 'cn', 'oid' => '2.5.13.3' /* caseIgnoreOrderingMatch */, 'reverse' => TRUE] - ] - ] - ] - ), - ldap_get_entries($link, $result), - ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), - $errcode, - $errmsg, - $controls + $result = ldap_search($link, $base, '(cn=*)', array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [ + [ + 'oid' => LDAP_CONTROL_SORTREQUEST, + 'iscritical' => TRUE, + 'value' => [ + ['attr' => 'cn', 'oid' => '2.5.13.3' /* caseIgnoreOrderingMatch */, 'reverse' => TRUE] + ] + ] + ] + ), + ldap_get_entries($link, $result), + ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), + $errcode, + $errmsg, + $controls ); /* Then with VLV control */ var_dump( - $result = ldap_search($link, $base, '(cn=*)', array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, - [ - [ - 'oid' => LDAP_CONTROL_SORTREQUEST, - 'iscritical' => TRUE, - 'value' => [ - ['attr' => 'cn', 'oid' => '2.5.13.3' /* caseIgnoreOrderingMatch */, 'reverse' => TRUE] - ] - ], - [ - 'oid' => LDAP_CONTROL_VLVREQUEST, - 'iscritical' => TRUE, - 'value' => [ - 'before' => 0, // Return 0 entry before target - 'after' => 1, // Return 1 entry after target - 'offset' => 2, // Target entry is the second one - 'count' => 0, // We have no idea how many entries there are - ] - ] - ] - ), - ldap_get_entries($link, $result), - ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), - array_keys($controls), - $controls[LDAP_CONTROL_SORTRESPONSE], - $controls[LDAP_CONTROL_VLVRESPONSE]['value']['target'], - $controls[LDAP_CONTROL_VLVRESPONSE]['value']['count'], - $controls[LDAP_CONTROL_VLVRESPONSE]['value']['errcode'], - bin2hex($controls[LDAP_CONTROL_VLVRESPONSE]['value']['context']) + $result = ldap_search($link, $base, '(cn=*)', array('cn'), 0, 0, 0, LDAP_DEREF_NEVER, + [ + [ + 'oid' => LDAP_CONTROL_SORTREQUEST, + 'iscritical' => TRUE, + 'value' => [ + ['attr' => 'cn', 'oid' => '2.5.13.3' /* caseIgnoreOrderingMatch */, 'reverse' => TRUE] + ] + ], + [ + 'oid' => LDAP_CONTROL_VLVREQUEST, + 'iscritical' => TRUE, + 'value' => [ + 'before' => 0, // Return 0 entry before target + 'after' => 1, // Return 1 entry after target + 'offset' => 2, // Target entry is the second one + 'count' => 0, // We have no idea how many entries there are + ] + ] + ] + ), + ldap_get_entries($link, $result), + ldap_parse_result($link, $result, $errcode , $matcheddn , $errmsg , $referrals, $controls), + array_keys($controls), + $controls[LDAP_CONTROL_SORTRESPONSE], + $controls[LDAP_CONTROL_VLVRESPONSE]['value']['target'], + $controls[LDAP_CONTROL_VLVRESPONSE]['value']['count'], + $controls[LDAP_CONTROL_VLVRESPONSE]['value']['errcode'], + bin2hex($controls[LDAP_CONTROL_VLVRESPONSE]['value']['context']) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_variation1.phpt b/ext/ldap/tests/ldap_search_variation1.phpt index 5fa30b4c7ac2..88eb79aa77ab 100644 --- a/ext/ldap/tests/ldap_search_variation1.phpt +++ b/ext/ldap/tests/ldap_search_variation1.phpt @@ -19,8 +19,8 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(dc=*)"; var_dump( - $result = ldap_search($link, "o=test,$base", "(o=*)", array('o')), - ldap_get_entries($link, $result) + $result = ldap_search($link, "o=test,$base", "(o=*)", array('o')), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_variation2.phpt b/ext/ldap/tests/ldap_search_variation2.phpt index c06afbaac050..8b130aaa0828 100644 --- a/ext/ldap/tests/ldap_search_variation2.phpt +++ b/ext/ldap/tests/ldap_search_variation2.phpt @@ -17,8 +17,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); insert_dummy_data($link, $base); var_dump( - $result = ldap_search($link, "$base", "(objectclass=person)", array('sn'), 1), - ldap_get_entries($link, $result) + $result = ldap_search($link, "$base", "(objectclass=person)", array('sn'), 1), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_variation3.phpt b/ext/ldap/tests/ldap_search_variation3.phpt index 2a07654e4f40..d0b6ec5cad95 100644 --- a/ext/ldap/tests/ldap_search_variation3.phpt +++ b/ext/ldap/tests/ldap_search_variation3.phpt @@ -19,13 +19,13 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(objectclass=person)"; var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 3), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 3), + ldap_get_entries($link, $result) ); var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_variation4.phpt b/ext/ldap/tests/ldap_search_variation4.phpt index 298777263e67..694840b397bb 100644 --- a/ext/ldap/tests/ldap_search_variation4.phpt +++ b/ext/ldap/tests/ldap_search_variation4.phpt @@ -19,8 +19,8 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(objectclass=person)"; var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_variation5.phpt b/ext/ldap/tests/ldap_search_variation5.phpt index e6ac54e21d00..211df9a12887 100644 --- a/ext/ldap/tests/ldap_search_variation5.phpt +++ b/ext/ldap/tests/ldap_search_variation5.phpt @@ -19,16 +19,16 @@ insert_dummy_data($link, $base); $dn = "$base"; $filter = "(objectclass=person)"; var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3, LDAP_DEREF_SEARCHING), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3, LDAP_DEREF_SEARCHING), + ldap_get_entries($link, $result) ); var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3, LDAP_DEREF_FINDING), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3, LDAP_DEREF_FINDING), + ldap_get_entries($link, $result) ); var_dump( - $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3, LDAP_DEREF_ALWAYS), - ldap_get_entries($link, $result) + $result = ldap_search($link, $dn, $filter, array('sn'), 1, 1, 3, LDAP_DEREF_ALWAYS), + ldap_get_entries($link, $result) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_search_variation6.phpt b/ext/ldap/tests/ldap_search_variation6.phpt index 593804136726..6451c2930b49 100644 --- a/ext/ldap/tests/ldap_search_variation6.phpt +++ b/ext/ldap/tests/ldap_search_variation6.phpt @@ -20,19 +20,19 @@ $dn = "$base"; $filter = "(objectclass=person)"; var_dump( - $result = ldap_search(array($link, $link), $dn, $filter), - $result0 = ldap_get_entries($link, $result[0]), - ldap_get_entries($link, $result[1]) === $result0 + $result = ldap_search(array($link, $link), $dn, $filter), + $result0 = ldap_get_entries($link, $result[0]), + ldap_get_entries($link, $result[1]) === $result0 ); var_dump( - $result = ldap_search(array($link, $link), "", $filter), - ldap_get_entries($link, $result[0]), - ldap_get_entries($link, $result[1]) + $result = ldap_search(array($link, $link), "", $filter), + ldap_get_entries($link, $result[0]), + ldap_get_entries($link, $result[1]) ); var_dump( - $result = ldap_search(array($link, $link), "", array($filter, $filter)), - ldap_get_entries($link, $result[0]), - ldap_get_entries($link, $result[1]) + $result = ldap_search(array($link, $link), "", array($filter, $filter)), + ldap_get_entries($link, $result[0]), + ldap_get_entries($link, $result[1]) ); ?> --CLEAN-- diff --git a/ext/ldap/tests/ldap_set_option_cafiles_basic.phpt b/ext/ldap/tests/ldap_set_option_cafiles_basic.phpt index 492df3bc8b1e..945216d1c010 100644 --- a/ext/ldap/tests/ldap_set_option_cafiles_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_cafiles_basic.phpt @@ -10,18 +10,18 @@ require "connect.inc"; $link = ldap_connect($host, $port); foreach([ - LDAP_OPT_X_TLS_CACERTDIR, - LDAP_OPT_X_TLS_CACERTFILE, - LDAP_OPT_X_TLS_CERTFILE, - LDAP_OPT_X_TLS_KEYFILE, - LDAP_OPT_X_TLS_CRLFILE, - LDAP_OPT_X_TLS_DHFILE, + LDAP_OPT_X_TLS_CACERTDIR, + LDAP_OPT_X_TLS_CACERTFILE, + LDAP_OPT_X_TLS_CERTFILE, + LDAP_OPT_X_TLS_KEYFILE, + LDAP_OPT_X_TLS_CRLFILE, + LDAP_OPT_X_TLS_DHFILE, ] as $option) { - $result = ldap_set_option($link, $option, '/foo/bar'); - var_dump($result); + $result = ldap_set_option($link, $option, '/foo/bar'); + var_dump($result); - ldap_get_option($link, $option, $optionval); - var_dump($optionval); + ldap_get_option($link, $option, $optionval); + var_dump($optionval); } ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_set_option_crlcheck_basic.phpt b/ext/ldap/tests/ldap_set_option_crlcheck_basic.phpt index f8e3c8cf4067..eff51c785eb5 100644 --- a/ext/ldap/tests/ldap_set_option_crlcheck_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_crlcheck_basic.phpt @@ -18,15 +18,15 @@ require "connect.inc"; $link = ldap_connect($host, $port); foreach([ - LDAP_OPT_X_TLS_CRL_NONE, - LDAP_OPT_X_TLS_CRL_PEER, - LDAP_OPT_X_TLS_CRL_ALL, + LDAP_OPT_X_TLS_CRL_NONE, + LDAP_OPT_X_TLS_CRL_PEER, + LDAP_OPT_X_TLS_CRL_ALL, ] as $option) { - $result = ldap_set_option($link, LDAP_OPT_X_TLS_CRLCHECK, $option); - var_dump($result); + $result = ldap_set_option($link, LDAP_OPT_X_TLS_CRLCHECK, $option); + var_dump($result); - ldap_get_option($link, LDAP_OPT_X_TLS_CRLCHECK, $optionval); - var_dump($optionval); + ldap_get_option($link, LDAP_OPT_X_TLS_CRLCHECK, $optionval); + var_dump($optionval); } ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_set_option_error.phpt b/ext/ldap/tests/ldap_set_option_error.phpt index e7ef6bac6bda..079c63577d50 100644 --- a/ext/ldap/tests/ldap_set_option_error.phpt +++ b/ext/ldap/tests/ldap_set_option_error.phpt @@ -11,22 +11,22 @@ require "connect.inc"; $link = ldap_connect($host, $port); $controls = array( - array( - array("xid" => "1.2.752.58.10.1", "iscritical" => true), - array("xid" => "1.2.752.58.1.10", "value" => "magic"), - ), - array( - array("oid" => "1.2.752.58.10.1", "iscritical" => true), - array("oid" => "1.2.752.58.1.10", "value" => "magic"), - "weird" - ), - "notanarray" + array( + array("xid" => "1.2.752.58.10.1", "iscritical" => true), + array("xid" => "1.2.752.58.1.10", "value" => "magic"), + ), + array( + array("oid" => "1.2.752.58.10.1", "iscritical" => true), + array("oid" => "1.2.752.58.1.10", "value" => "magic"), + "weird" + ), + "notanarray" ); var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 10)); foreach ($controls as $control) - var_dump(ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $control)); + var_dump(ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $control)); var_dump(ldap_set_option($link, 999999, 999999)); ?> diff --git a/ext/ldap/tests/ldap_set_option_keepalive_basic.phpt b/ext/ldap/tests/ldap_set_option_keepalive_basic.phpt index 865345dc4dd2..f00e885ebea9 100644 --- a/ext/ldap/tests/ldap_set_option_keepalive_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_keepalive_basic.phpt @@ -10,15 +10,15 @@ require "connect.inc"; $link = ldap_connect($host, $port); foreach([ - LDAP_OPT_X_KEEPALIVE_IDLE, - LDAP_OPT_X_KEEPALIVE_PROBES, - LDAP_OPT_X_KEEPALIVE_INTERVAL, + LDAP_OPT_X_KEEPALIVE_IDLE, + LDAP_OPT_X_KEEPALIVE_PROBES, + LDAP_OPT_X_KEEPALIVE_INTERVAL, ] as $option) { - $result = ldap_set_option($link, $option, 5); - var_dump($result); + $result = ldap_set_option($link, $option, 5); + var_dump($result); - ldap_get_option($link, $option, $optionval); - var_dump($optionval); + ldap_get_option($link, $option, $optionval); + var_dump($optionval); } ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_set_option_reqcert_basic.phpt b/ext/ldap/tests/ldap_set_option_reqcert_basic.phpt index 220bb2ff31e0..d087dbf88cc4 100644 --- a/ext/ldap/tests/ldap_set_option_reqcert_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_reqcert_basic.phpt @@ -10,17 +10,17 @@ require "connect.inc"; $link = ldap_connect($host, $port); foreach([ - LDAP_OPT_X_TLS_NEVER, - LDAP_OPT_X_TLS_HARD, - LDAP_OPT_X_TLS_DEMAND, - LDAP_OPT_X_TLS_ALLOW, - LDAP_OPT_X_TLS_TRY, + LDAP_OPT_X_TLS_NEVER, + LDAP_OPT_X_TLS_HARD, + LDAP_OPT_X_TLS_DEMAND, + LDAP_OPT_X_TLS_ALLOW, + LDAP_OPT_X_TLS_TRY, ] as $option) { - $result = ldap_set_option($link, LDAP_OPT_X_TLS_REQUIRE_CERT, $option); - var_dump($result); + $result = ldap_set_option($link, LDAP_OPT_X_TLS_REQUIRE_CERT, $option); + var_dump($result); - ldap_get_option($link, LDAP_OPT_X_TLS_REQUIRE_CERT, $optionval); - var_dump($optionval); + ldap_get_option($link, LDAP_OPT_X_TLS_REQUIRE_CERT, $optionval); + var_dump($optionval); } ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt index 796cb8c7e187..782ea2499223 100644 --- a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt @@ -10,17 +10,17 @@ require "connect.inc"; $link = ldap_connect($host, $port); foreach([ - LDAP_OPT_X_TLS_PROTOCOL_SSL2, - LDAP_OPT_X_TLS_PROTOCOL_SSL3, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, + LDAP_OPT_X_TLS_PROTOCOL_SSL2, + LDAP_OPT_X_TLS_PROTOCOL_SSL3, + LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, + LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, + LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, ] as $option) { - $result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $option); - var_dump($result); + $result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $option); + var_dump($result); - ldap_get_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $optionval); - var_dump($optionval); + ldap_get_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $optionval); + var_dump($optionval); } ?> --EXPECT-- diff --git a/ext/ldap/tests/ldap_set_option_variation.phpt b/ext/ldap/tests/ldap_set_option_variation.phpt index f31473ef7a88..4f1e8626d743 100644 --- a/ext/ldap/tests/ldap_set_option_variation.phpt +++ b/ext/ldap/tests/ldap_set_option_variation.phpt @@ -13,50 +13,50 @@ $link = ldap_connect($host, $port); $option = null; $controls = array( - array("oid" => "1.2.752.58.10.1", "iscritical" => true), - array("oid" => "1.2.752.58.1.10", "value" => "magic"), + array("oid" => "1.2.752.58.10.1", "iscritical" => true), + array("oid" => "1.2.752.58.1.10", "value" => "magic"), ); var_dump(ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS)); ldap_get_option($link, LDAP_OPT_DEREF, $option); var_dump( - $option === LDAP_DEREF_ALWAYS, - ldap_set_option($link, LDAP_OPT_SIZELIMIT, 123) + $option === LDAP_DEREF_ALWAYS, + ldap_set_option($link, LDAP_OPT_SIZELIMIT, 123) ); ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option); var_dump( - $option, - ldap_set_option($link, LDAP_OPT_TIMELIMIT, 33) + $option, + ldap_set_option($link, LDAP_OPT_TIMELIMIT, 33) ); ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option); var_dump( - $option, - ldap_set_option($link, LDAP_OPT_NETWORK_TIMEOUT, 44) + $option, + ldap_set_option($link, LDAP_OPT_NETWORK_TIMEOUT, 44) ); ldap_get_option($link, LDAP_OPT_NETWORK_TIMEOUT, $option); var_dump( - $option, - ldap_set_option($link, LDAP_OPT_REFERRALS, true) + $option, + ldap_set_option($link, LDAP_OPT_REFERRALS, true) ); ldap_get_option($link, LDAP_OPT_REFERRALS, $option); var_dump( - (bool) $option, - ldap_set_option($link, LDAP_OPT_RESTART, false) + (bool) $option, + ldap_set_option($link, LDAP_OPT_RESTART, false) ); ldap_get_option($link, LDAP_OPT_RESTART, $option); var_dump( - (bool) $option, - ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls) + (bool) $option, + ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls) ); ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $option); var_dump( - $option, - ldap_set_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls) + $option, + ldap_set_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls) ); ldap_get_option($link, LDAP_OPT_CLIENT_CONTROLS, $option); var_dump( - $option, - ldap_set_option($link, LDAP_OPT_MATCHED_DN, "dc=test,dc=com") + $option, + ldap_set_option($link, LDAP_OPT_MATCHED_DN, "dc=test,dc=com") ); ldap_get_option($link, LDAP_OPT_MATCHED_DN, $option); var_dump($option); diff --git a/ext/ldap/tests/ldap_unbind_variation.phpt b/ext/ldap/tests/ldap_unbind_variation.phpt index 3233e90b6fa4..0c933543ebc7 100644 --- a/ext/ldap/tests/ldap_unbind_variation.phpt +++ b/ext/ldap/tests/ldap_unbind_variation.phpt @@ -11,16 +11,16 @@ Patrick Allaert require "connect.inc"; function rebind_proc ($ds, $ldap_url) { - global $user; - global $passwd; - global $protocol_version; + global $user; + global $passwd; + global $protocol_version; - // required by most modern LDAP servers, use LDAPv3 - ldap_set_option($a, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); + // required by most modern LDAP servers, use LDAPv3 + ldap_set_option($a, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); - if (!ldap_bind($a, $user, $passwd)) { - print "Cannot bind"; - } + if (!ldap_bind($a, $user, $passwd)) { + print "Cannot bind"; + } } $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); diff --git a/ext/ldap/tests/skipif.inc b/ext/ldap/tests/skipif.inc index d3494284b0ea..dc016787dae7 100644 --- a/ext/ldap/tests/skipif.inc +++ b/ext/ldap/tests/skipif.inc @@ -1,5 +1,5 @@ diff --git a/ext/ldap/tests/skipifbindfailure.inc b/ext/ldap/tests/skipifbindfailure.inc index f79bb9d6903e..8f66c6cb9683 100644 --- a/ext/ldap/tests/skipifbindfailure.inc +++ b/ext/ldap/tests/skipifbindfailure.inc @@ -3,11 +3,11 @@ require_once 'connect.inc'; if ($skip_on_bind_failure) { - $link = ldap_connect($host, $port); - ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); - if (!@ldap_bind($link, $user, $passwd)) - die(sprintf("skip Can't bind to LDAP Server - [%d] %s", ldap_errno($link), ldap_error($link))); + $link = ldap_connect($host, $port); + ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version); + if (!@ldap_bind($link, $user, $passwd)) + die(sprintf("skip Can't bind to LDAP Server - [%d] %s", ldap_errno($link), ldap_error($link))); - ldap_unbind($link); + ldap_unbind($link); } ?> diff --git a/ext/ldap/tests/skipifcontrol.inc b/ext/ldap/tests/skipifcontrol.inc index ae551d6add86..ff690068aeeb 100644 --- a/ext/ldap/tests/skipifcontrol.inc +++ b/ext/ldap/tests/skipifcontrol.inc @@ -3,11 +3,11 @@ require_once 'connect.inc'; function skipifunsupportedcontrol($oid) { - global $host, $port, $user, $passwd, $protocol_version, $base; - $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); - $result = ldap_read($link, '', '(objectClass=*)', ['supportedControl']); - if (!in_array($oid, ldap_get_entries($link, $result)[0]['supportedcontrol'])) { - die(sprintf("skip Unsupported control %s", $oid)); - } + global $host, $port, $user, $passwd, $protocol_version, $base; + $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); + $result = ldap_read($link, '', '(objectClass=*)', ['supportedControl']); + if (!in_array($oid, ldap_get_entries($link, $result)[0]['supportedcontrol'])) { + die(sprintf("skip Unsupported control %s", $oid)); + } } ?> diff --git a/ext/libxml/tests/002.phpt b/ext/libxml/tests/002.phpt index 75011462f33e..f88753d977c6 100644 --- a/ext/libxml/tests/002.phpt +++ b/ext/libxml/tests/002.phpt @@ -20,40 +20,40 @@ $doc = simplexml_load_string($xmlstr); $xml = explode("\n", $xmlstr); if (!$doc) { - $errors = libxml_get_errors(); + $errors = libxml_get_errors(); - foreach ($errors as $error) { - echo display_xml_error($error, $xml); - } + foreach ($errors as $error) { + echo display_xml_error($error, $xml); + } - var_dump(libxml_get_last_error()); + var_dump(libxml_get_last_error()); } function display_xml_error($error, $xml) { - $return = $xml[$error->line - 1] . "\n"; - $return .= str_repeat('-', $error->column) . "^\n"; - - switch ($error->level) { - case LIBXML_ERR_WARNING: - $return .= "Warning $error->code: "; - break; - case LIBXML_ERR_ERROR: - $return .= "Error $error->code: "; - break; - case LIBXML_ERR_FATAL: - $return .= "Fatal Error $error->code: "; - break; - } - - $return .= trim($error->message) . "\n Line: $error->line" . "\n Column: $error->column"; - - if ($error->file) { - $return .= "\n File: $error->file"; - } - - return "$return\n\n--------------------------------------------\n\n"; + $return = $xml[$error->line - 1] . "\n"; + $return .= str_repeat('-', $error->column) . "^\n"; + + switch ($error->level) { + case LIBXML_ERR_WARNING: + $return .= "Warning $error->code: "; + break; + case LIBXML_ERR_ERROR: + $return .= "Error $error->code: "; + break; + case LIBXML_ERR_FATAL: + $return .= "Fatal Error $error->code: "; + break; + } + + $return .= trim($error->message) . "\n Line: $error->line" . "\n Column: $error->column"; + + if ($error->file) { + $return .= "\n File: $error->file"; + } + + return "$return\n\n--------------------------------------------\n\n"; } diff --git a/ext/libxml/tests/004.phpt b/ext/libxml/tests/004.phpt index da96faad57ec..e3daa41d24d6 100644 --- a/ext/libxml/tests/004.phpt +++ b/ext/libxml/tests/004.phpt @@ -6,22 +6,22 @@ libxml_set_streams_context() getMessage(), "\n"; } - $dom = new DOMDocument(); - var_dump($dom->load(__DIR__.'/test.xml')); + $dom = new DOMDocument(); + var_dump($dom->load(__DIR__.'/test.xml')); } echo "Done\n"; diff --git a/ext/libxml/tests/bug42112.phpt b/ext/libxml/tests/bug42112.phpt index a1b887134228..6ca95f6e0673 100644 --- a/ext/libxml/tests/bug42112.phpt +++ b/ext/libxml/tests/bug42112.phpt @@ -21,7 +21,7 @@ remove_node($doc); $node = $doc->getElementById( 'id1' ); if ($node) { - print 'Found Node: '.$node->nodeName."\n"; + print 'Found Node: '.$node->nodeName."\n"; } $root = $doc->documentElement; print 'Root Node: '.$root->nodeName."\n"; diff --git a/ext/libxml/tests/bug54440.phpt b/ext/libxml/tests/bug54440.phpt index 4074ff9fe840..a4d5ed488064 100644 --- a/ext/libxml/tests/bug54440.phpt +++ b/ext/libxml/tests/bug54440.phpt @@ -9,9 +9,9 @@ class TestWrapper { function stream_open($path, $mode, $options, &$opened_path) { - if ($this->context) - print_r(stream_context_get_options($this->context)); - return false; + if ($this->context) + print_r(stream_context_get_options($this->context)); + return false; } function url_stat($path, $flags) diff --git a/ext/libxml/tests/bug61367-read.phpt b/ext/libxml/tests/bug61367-read.phpt index f82ecf138a3a..97b6513094b8 100644 --- a/ext/libxml/tests/bug61367-read.phpt +++ b/ext/libxml/tests/bug61367-read.phpt @@ -10,25 +10,25 @@ open_basedir=. * Note: Using error_reporting=E_ALL & ~E_NOTICE to suppress "Trying to get property of non-object" notices. */ class StreamExploiter { - public function stream_close ( ) { - $doc = new DOMDocument; - $doc->resolveExternals = true; - $doc->substituteEntities = true; - $dir = htmlspecialchars(dirname(getcwd())); - $dir = str_replace('\\', '/', $dir); // fix for windows - $doc->loadXML( <<resolveExternals = true; + $doc->substituteEntities = true; + $dir = htmlspecialchars(dirname(getcwd())); + $dir = str_replace('\\', '/', $dir); // fix for windows + $doc->loadXML( << + ]> &file; XML - ); - print $doc->documentElement->firstChild->nodeValue; - } + ); + print $doc->documentElement->firstChild->nodeValue; + } - public function stream_open ( $path , $mode , $options , &$opened_path ) { - return true; - } + public function stream_open ( $path , $mode , $options , &$opened_path ) { + return true; + } } var_dump(mkdir('test_bug_61367-read')); diff --git a/ext/libxml/tests/bug61367-write.phpt b/ext/libxml/tests/bug61367-write.phpt index 16951ec82519..f84de1076ba6 100644 --- a/ext/libxml/tests/bug61367-write.phpt +++ b/ext/libxml/tests/bug61367-write.phpt @@ -8,15 +8,15 @@ open_basedir=. appendChild($doc->createTextNode('hello')); - var_dump($doc->save(dirname(getcwd()) . '/bad')); - } + public function stream_close ( ) { + $doc = new DOMDocument; + $doc->appendChild($doc->createTextNode('hello')); + var_dump($doc->save(dirname(getcwd()) . '/bad')); + } - public function stream_open ( $path , $mode , $options , &$opened_path ) { - return true; - } + public function stream_open ( $path , $mode , $options , &$opened_path ) { + return true; + } } var_dump(mkdir('test_bug_61367-write')); diff --git a/ext/libxml/tests/libxml_set_external_entity_loader_basic.phpt b/ext/libxml/tests/libxml_set_external_entity_loader_basic.phpt index b53027601688..b8b7b7f796c4 100644 --- a/ext/libxml/tests/libxml_set_external_entity_loader_basic.phpt +++ b/ext/libxml/tests/libxml_set_external_entity_loader_basic.phpt @@ -14,15 +14,15 @@ $dtd = <<loadXML($xml); var_dump(libxml_set_external_entity_loader(function($a, $b, $c, $d) {})); try { - var_dump($dd->validate()); + var_dump($dd->validate()); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "Done.\n"; diff --git a/ext/libxml/tests/libxml_set_external_entity_loader_variation1.phpt b/ext/libxml/tests/libxml_set_external_entity_loader_variation1.phpt index 02f984f9bc1a..61c82d327540 100644 --- a/ext/libxml/tests/libxml_set_external_entity_loader_variation1.phpt +++ b/ext/libxml/tests/libxml_set_external_entity_loader_variation1.phpt @@ -23,17 +23,17 @@ $entity = << --EXPECT-- diff --git a/ext/mbstring/tests/bug30549.phpt b/ext/mbstring/tests/bug30549.phpt index a6007e0b38de..2feadf1d5a03 100644 --- a/ext/mbstring/tests/bug30549.phpt +++ b/ext/mbstring/tests/bug30549.phpt @@ -9,13 +9,13 @@ test('ISO-8859-8', array(0xaf => 0x00af, 0xfd => 0x200e, 0xfe => 0x200f)); test('ISO-8859-10', array(0xa4 => 0x012a )); function test($enc, $map) { - print "$enc\n"; + print "$enc\n"; - foreach($map as $fromc => $toc) { - $ustr = mb_convert_encoding(pack('C', $fromc), 'UCS-4BE', $enc); - foreach (unpack('Nc', $ustr) as $unic); - printf("0x%04x, 0x%04x\n", $toc, $unic); - } + foreach($map as $fromc => $toc) { + $ustr = mb_convert_encoding(pack('C', $fromc), 'UCS-4BE', $enc); + foreach (unpack('Nc', $ustr) as $unic); + printf("0x%04x, 0x%04x\n", $toc, $unic); + } } ?> --EXPECT-- diff --git a/ext/mbstring/tests/bug43840.phpt b/ext/mbstring/tests/bug43840.phpt index 457356823ece..7a3fd030944e 100644 --- a/ext/mbstring/tests/bug43840.phpt +++ b/ext/mbstring/tests/bug43840.phpt @@ -24,19 +24,19 @@ $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXv $needle = base64_decode('44CC'); foreach($offsets as $i) { - echo "\n-- Offset is $i --\n"; - echo "--Multibyte String:--\n"; - try { - var_dump( mb_strpos($string_mb, $needle, $i, 'UTF-8') ); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } - echo"--ASCII String:--\n"; - try { - var_dump(mb_strpos('This is na English ta', 'a', $i)); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } + echo "\n-- Offset is $i --\n"; + echo "--Multibyte String:--\n"; + try { + var_dump( mb_strpos($string_mb, $needle, $i, 'UTF-8') ); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + echo"--ASCII String:--\n"; + try { + var_dump(mb_strpos('This is na English ta', 'a', $i)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } } ?> --EXPECT-- diff --git a/ext/mbstring/tests/bug43841.phpt b/ext/mbstring/tests/bug43841.phpt index cb24ece04a1c..4a1da505d4e7 100644 --- a/ext/mbstring/tests/bug43841.phpt +++ b/ext/mbstring/tests/bug43841.phpt @@ -22,26 +22,26 @@ $string_mb = "日本語テキストã§ã™ã€‚0123456789。"; $needle = "。"; foreach ($offsets as $i) { - echo "\n-- Offset is $i --\n"; - echo "Multibyte String:\n"; - try { - var_dump( mb_strrpos($string_mb, $needle, $i, 'UTF-8') ); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } - echo "ASCII String:\n"; - echo "mb_strrpos:\n"; - try { - var_dump(mb_strrpos('This is na English ta', 'a', $i)); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } - echo "strrpos:\n"; - try { - var_dump(strrpos('This is na English ta', 'a', $i)); - } catch (\ValueError $e) { - echo $e->getMessage() . \PHP_EOL; - } + echo "\n-- Offset is $i --\n"; + echo "Multibyte String:\n"; + try { + var_dump( mb_strrpos($string_mb, $needle, $i, 'UTF-8') ); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + echo "ASCII String:\n"; + echo "mb_strrpos:\n"; + try { + var_dump(mb_strrpos('This is na English ta', 'a', $i)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + echo "strrpos:\n"; + try { + var_dump(strrpos('This is na English ta', 'a', $i)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } } ?> --EXPECT-- diff --git a/ext/mbstring/tests/bug43994.phpt b/ext/mbstring/tests/bug43994.phpt index 6bc03326ad93..387a907c2987 100644 --- a/ext/mbstring/tests/bug43994.phpt +++ b/ext/mbstring/tests/bug43994.phpt @@ -25,16 +25,16 @@ $inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var, $iterator = 1; foreach($inputs as $input) { - if(@is_array($mb_regs)){ - $mb_regs = ''; - } - echo "\n-- Iteration $iterator --\n"; - echo "Without \$regs arg:\n"; - var_dump( mb_ereg($input, 'hello, world') ); - echo "With \$regs arg:\n"; - var_dump(mb_ereg($input, 'hello, world', $mb_regs)); - var_dump($mb_regs); - $iterator++; + if(@is_array($mb_regs)){ + $mb_regs = ''; + } + echo "\n-- Iteration $iterator --\n"; + echo "Without \$regs arg:\n"; + var_dump( mb_ereg($input, 'hello, world') ); + echo "With \$regs arg:\n"; + var_dump(mb_ereg($input, 'hello, world', $mb_regs)); + var_dump($mb_regs); + $iterator++; }; ?> --EXPECTF-- diff --git a/ext/mbstring/tests/bug45923.phpt b/ext/mbstring/tests/bug45923.phpt index 522f4ddddd63..37d2b13f8bbc 100644 --- a/ext/mbstring/tests/bug45923.phpt +++ b/ext/mbstring/tests/bug45923.phpt @@ -7,15 +7,15 @@ Bug #45923 (mb_st[r]ripos() offset not handled correctly) function section($func, $haystack, $needle) { - echo "\n------- $func -----------\n\n"; - foreach([0, 3, 6, 9, 11, 12, -1, -3, -6, -20] as $offset) { - echo "> Offset: $offset\n"; + echo "\n------- $func -----------\n\n"; + foreach([0, 3, 6, 9, 11, 12, -1, -3, -6, -20] as $offset) { + echo "> Offset: $offset\n"; try { - var_dump($func($haystack, $needle, $offset)); + var_dump($func($haystack, $needle, $offset)); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } - } + } } section('strpos' , "abc abc abc" , "abc"); diff --git a/ext/mbstring/tests/bug52981.phpt b/ext/mbstring/tests/bug52981.phpt index f6be08bf336a..3d909635e3ee 100644 --- a/ext/mbstring/tests/bug52981.phpt +++ b/ext/mbstring/tests/bug52981.phpt @@ -6,10 +6,10 @@ Bug #52981 (Unicode properties are outdated (from Unicode 3.2)) DONE diff --git a/ext/mbstring/tests/casefold.phpt b/ext/mbstring/tests/casefold.phpt index 2138aff255b4..2f872da1b50e 100644 --- a/ext/mbstring/tests/casefold.phpt +++ b/ext/mbstring/tests/casefold.phpt @@ -10,11 +10,11 @@ function_exists('mb_convert_case' ) or die("skip mb_convert_case() is not availa output_handler= --FILE-- --EXPECT-- abcdefghijklmnopqrstuvwxyz diff --git a/ext/mbstring/tests/common.inc b/ext/mbstring/tests/common.inc index c8467a29f512..2ee26bbfd535 100644 --- a/ext/mbstring/tests/common.inc +++ b/ext/mbstring/tests/common.inc @@ -5,18 +5,18 @@ // Var def for testing $t_ary = array( - 's1' => 'ÆüËܸìEUC-JP¤Îʸ»úÎó', - 's2' => 'English Text' - ); + 's1' => 'ÆüËܸìEUC-JP¤Îʸ»úÎó', + 's2' => 'English Text' + ); class tc { - public $s1 = 'ÆüËܸìEUC-JP¤Îʸ»úÎó'; - public $s2 = 'English Text'; + public $s1 = 'ÆüËܸìEUC-JP¤Îʸ»úÎó'; + public $s2 = 'English Text'; - function __construct() - { - } + function __construct() + { + } } $t_obj = new tc; diff --git a/ext/mbstring/tests/illformed_utf_sequences.phpt b/ext/mbstring/tests/illformed_utf_sequences.phpt index 11ab1799e9c8..3b7d431a0ed1 100644 --- a/ext/mbstring/tests/illformed_utf_sequences.phpt +++ b/ext/mbstring/tests/illformed_utf_sequences.phpt @@ -5,16 +5,16 @@ Unicode standard conformance test (ill-formed UTF sequences.) --FILE-- > 12), 0x80 | ($i >> 6) & 0x3f, 0x80 | $i & 0x3f), 3); - if ($s === false) { - $cnt++; - } else { - $out .= $s; - } + $s = chk_enc(pack('C3', 0xe0 | ($i >> 12), 0x80 | ($i >> 6) & 0x3f, 0x80 | $i & 0x3f), 3); + if ($s === false) { + $cnt++; + } else { + $out .= $s; + } } var_dump($cnt); var_dump($out); @@ -88,11 +88,11 @@ $out = ''; $cnt = 0; for ($i = 0xd7ff; $i <= 0xe000; ++$i) { $s = chk_enc(pack('C4', $i >> 24, ($i >> 16) & 0xff, ($i >> 8) & 0xff, $i & 0xff), 1, "UTF-32BE"); - if ($s === false) { - $cnt++; - } else { - $out .= $s; - } + if ($s === false) { + $cnt++; + } else { + $out .= $s; + } } var_dump($cnt); var_dump($out); @@ -101,11 +101,11 @@ $out = ''; $cnt = 0; for ($i = 0xd7ff; $i <= 0xe000; ++$i) { $s = chk_enc(pack('C4', $i & 0xff, ($i >> 8) & 0xff, ($i >> 16) & 0xff, ($i >> 24) & 0xff), 1, "UTF-32LE"); - if ($s === false) { - $cnt++; - } else { - $out .= $s; - } + if ($s === false) { + $cnt++; + } else { + $out .= $s; + } } var_dump($cnt); var_dump($out); @@ -114,11 +114,11 @@ $out = ''; $cnt = 0; for ($i = 0xd7ff; $i <= 0xe000; ++$i) { $s = chk_enc(pack('C4', $i >> 24, ($i >> 16) & 0xff, ($i >> 8) & 0xff, $i & 0xff), 1, "UTF-32"); - if ($s === false) { - $cnt++; - } else { - $out .= $s; - } + if ($s === false) { + $cnt++; + } else { + $out .= $s; + } } var_dump($cnt); var_dump($out); @@ -129,12 +129,12 @@ $out = ''; $cnt = 0; for ($i = 0xd7ff; $i <= 0xe000; ++$i) { $s = chk_enc("\x00\x00\xfe\xff". pack('C4', $i >> 24, ($i >> 16) & 0xff, ($i >> 8) & 0xff, $i & 0xff), - 1, "UTF-32", true); - if ($s === false) { - $cnt++; - } else { - $out .= $s; - } + 1, "UTF-32", true); + if ($s === false) { + $cnt++; + } else { + $out .= $s; + } } var_dump($cnt); var_dump(str_replace("0000feff","",$out)); @@ -143,12 +143,12 @@ $out = ''; $cnt = 0; for ($i = 0xd7ff; $i <= 0xe000; ++$i) { $s = chk_enc("\xff\xfe\x00\x00". pack('C4', $i & 0xff, ($i >> 8) & 0xff, ($i >> 16) & 0xff, ($i >> 24) & 0xff), - 1, "UTF-32", true); - if ($s === false) { - $cnt++; - } else { - $out .= $s; - } + 1, "UTF-32", true); + if ($s === false) { + $cnt++; + } else { + $out .= $s; + } } var_dump($cnt); var_dump(str_replace("0000feff","",$out)); diff --git a/ext/mbstring/tests/mb_chr.phpt b/ext/mbstring/tests/mb_chr.phpt index d61178af4d96..e4d74e0d678c 100644 --- a/ext/mbstring/tests/mb_chr.phpt +++ b/ext/mbstring/tests/mb_chr.phpt @@ -13,11 +13,11 @@ var_dump( // Invalid var_dump( - mb_chr(0xd800, "typo"), - mb_chr(0xd800, "pass"), - mb_chr(0xd800, "jis"), - mb_chr(0xd800, "cp50222"), - mb_chr(0xd800, "utf-7") + mb_chr(0xd800, "typo"), + mb_chr(0xd800, "pass"), + mb_chr(0xd800, "jis"), + mb_chr(0xd800, "cp50222"), + mb_chr(0xd800, "utf-7") ); ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_chr_ord.phpt b/ext/mbstring/tests/mb_chr_ord.phpt index 72a4220e8ba8..77f13dadfa7d 100644 --- a/ext/mbstring/tests/mb_chr_ord.phpt +++ b/ext/mbstring/tests/mb_chr_ord.phpt @@ -6,14 +6,14 @@ mb_chr() and mb_ord() s1 = $euc_jp; - $this->s2 = $euc_jp; - $this->s3 = $euc_jp; - } + public $s1; + public $s2; + public $s3; + + function __construct() + { + global $sjis, $jis, $euc_jp; + + $this->s1 = $euc_jp; + $this->s2 = $euc_jp; + $this->s3 = $euc_jp; + } } class bar { - public $s1; - public $s2; - public $s3; - - function __construct() - { - global $sjis, $jis, $euc_jp; - - $this->s1 = $euc_jp; - $this->s2 = $euc_jp; - $this->s3 = $euc_jp; - } + public $s1; + public $s2; + public $s3; + + function __construct() + { + global $sjis, $jis, $euc_jp; + + $this->s1 = $euc_jp; + $this->s2 = $euc_jp; + $this->s3 = $euc_jp; + } } diff --git a/ext/mbstring/tests/mb_encode_mimeheader_basic.phpt b/ext/mbstring/tests/mb_encode_mimeheader_basic.phpt index 1352088ccdb9..205aeafcbe8a 100644 --- a/ext/mbstring/tests/mb_encode_mimeheader_basic.phpt +++ b/ext/mbstring/tests/mb_encode_mimeheader_basic.phpt @@ -26,21 +26,21 @@ $nonEnglish = array('Japanese' => base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44G 'Greek' => base64_decode('zpHPhc+Ez4wgzrXOr869zrHOuSDOtc67zrvOt869zrnOus+MIM66zrXOr868zrXOvc6/LiAwMTIzNDU2Nzg5Lg==')); foreach ($english as $lang => $input) { - echo "\nLanguage: $lang\n"; - echo "-- Base 64: --\n"; - var_dump(mb_encode_mimeheader($input, 'UTF-8', 'B')); - echo "-- Quoted-Printable --\n"; - var_dump(mb_encode_mimeheader($input, 'UTF-8', 'Q')); + echo "\nLanguage: $lang\n"; + echo "-- Base 64: --\n"; + var_dump(mb_encode_mimeheader($input, 'UTF-8', 'B')); + echo "-- Quoted-Printable --\n"; + var_dump(mb_encode_mimeheader($input, 'UTF-8', 'Q')); } mb_internal_encoding('utf-8'); foreach ($nonEnglish as $lang => $input) { - echo "\nLanguage: $lang\n"; - echo "-- Base 64: --\n"; - var_dump(mb_encode_mimeheader($input, 'UTF-8', 'B')); - echo "-- Quoted-Printable --\n"; - var_dump(mb_encode_mimeheader($input, 'UTF-8', 'Q')); + echo "\nLanguage: $lang\n"; + echo "-- Base 64: --\n"; + var_dump(mb_encode_mimeheader($input, 'UTF-8', 'B')); + echo "-- Quoted-Printable --\n"; + var_dump(mb_encode_mimeheader($input, 'UTF-8', 'Q')); } echo "Done"; diff --git a/ext/mbstring/tests/mb_encode_mimeheader_basic2.phpt b/ext/mbstring/tests/mb_encode_mimeheader_basic2.phpt index 151d4a610f2f..f108938e8b06 100644 --- a/ext/mbstring/tests/mb_encode_mimeheader_basic2.phpt +++ b/ext/mbstring/tests/mb_encode_mimeheader_basic2.phpt @@ -29,13 +29,13 @@ $inputs = array('SJIS' => $sjis_string, 'EUC_JP' => $euc_jp_string); foreach ($inputs as $lang => $input) { - echo "\nLanguage: $lang\n"; - echo "-- Base 64: --\n"; - mb_internal_encoding($lang); - $outEncoding = "UTF-8"; - var_dump(mb_encode_mimeheader($input, $outEncoding, 'B')); - echo "-- Quoted-Printable --\n"; - var_dump(mb_encode_mimeheader($input, $outEncoding, 'Q')); + echo "\nLanguage: $lang\n"; + echo "-- Base 64: --\n"; + mb_internal_encoding($lang); + $outEncoding = "UTF-8"; + var_dump(mb_encode_mimeheader($input, $outEncoding, 'B')); + echo "-- Quoted-Printable --\n"; + var_dump(mb_encode_mimeheader($input, $outEncoding, 'Q')); } echo "Done"; diff --git a/ext/mbstring/tests/mb_encode_mimeheader_basic3.phpt b/ext/mbstring/tests/mb_encode_mimeheader_basic3.phpt index d56a996892cb..7235255754a6 100644 --- a/ext/mbstring/tests/mb_encode_mimeheader_basic3.phpt +++ b/ext/mbstring/tests/mb_encode_mimeheader_basic3.phpt @@ -29,13 +29,13 @@ $inputs = array('SJIS' => $sjis_string, 'EUC_JP' => $euc_jp_string); foreach ($inputs as $lang => $input) { - echo "\nLanguage: $lang\n"; - echo "-- Base 64: --\n"; - mb_internal_encoding($lang); - $outEncoding = $lang; - var_dump(mb_encode_mimeheader($input, $outEncoding, 'B')); - echo "-- Quoted-Printable --\n"; - var_dump(mb_encode_mimeheader($input, $outEncoding, 'Q')); + echo "\nLanguage: $lang\n"; + echo "-- Base 64: --\n"; + mb_internal_encoding($lang); + $outEncoding = $lang; + var_dump(mb_encode_mimeheader($input, $outEncoding, 'B')); + echo "-- Quoted-Printable --\n"; + var_dump(mb_encode_mimeheader($input, $outEncoding, 'Q')); } echo "Done"; diff --git a/ext/mbstring/tests/mb_encode_mimeheader_variation6.phpt b/ext/mbstring/tests/mb_encode_mimeheader_variation6.phpt index edf602d55090..51dd85956c9b 100644 --- a/ext/mbstring/tests/mb_encode_mimeheader_variation6.phpt +++ b/ext/mbstring/tests/mb_encode_mimeheader_variation6.phpt @@ -28,9 +28,9 @@ $str = base64_decode('zpHPhc+Ez4wgzrXOr869zrHOuSDOtc67zrvOt869zrnOus+MIM66zrXOr8 $iterator = 1; foreach ($linefeeds as $linefeed) { - echo "\n-- Iteration $iterator --\n"; - var_dump(mb_encode_mimeheader($str, 'utf-8', 'B', $linefeed)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(mb_encode_mimeheader($str, 'utf-8', 'B', $linefeed)); + $iterator++; } diff --git a/ext/mbstring/tests/mb_ereg.phpt b/ext/mbstring/tests/mb_ereg.phpt index ff507adc0793..bc95a5fbaa00 100644 --- a/ext/mbstring/tests/mb_ereg.phpt +++ b/ext/mbstring/tests/mb_ereg.phpt @@ -9,26 +9,26 @@ function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build output_handler= --FILE-- --EXPECT-- (15)6162632064656620676869206a6b6c2064656620676869206a6b6c diff --git a/ext/mbstring/tests/mb_ereg1.phpt b/ext/mbstring/tests/mb_ereg1.phpt index fcc7e72e9fa2..875426a6c71e 100644 --- a/ext/mbstring/tests/mb_ereg1.phpt +++ b/ext/mbstring/tests/mb_ereg1.phpt @@ -6,20 +6,20 @@ mb_ereg() and invalid arguments getMessage(), "\n"; - } - var_dump($args); + try { + var_dump(mb_ereg($args[0], $args[1], $args[2])); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + var_dump($args); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_ereg_basic.phpt b/ext/mbstring/tests/mb_ereg_basic.phpt index b13f012b7b98..ef5bc11120f2 100644 --- a/ext/mbstring/tests/mb_ereg_basic.phpt +++ b/ext/mbstring/tests/mb_ereg_basic.phpt @@ -19,9 +19,9 @@ function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build echo "*** Testing mb_ereg() : basic functionality ***\n"; if(mb_regex_encoding('utf-8') == true) { - echo "Regex encoding set to utf-8\n"; + echo "Regex encoding set to utf-8\n"; } else { - echo "Could not set regex encoding to utf-8\n"; + echo "Could not set regex encoding to utf-8\n"; } $string_ascii = 'This is an English string. 0123456789.'; $regex_ascii1 = '(.*is)+.*\.[[:blank:]][0-9]{9}'; @@ -59,20 +59,20 @@ echo "Done"; * @param array $regs */ function base64_encode_var_dump($regs) { - if ($regs) { - echo "array(" . count($regs) . ") {\n"; - foreach ($regs as $key => $value) { - echo " [$key]=>\n "; - if (is_string($value)) { - var_dump(base64_encode($value)); - } else { - var_dump($value); - } - } - echo "}\n"; - } else { - echo "NULL\n"; - } + if ($regs) { + echo "array(" . count($regs) . ") {\n"; + foreach ($regs as $key => $value) { + echo " [$key]=>\n "; + if (is_string($value)) { + var_dump(base64_encode($value)); + } else { + var_dump($value); + } + } + echo "}\n"; + } else { + echo "NULL\n"; + } } ?> --EXPECT-- diff --git a/ext/mbstring/tests/mb_ereg_replace.phpt b/ext/mbstring/tests/mb_ereg_replace.phpt index 26838341fe11..7afb8fdad6c9 100644 --- a/ext/mbstring/tests/mb_ereg_replace.phpt +++ b/ext/mbstring/tests/mb_ereg_replace.phpt @@ -7,9 +7,9 @@ function_exists('mb_ereg_replace') or die("skip mb_ereg_replace() is not availab ?> --FILE-- --EXPECT-- a-b-c-d-e diff --git a/ext/mbstring/tests/mb_ereg_search_pos.phpt b/ext/mbstring/tests/mb_ereg_search_pos.phpt index e9c8aaafc754..1eb425d4aa0e 100644 --- a/ext/mbstring/tests/mb_ereg_search_pos.phpt +++ b/ext/mbstring/tests/mb_ereg_search_pos.phpt @@ -12,13 +12,13 @@ $test_str = 'I if(mb_ereg_search_init($test_str)) { - $val=mb_ereg_search_pos("nâtiôn"); + $val=mb_ereg_search_pos("nâtiôn"); - var_dump($val); + var_dump($val); } else{ - var_dump("false"); + var_dump("false"); } ?> --EXPECT-- diff --git a/ext/mbstring/tests/mb_ereg_search_setpos.phpt b/ext/mbstring/tests/mb_ereg_search_setpos.phpt index bd7d3ea060bf..0a90d005dd8f 100644 --- a/ext/mbstring/tests/mb_ereg_search_setpos.phpt +++ b/ext/mbstring/tests/mb_ereg_search_setpos.phpt @@ -17,9 +17,9 @@ mb_ereg_search_init($test_str); $positions = array( 5, 20, 21, 25, 0, -5, -20, -30); foreach($positions as $pos) { - echo("\n* Position: $pos :\n"); - var_dump(mb_ereg_search_setpos($pos)); - var_dump(mb_ereg_search_getpos()); + echo("\n* Position: $pos :\n"); + var_dump(mb_ereg_search_setpos($pos)); + var_dump(mb_ereg_search_getpos()); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_ereg_search_xxx.phpt b/ext/mbstring/tests/mb_ereg_search_xxx.phpt index a2049df144b3..7c2ef2605ac8 100644 --- a/ext/mbstring/tests/mb_ereg_search_xxx.phpt +++ b/ext/mbstring/tests/mb_ereg_search_xxx.phpt @@ -9,30 +9,30 @@ function_exists('mb_ereg_search') or die("skip\n"); output_handler= --FILE-- --EXPECT-- (EUC-JP) (10) ¡¦¢Ï diff --git a/ext/mbstring/tests/mb_ereg_variation3.phpt b/ext/mbstring/tests/mb_ereg_variation3.phpt index 17fa9444a419..9f484ee83d1d 100644 --- a/ext/mbstring/tests/mb_ereg_variation3.phpt +++ b/ext/mbstring/tests/mb_ereg_variation3.phpt @@ -37,14 +37,14 @@ $character_classes = array ('aB1' => '[[:alnum:]]+', /*1*/ $iterator = 1; foreach($character_classes as $string => $pattern) { - if (is_array(@$regs)) { - $regs = null; - } - // make sure any multibyte output is in base 64 - echo "\n-- Iteration $iterator --\n"; - var_dump(mb_ereg($pattern, $string, $regs)); - base64_encode_var_dump($regs); - $iterator++; + if (is_array(@$regs)) { + $regs = null; + } + // make sure any multibyte output is in base 64 + echo "\n-- Iteration $iterator --\n"; + var_dump(mb_ereg($pattern, $string, $regs)); + base64_encode_var_dump($regs); + $iterator++; } /** * replicate a var dump of an array but outputted string values are base64 encoded @@ -52,20 +52,20 @@ foreach($character_classes as $string => $pattern) { * @param array $regs */ function base64_encode_var_dump($regs) { - if ($regs) { - echo "array(" . count($regs) . ") {\n"; - foreach ($regs as $key => $value) { - echo " [$key]=>\n "; - if (is_string($value)) { - var_dump(base64_encode($value)); - } else { - var_dump($value); - } - } - echo "}\n"; - } else { - echo "NULL\n"; - } + if ($regs) { + echo "array(" . count($regs) . ") {\n"; + foreach ($regs as $key => $value) { + echo " [$key]=>\n "; + if (is_string($value)) { + var_dump(base64_encode($value)); + } else { + var_dump($value); + } + } + echo "}\n"; + } else { + echo "NULL\n"; + } } echo "Done"; diff --git a/ext/mbstring/tests/mb_ereg_variation4.phpt b/ext/mbstring/tests/mb_ereg_variation4.phpt index 54efbfb3f817..e487c5463c9a 100644 --- a/ext/mbstring/tests/mb_ereg_variation4.phpt +++ b/ext/mbstring/tests/mb_ereg_variation4.phpt @@ -39,15 +39,15 @@ $character_classes = array ('[[:alnum:]]+', /*1*/ $iterator = 1; foreach ($character_classes as $pattern) { - if (is_array(@$regs)) { - $regs = null; - } - echo "\n-- Iteration $iterator --\n"; - var_dump(mb_ereg($pattern, $string_mb, $regs)); - if ($regs) { - base64_encode_var_dump($regs); - } - $iterator++; + if (is_array(@$regs)) { + $regs = null; + } + echo "\n-- Iteration $iterator --\n"; + var_dump(mb_ereg($pattern, $string_mb, $regs)); + if ($regs) { + base64_encode_var_dump($regs); + } + $iterator++; } /** * replicate a var dump of an array but outputted string values are base64 encoded @@ -55,20 +55,20 @@ foreach ($character_classes as $pattern) { * @param array $regs */ function base64_encode_var_dump($regs) { - if ($regs) { - echo "array(" . count($regs) . ") {\n"; - foreach ($regs as $key => $value) { - echo " [$key]=>\n "; - if (is_string($value)) { - var_dump(base64_encode($value)); - } else { - var_dump($value); - } - } - echo "}\n"; - } else { - echo "NULL\n"; - } + if ($regs) { + echo "array(" . count($regs) . ") {\n"; + foreach ($regs as $key => $value) { + echo " [$key]=>\n "; + if (is_string($value)) { + var_dump(base64_encode($value)); + } else { + var_dump($value); + } + } + echo "}\n"; + } else { + echo "NULL\n"; + } } echo "Done"; diff --git a/ext/mbstring/tests/mb_ereg_variation5.phpt b/ext/mbstring/tests/mb_ereg_variation5.phpt index 24b12f25a776..5467f24d1f1f 100644 --- a/ext/mbstring/tests/mb_ereg_variation5.phpt +++ b/ext/mbstring/tests/mb_ereg_variation5.phpt @@ -45,20 +45,20 @@ echo "Done"; * @param array $regs */ function base64_encode_var_dump($regs) { - if ($regs) { - echo "array(" . count($regs) . ") {\n"; - foreach ($regs as $key => $value) { - echo " [$key]=>\n "; - if (is_string($value)) { - var_dump(base64_encode($value)); - } else { - var_dump($value); - } - } - echo "}\n"; - } else { - echo "NULL\n"; - } + if ($regs) { + echo "array(" . count($regs) . ") {\n"; + foreach ($regs as $key => $value) { + echo " [$key]=>\n "; + if (is_string($value)) { + var_dump(base64_encode($value)); + } else { + var_dump($value); + } + } + echo "}\n"; + } else { + echo "NULL\n"; + } } ?> --EXPECT-- diff --git a/ext/mbstring/tests/mb_ereg_variation6.phpt b/ext/mbstring/tests/mb_ereg_variation6.phpt index 97e5e58906d1..e9c506ac7725 100644 --- a/ext/mbstring/tests/mb_ereg_variation6.phpt +++ b/ext/mbstring/tests/mb_ereg_variation6.phpt @@ -19,9 +19,9 @@ function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build echo "*** Testing mb_ereg() : usage variations ***\n"; if(mb_regex_encoding('utf-8') == true) { - echo "Regex encoding set to utf-8\n"; + echo "Regex encoding set to utf-8\n"; } else { - echo "Could not set regex encoding to utf-8\n"; + echo "Could not set regex encoding to utf-8\n"; } $regex_char = array ('\w+' => '\w+', @@ -37,18 +37,18 @@ $string_ascii = 'This is an English string. 0123456789.'; $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); foreach ($regex_char as $displayChar => $char) { - echo "\n--** Pattern is: $displayChar **--\n"; - if (@$regs_ascii || @$regs_mb) { - $regs_ascii = null; - $regs_mb = null; - } - echo "-- ASCII String: --\n"; - var_dump(mb_ereg($char, $string_ascii, $regs_ascii)); - base64_encode_var_dump($regs_ascii); + echo "\n--** Pattern is: $displayChar **--\n"; + if (@$regs_ascii || @$regs_mb) { + $regs_ascii = null; + $regs_mb = null; + } + echo "-- ASCII String: --\n"; + var_dump(mb_ereg($char, $string_ascii, $regs_ascii)); + base64_encode_var_dump($regs_ascii); - echo "-- Multibyte String: --\n"; - var_dump(mb_ereg($char, $string_mb, $regs_mb)); - base64_encode_var_dump($regs_mb); + echo "-- Multibyte String: --\n"; + var_dump(mb_ereg($char, $string_mb, $regs_mb)); + base64_encode_var_dump($regs_mb); } @@ -58,20 +58,20 @@ foreach ($regex_char as $displayChar => $char) { * @param array $regs */ function base64_encode_var_dump($regs) { - if ($regs) { - echo "array(" . count($regs) . ") {\n"; - foreach ($regs as $key => $value) { - echo " [$key]=>\n "; - if (is_string($value)) { - var_dump(base64_encode($value)); - } else { - var_dump($value); - } - } - echo "}\n"; - } else { - echo "NULL\n"; - } + if ($regs) { + echo "array(" . count($regs) . ") {\n"; + foreach ($regs as $key => $value) { + echo " [$key]=>\n "; + if (is_string($value)) { + var_dump(base64_encode($value)); + } else { + var_dump($value); + } + } + echo "}\n"; + } else { + echo "NULL\n"; + } } echo "Done"; diff --git a/ext/mbstring/tests/mb_ereg_variation7.phpt b/ext/mbstring/tests/mb_ereg_variation7.phpt index e43d051d2acd..63b726ffd87c 100644 --- a/ext/mbstring/tests/mb_ereg_variation7.phpt +++ b/ext/mbstring/tests/mb_ereg_variation7.phpt @@ -22,9 +22,9 @@ function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build echo "*** Testing mb_ereg() : usage variations ***\n"; if(mb_regex_encoding('utf-8') == true) { - echo "Regex encoding set to utf-8\n"; + echo "Regex encoding set to utf-8\n"; } else { - echo "Could not set regex encoding to utf-8\n"; + echo "Could not set regex encoding to utf-8\n"; } $string_ascii = 'This is an English string. 0123456789.'; @@ -43,20 +43,20 @@ base64_encode_var_dump($regs_mb); * @param array $regs */ function base64_encode_var_dump($regs) { - if ($regs) { - echo "array(" . count($regs) . ") {\n"; - foreach ($regs as $key => $value) { - echo " [$key]=>\n "; - if (is_string($value)) { - var_dump(base64_encode($value)); - } else { - var_dump($value); - } - } - echo "}\n"; - } else { - echo "NULL\n"; - } + if ($regs) { + echo "array(" . count($regs) . ") {\n"; + foreach ($regs as $key => $value) { + echo " [$key]=>\n "; + if (is_string($value)) { + var_dump(base64_encode($value)); + } else { + var_dump($value); + } + } + echo "}\n"; + } else { + echo "NULL\n"; + } } echo "Done"; diff --git a/ext/mbstring/tests/mb_http_input.phpt b/ext/mbstring/tests/mb_http_input.phpt index ea78b397b10e..586a7d094d93 100644 --- a/ext/mbstring/tests/mb_http_input.phpt +++ b/ext/mbstring/tests/mb_http_input.phpt @@ -29,17 +29,17 @@ $enc = mb_http_input('P'); // check if (empty($ini)) { - // Must be pass - if ($enc === 'pass') { - echo "OK\n"; - } - else { - echo "NG\n"; - } + // Must be pass + if ($enc === 'pass') { + echo "OK\n"; + } + else { + echo "NG\n"; + } } else { - // Some encoding - echo "This heppens when php.ini-dist is not used\n"; + // Some encoding + echo "This heppens when php.ini-dist is not used\n"; } ?> diff --git a/ext/mbstring/tests/mb_internal_encoding_variation2.phpt b/ext/mbstring/tests/mb_internal_encoding_variation2.phpt index ba53c484014b..b191f792031f 100644 --- a/ext/mbstring/tests/mb_internal_encoding_variation2.phpt +++ b/ext/mbstring/tests/mb_internal_encoding_variation2.phpt @@ -80,11 +80,11 @@ $encoding = array('UCS-4', /*1*/ $iterator = 1; foreach($encoding as $enc) { - echo "\n-- Iteration $iterator --\n"; - var_dump(mb_internal_encoding()); - var_dump(mb_internal_encoding($enc)); - var_dump(mb_internal_encoding()); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(mb_internal_encoding()); + var_dump(mb_internal_encoding($enc)); + var_dump(mb_internal_encoding()); + $iterator++; } echo "Done"; ?> diff --git a/ext/mbstring/tests/mb_ord.phpt b/ext/mbstring/tests/mb_ord.phpt index e0c5610c0b39..30fddb846cca 100644 --- a/ext/mbstring/tests/mb_ord.phpt +++ b/ext/mbstring/tests/mb_ord.phpt @@ -12,12 +12,12 @@ var_dump( // Invalid var_dump( - mb_ord("\u{d800}", "typo"), - mb_ord("\u{d800}", "pass"), - mb_ord("\u{d800}", "jis"), - mb_ord("\u{d800}", "cp50222"), - mb_ord("\u{d800}", "utf-7"), - mb_ord("") + mb_ord("\u{d800}", "typo"), + mb_ord("\u{d800}", "pass"), + mb_ord("\u{d800}", "jis"), + mb_ord("\u{d800}", "cp50222"), + mb_ord("\u{d800}", "utf-7"), + mb_ord("") ); mb_internal_encoding("utf-7"); diff --git a/ext/mbstring/tests/mb_parse_str.phpt b/ext/mbstring/tests/mb_parse_str.phpt index ab504f918f15..d1bf0066d37c 100644 --- a/ext/mbstring/tests/mb_parse_str.phpt +++ b/ext/mbstring/tests/mb_parse_str.phpt @@ -7,20 +7,20 @@ arg_separator.input=& --FILE-- --EXPECTF-- diff --git a/ext/mbstring/tests/mb_parse_str02.phpt b/ext/mbstring/tests/mb_parse_str02.phpt index bad388ee9002..f6456ab6615b 100644 --- a/ext/mbstring/tests/mb_parse_str02.phpt +++ b/ext/mbstring/tests/mb_parse_str02.phpt @@ -7,22 +7,22 @@ arg_separator.input=&# --FILE-- --EXPECTF-- diff --git a/ext/mbstring/tests/mb_regex_encoding_variation2.phpt b/ext/mbstring/tests/mb_regex_encoding_variation2.phpt index 0ef9eb4384d4..614c309c23ca 100644 --- a/ext/mbstring/tests/mb_regex_encoding_variation2.phpt +++ b/ext/mbstring/tests/mb_regex_encoding_variation2.phpt @@ -79,11 +79,11 @@ $encoding = array('UCS-4', /*1*/ $iterator = 1; foreach($encoding as $enc) { - echo "\n-- Iteration $iterator --\n"; - var_dump(mb_regex_encoding()); - var_dump(mb_regex_encoding($enc)); - var_dump(mb_regex_encoding()); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(mb_regex_encoding()); + var_dump(mb_regex_encoding($enc)); + var_dump(mb_regex_encoding()); + $iterator++; } echo "Done"; ?> diff --git a/ext/mbstring/tests/mb_regex_set_options.phpt b/ext/mbstring/tests/mb_regex_set_options.phpt index 301df8f118f1..ae10ba211c54 100644 --- a/ext/mbstring/tests/mb_regex_set_options.phpt +++ b/ext/mbstring/tests/mb_regex_set_options.phpt @@ -7,11 +7,11 @@ function_exists('mb_regex_set_options') or die("skip\n"); ?> --FILE-- --EXPECT-- + + + + +-++++ diff --git a/ext/mbstring/tests/mb_send_mail01.phpt b/ext/mbstring/tests/mb_send_mail01.phpt index 8ed9ea9721d8..349fab852c2d 100644 --- a/ext/mbstring/tests/mb_send_mail01.phpt +++ b/ext/mbstring/tests/mb_send_mail01.phpt @@ -21,8 +21,8 @@ mb_send_mail($to, mb_language(), "test"); /* neutral (UTF-8) */ if (mb_language("neutral")) { - mb_internal_encoding("none"); - mb_send_mail($to, "test ".mb_language(), "test"); + mb_internal_encoding("none"); + mb_send_mail($to, "test ".mb_language(), "test"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_send_mail02.phpt b/ext/mbstring/tests/mb_send_mail02.phpt index 923f57148666..06b85c691f5b 100644 --- a/ext/mbstring/tests/mb_send_mail02.phpt +++ b/ext/mbstring/tests/mb_send_mail02.phpt @@ -21,8 +21,8 @@ mb_send_mail($to, mb_language(), "test"); /* Japanese (EUC-JP) */ if (mb_language("japanese")) { - mb_internal_encoding('EUC-JP'); - mb_send_mail($to, "¥Æ¥¹¥È ".mb_language(), "¥Æ¥¹¥È"); + mb_internal_encoding('EUC-JP'); + mb_send_mail($to, "¥Æ¥¹¥È ".mb_language(), "¥Æ¥¹¥È"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_send_mail03.phpt b/ext/mbstring/tests/mb_send_mail03.phpt index 1b16529450d0..3d5ffd565953 100644 --- a/ext/mbstring/tests/mb_send_mail03.phpt +++ b/ext/mbstring/tests/mb_send_mail03.phpt @@ -21,8 +21,8 @@ mb_send_mail($to, mb_language(), "test"); /* English (iso-8859-1) */ if (mb_language("english")) { - mb_internal_encoding("ISO-8859-1"); - mb_send_mail($to, "test ".mb_language(), "test"); + mb_internal_encoding("ISO-8859-1"); + mb_send_mail($to, "test ".mb_language(), "test"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_send_mail04.phpt b/ext/mbstring/tests/mb_send_mail04.phpt index fbff4cd6167a..2eccb87189aa 100644 --- a/ext/mbstring/tests/mb_send_mail04.phpt +++ b/ext/mbstring/tests/mb_send_mail04.phpt @@ -21,8 +21,8 @@ mb_send_mail($to, mb_language(), "test"); /* German (iso-8859-15) */ if (mb_language("german")) { - mb_internal_encoding("ISO-8859-15"); - mb_send_mail($to, "Pr"."\xfc"."fung ".mb_language(), "Pr"."\xfc"."fung"); + mb_internal_encoding("ISO-8859-15"); + mb_send_mail($to, "Pr"."\xfc"."fung ".mb_language(), "Pr"."\xfc"."fung"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_send_mail05.phpt b/ext/mbstring/tests/mb_send_mail05.phpt index aa68ab8c8206..53d97ef3d18b 100644 --- a/ext/mbstring/tests/mb_send_mail05.phpt +++ b/ext/mbstring/tests/mb_send_mail05.phpt @@ -24,8 +24,8 @@ mb_send_mail($to, mb_language(), "test"); /* Simplified Chinese (HK-GB-2312) */ if (mb_language("simplified chinese")) { - mb_internal_encoding('GB2312'); - mb_send_mail($to, "²âÑé ".mb_language(), "²âÑé"); + mb_internal_encoding('GB2312'); + mb_send_mail($to, "²âÑé ".mb_language(), "²âÑé"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_send_mail06.phpt b/ext/mbstring/tests/mb_send_mail06.phpt index df3f06513687..44a877aaee52 100644 --- a/ext/mbstring/tests/mb_send_mail06.phpt +++ b/ext/mbstring/tests/mb_send_mail06.phpt @@ -24,8 +24,8 @@ mb_send_mail($to, mb_language(), "test"); /* Traditional Chinese () */ if (mb_language("traditional chinese")) { - mb_internal_encoding('BIG5'); - mb_send_mail($to, "´úÅç ".mb_language(), "´úÅç"); + mb_internal_encoding('BIG5'); + mb_send_mail($to, "´úÅç ".mb_language(), "´úÅç"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_send_mail07.phpt b/ext/mbstring/tests/mb_send_mail07.phpt index f62eccb8b221..9640abc1e88a 100644 --- a/ext/mbstring/tests/mb_send_mail07.phpt +++ b/ext/mbstring/tests/mb_send_mail07.phpt @@ -24,8 +24,8 @@ mb_send_mail($to, mb_language(), "test"); /* Korean */ if (mb_language("korean")) { - mb_internal_encoding('EUC-KR'); - mb_send_mail($to, "Å×½ºÆ® ".mb_language(), "Å×½ºÆ®"); + mb_internal_encoding('EUC-KR'); + mb_send_mail($to, "Å×½ºÆ® ".mb_language(), "Å×½ºÆ®"); } ?> --EXPECTF-- diff --git a/ext/mbstring/tests/mb_split-compat-01.phpt b/ext/mbstring/tests/mb_split-compat-01.phpt index 8dbc82c130d5..38adc2a7dda5 100644 --- a/ext/mbstring/tests/mb_split-compat-01.phpt +++ b/ext/mbstring/tests/mb_split-compat-01.phpt @@ -8,10 +8,10 @@ function_exists('mb_split') or die("skip mb_split() is not available in this bui --FILE-- diff --git a/ext/mbstring/tests/mb_split.phpt b/ext/mbstring/tests/mb_split.phpt index 9e9cd4080baf..a2260ca0593b 100644 --- a/ext/mbstring/tests/mb_split.phpt +++ b/ext/mbstring/tests/mb_split.phpt @@ -7,30 +7,30 @@ function_exists('mb_split') or die("skip mb_split() is not available in this bui ?> --FILE-- --EXPECT-- bool(true) diff --git a/ext/mbstring/tests/mb_str_split_utf8_utf16.phpt b/ext/mbstring/tests/mb_str_split_utf8_utf16.phpt index d53dd088dec8..39bfb0175fb7 100644 --- a/ext/mbstring/tests/mb_str_split_utf8_utf16.phpt +++ b/ext/mbstring/tests/mb_str_split_utf8_utf16.phpt @@ -11,14 +11,14 @@ ini_set('include_path','.'); include_once('common.inc'); /* 123 string and 4-bytes length character 0xf09280a9 */ -$utf8 = pack("H*", "313233f09280a9"); +$utf8 = pack("H*", "313233f09280a9"); /* 123 string and 4-bytes length character 0xf09280a9 head without tail */ -$utf8_bad = pack("H*", "313233f092"); +$utf8_bad = pack("H*", "313233f092"); /* very first and very last utf-16 4-bytes characters */ -$utf16_first_be = pack("H*", "d800dc00"); -$utf16_first_le = pack("H*", "00d800dc"); +$utf16_first_be = pack("H*", "d800dc00"); +$utf16_first_le = pack("H*", "00d800dc"); $utf16_last_be = pack("H*", "dbffdfff"); $utf16_last_le = pack("H*", "ffdbffdf"); @@ -35,37 +35,37 @@ $utf16le_bad = $utf16_first_le . $utf16le_char_bad; /* print each chunk as HEX string */ echo "UTF-8:"; foreach(mb_str_split($utf8, 2) as $chunk){ - printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); + printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); } echo PHP_EOL; echo "BAD UTF-8:"; foreach(mb_str_split($utf8_bad, 2) as $chunk){ - printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); + printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); } echo PHP_EOL; echo "UTF-16BE:"; foreach(mb_str_split($utf16be, 1, "UTF-16BE") as $chunk){ - printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); + printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); } echo PHP_EOL; echo "UTF-16LE:"; foreach(mb_str_split($utf16le, 1, "UTF-16LE") as $chunk){ - printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); + printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); } echo PHP_EOL; echo "BAD UTF-16BE:"; foreach(mb_str_split($utf16be_bad, 1, "UTF-16BE") as $chunk){ - printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); + printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); } echo PHP_EOL; echo "BAD UTF-16LE:"; foreach(mb_str_split($utf16le_bad, 1, "UTF-16LE") as $chunk){ - printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); + printf(" l:%d v:%s", strlen($chunk), unpack("H*", $chunk)[1]); } echo PHP_EOL; diff --git a/ext/mbstring/tests/mb_stripos_variation5_Bug45923.phpt b/ext/mbstring/tests/mb_stripos_variation5_Bug45923.phpt index ba2875e7674a..b071fdbff355 100644 --- a/ext/mbstring/tests/mb_stripos_variation5_Bug45923.phpt +++ b/ext/mbstring/tests/mb_stripos_variation5_Bug45923.phpt @@ -34,16 +34,16 @@ $needle_mb = base64_decode('44CC'); * 60 is larger than *BYTE* count for $string_mb */ for ($i = -30; $i <= 60; $i += 10) { - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; - try { - var_dump(mb_stripos($string_ascii, $needle_ascii, $i)); + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + try { + var_dump(mb_stripos($string_ascii, $needle_ascii, $i)); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } - echo "--Multibyte String --\n"; - try { - var_dump(mb_stripos($string_mb, $needle_mb, $i, 'UTF-8')); + echo "--Multibyte String --\n"; + try { + var_dump(mb_stripos($string_mb, $needle_mb, $i, 'UTF-8')); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } diff --git a/ext/mbstring/tests/mb_strlen_variation3.phpt b/ext/mbstring/tests/mb_strlen_variation3.phpt index b5f36dedc1b2..5a67fdd63baa 100644 --- a/ext/mbstring/tests/mb_strlen_variation3.phpt +++ b/ext/mbstring/tests/mb_strlen_variation3.phpt @@ -84,22 +84,22 @@ $string_ascii = 'abc def'; $string_mb = base64_decode('44K/44OT44Ol44Os44O844OG44Kj44Oz44Kw44O744Oe44K344O844Oz44O744Kr44Oz44OR44OL44O8'); foreach($encoding as $enc) { - echo "\n-- Iteration $iterator: $enc --\n"; - - echo "-- ASCII String --\n"; - if(mb_strlen($string_ascii, $enc)) { - echo "Encoding $enc recognised\n"; - } else { - echo "Encoding $enc not recognised\n"; - } - - echo "-- Multibyte String --\n"; - if(mb_strlen($string_mb, $enc)){ - echo "Encoding $enc recognised\n"; - } else { - echo "Encoding $enc not recognised\n"; - } - $iterator++; + echo "\n-- Iteration $iterator: $enc --\n"; + + echo "-- ASCII String --\n"; + if(mb_strlen($string_ascii, $enc)) { + echo "Encoding $enc recognised\n"; + } else { + echo "Encoding $enc not recognised\n"; + } + + echo "-- Multibyte String --\n"; + if(mb_strlen($string_mb, $enc)){ + echo "Encoding $enc recognised\n"; + } else { + echo "Encoding $enc not recognised\n"; + } + $iterator++; } echo "Done"; diff --git a/ext/mbstring/tests/mb_strpos_variation5.phpt b/ext/mbstring/tests/mb_strpos_variation5.phpt index 7c2d4cd4a545..fe7542099a97 100644 --- a/ext/mbstring/tests/mb_strpos_variation5.phpt +++ b/ext/mbstring/tests/mb_strpos_variation5.phpt @@ -33,17 +33,17 @@ $needle_mb = base64_decode('44CC'); * 60 is larger than *BYTE* count for $string_mb */ for ($i = -30; $i <= 60; $i += 10) { - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; try { - var_dump(mb_strpos($string_ascii, $needle_ascii, $i)); + var_dump(mb_strpos($string_ascii, $needle_ascii, $i)); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } - - echo "--Multibyte String --\n"; + + echo "--Multibyte String --\n"; try { - var_dump(mb_strpos($string_mb, $needle_mb, $i, 'UTF-8')); + var_dump(mb_strpos($string_mb, $needle_mb, $i, 'UTF-8')); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } diff --git a/ext/mbstring/tests/mb_strripos_variation5_Bug45923.phpt b/ext/mbstring/tests/mb_strripos_variation5_Bug45923.phpt index 90235d606474..ad20bfe3d901 100644 --- a/ext/mbstring/tests/mb_strripos_variation5_Bug45923.phpt +++ b/ext/mbstring/tests/mb_strripos_variation5_Bug45923.phpt @@ -35,17 +35,17 @@ $needle_mb = base64_decode('44CC'); * 60 is larger than *BYTE* count for $string_mb */ for ($i = -10; $i <= 60; $i += 10) { - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; try { - var_dump(mb_strripos($string_ascii, $needle_ascii, $i)); + var_dump(mb_strripos($string_ascii, $needle_ascii, $i)); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } - echo "--Multibyte String --\n"; + echo "--Multibyte String --\n"; try { - var_dump(mb_strripos($string_mb, $needle_mb, $i, 'UTF-8')); + var_dump(mb_strripos($string_mb, $needle_mb, $i, 'UTF-8')); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } diff --git a/ext/mbstring/tests/mb_strstr.phpt b/ext/mbstring/tests/mb_strstr.phpt index 61b2fcb1c338..87448467a1ff 100644 --- a/ext/mbstring/tests/mb_strstr.phpt +++ b/ext/mbstring/tests/mb_strstr.phpt @@ -5,11 +5,11 @@ mb_strstr() --FILE-- 'abcdefghijklmnopqrstuvwxyz', 'Russian' => base64_decode('0LDQsdCy0LPQtNC10LbQtw==')); foreach ($uppers as $lang => $sourcestring) { - echo "\n-- $lang --\n"; - $a = mb_strtolower($sourcestring, 'utf-8'); - var_dump(base64_encode($a)); - if ($a == $lowers[$lang]) { - echo "Correctly Converted\n"; - } else { - echo "Incorrectly Converted\n"; - } + echo "\n-- $lang --\n"; + $a = mb_strtolower($sourcestring, 'utf-8'); + var_dump(base64_encode($a)); + if ($a == $lowers[$lang]) { + echo "Correctly Converted\n"; + } else { + echo "Incorrectly Converted\n"; + } } echo "Done"; diff --git a/ext/mbstring/tests/mb_strtoupper_basic.phpt b/ext/mbstring/tests/mb_strtoupper_basic.phpt index ddaea2040bab..1c0357dc3430 100644 --- a/ext/mbstring/tests/mb_strtoupper_basic.phpt +++ b/ext/mbstring/tests/mb_strtoupper_basic.phpt @@ -29,9 +29,9 @@ $ascii = mb_strtoupper($ascii_lower); var_dump(base64_encode($ascii)); if($ascii == $ascii_upper) { - echo "Correctly converted\n"; + echo "Correctly converted\n"; } else { - echo "Incorrectly converted\n"; + echo "Incorrectly converted\n"; } echo "\n-- Multibyte String --\n"; @@ -39,9 +39,9 @@ $mb = mb_strtoupper($greek_lower, 'UTF-8'); var_dump(base64_encode($mb)); if ($mb == $greek_upper) { - echo "Correctly converted\n"; + echo "Correctly converted\n"; } else { - echo "Incorrectly converted\n"; + echo "Incorrectly converted\n"; } echo "Done"; diff --git a/ext/mbstring/tests/mb_strtoupper_variation3.phpt b/ext/mbstring/tests/mb_strtoupper_variation3.phpt index 3a40cb9bf305..d1f0244ae176 100644 --- a/ext/mbstring/tests/mb_strtoupper_variation3.phpt +++ b/ext/mbstring/tests/mb_strtoupper_variation3.phpt @@ -28,18 +28,18 @@ echo "\n-- Mixed string (mulitbyte and ASCII characters) --\n"; $a = mb_strtoupper($string_mixed_lower, 'UTF-8'); var_dump(base64_encode($a)); if ($a == $string_mixed_upper) { - echo "Correctly Converted\n"; + echo "Correctly Converted\n"; } else { - echo "Incorrectly Converted\n"; + echo "Incorrectly Converted\n"; } echo "\n-- Multibyte Only String--\n"; $b = mb_strtoupper($string_all_mb, 'UTF-8'); var_dump(base64_encode($b)); if ($b == $string_all_mb) { // Japanese characters only - should not be any conversion - echo "Correctly Converted\n"; + echo "Correctly Converted\n"; } else { - echo "Incorrectly Converted\n"; + echo "Incorrectly Converted\n"; } echo "Done"; diff --git a/ext/mbstring/tests/mb_strtoupper_variation4.phpt b/ext/mbstring/tests/mb_strtoupper_variation4.phpt index 7b126e671b34..81a8bdd1da8c 100644 --- a/ext/mbstring/tests/mb_strtoupper_variation4.phpt +++ b/ext/mbstring/tests/mb_strtoupper_variation4.phpt @@ -27,14 +27,14 @@ $lowers = array('Basic Latin' => 'abcdefghijklmnopqrstuvwxyz', 'Russian' => base64_decode('0LDQsdCy0LPQtNC10LbQtw==')); foreach ($lowers as $lang => $sourcestring) { - echo "\n-- $lang --\n"; - $a = mb_strtoupper($sourcestring, 'UTF-8'); - var_dump(base64_encode($a)); - if ($a == $uppers[$lang]) { - echo "Correctly Converted\n"; - } else { - echo "Incorrectly Converted\n"; - } + echo "\n-- $lang --\n"; + $a = mb_strtoupper($sourcestring, 'UTF-8'); + var_dump(base64_encode($a)); + if ($a == $uppers[$lang]) { + echo "Correctly Converted\n"; + } else { + echo "Incorrectly Converted\n"; + } } echo "Done"; diff --git a/ext/mbstring/tests/mb_substitute_character_variation1.phpt b/ext/mbstring/tests/mb_substitute_character_variation1.phpt index 094b9b5818e2..53a21c87878f 100644 --- a/ext/mbstring/tests/mb_substitute_character_variation1.phpt +++ b/ext/mbstring/tests/mb_substitute_character_variation1.phpt @@ -17,10 +17,10 @@ echo "*** Testing mb_substitute_character() : usage variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -33,9 +33,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/mbstring/tests/mb_substr_count.phpt b/ext/mbstring/tests/mb_substr_count.phpt index 5be510937526..84571515de9b 100644 --- a/ext/mbstring/tests/mb_substr_count.phpt +++ b/ext/mbstring/tests/mb_substr_count.phpt @@ -6,30 +6,30 @@ mb_substr_count() output_handler= --FILE-- --EXPECT-- bool(false) diff --git a/ext/mbstring/tests/mb_substr_variation4.phpt b/ext/mbstring/tests/mb_substr_variation4.phpt index c31af9b9ef0d..aac0a20c0d8b 100644 --- a/ext/mbstring/tests/mb_substr_variation4.phpt +++ b/ext/mbstring/tests/mb_substr_variation4.phpt @@ -29,21 +29,21 @@ $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXv * 60 is larger than *BYTE* count for $string_mb */ for ($i = -60; $i <= 60; $i += 10) { - if (@$a || @$b) { - $a = null; - $b = null; - } - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; - $a = mb_substr($string_ascii, $i, 4); - var_dump(base64_encode($a)); - echo "--Multibyte String --\n"; - $b = mb_substr($string_mb, $i, 4, 'UTF-8'); - if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length - var_dump(base64_encode($b)); - } else { - echo "Difference in length of ASCII string and multibyte string\n"; - } + if (@$a || @$b) { + $a = null; + $b = null; + } + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + $a = mb_substr($string_ascii, $i, 4); + var_dump(base64_encode($a)); + echo "--Multibyte String --\n"; + $b = mb_substr($string_mb, $i, 4, 'UTF-8'); + if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length + var_dump(base64_encode($b)); + } else { + echo "Difference in length of ASCII string and multibyte string\n"; + } } diff --git a/ext/mbstring/tests/mb_substr_variation5.phpt b/ext/mbstring/tests/mb_substr_variation5.phpt index 94231a46243b..5ede67925160 100644 --- a/ext/mbstring/tests/mb_substr_variation5.phpt +++ b/ext/mbstring/tests/mb_substr_variation5.phpt @@ -30,21 +30,21 @@ $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXv * 60 is larger than *BYTE* count for $string_mb */ for ($i = -60; $i <= 60; $i += 10) { - if (@$a || @$b) { - $a = null; - $b = null; - } - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; - $a = mb_substr($string_ascii, 1, $i); - var_dump(base64_encode($a)); - echo "--Multibyte String --\n"; - $b = mb_substr($string_mb, 1, $i, 'UTF-8'); - if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length - var_dump(base64_encode($b)); - } else { - echo "Difference in length of ASCII string and multibyte string\n"; - } + if (@$a || @$b) { + $a = null; + $b = null; + } + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + $a = mb_substr($string_ascii, 1, $i); + var_dump(base64_encode($a)); + echo "--Multibyte String --\n"; + $b = mb_substr($string_mb, 1, $i, 'UTF-8'); + if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length + var_dump(base64_encode($b)); + } else { + echo "Difference in length of ASCII string and multibyte string\n"; + } } diff --git a/ext/mbstring/tests/mb_substr_variation6.phpt b/ext/mbstring/tests/mb_substr_variation6.phpt index 172ab962b061..8b186fa00a72 100644 --- a/ext/mbstring/tests/mb_substr_variation6.phpt +++ b/ext/mbstring/tests/mb_substr_variation6.phpt @@ -29,26 +29,26 @@ $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXv * 60 is larger than *BYTE* count for $string_mb */ for ($i = -60; $i <= 60; $i += 10) { - if (@$a || @$b) { - $a = null; - $b = null; - } - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; - $a = mb_substr($string_ascii, $i, 4); - if ($a !== false) { - var_dump(bin2hex($a)); - } - else { - var_dump($a); - } - echo "--Multibyte String --\n"; - $b = mb_substr($string_mb, $i, 4, 'UTF-8'); - if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length - var_dump(bin2hex($b)); - } else { - echo "Difference in length of ASCII string and multibyte string\n"; - } + if (@$a || @$b) { + $a = null; + $b = null; + } + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + $a = mb_substr($string_ascii, $i, 4); + if ($a !== false) { + var_dump(bin2hex($a)); + } + else { + var_dump($a); + } + echo "--Multibyte String --\n"; + $b = mb_substr($string_mb, $i, 4, 'UTF-8'); + if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length + var_dump(bin2hex($b)); + } else { + echo "Difference in length of ASCII string and multibyte string\n"; + } } diff --git a/ext/mbstring/tests/mb_substr_variation7.phpt b/ext/mbstring/tests/mb_substr_variation7.phpt index 909393177ee2..243d7065d51d 100644 --- a/ext/mbstring/tests/mb_substr_variation7.phpt +++ b/ext/mbstring/tests/mb_substr_variation7.phpt @@ -30,26 +30,26 @@ $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXv * 60 is larger than *BYTE* count for $string_mb */ for ($i = -60; $i <= 60; $i += 10) { - if (@$a || @$b) { - $a = null; - $b = null; - } - echo "\n**-- Offset is: $i --**\n"; - echo "-- ASCII String --\n"; - $a = mb_substr($string_ascii, 1, $i); - if ($a !== false) { - var_dump(bin2hex($a)); - } - else { - var_dump($a); - } - echo "--Multibyte String --\n"; - $b = mb_substr($string_mb, 1, $i, 'UTF-8'); - if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length - var_dump(bin2hex($b)); - } else { - echo "Difference in length of ASCII string and multibyte string\n"; - } + if (@$a || @$b) { + $a = null; + $b = null; + } + echo "\n**-- Offset is: $i --**\n"; + echo "-- ASCII String --\n"; + $a = mb_substr($string_ascii, 1, $i); + if ($a !== false) { + var_dump(bin2hex($a)); + } + else { + var_dump($a); + } + echo "--Multibyte String --\n"; + $b = mb_substr($string_mb, 1, $i, 'UTF-8'); + if (strlen($a) == mb_strlen($b, 'UTF-8')) { // should return same length + var_dump(bin2hex($b)); + } else { + echo "Difference in length of ASCII string and multibyte string\n"; + } } diff --git a/ext/mbstring/tests/zend_multibyte-01.phpt b/ext/mbstring/tests/zend_multibyte-01.phpt index aae944de3558..6f8aab373d5a 100644 --- a/ext/mbstring/tests/zend_multibyte-01.phpt +++ b/ext/mbstring/tests/zend_multibyte-01.phpt @@ -8,12 +8,12 @@ zend.script_encoding=Shift_JIS internal_encoding=Shift_JIS --FILE-- --EXPECT-- ƒhƒŒƒ~ƒtƒ@ƒ\ diff --git a/ext/mbstring/tests/zend_multibyte-11.phpt b/ext/mbstring/tests/zend_multibyte-11.phpt index c5e02eeae3da..a1a589433c52 100644 --- a/ext/mbstring/tests/zend_multibyte-11.phpt +++ b/ext/mbstring/tests/zend_multibyte-11.phpt @@ -7,8 +7,8 @@ zend.multibyte=1 --FILE-- --EXPECTF-- diff --git a/ext/mbstring/tests/zend_multibyte-15.phpt b/ext/mbstring/tests/zend_multibyte-15.phpt index b24ed25fb215..7f552041a6d0 100644 --- a/ext/mbstring/tests/zend_multibyte-15.phpt +++ b/ext/mbstring/tests/zend_multibyte-15.phpt @@ -7,10 +7,10 @@ zend.multibyte=1 --FILE-- --EXPECT-- diff --git a/ext/mbstring/tests/zend_multibyte-16.phpt b/ext/mbstring/tests/zend_multibyte-16.phpt index a9b0920184fd..0fa0a8e9b26f 100644 --- a/ext/mbstring/tests/zend_multibyte-16.phpt +++ b/ext/mbstring/tests/zend_multibyte-16.phpt @@ -7,7 +7,7 @@ zend.multibyte=1 --FILE-- diff --git a/ext/mysqli/tests/001.phpt b/ext/mysqli/tests/001.phpt index f7a72aea05b4..f8ddc8a38dcc 100644 --- a/ext/mysqli/tests/001.phpt +++ b/ext/mysqli/tests/001.phpt @@ -8,55 +8,55 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- %s(4) "1111" diff --git a/ext/mysqli/tests/002.phpt b/ext/mysqli/tests/002.phpt index 1c98577454b9..0960da7a98c1 100644 --- a/ext/mysqli/tests/002.phpt +++ b/ext/mysqli/tests/002.phpt @@ -7,44 +7,44 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- 40100 && mysqli_get_client_version() < 50000 && - mysqli_get_server_version($link) > 50000) - echo "error (4.1 library with 5.x server)"; - else - echo "error"; + $test = ""; + for ($i=0; $i < count($c); $i++) + $test .= ($c[$i] == $d[$i]) ? "1" : "0"; + if ($test == "11111111") + echo "ok\n"; + else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 && + mysqli_get_server_version($link) > 50000) + echo "error (4.1 library with 5.x server)"; + else + echo "error"; - mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"); - mysqli_close($link); - print "done!"; + mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECT-- string(6) "foobar" diff --git a/ext/mysqli/tests/017.phpt b/ext/mysqli/tests/017.phpt index 7196ad48c694..0a1903abf8f3 100644 --- a/ext/mysqli/tests/017.phpt +++ b/ext/mysqli/tests/017.phpt @@ -8,28 +8,28 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- array(3) { diff --git a/ext/mysqli/tests/018.phpt b/ext/mysqli/tests/018.phpt index 8b3c9609240d..87a974694909 100644 --- a/ext/mysqli/tests/018.phpt +++ b/ext/mysqli/tests/018.phpt @@ -7,26 +7,26 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- int(0) diff --git a/ext/mysqli/tests/019.phpt b/ext/mysqli/tests/019.phpt index 4688ff9f8a12..d35b162cd714 100644 --- a/ext/mysqli/tests/019.phpt +++ b/ext/mysqli/tests/019.phpt @@ -7,53 +7,53 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- 0); + var_dump(strlen($status) > 0); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/028.phpt b/ext/mysqli/tests/028.phpt index e8d383537405..9b71d4d3da7b 100644 --- a/ext/mysqli/tests/028.phpt +++ b/ext/mysqli/tests/028.phpt @@ -7,17 +7,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- string(%d) "%s" diff --git a/ext/mysqli/tests/029.phpt b/ext/mysqli/tests/029.phpt index cf59999eaf07..0ed2517227df 100644 --- a/ext/mysqli/tests/029.phpt +++ b/ext/mysqli/tests/029.phpt @@ -7,24 +7,24 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- --EXPECT-- int(0) diff --git a/ext/mysqli/tests/031.phpt b/ext/mysqli/tests/031.phpt index 8518b45a3eba..e230e7974cb8 100644 --- a/ext/mysqli/tests/031.phpt +++ b/ext/mysqli/tests/031.phpt @@ -7,22 +7,22 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- string(0) "" diff --git a/ext/mysqli/tests/032.phpt b/ext/mysqli/tests/032.phpt index 27d8fb3fa542..660950d6f1e9 100644 --- a/ext/mysqli/tests/032.phpt +++ b/ext/mysqli/tests/032.phpt @@ -7,24 +7,24 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- --EXPECTF-- string(%d) "%s via %s" diff --git a/ext/mysqli/tests/034.phpt b/ext/mysqli/tests/034.phpt index 1eae37e1a535..f6e19ce5515d 100644 --- a/ext/mysqli/tests/034.phpt +++ b/ext/mysqli/tests/034.phpt @@ -8,17 +8,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- int(10) diff --git a/ext/mysqli/tests/035.phpt b/ext/mysqli/tests/035.phpt index 8e755b98461e..0f2421f6299c 100644 --- a/ext/mysqli/tests/035.phpt +++ b/ext/mysqli/tests/035.phpt @@ -7,17 +7,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- int(1) diff --git a/ext/mysqli/tests/036.phpt b/ext/mysqli/tests/036.phpt index 919625c8cdd6..af6d81d64e1b 100644 --- a/ext/mysqli/tests/036.phpt +++ b/ext/mysqli/tests/036.phpt @@ -11,36 +11,36 @@ function test: mysqli_insert_id() ?> --FILE-- --CLEAN-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECT-- int(2) diff --git a/ext/mysqli/tests/040.phpt b/ext/mysqli/tests/040.phpt index a860f30d815c..782cbe57ade5 100644 --- a/ext/mysqli/tests/040.phpt +++ b/ext/mysqli/tests/040.phpt @@ -7,29 +7,29 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECT-- int(1) diff --git a/ext/mysqli/tests/045.phpt b/ext/mysqli/tests/045.phpt index 0b7b68239cdd..10773ace1b7a 100644 --- a/ext/mysqli/tests/045.phpt +++ b/ext/mysqli/tests/045.phpt @@ -20,23 +20,23 @@ mysqli_stmt_bind_result (SHOW) ?> --FILE-- --EXPECTF-- array(2) { diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt index 8e4b8c3b2c09..0a64386db257 100644 --- a/ext/mysqli/tests/046.phpt +++ b/ext/mysqli/tests/046.phpt @@ -7,32 +7,32 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- select_db($db); - $mysql->query("DROP TABLE IF EXISTS test_fetch_null"); + $mysql->select_db($db); + $mysql->query("DROP TABLE IF EXISTS test_fetch_null"); - $mysql->query("CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint, - col3 int, col4 bigint, - col5 float, col6 double, - col7 date, col8 time, - col9 varbinary(10), - col10 varchar(50), - col11 char(20)) ENGINE=" . $engine); + $mysql->query("CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint, + col3 int, col4 bigint, + col5 float, col6 double, + col7 date, col8 time, + col9 varbinary(10), + col10 varchar(50), + col11 char(20)) ENGINE=" . $engine); - $mysql->query("INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)"); + $mysql->query("INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)"); - $stmt = $mysql->prepare("SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null"); - $stmt->bind_result($c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11); - $stmt->execute(); + $stmt = $mysql->prepare("SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null"); + $stmt->bind_result($c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11); + $stmt->execute(); - $stmt->fetch(); + $stmt->fetch(); - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11); + $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11); - var_dump($test); + var_dump($test); - $stmt->close(); - $mysql->query("DROP TABLE IF EXISTS test_fetch_null"); - $mysql->close(); - print "done!"; + $stmt->close(); + $mysql->query("DROP TABLE IF EXISTS test_fetch_null"); + $mysql->close(); + print "done!"; ?> --CLEAN-- --FILE-- select_db($db); - $result = $mysql->query("SELECT DATABASE()"); - $row = $result->fetch_row(); - $result->close(); + $mysql->select_db($db); + $result = $mysql->query("SELECT DATABASE()"); + $row = $result->fetch_row(); + $result->close(); - var_dump($row); - if ($row[0] != $db) - printf("[001] Expecting '%s' got '%s'\n", $db, $row[0]); + var_dump($row); + if ($row[0] != $db) + printf("[001] Expecting '%s' got '%s'\n", $db, $row[0]); - $mysql->close(); - print "done!"; + $mysql->close(); + print "done!"; ?> --EXPECTF-- array(1) { diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt index 448f164be17a..c51c7bc1d23a 100644 --- a/ext/mysqli/tests/050.phpt +++ b/ext/mysqli/tests/050.phpt @@ -7,18 +7,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- Ok diff --git a/ext/mysqli/tests/051.phpt b/ext/mysqli/tests/051.phpt index 4a766fb34d34..239f8cbcf03b 100644 --- a/ext/mysqli/tests/051.phpt +++ b/ext/mysqli/tests/051.phpt @@ -7,19 +7,19 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- Ok diff --git a/ext/mysqli/tests/052.phpt b/ext/mysqli/tests/052.phpt index 1d131f1428a9..e079bc508b33 100644 --- a/ext/mysqli/tests/052.phpt +++ b/ext/mysqli/tests/052.phpt @@ -7,19 +7,19 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- Ok diff --git a/ext/mysqli/tests/053.phpt b/ext/mysqli/tests/053.phpt index a1840c972645..4aac61514ac3 100644 --- a/ext/mysqli/tests/053.phpt +++ b/ext/mysqli/tests/053.phpt @@ -7,16 +7,16 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- diff --git a/ext/mysqli/tests/054.phpt b/ext/mysqli/tests/054.phpt index 6bd45a7c4bc0..b06d5edc3a92 100644 --- a/ext/mysqli/tests/054.phpt +++ b/ext/mysqli/tests/054.phpt @@ -7,17 +7,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- Ok diff --git a/ext/mysqli/tests/055.phpt b/ext/mysqli/tests/055.phpt index c73266e74809..7b6339afafe9 100644 --- a/ext/mysqli/tests/055.phpt +++ b/ext/mysqli/tests/055.phpt @@ -7,16 +7,16 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECT-- Ok diff --git a/ext/mysqli/tests/056.phpt b/ext/mysqli/tests/056.phpt index 413e67898798..9bb3a0eba9ff 100644 --- a/ext/mysqli/tests/056.phpt +++ b/ext/mysqli/tests/056.phpt @@ -7,18 +7,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- connect($host, $user, $passwd, $db, $port, $socket); - $foo->close(); - printf("%s\n", $foo->test()); + $foo = new foobar(); + $foo->connect($host, $user, $passwd, $db, $port, $socket); + $foo->close(); + printf("%s\n", $foo->test()); ?> --EXPECT-- I do not like MySQL 4.1 diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt index a8977be02f8a..7c4f149c4870 100644 --- a/ext/mysqli/tests/057.phpt +++ b/ext/mysqli/tests/057.phpt @@ -7,59 +7,59 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- affected_rows !== 0) - printf("[001] Expecting 0, got %d\n", $stmt->affected_rows); + var_dump($stmt = mysqli_prepare($link, "SELECT * FROM test_store_result")); + if ($stmt->affected_rows !== 0) + printf("[001] Expecting 0, got %d\n", $stmt->affected_rows); - var_dump(mysqli_stmt_execute($stmt)); - var_dump($stmt = @mysqli_prepare($link, "SELECT * FROM test_store_result"), mysqli_error($link)); + var_dump(mysqli_stmt_execute($stmt)); + var_dump($stmt = @mysqli_prepare($link, "SELECT * FROM test_store_result"), mysqli_error($link)); - $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"); - mysqli_stmt_execute($stmt); - $result1 = mysqli_stmt_result_metadata($stmt); - mysqli_stmt_store_result($stmt); + $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"); + mysqli_stmt_execute($stmt); + $result1 = mysqli_stmt_result_metadata($stmt); + mysqli_stmt_store_result($stmt); - printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt)); + printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt)); - /* this should show an error, cause results are not buffered */ - if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) { - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - } + /* this should show an error, cause results are not buffered */ + if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) { + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + } - var_dump($row); + var_dump($row); - mysqli_free_result($result1); - mysqli_stmt_close($stmt); - mysqli_close($link); - echo "done!"; + mysqli_free_result($result1); + mysqli_stmt_close($stmt); + mysqli_close($link); + echo "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --CLEAN-- --FILE-- real_query("SELECT 'foo' FROM DUAL"); + $mysql->real_query("SELECT 'foo' FROM DUAL"); - $myresult = new mysqli_result($mysql); + $myresult = new mysqli_result($mysql); - $row = $myresult->fetch_row(); - $myresult->close(); - $mysql->close(); + $row = $myresult->fetch_row(); + $myresult->close(); + $mysql->close(); - var_dump($row); - print "done!"; + var_dump($row); + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/063.phpt b/ext/mysqli/tests/063.phpt index b1d531427883..26bfe48ee54b 100644 --- a/ext/mysqli/tests/063.phpt +++ b/ext/mysqli/tests/063.phpt @@ -7,18 +7,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- execute(); - $stmt->bind_result($foo); - $stmt->fetch(); - $stmt->close(); - $mysql->close(); + $stmt = new mysqli_stmt($mysql, "SELECT 'foo' FROM DUAL"); + $stmt->execute(); + $stmt->bind_result($foo); + $stmt->fetch(); + $stmt->close(); + $mysql->close(); - var_dump($foo); + var_dump($foo); ?> --EXPECT-- string(3) "foo" diff --git a/ext/mysqli/tests/064.phpt b/ext/mysqli/tests/064.phpt index 46af7a6628fb..b2280ff426b1 100644 --- a/ext/mysqli/tests/064.phpt +++ b/ext/mysqli/tests/064.phpt @@ -7,18 +7,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- execute(); - $stmt->bind_result($foo); - $stmt->fetch(); - $stmt->close(); - $mysql->close(); + $stmt = new mysqli_stmt($mysql, "SELECT NULL FROM DUAL"); + $stmt->execute(); + $stmt->bind_result($foo); + $stmt->fetch(); + $stmt->close(); + $mysql->close(); - var_dump($foo); + var_dump($foo); ?> --EXPECT-- NULL diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt index 75c4b02a2942..2733cdafb027 100644 --- a/ext/mysqli/tests/065.phpt +++ b/ext/mysqli/tests/065.phpt @@ -11,42 +11,42 @@ if (!function_exists('mysqli_set_charset')) { ?> --FILE-- set_charset("latin1")) { - /* 5C should be escaped */ - if (3 !== ($tmp = strlen($mysql->real_escape_string($esc_str)))) - printf("[003] Expecting 3/int got %s/%s\n", gettype($tmp), $tmp); + if ($mysql->set_charset("latin1")) { + /* 5C should be escaped */ + if (3 !== ($tmp = strlen($mysql->real_escape_string($esc_str)))) + printf("[003] Expecting 3/int got %s/%s\n", gettype($tmp), $tmp); - if ('latin1' !== ($tmp = $mysql->character_set_name())) - printf("[004] Expecting latin1/string got %s/%s\n", gettype($tmp), $tmp); - } + if ('latin1' !== ($tmp = $mysql->character_set_name())) + printf("[004] Expecting latin1/string got %s/%s\n", gettype($tmp), $tmp); + } - if ($res = $mysql->query("SHOW CHARACTER SET LIKE 'gbk'")) { - $res->free_result(); - if ($mysql->set_charset("gbk")) { - /* nothing should be escaped, it's a valid gbk character */ + if ($res = $mysql->query("SHOW CHARACTER SET LIKE 'gbk'")) { + $res->free_result(); + if ($mysql->set_charset("gbk")) { + /* nothing should be escaped, it's a valid gbk character */ - if (2 !== ($tmp = strlen($mysql->real_escape_string($esc_str)))) - printf("[005] Expecting 2/int got %s/%s\n", gettype($tmp), $tmp); + if (2 !== ($tmp = strlen($mysql->real_escape_string($esc_str)))) + printf("[005] Expecting 2/int got %s/%s\n", gettype($tmp), $tmp); - if ('gbk' !== ($tmp = $mysql->character_set_name())) - printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp); - } - } - $mysql->close(); + if ('gbk' !== ($tmp = $mysql->character_set_name())) + printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp); + } + } + $mysql->close(); - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/066.phpt b/ext/mysqli/tests/066.phpt index a337e038c17a..678457e93430 100644 --- a/ext/mysqli/tests/066.phpt +++ b/ext/mysqli/tests/066.phpt @@ -7,28 +7,28 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("DROP TABLE IF EXISTS test_warnings"); + $mysql->query("DROP TABLE IF EXISTS test_warnings"); - $mysql->query("CREATE TABLE test_warnings (a int not null) ENGINE=myisam"); + $mysql->query("CREATE TABLE test_warnings (a int not null) ENGINE=myisam"); - $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)"); + $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)"); - if (($warning = $mysql->get_warnings())) { - do { - printf("Warning\n"); - } while ($warning->next()); - } + if (($warning = $mysql->get_warnings())) { + do { + printf("Warning\n"); + } while ($warning->next()); + } - $mysql->close(); - print "done!"; + $mysql->close(); + print "done!"; ?> --CLEAN-- --FILE-- prepare($query))) { - printf("[001] Cannot create statement object for '%s', [%d] %s\n", - $query, $mysql->errno, $mysql->error); - } + function open_cursor($mysql, $query) { + if (!is_object($stmt = $mysql->prepare($query))) { + printf("[001] Cannot create statement object for '%s', [%d] %s\n", + $query, $mysql->errno, $mysql->error); + } - $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); - return $stmt; - } + $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); + return $stmt; + } - require_once("connect.inc"); - $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + require_once("connect.inc"); + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); - if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) || - (mysqli_get_server_version($mysql) < 50009)) { - /* we really want to skip it... */ - die(var_dump(63)); - } + if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) || + (mysqli_get_server_version($mysql) < 50009)) { + /* we really want to skip it... */ + die(var_dump(63)); + } - $a = array(); + $a = array(); - for ($i=0;$i < 3; $i++) { - $mysql->query("DROP TABLE IF EXISTS cursor$i"); - $mysql->query("CREATE TABLE cursor$i (a int not null) ENGINE=" . $engine); - $mysql->query("INSERT INTO cursor$i VALUES (1),(2),(3),(4),(5),(6)"); - $stmt[$i] = open_cursor($mysql, "SELECT a FROM cursor$i"); - $stmt[$i]->execute(); - $stmt[$i]->bind_result($a[$i]); - } + for ($i=0;$i < 3; $i++) { + $mysql->query("DROP TABLE IF EXISTS cursor$i"); + $mysql->query("CREATE TABLE cursor$i (a int not null) ENGINE=" . $engine); + $mysql->query("INSERT INTO cursor$i VALUES (1),(2),(3),(4),(5),(6)"); + $stmt[$i] = open_cursor($mysql, "SELECT a FROM cursor$i"); + $stmt[$i]->execute(); + $stmt[$i]->bind_result($a[$i]); + } - $cnt = 0; - while ($stmt[0]->fetch()) { - $stmt[1]->fetch(); - $stmt[2]->fetch(); - $cnt += $a[0] + $a[1] + $a[2]; - } + $cnt = 0; + while ($stmt[0]->fetch()) { + $stmt[1]->fetch(); + $stmt[2]->fetch(); + $cnt += $a[0] + $a[1] + $a[2]; + } - for ($i=0; $i < 3; $i++) { - $stmt[$i]->close(); - } + for ($i=0; $i < 3; $i++) { + $stmt[$i]->close(); + } - $mysql->close(); - var_dump($cnt); + $mysql->close(); + var_dump($cnt); ?> --CLEAN-- --FILE-- --EXPECT-- string diff --git a/ext/mysqli/tests/069.phpt b/ext/mysqli/tests/069.phpt index 29ed2fd94a8c..9f1d0b447e0b 100644 --- a/ext/mysqli/tests/069.phpt +++ b/ext/mysqli/tests/069.phpt @@ -7,24 +7,24 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- multi_query('SELECT 1;SELECT 2'); - do { - $res = $mysql->store_result(); - if ($mysql->errno == 0) { - while ($arr = $res->fetch_assoc()) { - var_dump($arr); - } - $res->free(); - } - if (!$mysql->more_results()) { - break; - } - } while (@$mysql->next_result()); - $mysql->close(); - print "done!"; + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql->multi_query('SELECT 1;SELECT 2'); + do { + $res = $mysql->store_result(); + if ($mysql->errno == 0) { + while ($arr = $res->fetch_assoc()) { + var_dump($arr); + } + $res->free(); + } + if (!$mysql->more_results()) { + break; + } + } while (@$mysql->next_result()); + $mysql->close(); + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/070.phpt b/ext/mysqli/tests/070.phpt index 6452d6ab781d..a9832815da76 100644 --- a/ext/mysqli/tests/070.phpt +++ b/ext/mysqli/tests/070.phpt @@ -7,12 +7,12 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- ping()); - $mysql->close(); - print "done!"; + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + var_dump($mysql->ping()); + $mysql->close(); + print "done!"; ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/071.phpt b/ext/mysqli/tests/071.phpt index 48b719c6296d..0a1e4ce62e97 100644 --- a/ext/mysqli/tests/071.phpt +++ b/ext/mysqli/tests/071.phpt @@ -8,63 +8,63 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- server_version; + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $version = $mysql->server_version; - var_dump($mysql->ping()); + var_dump($mysql->ping()); - $ret = $mysql->kill($mysql->thread_id); - if ($IS_MYSQLND) { - if ($ret !== true){ - printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); - } - } else { - /* libmysql return value seems to depend on server version */ - if ((($version >= 50123) || ($version <= 40200)) && $version != 50200) { - /* TODO: find exact version */ - if ($ret !== true){ - printf("[001] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } else { - if ($ret !== false){ - printf("[001] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } - } + $ret = $mysql->kill($mysql->thread_id); + if ($IS_MYSQLND) { + if ($ret !== true){ + printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); + } + } else { + /* libmysql return value seems to depend on server version */ + if ((($version >= 50123) || ($version <= 40200)) && $version != 50200) { + /* TODO: find exact version */ + if ($ret !== true){ + printf("[001] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version); + } + } else { + if ($ret !== false){ + printf("[001] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version); + } + } + } - var_dump($mysql->ping()); + var_dump($mysql->ping()); - $mysql->close(); + $mysql->close(); - $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); - var_dump(mysqli_ping($mysql)); + var_dump(mysqli_ping($mysql)); - $ret = $mysql->kill($mysql->thread_id); - if ($IS_MYSQLND) { - if ($ret !== true){ - printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); - } - } else { - /* libmysql return value seems to depend on server version */ - if ((($version >= 50123) || ($version <= 40200)) && $version != 50200) { - /* TODO: find exact version */ - if ($ret !== true){ - printf("[002] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } else { - if ($ret !== false){ - printf("[002] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version); - } - } - } + $ret = $mysql->kill($mysql->thread_id); + if ($IS_MYSQLND) { + if ($ret !== true){ + printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true)); + } + } else { + /* libmysql return value seems to depend on server version */ + if ((($version >= 50123) || ($version <= 40200)) && $version != 50200) { + /* TODO: find exact version */ + if ($ret !== true){ + printf("[002] Expecting boolean/true got %s/%s @\n", gettype($ret), var_export($ret, true), $version); + } + } else { + if ($ret !== false){ + printf("[002] Expecting boolean/false got %s/%s @\n", gettype($ret), var_export($ret, true), $version); + } + } + } - var_dump(mysqli_ping($mysql)); + var_dump(mysqli_ping($mysql)); - $mysql->close(); - print "done!"; + $mysql->close(); + print "done!"; ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/072.phpt b/ext/mysqli/tests/072.phpt index 997469d39c68..cb4ff60a8628 100644 --- a/ext/mysqli/tests/072.phpt +++ b/ext/mysqli/tests/072.phpt @@ -7,22 +7,22 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("DROP TABLE IF EXISTS not_exists"); + $mysql->query("DROP TABLE IF EXISTS not_exists"); - var_dump($mysql->warning_count); + var_dump($mysql->warning_count); - $w = $mysql->get_warnings(); + $w = $mysql->get_warnings(); - var_dump($w->errno); - var_dump($w->message); - var_dump($w->sqlstate); + var_dump($w->errno); + var_dump($w->message); + var_dump($w->sqlstate); - $mysql->close(); - echo "done!" + $mysql->close(); + echo "done!" ?> --EXPECTF-- int(1) diff --git a/ext/mysqli/tests/073.phpt b/ext/mysqli/tests/073.phpt index 86e54ffc93cb..09156532d8b2 100644 --- a/ext/mysqli/tests/073.phpt +++ b/ext/mysqli/tests/073.phpt @@ -4,15 +4,15 @@ mysqli_driver properties --FILE-- embedded); - var_dump($driver->client_version); - var_dump($driver->client_info); - var_dump($driver->driver_version); - var_dump($driver->reconnect); - var_dump($driver->report_mode); - print "done!"; + var_dump($driver->embedded); + var_dump($driver->client_version); + var_dump($driver->client_info); + var_dump($driver->driver_version); + var_dump($driver->reconnect); + var_dump($driver->report_mode); + print "done!"; ?> --EXPECTF-- bool(%s) diff --git a/ext/mysqli/tests/074.phpt b/ext/mysqli/tests/074.phpt index a10f11136beb..3f1271130ff6 100644 --- a/ext/mysqli/tests/074.phpt +++ b/ext/mysqli/tests/074.phpt @@ -8,17 +8,17 @@ require_once('skipifconnectfailure.inc'); --FILE-- autocommit(false)); - $result = $mysqli->query("SELECT @@autocommit"); - var_dump($result->fetch_row()); + var_dump($mysqli->autocommit(false)); + $result = $mysqli->query("SELECT @@autocommit"); + var_dump($result->fetch_row()); - var_dump($mysqli->autocommit(true)); - $result = $mysqli->query("SELECT @@autocommit"); - var_dump($result->fetch_row()); + var_dump($mysqli->autocommit(true)); + $result = $mysqli->query("SELECT @@autocommit"); + var_dump($result->fetch_row()); ?> --EXPECT-- diff --git a/ext/mysqli/tests/bug28817.phpt b/ext/mysqli/tests/bug28817.phpt index 011d35e011ba..41c201c58920 100644 --- a/ext/mysqli/tests/bug28817.phpt +++ b/ext/mysqli/tests/bug28817.phpt @@ -7,33 +7,33 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- p_test[] = "foo"; - $this->p_test[] = "bar"; - } - } + function __construct() { + $this->p_test[] = "foo"; + $this->p_test[] = "bar"; + } + } - $mysql = new my_mysql(); + $mysql = new my_mysql(); - var_dump($mysql->p_test); - try { - $mysql->errno; - } catch (Error $exception) { + var_dump($mysql->p_test); + try { + $mysql->errno; + } catch (Error $exception) { echo $exception->getMessage() . "\n"; - } + } - $mysql->connect($host, $user, $passwd, $db, $port, $socket); - $mysql->select_db("nonexistingdb"); + $mysql->connect($host, $user, $passwd, $db, $port, $socket); + $mysql->select_db("nonexistingdb"); - var_dump($mysql->errno > 0); + var_dump($mysql->errno > 0); - $mysql->close(); + $mysql->close(); ?> --EXPECTF-- array(2) { diff --git a/ext/mysqli/tests/bug29311.phpt b/ext/mysqli/tests/bug29311.phpt index cfd5235e2b87..a5808418bfdb 100644 --- a/ext/mysqli/tests/bug29311.phpt +++ b/ext/mysqli/tests/bug29311.phpt @@ -7,45 +7,45 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- connect($host, $user, $passwd, $db, $port, $socket); - } - } - - /* class 3 has no constructor */ - class mysql3 extends mysqli { - - } - - $foo[0] = new mysql1(); - $foo[1] = new mysql2(); - $foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket); - - - for ($i=0; $i < 3; $i++) { - if (($result = $foo[$i]->query("SELECT DATABASE()"))) { - $row = $result->fetch_row(); - if ($row[0] != $db) - printf("%d: %s\n", $i, $row[0]); - $result->close(); - } - $foo[$i]->close(); - } - print "done!"; + require_once("connect.inc"); + + /* class 1 calls parent constructor */ + class mysql1 extends mysqli { + function __construct() { + global $host, $user, $passwd, $db, $port, $socket; + parent::__construct($host, $user, $passwd, $db, $port, $socket); + } + } + + /* class 2 has an own constructor */ + class mysql2 extends mysqli { + + function __construct() { + global $host, $user, $passwd, $db, $port, $socket; + $this->connect($host, $user, $passwd, $db, $port, $socket); + } + } + + /* class 3 has no constructor */ + class mysql3 extends mysqli { + + } + + $foo[0] = new mysql1(); + $foo[1] = new mysql2(); + $foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket); + + + for ($i=0; $i < 3; $i++) { + if (($result = $foo[$i]->query("SELECT DATABASE()"))) { + $row = $result->fetch_row(); + if ($row[0] != $db) + printf("%d: %s\n", $i, $row[0]); + $result->close(); + } + $foo[$i]->close(); + } + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/bug30967.phpt b/ext/mysqli/tests/bug30967.phpt index 9af81ea12a6c..9e68a0caec9e 100644 --- a/ext/mysqli/tests/bug30967.phpt +++ b/ext/mysqli/tests/bug30967.phpt @@ -7,20 +7,20 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("THIS DOES NOT WORK"); - printf("%d\n", $mysql->errno); + $mysql->query("THIS DOES NOT WORK"); + printf("%d\n", $mysql->errno); - $mysql->close(); + $mysql->close(); ?> --EXPECT-- 1064 diff --git a/ext/mysqli/tests/bug31141.phpt b/ext/mysqli/tests/bug31141.phpt index 71834742a9da..9894896dd51e 100644 --- a/ext/mysqli/tests/bug31141.phpt +++ b/ext/mysqli/tests/bug31141.phpt @@ -6,13 +6,13 @@ Bug #31141 (properties declared in the class extending MySQLi are not available) test = &$ar_test; - } + function foo() + { + $ar_test = array("foo", "bar"); + $this->test = &$ar_test; + } } $my_test = new Test; diff --git a/ext/mysqli/tests/bug31668.phpt b/ext/mysqli/tests/bug31668.phpt index 40bf357b6aa6..1dad169cc8c2 100644 --- a/ext/mysqli/tests/bug31668.phpt +++ b/ext/mysqli/tests/bug31668.phpt @@ -7,34 +7,34 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- multi_query('SELECT 1;SELECT 2'); - do { - $res = $mysql->store_result(); - if ($mysql->errno == 0) { - while ($arr = $res->fetch_assoc()) { - var_dump($arr); - } - $res->free(); - } - } while ($mysql->next_result()); - var_dump($mysql->error, __LINE__); - $mysql->close(); + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql->multi_query('SELECT 1;SELECT 2'); + do { + $res = $mysql->store_result(); + if ($mysql->errno == 0) { + while ($arr = $res->fetch_assoc()) { + var_dump($arr); + } + $res->free(); + } + } while ($mysql->next_result()); + var_dump($mysql->error, __LINE__); + $mysql->close(); - $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); - $mysql->multi_query('SELECT 1;SELECT 2'); - do { - $res = $mysql->store_result(); - if ($mysql->errno == 0) { - while ($arr = $res->fetch_assoc()) { - var_dump($arr); - } - $res->free(); - } - } while ($mysql->next_result()); - var_dump($mysql->error, __LINE__); + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql->multi_query('SELECT 1;SELECT 2'); + do { + $res = $mysql->store_result(); + if ($mysql->errno == 0) { + while ($arr = $res->fetch_assoc()) { + var_dump($arr); + } + $res->free(); + } + } while ($mysql->next_result()); + var_dump($mysql->error, __LINE__); ?> --EXPECTF-- array(1) { diff --git a/ext/mysqli/tests/bug32405.phpt b/ext/mysqli/tests/bug32405.phpt index 0b3cad50ffd5..974ad87b78da 100644 --- a/ext/mysqli/tests/bug32405.phpt +++ b/ext/mysqli/tests/bug32405.phpt @@ -7,29 +7,29 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))"); - $link->query('INSERT INTO test_users VALUES (NULL, "user1"), (NULL, "user2"), (NULL, "user3"), (NULL, "user4")'); + /* two fields are needed. the problem does not occur with 1 field only selected. */ + $link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))"); + $link->query('INSERT INTO test_users VALUES (NULL, "user1"), (NULL, "user2"), (NULL, "user3"), (NULL, "user4")'); - if ($stmt = $link->prepare("SELECT SQL_NO_CACHE user_id, login FROM test_users")) { - $stmt->execute(); - $stmt->bind_result($col1, $col2); - while ($stmt->fetch()) { - var_dump($col1, $col2); - } - $stmt->close(); - } + if ($stmt = $link->prepare("SELECT SQL_NO_CACHE user_id, login FROM test_users")) { + $stmt->execute(); + $stmt->bind_result($col1, $col2); + while ($stmt->fetch()) { + var_dump($col1, $col2); + } + $stmt->close(); + } - mysqli_query($link,"DROP TABLE test_users"); - mysqli_close($link); + mysqli_query($link,"DROP TABLE test_users"); + mysqli_close($link); ?> --CLEAN-- --FILE-- prepare("this makes no sense"))) { - printf("%d\n", $link->errno); - printf("%s\n", $link->sqlstate); - } - $link->close(); + if (!($link->prepare("this makes no sense"))) { + printf("%d\n", $link->errno); + printf("%s\n", $link->sqlstate); + } + $link->close(); ?> --EXPECT-- 1064 diff --git a/ext/mysqli/tests/bug33263.phpt b/ext/mysqli/tests/bug33263.phpt index e9ca36fe49a1..5df4065d2505 100644 --- a/ext/mysqli/tests/bug33263.phpt +++ b/ext/mysqli/tests/bug33263.phpt @@ -8,30 +8,30 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- prepare("SELECT DATABASE()"); - $stmt->execute(); - $stmt->bind_result($database); - $stmt->fetch(); - $stmt->close(); + $stmt = $mysql->prepare("SELECT DATABASE()"); + $stmt->execute(); + $stmt->bind_result($database); + $stmt->fetch(); + $stmt->close(); - if ($database != $db) - printf("[001] Expecting '%s' got %s/'%s'.\n", - gettype($database), $database); + if ($database != $db) + printf("[001] Expecting '%s' got %s/'%s'.\n", + gettype($database), $database); - $mysql->close(); - print "done!"; + $mysql->close(); + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/bug34785.phpt b/ext/mysqli/tests/bug34785.phpt index 18dd4c3566bb..17a18f4ca92b 100644 --- a/ext/mysqli/tests/bug34785.phpt +++ b/ext/mysqli/tests/bug34785.phpt @@ -7,43 +7,43 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- execute(); - $stmt->bind_result($var); - $stmt->fetch(); + $stmt->execute(); + $stmt->bind_result($var); + $stmt->fetch(); - $stmt->close(); - var_dump($var); + $stmt->close(); + var_dump($var); - mysqli_real_query($link, "SELECT 'bar' FROM DUAL"); - $result = new my_result($link, MYSQLI_STORE_RESULT); - $row = $result->fetch_row(); - $result->close(); + mysqli_real_query($link, "SELECT 'bar' FROM DUAL"); + $result = new my_result($link, MYSQLI_STORE_RESULT); + $row = $result->fetch_row(); + $result->close(); - var_dump($row[0]); + var_dump($row[0]); - mysqli_close($link); + mysqli_close($link); ?> --EXPECTF-- %s(3) "foo" diff --git a/ext/mysqli/tests/bug34810.phpt b/ext/mysqli/tests/bug34810.phpt index b56d1a5ac7cf..60ed3f8d1ad8 100644 --- a/ext/mysqli/tests/bug34810.phpt +++ b/ext/mysqli/tests/bug34810.phpt @@ -9,37 +9,37 @@ require_once('skipifconnectfailure.inc'); query("DROP TABLE IF EXISTS test_warnings"); - $mysql->query("CREATE TABLE test_warnings (a int not null)"); - $mysql->query("SET sql_mode=''"); - $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)"); + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql->query("DROP TABLE IF EXISTS test_warnings"); + $mysql->query("CREATE TABLE test_warnings (a int not null)"); + $mysql->query("SET sql_mode=''"); + $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)"); - $warning = $mysql->get_warnings(); - if (!$warning) - printf("[001] No warning!\n"); + $warning = $mysql->get_warnings(); + if (!$warning) + printf("[001] No warning!\n"); - if ($warning->errno == 1048 || $warning->errno == 1253) { - /* 1048 - Column 'a' cannot be null, 1263 - Data truncated; NULL supplied to NOT NULL column 'a' at row */ - if ("HY000" != $warning->sqlstate) - printf("[003] Wrong sql state code: %s\n", $warning->sqlstate); + if ($warning->errno == 1048 || $warning->errno == 1253) { + /* 1048 - Column 'a' cannot be null, 1263 - Data truncated; NULL supplied to NOT NULL column 'a' at row */ + if ("HY000" != $warning->sqlstate) + printf("[003] Wrong sql state code: %s\n", $warning->sqlstate); - if ("" == $warning->message) - printf("[004] Message string must not be empty\n"); - } else { - printf("[002] Empty error message!\n"); - var_dump($warning); - } - } + if ("" == $warning->message) + printf("[004] Message string must not be empty\n"); + } else { + printf("[002] Empty error message!\n"); + var_dump($warning); + } + } } $db = new DbConnection(); diff --git a/ext/mysqli/tests/bug35103.phpt b/ext/mysqli/tests/bug35103.phpt index fc3cad04c26d..7a990eacbf64 100644 --- a/ext/mysqli/tests/bug35103.phpt +++ b/ext/mysqli/tests/bug35103.phpt @@ -12,44 +12,44 @@ $drop = <<query("DROP TABLE IF EXISTS test_bint"); - $mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM"); - $mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)"); + $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql->query("DROP TABLE IF EXISTS test_bint"); + $mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM"); + $mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)"); - $mysql->query("DROP TABLE IF EXISTS test_buint"); - $mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)"); - $mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)"); + $mysql->query("DROP TABLE IF EXISTS test_buint"); + $mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)"); + $mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)"); - $stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a"); - $stmt->bind_result($v); - $stmt->execute(); - $i=0; - echo "BIG INT SIGNED, TEST\n"; - while ($i++ < 8) { - $stmt->fetch(); - echo $v, "\n"; - } - $stmt->close(); + $stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a"); + $stmt->bind_result($v); + $stmt->execute(); + $i=0; + echo "BIG INT SIGNED, TEST\n"; + while ($i++ < 8) { + $stmt->fetch(); + echo $v, "\n"; + } + $stmt->close(); - echo str_repeat("-", 20), "\n"; + echo str_repeat("-", 20), "\n"; - $stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a"); - $stmt->bind_result($v2); - $stmt->execute(); - $j=0; - echo "BIG INT UNSIGNED TEST\n"; - while ($j++ < 6) { - $stmt->fetch(); - echo $v2, "\n"; - } - $stmt->close(); + $stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a"); + $stmt->bind_result($v2); + $stmt->execute(); + $j=0; + echo "BIG INT UNSIGNED TEST\n"; + while ($j++ < 6) { + $stmt->fetch(); + echo $v2, "\n"; + } + $stmt->close(); - $mysql->multi_query($drop); + $mysql->multi_query($drop); - $mysql->close(); + $mysql->close(); ?> --CLEAN-- --FILE-- query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)"); - $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)"); - $stmt = $mysql->prepare("SELECT id FROM temp"); - $stmt->execute(); - $stmt->bind_result($id); - while ($stmt->fetch()) { - if (PHP_INT_SIZE == 8) { - if ((gettype($id) !== 'int') && (gettype($id) != 'integer')) - printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true)); - } else { - if (gettype($id) !== 'string') { - printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true)); - } - } - print $id; - print "\n"; - } - $stmt->close(); + $mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)"); + $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)"); + $stmt = $mysql->prepare("SELECT id FROM temp"); + $stmt->execute(); + $stmt->bind_result($id); + while ($stmt->fetch()) { + if (PHP_INT_SIZE == 8) { + if ((gettype($id) !== 'int') && (gettype($id) != 'integer')) + printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true)); + } else { + if (gettype($id) !== 'string') { + printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true)); + } + } + print $id; + print "\n"; + } + $stmt->close(); - $mysql->query("DROP TABLE temp"); - $mysql->close(); - print "done!"; + $mysql->query("DROP TABLE temp"); + $mysql->close(); + print "done!"; ?> --CLEAN-- query("DROP TABLE IF EXISTS test"); - $create = "CREATE TABLE test (a0 MEDIUMBLOB NOT NULL DEFAULT ''"; - $i= 0; - while (++$i < $col_num) { - $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''"; - } - $create .= ") ENGINE=MyISAM"; // doesn't work with InnoDB, which is default in 5.5 - - if (!$mysql->query($create)) { - if (1101 == $mysql->errno) { - /* SQL strict mode - [1101] BLOB/TEXT column 'a0' can't have a default value */ - print "done!"; - exit(0); - } - printf("[001] [%d] %s\n", $mysql->errno, $mysql->error); - } - - if (!$mysql->query("INSERT INTO test (a0) VALUES ('')")) - printf("[002] [%d] %s\n", $mysql->errno, $mysql->error); - - $stmt = $mysql->prepare("SELECT * FROM test"); - if ($stmt) { - - $stmt->execute(); - $stmt->store_result(); - for ($i = 0; $i < $col_num; $i++) { - $params[] = &$col_num; - } - call_user_func_array(array($stmt, "bind_result"), $params); - $stmt->fetch(); - - $stmt->close(); - } else { - printf("[003] [%d] %s\n", $mysql->errno, $mysql->error); - } - - $mysql->close(); - - echo "done!"; + require_once("connect.inc"); + $col_num= 1000; + + $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket); + $mysql->query("DROP TABLE IF EXISTS test"); + $create = "CREATE TABLE test (a0 MEDIUMBLOB NOT NULL DEFAULT ''"; + $i= 0; + while (++$i < $col_num) { + $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''"; + } + $create .= ") ENGINE=MyISAM"; // doesn't work with InnoDB, which is default in 5.5 + + if (!$mysql->query($create)) { + if (1101 == $mysql->errno) { + /* SQL strict mode - [1101] BLOB/TEXT column 'a0' can't have a default value */ + print "done!"; + exit(0); + } + printf("[001] [%d] %s\n", $mysql->errno, $mysql->error); + } + + if (!$mysql->query("INSERT INTO test (a0) VALUES ('')")) + printf("[002] [%d] %s\n", $mysql->errno, $mysql->error); + + $stmt = $mysql->prepare("SELECT * FROM test"); + if ($stmt) { + + $stmt->execute(); + $stmt->store_result(); + for ($i = 0; $i < $col_num; $i++) { + $params[] = &$col_num; + } + call_user_func_array(array($stmt, "bind_result"), $params); + $stmt->fetch(); + + $stmt->close(); + } else { + printf("[003] [%d] %s\n", $mysql->errno, $mysql->error); + } + + $mysql->close(); + + echo "done!"; ?> --CLEAN-- diff --git a/ext/mysqli/tests/bug36745.phpt b/ext/mysqli/tests/bug36745.phpt index 7a630afdc55d..744985ab418b 100644 --- a/ext/mysqli/tests/bug36745.phpt +++ b/ext/mysqli/tests/bug36745.phpt @@ -9,19 +9,19 @@ require_once('skipifconnectfailure.inc'); mysqli.allow_local_infile=1 --FILE-- query("DROP TABLE IF EXISTS litest"); - $mysql->query("CREATE TABLE litest (a VARCHAR(20))"); + $mysql->query("DROP TABLE IF EXISTS litest"); + $mysql->query("CREATE TABLE litest (a VARCHAR(20))"); - $mysql->query("LOAD DATA LOCAL INFILE 'filenotfound' INTO TABLE litest"); - var_dump($mysql->error); + $mysql->query("LOAD DATA LOCAL INFILE 'filenotfound' INTO TABLE litest"); + var_dump($mysql->error); - $mysql->close(); - printf("Done"); + $mysql->close(); + printf("Done"); ?> --CLEAN-- --FILE-- set_charset('utf8'); + /* following operations should not work */ + if (method_exists($mysql, 'set_charset')) { + try { + $mysql->set_charset('utf8'); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - } else { - $x[0] = false; - } + } else { + $x[0] = false; + } - try { + try { $mysql->query("SELECT 'foo' FROM DUAL"); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - /* following operations should work */ - $x[1] = ($mysql->client_version > 0); - $x[2] = $mysql->errno; + /* following operations should work */ + $x[1] = ($mysql->client_version > 0); + $x[2] = $mysql->errno; - $mysql->close(); + $mysql->close(); - var_dump($x); + var_dump($x); ?> --EXPECT-- mysqli object is not fully initialized diff --git a/ext/mysqli/tests/bug36949.phpt b/ext/mysqli/tests/bug36949.phpt index 2b3cc4955b02..5805a6510004 100644 --- a/ext/mysqli/tests/bug36949.phpt +++ b/ext/mysqli/tests/bug36949.phpt @@ -10,38 +10,38 @@ require_once('skipifconnectfailure.inc'); require_once("connect.inc"); class A { - private $mysqli; - - public function __construct() { - global $user, $host, $passwd, $db, $port, $socket; - $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); - $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL"); - $row = $result->fetch_object(); - echo $row->my_time."
\n"; - $result->close(); - } - - public function __destruct() { - $this->mysqli->close(); - } + private $mysqli; + + public function __construct() { + global $user, $host, $passwd, $db, $port, $socket; + $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); + $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL"); + $row = $result->fetch_object(); + echo $row->my_time."
\n"; + $result->close(); + } + + public function __destruct() { + $this->mysqli->close(); + } } class B { - private $mysqli; + private $mysqli; - public function __construct() { - global $user, $host, $passwd, $db, $port, $socket; - $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); - $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL"); - $row = $result->fetch_object(); - echo $row->my_time."
\n"; - $result->close(); - } + public function __construct() { + global $user, $host, $passwd, $db, $port, $socket; + $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); + $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL"); + $row = $result->fetch_object(); + echo $row->my_time."
\n"; + $result->close(); + } - public function __destruct() { - $this->mysqli->close(); - } + public function __destruct() { + $this->mysqli->close(); + } } $A = new A(); diff --git a/ext/mysqli/tests/bug37090.phpt b/ext/mysqli/tests/bug37090.phpt index d24e0d4a7ffc..13d939608d52 100644 --- a/ext/mysqli/tests/bug37090.phpt +++ b/ext/mysqli/tests/bug37090.phpt @@ -10,22 +10,22 @@ if (!function_exists('mysqli_set_charset')) { ?> --FILE-- set_charset("latin1"); - $cs[] = $mysql->character_set_name(); + $cs = array(); + $cs[] = $mysql->set_charset("latin1"); + $cs[] = $mysql->character_set_name(); - $cs[] = $mysql->set_charset("utf8"); - $cs[] = $mysql->character_set_name(); + $cs[] = $mysql->set_charset("utf8"); + $cs[] = $mysql->character_set_name(); - $cs[] = $mysql->set_charset("notdefined"); - $cs[] = $mysql->character_set_name(); + $cs[] = $mysql->set_charset("notdefined"); + $cs[] = $mysql->character_set_name(); - var_dump($cs); - print "done!"; + var_dump($cs); + print "done!"; ?> --EXPECT-- array(6) { diff --git a/ext/mysqli/tests/bug38710.phpt b/ext/mysqli/tests/bug38710.phpt index 7a47003632bf..dc6496971a37 100644 --- a/ext/mysqli/tests/bug38710.phpt +++ b/ext/mysqli/tests/bug38710.phpt @@ -16,7 +16,7 @@ $qry->execute(); $qry->bind_result($text); $qry->fetch(); if ($text !== str_repeat('a', ($IS_MYSQLND || mysqli_get_server_version($db) > 50110)? 100000:(mysqli_get_server_version($db)>=50000? 8193:8191))) { - var_dump(strlen($text)); + var_dump(strlen($text)); } echo "Done"; ?> diff --git a/ext/mysqli/tests/bug39457.phpt b/ext/mysqli/tests/bug39457.phpt index ec9239bb15af..f518b143310b 100644 --- a/ext/mysqli/tests/bug39457.phpt +++ b/ext/mysqli/tests/bug39457.phpt @@ -7,15 +7,15 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- connect($host, $user, $passwd, $db, $port, $socket); + $mysql = mysqli_init(); + $mysql->connect($host, $user, $passwd, $db, $port, $socket); - $mysql->connect($host, $user, $passwd, $db, $port, $socket); + $mysql->connect($host, $user, $passwd, $db, $port, $socket); - $mysql->close(); - echo "OK\n"; + $mysql->close(); + echo "OK\n"; ?> --EXPECT-- OK diff --git a/ext/mysqli/tests/bug42378.phpt b/ext/mysqli/tests/bug42378.phpt index 1c7514130696..3b0638c840a5 100644 --- a/ext/mysqli/tests/bug42378.phpt +++ b/ext/mysqli/tests/bug42378.phpt @@ -10,175 +10,175 @@ require_once('skipifconnectfailure.inc'); memory_limit=83886080 --FILE-- $v) { - if (!mysqli_stmt_fetch($stmt)) { - break; - } - if ($result !== $v) { - printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n", - $offset + 8, - $k, - gettype($v), $v, - gettype($result), $result, - $order_by_col, - $format, $sql); - } - } - - } - - mysqli_stmt_free_result($stmt); - mysqli_stmt_close($stmt); - - return true; - } - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect - [%d] %s\n", - mysqli_connect_errno(), - mysqli_connect_error()); - - /* create new table and select from it */ - $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'FORMAT(col1, 0)', 'test', NULL, array(), 100); - - $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 110); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120); - - $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 130); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140); - - $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 150); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160); - - mysqli_close($link); - print "done!"; + require_once("connect.inc"); + + function create_table($link, $column, $min, $max, $engine, $offset) { + + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { + printf("[%03d] Cannot drop table test, [%d] %s\n", + $offset, + mysqli_errno($link), mysqli_error($link)); + return array(); + } + print "$column\n"; + + $sql = sprintf("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, col1 %s) ENGINE=%s", + $column, $engine); + if (!mysqli_query($link, $sql)) { + printf("[%03d] Cannot create table test, [%d] %s\n", + $offset + 1, + mysqli_errno($link), mysqli_error($link)); + return array(); + } + + $values = array(); + for ($i = 1; $i <= 100; $i++) { + $col1 = mt_rand($min, $max); + $values[$i] = $col1; + $sql = sprintf("INSERT INTO test(id, col1) VALUES (%d, %f)", + $i, $col1); + if (!mysqli_query($link, $sql)) { + printf("[%03d] Cannot insert data, [%d] %s\n", + $offset + 2, + mysqli_errno($link), mysqli_error($link)); + return array(); + } + } + + return $values; + } + + function test_format($link, $format, $from, $order_by, $expected, $offset) { + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%03d] Cannot create PS, [%d] %s\n", + $offset, + mysqli_errno($link), mysqli_error($link)); + return false; + } + print "$format\n"; + + if ($order_by) + $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by); + else + $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from); + + if (!mysqli_stmt_prepare($stmt, $sql)) { + printf("[%03d] Cannot prepare PS, [%d] %s\n", + $offset + 1, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%03d] Cannot execute PS, [%d] %s\n", + $offset + 2, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_store_result($stmt)) { + printf("[%03d] Cannot store result set, [%d] %s\n", + $offset + 3, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!is_array($expected)) { + + $result = null; + if (!mysqli_stmt_bind_result($stmt, $result)) { + printf("[%03d] Cannot bind result, [%d] %s\n", + $offset + 4, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_fetch($stmt)) { + printf("[%03d] Cannot fetch result,, [%d] %s\n", + $offset + 5, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if ($result !== $expected) { + printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n", + $offset + 6, + gettype($expected), $expected, + gettype($result), $result, + $format, $sql); + } + + } else { + + $order_by_col = $result = null; + if (!is_null($order_by)) { + if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) { + printf("[%03d] Cannot bind result, [%d] %s\n", + $offset + 7, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + } else { + if (!mysqli_stmt_bind_result($stmt, $result)) { + printf("[%03d] Cannot bind result, [%d] %s\n", + $offset + 7, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + } + + foreach ($expected as $k => $v) { + if (!mysqli_stmt_fetch($stmt)) { + break; + } + if ($result !== $v) { + printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n", + $offset + 8, + $k, + gettype($v), $v, + gettype($result), $result, + $order_by_col, + $format, $sql); + } + } + + } + + mysqli_stmt_free_result($stmt); + mysqli_stmt_close($stmt); + + return true; + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect - [%d] %s\n", + mysqli_connect_errno(), + mysqli_connect_error()); + + /* create new table and select from it */ + $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'FORMAT(col1, 0)', 'test', NULL, array(), 100); + + $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 110); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120); + + $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 130); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140); + + $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 150); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160); + + mysqli_close($link); + print "done!"; ?> --CLEAN-- real_connect($host, $user, $passwd, $db, $port, $socket); if (mysqli_connect_errno()) { - printf("Connect failed: %s\n", mysqli_connect_error()); - exit(); + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); } $mysqli->query("DROP PROCEDURE IF EXISTS p1") or die($mysqli->error); @@ -28,22 +28,22 @@ $mysqli->query("CREATE PROCEDURE p1() BEGIN SELECT 23; SELECT 42; END") or die($ if ($mysqli->multi_query("CALL p1();")) { - do - { - if ($objResult = $mysqli->store_result()) { - while ($row = $objResult->fetch_assoc()) { - print_r($row); - } - $objResult->close(); - if ($mysqli->more_results()) { - print "----- next result -----------\n"; - } - } else { - print "no results found\n"; - } - } while ($mysqli->more_results() && $mysqli->next_result()); + do + { + if ($objResult = $mysqli->store_result()) { + while ($row = $objResult->fetch_assoc()) { + print_r($row); + } + $objResult->close(); + if ($mysqli->more_results()) { + print "----- next result -----------\n"; + } + } else { + print "no results found\n"; + } + } while ($mysqli->more_results() && $mysqli->next_result()); } else { - print $mysqli->error; + print $mysqli->error; } $mysqli->query("DROP PROCEDURE p1") or die($mysqli->error); diff --git a/ext/mysqli/tests/bug44897.phpt b/ext/mysqli/tests/bug44897.phpt index 948e4aaee7b3..ba7d0ca49d93 100644 --- a/ext/mysqli/tests/bug44897.phpt +++ b/ext/mysqli/tests/bug44897.phpt @@ -19,57 +19,57 @@ if (mysqli_get_server_version($link) <= 50000) { ?> --FILE-- query('DROP PROCEDURE IF EXISTS p')) - printf("[001] [%d] %s\n", $link->errno, $link->error); + if (!$link->query('DROP PROCEDURE IF EXISTS p')) + printf("[001] [%d] %s\n", $link->errno, $link->error); - if (!$link->query('CREATE PROCEDURE p(IN new_id INT, IN new_label CHAR(1)) BEGIN INSERT INTO test(id, label) VALUES (new_id, new_label); SELECT new_label; END;')) - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!$link->query('CREATE PROCEDURE p(IN new_id INT, IN new_label CHAR(1)) BEGIN INSERT INTO test(id, label) VALUES (new_id, new_label); SELECT new_label; END;')) + printf("[002] [%d] %s\n", $link->errno, $link->error); - $new_id = 100; - $new_label = 'z'; + $new_id = 100; + $new_label = 'z'; - if (!$stmt = $link->prepare('CALL p(?, ?)')) - printf("[003] [%d] %s\n", $link->errno, $link->error); + if (!$stmt = $link->prepare('CALL p(?, ?)')) + printf("[003] [%d] %s\n", $link->errno, $link->error); - if (!$stmt->bind_param('is', $new_id, $new_label) || !$stmt->execute()) - printf("[004] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->bind_param('is', $new_id, $new_label) || !$stmt->execute()) + printf("[004] [%d] %s\n", $stmt->errno, $stmt->error); - $out_new_label = null; - if (!$stmt->bind_result($out_new_label) || !$stmt->fetch()) - printf("[005] [%d] %s\n", $stmt->errno, $stmt->error); + $out_new_label = null; + if (!$stmt->bind_result($out_new_label) || !$stmt->fetch()) + printf("[005] [%d] %s\n", $stmt->errno, $stmt->error); - if ($out_new_label != $new_label) - printf("[006] IN value and returned value differ. Expecting %s/%s got %s/%s\n", - $new_label, gettype($new_label), $out_new_label, gettype($out_new_label)); + if ($out_new_label != $new_label) + printf("[006] IN value and returned value differ. Expecting %s/%s got %s/%s\n", + $new_label, gettype($new_label), $out_new_label, gettype($out_new_label)); - $stmt->close(); + $stmt->close(); - $stmt2 = $link->prepare('SELECT label FROM test WHERE id = ?'); - if (!is_object($stmt2)) { + $stmt2 = $link->prepare('SELECT label FROM test WHERE id = ?'); + if (!is_object($stmt2)) { - printf("[007] Failed to create new statement object, [%d] %s\n", - $link->errno, $link->error); + printf("[007] Failed to create new statement object, [%d] %s\n", + $link->errno, $link->error); - } else { + } else { - if (!$stmt2->bind_param("i", $new_id) || !$stmt2->execute()) - printf("[008] [%d] %s\n", $stmt2->errno, $stmt2->error); + if (!$stmt2->bind_param("i", $new_id) || !$stmt2->execute()) + printf("[008] [%d] %s\n", $stmt2->errno, $stmt2->error); - $out_new_label = null; - if (!$stmt2->bind_result($out_new_label) || !$stmt2->fetch()) - printf("[009] [%d] %s\n", $stmt2->errno, $stmt2->error); + $out_new_label = null; + if (!$stmt2->bind_result($out_new_label) || !$stmt2->fetch()) + printf("[009] [%d] %s\n", $stmt2->errno, $stmt2->error); - if ($out_new_label != $new_label) - printf("[010] IN value and returned value differ. Expecting %s/%s got %s/%s\n", - $new_label, gettype($new_label), $out_new_label, gettype($out_new_label)); + if ($out_new_label != $new_label) + printf("[010] IN value and returned value differ. Expecting %s/%s got %s/%s\n", + $new_label, gettype($new_label), $out_new_label, gettype($out_new_label)); - } + } - $link->close(); + $link->close(); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) - printf("[001] [%d] %s\n", $link->errno, $link->error); + // Regular (non-prepared) queries + print "Using CAST('somestring' AS CHAR)...\n"; + if (!($res = $link->query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) + printf("[001] [%d] %s\n", $link->errno, $link->error); - $data = array(); - while ($row = $res->fetch_assoc()) { - $data[] = $row['column1']; - var_dump($row['column1']); - } - $res->free(); + $data = array(); + while ($row = $res->fetch_assoc()) { + $data[] = $row['column1']; + var_dump($row['column1']); + } + $res->free(); - // Prepared Statements - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) - printf("[002] [%d] %s\n", $link->errno, $link->error); + // Prepared Statements + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) + printf("[002] [%d] %s\n", $link->errno, $link->error); - $column1 = null; - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); + $column1 = null; + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); - $index = 0; - while ($stmt->fetch()) { - /* NOTE: libmysql - http://bugs.mysql.com/bug.php?id=47483 */ - if ($data[$index] != $column1) { - if ($IS_MYSQLND || $index != 1) { - printf("[004] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } else { - if ($column1 != "thre") - printf("[005] Got '%s'. Please check if http://bugs.mysql.com/bug.php?id=47483 has been fixed and adapt tests bug45019.phpt/mysqli_ps_select_union.phpt", $column1); - } - } - $index++; - } - $stmt->close(); + $index = 0; + while ($stmt->fetch()) { + /* NOTE: libmysql - http://bugs.mysql.com/bug.php?id=47483 */ + if ($data[$index] != $column1) { + if ($IS_MYSQLND || $index != 1) { + printf("[004] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } else { + if ($column1 != "thre") + printf("[005] Got '%s'. Please check if http://bugs.mysql.com/bug.php?id=47483 has been fixed and adapt tests bug45019.phpt/mysqli_ps_select_union.phpt", $column1); + } + } + $index++; + } + $stmt->close(); - $link->close(); + $link->close(); - print "done!"; + print "done!"; ?> --EXPECT-- Using CAST('somestring' AS CHAR)... diff --git a/ext/mysqli/tests/bug45289.phpt b/ext/mysqli/tests/bug45289.phpt index 2ddacf4fdd2a..65b7ebd707c7 100644 --- a/ext/mysqli/tests/bug45289.phpt +++ b/ext/mysqli/tests/bug45289.phpt @@ -7,30 +7,30 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- close(); + $link->close(); - $link = mysqli_init(); - if (!($link->real_connect($host, $user, $passwd, $db, $port, $socket))) - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + $link = mysqli_init(); + if (!($link->real_connect($host, $user, $passwd, $db, $port, $socket))) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - $id = 1; - if (!($stmt = $link->prepare('SELECT id, label FROM test WHERE id=? LIMIT 1'))) - printf("[002] [%d] %s\n", $link->errno, $link->error); + $id = 1; + if (!($stmt = $link->prepare('SELECT id, label FROM test WHERE id=? LIMIT 1'))) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!$stmt->bind_param('i', $id) || !$stmt->execute()) - printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->bind_param('i', $id) || !$stmt->execute()) + printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); - if ($res = $link->store_result()) { - if ($IS_MYSQLND) - printf("[004] Can store result!\n"); - else - printf("[004] [007] http://bugs.mysql.com/bug.php?id=47485\n"); - } else { - printf("[004] [%d] %s\n", $link->errno, $link->error); - } + if ($res = $link->store_result()) { + if ($IS_MYSQLND) + printf("[004] Can store result!\n"); + else + printf("[004] [007] http://bugs.mysql.com/bug.php?id=47485\n"); + } else { + printf("[004] [%d] %s\n", $link->errno, $link->error); + } ?> --CLEAN-- --FILE-- init(); - $mysqli->init(); - echo "done"; + $mysqli = new mysqli(); + $mysqli->init(); + $mysqli->init(); + echo "done"; ?> --EXPECT-- done diff --git a/ext/mysqli/tests/bug46614.phpt b/ext/mysqli/tests/bug46614.phpt index 9e7822271300..2cdefbf4a316 100644 --- a/ext/mysqli/tests/bug46614.phpt +++ b/ext/mysqli/tests/bug46614.phpt @@ -11,13 +11,13 @@ if (!defined("MYSQLI_ASYNC")) { --FILE-- extData[] = 'Bar'; - return empty($this->extData); - } + public function isEmpty() + { + $this->extData[] = 'Bar'; + return empty($this->extData); + } } include ("connect.inc"); diff --git a/ext/mysqli/tests/bug47050.phpt b/ext/mysqli/tests/bug47050.phpt index 0358802bac16..ac305b07d252 100644 --- a/ext/mysqli/tests/bug47050.phpt +++ b/ext/mysqli/tests/bug47050.phpt @@ -10,22 +10,22 @@ if (!defined("MYSQLI_ASYNC")) { ?> --FILE-- query("SELECT 'test'", MYSQLI_ASYNC); - $all_links = array($link1); - $links = $errors = $reject = $all_links; - mysqli_poll($links, $errors, $reject, 1); + $link1->query("SELECT 'test'", MYSQLI_ASYNC); + $all_links = array($link1); + $links = $errors = $reject = $all_links; + mysqli_poll($links, $errors, $reject, 1); - echo "links: ", sizeof($links), "\n"; - echo "errors: ", sizeof($errors), "\n"; - echo "reject: ", sizeof($reject), "\n"; - echo "all_links: ", sizeof($all_links), "\n"; + echo "links: ", sizeof($links), "\n"; + echo "errors: ", sizeof($errors), "\n"; + echo "reject: ", sizeof($reject), "\n"; + echo "all_links: ", sizeof($all_links), "\n"; - $link1->close(); + $link1->close(); ?> --EXPECT-- links: 1 diff --git a/ext/mysqli/tests/bug48909.phpt b/ext/mysqli/tests/bug48909.phpt index ef46c97c6a5b..3c7e09f17e38 100644 --- a/ext/mysqli/tests/bug48909.phpt +++ b/ext/mysqli/tests/bug48909.phpt @@ -7,36 +7,36 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("DROP TABLE IF EXISTS test") || - !$link->query(sprintf("CREATE TABLE test(id INT, label varchar(255)) ENGINE = %s", $engine))) - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query(sprintf("CREATE TABLE test(id INT, label varchar(255)) ENGINE = %s", $engine))) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!$stmt = $link->prepare("INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[003] [%d] %s\n", $link->errno, $link->error); + if (!$stmt = $link->prepare("INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[003] [%d] %s\n", $link->errno, $link->error); - if (!$stmt->bind_param("bb",$bvar, $bvar)) - printf("[004] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->bind_param("bb",$bvar, $bvar)) + printf("[004] [%d] %s\n", $stmt->errno, $stmt->error); - if (!$stmt->execute()) { - if ($stmt->errno != 1366) { - /* - $bvar is null, b is for BLOB - any error like this should be OK: - 1366 - Incorrect integer value: '' for column 'id' at row 1 - */ - printf("[005] [%d] %s\n", $stmt->errno, $stmt->error); - } - } + if (!$stmt->execute()) { + if ($stmt->errno != 1366) { + /* + $bvar is null, b is for BLOB - any error like this should be OK: + 1366 - Incorrect integer value: '' for column 'id' at row 1 + */ + printf("[005] [%d] %s\n", $stmt->errno, $stmt->error); + } + } - $stmt->close(); - $link->close(); + $stmt->close(); + $link->close(); - echo "done"; + echo "done"; ?> --CLEAN-- --FILE-- query("SELECT 42")->fetch_row()); + var_dump($link->query("SELECT 42")->fetch_row()); - if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || - !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE=%s", $engine))) { - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, sprintf("CREATE TABLE test(id INT) ENGINE=%s", $engine))) { + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_close($link); + mysqli_close($link); - $link = mysqli_init(); - if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES(1)")) { - printf("[004] Cannot set INIT_COMMAND\n"); - } + $link = mysqli_init(); + if (!mysqli_options($link, MYSQLI_INIT_COMMAND, "INSERT INTO test(id) VALUES(1)")) { + printf("[004] Cannot set INIT_COMMAND\n"); + } - if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { - printf("[005] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - } + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { + printf("[005] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } - if (!$res = mysqli_query($link, "SELECT id FROM test")) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "SELECT id FROM test")) + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump(mysqli_fetch_assoc($res)); + var_dump(mysqli_fetch_assoc($res)); - mysqli_free_result($res); - mysqli_close($link); + mysqli_free_result($res); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --CLEAN-- --FILE-- options(MYSQLI_OPT_CONNECT_TIMEOUT, 3); - my_mysqli_real_connect($db1, $host, $user, $passwd, $db, $port, $socket); - if(mysqli_connect_error()) { - echo "error 1\n"; - } else { - echo "ok 1\n"; - } + // These calls fail + $db1->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3); + my_mysqli_real_connect($db1, $host, $user, $passwd, $db, $port, $socket); + if(mysqli_connect_error()) { + echo "error 1\n"; + } else { + echo "ok 1\n"; + } - $db2 = mysqli_init(); + $db2 = mysqli_init(); - $db2->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3); - my_mysqli_real_connect($db2, $host, $user, $passwd, $db, $port, $socket); - if(mysqli_connect_error()) { - echo "error 2\n"; - } else { - echo "ok 2\n"; - } - echo "done\n"; + $db2->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3); + my_mysqli_real_connect($db2, $host, $user, $passwd, $db, $port, $socket); + if(mysqli_connect_error()) { + echo "error 2\n"; + } else { + echo "ok 2\n"; + } + echo "done\n"; ?> --EXPECT-- ok 1 diff --git a/ext/mysqli/tests/bug51605.phpt b/ext/mysqli/tests/bug51605.phpt index c57a7b36d301..c3238da289e8 100644 --- a/ext/mysqli/tests/bug51605.phpt +++ b/ext/mysqli/tests/bug51605.phpt @@ -12,30 +12,30 @@ mysqli.max_persistent = 0 mysqli.reconnect = Off --FILE-- --EXPECT-- closed once diff --git a/ext/mysqli/tests/bug51647.phpt b/ext/mysqli/tests/bug51647.phpt index 816a612d5a1c..8fd107a95d59 100644 --- a/ext/mysqli/tests/bug51647.phpt +++ b/ext/mysqli/tests/bug51647.phpt @@ -39,69 +39,69 @@ $link->close(); ?> --FILE-- query('SHOW STATUS like "Ssl_cipher"')) { - if (1064 == $link->errno) { - /* ERROR 1064 (42000): You have an error in your SQL syntax; = sql strict mode */ - if ($res = $link->query("SHOW STATUS")) { - while ($row = $res->fetch_assoc()) - if ($row['Variable_name'] == 'Ssl_cipher') - break; - } else { - printf("[005] [%d] %s\n", $link->errno, $link->error); - } - } else { - printf("[004] [%d] %s\n", $link->errno, $link->error); - } - } else { - if (!$row = $res->fetch_assoc()) - printf("[006] [%d] %s\n", $link->errno, $link->error); - if (!strlen($row["Value"])) - printf("[007] Empty cipher. No encryption!"); - var_dump($row); - } - - $link->close(); - - if (!is_object($link = mysqli_init())) - printf("[008] Cannot create link\n"); - - if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_SSL)) { - printf("[009] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - } - - if (!$res = $link->query('SHOW STATUS like "Ssl_cipher"')) { - if (1064 == $link->errno) { - /* ERROR 1064 (42000): You have an error in your SQL syntax; = sql strict mode */ - if ($res = $link->query("SHOW STATUS")) { - while ($row = $res->fetch_assoc()) - if ($row['Variable_name'] == 'Ssl_cipher') - break; - } else { - printf("[010] [%d] %s\n", $link->errno, $link->error); - } - } else { - printf("[011] [%d] %s\n", $link->errno, $link->error); - } - } else { - if (!$row = $res->fetch_assoc()) - printf("[012] [%d] %s\n", $link->errno, $link->error); - if (!strlen($row["Value"])) - printf("[013] Empty cipher. No encryption!"); - var_dump($row); - } - - $link->close(); - - print "done!"; + include ("connect.inc"); + + if (!is_object($link = mysqli_init())) + printf("[001] Cannot create link\n"); + + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT)) { + printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } + + if (!$res = $link->query('SHOW STATUS like "Ssl_cipher"')) { + if (1064 == $link->errno) { + /* ERROR 1064 (42000): You have an error in your SQL syntax; = sql strict mode */ + if ($res = $link->query("SHOW STATUS")) { + while ($row = $res->fetch_assoc()) + if ($row['Variable_name'] == 'Ssl_cipher') + break; + } else { + printf("[005] [%d] %s\n", $link->errno, $link->error); + } + } else { + printf("[004] [%d] %s\n", $link->errno, $link->error); + } + } else { + if (!$row = $res->fetch_assoc()) + printf("[006] [%d] %s\n", $link->errno, $link->error); + if (!strlen($row["Value"])) + printf("[007] Empty cipher. No encryption!"); + var_dump($row); + } + + $link->close(); + + if (!is_object($link = mysqli_init())) + printf("[008] Cannot create link\n"); + + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_SSL)) { + printf("[009] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } + + if (!$res = $link->query('SHOW STATUS like "Ssl_cipher"')) { + if (1064 == $link->errno) { + /* ERROR 1064 (42000): You have an error in your SQL syntax; = sql strict mode */ + if ($res = $link->query("SHOW STATUS")) { + while ($row = $res->fetch_assoc()) + if ($row['Variable_name'] == 'Ssl_cipher') + break; + } else { + printf("[010] [%d] %s\n", $link->errno, $link->error); + } + } else { + printf("[011] [%d] %s\n", $link->errno, $link->error); + } + } else { + if (!$row = $res->fetch_assoc()) + printf("[012] [%d] %s\n", $link->errno, $link->error); + if (!strlen($row["Value"])) + printf("[013] Empty cipher. No encryption!"); + var_dump($row); + } + + $link->close(); + + print "done!"; ?> --EXPECTF-- array(2) { diff --git a/ext/mysqli/tests/bug52082.phpt b/ext/mysqli/tests/bug52082.phpt index 11157195ab78..f601406e8fed 100644 --- a/ext/mysqli/tests/bug52082.phpt +++ b/ext/mysqli/tests/bug52082.phpt @@ -8,19 +8,19 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- options(MYSQLI_SET_CHARSET_NAME, "latin2"); - if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { - die("can't connect"); - } - var_dump($link->query("show variables like 'character_set_client'")->fetch_row()); - var_dump($link->query("show variables like 'character_set_connection'")->fetch_row()); - $link->change_user($user, $passwd, $db); - var_dump($link->query("show variables like 'character_set_client'")->fetch_row()); - var_dump($link->query("show variables like 'character_set_connection'")->fetch_row()); + require_once("connect.inc"); + $link = mysqli_init(); + $link->options(MYSQLI_SET_CHARSET_NAME, "latin2"); + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { + die("can't connect"); + } + var_dump($link->query("show variables like 'character_set_client'")->fetch_row()); + var_dump($link->query("show variables like 'character_set_connection'")->fetch_row()); + $link->change_user($user, $passwd, $db); + var_dump($link->query("show variables like 'character_set_client'")->fetch_row()); + var_dump($link->query("show variables like 'character_set_connection'")->fetch_row()); - print "done!"; + print "done!"; ?> --EXPECT-- array(2) { diff --git a/ext/mysqli/tests/bug52891.phpt b/ext/mysqli/tests/bug52891.phpt index 22fcb735e335..f0692556399f 100644 --- a/ext/mysqli/tests/bug52891.phpt +++ b/ext/mysqli/tests/bug52891.phpt @@ -10,90 +10,90 @@ if (!$IS_MYSQLND) { ?> --FILE-- query("DROP TABLE IF EXISTS tuint") || - !$link->query("DROP TABLE IF EXISTS tsint")) { - printf("[002] [%d] %s\n", $link->errno, $link->error); - } + if (!$link->query("DROP TABLE IF EXISTS tuint") || + !$link->query("DROP TABLE IF EXISTS tsint")) { + printf("[002] [%d] %s\n", $link->errno, $link->error); + } - if (!$link->query("CREATE TABLE tuint(a BIGINT UNSIGNED) ENGINE=" . $engine) || - !$link->query("CREATE TABLE tsint(a BIGINT) ENGINE=" . $engine)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } + if (!$link->query("CREATE TABLE tuint(a BIGINT UNSIGNED) ENGINE=" . $engine) || + !$link->query("CREATE TABLE tsint(a BIGINT) ENGINE=" . $engine)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } - if (!$stmt1 = $link->prepare("INSERT INTO tuint VALUES(?)")) - printf("[004] [%d] %s\n", $link->errno, $link->error); + if (!$stmt1 = $link->prepare("INSERT INTO tuint VALUES(?)")) + printf("[004] [%d] %s\n", $link->errno, $link->error); - if (!$stmt2 = $link->prepare("INSERT INTO tsint VALUES(?)")) - printf("[005] [%d] %s\n", $link->errno, $link->error); + if (!$stmt2 = $link->prepare("INSERT INTO tsint VALUES(?)")) + printf("[005] [%d] %s\n", $link->errno, $link->error); - $param = 42; + $param = 42; - if (!$stmt1->bind_param("i", $param)) - printf("[006] [%d] %s\n", $stmt1->errno, $stmt1->error); + if (!$stmt1->bind_param("i", $param)) + printf("[006] [%d] %s\n", $stmt1->errno, $stmt1->error); - if (!$stmt2->bind_param("i", $param)) - printf("[007] [%d] %s\n", $stmt2->errno, $stmt2->error); + if (!$stmt2->bind_param("i", $param)) + printf("[007] [%d] %s\n", $stmt2->errno, $stmt2->error); - /* first insert normal value to force initial send of types */ - if (!$stmt1->execute()) - printf("[008] [%d] %s\n", $stmt1->errno, $stmt1->error); + /* first insert normal value to force initial send of types */ + if (!$stmt1->execute()) + printf("[008] [%d] %s\n", $stmt1->errno, $stmt1->error); - if (!$stmt2->execute()) - printf("[009] [%d] %s\n", $stmt2->errno, $stmt2->error); + if (!$stmt2->execute()) + printf("[009] [%d] %s\n", $stmt2->errno, $stmt2->error); - /* now try values that don't fit in long, on 32bit, new types should be sent or 0 will be inserted */ - $param = -4294967297; - if (!$stmt2->execute()) - printf("[010] [%d] %s\n", $stmt2->errno, $stmt2->error); + /* now try values that don't fit in long, on 32bit, new types should be sent or 0 will be inserted */ + $param = -4294967297; + if (!$stmt2->execute()) + printf("[010] [%d] %s\n", $stmt2->errno, $stmt2->error); - /* again normal value */ - $param = 43; + /* again normal value */ + $param = 43; - if (!$stmt1->execute()) - printf("[011] [%d] %s\n", $stmt1->errno, $stmt1->error); + if (!$stmt1->execute()) + printf("[011] [%d] %s\n", $stmt1->errno, $stmt1->error); - if (!$stmt2->execute()) - printf("[012] [%d] %s\n", $stmt2->errno, $stmt2->error); + if (!$stmt2->execute()) + printf("[012] [%d] %s\n", $stmt2->errno, $stmt2->error); - /* again conversion */ - $param = -4294967295; - if (!$stmt2->execute()) - printf("[013] [%d] %s\n", $stmt2->errno, $stmt2->error); + /* again conversion */ + $param = -4294967295; + if (!$stmt2->execute()) + printf("[013] [%d] %s\n", $stmt2->errno, $stmt2->error); - $param = 4294967295; - if (!$stmt1->execute()) - printf("[014] [%d] %s\n", $stmt1->errno, $stmt1->error); + $param = 4294967295; + if (!$stmt1->execute()) + printf("[014] [%d] %s\n", $stmt1->errno, $stmt1->error); - if (!$stmt2->execute()) - printf("[015] [%d] %s\n", $stmt2->errno, $stmt2->error); + if (!$stmt2->execute()) + printf("[015] [%d] %s\n", $stmt2->errno, $stmt2->error); - $param = 4294967297; - if (!$stmt1->execute()) - printf("[016] [%d] %s\n", $stmt1->errno, $stmt1->error); + $param = 4294967297; + if (!$stmt1->execute()) + printf("[016] [%d] %s\n", $stmt1->errno, $stmt1->error); - if (!$stmt2->execute()) - printf("[017] [%d] %s\n", $stmt2->errno, $stmt2->error); + if (!$stmt2->execute()) + printf("[017] [%d] %s\n", $stmt2->errno, $stmt2->error); - $result = $link->query("SELECT * FROM tsint ORDER BY a ASC"); - $result2 = $link->query("SELECT * FROM tuint ORDER BY a ASC"); + $result = $link->query("SELECT * FROM tsint ORDER BY a ASC"); + $result2 = $link->query("SELECT * FROM tuint ORDER BY a ASC"); - echo "tsint:\n"; - while ($row = $result->fetch_assoc()) { - var_dump($row); - } - echo "tuint:\n"; - while ($row = $result2->fetch_assoc()) { - var_dump($row); - } + echo "tsint:\n"; + while ($row = $result->fetch_assoc()) { + var_dump($row); + } + echo "tuint:\n"; + while ($row = $result2->fetch_assoc()) { + var_dump($row); + } - echo "done"; + echo "done"; ?> --CLEAN-- query("DROP TABLE IF EXISTS test")) { - printf("[002] [%d] %s\n", $link->errno, $link->error); - } + if (!$link->query("DROP TABLE IF EXISTS test")) { + printf("[002] [%d] %s\n", $link->errno, $link->error); + } - if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } + if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } - if (FALSE == file_put_contents('bug53503.data', "1\n2\n3\n")) - printf("[004] Failed to create CVS file\n"); + if (FALSE == file_put_contents('bug53503.data', "1\n2\n3\n")) + printf("[004] Failed to create CVS file\n"); - if (!$link->query("SELECT 1 FROM DUAL")) - printf("[005] [%d] %s\n", $link->errno, $link->error); + if (!$link->query("SELECT 1 FROM DUAL")) + printf("[005] [%d] %s\n", $link->errno, $link->error); - if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE test")) { - printf("[006] [%d] %s\n", $link->errno, $link->error); - echo "bug"; - } else { - echo "done"; - } - $link->close(); + if (!$link->query("LOAD DATA LOCAL INFILE 'bug53503.data' INTO TABLE test")) { + printf("[006] [%d] %s\n", $link->errno, $link->error); + echo "bug"; + } else { + echo "done"; + } + $link->close(); ?> --CLEAN-- multi_query($query)) { - do { - $sth = $link->store_result(); + $query = "$create;$create;$create;"; + if ($link->multi_query($query)) { + do { + $sth = $link->store_result(); - if ($link->warning_count) { - $warnings = $link->get_warnings(); - if ($warnings) { - do { - echo "Warning: ".$warnings->errno.": ".$warnings->message."\n"; - } while ($warnings->next()); - } - } - } while ($link->more_results() && $link->next_result()); - } + if ($link->warning_count) { + $warnings = $link->get_warnings(); + if ($warnings) { + do { + echo "Warning: ".$warnings->errno.": ".$warnings->message."\n"; + } while ($warnings->next()); + } + } + } while ($link->more_results() && $link->next_result()); + } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --EXPECT-- Warning: 1050: Table 't54221' already exists diff --git a/ext/mysqli/tests/bug54674.phpt b/ext/mysqli/tests/bug54674.phpt index e18eed7f99cb..b3c44be290d0 100644 --- a/ext/mysqli/tests/bug54674.phpt +++ b/ext/mysqli/tests/bug54674.phpt @@ -12,19 +12,19 @@ mysqli.max_persistent = 0 mysqli.reconnect = Off --FILE-- set_charset('sjis'); - var_dump($link->real_escape_string($japanese_so) === $japanese_so); - mysqli_close($link); + $japanese_so = pack('H4', '835c'); + $link->set_charset('sjis'); + var_dump($link->real_escape_string($japanese_so) === $japanese_so); + mysqli_close($link); - print "done!"; + print "done!"; ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/bug55283.phpt b/ext/mysqli/tests/bug55283.phpt index 843400ff98d8..306a4af156a3 100644 --- a/ext/mysqli/tests/bug55283.phpt +++ b/ext/mysqli/tests/bug55283.phpt @@ -39,28 +39,28 @@ $link->close(); ?> --FILE-- query("SHOW STATUS LIKE 'Ssl_cipher'"); - var_dump($r->fetch_row()); - } + $link = mysqli_init(); + mysqli_ssl_set($link, null, null, null, null, "AES256-SHA"); + if (my_mysqli_real_connect($link, 'p:' . $host, $user, $passwd, $db, $port, null, $flags)) { + $r = $link->query("SHOW STATUS LIKE 'Ssl_cipher'"); + var_dump($r->fetch_row()); + } - /* non-persistent connection */ - $link2 = mysqli_init(); - mysqli_ssl_set($link2, null, null, null, null, "AES256-SHA"); - if (my_mysqli_real_connect($link2, $host, $user, $passwd, $db, $port, null, $flags)) { - $r2 = $link2->query("SHOW STATUS LIKE 'Ssl_cipher'"); - var_dump($r2->fetch_row()); - } + /* non-persistent connection */ + $link2 = mysqli_init(); + mysqli_ssl_set($link2, null, null, null, null, "AES256-SHA"); + if (my_mysqli_real_connect($link2, $host, $user, $passwd, $db, $port, null, $flags)) { + $r2 = $link2->query("SHOW STATUS LIKE 'Ssl_cipher'"); + var_dump($r2->fetch_row()); + } - echo "done\n"; + echo "done\n"; ?> --EXPECTF-- array(2) { diff --git a/ext/mysqli/tests/bug55582.phpt b/ext/mysqli/tests/bug55582.phpt index 132a731d0c53..86626c0279f7 100644 --- a/ext/mysqli/tests/bug55582.phpt +++ b/ext/mysqli/tests/bug55582.phpt @@ -8,21 +8,21 @@ require_once("connect.inc"); ?> --FILE-- real_query("SELECT 1")); - $res = $link->use_result(); - var_dump(mysqli_num_rows($res)); - var_dump($res->fetch_assoc()); - var_dump(mysqli_num_rows($res)); - var_dump($res->fetch_assoc()); - var_dump(mysqli_num_rows($res)); + var_dump($link->real_query("SELECT 1")); + $res = $link->use_result(); + var_dump(mysqli_num_rows($res)); + var_dump($res->fetch_assoc()); + var_dump(mysqli_num_rows($res)); + var_dump($res->fetch_assoc()); + var_dump(mysqli_num_rows($res)); - $link->close(); - echo "done\n"; + $link->close(); + echo "done\n"; ?> --EXPECTF-- bool(true) diff --git a/ext/mysqli/tests/bug55653.phpt b/ext/mysqli/tests/bug55653.phpt index 80e654771c03..a51a7ddd22a5 100644 --- a/ext/mysqli/tests/bug55653.phpt +++ b/ext/mysqli/tests/bug55653.phpt @@ -7,30 +7,30 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- stmt_init())) - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!($stmt = $link->stmt_init())) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!($stmt->prepare("SELECT ?")) || - !($stmt->bind_param("s", $in_and_out)) || - !($stmt->execute()) || - !($stmt->bind_result($in_and_out))) - printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); + if (!($stmt->prepare("SELECT ?")) || + !($stmt->bind_param("s", $in_and_out)) || + !($stmt->execute()) || + !($stmt->bind_result($in_and_out))) + printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); - if (!$stmt->fetch()) - printf("[004] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->fetch()) + printf("[004] [%d] %s\n", $stmt->errno, $stmt->error); - if ("a" !== $in_and_out) - printf("[005] Wrong result: '%s'\n", $in_and_out); + if ("a" !== $in_and_out) + printf("[005] Wrong result: '%s'\n", $in_and_out); - echo "done!"; + echo "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/bug62046.phpt b/ext/mysqli/tests/bug62046.phpt index e996de361daf..5913ef399e54 100644 --- a/ext/mysqli/tests/bug62046.phpt +++ b/ext/mysqli/tests/bug62046.phpt @@ -7,33 +7,33 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- prepare('SELECT 42'))) { - printf("[002] Prepare failed, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - if (FALSE === $stmt->execute()) { - printf("[003] Execute failed, [%d] %s\n", $stmt->errorno, $stmt->error); - } - if (FALSE === $stmt->store_result()) { - printf("[004] store_result failed, [%d] %s\n", $stmt->errorno, $stmt->error); - } - $one = NULL; - if (FALSE === $stmt->bind_result($one)) { - printf("[005] bind_result failed, [%d] %s\n", $stmt->errorno, $stmt->error); - } - if (FALSE === $stmt->reset()) { - printf("[006] bind_result failed, [%d] %s\n", $stmt->errorno, $stmt->error); - } - while ($stmt->fetch()) { - var_dump($one); - } - $stmt->close(); - $link->close(); - echo "done!"; + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } + if (FALSE === ($stmt = $link->prepare('SELECT 42'))) { + printf("[002] Prepare failed, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (FALSE === $stmt->execute()) { + printf("[003] Execute failed, [%d] %s\n", $stmt->errorno, $stmt->error); + } + if (FALSE === $stmt->store_result()) { + printf("[004] store_result failed, [%d] %s\n", $stmt->errorno, $stmt->error); + } + $one = NULL; + if (FALSE === $stmt->bind_result($one)) { + printf("[005] bind_result failed, [%d] %s\n", $stmt->errorno, $stmt->error); + } + if (FALSE === $stmt->reset()) { + printf("[006] bind_result failed, [%d] %s\n", $stmt->errorno, $stmt->error); + } + while ($stmt->fetch()) { + var_dump($one); + } + $stmt->close(); + $link->close(); + echo "done!"; ?> --EXPECT-- int(42) diff --git a/ext/mysqli/tests/bug66043.phpt b/ext/mysqli/tests/bug66043.phpt index 54ddf6943c6f..07714f217a5d 100644 --- a/ext/mysqli/tests/bug66043.phpt +++ b/ext/mysqli/tests/bug66043.phpt @@ -13,7 +13,7 @@ require_once('skipifconnectfailure.inc'); stmt_init(); diff --git a/ext/mysqli/tests/bug66124.phpt b/ext/mysqli/tests/bug66124.phpt index d5dec314cf5d..cede635e144b 100644 --- a/ext/mysqli/tests/bug66124.phpt +++ b/ext/mysqli/tests/bug66124.phpt @@ -23,9 +23,9 @@ $id = '1311200011005001566'; require_once('connect.inc'); if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - exit(1); + printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + exit(1); } $link->query($table_drop); @@ -33,8 +33,8 @@ $link->query($table_create); $stmt = $link->prepare($table_insert); if (!$stmt) { - printf("Can't prepare\n"); - exit(1); + printf("Can't prepare\n"); + exit(1); } echo "Using 'i':\n"; @@ -43,8 +43,8 @@ $stmt->bind_param('i', $id); if ($stmt->execute()){ echo "insert id:{$id}=>{$stmt->insert_id}\n"; } else { - printf("Can't execute\n"); - exit(1); + printf("Can't execute\n"); + exit(1); } @@ -55,8 +55,8 @@ if ($result){ echo "fetch id:{$row['id']}\n"; } } else { - printf("Can't select\n"); - exit(1); + printf("Can't select\n"); + exit(1); } $stmt->close(); @@ -73,8 +73,8 @@ echo "Using 's':\n"; if ($stmt->execute()){ echo "insert id:{$id}\n"; } else{ - printf("Can't execute\n"); - exit(1); + printf("Can't execute\n"); + exit(1); } $result = $link->query($table_select); @@ -84,8 +84,8 @@ if ($result){ echo "fetch id:{$row['id']}\n"; } } else { - printf("Can't select\n"); - exit(1); + printf("Can't select\n"); + exit(1); } $link->close(); diff --git a/ext/mysqli/tests/bug66762.phpt b/ext/mysqli/tests/bug66762.phpt index f5240bc926d5..c1f749d8c4ee 100644 --- a/ext/mysqli/tests/bug66762.phpt +++ b/ext/mysqli/tests/bug66762.phpt @@ -7,18 +7,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- prepare("SELECT 1"); + $read_stmt = $mysqli->prepare("SELECT 1"); - var_dump($read_stmt->bind_result($data)); + var_dump($read_stmt->bind_result($data)); - unset($mysqli); - var_dump($read_stmt->bind_result($data)); + unset($mysqli); + var_dump($read_stmt->bind_result($data)); ?> done! --EXPECT-- diff --git a/ext/mysqli/tests/bug67839.phpt b/ext/mysqli/tests/bug67839.phpt index f36c2bf6e763..4e8fd68ffdbc 100644 --- a/ext/mysqli/tests/bug67839.phpt +++ b/ext/mysqli/tests/bug67839.phpt @@ -10,55 +10,55 @@ mysqli_float_handling - ensure 4 byte float is handled correctly precision=5 --FILE-- --CLEAN-- query("DROP TABLE IF EXISTS test")) { - printf("[002] [%d] %s\n", $link->errno, $link->error); - } + if (!$link->query("DROP TABLE IF EXISTS test")) { + printf("[002] [%d] %s\n", $link->errno, $link->error); + } - if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } + if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } - if (FALSE == file_put_contents(__DIR__ . '/bug53503.data', "1\n2\n3\n")) - printf("[004] Failed to create CVS file\n"); + if (FALSE == file_put_contents(__DIR__ . '/bug53503.data', "1\n2\n3\n")) + printf("[004] Failed to create CVS file\n"); - if (!$link->query("SELECT 1 FROM DUAL")) - printf("[005] [%d] %s\n", $link->errno, $link->error); + if (!$link->query("SELECT 1 FROM DUAL")) + printf("[005] [%d] %s\n", $link->errno, $link->error); - if (!$link->query("LOAD DATA LOCAL INFILE '" . str_replace("\\", "/", __DIR__) . "/bug53503.data' INTO TABLE test")) { - printf("[006] [%d] %s\n", $link->errno, $link->error); - echo "bug\n"; - } else { - echo "done\n"; - } + if (!$link->query("LOAD DATA LOCAL INFILE '" . str_replace("\\", "/", __DIR__) . "/bug53503.data' INTO TABLE test")) { + printf("[006] [%d] %s\n", $link->errno, $link->error); + echo "bug\n"; + } else { + echo "done\n"; + } - ini_set("open_basedir", __DIR__ . "/dummy"); - if (!$link->query("LOAD DATA LOCAL INFILE '" . __DIR__ . "/bug53503.data' INTO TABLE test")) { - printf("[006] [%d] %s\n", $link->errno, $link->error); - echo "done\n"; - } else { - echo "bug\n"; - } - $link->close(); + ini_set("open_basedir", __DIR__ . "/dummy"); + if (!$link->query("LOAD DATA LOCAL INFILE '" . __DIR__ . "/bug53503.data' INTO TABLE test")) { + printf("[006] [%d] %s\n", $link->errno, $link->error); + echo "done\n"; + } else { + echo "bug\n"; + } + $link->close(); ?> --CLEAN-- prepare('SELECT 1'); var_dump( - $mysqli->close(), - $stmt->free_result(), - $stmt->close() + $mysqli->close(), + $stmt->free_result(), + $stmt->close() ); ?> diff --git a/ext/mysqli/tests/bug70384.phpt b/ext/mysqli/tests/bug70384.phpt index 0f062f003508..27b9d16f25a6 100644 --- a/ext/mysqli/tests/bug70384.phpt +++ b/ext/mysqli/tests/bug70384.phpt @@ -19,40 +19,40 @@ mysqli_float_handling - ensure 4 byte float is handled correctly ?> --FILE-- fetch_all(); - if (json_encode($rows[0][0]) != json_encode($jsfield_data)) { - printf("[006] Data differs"); - var_dump(json_encode($rows[0][0]) != json_encode($jsfield_data)); - die(); - } - mysqli_close($link); - echo "OK"; + if (!($res = mysqli_query($link, "SELECT * FROM test"))) { + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + die(); + } + $rows = $res->fetch_all(); + if (json_encode($rows[0][0]) != json_encode($jsfield_data)) { + printf("[006] Data differs"); + var_dump(json_encode($rows[0][0]) != json_encode($jsfield_data)); + die(); + } + mysqli_close($link); + echo "OK"; ?> --CLEAN-- prepare($sql)) { - $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); + $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); - if ($stmt->bind_result($name)) { - { - if ($stmt->execute()) - { - while ($stmt->fetch()) - { - var_dump($name); - } - } - } + if ($stmt->bind_result($name)) { + { + if ($stmt->execute()) + { + while ($stmt->fetch()) + { + var_dump($name); + } + } + } - $stmt->free_result(); - $stmt->close(); - } + $stmt->free_result(); + $stmt->close(); + } - $mysql->close(); + $mysql->close(); } ?> diff --git a/ext/mysqli/tests/bug72701.phpt b/ext/mysqli/tests/bug72701.phpt index 8e6873aa33c2..2145de9b48da 100644 --- a/ext/mysqli/tests/bug72701.phpt +++ b/ext/mysqli/tests/bug72701.phpt @@ -19,7 +19,7 @@ require_once("connect.inc"); $con = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); if (mysqli_connect_errno()) { - echo "Failed to connect to MySQL: " . mysqli_connect_error(); + echo "Failed to connect to MySQL: " . mysqli_connect_error(); } var_dump(preg_match(",(127.0.0.1|localhost) via .*,i", mysqli_get_host_info($con))); diff --git a/ext/mysqli/tests/bug73462.phpt b/ext/mysqli/tests/bug73462.phpt index f82115cf6c99..1aa18d7fb6d5 100644 --- a/ext/mysqli/tests/bug73462.phpt +++ b/ext/mysqli/tests/bug73462.phpt @@ -8,38 +8,38 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("SHOW STATUS LIKE 'Connections'"); - $c1 = $result->fetch_row(); - $result->free(); - $mysql_1->close(); + /* Initial persistent connection */ + $mysql_1 = new mysqli('p:'.$host, $user, $passwd, $db); + $result = $mysql_1->query("SHOW STATUS LIKE 'Connections'"); + $c1 = $result->fetch_row(); + $result->free(); + $mysql_1->close(); - /* Failed connection to invalid host */ - $mysql_2 = @new mysqli(' !!! invalid !!! ', $user, $passwd, $db); - try { - $mysql_2->close(); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + /* Failed connection to invalid host */ + $mysql_2 = @new mysqli(' !!! invalid !!! ', $user, $passwd, $db); + try { + $mysql_2->close(); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - /* Re-use persistent connection */ - $mysql_3 = new mysqli('p:'.$host, $user, $passwd, $db); - $error = mysqli_connect_errno(); - $result = $mysql_3->query("SHOW STATUS LIKE 'Connections'"); - $c3 = $result->fetch_row(); - $result->free(); - $mysql_3->close(); + /* Re-use persistent connection */ + $mysql_3 = new mysqli('p:'.$host, $user, $passwd, $db); + $error = mysqli_connect_errno(); + $result = $mysql_3->query("SHOW STATUS LIKE 'Connections'"); + $c3 = $result->fetch_row(); + $result->free(); + $mysql_3->close(); - if (end($c1) !== end($c3)) - printf("[001] Expected '%d' got '%d'.\n", end($c1), end($c3)); + if (end($c1) !== end($c3)) + printf("[001] Expected '%d' got '%d'.\n", end($c1), end($c3)); - if ($error !== 0) - printf("[002] Expected '0' got '%d'.\n", $error); + if ($error !== 0) + printf("[002] Expected '0' got '%d'.\n", $error); - print "done!"; + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/bug74547.phpt b/ext/mysqli/tests/bug74547.phpt index c7075f07aaf6..90d790dc9e2e 100644 --- a/ext/mysqli/tests/bug74547.phpt +++ b/ext/mysqli/tests/bug74547.phpt @@ -7,17 +7,17 @@ Bug #74547 mysqli::change_user() doesn't accept null as $database argument w/str ?> --FILE-- --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/bug74968.phpt b/ext/mysqli/tests/bug74968.phpt index f78fa92d83dd..e3e971eb1fe8 100644 --- a/ext/mysqli/tests/bug74968.phpt +++ b/ext/mysqli/tests/bug74968.phpt @@ -7,13 +7,13 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query("SELECT 1 as a")->fetch_object("test"); + $mysqli = new mysqli("$host:$port", $user, $passwd, $db); + abstract class test { + public $a; + } + $mysqli->query("SELECT 1 as a")->fetch_object("test"); ?> ==DONE== --EXPECTF-- diff --git a/ext/mysqli/tests/bug75018.phpt b/ext/mysqli/tests/bug75018.phpt index 3f719acd867a..28af0bb77c31 100644 --- a/ext/mysqli/tests/bug75018.phpt +++ b/ext/mysqli/tests/bug75018.phpt @@ -27,7 +27,7 @@ $sql = "SELECT bit_column_1 FROM $tbl"; $result = $mysqli->query($sql); while ($row = $result->fetch_assoc()) { - var_dump($row['bit_column_1']); + var_dump($row['bit_column_1']); } ?> diff --git a/ext/mysqli/tests/bug77956.phpt b/ext/mysqli/tests/bug77956.phpt index d2f74d7c01c5..d4bc06f93be5 100644 --- a/ext/mysqli/tests/bug77956.phpt +++ b/ext/mysqli/tests/bug77956.phpt @@ -19,27 +19,27 @@ if ($msg = check_local_infile_support($link, $engine)) mysqli.allow_local_infile=0 --FILE-- query("DROP TABLE IF EXISTS test")) { - printf("[002] [%d] %s\n", $link->errno, $link->error); - } - if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } - if (FALSE == file_put_contents('bug77956.data', "waa? meukee!")) - printf("[004] Failed to create CVS file\n"); - if (!$link->query("SELECT 1 FROM DUAL")) - printf("[005] [%d] %s\n", $link->errno, $link->error); - if (!$link->query("LOAD DATA LOCAL INFILE 'bug77956.data' INTO TABLE test")) { - printf("[006] [%d] %s\n", $link->errno, $link->error); - echo "done"; - } else { - echo "bug"; - } - $link->close(); + require_once("connect.inc"); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } + if (!$link->query("DROP TABLE IF EXISTS test")) { + printf("[002] [%d] %s\n", $link->errno, $link->error); + } + if (!$link->query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } + if (FALSE == file_put_contents('bug77956.data', "waa? meukee!")) + printf("[004] Failed to create CVS file\n"); + if (!$link->query("SELECT 1 FROM DUAL")) + printf("[005] [%d] %s\n", $link->errno, $link->error); + if (!$link->query("LOAD DATA LOCAL INFILE 'bug77956.data' INTO TABLE test")) { + printf("[006] [%d] %s\n", $link->errno, $link->error); + echo "done"; + } else { + echo "bug"; + } + $link->close(); ?> --CLEAN-- query("CREATE TABLE `bug_bits` (`inty` bigint(20) unsigned NOT NULL } $insertQuery = "INSERT INTO `bug_bits` VALUES (18446744073709551615, 18446744073709551615)". - ",(18446744073709551614, 18446744073709551614)". - ",(4294967296, 4294967296)". - ",(4294967295, 4294967295)". - ",(2147483648, 2147483648)". - ",(2147483647, 2147483647)". - ",(1, 1)"; + ",(18446744073709551614, 18446744073709551614)". + ",(4294967296, 4294967296)". + ",(4294967295, 4294967295)". + ",(2147483648, 2147483648)". + ",(2147483647, 2147483647)". + ",(1, 1)"; if (!$link->query($insertQuery)) { printf("[004] [%d] %s\n", $link->errno, $link->error); } @@ -37,7 +37,7 @@ if (!($res = $link->query("SELECT * FROM `bug_bits`"))) { } while ($row = $res->fetch_assoc()) { - var_dump($row); + var_dump($row); } $link->close(); diff --git a/ext/mysqli/tests/bug_mysql_49406.phpt b/ext/mysqli/tests/bug_mysql_49406.phpt index 74ea471702a2..73ca0ad882de 100644 --- a/ext/mysqli/tests/bug_mysql_49406.phpt +++ b/ext/mysqli/tests/bug_mysql_49406.phpt @@ -7,90 +7,90 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query($query)) - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!$res = $link->query($query)) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!$row = $res->fetch_row()) - printf("[003] No result, [%d] %s\n", $link->errno, $link->error); + if (!$row = $res->fetch_row()) + printf("[003] No result, [%d] %s\n", $link->errno, $link->error); - $res->free(); + $res->free(); - if ($row[0] != '2009-12-03') { - printf("[004] Expecting '2009-12-03' got '%s'\n", $row[0]); - } + if ($row[0] != '2009-12-03') { + printf("[004] Expecting '2009-12-03' got '%s'\n", $row[0]); + } - if (!$stmt = $link->prepare($query)) - printf("[005] [%d] %s\n", $link->errno, $link->error); + if (!$stmt = $link->prepare($query)) + printf("[005] [%d] %s\n", $link->errno, $link->error); - if (!$stmt->execute() || !$stmt->store_result()) - printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->execute() || !$stmt->store_result()) + printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); - $datatypes = array( - MYSQLI_TYPE_TINY => "TINY", - MYSQLI_TYPE_SHORT => "SHORT", - MYSQLI_TYPE_LONG => "LONG", - MYSQLI_TYPE_FLOAT => "FLOAT", - MYSQLI_TYPE_DOUBLE => "DOUBLE", - MYSQLI_TYPE_TIMESTAMP => "TIMESTAMP", - MYSQLI_TYPE_LONGLONG => "LONGLONG", - MYSQLI_TYPE_INT24 => "INT24", - MYSQLI_TYPE_DATE => "DATE", - MYSQLI_TYPE_TIME => "TIME", - MYSQLI_TYPE_DATETIME => "DATETIME", - MYSQLI_TYPE_YEAR => "YEAR", - MYSQLI_TYPE_ENUM => "ENUM", - MYSQLI_TYPE_SET => "SET", - MYSQLI_TYPE_TINY_BLOB => "TINYBLOB", - MYSQLI_TYPE_MEDIUM_BLOB => "MEDIUMBLOB", - MYSQLI_TYPE_LONG_BLOB => "LONGBLOB", - MYSQLI_TYPE_BLOB => "BLOB", - MYSQLI_TYPE_VAR_STRING => "VAR_STRING", - MYSQLI_TYPE_STRING => "STRING", - MYSQLI_TYPE_NULL => "NULL", - MYSQLI_TYPE_NEWDATE => "NEWDATE", - MYSQLI_TYPE_INTERVAL => "INTERVAL", - MYSQLI_TYPE_GEOMETRY => "GEOMETRY", - ); + $datatypes = array( + MYSQLI_TYPE_TINY => "TINY", + MYSQLI_TYPE_SHORT => "SHORT", + MYSQLI_TYPE_LONG => "LONG", + MYSQLI_TYPE_FLOAT => "FLOAT", + MYSQLI_TYPE_DOUBLE => "DOUBLE", + MYSQLI_TYPE_TIMESTAMP => "TIMESTAMP", + MYSQLI_TYPE_LONGLONG => "LONGLONG", + MYSQLI_TYPE_INT24 => "INT24", + MYSQLI_TYPE_DATE => "DATE", + MYSQLI_TYPE_TIME => "TIME", + MYSQLI_TYPE_DATETIME => "DATETIME", + MYSQLI_TYPE_YEAR => "YEAR", + MYSQLI_TYPE_ENUM => "ENUM", + MYSQLI_TYPE_SET => "SET", + MYSQLI_TYPE_TINY_BLOB => "TINYBLOB", + MYSQLI_TYPE_MEDIUM_BLOB => "MEDIUMBLOB", + MYSQLI_TYPE_LONG_BLOB => "LONGBLOB", + MYSQLI_TYPE_BLOB => "BLOB", + MYSQLI_TYPE_VAR_STRING => "VAR_STRING", + MYSQLI_TYPE_STRING => "STRING", + MYSQLI_TYPE_NULL => "NULL", + MYSQLI_TYPE_NEWDATE => "NEWDATE", + MYSQLI_TYPE_INTERVAL => "INTERVAL", + MYSQLI_TYPE_GEOMETRY => "GEOMETRY", + ); - $meta_res = $stmt->result_metadata(); - for ($field_idx = 0; $field_idx < $meta_res->field_count; $field_idx++) { - $field = $meta_res->fetch_field(); - printf("Field : %d\n", $field_idx); - printf("Name : %s\n", $field->name); - printf("Orgname : %s\n", $field->orgname); - printf("Table : %s\n", $field->table); - printf("Orgtable : %s\n", $field->orgtable); - printf("Maxlength : %d\n", $field->max_length); - printf("Length : %d\n", $field->length); - printf("Charsetnr : %d\n", $field->charsetnr); - printf("Flags : %d\n", $field->flags); - printf("Type : %d (%s)\n", $field->type, (isset($datatypes[$field->type])) ? $datatypes[$field->type] : 'unknown'); - printf("Decimals : %d\n", $field->decimals); - } + $meta_res = $stmt->result_metadata(); + for ($field_idx = 0; $field_idx < $meta_res->field_count; $field_idx++) { + $field = $meta_res->fetch_field(); + printf("Field : %d\n", $field_idx); + printf("Name : %s\n", $field->name); + printf("Orgname : %s\n", $field->orgname); + printf("Table : %s\n", $field->table); + printf("Orgtable : %s\n", $field->orgtable); + printf("Maxlength : %d\n", $field->max_length); + printf("Length : %d\n", $field->length); + printf("Charsetnr : %d\n", $field->charsetnr); + printf("Flags : %d\n", $field->flags); + printf("Type : %d (%s)\n", $field->type, (isset($datatypes[$field->type])) ? $datatypes[$field->type] : 'unknown'); + printf("Decimals : %d\n", $field->decimals); + } - $row_stmt = null; - if (!$stmt->bind_result($row_stmt) || !$stmt->fetch()) - printf("[007] [%d] %s\n", $stmt->errno, $stmt->error); + $row_stmt = null; + if (!$stmt->bind_result($row_stmt) || !$stmt->fetch()) + printf("[007] [%d] %s\n", $stmt->errno, $stmt->error); - if ($row[0] != $row_stmt) { - printf("[008] PS and non-PS results differ, dumping data\n"); - var_dump($row[0]); - var_dump($row_stmt); - } + if ($row[0] != $row_stmt) { + printf("[008] PS and non-PS results differ, dumping data\n"); + var_dump($row[0]); + var_dump($row_stmt); + } - $stmt->close(); - $link->close(); + $stmt->close(); + $link->close(); - echo "done"; + echo "done"; ?> --EXPECTF-- Field : %s diff --git a/ext/mysqli/tests/clean_table.inc b/ext/mysqli/tests/clean_table.inc index 86e5fcb37968..a3dc8b66debf 100644 --- a/ext/mysqli/tests/clean_table.inc +++ b/ext/mysqli/tests/clean_table.inc @@ -2,12 +2,12 @@ require_once('connect.inc'); if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); } if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { - printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_close($link); diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index c190e6f61fa8..439a7ab8f160 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -1,150 +1,150 @@ real_connect($host, $user, $passwd, $db, $port, $socket, $flags); - } else { - parent::__construct($host, $user, $passwd, $db, $port, $socket); - } - } - } - - function have_innodb($link) { - if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) && - ($row = $res->fetch_row()) && - !empty($row)) { - if ($row[1] == "DISABLED" || $row[1] == "NO") { - return false; - } - return true; - } else { - /* MySQL 5.6.1+ */ - if ($res = $link->query("SHOW ENGINES")) { - while ($row = $res->fetch_assoc()) { - if (!isset($row['Engine']) || !isset($row['Support'])) - return false; - - if (('InnoDB' == $row['Engine']) && - (('YES' == $row['Support']) || ('DEFAULT' == $row['Support'])) - ) { - return true; - } - } - return false; - } else { - return false; - } - } - return false; - } - - } else { - printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n"); - } - - function handle_catchable_fatal($errno, $error, $file, $line) { - static $errcodes = array(); - if (empty($errcodes)) { - $constants = get_defined_constants(); - foreach ($constants as $name => $value) { - if (substr($name, 0, 2) == "E_") - $errcodes[$value] = $name; - } - } - printf("[%s] %s in %s on line %s\n", - (isset($errcodes[$errno])) ? $errcodes[$errno] : $errno, - $error, $file, $line); - - return true; - } + /* + Default values are "localhost", "root", + database "test" and empty password. + Change the MYSQL_TEST environment values + if you want to use another configuration + */ + + $driver = new mysqli_driver; + + $host = getenv("MYSQL_TEST_HOST") ?: "localhost"; + $port = getenv("MYSQL_TEST_PORT") ?: 3306; + $user = getenv("MYSQL_TEST_USER") ?: "root"; + $passwd = getenv("MYSQL_TEST_PASSWD") ?: ""; + $db = getenv("MYSQL_TEST_DB") ?: "test"; + $engine = getenv("MYSQL_TEST_ENGINE") ?: "MyISAM"; + $socket = getenv("MYSQL_TEST_SOCKET") ?: null; + $skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ?: true; + $connect_flags = (int)getenv("MYSQL_TEST_CONNECT_FLAGS") ?: 0; + if ($socket) { + ini_set('mysqli.default_socket', $socket); + } + + /* Development setting: test experimal features and/or feature requests that never worked before? */ + $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? + ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) : + false; + + $IS_MYSQLND = stristr(mysqli_get_client_info(), "mysqlnd"); + + if (!function_exists('sys_get_temp_dir')) { + function sys_get_temp_dir() { + + if (!empty($_ENV['TMP'])) + return realpath( $_ENV['TMP'] ); + if (!empty($_ENV['TMPDIR'])) + return realpath( $_ENV['TMPDIR'] ); + if (!empty($_ENV['TEMP'])) + return realpath( $_ENV['TEMP'] ); + + $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); + if ($temp_file) { + $temp_dir = realpath(dirname($temp_file)); + unlink($temp_file); + return $temp_dir; + } + return FALSE; + } + } + + if (!function_exists('my_mysqli_connect')) { + + /** + * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible + * + * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)? + */ + function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { + global $connect_flags; + + $flags = $enable_env_flags? $connect_flags:0; + if ($flags !== 0) { + $link = mysqli_init(); + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) + $link = false; + } else { + $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket); + } + + return $link; + } + + /** + * Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible + * + * @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS) + */ + function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) { + global $connect_flags; + + if ($enable_env_flags) + $flags = $flags | $connect_flags; + + return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags); + } + + class my_mysqli extends mysqli { + public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) { + global $connect_flags; + + $flags = ($enable_env_flags) ? $connect_flags : 0; + + if ($flags !== false) { + parent::init(); + $this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags); + } else { + parent::__construct($host, $user, $passwd, $db, $port, $socket); + } + } + } + + function have_innodb($link) { + if (($res = $link->query("SHOW VARIABLES LIKE 'have_innodb'")) && + ($row = $res->fetch_row()) && + !empty($row)) { + if ($row[1] == "DISABLED" || $row[1] == "NO") { + return false; + } + return true; + } else { + /* MySQL 5.6.1+ */ + if ($res = $link->query("SHOW ENGINES")) { + while ($row = $res->fetch_assoc()) { + if (!isset($row['Engine']) || !isset($row['Support'])) + return false; + + if (('InnoDB' == $row['Engine']) && + (('YES' == $row['Support']) || ('DEFAULT' == $row['Support'])) + ) { + return true; + } + } + return false; + } else { + return false; + } + } + return false; + } + + } else { + printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n"); + } + + function handle_catchable_fatal($errno, $error, $file, $line) { + static $errcodes = array(); + if (empty($errcodes)) { + $constants = get_defined_constants(); + foreach ($constants as $name => $value) { + if (substr($name, 0, 2) == "E_") + $errcodes[$value] = $name; + } + } + printf("[%s] %s in %s on line %s\n", + (isset($errcodes[$errno])) ? $errcodes[$errno] : $errno, + $error, $file, $line); + + return true; + } ?> diff --git a/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt b/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt index b075df94d349..9c94aa6dfb97 100644 --- a/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt +++ b/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt @@ -8,17 +8,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- multi_query("SELECT 1"); + // Returns only one result set + $link->multi_query("SELECT 1"); var_dump($link->next_result()); // should return false var_dump($link->store_result()); // now what happens here!? - // Returns only one result set - $link->multi_query("SELECT 1"); + // Returns only one result set + $link->multi_query("SELECT 1"); var_dump($link->next_result()); var_dump($link->use_result()); diff --git a/ext/mysqli/tests/local_infile_tools.inc b/ext/mysqli/tests/local_infile_tools.inc index af66d4c20c5a..fef400d0a907 100644 --- a/ext/mysqli/tests/local_infile_tools.inc +++ b/ext/mysqli/tests/local_infile_tools.inc @@ -1,146 +1,146 @@ errno) { - return $link->error; - } - } - mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name)); - return ""; - } - - function create_standard_csv($offset, $verbose = true) { - // create a CVS file - $file = tempnam(sys_get_temp_dir(), 'mysqli_test'); - if (!$fp = fopen($file, 'w')) { - if ($verbose) - printf("[%03d + 1] Cannot create CVS file '%s'\n", $offset, $file); - return NULL; - } else { - /* Looks ugly? No, handy if you have crashes... */ - register_shutdown_function("shutdown_clean", $file); - } - - if (!fwrite($fp, "97;'x';\n") || - !fwrite($fp, "98;'y';\n") || - !fwrite($fp, "99;'z';\n")) { - if ($verbose) - printf("[%03d + 3] Cannot write CVS file '%s'\n", $offset, $file); - return NULL; - } - - fclose($fp); - - if (!chmod($file, 0644)) { - if ($verbose) - printf("[%03d + 4] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not be able to read it\n", - $offset, $file); - return NULL; - } - return $file; - } - - function try_handler($offset, $link, $file, $handler, $expected = null) { - - if ('default' == $handler) { - mysqli_set_local_infile_default($link); - } else if (!mysqli_set_local_infile_handler($link, $handler)) { - printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler); - return false; - } - printf("Callback set to '%s'\n", $handler); - - if (!mysqli_query($link, sprintf("DELETE FROM test"))) { - printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' - INTO TABLE test - FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' - LINES TERMINATED BY '\n'", - mysqli_real_escape_string($link, $file)))) { - printf("[%03d] LOAD DATA failed, [%d] %s\n", - $offset + 2, - mysqli_errno($link), mysqli_error($link)); - } - - if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) { - printf("[%03d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!is_array($expected)) - return true; - - foreach ($expected as $k => $values) { - if (!$tmp = mysqli_fetch_assoc($res)) { - printf("[%03d/%d] [%d] '%s'\n", $offset + 4, $k, mysqli_errno($link), mysqli_error($link)); - return false; - } - if ($values['id'] != $tmp['id']) { - printf("[%03d/%d] Expecting %s got %s\n", - $offset + 5, $k, - $values['id'], $tmp['id']); - return false; - } - if ($values['label'] != $tmp['label']) { - printf("[%03d/%d] Expecting %s got %s\n", - $offset + 6, $k, - $values['label'], $tmp['label']); - return false; - } - } - - if ($res && $tmp = mysqli_fetch_assoc($res)) { - printf("[%03d] More results than expected!\n", $offset + 7); - do { - var_dump($tmp); - } while ($tmp = mysqli_fetch_assoc($res)); - return false; - } - - if ($res) - mysqli_free_result($res); - - return true; - } + /* Utility function for mysqli_set_local_infile*.phpt tests */ + function shutdown_clean($file) { + if ($file) { + unlink($file); + } + } + + function check_local_infile_support($link, $engine, $table_name = 'test') { + + if (!$res = mysqli_query($link, 'SHOW VARIABLES LIKE "local_infile"')) + return "Cannot check if Server variable 'local_infile' is set to 'ON'"; + + $row = mysqli_fetch_assoc($res); + mysqli_free_result($res); + if ('ON' != $row['Value']) + return sprintf("Server variable 'local_infile' seems not set to 'ON', found '%s'", $row['Value']); + + if (!mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name))) { + return "Failed to drop old test table"; + } + + if (!mysqli_query($link, $sql = sprintf('CREATE TABLE %s(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=%s', + $table_name, $engine))) + return "Failed to create test table: $sql"; + + $file = create_standard_csv(1, false); + if (!$file) { + mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name)); + return "Cannot create CSV file"; + } + + if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' + INTO TABLE %s + FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' + LINES TERMINATED BY '\n'", + mysqli_real_escape_string($link, $file), + $table_name))) { + if (1148 == mysqli_errno($link)) { + mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name)); + return "Cannot test LOAD DATA LOCAL INFILE, [1148] The used command is not allowed with this MySQL version"; + } else if ($link->errno) { + return $link->error; + } + } + mysqli_query($link, sprintf('DROP TABLE IF EXISTS %s', $table_name)); + return ""; + } + + function create_standard_csv($offset, $verbose = true) { + // create a CVS file + $file = tempnam(sys_get_temp_dir(), 'mysqli_test'); + if (!$fp = fopen($file, 'w')) { + if ($verbose) + printf("[%03d + 1] Cannot create CVS file '%s'\n", $offset, $file); + return NULL; + } else { + /* Looks ugly? No, handy if you have crashes... */ + register_shutdown_function("shutdown_clean", $file); + } + + if (!fwrite($fp, "97;'x';\n") || + !fwrite($fp, "98;'y';\n") || + !fwrite($fp, "99;'z';\n")) { + if ($verbose) + printf("[%03d + 3] Cannot write CVS file '%s'\n", $offset, $file); + return NULL; + } + + fclose($fp); + + if (!chmod($file, 0644)) { + if ($verbose) + printf("[%03d + 4] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might not be able to read it\n", + $offset, $file); + return NULL; + } + return $file; + } + + function try_handler($offset, $link, $file, $handler, $expected = null) { + + if ('default' == $handler) { + mysqli_set_local_infile_default($link); + } else if (!mysqli_set_local_infile_handler($link, $handler)) { + printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler); + return false; + } + printf("Callback set to '%s'\n", $handler); + + if (!mysqli_query($link, sprintf("DELETE FROM test"))) { + printf("[%03d] Cannot remove records, [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' + INTO TABLE test + FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' + LINES TERMINATED BY '\n'", + mysqli_real_escape_string($link, $file)))) { + printf("[%03d] LOAD DATA failed, [%d] %s\n", + $offset + 2, + mysqli_errno($link), mysqli_error($link)); + } + + if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) { + printf("[%03d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!is_array($expected)) + return true; + + foreach ($expected as $k => $values) { + if (!$tmp = mysqli_fetch_assoc($res)) { + printf("[%03d/%d] [%d] '%s'\n", $offset + 4, $k, mysqli_errno($link), mysqli_error($link)); + return false; + } + if ($values['id'] != $tmp['id']) { + printf("[%03d/%d] Expecting %s got %s\n", + $offset + 5, $k, + $values['id'], $tmp['id']); + return false; + } + if ($values['label'] != $tmp['label']) { + printf("[%03d/%d] Expecting %s got %s\n", + $offset + 6, $k, + $values['label'], $tmp['label']); + return false; + } + } + + if ($res && $tmp = mysqli_fetch_assoc($res)) { + printf("[%03d] More results than expected!\n", $offset + 7); + do { + var_dump($tmp); + } while ($tmp = mysqli_fetch_assoc($res)); + return false; + } + + if ($res) + mysqli_free_result($res); + + return true; + } ?> diff --git a/ext/mysqli/tests/mysqli_affected_rows.phpt b/ext/mysqli/tests/mysqli_affected_rows.phpt index c74d0bc0ca4c..f89c56ef0ff4 100644 --- a/ext/mysqli/tests/mysqli_affected_rows.phpt +++ b/ext/mysqli/tests/mysqli_affected_rows.phpt @@ -8,115 +8,115 @@ mysqli_affected_rows() ?> --FILE-- $charset) { - if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $charset)))) - continue; - mysqli_free_result($res); - if (true !== ($tmp = mysqli_set_charset($link, $charset))) - printf("[026] Expecting boolean/true got %s/%s\n", - gettype($tmp), $tmp); - if (0 !== ($tmp = mysqli_affected_rows($link))) - printf("[027] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); - } + $charsets = array('utf8'); + foreach ($charsets as $k => $charset) { + if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $charset)))) + continue; + mysqli_free_result($res); + if (true !== ($tmp = mysqli_set_charset($link, $charset))) + printf("[026] Expecting boolean/true got %s/%s\n", + gettype($tmp), $tmp); + if (0 !== ($tmp = mysqli_affected_rows($link))) + printf("[027] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); + } - if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 2")) { - printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 2")) { + printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - if (0 !== ($tmp = mysqli_affected_rows($link))) - printf("[029] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = mysqli_affected_rows($link))) + printf("[029] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 100")) { - printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + if (!mysqli_query($link, "UPDATE test SET label = 'a' WHERE id = 100")) { + printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - if (0 !== ($tmp = mysqli_affected_rows($link))) - printf("[031] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = mysqli_affected_rows($link))) + printf("[031] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) - printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) + printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_close($link); + mysqli_close($link); - try { - mysqli_affected_rows($link); + try { + mysqli_affected_rows($link); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- affected_rows ?> --FILE-- affected_rows; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + $mysqli = new mysqli(); + try { + $mysqli->affected_rows; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } - if (0 !== ($tmp = $mysqli->affected_rows)) - printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = $mysqli->affected_rows)) + printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) - printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('DROP TABLE IF EXISTS test')) + printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine)) - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine)) + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a')")) - printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a')")) + printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (1 !== ($tmp = $mysqli->affected_rows)) - printf("[006] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + if (1 !== ($tmp = $mysqli->affected_rows)) + printf("[006] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented - $mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a')"); - if (-1 !== ($tmp = $mysqli->affected_rows)) - printf("[007] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); + // ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented + $mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a')"); + if (-1 !== ($tmp = $mysqli->affected_rows)) + printf("[007] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4")) - printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4")) + printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (2 !== ($tmp = $mysqli->affected_rows)) - printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); + if (2 !== ($tmp = $mysqli->affected_rows)) + printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) - printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("INSERT INTO test(id, label) VALUES (2, 'b'), (3, 'c')")) + printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (2 !== ($tmp = $mysqli->affected_rows)) - printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); + if (2 !== ($tmp = $mysqli->affected_rows)) + printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { - printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query("INSERT IGNORE INTO test(id, label) VALUES (1, 'a')")) { + printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); + } - if (1 !== ($tmp = $mysqli->affected_rows)) - printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + if (1 !== ($tmp = $mysqli->affected_rows)) + printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("INSERT INTO test(id, label) SELECT id + 10, label FROM test")) - printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("INSERT INTO test(id, label) SELECT id + 10, label FROM test")) + printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (4 !== ($tmp = $mysqli->affected_rows)) - printf("[015] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); + if (4 !== ($tmp = $mysqli->affected_rows)) + printf("[015] Expecting int/4, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("REPLACE INTO test(id, label) values (4, 'd')")) - printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("REPLACE INTO test(id, label) values (4, 'd')")) + printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (2 !== ($tmp = $mysqli->affected_rows)) - printf("[016] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); + if (2 !== ($tmp = $mysqli->affected_rows)) + printf("[016] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("REPLACE INTO test(id, label) values (5, 'e')")) - printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("REPLACE INTO test(id, label) values (5, 'e')")) + printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (1 !== ($tmp = $mysqli->affected_rows)) - printf("[018] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + if (1 !== ($tmp = $mysqli->affected_rows)) + printf("[018] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) - printf("[019] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) + printf("[019] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (1 !== ($tmp = $mysqli->affected_rows)) - printf("[020] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + if (1 !== ($tmp = $mysqli->affected_rows)) + printf("[020] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) { - printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 2")) { + printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); + } - if (0 !== ($tmp = $mysqli->affected_rows)) - printf("[022] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = $mysqli->affected_rows)) + printf("[022] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 100")) { - printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query("UPDATE test SET label = 'a' WHERE id = 100")) { + printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); + } - if (0 !== ($tmp = $mysqli->affected_rows)) - printf("[024] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = $mysqli->affected_rows)) + printf("[024] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) - printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('DROP TABLE IF EXISTS test')) + printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); - $mysqli->close(); + $mysqli->close(); - try { + try { $mysqli->affected_rows; } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- query("SELECT id FROM test WHERE id = 1")) - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!$row = mysqli_fetch_assoc($res)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } - if ($row['id'] != 1) { - printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); - } + if ($row['id'] != 1) { + printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } - $res->close(); - $link->close(); - } + $res->close(); + $link->close(); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; --CLEAN-- autocommit() ?> --FILE-- autocommit(true))) - printf("[002] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); + if (!is_bool($tmp = $mysqli->autocommit(true))) + printf("[002] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query('SET AUTOCOMMIT = 0')) - printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('SET AUTOCOMMIT = 0')) + printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - if ($tmp['auto_commit']) - printf("[005] Cannot turn off autocommit\n"); + $tmp = $res->fetch_assoc(); + $res->free_result(); + if ($tmp['auto_commit']) + printf("[005] Cannot turn off autocommit\n"); - if (true !== ($tmp = $mysqli->autocommit( true))) - printf("[006] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $mysqli->autocommit( true))) + printf("[006] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) - printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - if (!$tmp['auto_commit']) - printf("[008] Cannot turn on autocommit\n"); + if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) + printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); + if (!$tmp['auto_commit']) + printf("[008] Cannot turn on autocommit\n"); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) - printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('DROP TABLE IF EXISTS test')) + printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { - printf("[010] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { + printf("[010] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); + } - if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) - printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) + printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query('ROLLBACK')) - printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('ROLLBACK')) + printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) - printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) + printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); - if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) - printf("[014] Expecting 1 row in table test, found %d rows. [%d] %s\n", - $tmp['num'], $mysqli->errno, $mysqli->error); + if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) + printf("[014] Expecting 1 row in table test, found %d rows. [%d] %s\n", + $tmp['num'], $mysqli->errno, $mysqli->error); - $res->free_result(); + $res->free_result(); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) - printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('DROP TABLE IF EXISTS test')) + printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query('SET AUTOCOMMIT = 1')) - printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('SET AUTOCOMMIT = 1')) + printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) - printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$res = $mysqli->query('SELECT @@autocommit as auto_commit')) + printf("[017] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - if (!$tmp['auto_commit']) - printf("[018] Cannot turn on autocommit\n"); + $tmp = $res->fetch_assoc(); + $res->free_result(); + if (!$tmp['auto_commit']) + printf("[018] Cannot turn on autocommit\n"); - if (true !== ($tmp = $mysqli->autocommit( false))) - printf("[019] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $mysqli->autocommit( false))) + printf("[019] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { - printf("[020] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { + printf("[020] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); + } - if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) - printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) + printf("[021] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query('ROLLBACK')) - printf("[022] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('ROLLBACK')) + printf("[022] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) - printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - if (0 != $tmp['num']) - printf("[24] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); - $res->free_result(); + if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) + printf("[023] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + if (0 != $tmp['num']) + printf("[24] Expecting 0 rows in table test, found %d rows\n", $tmp['num']); + $res->free_result(); - if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) - printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) + printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$mysqli->query('COMMIT')) - printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('COMMIT')) + printf("[025] [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) - printf("[027] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) + printf("[027] [%d] %s\n", $mysqli->errno, $mysqli->error); - if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) - printf("[028] Expecting 1 row in table test, found %d rows. [%d] %s\n", - $tmp['num'], $mysqli->errno, $mysqli->error); - $res->free_result(); + if ((!$tmp = $res->fetch_assoc()) || (1 != $tmp['num'])) + printf("[028] Expecting 1 row in table test, found %d rows. [%d] %s\n", + $tmp['num'], $mysqli->errno, $mysqli->error); + $res->free_result(); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) - printf("[029] [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('DROP TABLE IF EXISTS test')) + printf("[029] [%d] %s\n", $mysqli->errno, $mysqli->error); - $mysqli->close(); + $mysqli->close(); - try { + try { $mysqli->autocommit(false); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- fetch_assoc()); - - /* valid flags */ - $flags = array(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); - - if (mysqli_get_server_version($link) >= 50605) { - $flags[] = MYSQLI_TRANS_START_READ_WRITE; - $flags[] = MYSQLI_TRANS_START_READ_ONLY; - } - - /* just coverage */ - foreach ($flags as $flag) { - if (!mysqli_begin_transaction($link, $flag, sprintf("flag %d", $flag))) { - printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - if (!mysqli_query($link, 'SELECT * FROM test') || !mysqli_rollback($link)) { - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - } - - /* does it really set a flag? */ - if (mysqli_get_server_version($link) >= 50605) { - if (!mysqli_begin_transaction($link, MYSQLI_TRANS_START_READ_ONLY, sprintf("flag %d", $flag))) { - printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - if (mysqli_query($link, "INSERT INTO test(id) VALUES (2)")) { - printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } else if (!mysqli_commit($link)) { - printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } else { - $res = mysqli_query($link, "SELECT id FROM test WHERE id = 2"); - } - } - - if (!mysqli_begin_transaction($link, -1)) { - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - - if (mysqli_get_server_version($link) >= 50605) { - /* does it like stupid names? */ - if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "*/trick me?\n\0")) - printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - /* does it like stupid names? */ - if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "az09")) - printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - - print "done!"; + require_once("connect.inc"); + /* {{{ proto bool mysqli_begin_transaction(object link, [int flags [, string name]]) */ + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[004] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) + printf("[009] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (true !== ($tmp = mysqli_autocommit($link, true))) + printf("[010] Cannot turn on autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); + + /* overrule autocommit */ + if (true !== ($tmp = mysqli_begin_transaction($link))) + printf("[011] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $tmp = mysqli_rollback($link); + if ($tmp !== true) + printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + /* empty */ + $res = mysqli_query($link, "SELECT * FROM test"); + var_dump($res->fetch_assoc()); + + /* valid flags */ + $flags = array(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); + + if (mysqli_get_server_version($link) >= 50605) { + $flags[] = MYSQLI_TRANS_START_READ_WRITE; + $flags[] = MYSQLI_TRANS_START_READ_ONLY; + } + + /* just coverage */ + foreach ($flags as $flag) { + if (!mysqli_begin_transaction($link, $flag, sprintf("flag %d", $flag))) { + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (!mysqli_query($link, 'SELECT * FROM test') || !mysqli_rollback($link)) { + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + } + + /* does it really set a flag? */ + if (mysqli_get_server_version($link) >= 50605) { + if (!mysqli_begin_transaction($link, MYSQLI_TRANS_START_READ_ONLY, sprintf("flag %d", $flag))) { + printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (mysqli_query($link, "INSERT INTO test(id) VALUES (2)")) { + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } else if (!mysqli_commit($link)) { + printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } else { + $res = mysqli_query($link, "SELECT id FROM test WHERE id = 2"); + } + } + + if (!mysqli_begin_transaction($link, -1)) { + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (mysqli_get_server_version($link) >= 50605) { + /* does it like stupid names? */ + if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "*/trick me?\n\0")) + printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + /* does it like stupid names? */ + if (@!$link->begin_transaction(MYSQLI_TRANS_START_READ_WRITE, "az09")) + printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[019] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1')) - printf("[020] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) - printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - mysqli_free_result($res); - if (1 != $tmp['test_var']) - printf("[022] Cannot set test variable\n"); - - if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db))) - printf("[023] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - - if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) - printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - mysqli_free_result($res); - - if (substr($tmp['user'], 0, strlen($user)) !== $user) - printf("[025] Expecting user %s, got user() %s\n", $user, $tmp['user']); - if ($tmp['dbname'] != $db) - printf("[026] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); - - if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) - printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - mysqli_free_result($res); - if (NULL !== $tmp['test_var']) - printf("[028] Test variable is still set!\n"); - - print "done!"; + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[019] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!mysqli_query($link, 'SET @mysqli_change_user_test_var=1')) + printf("[020] Failed to set test variable: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) + printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + if (1 != $tmp['test_var']) + printf("[022] Cannot set test variable\n"); + + if (true !== ($tmp = mysqli_change_user($link, $user, $passwd, $db))) + printf("[023] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + + if (!$res = mysqli_query($link, 'SELECT database() AS dbname, user() AS user')) + printf("[024] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + + if (substr($tmp['user'], 0, strlen($user)) !== $user) + printf("[025] Expecting user %s, got user() %s\n", $user, $tmp['user']); + if ($tmp['dbname'] != $db) + printf("[026] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); + + if (!$res = mysqli_query($link, 'SELECT @mysqli_change_user_test_var AS test_var')) + printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + if (NULL !== $tmp['test_var']) + printf("[028] Test variable is still set!\n"); + + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_change_user_get_lock.phpt b/ext/mysqli/tests/mysqli_change_user_get_lock.phpt index 4cc071d7ab63..75d0930a83b0 100644 --- a/ext/mysqli/tests/mysqli_change_user_get_lock.phpt +++ b/ext/mysqli/tests/mysqli_change_user_get_lock.phpt @@ -11,87 +11,87 @@ die("skip - is the server still buggy?"); max_execution_time=240 --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- fetch_assoc()); + if (!$res = mysqli_query($link, 'SELECT 1 AS _one')) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + else + var_dump($res->fetch_assoc()); - print "done!"; + print "done!"; ?> --EXPECT-- [003] [2006] MySQL server has gone away diff --git a/ext/mysqli/tests/mysqli_change_user_old.phpt b/ext/mysqli/tests/mysqli_change_user_old.phpt index a077d9c4b62b..314ff2e6df4e 100644 --- a/ext/mysqli/tests/mysqli_change_user_old.phpt +++ b/ext/mysqli/tests/mysqli_change_user_old.phpt @@ -15,98 +15,98 @@ if (mysqli_get_server_version($link) >= 50600) ?> --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_change_user_oo.phpt b/ext/mysqli/tests/mysqli_change_user_oo.phpt index 7707cca095f8..5ef86a144325 100644 --- a/ext/mysqli/tests/mysqli_change_user_oo.phpt +++ b/ext/mysqli/tests/mysqli_change_user_oo.phpt @@ -16,65 +16,65 @@ if (mysqli_get_server_version($link) >= 50600) ?> --FILE-- change_user($user . '_unknown_really', $passwd . 'non_empty', $db))) - printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db))) + printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = $mysqli->change_user($user, $passwd . '_unknown_really', $db))) - printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $mysqli->change_user($user, $passwd . '_unknown_really', $db))) + printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really'))) - printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $mysqli->change_user($user, $passwd, $db . '_unknown_really'))) + printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp); - // Reconnect because after 3 failed change_user attempts, the server blocks you off. - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + // Reconnect because after 3 failed change_user attempts, the server blocks you off. + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (!$mysqli->query('SET @mysqli_change_user_test_var=1')) - printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error); + if (!$mysqli->query('SET @mysqli_change_user_test_var=1')) + printf("[009] Failed to set test variable: [%d] %s\n", $mysqli->errno, $mysqli->error); - if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) - printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - if (1 != $tmp['test_var']) - printf("[011] Cannot set test variable\n"); + if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) + printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); + if (1 != $tmp['test_var']) + printf("[011] Cannot set test variable\n"); - if (true !== ($tmp = $mysqli->change_user($user, $passwd, $db))) - printf("[012] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $mysqli->change_user($user, $passwd, $db))) + printf("[012] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - if (!$res = $mysqli->query('SELECT database() AS dbname, user() AS user')) - printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); + if (!$res = $mysqli->query('SELECT database() AS dbname, user() AS user')) + printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); - if (substr($tmp['user'], 0, strlen($user)) !== $user) - printf("[014] Expecting user %s, got user() %s\n", $user, $tmp['user']); - if ($tmp['dbname'] != $db) - printf("[015] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); + if (substr($tmp['user'], 0, strlen($user)) !== $user) + printf("[014] Expecting user %s, got user() %s\n", $user, $tmp['user']); + if ($tmp['dbname'] != $db) + printf("[015] Expecting database %s, got database() %s\n", $db, $tmp['dbname']); - if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) - printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - if (NULL !== $tmp['test_var']) - printf("[017] Test variable is still set!\n"); + if (!$res = $mysqli->query('SELECT @mysqli_change_user_test_var AS test_var')) + printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); + if (NULL !== $tmp['test_var']) + printf("[017] Test variable is still set!\n"); - $mysqli->close(); + $mysqli->close(); - if (false !== ($tmp = @$mysqli->change_user($user, $passwd, $db))) - printf("[018] Expecting false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = @$mysqli->change_user($user, $passwd, $db))) + printf("[018] Expecting false, got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt b/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt index 1f3eacecebf2..4409d453ab2c 100644 --- a/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt +++ b/ext/mysqli/tests/mysqli_change_user_prepared_statements.phpt @@ -8,26 +8,26 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- execute() && $stmt->bind_result($wrong) && $stmt->fetch()) { - printf("This is wrong, because after a mysqli_change_user() %s\n", $wrong); - } else { - if ($stmt->errno == 0) - printf("Error code 2013, 1243 or similar should have been set\n"); - } + $wrong = null; + if ($stmt->execute() && $stmt->bind_result($wrong) && $stmt->fetch()) { + printf("This is wrong, because after a mysqli_change_user() %s\n", $wrong); + } else { + if ($stmt->errno == 0) + printf("Error code 2013, 1243 or similar should have been set\n"); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_change_user_rollback.phpt b/ext/mysqli/tests/mysqli_change_user_rollback.phpt index 1731abafef5c..19c4e36375fc 100644 --- a/ext/mysqli/tests/mysqli_change_user_rollback.phpt +++ b/ext/mysqli/tests/mysqli_change_user_rollback.phpt @@ -14,53 +14,53 @@ if (!have_innodb($link)) ?> --FILE-- 0); + $num = $row['_num']; + assert($num > 0); - if (!$res = mysqli_query($link, 'DELETE FROM test')) - printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, 'DELETE FROM test')) + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) - printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + if (!$row = mysqli_fetch_assoc($res)) + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); - if (0 != $row['_num']) - printf("[007] Rows should have been deleted in this transaction\n"); + if (0 != $row['_num']) + printf("[007] Rows should have been deleted in this transaction\n"); - // DELETE should be rolled back - mysqli_change_user($link, $user, $passwd, $db); + // DELETE should be rolled back + mysqli_change_user($link, $user, $passwd, $db); - if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$row = mysqli_fetch_assoc($res)) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if ($row['_num'] != $num) - printf("[010] Expecting %d rows in the table test, found %d rows\n", - $num, $row['_num']); + if ($row['_num'] != $num) + printf("[010] Expecting %d rows in the table test, found %d rows\n", + $num, $row['_num']); - mysqli_free_result($res); - mysqli_close($link); - print "done!"; + mysqli_free_result($res); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- $collation) { - - if (isset($not_changed['charset_client']) && - $charset != $not_changed['charset_client'] && - mysqli_query($link, sprintf("SET @@character_set_client = '%s'", $charset))) - unset($not_changed['charset_client']); - - if (isset($not_changed['charset_connection']) && - $charset != $not_changed['charset_connection'] && - mysqli_query($link, sprintf("SET @@character_connection = '%s'", $charset))) - unset($not_changed['charset_connection']); - - if (isset($not_changed['charset_results']) && - $charset != $not_changed['charset_results'] && - mysqli_query($link, sprintf("SET @@character_set_results = '%s'", $charset))) - unset($not_changed['charset_results']); - - if (isset($not_changed['collation_connection']) && - $collation != $not_changed['collation_connection'] && - mysqli_query($link, sprintf("SET @@collation_connection = '%s'", $collation))) - unset($not_changed['collation_connection']); - - if (isset($not_changed['collation_database']) && - $collation != $not_changed['collation_database'] && - mysqli_query($link, sprintf("SET @@collation_database = '%s'", $collation))) - unset($not_changed['collation_database']); - - if (isset($not_changed['collation_server']) && - $collation != $not_changed['collation_server'] && - mysqli_query($link, sprintf("SET @@collation_server = '%s'", $collation))) - unset($not_changed['collation_server']); - - if (empty($not_changed)) - break; - } - - if (!$res = mysqli_query($link, 'SELECT - @@character_set_client AS charset_client, - @@character_set_connection AS charset_connection, - @@character_set_results AS charset_results, - @@collation_connection AS collation_connection, - @@collation_database AS collation_database, - @@collation_server AS collation_server')) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!$modified = mysqli_fetch_assoc($res)) - printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); - - if ($modified == $defaults) - printf("[008] Not all settings have been changed\n"); - - // LAST_INSERT_ID should be reset - mysqli_change_user($link, $user, $passwd, $db); - - if (!$res = mysqli_query($link, 'SELECT - @@character_set_client AS charset_client, - @@character_set_connection AS charset_connection, - @@character_set_results AS charset_results, - @@collation_connection AS collation_connection, - @@collation_database AS collation_database, - @@collation_server AS collation_server')) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!$new = mysqli_fetch_assoc($res)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); - - if ($new == $modified) { - printf("[011] Charsets/collations have not been reset.\n"); - printf("Got:\n"); - var_dump($new); - printf("Expected:\n"); - var_dump($defaults); - } - - if ($new != $defaults) { - printf("[012] Charsets/collations have not been reset to their defaults.\n"); - printf("Got:\n"); - var_dump($new); - printf("Expected:\n"); - var_dump($defaults); - } - - if (!is_object($charset = mysqli_get_charset($link))) - printf("[013] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); - - if ($charset->charset != $defaults['charset_connection']) - printf("[014] Expecting connection charset to be %s got %s\n", - $defaults['charset_connection'], - $charset->charset); - - if ($charset->collation != $defaults['collation_connection']) - printf("[015] Expecting collation to be %s got %s\n", - $defaults['collation_connection'], - $charset->collation); - - mysqli_close($link); - print "done!"; + require_once('connect.inc'); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + if (!$res = mysqli_query($link, "SHOW CHARACTER SET LIKE 'latin%'")) + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $charsets = array(); + while ($row = mysqli_fetch_assoc($res)) + $charsets[$row['Charset']] = $row['Default collation']; + + mysqli_free_result($res); + if (!mysqli_query($link, 'SET NAMES DEFAULT')) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$res = mysqli_query($link, 'SELECT + @@character_set_client AS charset_client, + @@character_set_connection AS charset_connection, + @@character_set_results AS charset_results, + @@collation_connection AS collation_connection, + @@collation_database AS collation_database, + @@collation_server AS collation_server')) + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$defaults = mysqli_fetch_assoc($res)) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + + $not_changed = $defaults; + foreach ($charsets as $charset => $collation) { + + if (isset($not_changed['charset_client']) && + $charset != $not_changed['charset_client'] && + mysqli_query($link, sprintf("SET @@character_set_client = '%s'", $charset))) + unset($not_changed['charset_client']); + + if (isset($not_changed['charset_connection']) && + $charset != $not_changed['charset_connection'] && + mysqli_query($link, sprintf("SET @@character_connection = '%s'", $charset))) + unset($not_changed['charset_connection']); + + if (isset($not_changed['charset_results']) && + $charset != $not_changed['charset_results'] && + mysqli_query($link, sprintf("SET @@character_set_results = '%s'", $charset))) + unset($not_changed['charset_results']); + + if (isset($not_changed['collation_connection']) && + $collation != $not_changed['collation_connection'] && + mysqli_query($link, sprintf("SET @@collation_connection = '%s'", $collation))) + unset($not_changed['collation_connection']); + + if (isset($not_changed['collation_database']) && + $collation != $not_changed['collation_database'] && + mysqli_query($link, sprintf("SET @@collation_database = '%s'", $collation))) + unset($not_changed['collation_database']); + + if (isset($not_changed['collation_server']) && + $collation != $not_changed['collation_server'] && + mysqli_query($link, sprintf("SET @@collation_server = '%s'", $collation))) + unset($not_changed['collation_server']); + + if (empty($not_changed)) + break; + } + + if (!$res = mysqli_query($link, 'SELECT + @@character_set_client AS charset_client, + @@character_set_connection AS charset_connection, + @@character_set_results AS charset_results, + @@collation_connection AS collation_connection, + @@collation_database AS collation_database, + @@collation_server AS collation_server')) + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$modified = mysqli_fetch_assoc($res)) + printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + + if ($modified == $defaults) + printf("[008] Not all settings have been changed\n"); + + // LAST_INSERT_ID should be reset + mysqli_change_user($link, $user, $passwd, $db); + + if (!$res = mysqli_query($link, 'SELECT + @@character_set_client AS charset_client, + @@character_set_connection AS charset_connection, + @@character_set_results AS charset_results, + @@collation_connection AS collation_connection, + @@collation_database AS collation_database, + @@collation_server AS collation_server')) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$new = mysqli_fetch_assoc($res)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + + if ($new == $modified) { + printf("[011] Charsets/collations have not been reset.\n"); + printf("Got:\n"); + var_dump($new); + printf("Expected:\n"); + var_dump($defaults); + } + + if ($new != $defaults) { + printf("[012] Charsets/collations have not been reset to their defaults.\n"); + printf("Got:\n"); + var_dump($new); + printf("Expected:\n"); + var_dump($defaults); + } + + if (!is_object($charset = mysqli_get_charset($link))) + printf("[013] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); + + if ($charset->charset != $defaults['charset_connection']) + printf("[014] Expecting connection charset to be %s got %s\n", + $defaults['charset_connection'], + $charset->charset); + + if ($charset->collation != $defaults['collation_connection']) + printf("[015] Expecting collation to be %s got %s\n", + $defaults['collation_connection'], + $charset->collation); + + mysqli_close($link); + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_character_set.phpt b/ext/mysqli/tests/mysqli_character_set.phpt index 855141e40dd0..ee09719b64d8 100644 --- a/ext/mysqli/tests/mysqli_character_set.phpt +++ b/ext/mysqli/tests/mysqli_character_set.phpt @@ -12,92 +12,92 @@ if (!function_exists('mysqli_set_charset')) { ?> --FILE-- --CLEAN-- --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; --EXPECT-- mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt index b29fb7fc2db3..cedc138e687a 100644 --- a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt +++ b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt @@ -8,53 +8,53 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias] ?> --FILE-- query('SELECT version() AS server_version')) - printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - $version = explode('.', $tmp['server_version']); - if (empty($version)) - printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); + if (!$res = $mysqli->query('SELECT version() AS server_version')) + printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); + $version = explode('.', $tmp['server_version']); + if (empty($version)) + printf("[006] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); - if ($version[0] <= 4 && $version[1] < 1) - printf("[007] Need MySQL Server 4.1+ for the test!\n"); + if ($version[0] <= 4 && $version[1] < 1) + printf("[007] Need MySQL Server 4.1+ for the test!\n"); - if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) - printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - if (!$tmp['charset']) - printf("[009] Cannot determine current character set and collation\n"); + if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) + printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); + if (!$tmp['charset']) + printf("[009] Cannot determine current character set and collation\n"); - $charset = $mysqli->character_set_name(); - if ($tmp['charset'] !== $charset) { - if ($tmp['collation'] === $charset) { - printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", - $tmp['collation'], $tmp['charset'], gettype($charset), $charset); - } else { - printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); - } - } + $charset = $mysqli->character_set_name(); + if ($tmp['charset'] !== $charset) { + if ($tmp['collation'] === $charset) { + printf("[010] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n", + $tmp['collation'], $tmp['charset'], gettype($charset), $charset); + } else { + printf("[011] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset); + } + } - $charset2 = $mysqli->character_set_name(); - if ($charset2 !== $charset) { - printf("[012] Alias mysqli_character_set_name returned %s/%s, expected %s/%s\n", - gettype($charset2), $charset2, gettype($charset), $charset); - } + $charset2 = $mysqli->character_set_name(); + if ($charset2 !== $charset) { + printf("[012] Alias mysqli_character_set_name returned %s/%s, expected %s/%s\n", + gettype($charset2), $charset2, gettype($charset), $charset); + } - $mysqli->close(); + $mysqli->close(); - try { + try { $mysqli->character_set_name(); } catch (Error $exception) { echo $exception->getMessage() . "\n"; @@ -66,7 +66,7 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias] echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; --EXPECT-- my_mysqli object is already closed my_mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt index 78784210bb68..27cf9f0fc62a 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_driver_interface.phpt @@ -8,80 +8,80 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- $method) { - if (isset($expected_methods[$method])) { - unset($expected_methods[$method]); - unset($methods[$k]); - } - } - if (!empty($expected_methods)) { - printf("Dumping list of missing methods.\n"); - var_dump($expected_methods); - } - if (!empty($methods)) { - printf("Dumping list of unexpected methods.\n"); - var_dump($methods); - } - if (empty($expected_methods) && empty($methods)) - printf("ok\n"); - - printf("\nClass variables:\n"); - $variables = array_keys(get_class_vars(get_class($driver))); - sort($variables); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nObject variables:\n"); - $variables = array_keys(get_object_vars($driver)); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nMagic, magic properties:\n"); - - assert(mysqli_get_client_info() === $driver->client_info); - printf("driver->client_info = '%s'\n", $driver->client_info); - - assert(mysqli_get_client_version() === $driver->client_version); - printf("driver->client_version = '%s'\n", $driver->client_version); - - assert($driver->driver_version > 0); - printf("driver->driver_version = '%s'\n", $driver->driver_version); - - assert(in_array($driver->report_mode, - array( - MYSQLI_REPORT_ALL, - MYSQLI_REPORT_STRICT, - MYSQLI_REPORT_ERROR, - MYSQLI_REPORT_INDEX, - MYSQLI_REPORT_OFF - ) - )); - - printf("driver->report_mode = '%s'\n", $driver->report_mode); - $driver->report_mode = MYSQLI_REPORT_STRICT; - assert($driver->report_mode === MYSQLI_REPORT_STRICT); - - assert(is_bool($driver->embedded)); - printf("driver->embedded = '%s'\n", $driver->embedded); - - printf("driver->reconnect = '%s'\n", $driver->reconnect); - - printf("\nAccess to undefined properties:\n"); - printf("driver->unknown = '%s'\n", @$driver->unknown); - - print "done!"; + require('connect.inc'); + require('table.inc'); + + $driver = new mysqli_driver(); + + printf("Parent class:\n"); + var_dump(get_parent_class($driver)); + + printf("\nMethods:\n"); + $methods = get_class_methods($driver); + $expected_methods = array(); + + foreach ($methods as $k => $method) { + if (isset($expected_methods[$method])) { + unset($expected_methods[$method]); + unset($methods[$k]); + } + } + if (!empty($expected_methods)) { + printf("Dumping list of missing methods.\n"); + var_dump($expected_methods); + } + if (!empty($methods)) { + printf("Dumping list of unexpected methods.\n"); + var_dump($methods); + } + if (empty($expected_methods) && empty($methods)) + printf("ok\n"); + + printf("\nClass variables:\n"); + $variables = array_keys(get_class_vars(get_class($driver))); + sort($variables); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nObject variables:\n"); + $variables = array_keys(get_object_vars($driver)); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nMagic, magic properties:\n"); + + assert(mysqli_get_client_info() === $driver->client_info); + printf("driver->client_info = '%s'\n", $driver->client_info); + + assert(mysqli_get_client_version() === $driver->client_version); + printf("driver->client_version = '%s'\n", $driver->client_version); + + assert($driver->driver_version > 0); + printf("driver->driver_version = '%s'\n", $driver->driver_version); + + assert(in_array($driver->report_mode, + array( + MYSQLI_REPORT_ALL, + MYSQLI_REPORT_STRICT, + MYSQLI_REPORT_ERROR, + MYSQLI_REPORT_INDEX, + MYSQLI_REPORT_OFF + ) + )); + + printf("driver->report_mode = '%s'\n", $driver->report_mode); + $driver->report_mode = MYSQLI_REPORT_STRICT; + assert($driver->report_mode === MYSQLI_REPORT_STRICT); + + assert(is_bool($driver->embedded)); + printf("driver->embedded = '%s'\n", $driver->embedded); + + printf("driver->reconnect = '%s'\n", $driver->reconnect); + + printf("\nAccess to undefined properties:\n"); + printf("driver->unknown = '%s'\n", @$driver->unknown); + + print "done!"; ?> --EXPECTF-- Parent class: diff --git a/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt index 7b6c0a65d9ce..5d125dda845f 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt @@ -16,10 +16,10 @@ if (!$IS_MYSQLND) ?> --FILE-- --EXPECTF-- Inspecting class 'mysqli_driver' diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt index dfefb9098c17..794f8eb241c0 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt @@ -8,257 +8,257 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- true, - 'autocommit' => true, - 'begin_transaction' => true, - 'change_user' => true, - 'character_set_name' => true, - 'close' => true, - 'commit' => true, - 'connect' => true, - 'dump_debug_info' => true, - 'escape_string' => true, - 'get_charset' => true, - 'get_client_info' => true, - 'get_server_info' => true, - 'get_warnings' => true, - 'init' => true, - 'kill' => true, - 'more_results' => true, - 'multi_query' => true, - 'next_result' => true, - 'options' => true, - 'ping' => true, - 'prepare' => true, - 'query' => true, - 'real_connect' => true, - 'real_escape_string' => true, - 'real_query' => true, - 'refresh' => true, - 'rollback' => true, - 'release_savepoint' => true, - 'savepoint' => true, - 'select_db' => true, - 'set_charset' => true, - 'set_opt' => true, - 'ssl_set' => true, - 'stat' => true, - 'stmt_init' => true, - 'store_result' => true, - 'thread_safe' => true, - 'use_result' => true, - ); - - if ($IS_MYSQLND) { - // mysqlnd only - /* $expected_methods['get_client_stats'] = true; */ - $expected_methods['get_connection_stats'] = true; - $expected_methods['reap_async_query'] = true; - $expected_methods['poll'] = true; - } - - /* we should add ruled when to expect them */ - if (function_exists('mysqli_debug')) - $expected_methods['debug'] = true; - if (function_exists('ssl_set')) - $expected_methods['ssl_set'] = true; - - foreach ($methods as $k => $method) { - if (isset($expected_methods[$method])) { - unset($methods[$k]); - unset($expected_methods[$method]); - } - } - if (!empty($methods)) { - printf("Dumping list of unexpected methods.\n"); - var_dump($methods); - } - if (!empty($expected_methods)) { - printf("Dumping list of missing methods.\n"); - var_dump($expected_methods); - } - if (empty($methods) && empty($expected_methods)) - printf("ok\n"); - - printf("\nClass variables:\n"); - - $expected_class_variables = $expected_object_variables = array( - "affected_rows" => true, - "client_info" => true, - "client_version" => true, - "connect_errno" => true, - "connect_error" => true, - "errno" => true, - "error" => true, - "field_count" => true, - "host_info" => true, - "info" => true, - "insert_id" => true, - "protocol_version" => true, - "server_info" => true, - "server_version" => true, - "sqlstate" => true, - "thread_id" => true, - "warning_count" => true, - ); - - $expected_class_variables["error_list"] = true; - $expected_object_variables["error_list"] = true; - - $variables = get_class_vars(get_class($mysqli)); - foreach ($variables as $var => $v) { - if (isset($expected_class_variables[$var])) { - unset($expected_class_variables[$var]); - unset($variables[$var]); - } - } - - if (!empty($expected_class_variables)) { - printf("Dumping list of missing class variables\n"); - var_dump($expected_class_variables); - } - if (!empty($variables)) { - printf("Dumping list of unexpected class variables\n"); - var_dump($variables); - } - echo "ok\n"; - - printf("\nObject variables:\n"); - $variables = get_object_vars($mysqli); - foreach ($variables as $var => $v) { - if (isset($expected_object_variables[$var])) { - unset($expected_object_variables[$var]); - unset($variables[$var]); - } - } - - if (!empty($expected_object_variables)) { - printf("Dumping list of missing object variables\n"); - var_dump($expected_object_variables); - } - if (!empty($variables)) { - printf("Dumping list of unexpected object variables\n"); - var_dump($variables); - } - echo "ok\n"; - - - printf("\nMagic, magic properties:\n"); - - assert(mysqli_affected_rows($link) === $mysqli->affected_rows); - printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", - $mysqli->affected_rows, gettype($mysqli->affected_rows), - mysqli_affected_rows($link), gettype(mysqli_affected_rows($link))); - - assert(mysqli_get_client_info() === $mysqli->client_info); - printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", - $mysqli->client_info, gettype($mysqli->client_info), - mysqli_get_client_info(), gettype(mysqli_get_client_info())); - - assert(mysqli_get_client_version() === $mysqli->client_version); - printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", - $mysqli->client_version, gettype($mysqli->client_version), - mysqli_get_client_version(), gettype(mysqli_get_client_version())); - - assert(mysqli_errno($link) === $mysqli->errno); - printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", - $mysqli->errno, gettype($mysqli->errno), - mysqli_errno($link), gettype(mysqli_errno($link))); - - assert(mysqli_error($link) === $mysqli->error); - printf("mysqli->error = '%s'/%s ('%s'/%s)\n", - $mysqli->error, gettype($mysqli->error), - mysqli_error($link), gettype(mysqli_error($link))); - - assert(mysqli_error_list($link) === $mysqli->error_list); - assert(is_array($mysqli->error_list)); - - assert(mysqli_field_count($link) === $mysqli->field_count); - printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", - $mysqli->field_count, gettype($mysqli->field_count), - mysqli_field_count($link), gettype(mysqli_field_count($link))); - - assert(mysqli_insert_id($link) === $mysqli->insert_id); - printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", - $mysqli->insert_id, gettype($mysqli->insert_id), - mysqli_insert_id($link), gettype(mysqli_insert_id($link))); - - assert(mysqli_sqlstate($link) === $mysqli->sqlstate); - printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", - $mysqli->sqlstate, gettype($mysqli->sqlstate), - mysqli_sqlstate($link), gettype(mysqli_sqlstate($link))); - - assert(mysqli_get_host_info($link) === $mysqli->host_info); - printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", - $mysqli->host_info, gettype($mysqli->host_info), - mysqli_get_host_info($link), gettype(mysqli_get_host_info($link))); - - /* note that the data types are different */ - assert(mysqli_info($link) == $mysqli->info); - printf("mysqli->info = '%s'/%s ('%s'/%s)\n", - $mysqli->info, gettype($mysqli->info), - mysqli_info($link), gettype(mysqli_info($link))); - - assert(mysqli_thread_id($link) > $mysqli->thread_id); - assert(gettype($mysqli->thread_id) == gettype(mysqli_thread_id($link))); - printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", - $mysqli->thread_id, gettype($mysqli->thread_id), - mysqli_thread_id($link), gettype(mysqli_thread_id($link))); - - assert(mysqli_get_proto_info($link) === $mysqli->protocol_version); - printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", - $mysqli->protocol_version, gettype($mysqli->protocol_version), - mysqli_get_proto_info($link), gettype(mysqli_get_proto_info($link))); - - assert(mysqli_get_server_info($link) === $mysqli->server_info); - printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", - $mysqli->server_info, gettype($mysqli->server_info), - mysqli_get_server_info($link), gettype(mysqli_get_server_info($link))); - - assert(mysqli_get_server_version($link) === $mysqli->server_version); - printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", - $mysqli->server_version, gettype($mysqli->server_version), - mysqli_get_server_version($link), gettype(mysqli_get_server_version($link))); - - assert(mysqli_warning_count($link) === $mysqli->warning_count); - printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", - $mysqli->warning_count, gettype($mysqli->warning_count), - mysqli_warning_count($link), gettype(mysqli_warning_count($link))); - - printf("\nAccess to undefined properties:\n"); - printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); - - @$mysqli->unknown = 13; - printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); - - $unknown = 'friday'; - @$mysqli->unknown = $unknown; - printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); - - $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); - printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); - assert(mysqli_connect_error() === $mysqli->connect_error); - printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", - $mysqli->connect_error, gettype($mysqli->connect_error), - mysqli_connect_error(), gettype(mysqli_connect_error())); - - assert(mysqli_connect_errno() === $mysqli->connect_errno); - printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", - $mysqli->connect_errno, gettype($mysqli->connect_errno), - mysqli_connect_errno(), gettype(mysqli_connect_errno())); - - print "done!"; + require('connect.inc'); + + $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket); + $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); + + printf("Parent class:\n"); + var_dump(get_parent_class($mysqli)); + + printf("\nMethods:\n"); + $methods = get_class_methods($mysqli); + $expected_methods = array( + '__construct' => true, + 'autocommit' => true, + 'begin_transaction' => true, + 'change_user' => true, + 'character_set_name' => true, + 'close' => true, + 'commit' => true, + 'connect' => true, + 'dump_debug_info' => true, + 'escape_string' => true, + 'get_charset' => true, + 'get_client_info' => true, + 'get_server_info' => true, + 'get_warnings' => true, + 'init' => true, + 'kill' => true, + 'more_results' => true, + 'multi_query' => true, + 'next_result' => true, + 'options' => true, + 'ping' => true, + 'prepare' => true, + 'query' => true, + 'real_connect' => true, + 'real_escape_string' => true, + 'real_query' => true, + 'refresh' => true, + 'rollback' => true, + 'release_savepoint' => true, + 'savepoint' => true, + 'select_db' => true, + 'set_charset' => true, + 'set_opt' => true, + 'ssl_set' => true, + 'stat' => true, + 'stmt_init' => true, + 'store_result' => true, + 'thread_safe' => true, + 'use_result' => true, + ); + + if ($IS_MYSQLND) { + // mysqlnd only + /* $expected_methods['get_client_stats'] = true; */ + $expected_methods['get_connection_stats'] = true; + $expected_methods['reap_async_query'] = true; + $expected_methods['poll'] = true; + } + + /* we should add ruled when to expect them */ + if (function_exists('mysqli_debug')) + $expected_methods['debug'] = true; + if (function_exists('ssl_set')) + $expected_methods['ssl_set'] = true; + + foreach ($methods as $k => $method) { + if (isset($expected_methods[$method])) { + unset($methods[$k]); + unset($expected_methods[$method]); + } + } + if (!empty($methods)) { + printf("Dumping list of unexpected methods.\n"); + var_dump($methods); + } + if (!empty($expected_methods)) { + printf("Dumping list of missing methods.\n"); + var_dump($expected_methods); + } + if (empty($methods) && empty($expected_methods)) + printf("ok\n"); + + printf("\nClass variables:\n"); + + $expected_class_variables = $expected_object_variables = array( + "affected_rows" => true, + "client_info" => true, + "client_version" => true, + "connect_errno" => true, + "connect_error" => true, + "errno" => true, + "error" => true, + "field_count" => true, + "host_info" => true, + "info" => true, + "insert_id" => true, + "protocol_version" => true, + "server_info" => true, + "server_version" => true, + "sqlstate" => true, + "thread_id" => true, + "warning_count" => true, + ); + + $expected_class_variables["error_list"] = true; + $expected_object_variables["error_list"] = true; + + $variables = get_class_vars(get_class($mysqli)); + foreach ($variables as $var => $v) { + if (isset($expected_class_variables[$var])) { + unset($expected_class_variables[$var]); + unset($variables[$var]); + } + } + + if (!empty($expected_class_variables)) { + printf("Dumping list of missing class variables\n"); + var_dump($expected_class_variables); + } + if (!empty($variables)) { + printf("Dumping list of unexpected class variables\n"); + var_dump($variables); + } + echo "ok\n"; + + printf("\nObject variables:\n"); + $variables = get_object_vars($mysqli); + foreach ($variables as $var => $v) { + if (isset($expected_object_variables[$var])) { + unset($expected_object_variables[$var]); + unset($variables[$var]); + } + } + + if (!empty($expected_object_variables)) { + printf("Dumping list of missing object variables\n"); + var_dump($expected_object_variables); + } + if (!empty($variables)) { + printf("Dumping list of unexpected object variables\n"); + var_dump($variables); + } + echo "ok\n"; + + + printf("\nMagic, magic properties:\n"); + + assert(mysqli_affected_rows($link) === $mysqli->affected_rows); + printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", + $mysqli->affected_rows, gettype($mysqli->affected_rows), + mysqli_affected_rows($link), gettype(mysqli_affected_rows($link))); + + assert(mysqli_get_client_info() === $mysqli->client_info); + printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", + $mysqli->client_info, gettype($mysqli->client_info), + mysqli_get_client_info(), gettype(mysqli_get_client_info())); + + assert(mysqli_get_client_version() === $mysqli->client_version); + printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n", + $mysqli->client_version, gettype($mysqli->client_version), + mysqli_get_client_version(), gettype(mysqli_get_client_version())); + + assert(mysqli_errno($link) === $mysqli->errno); + printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", + $mysqli->errno, gettype($mysqli->errno), + mysqli_errno($link), gettype(mysqli_errno($link))); + + assert(mysqli_error($link) === $mysqli->error); + printf("mysqli->error = '%s'/%s ('%s'/%s)\n", + $mysqli->error, gettype($mysqli->error), + mysqli_error($link), gettype(mysqli_error($link))); + + assert(mysqli_error_list($link) === $mysqli->error_list); + assert(is_array($mysqli->error_list)); + + assert(mysqli_field_count($link) === $mysqli->field_count); + printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", + $mysqli->field_count, gettype($mysqli->field_count), + mysqli_field_count($link), gettype(mysqli_field_count($link))); + + assert(mysqli_insert_id($link) === $mysqli->insert_id); + printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", + $mysqli->insert_id, gettype($mysqli->insert_id), + mysqli_insert_id($link), gettype(mysqli_insert_id($link))); + + assert(mysqli_sqlstate($link) === $mysqli->sqlstate); + printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", + $mysqli->sqlstate, gettype($mysqli->sqlstate), + mysqli_sqlstate($link), gettype(mysqli_sqlstate($link))); + + assert(mysqli_get_host_info($link) === $mysqli->host_info); + printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", + $mysqli->host_info, gettype($mysqli->host_info), + mysqli_get_host_info($link), gettype(mysqli_get_host_info($link))); + + /* note that the data types are different */ + assert(mysqli_info($link) == $mysqli->info); + printf("mysqli->info = '%s'/%s ('%s'/%s)\n", + $mysqli->info, gettype($mysqli->info), + mysqli_info($link), gettype(mysqli_info($link))); + + assert(mysqli_thread_id($link) > $mysqli->thread_id); + assert(gettype($mysqli->thread_id) == gettype(mysqli_thread_id($link))); + printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", + $mysqli->thread_id, gettype($mysqli->thread_id), + mysqli_thread_id($link), gettype(mysqli_thread_id($link))); + + assert(mysqli_get_proto_info($link) === $mysqli->protocol_version); + printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", + $mysqli->protocol_version, gettype($mysqli->protocol_version), + mysqli_get_proto_info($link), gettype(mysqli_get_proto_info($link))); + + assert(mysqli_get_server_info($link) === $mysqli->server_info); + printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", + $mysqli->server_info, gettype($mysqli->server_info), + mysqli_get_server_info($link), gettype(mysqli_get_server_info($link))); + + assert(mysqli_get_server_version($link) === $mysqli->server_version); + printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", + $mysqli->server_version, gettype($mysqli->server_version), + mysqli_get_server_version($link), gettype(mysqli_get_server_version($link))); + + assert(mysqli_warning_count($link) === $mysqli->warning_count); + printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", + $mysqli->warning_count, gettype($mysqli->warning_count), + mysqli_warning_count($link), gettype(mysqli_warning_count($link))); + + printf("\nAccess to undefined properties:\n"); + printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); + + @$mysqli->unknown = 13; + printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); + + $unknown = 'friday'; + @$mysqli->unknown = $unknown; + printf("setting mysqli->unknown, mysqli_unknown = '%s'\n", @$mysqli->unknown); + + $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); + assert(mysqli_connect_error() === $mysqli->connect_error); + printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", + $mysqli->connect_error, gettype($mysqli->connect_error), + mysqli_connect_error(), gettype(mysqli_connect_error())); + + assert(mysqli_connect_errno() === $mysqli->connect_errno); + printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", + $mysqli->connect_errno, gettype($mysqli->connect_errno), + mysqli_connect_errno(), gettype(mysqli_connect_errno())); + + print "done!"; ?> --EXPECTF-- Parent class: diff --git a/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt b/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt index 2d07ef155c7b..fa7c7cd53dd8 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt @@ -8,233 +8,233 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- $var) { - try { + printf("\nClass variables:\n"); + $variables = array_keys(get_class_vars(get_class($mysqli))); + sort($variables); + foreach ($variables as $k => $var) { + try { printf("%s = '%s'\n", $var, var_export($mysqli->$var, true)); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - } + } - printf("\nObject variables:\n"); - $variables = array_keys(get_object_vars($mysqli)); + printf("\nObject variables:\n"); + $variables = array_keys(get_object_vars($mysqli)); foreach ($variables as $k => $var) { - try { + try { printf("%s = '%s'\n", $var, var_export($mysqli->$var, true)); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - } + } - printf("\nMagic, magic properties:\n"); - try { + printf("\nMagic, magic properties:\n"); + try { mysqli_affected_rows($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->affected_rows; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->client_info; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - printf("mysqli->client_version = '%s'/%s\n", $mysqli->client_version, gettype($mysqli->client_version)); + printf("mysqli->client_version = '%s'/%s\n", $mysqli->client_version, gettype($mysqli->client_version)); - try { + try { mysqli_errno($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->errno; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_error($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->error; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_field_count($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->field_count; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_insert_id($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->insert_id; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_sqlstate($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->sqlstate; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_get_host_info($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->host_info; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_info($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->info; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_thread_id($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->thread_id; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_get_proto_info($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->protocol_version; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_get_server_info($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->server_info; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_get_server_version($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->server_version; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { mysqli_warning_count($mysqli); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - try { + try { $mysqli->warning_count; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } - - - printf("\nAccess to undefined properties:\n"); - printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); - - @$mysqli->unknown = 13; - printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown); - - $unknown = 'friday'; - @$mysqli->unknown = $unknown; - printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown); - - printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); - assert(@mysqli_connect_error() === @$mysqli->connect_error); - printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", - @$mysqli->connect_error, gettype(@$mysqli->connect_error), - @mysqli_connect_error(), gettype(@mysqli_connect_error())); - - assert(@mysqli_connect_errno() === @$mysqli->connect_errno); - printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", - @$mysqli->connect_errno, gettype(@$mysqli->connect_errno), - @mysqli_connect_errno(), gettype(@mysqli_connect_errno())); - } - - printf("Without RS\n"); - $mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket); - dump_properties($mysqli); - - printf("\nWith RS\n"); - $mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket); - try { - $mysqli->query("SELECT * FROM test"); - } catch (Error $exception) { + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } + + + printf("\nAccess to undefined properties:\n"); + printf("mysqli->unknown = '%s'\n", @$mysqli->unknown); + + @$mysqli->unknown = 13; + printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown); + + $unknown = 'friday'; + @$mysqli->unknown = $unknown; + printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown); + + printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n"); + assert(@mysqli_connect_error() === @$mysqli->connect_error); + printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", + @$mysqli->connect_error, gettype(@$mysqli->connect_error), + @mysqli_connect_error(), gettype(@mysqli_connect_error())); + + assert(@mysqli_connect_errno() === @$mysqli->connect_errno); + printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", + @$mysqli->connect_errno, gettype(@$mysqli->connect_errno), + @mysqli_connect_errno(), gettype(@mysqli_connect_errno())); + } + + printf("Without RS\n"); + $mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket); + dump_properties($mysqli); + + printf("\nWith RS\n"); + $mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket); + try { + $mysqli->query("SELECT * FROM test"); + } catch (Error $exception) { echo $exception->getMessage() . "\n"; - } - dump_properties($mysqli); + } + dump_properties($mysqli); - print "done!"; + print "done!"; ?> --CLEAN-- diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt index c341acf2b345..9b181d3838e1 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt @@ -17,10 +17,10 @@ if (!$IS_MYSQLND) ?> --FILE-- --EXPECT-- Inspecting class 'mysqli' diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt index d16e35fb22b6..3dc73a0819d6 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt @@ -8,145 +8,145 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- query('SELECT * FROM test'); - $row = $mysqli_result->fetch_row(); - - $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); - $res = mysqli_query($link, 'SELECT * FROM test'); - assert(mysqli_fetch_row($res) === $row); - - printf("Parent class:\n"); - var_dump(get_parent_class($mysqli_result)); - - printf("\nMethods:\n"); - $methods = get_class_methods($mysqli_result); - $expected_methods = array( - '__construct' => true, - 'close' => true, - 'data_seek' => true, - 'fetch_array' => true, - 'fetch_assoc' => true, - 'fetch_field' => true, - 'fetch_field_direct' => true, - 'fetch_fields' => true, - 'fetch_object' => true, - 'fetch_row' => true, - 'field_seek' => true, - 'free' => true, - 'free_result' => true, - ); - if ($IS_MYSQLND) - $expected_methods['fetch_all'] = true; - - foreach ($methods as $k => $method) { - if (isset($expected_methods[$method])) { - unset($expected_methods[$method]); - unset($methods[$k]); - } - if ($method == 'mysqli_result') { - // get_class_method reports different constructor names - unset($expected_methods['__construct']); - unset($methods[$k]); - } - } - - if (!empty($expected_methods)) { - printf("Dumping list of missing methods.\n"); - var_dump($expected_methods); - } - if (!empty($methods)) { - printf("Dumping list of unexpected methods.\n"); - var_dump($methods); - } - if (empty($expected_methods) && empty($methods)) - printf("ok\n"); - - - printf("\nClass variables:\n"); - $variables = array_keys(get_class_vars(get_class($mysqli_result))); - sort($variables); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nObject variables:\n"); - $variables = array_keys(get_object_vars($mysqli_result)); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nMagic, magic properties:\n"); - - assert(($tmp = mysqli_field_tell($res)) === $mysqli_result->current_field); - printf("mysqli_result->current_field = '%s'/%s ('%s'/%s)\n", - $mysqli_result->current_field, gettype($mysqli_result->current_field), - $tmp, gettype($tmp)); - - assert(($tmp = mysqli_field_count($link)) === $mysqli_result->field_count); - printf("mysqli_result->field_count = '%s'/%s ('%s'/%s)\n", - $mysqli_result->field_count, gettype($mysqli_result->field_count), - $tmp, gettype($tmp)); - - assert(($tmp = mysqli_fetch_lengths($res)) === $mysqli_result->lengths); - printf("mysqli_result->lengths -> '%s'/%s ('%s'/%s)\n", - ((is_array($mysqli_result->lengths)) ? implode(' ', $mysqli_result->lengths) : 'n/a'), - gettype($mysqli_result->lengths), - ((is_array($tmp)) ? implode(' ', $tmp) : 'n/a'), - gettype($tmp)); - - assert(($tmp = mysqli_num_rows($res)) === $mysqli_result->num_rows); - printf("mysqli_result->num_rows = '%s'/%s ('%s'/%s)\n", - $mysqli_result->num_rows, gettype($mysqli_result->num_rows), - $tmp, gettype($tmp)); - - assert(in_array($mysqli_result->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))); - printf("mysqli_result->type = '%s'/%s\n", - ((MYSQLI_STORE_RESULT == $mysqli_result->type) ? 'store' : 'use'), - gettype($mysqli_result->type)); - - printf("\nAccess to undefined properties:\n"); - printf("mysqli_result->unknown = '%s'\n", @$mysqli_result->unknown); - - printf("\nConstructor:\n"); - if (!is_object($res = new mysqli_result($link))) - printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res); - - try { + require('connect.inc'); + require('table.inc'); + + $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $mysqli_result = $mysqli->query('SELECT * FROM test'); + $row = $mysqli_result->fetch_row(); + + $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); + $res = mysqli_query($link, 'SELECT * FROM test'); + assert(mysqli_fetch_row($res) === $row); + + printf("Parent class:\n"); + var_dump(get_parent_class($mysqli_result)); + + printf("\nMethods:\n"); + $methods = get_class_methods($mysqli_result); + $expected_methods = array( + '__construct' => true, + 'close' => true, + 'data_seek' => true, + 'fetch_array' => true, + 'fetch_assoc' => true, + 'fetch_field' => true, + 'fetch_field_direct' => true, + 'fetch_fields' => true, + 'fetch_object' => true, + 'fetch_row' => true, + 'field_seek' => true, + 'free' => true, + 'free_result' => true, + ); + if ($IS_MYSQLND) + $expected_methods['fetch_all'] = true; + + foreach ($methods as $k => $method) { + if (isset($expected_methods[$method])) { + unset($expected_methods[$method]); + unset($methods[$k]); + } + if ($method == 'mysqli_result') { + // get_class_method reports different constructor names + unset($expected_methods['__construct']); + unset($methods[$k]); + } + } + + if (!empty($expected_methods)) { + printf("Dumping list of missing methods.\n"); + var_dump($expected_methods); + } + if (!empty($methods)) { + printf("Dumping list of unexpected methods.\n"); + var_dump($methods); + } + if (empty($expected_methods) && empty($methods)) + printf("ok\n"); + + + printf("\nClass variables:\n"); + $variables = array_keys(get_class_vars(get_class($mysqli_result))); + sort($variables); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nObject variables:\n"); + $variables = array_keys(get_object_vars($mysqli_result)); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nMagic, magic properties:\n"); + + assert(($tmp = mysqli_field_tell($res)) === $mysqli_result->current_field); + printf("mysqli_result->current_field = '%s'/%s ('%s'/%s)\n", + $mysqli_result->current_field, gettype($mysqli_result->current_field), + $tmp, gettype($tmp)); + + assert(($tmp = mysqli_field_count($link)) === $mysqli_result->field_count); + printf("mysqli_result->field_count = '%s'/%s ('%s'/%s)\n", + $mysqli_result->field_count, gettype($mysqli_result->field_count), + $tmp, gettype($tmp)); + + assert(($tmp = mysqli_fetch_lengths($res)) === $mysqli_result->lengths); + printf("mysqli_result->lengths -> '%s'/%s ('%s'/%s)\n", + ((is_array($mysqli_result->lengths)) ? implode(' ', $mysqli_result->lengths) : 'n/a'), + gettype($mysqli_result->lengths), + ((is_array($tmp)) ? implode(' ', $tmp) : 'n/a'), + gettype($tmp)); + + assert(($tmp = mysqli_num_rows($res)) === $mysqli_result->num_rows); + printf("mysqli_result->num_rows = '%s'/%s ('%s'/%s)\n", + $mysqli_result->num_rows, gettype($mysqli_result->num_rows), + $tmp, gettype($tmp)); + + assert(in_array($mysqli_result->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))); + printf("mysqli_result->type = '%s'/%s\n", + ((MYSQLI_STORE_RESULT == $mysqli_result->type) ? 'store' : 'use'), + gettype($mysqli_result->type)); + + printf("\nAccess to undefined properties:\n"); + printf("mysqli_result->unknown = '%s'\n", @$mysqli_result->unknown); + + printf("\nConstructor:\n"); + if (!is_object($res = new mysqli_result($link))) + printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res); + + try { $res->num_rows; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } - - if (!mysqli_query($link, "SELECT id FROM test ORDER BY id")) - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = new mysqli_result($link))) - printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = new mysqli_result($link, MYSQLI_STORE_RESULT))) - printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = new mysqli_result($link, MYSQLI_USE_RESULT))) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); - do { - $mode = mt_rand(-1000, 1000); - } while (in_array($mode, $valid)); - - if ($TEST_EXPERIMENTAL) { - ob_start(); - if (!is_object($res = new mysqli_result($link, $mode))) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $content = ob_get_contents(); - ob_end_clean(); - if (!stristr($content, 'Invalid value for resultmode')) - printf("[009] Expecting warning because of invalid resultmode\n"); - } - - print "done!"; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } + + if (!mysqli_query($link, "SELECT id FROM test ORDER BY id")) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = new mysqli_result($link))) + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = new mysqli_result($link, MYSQLI_STORE_RESULT))) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = new mysqli_result($link, MYSQLI_USE_RESULT))) + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); + do { + $mode = mt_rand(-1000, 1000); + } while (in_array($mode, $valid)); + + if ($TEST_EXPERIMENTAL) { + ob_start(); + if (!is_object($res = new mysqli_result($link, $mode))) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $content = ob_get_contents(); + ob_end_clean(); + if (!stristr($content, 'Invalid value for resultmode')) + printf("[009] Expecting warning because of invalid resultmode\n"); + } + + print "done!"; ?> --EXPECTF-- Parent class: diff --git a/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt index c130e27a6bdf..83b4fbbd9585 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_result_reflection.phpt @@ -17,10 +17,10 @@ if (!$IS_MYSQLND) ?> --FILE-- --EXPECT-- Inspecting class 'mysqli_result' diff --git a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt index 134529d35c6d..8c79d3529732 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt @@ -8,76 +8,76 @@ Interface of the class mysqli_stmt ?> --FILE-- true, - 'attr_get' => true, - 'attr_set' => true, - 'bind_param' => true, - 'bind_result' => true, - 'close' => true, - 'data_seek' => true, - 'execute' => true, - 'fetch' => true, - 'free_result' => true, - 'get_warnings' => true, - 'num_rows' => true, - 'prepare' => true, - 'reset' => true, - 'result_metadata' => true, - 'send_long_data' => true, - 'store_result' => true, - ); - - if ($IS_MYSQLND) { - $expected_methods['get_result'] = true; - $expected_methods['more_results'] = true; - $expected_methods['next_result'] = true; - } - - foreach ($methods as $k => $method) { - if (isset($expected_methods[$method])) { - unset($methods[$k]); - unset($expected_methods[$method]); - } - if ($method == 'mysqli_stmt') { - // get_class_method reports different constructor names - unset($expected_methods['__construct']); - unset($methods[$k]); - } - } - if (!empty($methods)) { - printf("More methods found than indicated. Dumping list of unexpected methods.\n"); - var_dump($methods); - } - if (!empty($expected_methods)) { - printf("Some methods are missing. Dumping list of missing methods.\n"); - var_dump($expected_methods); - } - if (empty($methods) && empty($expected_methods)) - printf("ok\n"); - - printf("\nClass variables:\n"); - $variables = array_keys(get_class_vars(get_class($stmt))); - sort($variables); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nObject variables:\n"); - $variables = array_keys(get_object_vars($stmt)); - foreach ($variables as $k => $var) - printf("%s\n", $var); + require('connect.inc'); + require('table.inc'); + + $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); + $stmt = new mysqli_stmt($link); + + printf("Parent class:\n"); + var_dump(get_parent_class($stmt)); + + printf("\nMethods:\n"); + + $methods = get_class_methods($stmt); + $expected_methods = array( + '__construct' => true, + 'attr_get' => true, + 'attr_set' => true, + 'bind_param' => true, + 'bind_result' => true, + 'close' => true, + 'data_seek' => true, + 'execute' => true, + 'fetch' => true, + 'free_result' => true, + 'get_warnings' => true, + 'num_rows' => true, + 'prepare' => true, + 'reset' => true, + 'result_metadata' => true, + 'send_long_data' => true, + 'store_result' => true, + ); + + if ($IS_MYSQLND) { + $expected_methods['get_result'] = true; + $expected_methods['more_results'] = true; + $expected_methods['next_result'] = true; + } + + foreach ($methods as $k => $method) { + if (isset($expected_methods[$method])) { + unset($methods[$k]); + unset($expected_methods[$method]); + } + if ($method == 'mysqli_stmt') { + // get_class_method reports different constructor names + unset($expected_methods['__construct']); + unset($methods[$k]); + } + } + if (!empty($methods)) { + printf("More methods found than indicated. Dumping list of unexpected methods.\n"); + var_dump($methods); + } + if (!empty($expected_methods)) { + printf("Some methods are missing. Dumping list of missing methods.\n"); + var_dump($expected_methods); + } + if (empty($methods) && empty($expected_methods)) + printf("ok\n"); + + printf("\nClass variables:\n"); + $variables = array_keys(get_class_vars(get_class($stmt))); + sort($variables); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nObject variables:\n"); + $variables = array_keys(get_object_vars($stmt)); + foreach ($variables as $k => $var) + printf("%s\n", $var); printf("\nMagic, magic properties:\n"); diff --git a/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt b/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt index a73ef8ad684f..127777fc6a1c 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_warning.phpt @@ -12,82 +12,82 @@ if (!$TEST_EXPERIMENTAL) ?> --FILE-- stmt_init(); - $warning = new mysqli_warning($stmt); - - $obj = new stdClass(); - $warning = new mysqli_warning($obj); - - include("table.inc"); - $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); - $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")'); - $warning = mysqli_get_warnings($mysqli); - - printf("Parent class:\n"); - var_dump(get_parent_class($warning)); - - printf("\nMethods:\n"); - $methods = get_class_methods($warning); - $expected_methods = array( - 'next' => true, - ); - - foreach ($methods as $k => $method) { - if (isset($expected_methods[$method])) { - unset($methods[$k]); - unset($expected_methods[$method]); - } - } - if (!empty($methods)) { - printf("Dumping list of unexpected methods.\n"); - var_dump($methods); - } - if (!empty($expected_methods)) { - printf("Dumping list of missing methods.\n"); - var_dump($expected_methods); - } - if (empty($methods) && empty($expected_methods)) - printf("ok\n"); - - printf("\nClass variables:\n"); - $variables = get_class_vars(get_class($mysqli)); - sort($variables); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nObject variables:\n"); - $variables = get_object_vars($mysqli); - foreach ($variables as $k => $var) - printf("%s\n", $var); - - printf("\nMagic, magic properties:\n"); - - assert('' === $warning->message); - printf("warning->message = '%s'\n", $warning->message); - - assert('' === $warning->sqlstate); - printf("warning->sqlstate= '%s'\n", $warning->sqlstate); - - assert(0 === $warning->errno); - printf("warning->errno = '%s'\n", $warning->errno); - - printf("\nAccess to undefined properties:\n"); - printf("warning->unknown = '%s'\n", @$warning->unknown); - - print "done!"; + require('connect.inc'); + + $warning = new mysqli_warning(); + $warning = new mysqli_warning(null); + $warning = new mysqli_warning(null, null); + + $mysqli = new mysqli(); + $warning = new mysqli_warning($mysqli); + + $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $stmt = new mysqli_stmt($mysqli); + $warning = new mysqli_warning($stmt); + + $stmt = $mysqli->stmt_init(); + $warning = new mysqli_warning($stmt); + + $obj = new stdClass(); + $warning = new mysqli_warning($obj); + + include("table.inc"); + $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); + $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")'); + $warning = mysqli_get_warnings($mysqli); + + printf("Parent class:\n"); + var_dump(get_parent_class($warning)); + + printf("\nMethods:\n"); + $methods = get_class_methods($warning); + $expected_methods = array( + 'next' => true, + ); + + foreach ($methods as $k => $method) { + if (isset($expected_methods[$method])) { + unset($methods[$k]); + unset($expected_methods[$method]); + } + } + if (!empty($methods)) { + printf("Dumping list of unexpected methods.\n"); + var_dump($methods); + } + if (!empty($expected_methods)) { + printf("Dumping list of missing methods.\n"); + var_dump($expected_methods); + } + if (empty($methods) && empty($expected_methods)) + printf("ok\n"); + + printf("\nClass variables:\n"); + $variables = get_class_vars(get_class($mysqli)); + sort($variables); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nObject variables:\n"); + $variables = get_object_vars($mysqli); + foreach ($variables as $k => $var) + printf("%s\n", $var); + + printf("\nMagic, magic properties:\n"); + + assert('' === $warning->message); + printf("warning->message = '%s'\n", $warning->message); + + assert('' === $warning->sqlstate); + printf("warning->sqlstate= '%s'\n", $warning->sqlstate); + + assert(0 === $warning->errno); + printf("warning->errno = '%s'\n", $warning->errno); + + printf("\nAccess to undefined properties:\n"); + printf("warning->unknown = '%s'\n", @$warning->unknown); + + print "done!"; ?> --CLEAN-- --FILE-- --EXPECTF-- Inspecting class 'mysqli_warning' diff --git a/ext/mysqli/tests/mysqli_close.phpt b/ext/mysqli/tests/mysqli_close.phpt index 4532749624a9..a0d7fa2eab0e 100644 --- a/ext/mysqli/tests/mysqli_close.phpt +++ b/ext/mysqli/tests/mysqli_close.phpt @@ -8,23 +8,23 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; --EXPECT-- mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_close_oo.phpt b/ext/mysqli/tests/mysqli_close_oo.phpt index dc912925d9dc..351df66d94e8 100644 --- a/ext/mysqli/tests/mysqli_close_oo.phpt +++ b/ext/mysqli/tests/mysqli_close_oo.phpt @@ -8,18 +8,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- close(); - if (true !== $tmp) - printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $tmp = $mysqli->close(); + if (true !== $tmp) + printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); try { $mysqli->close(); @@ -33,7 +33,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- my_mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_commit.phpt b/ext/mysqli/tests/mysqli_commit.phpt index 9f1f969f4d59..33bb2011cdb9 100644 --- a/ext/mysqli/tests/mysqli_commit.phpt +++ b/ext/mysqli/tests/mysqli_commit.phpt @@ -15,42 +15,42 @@ if (!have_innodb($link)) ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- commit(); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } - - if (true !== ($tmp = $mysqli->commit())) { - printf("[002] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - } - - if (true !== ($tmp = $mysqli->autocommit(false))) { - printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); - } - - if (!$mysqli->query('DROP TABLE IF EXISTS test')) { - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { - printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) { - printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - $tmp = $mysqli->commit(); - if ($tmp !== true) { - printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - } - - if (!$mysqli->query('ROLLBACK')) - printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); - - if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) { - printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - $tmp = $res->fetch_assoc(); - if (1 != $tmp['num']) { - printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']); - } - $res->free(); - - if (!$mysqli->query('DROP TABLE IF EXISTS test')) { - printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - if (!$mysqli->commit(0 , "tx_name0123")) { - printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - if (!$mysqli->commit(0 , "*/ nonsense")) { - printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - if (!$mysqli->commit(0 , "tx_name ulf вендел")) { - printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - if (!$mysqli->commit(0 , "tx_name \t\n\r\b")) { - printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - if (!$mysqli->commit(MYSQLI_TRANS_COR_AND_CHAIN | MYSQLI_TRANS_COR_NO_RELEASE , "tx_name")) { - printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - $mysqli->close(); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } + + if (true !== ($tmp = $mysqli->commit())) { + printf("[002] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + } + + if (true !== ($tmp = $mysqli->autocommit(false))) { + printf("[003] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); + } + + if (!$mysqli->query('DROP TABLE IF EXISTS test')) { + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + if (!$mysqli->query('CREATE TABLE test(id INT) ENGINE = InnoDB')) { + printf("[005] Cannot create test table, [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + if (!$mysqli->query('INSERT INTO test(id) VALUES (1)')) { + printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + $tmp = $mysqli->commit(); + if ($tmp !== true) { + printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + } + + if (!$mysqli->query('ROLLBACK')) + printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); + + if (!$res = $mysqli->query('SELECT COUNT(*) AS num FROM test')) { + printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + $tmp = $res->fetch_assoc(); + if (1 != $tmp['num']) { + printf("[010] Expecting 1 row in table test, found %d rows\n", $tmp['num']); + } + $res->free(); + + if (!$mysqli->query('DROP TABLE IF EXISTS test')) { + printf("[011] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + if (!$mysqli->commit(0 , "tx_name0123")) { + printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + if (!$mysqli->commit(0 , "*/ nonsense")) { + printf("[013] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + if (!$mysqli->commit(0 , "tx_name ulf вендел")) { + printf("[014] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + if (!$mysqli->commit(0 , "tx_name \t\n\r\b")) { + printf("[015] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + if (!$mysqli->commit(MYSQLI_TRANS_COR_AND_CHAIN | MYSQLI_TRANS_COR_NO_RELEASE , "tx_name")) { + printf("[016] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + $mysqli->close(); try { $mysqli->commit(); @@ -98,7 +98,7 @@ if (!have_innodb($link)) echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; --CLEAN-- --FILE-- --EXPECTF-- Warning: mysqli_connect(): (%s/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d diff --git a/ext/mysqli/tests/mysqli_connect_attr.phpt b/ext/mysqli/tests/mysqli_connect_attr.phpt index 96c79b1a6b75..86f3e08a5c6d 100644 --- a/ext/mysqli/tests/mysqli_connect_attr.phpt +++ b/ext/mysqli/tests/mysqli_connect_attr.phpt @@ -37,13 +37,13 @@ mysqli_close($link); ?> --FILE-- --FILE-- getMessage() . "\n"); - } + // too many parameter + try { + mysqli_connect_errno($link); + } catch (ArgumentCountError $exception) { + print($exception->getMessage() . "\n"); + } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (0 !== ($tmp = mysqli_connect_errno())) - printf("[003] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = mysqli_connect_errno())) + printf("[003] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp); - mysqli_close($link); + mysqli_close($link); - $link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); - if (false !== $link) - printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n", - $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true)); + $link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); + if (false !== $link) + printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n", + $host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true)); - if (0 === ($tmp = mysqli_connect_errno())) - printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp); + if (0 === ($tmp = mysqli_connect_errno())) + printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECT-- mysqli_connect_errno() expects exactly 0 parameters, 1 given diff --git a/ext/mysqli/tests/mysqli_connect_error.phpt b/ext/mysqli/tests/mysqli_connect_error.phpt index 40b2c7e4b449..0f51d15dfd53 100644 --- a/ext/mysqli/tests/mysqli_connect_error.phpt +++ b/ext/mysqli/tests/mysqli_connect_error.phpt @@ -8,35 +8,35 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"); - } + // too many parameter + try { + mysqli_connect_error($link); + } catch (ArgumentCountError $exception) { + print($exception->getMessage() . "\n"); + } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (NULL !== ($tmp = mysqli_connect_error())) - printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = mysqli_connect_error())) + printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - mysqli_close($link); + mysqli_close($link); - if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) - printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", - $host, $user . 'unknown_really', $db, $port, $socket); + if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) + printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); - if ('' === ($tmp = mysqli_connect_error())) - printf("[004] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp); + if ('' === ($tmp = mysqli_connect_error())) + printf("[004] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECT-- mysqli_connect_error() expects exactly 0 parameters, 1 given diff --git a/ext/mysqli/tests/mysqli_connect_oo.phpt b/ext/mysqli/tests/mysqli_connect_oo.phpt index 4a675b587c90..e39b4ac2dab1 100644 --- a/ext/mysqli/tests/mysqli_connect_oo.phpt +++ b/ext/mysqli/tests/mysqli_connect_oo.phpt @@ -8,145 +8,145 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- close(); - } - - ini_set('mysqli.default_port', $port); - if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db)) || (0 !== mysqli_connect_errno())) { - printf("[006] Usage of mysqli.default_port failed\n") ; - } else { - $mysqli->close(); - } - - ini_set('mysqli.default_pw', $passwd); - if (!is_object($mysqli = new mysqli($host, $user)) || (0 !== mysqli_connect_errno())) { - printf("[007] Usage of mysqli.default_pw failed\n") ; - } else { - $mysqli->close(); - } - - ini_set('mysqli.default_user', $user); - if (!is_object($mysqli = new mysqli($host)) || (0 !== mysqli_connect_errno())) { - printf("[008] Usage of mysqli.default_user failed\n") ; - } else { - $mysqli->close(); - } - - ini_set('mysqli.default_host', $host); - if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { - printf("[012] Failed to create mysqli object\n"); - } else { - // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! - // We had long discussions on this and found that the ext/mysqli API as - // such is broken. As we can't fix it, we document how it has behaved from - // the first day on. And that's: no connection. + require_once("connect.inc"); + + $tmp = NULL; + $link = NULL; + + $obj = new stdClass(); + + if ($mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket) && !mysqli_connect_errno()) + printf("[003] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + + if (false !== $mysqli) + printf("[004] Expecting boolean/false, got %s/%s\n", gettype($mysqli), $mysqli); + + // Run the following tests without an anoynmous MySQL user and use a password for the test user! + ini_set('mysqli.default_socket', $socket); + if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db, $port)) || (0 !== mysqli_connect_errno())) { + printf("[005] Usage of mysqli.default_socket failed\n") ; + } else { + $mysqli->close(); + } + + ini_set('mysqli.default_port', $port); + if (!is_object($mysqli = new mysqli($host, $user, $passwd, $db)) || (0 !== mysqli_connect_errno())) { + printf("[006] Usage of mysqli.default_port failed\n") ; + } else { + $mysqli->close(); + } + + ini_set('mysqli.default_pw', $passwd); + if (!is_object($mysqli = new mysqli($host, $user)) || (0 !== mysqli_connect_errno())) { + printf("[007] Usage of mysqli.default_pw failed\n") ; + } else { + $mysqli->close(); + } + + ini_set('mysqli.default_user', $user); + if (!is_object($mysqli = new mysqli($host)) || (0 !== mysqli_connect_errno())) { + printf("[008] Usage of mysqli.default_user failed\n") ; + } else { + $mysqli->close(); + } + + ini_set('mysqli.default_host', $host); + if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) { + printf("[012] Failed to create mysqli object\n"); + } else { + // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! + // We had long discussions on this and found that the ext/mysqli API as + // such is broken. As we can't fix it, we document how it has behaved from + // the first day on. And that's: no connection. try { $mysqli->query('SELECT 1'); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - } - - if ($IS_MYSQLND) { - ini_set('mysqli.default_host', 'p:' . $host); - if (!is_object($mysqli = new mysqli())) { - // Due to an API flaw this shall not connect - printf("[010] Failed to create mysqli object\n"); - } else { - // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! - // We had long discussions on this and found that the ext/mysqli API as - // such is broken. As we can't fix it, we document how it has behaved from - // the first day on. And that's: no connection. - try { - $mysqli->query('SELECT 1'); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } - } - } - - print "... and now Exceptions\n"; - mysqli_report(MYSQLI_REPORT_OFF); - mysqli_report(MYSQLI_REPORT_STRICT); - - try { - $mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); - printf("[016] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", - $host, $user . 'unknown_really', $db, $port, $socket); - $mysqli->close(); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - } - - ini_set('mysqli.default_socket', $socket); - try { - $mysqli = new mysqli($host, $user, $passwd, $db, $port); - $mysqli->close(); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[017] Usage of mysqli.default_socket failed\n") ; - } - - ini_set('mysqli.default_port', $port); - try { - $mysqli = new mysqli($host, $user, $passwd, $db); - $mysqli->close(); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[018] Usage of mysqli.default_port failed\n") ; - } - - ini_set('mysqli.default_pw', $passwd); - try { - $mysqli = new mysqli($host, $user); - $mysqli->close(); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[019] Usage of mysqli.default_pw failed\n"); - } - - ini_set('mysqli.default_user', $user); - try { - $mysqli = new mysqli($host); - $mysqli->close(); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[020] Usage of mysqli.default_user failed\n") ; - } - - ini_set('mysqli.default_host', $host); - try { - /* NOTE that at this point one must use a different syntax! */ - $mysqli = mysqli_init(); - $mysqli->real_connect(); - assert(0 === mysqli_connect_errno()); - $mysqli->close(); - assert(0 === mysqli_connect_errno()); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[021] Usage of mysqli.default_host failed\n"); - } - - print "done!"; + } + + if ($IS_MYSQLND) { + ini_set('mysqli.default_host', 'p:' . $host); + if (!is_object($mysqli = new mysqli())) { + // Due to an API flaw this shall not connect + printf("[010] Failed to create mysqli object\n"); + } else { + // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection! + // We had long discussions on this and found that the ext/mysqli API as + // such is broken. As we can't fix it, we document how it has behaved from + // the first day on. And that's: no connection. + try { + $mysqli->query('SELECT 1'); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } + } + } + + print "... and now Exceptions\n"; + mysqli_report(MYSQLI_REPORT_OFF); + mysqli_report(MYSQLI_REPORT_STRICT); + + try { + $mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket); + printf("[016] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + $mysqli->close(); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + } + + ini_set('mysqli.default_socket', $socket); + try { + $mysqli = new mysqli($host, $user, $passwd, $db, $port); + $mysqli->close(); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[017] Usage of mysqli.default_socket failed\n") ; + } + + ini_set('mysqli.default_port', $port); + try { + $mysqli = new mysqli($host, $user, $passwd, $db); + $mysqli->close(); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[018] Usage of mysqli.default_port failed\n") ; + } + + ini_set('mysqli.default_pw', $passwd); + try { + $mysqli = new mysqli($host, $user); + $mysqli->close(); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[019] Usage of mysqli.default_pw failed\n"); + } + + ini_set('mysqli.default_user', $user); + try { + $mysqli = new mysqli($host); + $mysqli->close(); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[020] Usage of mysqli.default_user failed\n") ; + } + + ini_set('mysqli.default_host', $host); + try { + /* NOTE that at this point one must use a different syntax! */ + $mysqli = mysqli_init(); + $mysqli->real_connect(); + assert(0 === mysqli_connect_errno()); + $mysqli->close(); + assert(0 === mysqli_connect_errno()); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[021] Usage of mysqli.default_host failed\n"); + } + + print "done!"; ?> --EXPECTF-- Warning: mysqli::__construct(): (%s/%d): Access denied for user '%sunknown%s'@'%s' (using password: %s) in %s on line %d diff --git a/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt b/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt index cdc804971979..c5e65f761650 100644 --- a/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt +++ b/ext/mysqli/tests/mysqli_connect_oo_defaults.phpt @@ -8,153 +8,153 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- real_connect($host, $user, $passwd, $db, $port); - - if (!$res = $mysqli->query("SELECT 'mysqli.default_socket' AS testing")) - printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error); - $tmp = $res->fetch_assoc(); - $res->free_result(); - - if (!isset($tmp['testing']) || $tmp['testing'] != 'mysqli.default_socket') { - printf("[002] mysqli.default_socket not properly set?\n"); - var_dump($tmp); - } - - $mysqli->close(); - - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[002] Usage of mysqli.default_socket failed\n"); - } - } - - ini_set('mysqli.default_port', $port); - try { - $mysqli = mysqli_init(); - $mysqli->real_connect($host, $user, $passwd, $db); - - if (!$res = $mysqli->query("SELECT 'mysqli.default_port' AS testing")) - printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($res->fetch_assoc()); - $res->free_result(); - - $mysqli->close(); - - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[004] Usage of mysqli.default_port failed\n"); - } - - ini_set('mysqli.default_pw', $passwd); - try { - $mysqli = mysqli_init(); - $mysqli->real_connect($host, $user); - $mysqli->select_db($db); - - if (!$res = $mysqli->query("SELECT 'mysqli.default_pw' AS testing")) - printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($res->fetch_assoc()); - $res->free_result(); - - $mysqli->close(); - - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[006] Usage of mysqli.default_pw failed\n"); - } - - ini_set('mysqli.default_user', $user); - try { - $mysqli = mysqli_init(); - $mysqli->real_connect($host); - $mysqli->select_db($db); - - if (!$res = $mysqli->query("SELECT 'mysqli.default_user' AS testing")) - printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($res->fetch_assoc()); - $res->free_result(); - - $mysqli->close(); - - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[008] Usage of mysqli.default_user failed\n"); - } - - ini_set('mysqli.default_host', $host); - try { - $mysqli = mysqli_init(); - $mysqli->real_connect(); - $mysqli->select_db($db); - - if (!$res = $mysqli->query("SELECT 1")) - printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); - $res->free_result(); - - if (!$res = $mysqli->query("SELECT SUBSTRING_INDEX(USER(),'@',1) AS username")) - printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); - - $tmp = $res->fetch_assoc(); - $res->free_result(); - if ($tmp['username'] !== $user) - printf("[011] Expecting string/%s, got %s/%s\n", $user, gettype($tmp['username']), $tmp['username']); - - $mysqli->close(); - - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[012] Usage of mysqli.default_host failed\n"); - } - - try { - $link = mysqli_connect($host, $user, $passwd, null, ini_get('mysqli.default_port')); - mysqli_select_db($link, $db); - if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump(mysqli_fetch_assoc($res)); - mysqli_free_result($res); - mysqli_close($link); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[014] Usage of mysqli_connect() has failed\n"); - } - - try { - $link = mysqli_connect($host, $user, $passwd, null); - mysqli_select_db($link, $db); - if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump(mysqli_fetch_assoc($res)); - mysqli_free_result($res); - mysqli_close($link); - } catch (mysqli_sql_exception $e) { - printf("%s\n", $e->getMessage()); - printf("[016] Usage of mysqli_connect() has failed\n"); - } - - - print "done!"; + require_once("connect.inc"); + + $tmp = NULL; + $link = NULL; + + if ($socket != "") + /* mysqli.default_socket requires non-empty string */ + ini_set('mysqli.default_socket', 'socket'); + + ini_set('mysqli.default_port', 9999); + ini_set('mysqli.default_pw', 'password'); + ini_set('mysqli.default_user', 'user'); + ini_set('mysqli.default_host', 'host'); + + mysqli_report(MYSQLI_REPORT_OFF); + mysqli_report(MYSQLI_REPORT_STRICT); + + if ($socket != "") { + ini_set('mysqli.default_socket', $socket); + try { + $mysqli = mysqli_init(); + $mysqli->real_connect($host, $user, $passwd, $db, $port); + + if (!$res = $mysqli->query("SELECT 'mysqli.default_socket' AS testing")) + printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error); + $tmp = $res->fetch_assoc(); + $res->free_result(); + + if (!isset($tmp['testing']) || $tmp['testing'] != 'mysqli.default_socket') { + printf("[002] mysqli.default_socket not properly set?\n"); + var_dump($tmp); + } + + $mysqli->close(); + + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[002] Usage of mysqli.default_socket failed\n"); + } + } + + ini_set('mysqli.default_port', $port); + try { + $mysqli = mysqli_init(); + $mysqli->real_connect($host, $user, $passwd, $db); + + if (!$res = $mysqli->query("SELECT 'mysqli.default_port' AS testing")) + printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($res->fetch_assoc()); + $res->free_result(); + + $mysqli->close(); + + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[004] Usage of mysqli.default_port failed\n"); + } + + ini_set('mysqli.default_pw', $passwd); + try { + $mysqli = mysqli_init(); + $mysqli->real_connect($host, $user); + $mysqli->select_db($db); + + if (!$res = $mysqli->query("SELECT 'mysqli.default_pw' AS testing")) + printf("[005] [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($res->fetch_assoc()); + $res->free_result(); + + $mysqli->close(); + + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[006] Usage of mysqli.default_pw failed\n"); + } + + ini_set('mysqli.default_user', $user); + try { + $mysqli = mysqli_init(); + $mysqli->real_connect($host); + $mysqli->select_db($db); + + if (!$res = $mysqli->query("SELECT 'mysqli.default_user' AS testing")) + printf("[007] [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($res->fetch_assoc()); + $res->free_result(); + + $mysqli->close(); + + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[008] Usage of mysqli.default_user failed\n"); + } + + ini_set('mysqli.default_host', $host); + try { + $mysqli = mysqli_init(); + $mysqli->real_connect(); + $mysqli->select_db($db); + + if (!$res = $mysqli->query("SELECT 1")) + printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); + $res->free_result(); + + if (!$res = $mysqli->query("SELECT SUBSTRING_INDEX(USER(),'@',1) AS username")) + printf("[010] [%d] %s\n", $mysqli->errno, $mysqli->error); + + $tmp = $res->fetch_assoc(); + $res->free_result(); + if ($tmp['username'] !== $user) + printf("[011] Expecting string/%s, got %s/%s\n", $user, gettype($tmp['username']), $tmp['username']); + + $mysqli->close(); + + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[012] Usage of mysqli.default_host failed\n"); + } + + try { + $link = mysqli_connect($host, $user, $passwd, null, ini_get('mysqli.default_port')); + mysqli_select_db($link, $db); + if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + mysqli_close($link); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[014] Usage of mysqli_connect() has failed\n"); + } + + try { + $link = mysqli_connect($host, $user, $passwd, null); + mysqli_select_db($link, $db); + if (!$res = mysqli_query($link, "SELECT 'have been set' AS all_defaults")) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + mysqli_close($link); + } catch (mysqli_sql_exception $e) { + printf("%s\n", $e->getMessage()); + printf("[016] Usage of mysqli_connect() has failed\n"); + } + + + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt index 8204d0f1da21..5b410b746b11 100644 --- a/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt +++ b/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt @@ -12,34 +12,34 @@ new mysqli() ?> --FILE-- --EXPECTF-- 1) bail diff --git a/ext/mysqli/tests/mysqli_connect_twice.phpt b/ext/mysqli/tests/mysqli_connect_twice.phpt index c5ba7493c13f..6fa6746537af 100644 --- a/ext/mysqli/tests/mysqli_connect_twice.phpt +++ b/ext/mysqli/tests/mysqli_connect_twice.phpt @@ -8,69 +8,69 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- thread_id) - printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$thread_id = $link->thread_id) + printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) - printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) + printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) - printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); + if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) + printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); - if ($thread_id == $new_thread_id) - printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); + if ($thread_id == $new_thread_id) + printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); - if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || - !($row = $res->fetch_assoc())) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || + !($row = $res->fetch_assoc())) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($row); - mysqli_free_result($res); + var_dump($row); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) - printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) + printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) - printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) + printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index 1994a5ec963c..b281a9c9c5de 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -10,234 +10,234 @@ require_once('skipifconnectfailure.inc'); mysqli.allow_local_infile=1 --FILE-- true, - 'MYSQLI_READ_DEFAULT_FILE' => true, - 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, - 'MYSQLI_OPT_LOCAL_INFILE' => true, - 'MYSQLI_OPT_READ_TIMEOUT' => true, - 'MYSQLI_INIT_COMMAND' => true, - 'MYSQLI_CLIENT_SSL' => true, - "MYSQLI_CLIENT_COMPRESS" => true, - "MYSQLI_CLIENT_INTERACTIVE" => true, - "MYSQLI_CLIENT_IGNORE_SPACE" => true, - "MYSQLI_CLIENT_NO_SCHEMA" => true, - "MYSQLI_CLIENT_FOUND_ROWS" => true, - "MYSQLI_STORE_RESULT" => true, - "MYSQLI_USE_RESULT" => true, - "MYSQLI_ASSOC" => true, - "MYSQLI_NUM" => true, - "MYSQLI_BOTH" => true, - "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true, - "MYSQLI_NOT_NULL_FLAG" => true, - "MYSQLI_PRI_KEY_FLAG" => true, - "MYSQLI_UNIQUE_KEY_FLAG" => true, - "MYSQLI_MULTIPLE_KEY_FLAG" => true, - "MYSQLI_BLOB_FLAG" => true, - "MYSQLI_UNSIGNED_FLAG" => true, - "MYSQLI_ZEROFILL_FLAG" => true, - "MYSQLI_AUTO_INCREMENT_FLAG" => true, - "MYSQLI_TIMESTAMP_FLAG" => true, - "MYSQLI_SET_FLAG" => true, - "MYSQLI_NUM_FLAG" => true, - "MYSQLI_ENUM_FLAG" => true, - "MYSQLI_BINARY_FLAG" => true, - "MYSQLI_PART_KEY_FLAG" => true, - "MYSQLI_GROUP_FLAG" => true, - "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true, - "MYSQLI_SERVER_QUERY_NO_INDEX_USED" => true, - - "MYSQLI_TYPE_DECIMAL" => true, - "MYSQLI_TYPE_TINY" => true, - "MYSQLI_TYPE_SHORT" => true, - "MYSQLI_TYPE_LONG" => true, - "MYSQLI_TYPE_FLOAT" => true, - "MYSQLI_TYPE_DOUBLE" => true, - "MYSQLI_TYPE_NULL" => true, - "MYSQLI_TYPE_TIMESTAMP" => true, - "MYSQLI_TYPE_LONGLONG" => true, - "MYSQLI_TYPE_INT24" => true, - "MYSQLI_TYPE_DATE" => true, - "MYSQLI_TYPE_TIME" => true, - "MYSQLI_TYPE_DATETIME" => true, - "MYSQLI_TYPE_YEAR" => true, - "MYSQLI_TYPE_NEWDATE" => true, - "MYSQLI_TYPE_ENUM" => true, - "MYSQLI_TYPE_SET" => true, - "MYSQLI_TYPE_TINY_BLOB" => true, - "MYSQLI_TYPE_MEDIUM_BLOB" => true, - "MYSQLI_TYPE_LONG_BLOB" => true, - "MYSQLI_TYPE_BLOB" => true, - "MYSQLI_TYPE_VAR_STRING" => true, - "MYSQLI_TYPE_STRING" => true, - "MYSQLI_TYPE_CHAR" => true, - "MYSQLI_TYPE_INTERVAL" => true, - "MYSQLI_TYPE_GEOMETRY" => true, - "MYSQLI_NO_DATA" => true, - "MYSQLI_REPORT_INDEX" => true, - "MYSQLI_REPORT_STRICT" => true, - "MYSQLI_REPORT_ALL" => true, - "MYSQLI_REPORT_ERROR" => true, - "MYSQLI_REPORT_OFF" => true, - "MYSQLI_SET_CHARSET_NAME" => true, - "MYSQLI_SET_CHARSET_DIR" => true, - "MYSQLI_REFRESH_GRANT" => true, - "MYSQLI_REFRESH_LOG" => true, - "MYSQLI_REFRESH_TABLES" => true, - "MYSQLI_REFRESH_HOSTS" => true, - "MYSQLI_REFRESH_STATUS" => true, - "MYSQLI_REFRESH_THREADS" => true, - "MYSQLI_REFRESH_SLAVE" => true, - "MYSQLI_REFRESH_MASTER" => true, - "MYSQLI_DEBUG_TRACE_ENABLED" => true, - "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true, - "MYSQLI_TRANS_START_READ_WRITE" => true, - "MYSQLI_TRANS_START_READ_ONLY" => true, - "MYSQLI_TRANS_COR_AND_CHAIN" => true, - "MYSQLI_TRANS_COR_AND_NO_CHAIN" => true, - "MYSQLI_TRANS_COR_RELEASE" => true, - "MYSQLI_TRANS_COR_NO_RELEASE" => true, - ); - - /* depends on the build - experimental */ - if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) { - $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true; - } - - if ($IS_MYSQLND && defined('MYSQLI_STORE_RESULT_COPY_DATA')) { - $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true; - } - - if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) { - $expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true; - } - - if ($IS_MYSQLND) { - $version = 50007 + 1; - $expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true; - $expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true; - $expected_constants['MYSQLI_ASYNC'] = true; - - $expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true; - } else { - $version = mysqli_get_client_version(); - } - - if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) { - $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true; - } - - /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ - if ($version >= 50500 || $IS_MYSQLND) { - $expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true; - } - - if ($version >= 50033 || $IS_MYSQLND) { - $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true; - } - if ($IS_MYSQLND) { - $expected_constants['MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'] = true; - } - - /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ - if ($version >= 50606 || $IS_MYSQLND) { - $expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true; - } - - if ($version > 50002) { - $expected_constants = array_merge($expected_constants, array( - "MYSQLI_TYPE_NEWDECIMAL" => true, - "MYSQLI_TYPE_BIT" => true, - )); - } - - if ($version > 50002 || $IS_MYSQLND) { - $expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true; - } - - if ($version > 50003) { - $expected_constants = array_merge($expected_constants, array( - "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, - "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, - "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, - "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, - "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, - )); - } - - if ($version > 50007) { - $expected_constants = array_merge($expected_constants, array( - "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, - )); - } - - if ($version > 50110 || $IS_MYSQLND) { - $expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true; - } - - /* pretty dump test, but that is the best way to mimic mysql.c */ - if (defined('MYSQLI_DATA_TRUNCATED')) - $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; - - if (defined('MYSQLI_SERVER_PS_OUT_PARAMS')) - $expected_constants["MYSQLI_SERVER_PS_OUT_PARAMS"] = true; - - if (!$IS_MYSQLND) { - /* libmysql only */ - - /* are they available in all versions of ext/mysqli ? - ... no we must have removed them at some point - for BC, weakening the test - */ - if (defined("MYSQLI_RPL_MASTER")) { - $expected_constants["MYSQLI_RPL_MASTER"] = true; - $expected_constants["MYSQLI_RPL_SLAVE"] = true; - $expected_constants["MYSQLI_RPL_ADMIN"] = true; - } - } - - if ($IS_MYSQLND || (!$IS_MYSQLND && ($version > 50610))) { - /* could be that MySQL/libmysql 5.6.9 had the flag already but it was no stable release */ - $expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; - $expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; - } - - if ($IS_MYSQLND) { - $expected_constants["MYSQLI_TYPE_JSON"] = true; - } - - $unexpected_constants = array(); - - foreach ($constants as $group => $consts) { - foreach ($consts as $name => $value) { - if (stristr($name, 'mysqli')) { - $name = strtoupper($name); - if (isset($expected_constants[$name])) { - unset($expected_constants[$name]); - } else { - $unexpected_constants[$name] = $name; - } - } - } - } - - if (!empty($unexpected_constants)) { - printf("Dumping list of unexpected constants\n"); - var_dump($unexpected_constants); - } - - if (!empty($expected_constants)) { - printf("Dumping list of missing constants\n"); - var_dump($expected_constants); - } - - print "done!"; + require("connect.inc"); + require("table.inc"); + + $php_version = (int)str_replace('.', '', PHP_VERSION); + $constants = get_defined_constants(true); + sort($constants); + + $expected_constants = array( + 'MYSQLI_READ_DEFAULT_GROUP' => true, + 'MYSQLI_READ_DEFAULT_FILE' => true, + 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, + 'MYSQLI_OPT_LOCAL_INFILE' => true, + 'MYSQLI_OPT_READ_TIMEOUT' => true, + 'MYSQLI_INIT_COMMAND' => true, + 'MYSQLI_CLIENT_SSL' => true, + "MYSQLI_CLIENT_COMPRESS" => true, + "MYSQLI_CLIENT_INTERACTIVE" => true, + "MYSQLI_CLIENT_IGNORE_SPACE" => true, + "MYSQLI_CLIENT_NO_SCHEMA" => true, + "MYSQLI_CLIENT_FOUND_ROWS" => true, + "MYSQLI_STORE_RESULT" => true, + "MYSQLI_USE_RESULT" => true, + "MYSQLI_ASSOC" => true, + "MYSQLI_NUM" => true, + "MYSQLI_BOTH" => true, + "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true, + "MYSQLI_NOT_NULL_FLAG" => true, + "MYSQLI_PRI_KEY_FLAG" => true, + "MYSQLI_UNIQUE_KEY_FLAG" => true, + "MYSQLI_MULTIPLE_KEY_FLAG" => true, + "MYSQLI_BLOB_FLAG" => true, + "MYSQLI_UNSIGNED_FLAG" => true, + "MYSQLI_ZEROFILL_FLAG" => true, + "MYSQLI_AUTO_INCREMENT_FLAG" => true, + "MYSQLI_TIMESTAMP_FLAG" => true, + "MYSQLI_SET_FLAG" => true, + "MYSQLI_NUM_FLAG" => true, + "MYSQLI_ENUM_FLAG" => true, + "MYSQLI_BINARY_FLAG" => true, + "MYSQLI_PART_KEY_FLAG" => true, + "MYSQLI_GROUP_FLAG" => true, + "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true, + "MYSQLI_SERVER_QUERY_NO_INDEX_USED" => true, + + "MYSQLI_TYPE_DECIMAL" => true, + "MYSQLI_TYPE_TINY" => true, + "MYSQLI_TYPE_SHORT" => true, + "MYSQLI_TYPE_LONG" => true, + "MYSQLI_TYPE_FLOAT" => true, + "MYSQLI_TYPE_DOUBLE" => true, + "MYSQLI_TYPE_NULL" => true, + "MYSQLI_TYPE_TIMESTAMP" => true, + "MYSQLI_TYPE_LONGLONG" => true, + "MYSQLI_TYPE_INT24" => true, + "MYSQLI_TYPE_DATE" => true, + "MYSQLI_TYPE_TIME" => true, + "MYSQLI_TYPE_DATETIME" => true, + "MYSQLI_TYPE_YEAR" => true, + "MYSQLI_TYPE_NEWDATE" => true, + "MYSQLI_TYPE_ENUM" => true, + "MYSQLI_TYPE_SET" => true, + "MYSQLI_TYPE_TINY_BLOB" => true, + "MYSQLI_TYPE_MEDIUM_BLOB" => true, + "MYSQLI_TYPE_LONG_BLOB" => true, + "MYSQLI_TYPE_BLOB" => true, + "MYSQLI_TYPE_VAR_STRING" => true, + "MYSQLI_TYPE_STRING" => true, + "MYSQLI_TYPE_CHAR" => true, + "MYSQLI_TYPE_INTERVAL" => true, + "MYSQLI_TYPE_GEOMETRY" => true, + "MYSQLI_NO_DATA" => true, + "MYSQLI_REPORT_INDEX" => true, + "MYSQLI_REPORT_STRICT" => true, + "MYSQLI_REPORT_ALL" => true, + "MYSQLI_REPORT_ERROR" => true, + "MYSQLI_REPORT_OFF" => true, + "MYSQLI_SET_CHARSET_NAME" => true, + "MYSQLI_SET_CHARSET_DIR" => true, + "MYSQLI_REFRESH_GRANT" => true, + "MYSQLI_REFRESH_LOG" => true, + "MYSQLI_REFRESH_TABLES" => true, + "MYSQLI_REFRESH_HOSTS" => true, + "MYSQLI_REFRESH_STATUS" => true, + "MYSQLI_REFRESH_THREADS" => true, + "MYSQLI_REFRESH_SLAVE" => true, + "MYSQLI_REFRESH_MASTER" => true, + "MYSQLI_DEBUG_TRACE_ENABLED" => true, + "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true, + "MYSQLI_TRANS_START_READ_WRITE" => true, + "MYSQLI_TRANS_START_READ_ONLY" => true, + "MYSQLI_TRANS_COR_AND_CHAIN" => true, + "MYSQLI_TRANS_COR_AND_NO_CHAIN" => true, + "MYSQLI_TRANS_COR_RELEASE" => true, + "MYSQLI_TRANS_COR_NO_RELEASE" => true, + ); + + /* depends on the build - experimental */ + if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) { + $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true; + } + + if ($IS_MYSQLND && defined('MYSQLI_STORE_RESULT_COPY_DATA')) { + $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true; + } + + if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) { + $expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true; + } + + if ($IS_MYSQLND) { + $version = 50007 + 1; + $expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true; + $expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true; + $expected_constants['MYSQLI_ASYNC'] = true; + + $expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true; + } else { + $version = mysqli_get_client_version(); + } + + if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) { + $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true; + } + + /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ + if ($version >= 50500 || $IS_MYSQLND) { + $expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true; + } + + if ($version >= 50033 || $IS_MYSQLND) { + $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true; + } + if ($IS_MYSQLND) { + $expected_constants['MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'] = true; + } + + /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ + if ($version >= 50606 || $IS_MYSQLND) { + $expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true; + } + + if ($version > 50002) { + $expected_constants = array_merge($expected_constants, array( + "MYSQLI_TYPE_NEWDECIMAL" => true, + "MYSQLI_TYPE_BIT" => true, + )); + } + + if ($version > 50002 || $IS_MYSQLND) { + $expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true; + } + + if ($version > 50003) { + $expected_constants = array_merge($expected_constants, array( + "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, + "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, + "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, + "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, + "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, + )); + } + + if ($version > 50007) { + $expected_constants = array_merge($expected_constants, array( + "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, + )); + } + + if ($version > 50110 || $IS_MYSQLND) { + $expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true; + } + + /* pretty dump test, but that is the best way to mimic mysql.c */ + if (defined('MYSQLI_DATA_TRUNCATED')) + $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; + + if (defined('MYSQLI_SERVER_PS_OUT_PARAMS')) + $expected_constants["MYSQLI_SERVER_PS_OUT_PARAMS"] = true; + + if (!$IS_MYSQLND) { + /* libmysql only */ + + /* are they available in all versions of ext/mysqli ? + ... no we must have removed them at some point - for BC, weakening the test + */ + if (defined("MYSQLI_RPL_MASTER")) { + $expected_constants["MYSQLI_RPL_MASTER"] = true; + $expected_constants["MYSQLI_RPL_SLAVE"] = true; + $expected_constants["MYSQLI_RPL_ADMIN"] = true; + } + } + + if ($IS_MYSQLND || (!$IS_MYSQLND && ($version > 50610))) { + /* could be that MySQL/libmysql 5.6.9 had the flag already but it was no stable release */ + $expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; + $expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; + } + + if ($IS_MYSQLND) { + $expected_constants["MYSQLI_TYPE_JSON"] = true; + } + + $unexpected_constants = array(); + + foreach ($constants as $group => $consts) { + foreach ($consts as $name => $value) { + if (stristr($name, 'mysqli')) { + $name = strtoupper($name); + if (isset($expected_constants[$name])) { + unset($expected_constants[$name]); + } else { + $unexpected_constants[$name] = $name; + } + } + } + } + + if (!empty($unexpected_constants)) { + printf("Dumping list of unexpected constants\n"); + var_dump($unexpected_constants); + } + + if (!empty($expected_constants)) { + printf("Dumping list of missing constants\n"); + var_dump($expected_constants); + } + + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_constants_categories.phpt b/ext/mysqli/tests/mysqli_constants_categories.phpt index 6a90e3d3f0b6..d02463e20a96 100644 --- a/ext/mysqli/tests/mysqli_constants_categories.phpt +++ b/ext/mysqli/tests/mysqli_constants_categories.phpt @@ -7,18 +7,18 @@ require_once('skipifemb.inc'); ?> --FILE-- $consts) { - foreach ($consts as $name => $value) { - if (stristr($name, 'mysqli')) { - if ('mysqli' != $group) - printf("found constant '%s' in group '%s'. expecting group 'mysqli'\n", $name, $group); - } - } - } + foreach ($constants as $group => $consts) { + foreach ($consts as $name => $value) { + if (stristr($name, 'mysqli')) { + if ('mysqli' != $group) + printf("found constant '%s' in group '%s'. expecting group 'mysqli'\n", $name, $group); + } + } + } - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_data_seek.phpt b/ext/mysqli/tests/mysqli_data_seek.phpt index b97cf717fa3e..53c8b8354d5b 100644 --- a/ext/mysqli/tests/mysqli_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_data_seek.phpt @@ -8,41 +8,41 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- data_seek(0); @@ -23,38 +23,38 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = $res->data_seek(3))) - printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $res->data_seek(3))) + printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $row = $res->fetch_assoc(); - if (4 != $row['id']) - printf("[008] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); + $row = $res->fetch_assoc(); + if (4 != $row['id']) + printf("[008] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); - if (true !== ($tmp = $res->data_seek(0))) - printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $res->data_seek(0))) + printf("[009] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $row = $res->fetch_assoc(); - if (1 != $row['id']) - printf("[010] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); + $row = $res->fetch_assoc(); + if (1 != $row['id']) + printf("[010] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); - if (false !== ($tmp = $res->data_seek(4))) - printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $res->data_seek(4))) + printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = $res->data_seek(-1))) - printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $res->data_seek(-1))) + printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - $res->free_result(); + $res->free_result(); - if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (false !== ($tmp = $res->data_seek(3))) - printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $res->data_seek(3))) + printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - $res->free_result(); + $res->free_result(); try { $res->data_seek(1); @@ -62,9 +62,9 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - $mysqli->close(); + $mysqli->close(); - print "done!"; + print "done!"; --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- --EXPECTF-- [023][control string '%s'] Trace file has not been written. diff --git a/ext/mysqli/tests/mysqli_debug_ini.phpt b/ext/mysqli/tests/mysqli_debug_ini.phpt index f1a37bf8821f..3416e9a9e276 100644 --- a/ext/mysqli/tests/mysqli_debug_ini.phpt +++ b/ext/mysqli/tests/mysqli_debug_ini.phpt @@ -29,24 +29,24 @@ else mysqlnd.debug="t:O,/tmp/mysqli_debug_phpt.trace" --FILE-- --EXPECT-- string(32) "t:O,/tmp/mysqli_debug_phpt.trace" diff --git a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt index 9999d84395fc..a18ee5e7d36f 100644 --- a/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt +++ b/ext/mysqli/tests/mysqli_debug_mysqlnd_control_string.phpt @@ -20,206 +20,206 @@ if (!$IS_MYSQLND) ?> --FILE-- mysql_real_query - $trace = try_control_string($link, 't:O,' . $trace_file . ':T', $trace_file, 20); - if (!preg_match('@^[012]{0,1}[0-9]{1}:[0-5]{0,1}[0-9]{1}:[0-5]{0,1}[0-9]{1}@ismU', $trace)) - printf("[025] Timestamp not found. One reason could be that the test is borked and does not recognize the format of the gettimeofday() system call. Check manually (and fix the test, if needed :-)). First characters from trace are '%s'\n", substr($trace, 0, 80)); - - // i - add PID of the current process - // currently PHP is not multi-threaded, so it should be save to test for the PID of this PHP process - if (false === ($pid = getmypid())) - $pid = "[\d]+"; - - $trace = try_control_string($link, 't:O,' . $trace_file . ':i', $trace_file, 30); - if (!preg_match("@^" . $pid . "*@ismU", $trace)) - printf("[035] Process ID has not been found, first characters from trace are '%s'\n", substr($trace, 0, 80)); - - // L - line numbers - $trace = try_control_string($link, 't:O,' . $trace_file . ':L', $trace_file, 40); - if (!preg_match("@^[\d]+@ismU", $trace)) - printf("[045] Line numbers have not been found, first characters from trace are '%s'\n", substr($trace, 0, 80)); - - // F - file name - $trace = try_control_string($link, 't:O,' . $trace_file . ':F', $trace_file, 50); - // hopefully we'll never see a file name that's not covered by this regular expression... - if (!preg_match("@^\s*[/\w\\\\d\.\-]+\.[ch]@ismU", $trace)) - printf("[055] File names seem to be missing, first characters from trace are '%s'\n", substr($trace, 0, 80)); - - // -n - print function nesting depth - $trace = try_control_string($link, 't:O,' . $trace_file . ':n', $trace_file, 60); - if (!preg_match("@^\d+:@ismU", $trace)) - printf("[065] Nesting level seem to be missing, first characters from trace are '%s'\n", substr($trace, 0, 80)); - - // -t,[N] - maximum nesting level - $trace = try_control_string($link, 't,1:n:O,' . $trace_file, $trace_file, 70); - $lines = explode("\n", $trace); - foreach ($lines as $k => $line) { - $line = trim($line); - if (!preg_match("@^(\d+):+@ismU", $line, $matches)) { - printf("[075] Nesting level seem to be missing, first characters from trace are '%s'\n", substr($line, 0, 80)); - } else { - if (!isset($matches[1]) || ((int)$matches[1] > 1)) { - printf("[076] Nesting level seem to be %d, should not be higher than 1, first characters from trace are '%s'\n", - $matches[1], - substr($line, 0, 80)); - } - } - } - - // omitting t - $trace = try_control_string($link, 'n:O,' . $trace_file, $trace_file, 80); - $lines = explode("\n", $trace); - foreach ($lines as $k => $line) { - $line = trim($line); - if (preg_match("@^[|\s]*>[\w]+@ism", $line, $matches)) { - printf("[085] Looks like a function call, but there should be none in the trace file, first characters from trace are '%s'\n", - substr($line, 0, 80)); - } - } - - // -f[,functions] - Limit debugger list to specified functions. Empty list -> all functions - $lines_all_funcs = explode("\n", try_control_string($link, 't:O,' . $trace_file, $trace_file, 90)); - $functions_all_funcs = array(); - foreach ($lines_all_funcs as $k => $line) { - $line = trim($line); - if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { - $functions_all_funcs[$matches[1]] = $matches[1]; - } - } - - $lines_trace = explode("\n", try_control_string($link, 't:f:O,' . $trace_file, $trace_file, 100)); - $functions_trace = array(); - foreach ($lines_trace as $k => $line) { - $line = trim($line); - if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { - $functions_trace[$matches[1]] = $matches[1]; - } - } - - $tmp = array_diff($functions_all_funcs, $functions_trace); - if (!empty($tmp)) { - printf("[105] Looks like not all functions are listed in the trace. Check manually, dumping diff."); - var_dump($tmp); - } - - // get two or three function names to play with... - $test_functions = array('simple' => array(), 'doubledot' => array()); - - foreach ($functions_all_funcs as $func) { - if (count($test_functions['simple']) < 2 && !strstr($func, '::')) - $test_functions['simple'][$func] = $func; - else if (count($test_functions['doubledot']) < 2 && strstr($func, '::')) - $test_functions['doubledot'][$func] = $func; - } - - $control_string = ''; - if ($func = reset($test_functions['simple'])) - $control_string .= sprintf('%s,', $func); - if ($func = reset($test_functions['doubledot'])) - $control_string .= sprintf('%s,', $func); - if ($func = next($test_functions['simple'])) - $control_string .= sprintf('%s,', $func); - if ($func = next($test_functions['doubledot'])) - $control_string .= sprintf('%s,', $func); - $control_string = sprintf('t:f,%s:O,%s', $control_string, $trace_file); - - $lines_trace = explode("\n", try_control_string($link, $control_string, $trace_file, 110)); - $functions_trace = array(); - foreach ($lines_trace as $k => $line) { - $line = trim($line); - if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { - $functions_trace[$matches[1]] = $matches[1]; - } - } - - foreach ($test_functions['simple'] as $func) - if (isset($functions_trace[$func])) { - unset($functions_trace[$func]); - unset($test_functions['simple'][$func]); - } - - foreach ($test_functions['doubledot'] as $func) - if (isset($functions_trace[$func])) { - unset($functions_trace[$func]); - unset($test_functions['doubledot'][$func]); - } - - if (!empty($functions_trace)) { - printf("[115] Dumping list of unexpected functions which should have not been shown when using control string '%s'.\n", - $control_string); - var_dump($functions_trace); - } - $tmp = array_merge($test_functions['doubledot'], $test_functions['simple']); - if (!empty($tmp)) { - printf("[116] Dumping list of functions which should have been shown when using control string '%s'.\n", - $control_string); - var_dump($tmp); - } - - if ($IS_MYSQLND) { - // mysqlnd only option - // m - trace memory allocations - $trace = try_control_string($link, 't:O,' . $trace_file . ':m', $trace_file, 120); - if (!preg_match("@^[|\s]*>\_mysqlnd_p?efree@ismU", $trace, $matches) && - !preg_match("@^[|\s]*>\_mysqlnd_p?emalloc@ismU", $trace, $matches)) { - printf("[125] Memory dump does neither contain _mysqlnd_pefree nor _mysqlnd_pemalloc calls - check manually.\n"); - var_dump($trace); - } - - } - - mysqli_close($link); - print "done"; - if ($IS_MYSQLND) - print "libmysql/DBUG package prints some debug info here."; - @unlink($trace_file); + require_once('connect.inc'); + require_once('table.inc'); + + function try_control_string($link, $control_string, $trace_file, $offset) { + + @unlink($trace_file); + if (true !== ($tmp = @mysqli_debug($control_string))) { + printf("[%03d][control string '%s'] Expecting boolean/true, got %s/%s.\n", + $offset + 1, + $control_string, + gettype($tmp), + $tmp); + return false; + } + + if (!$res = mysqli_query($link, 'SELECT * FROM test')) { + printf("[%03d][control string '%s'] [%d] %s.\n", + $offset + 2, + $control_string, + mysqli_errno($link), + mysqli_error($link)); + return false; + } + while ($row = mysqli_fetch_assoc($res)) + ; + mysqli_free_result($res); + + clearstatcache(); + if (!file_exists($trace_file)) { + printf("[%03d][control string '%s'] Trace file has not been written.\n", + $offset + 3, + $control_string, + gettype($tmp), + $tmp); + return false; + } + + return trim(substr(file_get_contents($trace_file), 0, 100024)); + } + + $trace_file = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, 'mysqli_debug_phpt.trace'); + + $trace = try_control_string($link, 't:O,' . $trace_file, $trace_file, 10); + if (!strstr($trace, 'SELECT * FROM test') && !strstr($trace, 'mysql_real_query')) + printf("[015] SELECT query cannot be found in trace. Trace contents seems wrong.\n"); + + // T - gettimeofday() system call, system dependent format + // 16:57:03.350734 >mysql_real_query + $trace = try_control_string($link, 't:O,' . $trace_file . ':T', $trace_file, 20); + if (!preg_match('@^[012]{0,1}[0-9]{1}:[0-5]{0,1}[0-9]{1}:[0-5]{0,1}[0-9]{1}@ismU', $trace)) + printf("[025] Timestamp not found. One reason could be that the test is borked and does not recognize the format of the gettimeofday() system call. Check manually (and fix the test, if needed :-)). First characters from trace are '%s'\n", substr($trace, 0, 80)); + + // i - add PID of the current process + // currently PHP is not multi-threaded, so it should be save to test for the PID of this PHP process + if (false === ($pid = getmypid())) + $pid = "[\d]+"; + + $trace = try_control_string($link, 't:O,' . $trace_file . ':i', $trace_file, 30); + if (!preg_match("@^" . $pid . "*@ismU", $trace)) + printf("[035] Process ID has not been found, first characters from trace are '%s'\n", substr($trace, 0, 80)); + + // L - line numbers + $trace = try_control_string($link, 't:O,' . $trace_file . ':L', $trace_file, 40); + if (!preg_match("@^[\d]+@ismU", $trace)) + printf("[045] Line numbers have not been found, first characters from trace are '%s'\n", substr($trace, 0, 80)); + + // F - file name + $trace = try_control_string($link, 't:O,' . $trace_file . ':F', $trace_file, 50); + // hopefully we'll never see a file name that's not covered by this regular expression... + if (!preg_match("@^\s*[/\w\\\\d\.\-]+\.[ch]@ismU", $trace)) + printf("[055] File names seem to be missing, first characters from trace are '%s'\n", substr($trace, 0, 80)); + + // -n - print function nesting depth + $trace = try_control_string($link, 't:O,' . $trace_file . ':n', $trace_file, 60); + if (!preg_match("@^\d+:@ismU", $trace)) + printf("[065] Nesting level seem to be missing, first characters from trace are '%s'\n", substr($trace, 0, 80)); + + // -t,[N] - maximum nesting level + $trace = try_control_string($link, 't,1:n:O,' . $trace_file, $trace_file, 70); + $lines = explode("\n", $trace); + foreach ($lines as $k => $line) { + $line = trim($line); + if (!preg_match("@^(\d+):+@ismU", $line, $matches)) { + printf("[075] Nesting level seem to be missing, first characters from trace are '%s'\n", substr($line, 0, 80)); + } else { + if (!isset($matches[1]) || ((int)$matches[1] > 1)) { + printf("[076] Nesting level seem to be %d, should not be higher than 1, first characters from trace are '%s'\n", + $matches[1], + substr($line, 0, 80)); + } + } + } + + // omitting t + $trace = try_control_string($link, 'n:O,' . $trace_file, $trace_file, 80); + $lines = explode("\n", $trace); + foreach ($lines as $k => $line) { + $line = trim($line); + if (preg_match("@^[|\s]*>[\w]+@ism", $line, $matches)) { + printf("[085] Looks like a function call, but there should be none in the trace file, first characters from trace are '%s'\n", + substr($line, 0, 80)); + } + } + + // -f[,functions] - Limit debugger list to specified functions. Empty list -> all functions + $lines_all_funcs = explode("\n", try_control_string($link, 't:O,' . $trace_file, $trace_file, 90)); + $functions_all_funcs = array(); + foreach ($lines_all_funcs as $k => $line) { + $line = trim($line); + if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { + $functions_all_funcs[$matches[1]] = $matches[1]; + } + } + + $lines_trace = explode("\n", try_control_string($link, 't:f:O,' . $trace_file, $trace_file, 100)); + $functions_trace = array(); + foreach ($lines_trace as $k => $line) { + $line = trim($line); + if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { + $functions_trace[$matches[1]] = $matches[1]; + } + } + + $tmp = array_diff($functions_all_funcs, $functions_trace); + if (!empty($tmp)) { + printf("[105] Looks like not all functions are listed in the trace. Check manually, dumping diff."); + var_dump($tmp); + } + + // get two or three function names to play with... + $test_functions = array('simple' => array(), 'doubledot' => array()); + + foreach ($functions_all_funcs as $func) { + if (count($test_functions['simple']) < 2 && !strstr($func, '::')) + $test_functions['simple'][$func] = $func; + else if (count($test_functions['doubledot']) < 2 && strstr($func, '::')) + $test_functions['doubledot'][$func] = $func; + } + + $control_string = ''; + if ($func = reset($test_functions['simple'])) + $control_string .= sprintf('%s,', $func); + if ($func = reset($test_functions['doubledot'])) + $control_string .= sprintf('%s,', $func); + if ($func = next($test_functions['simple'])) + $control_string .= sprintf('%s,', $func); + if ($func = next($test_functions['doubledot'])) + $control_string .= sprintf('%s,', $func); + $control_string = sprintf('t:f,%s:O,%s', $control_string, $trace_file); + + $lines_trace = explode("\n", try_control_string($link, $control_string, $trace_file, 110)); + $functions_trace = array(); + foreach ($lines_trace as $k => $line) { + $line = trim($line); + if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { + $functions_trace[$matches[1]] = $matches[1]; + } + } + + foreach ($test_functions['simple'] as $func) + if (isset($functions_trace[$func])) { + unset($functions_trace[$func]); + unset($test_functions['simple'][$func]); + } + + foreach ($test_functions['doubledot'] as $func) + if (isset($functions_trace[$func])) { + unset($functions_trace[$func]); + unset($test_functions['doubledot'][$func]); + } + + if (!empty($functions_trace)) { + printf("[115] Dumping list of unexpected functions which should have not been shown when using control string '%s'.\n", + $control_string); + var_dump($functions_trace); + } + $tmp = array_merge($test_functions['doubledot'], $test_functions['simple']); + if (!empty($tmp)) { + printf("[116] Dumping list of functions which should have been shown when using control string '%s'.\n", + $control_string); + var_dump($tmp); + } + + if ($IS_MYSQLND) { + // mysqlnd only option + // m - trace memory allocations + $trace = try_control_string($link, 't:O,' . $trace_file . ':m', $trace_file, 120); + if (!preg_match("@^[|\s]*>\_mysqlnd_p?efree@ismU", $trace, $matches) && + !preg_match("@^[|\s]*>\_mysqlnd_p?emalloc@ismU", $trace, $matches)) { + printf("[125] Memory dump does neither contain _mysqlnd_pefree nor _mysqlnd_pemalloc calls - check manually.\n"); + var_dump($trace); + } + + } + + mysqli_close($link); + print "done"; + if ($IS_MYSQLND) + print "libmysql/DBUG package prints some debug info here."; + @unlink($trace_file); ?> --CLEAN-- --FILE-- $line) { - $line = trim($line); - if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { - $functions_trace[$matches[1]] = $matches[1]; - } - } - - $found = 0; - foreach ($memory_funcs as $k => $name) - if (isset($functions_trace[$name])) - $found++; - - if ($found < 1) { - printf("[016] Only %d memory functions have been found, expecting at least %d.\n", - $found, 1); - var_dump($trace); - } - - $trace = try_control_string($link, 't:O,' . $trace_file, $trace_file, 20); - if (!strstr($trace, 'SELECT * FROM test') && !strstr($trace, 'mysql_real_query')) - printf("[025] SELECT query cannot be found in trace. Trace contents seems wrong.\n"); - - $lines_trace = explode("\n", $trace); - $functions_trace = array(); - foreach ($lines_trace as $k => $line) { - $line = trim($line); - if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { - $functions_trace[$matches[1]] = $matches[1]; - } - } - - $found = 0; - foreach ($memory_funcs as $k => $name) - if (isset($functions_trace[$name])) - $found++; - - if ($found > 2) { - printf("[026] More than %d memory functions have been recorded, that's strange.\n", - $found); - var_dump($trace); - } - - mysqli_close($link); - @unlink($trace_file); - print "done!"; + require_once('connect.inc'); + require_once('table.inc'); + + function try_control_string($link, $control_string, $trace_file, $offset) { + + @unlink($trace_file); + if (true !== ($tmp = @mysqli_debug($control_string))) { + printf("[%03d][control string '%s'] Expecting boolean/true, got %s/%s.\n", + $offset + 1, + $control_string, + gettype($tmp), + $tmp); + return false; + } + + if (!$res = mysqli_query($link, 'SELECT * FROM test')) { + printf("[%03d][control string '%s'] [%d] %s.\n", + $offset + 2, + $control_string, + mysqli_errno($link), + mysqli_error($link)); + return false; + } + while ($row = mysqli_fetch_assoc($res)) + ; + mysqli_free_result($res); + + clearstatcache(); + if (!file_exists($trace_file)) { + printf("[%03d][control string '%s'] Trace file has not been written.\n", + $offset + 3, + $control_string, + gettype($tmp), + $tmp); + return false; + } + + return trim(substr(file_get_contents($trace_file), 0, 100024)); + } + + $memory_funcs = array( + '_mysqlnd_ecalloc', + '_mysqlnd_emalloc', + '_mysqlnd_palloc_free_thd_cache_reference', + '_mysqlnd_pecalloc', + '_mysqlnd_pefree', + '_mysqlnd_pemalloc', + '_mysqlnd_perealloc', + ); + $trace_file = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, 'mysqli_debug_phpt.trace'); + + $trace = try_control_string($link, 't:m:O,' . $trace_file, $trace_file, 10); + if (!strstr($trace, 'SELECT * FROM test') && !strstr($trace, 'mysql_real_query')) + printf("[015] SELECT query cannot be found in trace. Trace contents seems wrong.\n"); + + $lines_trace = explode("\n", $trace); + $functions_trace = array(); + foreach ($lines_trace as $k => $line) { + $line = trim($line); + if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { + $functions_trace[$matches[1]] = $matches[1]; + } + } + + $found = 0; + foreach ($memory_funcs as $k => $name) + if (isset($functions_trace[$name])) + $found++; + + if ($found < 1) { + printf("[016] Only %d memory functions have been found, expecting at least %d.\n", + $found, 1); + var_dump($trace); + } + + $trace = try_control_string($link, 't:O,' . $trace_file, $trace_file, 20); + if (!strstr($trace, 'SELECT * FROM test') && !strstr($trace, 'mysql_real_query')) + printf("[025] SELECT query cannot be found in trace. Trace contents seems wrong.\n"); + + $lines_trace = explode("\n", $trace); + $functions_trace = array(); + foreach ($lines_trace as $k => $line) { + $line = trim($line); + if (preg_match("@^[|\s]*>([\w:]+)@ism", $line, $matches)) { + $functions_trace[$matches[1]] = $matches[1]; + } + } + + $found = 0; + foreach ($memory_funcs as $k => $name) + if (isset($functions_trace[$name])) + $found++; + + if ($found > 2) { + printf("[026] More than %d memory functions have been recorded, that's strange.\n", + $found); + var_dump($trace); + } + + mysqli_close($link); + @unlink($trace_file); + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- client_info) !== $client_info) - printf("[002] Expecting %s/%s, got %s/%s\n", - gettype($client_info), $client_info, - gettype($tmp), $tmp); - - $client_version = mysqli_get_client_version(); - if (($tmp = $driver->client_version) !== $client_version) - printf("[003] Expecting %s/%s, got %s/%s\n", - gettype($client_version), $client_version, - gettype($tmp), $tmp); - - if (!is_int($tmp = $driver->driver_version) || (0 == $tmp)) - printf("[004] Expecting int/any, got %s/%s\n", - gettype($tmp), $tmp); - - - $all_modes = array(MYSQLI_REPORT_INDEX, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_STRICT, - MYSQLI_REPORT_ALL, MYSQLI_REPORT_OFF); - $report_mode = $driver->report_mode; - if (!is_int($report_mode)) - printf("[005] Expecting int/any, got %s/%s\n", - gettype($report_mode), $report_mode); - - if (!in_array($report_mode, $all_modes)) - printf("[006] Illegal report mode returned? Got %s, expected %s\n", - $report_mode, implode(', ', $all_modes)); - - $driver->report_mode = MYSQLI_REPORT_STRICT; - $ok = false; - try { - - if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) - printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", - $host, $user . 'unknown_really', $db, $port, $socket); - mysqli_close($link); - - } catch (mysqli_sql_exception $e) { - $ok = true; - if ('' == $e->getMessage()) - printf("[008] getMessage() has returned an empty string.\n"); - if ('' == $e->getCode()) - printf("[009] getCode() has returned an empty string.\n"); - if ('' == $e->getFile()) - printf("[010] getFile() has returned an empty string.\n"); - if ('' == $e->getLine()) - printf("[011] getLine() has returned an empty string.\n"); - $tmp = $e->getTrace(); - if (empty($tmp)) - printf("[012] getTrace() has returned an empty array.\n"); - if ('' == $e->getTraceAsString()) - printf("[013] getTraceAsString() has returned an empty string.\n"); - if ('' == $e->__toString()) - printf("[014] __toString() has returned an empty string.\n"); - - } - if (!$ok) - printf("[015] Error reporting mode has not been switched to exceptions and or no exception thrown\n"); - - - $driver->report_mode = MYSQLI_REPORT_OFF; - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - mysqli_query($link, "NO_SQL"); - mysqli_close($link); - - $driver->report_mode = MYSQLI_REPORT_ERROR; - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - mysqli_query($link, "NO_SQL"); - mysqli_close($link); - - if (MYSQLI_REPORT_ERROR !== $driver->report_mode) - printf("[018] Error mode should be different\n"); - - /* TODO - more report testing should go in here, but it's not really documented what behaviour is expected */ - - $driver->report_mode = $report_mode; - - $reconnect = $driver->reconnect; - if (!is_bool($reconnect)) - printf("[019] Expecting boolean/any, got %s/%s\n", - gettype($reconnect), $reconnect); - - /* pointless, but I need more documentation */ - $driver->reconnect = true; - $driver->reconnect = false; - $driver->reconnect = $reconnect; - - if (!is_bool($embedded = $driver->embedded)) - printf("[020] Expecting boolean/any, got %s/%s\n", - gettype($embedded), $embedded); - - print "done!"; + require("table.inc"); + + if (!is_object($driver = new mysqli_driver())) + printf("[001] Failed to create mysqli_driver object\n"); + + $client_info = mysqli_get_client_info(); + if (($tmp = $driver->client_info) !== $client_info) + printf("[002] Expecting %s/%s, got %s/%s\n", + gettype($client_info), $client_info, + gettype($tmp), $tmp); + + $client_version = mysqli_get_client_version(); + if (($tmp = $driver->client_version) !== $client_version) + printf("[003] Expecting %s/%s, got %s/%s\n", + gettype($client_version), $client_version, + gettype($tmp), $tmp); + + if (!is_int($tmp = $driver->driver_version) || (0 == $tmp)) + printf("[004] Expecting int/any, got %s/%s\n", + gettype($tmp), $tmp); + + + $all_modes = array(MYSQLI_REPORT_INDEX, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_STRICT, + MYSQLI_REPORT_ALL, MYSQLI_REPORT_OFF); + $report_mode = $driver->report_mode; + if (!is_int($report_mode)) + printf("[005] Expecting int/any, got %s/%s\n", + gettype($report_mode), $report_mode); + + if (!in_array($report_mode, $all_modes)) + printf("[006] Illegal report mode returned? Got %s, expected %s\n", + $report_mode, implode(', ', $all_modes)); + + $driver->report_mode = MYSQLI_REPORT_STRICT; + $ok = false; + try { + + if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) + printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + mysqli_close($link); + + } catch (mysqli_sql_exception $e) { + $ok = true; + if ('' == $e->getMessage()) + printf("[008] getMessage() has returned an empty string.\n"); + if ('' == $e->getCode()) + printf("[009] getCode() has returned an empty string.\n"); + if ('' == $e->getFile()) + printf("[010] getFile() has returned an empty string.\n"); + if ('' == $e->getLine()) + printf("[011] getLine() has returned an empty string.\n"); + $tmp = $e->getTrace(); + if (empty($tmp)) + printf("[012] getTrace() has returned an empty array.\n"); + if ('' == $e->getTraceAsString()) + printf("[013] getTraceAsString() has returned an empty string.\n"); + if ('' == $e->__toString()) + printf("[014] __toString() has returned an empty string.\n"); + + } + if (!$ok) + printf("[015] Error reporting mode has not been switched to exceptions and or no exception thrown\n"); + + + $driver->report_mode = MYSQLI_REPORT_OFF; + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + mysqli_query($link, "NO_SQL"); + mysqli_close($link); + + $driver->report_mode = MYSQLI_REPORT_ERROR; + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + mysqli_query($link, "NO_SQL"); + mysqli_close($link); + + if (MYSQLI_REPORT_ERROR !== $driver->report_mode) + printf("[018] Error mode should be different\n"); + + /* TODO - more report testing should go in here, but it's not really documented what behaviour is expected */ + + $driver->report_mode = $report_mode; + + $reconnect = $driver->reconnect; + if (!is_bool($reconnect)) + printf("[019] Expecting boolean/any, got %s/%s\n", + gettype($reconnect), $reconnect); + + /* pointless, but I need more documentation */ + $driver->reconnect = true; + $driver->reconnect = false; + $driver->reconnect = $reconnect; + + if (!is_bool($embedded = $driver->embedded)) + printf("[020] Expecting boolean/any, got %s/%s\n", + gettype($embedded), $embedded); + + print "done!"; ?> --EXPECTF-- Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'NO_SQL' at line 1 in %s on line %d diff --git a/ext/mysqli/tests/mysqli_driver_unclonable.phpt b/ext/mysqli/tests/mysqli_driver_unclonable.phpt index 2b82f91d65c4..98559f46fc2b 100644 --- a/ext/mysqli/tests/mysqli_driver_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_driver_unclonable.phpt @@ -5,9 +5,9 @@ Trying to clone mysqli_driver object --FILE-- --EXPECTF-- Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_driver in %s:%d diff --git a/ext/mysqli/tests/mysqli_dump_debug_info.phpt b/ext/mysqli/tests/mysqli_dump_debug_info.phpt index d7ef81b822ca..95366417cfd6 100644 --- a/ext/mysqli/tests/mysqli_dump_debug_info.phpt +++ b/ext/mysqli/tests/mysqli_dump_debug_info.phpt @@ -8,20 +8,20 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; --EXPECT-- mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt b/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt index 8fb07617b73e..ae153a320aa1 100644 --- a/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt +++ b/ext/mysqli/tests/mysqli_dump_debug_info_oo.phpt @@ -8,20 +8,20 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- dump_debug_info())) - printf("[003] Expecting boolean/[true|false] value, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, - $mysqli->errno, $mysqli->error); + if (!is_bool($tmp = $mysqli->dump_debug_info())) + printf("[003] Expecting boolean/[true|false] value, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, + $mysqli->errno, $mysqli->error); - $mysqli->close(); + $mysqli->close(); try { $mysqli->dump_debug_info(); @@ -29,7 +29,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_embedded_connect.phpt b/ext/mysqli/tests/mysqli_embedded_connect.phpt index d1a8730a06ae..7c6ca78ad457 100644 --- a/ext/mysqli/tests/mysqli_embedded_connect.phpt +++ b/ext/mysqli/tests/mysqli_embedded_connect.phpt @@ -8,24 +8,24 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- Warning: mysqli_embedded_connect() expects parameter 1 to be mysqli, null given in %s on line %d diff --git a/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt b/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt index 3399f843b19a..203f58fd28a5 100644 --- a/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt +++ b/ext/mysqli/tests/mysqli_enable_reads_from_master.phpt @@ -12,35 +12,35 @@ if (!function_exists('mysqli_enable_reads_from_master')) { ?> --FILE-- getMessage() . "\n"; - } + try { + mysqli_close($link); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - if (NULL !== ($tmp = mysqli_enable_reads_from_master($link))) - printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = mysqli_enable_reads_from_master($link))) + printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECTF-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_errno.phpt b/ext/mysqli/tests/mysqli_errno.phpt index 04ab8a4a4126..2cfb17fde3bc 100644 --- a/ext/mysqli/tests/mysqli_errno.phpt +++ b/ext/mysqli/tests/mysqli_errno.phpt @@ -8,27 +8,27 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECTF-- int(0) diff --git a/ext/mysqli/tests/mysqli_errno_oo.phpt b/ext/mysqli/tests/mysqli_errno_oo.phpt index b548575d6dd3..d35477b2c40d 100644 --- a/ext/mysqli/tests/mysqli_errno_oo.phpt +++ b/ext/mysqli/tests/mysqli_errno_oo.phpt @@ -8,33 +8,33 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- errno)) - printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + $mysqli = new mysqli(); + if (0 !== ($tmp = @$mysqli->errno)) + printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - var_dump($mysqli->errno); + var_dump($mysqli->errno); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) { - printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query('DROP TABLE IF EXISTS test')) { + printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); + } - $mysqli->query('SELECT * FROM test'); - var_dump($mysqli->errno); + $mysqli->query('SELECT * FROM test'); + var_dump($mysqli->errno); - @$mysqli->query('No SQL'); - if (($tmp = $mysqli->errno) === 0) - printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp); + @$mysqli->query('No SQL'); + if (($tmp = $mysqli->errno) === 0) + printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp); - $mysqli->close(); + $mysqli->close(); try { $mysqli->errno; @@ -42,7 +42,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECTF-- int(0) diff --git a/ext/mysqli/tests/mysqli_error.phpt b/ext/mysqli/tests/mysqli_error.phpt index b7f034f26700..7a35cd0dd143 100644 --- a/ext/mysqli/tests/mysqli_error.phpt +++ b/ext/mysqli/tests/mysqli_error.phpt @@ -8,27 +8,27 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_error_oo.phpt b/ext/mysqli/tests/mysqli_error_oo.phpt index 3f3c67341585..177e3a9f5ac7 100644 --- a/ext/mysqli/tests/mysqli_error_oo.phpt +++ b/ext/mysqli/tests/mysqli_error_oo.phpt @@ -8,41 +8,41 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- error)) - printf("[001] Expecting empty string, got %s/'%s'\n", gettype($tmp), $tmp); + $mysqli = new mysqli(); + if ('' !== ($tmp = @$mysqli->error)) + printf("[001] Expecting empty string, got %s/'%s'\n", gettype($tmp), $tmp); - if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - $tmp = $mysqli->error; - if (!is_string($tmp) || ('' !== $tmp)) - printf("[003] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + $tmp = $mysqli->error; + if (!is_string($tmp) || ('' !== $tmp)) + printf("[003] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); - if (!$mysqli->query('DROP TABLE IF EXISTS test')) { - printf("[004] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$mysqli->query('DROP TABLE IF EXISTS test')) { + printf("[004] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error); + } - $mysqli->query('SELECT * FROM test'); - $tmp = $mysqli->error; - if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) - printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + $mysqli->query('SELECT * FROM test'); + $tmp = $mysqli->error; + if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp)) + printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); - $mysqli->close(); + $mysqli->close(); - try { + try { $mysqli->error; } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_error_unicode.phpt b/ext/mysqli/tests/mysqli_error_unicode.phpt index ce70c901e1de..1025f1cda261 100644 --- a/ext/mysqli/tests/mysqli_error_unicode.phpt +++ b/ext/mysqli/tests/mysqli_error_unicode.phpt @@ -8,25 +8,25 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; --EXPECTF-- string(%d) "Table 'нÑма_такава_таблица' doesn't exist" mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_expire_password.phpt b/ext/mysqli/tests/mysqli_expire_password.phpt index 679e210f92fa..18517e521a26 100644 --- a/ext/mysqli/tests/mysqli_expire_password.phpt +++ b/ext/mysqli/tests/mysqli_expire_password.phpt @@ -50,71 +50,71 @@ if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'% ?> --FILE-- query("SELECT id FROM test WHERE id = 1"); - printf("[002] Connect should fail, [%d] %s\n", $link->errno, $link->error); - } - /* explicitly requesting default */ - $link = mysqli_init(); - $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 0); - if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { - printf("[003] Cannot connect [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); - } else { - $link->query("SELECT id FROM test WHERE id = 1"); - printf("[004] Connect should fail, [%d] %s\n", $link->errno, $link->error); - } - - /* allow connect */ - $link = mysqli_init(); - $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1); - if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { - printf("[005] Cannot connect [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); - } else { - $link->query("SELECT id FROM test WHERE id = 1"); - printf("[006] Connect allowed, query fail, [%d] %s\n", $link->errno, $link->error); - $link->close(); - } - - /* allow connect, fix pw */ - $link = mysqli_init(); - $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1); - if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { - printf("[007] Cannot connect [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); - } else { - if (!$link->query("SET PASSWORD='expiretest'")) { - $link->query("SET PASSWORD=PASSWORD('expiretest')"); - } - printf("[008] Connect allowed, pw set, [%d] %s\n", $link->errno, $link->error); - if ($res = $link->query("SELECT id FROM test WHERE id = 1")) - var_dump($res->fetch_assoc()); - $link->close(); - } - - - /* check login */ - if (!$link = my_mysqli_connect($host, 'expiretest', "expiretest", $db, $port, $socket)) { - printf("[001] Cannot connect [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); - } else { - $link->query("SELECT id FROM test WHERE id = 1"); - if ($res = $link->query("SELECT id FROM test WHERE id = 1")) - var_dump($res->fetch_assoc()); - $link->close(); - } - - - - print "done!"; + require_once('connect.inc'); + require_once('table.inc'); + + /* default */ + if (!$link = my_mysqli_connect($host, 'expiretest', "", $db, $port, $socket)) { + printf("[001] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + printf("[002] Connect should fail, [%d] %s\n", $link->errno, $link->error); + } + /* explicitly requesting default */ + $link = mysqli_init(); + $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 0); + if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { + printf("[003] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + printf("[004] Connect should fail, [%d] %s\n", $link->errno, $link->error); + } + + /* allow connect */ + $link = mysqli_init(); + $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1); + if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { + printf("[005] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + printf("[006] Connect allowed, query fail, [%d] %s\n", $link->errno, $link->error); + $link->close(); + } + + /* allow connect, fix pw */ + $link = mysqli_init(); + $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1); + if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) { + printf("[007] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + if (!$link->query("SET PASSWORD='expiretest'")) { + $link->query("SET PASSWORD=PASSWORD('expiretest')"); + } + printf("[008] Connect allowed, pw set, [%d] %s\n", $link->errno, $link->error); + if ($res = $link->query("SELECT id FROM test WHERE id = 1")) + var_dump($res->fetch_assoc()); + $link->close(); + } + + + /* check login */ + if (!$link = my_mysqli_connect($host, 'expiretest', "expiretest", $db, $port, $socket)) { + printf("[001] Cannot connect [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + } else { + $link->query("SELECT id FROM test WHERE id = 1"); + if ($res = $link->query("SELECT id FROM test WHERE id = 1")) + var_dump($res->fetch_assoc()); + $link->close(); + } + + + + print "done!"; ?> --CLEAN-- --FILE-- $value) - $field_names[$name] = gettype($value); - } + $num_rows = 0; + $num_fields = 0; + $field_names = array(); + if (!$row = mysqli_fetch_assoc($res)) { + printf("[002] Expecting result but got no data [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + } else { + $num_rows++; + $num_fields = count($row); + foreach ($row as $name => $value) + $field_names[$name] = gettype($value); + } - while ($row = mysqli_fetch_assoc($res)) - $num_rows++; + while ($row = mysqli_fetch_assoc($res)) + $num_rows++; - if (($tmp = mysqli_num_rows($res)) !== $num_rows) { - printf("[003] Expecting int/%d got %s/%s\n", - $num_rows, gettype($tmp), $tmp); - } - if (($tmp = mysqli_field_count($link)) !== $num_fields) { - printf("[004] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } - $fields = mysqli_fetch_fields($res); - if (($tmp = count($fields)) !== $num_fields) { - printf("[005] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } + if (($tmp = mysqli_num_rows($res)) !== $num_rows) { + printf("[003] Expecting int/%d got %s/%s\n", + $num_rows, gettype($tmp), $tmp); + } + if (($tmp = mysqli_field_count($link)) !== $num_fields) { + printf("[004] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } + $fields = mysqli_fetch_fields($res); + if (($tmp = count($fields)) !== $num_fields) { + printf("[005] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } - foreach ($fields as $k => $field) { - $field->max_length = 0;// change it or we will get diff error - if (isset($field_names[$field->name])) { - unset($field_names[$field->name]); - } else { - printf("[006] Unexpected field '%s', dumping info\n"); - var_dump($field); - } - } - if (!empty($field_names)) { - printf("[007] Field descriptions missing for the following columns\n"); - var_dump($field_names); - } + foreach ($fields as $k => $field) { + $field->max_length = 0;// change it or we will get diff error + if (isset($field_names[$field->name])) { + unset($field_names[$field->name]); + } else { + printf("[006] Unexpected field '%s', dumping info\n"); + var_dump($field); + } + } + if (!empty($field_names)) { + printf("[007] Field descriptions missing for the following columns\n"); + var_dump($field_names); + } - mysqli_free_result($res); + mysqli_free_result($res); - $stmt = mysqli_stmt_init($link); - /* Depending on your version, the MySQL server migit not support this */ - if ($stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { - if (!mysqli_stmt_store_result($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $stmt = mysqli_stmt_init($link); + /* Depending on your version, the MySQL server migit not support this */ + if ($stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) { + if (!mysqli_stmt_store_result($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!$res_meta = mysqli_stmt_result_metadata($stmt)) - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!$res_meta = mysqli_stmt_result_metadata($stmt)) + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (($tmp = mysqli_stmt_num_rows($stmt)) !== $num_rows) { - printf("[010] Expecting int/%d got %s/%s\n", - $num_rows, gettype($tmp), $tmp); - } - if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { - printf("[011] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } - if (($tmp = mysqli_field_count($link)) !== $num_fields) { - printf("[013] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } - if (($tmp = $res_meta->field_count) !== $num_fields) { - printf("[014] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } - $fields_res_meta = mysqli_fetch_fields($res_meta); - if (($tmp = count($fields_res_meta)) !== $num_fields) - printf("[015] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); + if (($tmp = mysqli_stmt_num_rows($stmt)) !== $num_rows) { + printf("[010] Expecting int/%d got %s/%s\n", + $num_rows, gettype($tmp), $tmp); + } + if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { + printf("[011] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } + if (($tmp = mysqli_field_count($link)) !== $num_fields) { + printf("[013] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } + if (($tmp = $res_meta->field_count) !== $num_fields) { + printf("[014] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } + $fields_res_meta = mysqli_fetch_fields($res_meta); + if (($tmp = count($fields_res_meta)) !== $num_fields) + printf("[015] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); - if ($fields_res_meta != $fields) { - printf("[016] Prepared Statement metadata differs from normal metadata, dumping\n"); - var_dump($fields_res_meta); - var_dump($fields); - } + if ($fields_res_meta != $fields) { + printf("[016] Prepared Statement metadata differs from normal metadata, dumping\n"); + var_dump($fields_res_meta); + var_dump($fields); + } - if (function_exists('mysqli_stmt_get_result') && - $stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && - $stmt->execute()) { - if (!$res_stmt = mysqli_stmt_get_result($stmt)) { - printf("[017] Cannot fetch result from PS [%d] %s\n", - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - if (($tmp = mysqli_num_rows($res_stmt)) !== $num_rows) { - printf("[018] Expecting int/%d got %s/%s\n", - $num_rows, gettype($tmp), $tmp); - } - if ((mysqli_stmt_num_rows($stmt)) !== 0) { - printf("[019] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); - } - if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { - printf("[020] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); + if (function_exists('mysqli_stmt_get_result') && + $stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && + $stmt->execute()) { + if (!$res_stmt = mysqli_stmt_get_result($stmt)) { + printf("[017] Cannot fetch result from PS [%d] %s\n", + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + if (($tmp = mysqli_num_rows($res_stmt)) !== $num_rows) { + printf("[018] Expecting int/%d got %s/%s\n", + $num_rows, gettype($tmp), $tmp); + } + if ((mysqli_stmt_num_rows($stmt)) !== 0) { + printf("[019] Expecting int/0 got %s/%s\n", gettype($tmp), $tmp); + } + if (($tmp = mysqli_stmt_field_count($stmt)) !== $num_fields) { + printf("[020] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); - } - if (($tmp = $res_stmt->field_count) !== $num_fields) { - printf("[021] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } + } + if (($tmp = $res_stmt->field_count) !== $num_fields) { + printf("[021] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } - $fields_stmt = mysqli_fetch_fields($res_stmt); - if (($tmp = count($fields_stmt)) !== $num_fields) { - printf("[022] Expecting int/%d got %s/%s\n", - $num_fields, gettype($tmp), $tmp); - } - reset($fields); - foreach ($fields_stmt as $fields_stmt_val) { - $fields_val = current($fields); - next($fields); - unset($fields_stmt_val->max_length); - unset($fields_val->max_length); - if ($fields_stmt_val != $fields_val) { - printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); - var_dump($fields_stmt_val); - var_dump($fields_val); - } - } + $fields_stmt = mysqli_fetch_fields($res_stmt); + if (($tmp = count($fields_stmt)) !== $num_fields) { + printf("[022] Expecting int/%d got %s/%s\n", + $num_fields, gettype($tmp), $tmp); + } + reset($fields); + foreach ($fields_stmt as $fields_stmt_val) { + $fields_val = current($fields); + next($fields); + unset($fields_stmt_val->max_length); + unset($fields_val->max_length); + if ($fields_stmt_val != $fields_val) { + printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); + var_dump($fields_stmt_val); + var_dump($fields_val); + } + } /* - if ($fields_stmt != $fields) { - printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); - var_dump($fields_stmt); - var_dump($fields); - } + if ($fields_stmt != $fields) { + printf("[023] PS mysqli_stmt_get_result() metadata seems wrong, dumping\n"); + var_dump($fields_stmt); + var_dump($fields); + } */ - mysqli_free_result($res_stmt); - } - } - mysqli_stmt_close($stmt); + mysqli_free_result($res_stmt); + } + } + mysqli_stmt_close($stmt); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- flags & 128))) { - - if ($regexp_comparison) { - if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { - printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, $regexp_comparison, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); - return false; - } - } else { - if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { - printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); - return false; - } - } - } - - return true; - } - - function func_mysqli_fetch_array_make_string($len) { - - $ret = ''; - for ($i = 0; $i < $len; $i++) - $ret .= chr(mt_rand(65, 90)); - - return $ret; - } - - func_mysqli_fetch_all($link, $engine, "TINYINT", -11, "-11", 20); - func_mysqli_fetch_all($link, $engine, "TINYINT", NULL, NULL, 30); - func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", 1, "1", 40); - func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); - - func_mysqli_fetch_all($link, $engine, "BOOL", 1, "1", 60); - func_mysqli_fetch_all($link, $engine, "BOOL", NULL, NULL, 70); - func_mysqli_fetch_all($link, $engine, "BOOLEAN", 0, "0", 80); - func_mysqli_fetch_all($link, $engine, "BOOLEAN", NULL, NULL, 90); - - func_mysqli_fetch_all($link, $engine, "SMALLINT", -32768, "-32768", 100); - func_mysqli_fetch_all($link, $engine, "SMALLINT", 32767, "32767", 110); - func_mysqli_fetch_all($link, $engine, "SMALLINT", NULL, NULL, 120); - func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130); - func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); - - func_mysqli_fetch_all($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150); - func_mysqli_fetch_all($link, $engine, "MEDIUMINT", 8388607, "8388607", 160); - func_mysqli_fetch_all($link, $engine, "MEDIUMINT", NULL, NULL, 170); - func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); - func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); - - func_mysqli_fetch_all($link, $engine, "INTEGER", -2147483648, "-2147483648", 200); - func_mysqli_fetch_all($link, $engine, "INTEGER", 2147483647, "2147483647", 210); - func_mysqli_fetch_all($link, $engine, "INTEGER", NULL, NULL, 220); - func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); - func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); - - func_mysqli_fetch_all($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); - - func_mysqli_fetch_all($link, $engine, "BIGINT", NULL, NULL, 260); - func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); - func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); - - func_mysqli_fetch_all($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); - func_mysqli_fetch_all($link, $engine, "FLOAT", NULL, NULL, 300); - func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+19", 310, "/1\.84467e\+?[0]?19/iu"); - func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); - - func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); - func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); - func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); - func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); - - func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); - func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); - func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); - func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); - - // don't care about date() strict TZ warnings... - func_mysqli_fetch_all($link, $engine, "DATE", @date('Y-m-d'), @date('Y-m-d'), 410); - func_mysqli_fetch_all($link, $engine, "DATE NOT NULL", @date('Y-m-d'), @date('Y-m-d'), 420); - func_mysqli_fetch_all($link, $engine, "DATE", NULL, NULL, 430); - - func_mysqli_fetch_all($link, $engine, "DATETIME", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 440); - func_mysqli_fetch_all($link, $engine, "DATETIME NOT NULL", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 450); - func_mysqli_fetch_all($link, $engine, "DATETIME", NULL, NULL, 460); - - func_mysqli_fetch_all($link, $engine, "TIMESTAMP", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 470); - - func_mysqli_fetch_all($link, $engine, "TIME", @date('H:i:s'), @date('H:i:s'), 480); - func_mysqli_fetch_all($link, $engine, "TIME NOT NULL", @date('H:i:s'), @date('H:i:s'), 490); - func_mysqli_fetch_all($link, $engine, "TIME", NULL, NULL, 500); - - func_mysqli_fetch_all($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); - func_mysqli_fetch_all($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); - func_mysqli_fetch_all($link, $engine, "YEAR", NULL, NULL, 530); - - $string255 = func_mysqli_fetch_array_make_string(255); - func_mysqli_fetch_all($link, $engine, "CHAR(1)", "a", "a", 540); - func_mysqli_fetch_all($link, $engine, "CHAR(255)", $string255, $string255, 550); - func_mysqli_fetch_all($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); - func_mysqli_fetch_all($link, $engine, "CHAR(1)", NULL, NULL, 570); - - $string65k = func_mysqli_fetch_array_make_string(65400); - func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", "a", "a", 580); - func_mysqli_fetch_all($link, $engine, "VARCHAR(255)", $string255, $string255, 590); - func_mysqli_fetch_all($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); - func_mysqli_fetch_all($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); - func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", NULL, NULL, 620); - - func_mysqli_fetch_all($link, $engine, "BINARY(1)", "a", "a", 630); - func_mysqli_fetch_all($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640); - func_mysqli_fetch_all($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650); - func_mysqli_fetch_all($link, $engine, "BINARY(1)", NULL, NULL, 660); - - func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", "a", "a", 670); - func_mysqli_fetch_all($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680); - func_mysqli_fetch_all($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); - func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", NULL, NULL, 700); - - func_mysqli_fetch_all($link, $engine, "TINYBLOB", "a", "a", 710); - func_mysqli_fetch_all($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720); - func_mysqli_fetch_all($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730); - func_mysqli_fetch_all($link, $engine, "TINYBLOB", NULL, NULL, 740); - - func_mysqli_fetch_all($link, $engine, "TINYTEXT", "a", "a", 750); - func_mysqli_fetch_all($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); - func_mysqli_fetch_all($link, $engine, "TINYTEXT", NULL, NULL, 770); - - func_mysqli_fetch_all($link, $engine, "BLOB", "a", "a", 780); - func_mysqli_fetch_all($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780); - func_mysqli_fetch_all($link, $engine, "BLOB", NULL, NULL, 790); - - func_mysqli_fetch_all($link, $engine, "TEXT", "a", "a", 800); - func_mysqli_fetch_all($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); - func_mysqli_fetch_all($link, $engine, "TEXT", NULL, NULL, 820); - - func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", "a", "a", 830); - func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840); - func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", NULL, NULL, 850); - - func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", "a", "a", 860); - func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); - func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); - - func_mysqli_fetch_all($link, $engine, "LONGBLOB", "a", "a", 890); - func_mysqli_fetch_all($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); - func_mysqli_fetch_all($link, $engine, "LONGBLOB", NULL, NULL, 910); - - func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", "a", "a", 920); - func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); - - func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", "a", "a", 940); - func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", NULL, NULL, 950); + mysqli_free_result($res); + + function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail, engine might not support the datatype + return false; + } + + if (is_null($php_value)) { + if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + } else { + if (is_string($sql_value)) { + if (!mysqli_query($link, $sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) { + printf("[%04ds] [%d] %s - %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link), $sql); + return false; + } + } else { + if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { + printf("[%04di] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + } + } + + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) { + printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link)); + return false; + } + $row = $tmp[0]; + + $fields = mysqli_fetch_fields($res); + + if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { + + if ($regexp_comparison) { + if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { + printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, $regexp_comparison, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + } else { + if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { + printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + } + } + + return true; + } + + function func_mysqli_fetch_array_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_fetch_all($link, $engine, "TINYINT", -11, "-11", 20); + func_mysqli_fetch_all($link, $engine, "TINYINT", NULL, NULL, 30); + func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", 1, "1", 40); + func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); + + func_mysqli_fetch_all($link, $engine, "BOOL", 1, "1", 60); + func_mysqli_fetch_all($link, $engine, "BOOL", NULL, NULL, 70); + func_mysqli_fetch_all($link, $engine, "BOOLEAN", 0, "0", 80); + func_mysqli_fetch_all($link, $engine, "BOOLEAN", NULL, NULL, 90); + + func_mysqli_fetch_all($link, $engine, "SMALLINT", -32768, "-32768", 100); + func_mysqli_fetch_all($link, $engine, "SMALLINT", 32767, "32767", 110); + func_mysqli_fetch_all($link, $engine, "SMALLINT", NULL, NULL, 120); + func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130); + func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); + + func_mysqli_fetch_all($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150); + func_mysqli_fetch_all($link, $engine, "MEDIUMINT", 8388607, "8388607", 160); + func_mysqli_fetch_all($link, $engine, "MEDIUMINT", NULL, NULL, 170); + func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); + func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); + + func_mysqli_fetch_all($link, $engine, "INTEGER", -2147483648, "-2147483648", 200); + func_mysqli_fetch_all($link, $engine, "INTEGER", 2147483647, "2147483647", 210); + func_mysqli_fetch_all($link, $engine, "INTEGER", NULL, NULL, 220); + func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); + func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); + + func_mysqli_fetch_all($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); + + func_mysqli_fetch_all($link, $engine, "BIGINT", NULL, NULL, 260); + func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); + func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); + + func_mysqli_fetch_all($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); + func_mysqli_fetch_all($link, $engine, "FLOAT", NULL, NULL, 300); + func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+19", 310, "/1\.84467e\+?[0]?19/iu"); + func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); + + func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); + func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); + func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); + func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); + + func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); + func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); + func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); + func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); + + // don't care about date() strict TZ warnings... + func_mysqli_fetch_all($link, $engine, "DATE", @date('Y-m-d'), @date('Y-m-d'), 410); + func_mysqli_fetch_all($link, $engine, "DATE NOT NULL", @date('Y-m-d'), @date('Y-m-d'), 420); + func_mysqli_fetch_all($link, $engine, "DATE", NULL, NULL, 430); + + func_mysqli_fetch_all($link, $engine, "DATETIME", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 440); + func_mysqli_fetch_all($link, $engine, "DATETIME NOT NULL", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 450); + func_mysqli_fetch_all($link, $engine, "DATETIME", NULL, NULL, 460); + + func_mysqli_fetch_all($link, $engine, "TIMESTAMP", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 470); + + func_mysqli_fetch_all($link, $engine, "TIME", @date('H:i:s'), @date('H:i:s'), 480); + func_mysqli_fetch_all($link, $engine, "TIME NOT NULL", @date('H:i:s'), @date('H:i:s'), 490); + func_mysqli_fetch_all($link, $engine, "TIME", NULL, NULL, 500); + + func_mysqli_fetch_all($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); + func_mysqli_fetch_all($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); + func_mysqli_fetch_all($link, $engine, "YEAR", NULL, NULL, 530); + + $string255 = func_mysqli_fetch_array_make_string(255); + func_mysqli_fetch_all($link, $engine, "CHAR(1)", "a", "a", 540); + func_mysqli_fetch_all($link, $engine, "CHAR(255)", $string255, $string255, 550); + func_mysqli_fetch_all($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); + func_mysqli_fetch_all($link, $engine, "CHAR(1)", NULL, NULL, 570); + + $string65k = func_mysqli_fetch_array_make_string(65400); + func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", "a", "a", 580); + func_mysqli_fetch_all($link, $engine, "VARCHAR(255)", $string255, $string255, 590); + func_mysqli_fetch_all($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); + func_mysqli_fetch_all($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); + func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", NULL, NULL, 620); + + func_mysqli_fetch_all($link, $engine, "BINARY(1)", "a", "a", 630); + func_mysqli_fetch_all($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640); + func_mysqli_fetch_all($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650); + func_mysqli_fetch_all($link, $engine, "BINARY(1)", NULL, NULL, 660); + + func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", "a", "a", 670); + func_mysqli_fetch_all($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680); + func_mysqli_fetch_all($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); + func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", NULL, NULL, 700); + + func_mysqli_fetch_all($link, $engine, "TINYBLOB", "a", "a", 710); + func_mysqli_fetch_all($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720); + func_mysqli_fetch_all($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730); + func_mysqli_fetch_all($link, $engine, "TINYBLOB", NULL, NULL, 740); + + func_mysqli_fetch_all($link, $engine, "TINYTEXT", "a", "a", 750); + func_mysqli_fetch_all($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); + func_mysqli_fetch_all($link, $engine, "TINYTEXT", NULL, NULL, 770); + + func_mysqli_fetch_all($link, $engine, "BLOB", "a", "a", 780); + func_mysqli_fetch_all($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780); + func_mysqli_fetch_all($link, $engine, "BLOB", NULL, NULL, 790); + + func_mysqli_fetch_all($link, $engine, "TEXT", "a", "a", 800); + func_mysqli_fetch_all($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); + func_mysqli_fetch_all($link, $engine, "TEXT", NULL, NULL, 820); + + func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", "a", "a", 830); + func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840); + func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", NULL, NULL, 850); + + func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", "a", "a", 860); + func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); + func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); + + func_mysqli_fetch_all($link, $engine, "LONGBLOB", "a", "a", 890); + func_mysqli_fetch_all($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); + func_mysqli_fetch_all($link, $engine, "LONGBLOB", NULL, NULL, 910); + + func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", "a", "a", 920); + func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); + + func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", "a", "a", 940); + func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", NULL, NULL, 950); - mysqli_close($link); + mysqli_close($link); try { mysqli_fetch_array($res, MYSQLI_ASSOC); @@ -290,26 +290,26 @@ if (!function_exists('mysqli_fetch_all')) echo $exception->getMessage() . "\n"; } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } - if (!$res = mysqli_real_query($link, "SELECT 1 AS _one")) - printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_real_query($link, "SELECT 1 AS _one")) + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - /* on mysqlnd level this would not be allowed */ - if (!is_object($res = mysqli_use_result($link))) - printf("[018] Expecting object, got %s/%s. [%d] %s\n", - gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + /* on mysqlnd level this would not be allowed */ + if (!is_object($res = mysqli_use_result($link))) + printf("[018] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - $rows = mysqli_fetch_all($res, MYSQLI_ASSOC); - if (!is_array($rows) || (count($rows) > 1) || !isset($rows[0]['_one']) || ($rows[0]['_one'] != 1)) { - printf("[019] Results seem wrong, dumping\n"); - var_dump($rows); - } + $rows = mysqli_fetch_all($res, MYSQLI_ASSOC); + if (!is_array($rows) || (count($rows) > 1) || !isset($rows[0]['_one']) || ($rows[0]['_one'] != 1)) { + printf("[019] Results seem wrong, dumping\n"); + var_dump($rows); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT * FROM test ORDER BY id LIMIT 2")) { - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - print "[005]\n"; - var_dump($res->fetch_all()); - $res->free_result(); - - if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { - printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - print "[007]\n"; - var_dump($res->fetch_all(MYSQLI_NUM)); - $res->free_result(); - - if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { - printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - print "[008]\n"; - var_dump($res->fetch_all(MYSQLI_BOTH)); - $res->free_result(); - - if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { - printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - print "[010]\n"; - var_dump($res->fetch_all(MYSQLI_ASSOC)); - - print "[011]\n"; - var_dump($res->fetch_array()); - $res->free_result(); - - if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { - printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - print "[013]\n"; - var_dump($res->fetch_all(MYSQLI_ASSOC)); - - print "[016]\n"; - var_dump($res->fetch_array()); - - if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { - printf("[010] Cannot run query, [%d] %s\n", $mysqli->errno, $$mysqli->error); - } - print "[017]\n"; - var_dump($res->fetch_all(MYSQLI_BOTH)); - - $res->free_result(); - if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) { - printf("[018] Cannot run query, [%d] %s\n", - $mysqli->errno, $$mysqli->error); - exit(1); - } - - do { - $illegal_mode = mt_rand(-10000, 10000); - } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); - // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. - $tmp = $res->fetch_all($illegal_mode); - if (false !== $tmp) - printf("[019] Expecting boolean/false although, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); - - $res->free_result(); - - function func_mysqli_fetch_all_oo($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { - - if (!$link->query("DROP TABLE IF EXISTS test")) { - printf("[%04d] [%d] %s\n", $offset, $link->errno, $link->error); - return false; - } - - if (!$link->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { - // don't bail, engine might not support the datatype - return false; - } - - if (is_null($php_value)) { - if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { - printf("[%04d] [%d] %s\n", $offset + 1, $link->errno, $link->error); - return false; - } - } else { - if (is_string($sql_value)) { - if (!$link->query($sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) { - printf("[%04ds] [%d] %s - %s\n", $offset + 1, $link->errno, $link->error, $sql); - return false; - } - } else { - if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { - printf("[%04di] [%d] %s\n", $offset + 1, $link->errno, $link->error); - return false; - } - } - } - - if (!$res = $link->query("SELECT id, label FROM test")) { - printf("[%04d] [%d] %s\n", $offset + 2, $link->errno, $link->error); - return false; - } - - if (!$tmp = $res->fetch_all(MYSQLI_BOTH)) { - printf("[%04d] [%d] %s\n", $offset + 3, $link->errno, $link->error); - return false; - } - $row = $tmp[0]; - - $fields = mysqli_fetch_fields($res); - - if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { - if ($regexp_comparison) { - if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { - printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, $regexp_comparison, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], $link->errno, $link->error); - return false; - } - } else { - if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { - printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], $link->errno, $link->error); - return false; - } - } - } - - return true; - } - - function func_mysqli_fetch_array_oo_make_string($len) { - - $ret = ''; - for ($i = 0; $i < $len; $i++) - $ret .= chr(mt_rand(65, 90)); - - return $ret; - } - - func_mysqli_fetch_all_oo($link, $engine, "TINYINT", -11, "-11", 20); - func_mysqli_fetch_all_oo($link, $engine, "TINYINT", NULL, NULL, 30); - func_mysqli_fetch_all_oo($link, $engine, "TINYINT UNSIGNED", 1, "1", 40); - func_mysqli_fetch_all_oo($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); - - func_mysqli_fetch_all_oo($link, $engine, "BOOL", 1, "1", 60); - func_mysqli_fetch_all_oo($link, $engine, "BOOL", NULL, NULL, 70); - func_mysqli_fetch_all_oo($link, $engine, "BOOLEAN", 0, "0", 80); - func_mysqli_fetch_all_oo($link, $engine, "BOOLEAN", NULL, NULL, 90); - - func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", -32768, "-32768", 100); - func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", 32767, "32767", 110); - func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", NULL, NULL, 120); - func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", 65400, "65400", 130); - func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); - - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", 8388607, "8388607", 160); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", NULL, NULL, 170); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); - - func_mysqli_fetch_all_oo($link, $engine, "INTEGER", -2147483648, "-2147483648", 200); - func_mysqli_fetch_all_oo($link, $engine, "INTEGER", 2147483647, "2147483647", 210); - func_mysqli_fetch_all_oo($link, $engine, "INTEGER", NULL, NULL, 220); - func_mysqli_fetch_all_oo($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); - func_mysqli_fetch_all_oo($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); - - func_mysqli_fetch_all_oo($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); - func_mysqli_fetch_all_oo($link, $engine, "BIGINT", NULL, NULL, 260); - func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); - func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); - - func_mysqli_fetch_all_oo($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); - func_mysqli_fetch_all_oo($link, $engine, "FLOAT", NULL, NULL, 300); - func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu"); - func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); - - func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); - func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); - func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); - func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); - - func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); - func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); - func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); - func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); - - // don't care about date() strict TZ warnings... - $date = @date('Y-m-d'); - func_mysqli_fetch_all_oo($link, $engine, "DATE", $date, $date, 410); - func_mysqli_fetch_all_oo($link, $engine, "DATE NOT NULL", $date, $date, 420); - func_mysqli_fetch_all_oo($link, $engine, "DATE", NULL, NULL, 430); - - $datetime = @date('Y-m-d H:i:s'); - func_mysqli_fetch_all_oo($link, $engine, "DATETIME", $datetime, $datetime, 440); - func_mysqli_fetch_all_oo($link, $engine, "DATETIME NOT NULL", $datetime, $datetime, 450); - func_mysqli_fetch_all_oo($link, $engine, "DATETIME", NULL, NULL, 460); - - func_mysqli_fetch_all_oo($link, $engine, "TIMESTAMP", $datetime, $datetime, 470); - - $time = @date('H:i:s'); - func_mysqli_fetch_all_oo($link, $engine, "TIME", $time, $time, 480); - func_mysqli_fetch_all_oo($link, $engine, "TIME NOT NULL", $time, $time, 490); - func_mysqli_fetch_all_oo($link, $engine, "TIME", NULL, NULL, 500); - - func_mysqli_fetch_all_oo($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); - func_mysqli_fetch_all_oo($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); - func_mysqli_fetch_all_oo($link, $engine, "YEAR", NULL, NULL, 530); - - $string255 = func_mysqli_fetch_array_oo_make_string(255); - func_mysqli_fetch_all_oo($link, $engine, "CHAR(1)", "a", "a", 540); - func_mysqli_fetch_all_oo($link, $engine, "CHAR(255)", $string255, $string255, 550); - func_mysqli_fetch_all_oo($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); - func_mysqli_fetch_all_oo($link, $engine, "CHAR(1)", NULL, NULL, 570); - - $string65k = func_mysqli_fetch_array_oo_make_string(65400); - func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1)", "a", "a", 580); - func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(255)", $string255, $string255, 590); - func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); - func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); - func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1)", NULL, NULL, 620); - - func_mysqli_fetch_all_oo($link, $engine, "BINARY(1)", "a", "a", 630); - func_mysqli_fetch_all_oo($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640); - func_mysqli_fetch_all_oo($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650); - func_mysqli_fetch_all_oo($link, $engine, "BINARY(1)", NULL, NULL, 660); - - func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(1)", "a", "a", 670); - func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680); - func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); - func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(1)", NULL, NULL, 700); - - func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB", "a", "a", 710); - func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720); - func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730); - func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB", NULL, NULL, 740); - - func_mysqli_fetch_all_oo($link, $engine, "TINYTEXT", "a", "a", 750); - func_mysqli_fetch_all_oo($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); - func_mysqli_fetch_all_oo($link, $engine, "TINYTEXT", NULL, NULL, 770); - - func_mysqli_fetch_all_oo($link, $engine, "BLOB", "a", "a", 780); - func_mysqli_fetch_all_oo($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780); - func_mysqli_fetch_all_oo($link, $engine, "BLOB", NULL, NULL, 790); - - func_mysqli_fetch_all_oo($link, $engine, "TEXT", "a", "a", 800); - func_mysqli_fetch_all_oo($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); - func_mysqli_fetch_all_oo($link, $engine, "TEXT", NULL, NULL, 820); - - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMBLOB", "a", "a", 830); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMBLOB", NULL, NULL, 850); - - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMTEXT", "a", "a", 860); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); - func_mysqli_fetch_all_oo($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); - - func_mysqli_fetch_all_oo($link, $engine, "LONGBLOB", "a", "a", 890); - func_mysqli_fetch_all_oo($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); - func_mysqli_fetch_all_oo($link, $engine, "LONGBLOB", NULL, NULL, 910); - - func_mysqli_fetch_all_oo($link, $engine, "ENUM('a', 'b')", "a", "a", 920); - func_mysqli_fetch_all_oo($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); - - func_mysqli_fetch_all_oo($link, $engine, "SET('a', 'b')", "a", "a", 940); - func_mysqli_fetch_all_oo($link, $engine, "SET('a', 'b')", NULL, NULL, 950); - - mysqli_close($link); + require_once("connect.inc"); + + $tmp = NULL; + $link = NULL; + + $mysqli = new mysqli(); + + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + require('table.inc'); + if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + print "[005]\n"; + var_dump($res->fetch_all()); + $res->free_result(); + + if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { + printf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + print "[007]\n"; + var_dump($res->fetch_all(MYSQLI_NUM)); + $res->free_result(); + + if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { + printf("[008] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + print "[008]\n"; + var_dump($res->fetch_all(MYSQLI_BOTH)); + $res->free_result(); + + if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { + printf("[009] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + print "[010]\n"; + var_dump($res->fetch_all(MYSQLI_ASSOC)); + + print "[011]\n"; + var_dump($res->fetch_array()); + $res->free_result(); + + if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 2")) { + printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + print "[013]\n"; + var_dump($res->fetch_all(MYSQLI_ASSOC)); + + print "[016]\n"; + var_dump($res->fetch_array()); + + if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { + printf("[010] Cannot run query, [%d] %s\n", $mysqli->errno, $$mysqli->error); + } + print "[017]\n"; + var_dump($res->fetch_all(MYSQLI_BOTH)); + + $res->free_result(); + if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) { + printf("[018] Cannot run query, [%d] %s\n", + $mysqli->errno, $$mysqli->error); + exit(1); + } + + do { + $illegal_mode = mt_rand(-10000, 10000); + } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); + // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. + $tmp = $res->fetch_all($illegal_mode); + if (false !== $tmp) + printf("[019] Expecting boolean/false although, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + + $res->free_result(); + + function func_mysqli_fetch_all_oo($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { + + if (!$link->query("DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + if (!$link->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail, engine might not support the datatype + return false; + } + + if (is_null($php_value)) { + if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { + printf("[%04d] [%d] %s\n", $offset + 1, $link->errno, $link->error); + return false; + } + } else { + if (is_string($sql_value)) { + if (!$link->query($sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) { + printf("[%04ds] [%d] %s - %s\n", $offset + 1, $link->errno, $link->error, $sql); + return false; + } + } else { + if (!$link->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { + printf("[%04di] [%d] %s\n", $offset + 1, $link->errno, $link->error); + return false; + } + } + } + + if (!$res = $link->query("SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 2, $link->errno, $link->error); + return false; + } + + if (!$tmp = $res->fetch_all(MYSQLI_BOTH)) { + printf("[%04d] [%d] %s\n", $offset + 3, $link->errno, $link->error); + return false; + } + $row = $tmp[0]; + + $fields = mysqli_fetch_fields($res); + + if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { + if ($regexp_comparison) { + if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { + printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, $regexp_comparison, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], $link->errno, $link->error); + return false; + } + } else { + if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { + printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], $link->errno, $link->error); + return false; + } + } + } + + return true; + } + + function func_mysqli_fetch_array_oo_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_fetch_all_oo($link, $engine, "TINYINT", -11, "-11", 20); + func_mysqli_fetch_all_oo($link, $engine, "TINYINT", NULL, NULL, 30); + func_mysqli_fetch_all_oo($link, $engine, "TINYINT UNSIGNED", 1, "1", 40); + func_mysqli_fetch_all_oo($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); + + func_mysqli_fetch_all_oo($link, $engine, "BOOL", 1, "1", 60); + func_mysqli_fetch_all_oo($link, $engine, "BOOL", NULL, NULL, 70); + func_mysqli_fetch_all_oo($link, $engine, "BOOLEAN", 0, "0", 80); + func_mysqli_fetch_all_oo($link, $engine, "BOOLEAN", NULL, NULL, 90); + + func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", -32768, "-32768", 100); + func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", 32767, "32767", 110); + func_mysqli_fetch_all_oo($link, $engine, "SMALLINT", NULL, NULL, 120); + func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", 65400, "65400", 130); + func_mysqli_fetch_all_oo($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); + + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", 8388607, "8388607", 160); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT", NULL, NULL, 170); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); + + func_mysqli_fetch_all_oo($link, $engine, "INTEGER", -2147483648, "-2147483648", 200); + func_mysqli_fetch_all_oo($link, $engine, "INTEGER", 2147483647, "2147483647", 210); + func_mysqli_fetch_all_oo($link, $engine, "INTEGER", NULL, NULL, 220); + func_mysqli_fetch_all_oo($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); + func_mysqli_fetch_all_oo($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); + + func_mysqli_fetch_all_oo($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); + func_mysqli_fetch_all_oo($link, $engine, "BIGINT", NULL, NULL, 260); + func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); + func_mysqli_fetch_all_oo($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); + + func_mysqli_fetch_all_oo($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); + func_mysqli_fetch_all_oo($link, $engine, "FLOAT", NULL, NULL, 300); + func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu"); + func_mysqli_fetch_all_oo($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); + + func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); + func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); + func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); + func_mysqli_fetch_all_oo($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); + + func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); + func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); + func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); + func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); + + // don't care about date() strict TZ warnings... + $date = @date('Y-m-d'); + func_mysqli_fetch_all_oo($link, $engine, "DATE", $date, $date, 410); + func_mysqli_fetch_all_oo($link, $engine, "DATE NOT NULL", $date, $date, 420); + func_mysqli_fetch_all_oo($link, $engine, "DATE", NULL, NULL, 430); + + $datetime = @date('Y-m-d H:i:s'); + func_mysqli_fetch_all_oo($link, $engine, "DATETIME", $datetime, $datetime, 440); + func_mysqli_fetch_all_oo($link, $engine, "DATETIME NOT NULL", $datetime, $datetime, 450); + func_mysqli_fetch_all_oo($link, $engine, "DATETIME", NULL, NULL, 460); + + func_mysqli_fetch_all_oo($link, $engine, "TIMESTAMP", $datetime, $datetime, 470); + + $time = @date('H:i:s'); + func_mysqli_fetch_all_oo($link, $engine, "TIME", $time, $time, 480); + func_mysqli_fetch_all_oo($link, $engine, "TIME NOT NULL", $time, $time, 490); + func_mysqli_fetch_all_oo($link, $engine, "TIME", NULL, NULL, 500); + + func_mysqli_fetch_all_oo($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); + func_mysqli_fetch_all_oo($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); + func_mysqli_fetch_all_oo($link, $engine, "YEAR", NULL, NULL, 530); + + $string255 = func_mysqli_fetch_array_oo_make_string(255); + func_mysqli_fetch_all_oo($link, $engine, "CHAR(1)", "a", "a", 540); + func_mysqli_fetch_all_oo($link, $engine, "CHAR(255)", $string255, $string255, 550); + func_mysqli_fetch_all_oo($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); + func_mysqli_fetch_all_oo($link, $engine, "CHAR(1)", NULL, NULL, 570); + + $string65k = func_mysqli_fetch_array_oo_make_string(65400); + func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1)", "a", "a", 580); + func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(255)", $string255, $string255, 590); + func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); + func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); + func_mysqli_fetch_all_oo($link, $engine, "VARCHAR(1)", NULL, NULL, 620); + + func_mysqli_fetch_all_oo($link, $engine, "BINARY(1)", "a", "a", 630); + func_mysqli_fetch_all_oo($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640); + func_mysqli_fetch_all_oo($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650); + func_mysqli_fetch_all_oo($link, $engine, "BINARY(1)", NULL, NULL, 660); + + func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(1)", "a", "a", 670); + func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680); + func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); + func_mysqli_fetch_all_oo($link, $engine, "VARBINARY(1)", NULL, NULL, 700); + + func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB", "a", "a", 710); + func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720); + func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730); + func_mysqli_fetch_all_oo($link, $engine, "TINYBLOB", NULL, NULL, 740); + + func_mysqli_fetch_all_oo($link, $engine, "TINYTEXT", "a", "a", 750); + func_mysqli_fetch_all_oo($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); + func_mysqli_fetch_all_oo($link, $engine, "TINYTEXT", NULL, NULL, 770); + + func_mysqli_fetch_all_oo($link, $engine, "BLOB", "a", "a", 780); + func_mysqli_fetch_all_oo($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780); + func_mysqli_fetch_all_oo($link, $engine, "BLOB", NULL, NULL, 790); + + func_mysqli_fetch_all_oo($link, $engine, "TEXT", "a", "a", 800); + func_mysqli_fetch_all_oo($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); + func_mysqli_fetch_all_oo($link, $engine, "TEXT", NULL, NULL, 820); + + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMBLOB", "a", "a", 830); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMBLOB", NULL, NULL, 850); + + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMTEXT", "a", "a", 860); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); + func_mysqli_fetch_all_oo($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); + + func_mysqli_fetch_all_oo($link, $engine, "LONGBLOB", "a", "a", 890); + func_mysqli_fetch_all_oo($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); + func_mysqli_fetch_all_oo($link, $engine, "LONGBLOB", NULL, NULL, 910); + + func_mysqli_fetch_all_oo($link, $engine, "ENUM('a', 'b')", "a", "a", 920); + func_mysqli_fetch_all_oo($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); + + func_mysqli_fetch_all_oo($link, $engine, "SET('a', 'b')", "a", "a", 940); + func_mysqli_fetch_all_oo($link, $engine, "SET('a', 'b')", NULL, NULL, 950); + + mysqli_close($link); try { $res->fetch_array(MYSQLI_ASSOC); @@ -304,7 +304,7 @@ if (!function_exists('mysqli_fetch_all')) echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- = 51000) && - (mysqli_get_client_version($link) >= 51000))) { - func_mysqli_fetch_array($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); - func_mysqli_fetch_array($link, $engine, "BIGINT", NULL, NULL, 260); - func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 260); - func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); - } - - func_mysqli_fetch_array($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); - func_mysqli_fetch_array($link, $engine, "FLOAT", NULL, NULL, 300); - func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu"); - func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); - - func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); - func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); - func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); - func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); - - func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); - func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); - func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); - func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); - - // don't care about date() strict TZ warnings... - $date = @date('Y-m-d'); - func_mysqli_fetch_array($link, $engine, "DATE",$date, $date, 410); - func_mysqli_fetch_array($link, $engine, "DATE NOT NULL",$date, $date, 420); - func_mysqli_fetch_array($link, $engine, "DATE", NULL, NULL, 430); - - $date = @date('Y-m-d H:i:s'); - func_mysqli_fetch_array($link, $engine, "DATETIME", $date, $date, 440); - func_mysqli_fetch_array($link, $engine, "DATETIME NOT NULL", $date, $date, 450); - func_mysqli_fetch_array($link, $engine, "DATETIME", NULL, NULL, 460); - func_mysqli_fetch_array($link, $engine, "TIMESTAMP", $date, $date, 470); - - $date = @date('H:i:s'); - func_mysqli_fetch_array($link, $engine, "TIME", $date, $date, 480); - func_mysqli_fetch_array($link, $engine, "TIME NOT NULL", $date, $date, 490); - func_mysqli_fetch_array($link, $engine, "TIME", NULL, NULL, 500); - - func_mysqli_fetch_array($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); - func_mysqli_fetch_array($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); - func_mysqli_fetch_array($link, $engine, "YEAR", NULL, NULL, 530); - - $string255 = func_mysqli_fetch_array_make_string(255); - func_mysqli_fetch_array($link, $engine, "CHAR(1)", "a", "a", 540); - func_mysqli_fetch_array($link, $engine, "CHAR(255)", $string255, $string255, 550); - func_mysqli_fetch_array($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); - func_mysqli_fetch_array($link, $engine, "CHAR(1)", NULL, NULL, 570); - - $string65k = func_mysqli_fetch_array_make_string(65400); - func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", "a", "a", 580); - func_mysqli_fetch_array($link, $engine, "VARCHAR(255)", $string255, $string255, 590); - func_mysqli_fetch_array($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); - func_mysqli_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); - func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620); - - func_mysqli_fetch_array($link, $engine, "BINARY(1)", "a", "a", 630, null, true); - func_mysqli_fetch_array($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640, null, true); - func_mysqli_fetch_array($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650, null, true); - func_mysqli_fetch_array($link, $engine, "BINARY(1)", NULL, NULL, 660, null, true); - - func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", "a", "a", 670, null, true); - func_mysqli_fetch_array($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680, null, true); - func_mysqli_fetch_array($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690, null, true); - func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", NULL, NULL, 700, null, true); - - func_mysqli_fetch_array($link, $engine, "TINYBLOB", "a", "a", 710, null, true); - func_mysqli_fetch_array($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720, null, true); - func_mysqli_fetch_array($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730, null, true); - func_mysqli_fetch_array($link, $engine, "TINYBLOB", NULL, NULL, 740, null, true); - - func_mysqli_fetch_array($link, $engine, "TINYTEXT", "a", "a", 750); - func_mysqli_fetch_array($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); - func_mysqli_fetch_array($link, $engine, "TINYTEXT", NULL, NULL, 770); - - func_mysqli_fetch_array($link, $engine, "BLOB", "a", "a", 780, null, true); - func_mysqli_fetch_array($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780, null, true); - func_mysqli_fetch_array($link, $engine, "BLOB", NULL, NULL, 790, null, true); - - func_mysqli_fetch_array($link, $engine, "TEXT", "a", "a", 800); - func_mysqli_fetch_array($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); - func_mysqli_fetch_array($link, $engine, "TEXT", NULL, NULL, 820); - - func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", "a", "a", 830, null, true); - func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840, null, true); - func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", NULL, NULL, 850, null, true); - - func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", "a", "a", 860); - func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); - func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); - - func_mysqli_fetch_array($link, $engine, "LONGBLOB", "a", "a", 890, null, true); - func_mysqli_fetch_array($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); - func_mysqli_fetch_array($link, $engine, "LONGBLOB", NULL, NULL, 910, null, true); - - func_mysqli_fetch_array($link, $engine, "ENUM('a', 'b')", "a", "a", 920); - func_mysqli_fetch_array($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); - - func_mysqli_fetch_array($link, $engine, "SET('a', 'b')", "a", "a", 940); - func_mysqli_fetch_array($link, $engine, "SET('a', 'b')", NULL, NULL, 950); - - mysqli_close($link); + require_once("connect.inc"); + + require('table.inc'); + if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 5")) { + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + print "[005]\n"; + var_dump(mysqli_fetch_array($res)); + + print "[006]\n"; + var_dump(mysqli_fetch_array($res, MYSQLI_NUM)); + + print "[007]\n"; + var_dump(mysqli_fetch_array($res, MYSQLI_BOTH)); + + print "[008]\n"; + var_dump(mysqli_fetch_array($res, MYSQLI_ASSOC)); + + print "[009]\n"; + var_dump(mysqli_fetch_array($res)); + + mysqli_free_result($res); + + if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { + printf("[010] Cannot run query, [%d] %s\n", mysqli_errno($link), $mysqli_error($link)); + } + print "[011]\n"; + var_dump(mysqli_fetch_array($res, MYSQLI_BOTH)); + + mysqli_free_result($res); + if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) { + printf("[012] Cannot run query, [%d] %s\n", + mysqli_errno($link), $mysqli_error($link)); + exit(1); + } + + do { + $illegal_mode = mt_rand(-10000, 10000); + } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); + // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. + $tmp = mysqli_fetch_array($res, $illegal_mode); + if (false !== $tmp) + printf("[013] Expecting boolean/false although, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + + $tmp = mysqli_fetch_array($res, $illegal_mode); + if (false !== $tmp) + printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + + mysqli_free_result($res); + + function func_mysqli_fetch_array($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL, $binary_type = false) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail, engine might not support the datatype + return false; + } + + if (is_null($php_value)) { + if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + } else { + if (is_string($sql_value)) { + if (!mysqli_query($link, $sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) { + printf("[%04ds] [%d] %s - %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link), $sql); + return false; + } + } else { + if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { + printf("[%04di] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + } + } + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$row = mysqli_fetch_array($res, MYSQLI_BOTH)) { + printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($regexp_comparison) { + if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { + printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, $regexp_comparison, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + } else if ((gettype($php_value) == 'unicode') && $binary_type) { + // Unicode is on and we are told that the MySQL column type is a binary type. + // Don't expect a unicode value from the database, you'll get binary string + if (($row['label'] != $php_value) || ($row[1] != $php_value)) { + printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 5, + gettype($php_value), $php_value, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + if (gettype($row['label']) == 'unicode') { + var_dump(mysqli_fetch_field_direct($res, 1), $row['label']); + printf("[%04d] SQL Type: '%s', binary columns are supposed to return binary string and not unicode\n", + $offset + 6, $sql_type); + return false; + } + } else { + if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { + printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 7, + gettype($php_value), $php_value, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + } + return true; + } + + function func_mysqli_fetch_array_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_fetch_array($link, $engine, "TINYINT", -11, "-11", 20); + func_mysqli_fetch_array($link, $engine, "TINYINT", NULL, NULL, 30); + func_mysqli_fetch_array($link, $engine, "TINYINT UNSIGNED", 1, "1", 40); + func_mysqli_fetch_array($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); + + func_mysqli_fetch_array($link, $engine, "BOOL", 1, "1", 60); + func_mysqli_fetch_array($link, $engine, "BOOL", NULL, NULL, 70); + func_mysqli_fetch_array($link, $engine, "BOOLEAN", 0, "0", 80); + func_mysqli_fetch_array($link, $engine, "BOOLEAN", NULL, NULL, 90); + + func_mysqli_fetch_array($link, $engine, "SMALLINT", -32768, "-32768", 100); + func_mysqli_fetch_array($link, $engine, "SMALLINT", 32767, "32767", 110); + func_mysqli_fetch_array($link, $engine, "SMALLINT", NULL, NULL, 120); + func_mysqli_fetch_array($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130); + func_mysqli_fetch_array($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); + + func_mysqli_fetch_array($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150); + func_mysqli_fetch_array($link, $engine, "MEDIUMINT", 8388607, "8388607", 160); + func_mysqli_fetch_array($link, $engine, "MEDIUMINT", NULL, NULL, 170); + func_mysqli_fetch_array($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); + func_mysqli_fetch_array($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); + + func_mysqli_fetch_array($link, $engine, "INTEGER", -2147483648, "-2147483648", 200); + func_mysqli_fetch_array($link, $engine, "INTEGER", 2147483647, "2147483647", 210); + func_mysqli_fetch_array($link, $engine, "INTEGER", NULL, NULL, 220); + func_mysqli_fetch_array($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); + func_mysqli_fetch_array($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); + + if ($IS_MYSQLND || + ((mysqli_get_server_version($link) >= 51000) && + (mysqli_get_client_version($link) >= 51000))) { + func_mysqli_fetch_array($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); + func_mysqli_fetch_array($link, $engine, "BIGINT", NULL, NULL, 260); + func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 260); + func_mysqli_fetch_array($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); + } + + func_mysqli_fetch_array($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); + func_mysqli_fetch_array($link, $engine, "FLOAT", NULL, NULL, 300); + func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu"); + func_mysqli_fetch_array($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); + + func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); + func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340); + func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); + func_mysqli_fetch_array($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); + + func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); + func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380); + func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); + func_mysqli_fetch_array($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); + + // don't care about date() strict TZ warnings... + $date = @date('Y-m-d'); + func_mysqli_fetch_array($link, $engine, "DATE",$date, $date, 410); + func_mysqli_fetch_array($link, $engine, "DATE NOT NULL",$date, $date, 420); + func_mysqli_fetch_array($link, $engine, "DATE", NULL, NULL, 430); + + $date = @date('Y-m-d H:i:s'); + func_mysqli_fetch_array($link, $engine, "DATETIME", $date, $date, 440); + func_mysqli_fetch_array($link, $engine, "DATETIME NOT NULL", $date, $date, 450); + func_mysqli_fetch_array($link, $engine, "DATETIME", NULL, NULL, 460); + func_mysqli_fetch_array($link, $engine, "TIMESTAMP", $date, $date, 470); + + $date = @date('H:i:s'); + func_mysqli_fetch_array($link, $engine, "TIME", $date, $date, 480); + func_mysqli_fetch_array($link, $engine, "TIME NOT NULL", $date, $date, 490); + func_mysqli_fetch_array($link, $engine, "TIME", NULL, NULL, 500); + + func_mysqli_fetch_array($link, $engine, "YEAR", @date('Y'), @date('Y'), 510); + func_mysqli_fetch_array($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); + func_mysqli_fetch_array($link, $engine, "YEAR", NULL, NULL, 530); + + $string255 = func_mysqli_fetch_array_make_string(255); + func_mysqli_fetch_array($link, $engine, "CHAR(1)", "a", "a", 540); + func_mysqli_fetch_array($link, $engine, "CHAR(255)", $string255, $string255, 550); + func_mysqli_fetch_array($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560); + func_mysqli_fetch_array($link, $engine, "CHAR(1)", NULL, NULL, 570); + + $string65k = func_mysqli_fetch_array_make_string(65400); + func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", "a", "a", 580); + func_mysqli_fetch_array($link, $engine, "VARCHAR(255)", $string255, $string255, 590); + func_mysqli_fetch_array($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); + func_mysqli_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); + func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620); + + func_mysqli_fetch_array($link, $engine, "BINARY(1)", "a", "a", 630, null, true); + func_mysqli_fetch_array($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640, null, true); + func_mysqli_fetch_array($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650, null, true); + func_mysqli_fetch_array($link, $engine, "BINARY(1)", NULL, NULL, 660, null, true); + + func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", "a", "a", 670, null, true); + func_mysqli_fetch_array($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680, null, true); + func_mysqli_fetch_array($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690, null, true); + func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", NULL, NULL, 700, null, true); + + func_mysqli_fetch_array($link, $engine, "TINYBLOB", "a", "a", 710, null, true); + func_mysqli_fetch_array($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720, null, true); + func_mysqli_fetch_array($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730, null, true); + func_mysqli_fetch_array($link, $engine, "TINYBLOB", NULL, NULL, 740, null, true); + + func_mysqli_fetch_array($link, $engine, "TINYTEXT", "a", "a", 750); + func_mysqli_fetch_array($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760); + func_mysqli_fetch_array($link, $engine, "TINYTEXT", NULL, NULL, 770); + + func_mysqli_fetch_array($link, $engine, "BLOB", "a", "a", 780, null, true); + func_mysqli_fetch_array($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780, null, true); + func_mysqli_fetch_array($link, $engine, "BLOB", NULL, NULL, 790, null, true); + + func_mysqli_fetch_array($link, $engine, "TEXT", "a", "a", 800); + func_mysqli_fetch_array($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); + func_mysqli_fetch_array($link, $engine, "TEXT", NULL, NULL, 820); + + func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", "a", "a", 830, null, true); + func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840, null, true); + func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", NULL, NULL, 850, null, true); + + func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", "a", "a", 860); + func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); + func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", NULL, NULL, 880); + + func_mysqli_fetch_array($link, $engine, "LONGBLOB", "a", "a", 890, null, true); + func_mysqli_fetch_array($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); + func_mysqli_fetch_array($link, $engine, "LONGBLOB", NULL, NULL, 910, null, true); + + func_mysqli_fetch_array($link, $engine, "ENUM('a', 'b')", "a", "a", 920); + func_mysqli_fetch_array($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930); + + func_mysqli_fetch_array($link, $engine, "SET('a', 'b')", "a", "a", 940); + func_mysqli_fetch_array($link, $engine, "SET('a', 'b')", NULL, NULL, 950); + + mysqli_close($link); try { mysqli_fetch_array($res, MYSQLI_ASSOC); @@ -285,7 +285,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECTF-- [005] diff --git a/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt b/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt index 4701926d6c92..6899c0bfba6a 100644 --- a/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt +++ b/ext/mysqli/tests/mysqli_fetch_array_assoc.phpt @@ -8,24 +8,24 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32); - - /* try to respect php.ini but make run time a soft limit */ - $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30; - set_time_limit(0); - - do { - if ($package_size > $limit) { - printf("stop: memory limit - %s vs. %s\n", $package_size, $limit); - break; - } - - $start = microtime(true); - if (!mysqli_fetch_array_large($offset++, $link, $package_size)) { - printf("stop: packet size - %d\n", $package_size); - break; - } - - $duration = microtime(true) - $start; - $max_runtime -= $duration; - if ($max_runtime < ($duration * 3)) { - /* likely the next iteration will not be within max_execution_time */ - printf("stop: time limit - %2.2fs\n", $max_runtime); - break; - } - - $package_size += $package_size; - - } while (true); - - - mysqli_close($link); - return true; - } - - - test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null); - test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS); - print "done!"; + require_once("connect.inc"); + + function mysqli_fetch_array_large($offset, $link, $package_size) { + + /* we are aiming for maximum compression to test MYSQLI_CLIENT_COMPRESS */ + $random_char = str_repeat('a', 255); + $sql = "INSERT INTO test(label) VALUES "; + + while (strlen($sql) < ($package_size - 259)) + $sql .= sprintf("('%s'), ", $random_char); + + $sql = substr($sql, 0, -2); + $len = strlen($sql); + assert($len < $package_size); + + if (!@mysqli_query($link, $sql)) { + if (1153 == mysqli_errno($link) || 2006 == mysqli_errno($link) || stristr(mysqli_error($link), 'max_allowed_packet')) + /* + myslqnd - [1153] Got a packet bigger than 'max_allowed_packet' bytes + libmysql -[2006] MySQL server has gone away + */ + return false; + + printf("[%03d + 1] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link)); + return false; + } + + /* buffered result set - let's hope we do not run into PHP memory limit... */ + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { + printf("[%03d + 2] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link)); + return false; + } + + while ($row = mysqli_fetch_assoc($res)) { + if ($row['label'] != $random_char) { + printf("[%03d + 3] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", + $offset, $random_char, $row['label'], $len, mysqli_errno($link), mysqli_error($link)); + return false; + } + } + mysqli_free_result($res); + + if (!$stmt = mysqli_prepare($link, "SELECT id, label FROM test")) { + printf("[%03d + 4] len = %d, [%d] %s\n", $offset, $len, mysqli_errno($link), mysqli_error($link)); + return false; + } + + /* unbuffered result set */ + if (!mysqli_stmt_execute($stmt)) { + printf("[%03d + 5] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link)); + return false; + } + + $id = $label = NULL; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) { + printf("[%03d + 6] len = %d, [%d] %s, [%d] %s\n", $offset, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), mysqli_errno($link), mysqli_error($link)); + return false; + } + + while (mysqli_stmt_fetch($stmt)) { + if ($label != $random_char) { + printf("[%03d + 7] Wrong results - expecting '%s' got '%s', len = %d, [%d] %s\n", + $offset, $random_char, $label, $len, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + } + + mysqli_stmt_free_result($stmt); + mysqli_stmt_close($stmt); + + return true; + } + + function parse_memory_limit($limit) { + + $val = trim($limit); + $last = strtolower($val[strlen($val)-1]); + + switch($last) { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + default: + break; + } + return $val; + } + + + function test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, $flags = null) { + + $link = mysqli_init(); + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + return false; + } + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) { + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + return false; + } + + $package_size = 524288; + $offset = 3; + $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32); + + /* try to respect php.ini but make run time a soft limit */ + $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30; + set_time_limit(0); + + do { + if ($package_size > $limit) { + printf("stop: memory limit - %s vs. %s\n", $package_size, $limit); + break; + } + + $start = microtime(true); + if (!mysqli_fetch_array_large($offset++, $link, $package_size)) { + printf("stop: packet size - %d\n", $package_size); + break; + } + + $duration = microtime(true) - $start; + $max_runtime -= $duration; + if ($max_runtime < ($duration * 3)) { + /* likely the next iteration will not be within max_execution_time */ + printf("stop: time limit - %2.2fs\n", $max_runtime); + break; + } + + $package_size += $package_size; + + } while (true); + + + mysqli_close($link); + return true; + } + + + test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null); + test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS); + print "done!"; ?> --CLEAN-- --FILE-- $id) { - printf("[004] Unexpected result row[0] = '%s' (range 0...%d), [%d] %s\n", - $row[0], $id, mysqli_errno($link), mysqli_error($link)); - break; - } - if ($row[0] !== $row['id']) { - printf("[005] Unexpected result row[0] = '%s', row[id] = '%s', [%d] %s\n", - $row[0], $row[id], mysqli_errno($link), mysqli_error($link)); - break; - } - - $len = strlen($row[1]); - if (!is_string($row[1]) || $len == 0 || $len > 1) { - printf("[006] Unexpected result row[1] = '%s', [%d] %s\n", - $row[1], mysqli_errno($link), mysqli_error($link)); - break; - } - if ($row[1] !== $row['label']) { - printf("[007] Unexpected result row[1] = '%s', row[label] = '%s', [%d] %s\n", - $row[1], $row['label'], mysqli_errno($link), mysqli_error($link)); - break; - } - - } - mysqli_free_result($res); - - if (!$res = mysqli_query($link, 'SELECT id, label FROM test')) { - printf("[008] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - } - - while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) { - // overwrite results and check if the cache magic works - $row['label'] = NULL; - } - mysqli_free_result($res); - - if (!$res = mysqli_query($link, 'SELECT count(*) AS num FROM test')) { - printf("[009] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - } - $row = mysqli_fetch_assoc($res); - $num = $row['num']; - mysqli_free_result($res); - - if (!$res = mysqli_query($link, 'SELECT id, label FROM test')) { - printf("[010] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); - } - - $i = 0; - while ($row = mysqli_fetch_array($res, MYSQLI_NUM)) { - // overwrite results and check if the cache magic works - $row[0] = NULL; - $i++; - } - mysqli_free_result($res); - - if ($i != $num) - printf("[011] Expecting %d results, got %d results, [%d] %s\n", - $num, $i, mysqli_errno($link), mysqli_error($link)); - - mysqli_close($link); - - print "done!"; + require("table.inc"); + + // do as much as we can do in 5 seconds + $start = microtime(true); + for ($id = 100, $start = microtime(true); (microtime(true) - $start) < 5; $id++) { + if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, '%s')", + $id, mysqli_real_escape_string($link, chr(65 + ($id % 26)))))) { + printf("[001] %s failed: [%d] %s\n", $sql, mysqli_errno($link), mysqli_error($link)); + break; + } + } + + if (!$res = mysqli_query($link, 'SELECT id, label FROM test')) { + printf("[002] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + } + + while ($row = mysqli_fetch_array($res)) { + // overwrite results and check if the cache magic works + $row['label'] = NULL; + } + mysqli_free_result($res); + + if (!$res = mysqli_query($link, 'SELECT id, label FROM test')) { + printf("[003] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + } + + $i = 0; + $results = array(); + while ($row = mysqli_fetch_array($res, MYSQLI_BOTH)) { + + // create copies and destroy later + $results[$i++] = &$row; + if ($i % 999) { + $results = array(); + } + + if ($row[0] < 0 || $row[0] > $id) { + printf("[004] Unexpected result row[0] = '%s' (range 0...%d), [%d] %s\n", + $row[0], $id, mysqli_errno($link), mysqli_error($link)); + break; + } + if ($row[0] !== $row['id']) { + printf("[005] Unexpected result row[0] = '%s', row[id] = '%s', [%d] %s\n", + $row[0], $row[id], mysqli_errno($link), mysqli_error($link)); + break; + } + + $len = strlen($row[1]); + if (!is_string($row[1]) || $len == 0 || $len > 1) { + printf("[006] Unexpected result row[1] = '%s', [%d] %s\n", + $row[1], mysqli_errno($link), mysqli_error($link)); + break; + } + if ($row[1] !== $row['label']) { + printf("[007] Unexpected result row[1] = '%s', row[label] = '%s', [%d] %s\n", + $row[1], $row['label'], mysqli_errno($link), mysqli_error($link)); + break; + } + + } + mysqli_free_result($res); + + if (!$res = mysqli_query($link, 'SELECT id, label FROM test')) { + printf("[008] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + } + + while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) { + // overwrite results and check if the cache magic works + $row['label'] = NULL; + } + mysqli_free_result($res); + + if (!$res = mysqli_query($link, 'SELECT count(*) AS num FROM test')) { + printf("[009] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + } + $row = mysqli_fetch_assoc($res); + $num = $row['num']; + mysqli_free_result($res); + + if (!$res = mysqli_query($link, 'SELECT id, label FROM test')) { + printf("[010] SELECT failed: [%d] %s\n", mysqli_errno($link), mysqli_errno($link)); + } + + $i = 0; + while ($row = mysqli_fetch_array($res, MYSQLI_NUM)) { + // overwrite results and check if the cache magic works + $row[0] = NULL; + $i++; + } + mysqli_free_result($res); + + if ($i != $num) + printf("[011] Expecting %d results, got %d results, [%d] %s\n", + $num, $i, mysqli_errno($link), mysqli_error($link)); + + mysqli_close($link); + + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT * FROM test ORDER BY id LIMIT 5")) { - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - print "[005]\n"; - var_dump($res->fetch_array()); - - print "[006]\n"; - var_dump($res->fetch_array(MYSQLI_NUM)); - - print "[007]\n"; - var_dump($res->fetch_array(MYSQLI_BOTH)); - - print "[008]\n"; - var_dump($res->fetch_array(MYSQLI_ASSOC)); - - print "[009]\n"; - var_dump($res->fetch_array()); - - $res->free_result(); - - if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { - printf("[010] Cannot run query, [%d] %s\n", $mysqli->errno, $$mysqli->error); - } - print "[011]\n"; - var_dump($res->fetch_array(MYSQLI_BOTH)); - - $res->free_result(); - if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) { - printf("[012] Cannot run query, [%d] %s\n", - $mysqli->errno, $$mysqli->error); - exit(1); - } - - do { - $illegal_mode = mt_rand(-10000, 10000); - } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); - // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. - $tmp = $res->fetch_array($illegal_mode); - if (false !== $tmp) - printf("[013] Expecting boolean/false although, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); - - $tmp = $res->fetch_array($illegal_mode); - if (false !== $tmp) - printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); - - $res->free_result(); - - function func_mysqli_fetch_array($mysqli, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { - - if (!$mysqli->query("DROP TABLE IF EXISTS test")) { - printf("[%04d] [%d] %s\n", $offset, $mysqli->errno, $mysqli->error); - return false; - } - - if (!$mysqli->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { - // don't bail, engine might not support the datatype - return false; - } - - if (is_null($php_value)) { - if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { - printf("[%04d] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error); - return false; - } - } else { - if (is_string($sql_value)) { - if (!$mysqli->query($sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) { - printf("[%04ds] [%d] %s - %s\n", $offset + 1, $mysqli->errno, $mysqli->error, $sql); - return false; - } - } else { - if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { - printf("[%04di] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error); - return false; - } - } - } - - if (!$res = $mysqli->query("SELECT id, label FROM test")) { - printf("[%04d] [%d] %s\n", $offset + 2, $mysqli->errno, $mysqli->error); - return false; - } - - if (!$row = $res->fetch_array(MYSQLI_BOTH)) { - printf("[%04d] [%d] %s\n", $offset + 3, $mysqli->errno, $mysqli->error); - return false; - } - $fields = mysqli_fetch_fields($res); - - if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { - if ($regexp_comparison) { - if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { - printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, $regexp_comparison, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], $mysqli->errno, $mysqli->error); - return false; - } - } else { - if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { - printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], $mysqli->errno, $mysqli->error); - return false; - } - } - } - return true; - } - - function func_mysqli_fetch_array_make_string($len) { - - $ret = ''; - for ($i = 0; $i < $len; $i++) - $ret .= chr(mt_rand(65, 90)); - - return $ret; - } - - func_mysqli_fetch_array($mysqli, $engine, "TINYINT", -11, "-11", 20); - func_mysqli_fetch_array($mysqli, $engine, "TINYINT", NULL, NULL, 30); - func_mysqli_fetch_array($mysqli, $engine, "TINYINT UNSIGNED", 1, "1", 40); - func_mysqli_fetch_array($mysqli, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); - - func_mysqli_fetch_array($mysqli, $engine, "BOOL", 1, "1", 60); - func_mysqli_fetch_array($mysqli, $engine, "BOOL", NULL, NULL, 70); - func_mysqli_fetch_array($mysqli, $engine, "BOOLEAN", 0, "0", 80); - func_mysqli_fetch_array($mysqli, $engine, "BOOLEAN", NULL, NULL, 90); - - func_mysqli_fetch_array($mysqli, $engine, "SMALLINT", -32768, "-32768", 100); - func_mysqli_fetch_array($mysqli, $engine, "SMALLINT", 32767, "32767", 110); - func_mysqli_fetch_array($mysqli, $engine, "SMALLINT", NULL, NULL, 120); - func_mysqli_fetch_array($mysqli, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130); - func_mysqli_fetch_array($mysqli, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); - - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT", -8388608, "-8388608", 150); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT", 8388607, "8388607", 160); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT", NULL, NULL, 170); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); - - func_mysqli_fetch_array($mysqli, $engine, "INTEGER", -2147483648, "-2147483648", 200); - func_mysqli_fetch_array($mysqli, $engine, "INTEGER", 2147483647, "2147483647", 210); - func_mysqli_fetch_array($mysqli, $engine, "INTEGER", NULL, NULL, 220); - func_mysqli_fetch_array($mysqli, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); - func_mysqli_fetch_array($mysqli, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); - - if ($IS_MYSQLND || - ((mysqli_get_server_version($link) >= 51000) && - (mysqli_get_client_version($link) >= 51000))) { - func_mysqli_fetch_array($mysqli, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); - func_mysqli_fetch_array($mysqli, $engine, "BIGINT", NULL, NULL, 260); - func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); - func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); - } - - func_mysqli_fetch_array($mysqli, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); - func_mysqli_fetch_array($mysqli, $engine, "FLOAT", NULL, NULL, 300); - func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu"); - func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); - - func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); - func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", NULL, NULL, 340); - func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); - func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); - func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); - func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", NULL, NULL, 380); - func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); - func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", NULL, NULL, 400); - - // don't care about date() strict TZ warnings... - $date = @date('Y-m-d'); - func_mysqli_fetch_array($mysqli, $engine, "DATE",$date, $date, 410); - func_mysqli_fetch_array($mysqli, $engine, "DATE NOT NULL",$date, $date, 420); - func_mysqli_fetch_array($mysqli, $engine, "DATE", NULL, NULL, 430); - - $date = @date('Y-m-d H:i:s'); - func_mysqli_fetch_array($mysqli, $engine, "DATETIME", $date, $date, 440); - func_mysqli_fetch_array($mysqli, $engine, "DATETIME NOT NULL", $date, $date, 450); - func_mysqli_fetch_array($mysqli, $engine, "DATETIME", NULL, NULL, 460); - func_mysqli_fetch_array($mysqli, $engine, "TIMESTAMP", $date, $date, 470); - $date = @date('H:i:s'); - func_mysqli_fetch_array($mysqli, $engine, "TIME", $date, $date, 480); - func_mysqli_fetch_array($mysqli, $engine, "TIME NOT NULL", $date, $date, 490); - func_mysqli_fetch_array($mysqli, $engine, "TIME", NULL, NULL, 500); - func_mysqli_fetch_array($mysqli, $engine, "YEAR", @date('Y'), @date('Y'), 510); - func_mysqli_fetch_array($mysqli, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); - func_mysqli_fetch_array($mysqli, $engine, "YEAR", NULL, NULL, 530); - - $string255 = func_mysqli_fetch_array_make_string(255); - func_mysqli_fetch_array($mysqli, $engine, "CHAR(1)", "a", "a", 540); - func_mysqli_fetch_array($mysqli, $engine, "CHAR(255)", $string255, $string255, 550); - func_mysqli_fetch_array($mysqli, $engine, "CHAR(1) NOT NULL", "a", "a", 560); - func_mysqli_fetch_array($mysqli, $engine, "CHAR(1)", NULL, NULL, 570); - - $string65k = func_mysqli_fetch_array_make_string(65400); - func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1)", "a", "a", 580); - func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(255)", $string255, $string255, 590); - func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); - func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); - func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1)", NULL, NULL, 620); - - func_mysqli_fetch_array($mysqli, $engine, "BINARY(1)", "a", "a", 630); - func_mysqli_fetch_array($mysqli, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640); - func_mysqli_fetch_array($mysqli, $engine, "BINARY(1) NOT NULL", "b", "b", 650); - func_mysqli_fetch_array($mysqli, $engine, "BINARY(1)", NULL, NULL, 660); - - func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(1)", "a", "a", 670); - func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680); - func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); - func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(1)", NULL, NULL, 700); - - func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB", "a", "a", 710); - func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720); - func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB NOT NULL", "b", "b", 730); - func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB", NULL, NULL, 740); - - func_mysqli_fetch_array($mysqli, $engine, "TINYTEXT", "a", "a", 750); - func_mysqli_fetch_array($mysqli, $engine, "TINYTEXT NOT NULL", "a", "a", 760); - func_mysqli_fetch_array($mysqli, $engine, "TINYTEXT", NULL, NULL, 770); - - func_mysqli_fetch_array($mysqli, $engine, "BLOB", "a", "a", 780); - func_mysqli_fetch_array($mysqli, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780); - func_mysqli_fetch_array($mysqli, $engine, "BLOB", NULL, NULL, 790); - - func_mysqli_fetch_array($mysqli, $engine, "TEXT", "a", "a", 800); - func_mysqli_fetch_array($mysqli, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); - func_mysqli_fetch_array($mysqli, $engine, "TEXT", NULL, NULL, 820); - - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMBLOB", "a", "a", 830); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMBLOB", NULL, NULL, 850); - - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMTEXT", "a", "a", 860); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); - func_mysqli_fetch_array($mysqli, $engine, "MEDIUMTEXT", NULL, NULL, 880); - - func_mysqli_fetch_array($mysqli, $engine, "LONGBLOB", "a", "a", 890); - func_mysqli_fetch_array($mysqli, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); - func_mysqli_fetch_array($mysqli, $engine, "LONGBLOB", NULL, NULL, 910); - - func_mysqli_fetch_array($mysqli, $engine, "ENUM('a', 'b')", "a", "a", 920); - func_mysqli_fetch_array($mysqli, $engine, "ENUM('a', 'b')", NULL, NULL, 930); - - func_mysqli_fetch_array($mysqli, $engine, "SET('a', 'b')", "a", "a", 940); - func_mysqli_fetch_array($mysqli, $engine, "SET('a', 'b')", NULL, NULL, 950); - - $mysqli->close(); + require_once("connect.inc"); + + $tmp = NULL; + $link = NULL; + + require('table.inc'); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!$res = $mysqli->query("SELECT * FROM test ORDER BY id LIMIT 5")) { + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + print "[005]\n"; + var_dump($res->fetch_array()); + + print "[006]\n"; + var_dump($res->fetch_array(MYSQLI_NUM)); + + print "[007]\n"; + var_dump($res->fetch_array(MYSQLI_BOTH)); + + print "[008]\n"; + var_dump($res->fetch_array(MYSQLI_ASSOC)); + + print "[009]\n"; + var_dump($res->fetch_array()); + + $res->free_result(); + + if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { + printf("[010] Cannot run query, [%d] %s\n", $mysqli->errno, $$mysqli->error); + } + print "[011]\n"; + var_dump($res->fetch_array(MYSQLI_BOTH)); + + $res->free_result(); + if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) { + printf("[012] Cannot run query, [%d] %s\n", + $mysqli->errno, $$mysqli->error); + exit(1); + } + + do { + $illegal_mode = mt_rand(-10000, 10000); + } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); + // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. + $tmp = $res->fetch_array($illegal_mode); + if (false !== $tmp) + printf("[013] Expecting boolean/false although, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + + $tmp = $res->fetch_array($illegal_mode); + if (false !== $tmp) + printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + + $res->free_result(); + + function func_mysqli_fetch_array($mysqli, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { + + if (!$mysqli->query("DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, $mysqli->errno, $mysqli->error); + return false; + } + + if (!$mysqli->query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail, engine might not support the datatype + return false; + } + + if (is_null($php_value)) { + if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { + printf("[%04d] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error); + return false; + } + } else { + if (is_string($sql_value)) { + if (!$mysqli->query($sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) { + printf("[%04ds] [%d] %s - %s\n", $offset + 1, $mysqli->errno, $mysqli->error, $sql); + return false; + } + } else { + if (!$mysqli->query($sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { + printf("[%04di] [%d] %s\n", $offset + 1, $mysqli->errno, $mysqli->error); + return false; + } + } + } + + if (!$res = $mysqli->query("SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 2, $mysqli->errno, $mysqli->error); + return false; + } + + if (!$row = $res->fetch_array(MYSQLI_BOTH)) { + printf("[%04d] [%d] %s\n", $offset + 3, $mysqli->errno, $mysqli->error); + return false; + } + $fields = mysqli_fetch_fields($res); + + if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { + if ($regexp_comparison) { + if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { + printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, $regexp_comparison, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], $mysqli->errno, $mysqli->error); + return false; + } + } else { + if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { + printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], $mysqli->errno, $mysqli->error); + return false; + } + } + } + return true; + } + + function func_mysqli_fetch_array_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_fetch_array($mysqli, $engine, "TINYINT", -11, "-11", 20); + func_mysqli_fetch_array($mysqli, $engine, "TINYINT", NULL, NULL, 30); + func_mysqli_fetch_array($mysqli, $engine, "TINYINT UNSIGNED", 1, "1", 40); + func_mysqli_fetch_array($mysqli, $engine, "TINYINT UNSIGNED", NULL, NULL, 50); + + func_mysqli_fetch_array($mysqli, $engine, "BOOL", 1, "1", 60); + func_mysqli_fetch_array($mysqli, $engine, "BOOL", NULL, NULL, 70); + func_mysqli_fetch_array($mysqli, $engine, "BOOLEAN", 0, "0", 80); + func_mysqli_fetch_array($mysqli, $engine, "BOOLEAN", NULL, NULL, 90); + + func_mysqli_fetch_array($mysqli, $engine, "SMALLINT", -32768, "-32768", 100); + func_mysqli_fetch_array($mysqli, $engine, "SMALLINT", 32767, "32767", 110); + func_mysqli_fetch_array($mysqli, $engine, "SMALLINT", NULL, NULL, 120); + func_mysqli_fetch_array($mysqli, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130); + func_mysqli_fetch_array($mysqli, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140); + + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT", -8388608, "-8388608", 150); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT", 8388607, "8388607", 160); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT", NULL, NULL, 170); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190); + + func_mysqli_fetch_array($mysqli, $engine, "INTEGER", -2147483648, "-2147483648", 200); + func_mysqli_fetch_array($mysqli, $engine, "INTEGER", 2147483647, "2147483647", 210); + func_mysqli_fetch_array($mysqli, $engine, "INTEGER", NULL, NULL, 220); + func_mysqli_fetch_array($mysqli, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230); + func_mysqli_fetch_array($mysqli, $engine, "INTEGER UNSIGNED", NULL, NULL, 240); + + if ($IS_MYSQLND || + ((mysqli_get_server_version($link) >= 51000) && + (mysqli_get_client_version($link) >= 51000))) { + func_mysqli_fetch_array($mysqli, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250); + func_mysqli_fetch_array($mysqli, $engine, "BIGINT", NULL, NULL, 260); + func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270); + func_mysqli_fetch_array($mysqli, $engine, "BIGINT UNSIGNED", NULL, NULL, 280); + } + + func_mysqli_fetch_array($mysqli, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu"); + func_mysqli_fetch_array($mysqli, $engine, "FLOAT", NULL, NULL, 300); + func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+?19", 310, "/1\.84467e\+?[0]?19/iu"); + func_mysqli_fetch_array($mysqli, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320); + + func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330); + func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2)", NULL, NULL, 340); + func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350); + func_mysqli_fetch_array($mysqli, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360); + func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370); + func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", NULL, NULL, 380); + func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390); + func_mysqli_fetch_array($mysqli, $engine, "DECIMAL(10,2)", NULL, NULL, 400); + + // don't care about date() strict TZ warnings... + $date = @date('Y-m-d'); + func_mysqli_fetch_array($mysqli, $engine, "DATE",$date, $date, 410); + func_mysqli_fetch_array($mysqli, $engine, "DATE NOT NULL",$date, $date, 420); + func_mysqli_fetch_array($mysqli, $engine, "DATE", NULL, NULL, 430); + + $date = @date('Y-m-d H:i:s'); + func_mysqli_fetch_array($mysqli, $engine, "DATETIME", $date, $date, 440); + func_mysqli_fetch_array($mysqli, $engine, "DATETIME NOT NULL", $date, $date, 450); + func_mysqli_fetch_array($mysqli, $engine, "DATETIME", NULL, NULL, 460); + func_mysqli_fetch_array($mysqli, $engine, "TIMESTAMP", $date, $date, 470); + $date = @date('H:i:s'); + func_mysqli_fetch_array($mysqli, $engine, "TIME", $date, $date, 480); + func_mysqli_fetch_array($mysqli, $engine, "TIME NOT NULL", $date, $date, 490); + func_mysqli_fetch_array($mysqli, $engine, "TIME", NULL, NULL, 500); + func_mysqli_fetch_array($mysqli, $engine, "YEAR", @date('Y'), @date('Y'), 510); + func_mysqli_fetch_array($mysqli, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520); + func_mysqli_fetch_array($mysqli, $engine, "YEAR", NULL, NULL, 530); + + $string255 = func_mysqli_fetch_array_make_string(255); + func_mysqli_fetch_array($mysqli, $engine, "CHAR(1)", "a", "a", 540); + func_mysqli_fetch_array($mysqli, $engine, "CHAR(255)", $string255, $string255, 550); + func_mysqli_fetch_array($mysqli, $engine, "CHAR(1) NOT NULL", "a", "a", 560); + func_mysqli_fetch_array($mysqli, $engine, "CHAR(1)", NULL, NULL, 570); + + $string65k = func_mysqli_fetch_array_make_string(65400); + func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1)", "a", "a", 580); + func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(255)", $string255, $string255, 590); + func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(65400)", $string65k, $string65k, 600); + func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610); + func_mysqli_fetch_array($mysqli, $engine, "VARCHAR(1)", NULL, NULL, 620); + + func_mysqli_fetch_array($mysqli, $engine, "BINARY(1)", "a", "a", 630); + func_mysqli_fetch_array($mysqli, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640); + func_mysqli_fetch_array($mysqli, $engine, "BINARY(1) NOT NULL", "b", "b", 650); + func_mysqli_fetch_array($mysqli, $engine, "BINARY(1)", NULL, NULL, 660); + + func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(1)", "a", "a", 670); + func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680); + func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690); + func_mysqli_fetch_array($mysqli, $engine, "VARBINARY(1)", NULL, NULL, 700); + + func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB", "a", "a", 710); + func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720); + func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB NOT NULL", "b", "b", 730); + func_mysqli_fetch_array($mysqli, $engine, "TINYBLOB", NULL, NULL, 740); + + func_mysqli_fetch_array($mysqli, $engine, "TINYTEXT", "a", "a", 750); + func_mysqli_fetch_array($mysqli, $engine, "TINYTEXT NOT NULL", "a", "a", 760); + func_mysqli_fetch_array($mysqli, $engine, "TINYTEXT", NULL, NULL, 770); + + func_mysqli_fetch_array($mysqli, $engine, "BLOB", "a", "a", 780); + func_mysqli_fetch_array($mysqli, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780); + func_mysqli_fetch_array($mysqli, $engine, "BLOB", NULL, NULL, 790); + + func_mysqli_fetch_array($mysqli, $engine, "TEXT", "a", "a", 800); + func_mysqli_fetch_array($mysqli, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810); + func_mysqli_fetch_array($mysqli, $engine, "TEXT", NULL, NULL, 820); + + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMBLOB", "a", "a", 830); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMBLOB", NULL, NULL, 850); + + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMTEXT", "a", "a", 860); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870); + func_mysqli_fetch_array($mysqli, $engine, "MEDIUMTEXT", NULL, NULL, 880); + + func_mysqli_fetch_array($mysqli, $engine, "LONGBLOB", "a", "a", 890); + func_mysqli_fetch_array($mysqli, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900); + func_mysqli_fetch_array($mysqli, $engine, "LONGBLOB", NULL, NULL, 910); + + func_mysqli_fetch_array($mysqli, $engine, "ENUM('a', 'b')", "a", "a", 920); + func_mysqli_fetch_array($mysqli, $engine, "ENUM('a', 'b')", NULL, NULL, 930); + + func_mysqli_fetch_array($mysqli, $engine, "SET('a', 'b')", "a", "a", 940); + func_mysqli_fetch_array($mysqli, $engine, "SET('a', 'b')", NULL, NULL, 950); + + $mysqli->close(); try { $res->fetch_array(MYSQLI_ASSOC); @@ -277,7 +277,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- = 1; $bitval = $bitval / 2) { - if (($dec / $bitval) >= 1) { - $bin .= '1'; - $dec -= $bitval; - } else { - $bin .= '0'; - } - } - return $bin; - } + $maxval = pow(2, $bits); + $bin = ''; + for ($bitval = $maxval; $bitval >= 1; $bitval = $bitval / 2) { + if (($dec / $bitval) >= 1) { + $bin .= '1'; + $dec -= $bitval; + } else { + $bin .= '0'; + } + } + return $bin; + } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - for ($bits = 1; $bits <= 46; $bits++) { - if (1 == $bits) - $max_value = 1; - else - $max_value = pow(2, $bits) - 1; - $tests = 0; - if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || - !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE="%s"', $bits, $bits, $engine))) - printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); + for ($bits = 1; $bits <= 46; $bits++) { + if (1 == $bits) + $max_value = 1; + else + $max_value = pow(2, $bits) - 1; + $tests = 0; + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE="%s"', $bits, $bits, $engine))) + printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); - $tests = 0; - $rand_max = mt_getrandmax(); - while ($tests < 10) { + $tests = 0; + $rand_max = mt_getrandmax(); + while ($tests < 10) { - $tests++; - if (1 == $tests) - $value = 0; - else if (2 == $tests) - $value = $max_value; - else { - if ($max_value > $rand_max) { - $max_loops = floor($max_value/$rand_max); - $num_loops = mt_rand(1, $max_loops); - $value = 0; - for ($i = 0; $i < $num_loops; $i++) - $value += mt_rand(0, $rand_max); - } else { - $value = mt_rand(0, $max_value); - } - } + $tests++; + if (1 == $tests) + $value = 0; + else if (2 == $tests) + $value = $max_value; + else { + if ($max_value > $rand_max) { + $max_loops = floor($max_value/$rand_max); + $num_loops = mt_rand(1, $max_loops); + $value = 0; + for ($i = 0; $i < $num_loops; $i++) + $value += mt_rand(0, $rand_max); + } else { + $value = mt_rand(0, $max_value); + } + } - $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); - $sql = sprintf("INSERT INTO test(id, bit_value) VALUES (%s, b'%s')", $value, $bin); - for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) - ; - $bin2 = substr($bin, $i, strlen($bin)); + $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); + $sql = sprintf("INSERT INTO test(id, bit_value) VALUES (%s, b'%s')", $value, $bin); + for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) + ; + $bin2 = substr($bin, $i, strlen($bin)); - if (!mysqli_query($link, $sql)) - printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, $sql)) + printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value + 0 AS _bit_value0, bit_value, bit_null FROM test WHERE id = %s", $value); - if (!$res = mysqli_query($link, $sql)) - printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value + 0 AS _bit_value0, bit_value, bit_null FROM test WHERE id = %s", $value); + if (!$res = mysqli_query($link, $sql)) + printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[005 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + if (!$row = mysqli_fetch_assoc($res)) + printf("[005 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { - debug_zval_dump($row); - printf("[006 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", - $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); - break; - } - if ($value != $row['bit_value']) { - debug_zval_dump($row); - printf("%10s %64s\n%10s %64s\n", '_bin', $row['_bin'], 'insert', $bin); - printf("[007 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); - break; - } + if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { + debug_zval_dump($row); + printf("[006 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", + $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); + break; + } + if ($value != $row['bit_value']) { + debug_zval_dump($row); + printf("%10s %64s\n%10s %64s\n", '_bin', $row['_bin'], 'insert', $bin); + printf("[007 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); + break; + } - if (null !== $row['bit_null']) { - debug_zval_dump($row); - printf("[008 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); - break; - } - } - } + if (null !== $row['bit_null']) { + debug_zval_dump($row); + printf("[008 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); + break; + } + } + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --EXPECTF-- [002] diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt index fdbf222df82f..e1ed5c5c87d7 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_no_alias_utf8.phpt @@ -35,48 +35,48 @@ mysqli_fetch_assoc() - utf8 ?> --FILE-- --EXPECTF-- [003] diff --git a/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt b/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt index c1eef6eaf533..db07a2ef4b1f 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc_oo.phpt @@ -8,43 +8,43 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - require('table.inc'); - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + require('table.inc'); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (!$res = $mysqli->query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$res = $mysqli->query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + } - print "[005]\n"; - var_dump($res->fetch_assoc()); + print "[005]\n"; + var_dump($res->fetch_assoc()); - print "[006]\n"; - var_dump($res->fetch_assoc()); + print "[006]\n"; + var_dump($res->fetch_assoc()); - $res->free_result(); + $res->free_result(); - if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { - printf("[007] Cannot run query, [%d] %s\n", $mysqli->errno, $mysqli->error); - } - print "[008]\n"; - var_dump($res->fetch_assoc()); + if (!$res = $mysqli->query("SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { + printf("[007] Cannot run query, [%d] %s\n", $mysqli->errno, $mysqli->error); + } + print "[008]\n"; + var_dump($res->fetch_assoc()); - $res->free_result(); + $res->free_result(); try { $res->fetch_assoc(); @@ -52,9 +52,9 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- length; - if ($length > strlen($insert)) { + $row = mysqli_fetch_assoc($res); + $meta = mysqli_fetch_fields($res); + mysqli_free_result($res); + $meta = $meta[0]; + $length = $meta->length; + if ($length > strlen($insert)) { - $expected = str_repeat('0', $length - strlen($insert)); - $expected .= $insert; - if ($expected !== $row['zero']) { - printf("[%03d] Expecting '%s' got '%s'\n", $offset, $expected, $row['zero']); - return false; - } + $expected = str_repeat('0', $length - strlen($insert)); + $expected .= $insert; + if ($expected !== $row['zero']) { + printf("[%03d] Expecting '%s' got '%s'\n", $offset, $expected, $row['zero']); + return false; + } - } else if ($length <= 1) { - printf("[%03d] Length reported is too small to run test\n", $offset); - return false; - } + } else if ($length <= 1) { + printf("[%03d] Length reported is too small to run test\n", $offset); + return false; + } - return true; - } + return true; + } - zerofill(2, $link, 'TINYINT'); - zerofill(3, $link, 'SMALLINT'); - zerofill(4, $link, 'MEDIUMINT'); - zerofill(5, $link, 'INT'); - zerofill(6, $link, 'INTEGER'); - zerofill(7, $link, 'BIGINT'); - zerofill(8, $link, 'FLOAT'); - zerofill(9, $link, 'DOUBLE'); - zerofill(10, $link, 'DOUBLE PRECISION'); - zerofill(11, $link, 'DECIMAL'); - zerofill(12, $link, 'DEC'); + zerofill(2, $link, 'TINYINT'); + zerofill(3, $link, 'SMALLINT'); + zerofill(4, $link, 'MEDIUMINT'); + zerofill(5, $link, 'INT'); + zerofill(6, $link, 'INTEGER'); + zerofill(7, $link, 'BIGINT'); + zerofill(8, $link, 'FLOAT'); + zerofill(9, $link, 'DOUBLE'); + zerofill(10, $link, 'DOUBLE PRECISION'); + zerofill(11, $link, 'DECIMAL'); + zerofill(12, $link, 'DEC'); - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- charsetnr != $charsetInfo->number) { - printf("[004] Expecting charset %s/%d got %d\n", - $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr); - } - if ($tmp->length != $charsetInfo->max_length) { - printf("[005] Expecting length %d got %d\n", - $charsetInfo->max_length, $tmp->max_length); - } - if ($tmp->db != $db) { - printf("011] Expecting database '%s' got '%s'\n", - $db, $tmp->db); - } + /* label column, result set charset */ + $tmp = mysqli_fetch_field($res); + var_dump($tmp); + if ($tmp->charsetnr != $charsetInfo->number) { + printf("[004] Expecting charset %s/%d got %d\n", + $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr); + } + if ($tmp->length != $charsetInfo->max_length) { + printf("[005] Expecting length %d got %d\n", + $charsetInfo->max_length, $tmp->max_length); + } + if ($tmp->db != $db) { + printf("011] Expecting database '%s' got '%s'\n", + $db, $tmp->db); + } - var_dump(mysqli_fetch_field($res)); + var_dump(mysqli_fetch_field($res)); - mysqli_free_result($res); + mysqli_free_result($res); - // Read http://bugs.php.net/bug.php?id=42344 on defaults! + // Read http://bugs.php.net/bug.php?id=42344 on defaults! try { mysqli_fetch_field($res); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) - printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) + printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL DEFAULT 1)")) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL DEFAULT 1)")) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_query($link, "INSERT INTO test(id) VALUES (2)")) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "INSERT INTO test(id) VALUES (2)")) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$res = mysqli_query($link, "SELECT id as _default_test FROM test")) { - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - var_dump(mysqli_fetch_assoc($res)); - /* binary */ - var_dump(mysqli_fetch_field($res)); - mysqli_free_result($res); + if (!$res = mysqli_query($link, "SELECT id as _default_test FROM test")) { + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + var_dump(mysqli_fetch_assoc($res)); + /* binary */ + var_dump(mysqli_fetch_field($res)); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - require('table.inc'); + require('table.inc'); - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - var_dump($res->fetch_field_direct(-1)); - var_dump($res->fetch_field_direct(0)); - var_dump($res->fetch_field_direct(2)); + var_dump($res->fetch_field_direct(-1)); + var_dump($res->fetch_field_direct(0)); + var_dump($res->fetch_field_direct(2)); - $res->free_result(); + $res->free_result(); try { $res->fetch_field_direct(0); @@ -39,8 +39,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - $mysqli->close(); - print "done!"; + $mysqli->close(); + print "done!"; ?> --CLEAN-- --FILE-- 'NOT_NULL', - MYSQLI_PRI_KEY_FLAG => 'PRI_KEY', - MYSQLI_UNIQUE_KEY_FLAG => 'UNIQUE_KEY', - MYSQLI_MULTIPLE_KEY_FLAG => 'MULTIPLE_KEY', - MYSQLI_BLOB_FLAG => 'BLOB', - MYSQLI_UNSIGNED_FLAG => 'UNSIGNED', - MYSQLI_ZEROFILL_FLAG => 'ZEROFILL', - MYSQLI_AUTO_INCREMENT_FLAG => 'AUTO_INCREMENT', - MYSQLI_TIMESTAMP_FLAG => 'TIMESTAMP', - MYSQLI_SET_FLAG => 'SET', - MYSQLI_NUM_FLAG => 'NUM', - MYSQLI_PART_KEY_FLAG => 'PART_KEY', - // MYSQLI_GROUP_FLAG => 'MYSQLI_GROUP_FLAG' - internal usage only - (defined('MYSQLI_NO_DEFAULT_VALUE_FLAG') ? MYSQLI_NO_DEFAULT_VALUE_FLAG : 4096) => 'NO_DEFAULT_VALUE', - (defined('MYSQLI_BINARY_FLAG') ? MYSQLI_BINARY_FLAG : 128) => 'BINARY', - (defined('MYSQLI_ENUM_FLAG') ? MYSQLI_ENUM_FLAG : 256) => 'ENUM', - // MYSQLI_BINCMP_FLAG - ); - - // 5.1.24 / 6.0.4+ - if (defined('MYSQLI_ON_UPDATE_NOW')) - $flags[MYSQLI_ON_UPDATE_NOW] = 'ON_UPDATE_NOW'; - else - $flags[8192] = 'ON_UPDATE_NOW'; - - krsort($flags); - - $columns = array( - 'INT DEFAULT NULL' => 'NUM', - 'INT NOT NULL' => 'NOT_NULL NO_DEFAULT_VALUE NUM', - 'INT NOT NULL DEFAULT 1' => 'NOT_NULL NUM', - 'INT UNSIGNED DEFAULT NULL' => 'UNSIGNED NUM', - 'INT UNSIGNED NOT NULL' => 'NOT_NULL UNSIGNED NO_DEFAULT_VALUE NUM', - 'INT UNSIGNED NOT NULL DEFAULT 1' => 'NOT_NULL UNSIGNED NUM', - 'INT UNSIGNED ZEROFILL DEFAULT NULL' => 'UNSIGNED ZEROFILL NUM', - 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY' => 'NOT_NULL PRI_KEY UNSIGNED AUTO_INCREMENT NUM PART_KEY', - 'CHAR(1) DEFAULT NULL' => '', - 'CHAR(1) NOT NULL' => 'NOT_NULL NO_DEFAULT_VALUE', - 'VARBINARY(127) DEFAULT NULL' => 'BINARY', - 'BLOB' => 'BLOB BINARY', - 'TINYBLOB' => 'BLOB BINARY', - 'MEDIUMBLOB' => 'BLOB BINARY', - 'LONGBLOB' => 'BLOB BINARY', - 'TEXT' => 'BLOB', - 'TINYTEXT' => 'BLOB', - 'MEDIUMTEXT' => 'BLOB', - 'LONGTEXT' => 'BLOB', - 'SET("one", "two")' => 'SET', - 'SET("one", "two") NOT NULL' => 'NOT_NULL SET NO_DEFAULT_VALUE', - 'SET("one", "two") NOT NULL DEFAULT "one"' => 'NOT_NULL SET', - 'ENUM("one", "two")' => 'ENUM', - 'ENUM("one", "two") NOT NULL' => 'NOT_NULL ENUM NO_DEFAULT_VALUE', - 'ENUM("one", "two") NOT NULL DEFAULT "one"' => 'NOT_NULL ENUM', - 'TINYINT UNIQUE' => 'UNIQUE_KEY NUM PART_KEY', - 'SMALLINT UNIQUE' => 'UNIQUE_KEY NUM PART_KEY', - 'MEDIUMINT UNIQUE DEFAULT 1' => 'UNIQUE_KEY NUM PART_KEY', - 'BIGINT UNSIGNED UNIQUE DEFAULT 100' => 'UNIQUE_KEY UNSIGNED NUM PART_KEY', - 'BIT' => 'UNSIGNED', - 'VARCHAR(2) NOT NULL PRIMARY KEY' => 'NOT_NULL PRI_KEY NO_DEFAULT_VALUE PART_KEY' - ); - - - - function checkFlags($reported_flags, $expected_flags, $flags) { - $found_flags = $unexpected_flags = ''; - foreach ($flags as $code => $name) { - if ($reported_flags >= $code) { - $reported_flags -= $code; - $found_flags .= $name . ' '; - if (stristr($expected_flags, $name)) { - $expected_flags = trim(str_ireplace($name, '', $expected_flags)); - } else { - $unexpected_flags .= $name . ' '; - } - } - } - - return array($expected_flags, $unexpected_flags, $found_flags); - } - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - - foreach ($columns as $column_def => $expected_flags) { - if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { - printf("[002] %s [%d] %s\n", $column_def, - mysqli_errno($link), mysqli_error($link)); - continue; - } - - $create = sprintf('CREATE TABLE test(id INT, col1 %s)', $column_def); - if (!mysqli_query($link, $create)) { - // Server might not support it - skip - continue; - } - - if (!$res = mysqli_query($link, 'SELECT * FROM test')) { - printf("[003] Can't select from table, %s [%d] %s\n", $column_def, - mysqli_errno($link), mysqli_error($link)); - continue; - } - - $field = mysqli_fetch_field_direct($res, 1); - if (!is_object($field)) { - printf("[004] Fetching the meta data failed, %s [%d] %s\n", $column_def, - mysqli_errno($link), mysqli_error($link)); - continue; - } - if ($field->name != 'col1') { - printf("[005] Field information seems wrong, %s [%d] %s\n", $column_def, - mysqli_errno($link), mysqli_error($link)); - continue; - } - - /* - TODO - Unfortunately different server versions give you slightly different - results.The test does not yet fully reflect all server changes/bugs etc. - */ - switch ($column_def) { - case 'INT UNSIGNED NOT NULL': - case 'INT NOT NULL': - case 'CHAR(1) NOT NULL': - case 'SET("one", "two") NOT NULL': - case 'ENUM("one", "two") NOT NULL': - $version = mysqli_get_server_version($link); - if ($version < 50000) { - // TODO - check exact version! - $expected_flags = trim(str_replace('NO_DEFAULT_VALUE', '', $expected_flags)); - } - break; - - case 'BIT': - $version = mysqli_get_server_version($link); - if (($version <= 50114 && $version > 50100) || ($version == 50200)) { - // TODO - check exact version! - $expected_flags = trim(str_replace('UNSIGNED', '', $expected_flags)); - } - - default: - break; - } - - list($missing_flags, $unexpected_flags, $flags_found) = checkFlags($field->flags, $expected_flags, $flags); - if ($unexpected_flags) { - printf("[006] Found unexpected flags '%s' for %s, found '%s' with MySQL %s'\n", - $unexpected_flags, $column_def, $flags_found, mysqli_get_server_version($link)); - } - if ($missing_flags) { - printf("[007] The flags '%s' have not been reported for %s, found '%s'\n", - $missing_flags, $column_def, $flags_found); - var_dump($create); - var_dump(mysqli_get_server_version($link)); - die($missing_flags); - } - - mysqli_free_result($res); - } - - if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { - printf("[008] %s [%d] %s\n", $column_def, - mysqli_errno($link), mysqli_error($link)); - } - - $column_def = array('col1 CHAR(1)', 'col2 CHAR(2)','INDEX idx_col1_col2(col1, col2)'); - $expected_flags = array('col1' => 'MULTIPLE_KEY PART_KEY', 'col2' => 'PART_KEY'); - $create = 'CREATE TABLE test(id INT, '; - foreach ($column_def as $k => $v) { - $create .= sprintf('%s, ', $v); - } - $create = sprintf('%s)', substr($create, 0, -2)); - - if (mysqli_query($link, $create)) { - if (!$res = mysqli_query($link, 'SELECT * FROM test')) { - printf("[009] Cannot run SELECT, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - } - // id column - skip it - $field = mysqli_fetch_field($res); - while ($field = mysqli_fetch_field($res)) { - if (!isset($expected_flags[$field->name])) { - printf("[010] Found unexpected field '%s'\n", $field->name); - } - list($missing_flags, $unexpected_flags, $flags_found) = checkFlags($field->flags, $expected_flags[$field->name], $flags); - if ($unexpected_flags) - printf("[011] Found unexpected flags '%s' for %s, found '%s'\n", - $unexpected_flags, $field->name, $flags_found); - if ($missing_flags) - printf("[012] The flags '%s' have not been reported for %s, found '%s'\n", - $missing_flags, $field->name, $flags_found); - } - } - - mysqli_close($link); - print "done!"; + $flags = array( + MYSQLI_NOT_NULL_FLAG => 'NOT_NULL', + MYSQLI_PRI_KEY_FLAG => 'PRI_KEY', + MYSQLI_UNIQUE_KEY_FLAG => 'UNIQUE_KEY', + MYSQLI_MULTIPLE_KEY_FLAG => 'MULTIPLE_KEY', + MYSQLI_BLOB_FLAG => 'BLOB', + MYSQLI_UNSIGNED_FLAG => 'UNSIGNED', + MYSQLI_ZEROFILL_FLAG => 'ZEROFILL', + MYSQLI_AUTO_INCREMENT_FLAG => 'AUTO_INCREMENT', + MYSQLI_TIMESTAMP_FLAG => 'TIMESTAMP', + MYSQLI_SET_FLAG => 'SET', + MYSQLI_NUM_FLAG => 'NUM', + MYSQLI_PART_KEY_FLAG => 'PART_KEY', + // MYSQLI_GROUP_FLAG => 'MYSQLI_GROUP_FLAG' - internal usage only + (defined('MYSQLI_NO_DEFAULT_VALUE_FLAG') ? MYSQLI_NO_DEFAULT_VALUE_FLAG : 4096) => 'NO_DEFAULT_VALUE', + (defined('MYSQLI_BINARY_FLAG') ? MYSQLI_BINARY_FLAG : 128) => 'BINARY', + (defined('MYSQLI_ENUM_FLAG') ? MYSQLI_ENUM_FLAG : 256) => 'ENUM', + // MYSQLI_BINCMP_FLAG + ); + + // 5.1.24 / 6.0.4+ + if (defined('MYSQLI_ON_UPDATE_NOW')) + $flags[MYSQLI_ON_UPDATE_NOW] = 'ON_UPDATE_NOW'; + else + $flags[8192] = 'ON_UPDATE_NOW'; + + krsort($flags); + + $columns = array( + 'INT DEFAULT NULL' => 'NUM', + 'INT NOT NULL' => 'NOT_NULL NO_DEFAULT_VALUE NUM', + 'INT NOT NULL DEFAULT 1' => 'NOT_NULL NUM', + 'INT UNSIGNED DEFAULT NULL' => 'UNSIGNED NUM', + 'INT UNSIGNED NOT NULL' => 'NOT_NULL UNSIGNED NO_DEFAULT_VALUE NUM', + 'INT UNSIGNED NOT NULL DEFAULT 1' => 'NOT_NULL UNSIGNED NUM', + 'INT UNSIGNED ZEROFILL DEFAULT NULL' => 'UNSIGNED ZEROFILL NUM', + 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY' => 'NOT_NULL PRI_KEY UNSIGNED AUTO_INCREMENT NUM PART_KEY', + 'CHAR(1) DEFAULT NULL' => '', + 'CHAR(1) NOT NULL' => 'NOT_NULL NO_DEFAULT_VALUE', + 'VARBINARY(127) DEFAULT NULL' => 'BINARY', + 'BLOB' => 'BLOB BINARY', + 'TINYBLOB' => 'BLOB BINARY', + 'MEDIUMBLOB' => 'BLOB BINARY', + 'LONGBLOB' => 'BLOB BINARY', + 'TEXT' => 'BLOB', + 'TINYTEXT' => 'BLOB', + 'MEDIUMTEXT' => 'BLOB', + 'LONGTEXT' => 'BLOB', + 'SET("one", "two")' => 'SET', + 'SET("one", "two") NOT NULL' => 'NOT_NULL SET NO_DEFAULT_VALUE', + 'SET("one", "two") NOT NULL DEFAULT "one"' => 'NOT_NULL SET', + 'ENUM("one", "two")' => 'ENUM', + 'ENUM("one", "two") NOT NULL' => 'NOT_NULL ENUM NO_DEFAULT_VALUE', + 'ENUM("one", "two") NOT NULL DEFAULT "one"' => 'NOT_NULL ENUM', + 'TINYINT UNIQUE' => 'UNIQUE_KEY NUM PART_KEY', + 'SMALLINT UNIQUE' => 'UNIQUE_KEY NUM PART_KEY', + 'MEDIUMINT UNIQUE DEFAULT 1' => 'UNIQUE_KEY NUM PART_KEY', + 'BIGINT UNSIGNED UNIQUE DEFAULT 100' => 'UNIQUE_KEY UNSIGNED NUM PART_KEY', + 'BIT' => 'UNSIGNED', + 'VARCHAR(2) NOT NULL PRIMARY KEY' => 'NOT_NULL PRI_KEY NO_DEFAULT_VALUE PART_KEY' + ); + + + + function checkFlags($reported_flags, $expected_flags, $flags) { + $found_flags = $unexpected_flags = ''; + foreach ($flags as $code => $name) { + if ($reported_flags >= $code) { + $reported_flags -= $code; + $found_flags .= $name . ' '; + if (stristr($expected_flags, $name)) { + $expected_flags = trim(str_ireplace($name, '', $expected_flags)); + } else { + $unexpected_flags .= $name . ' '; + } + } + } + + return array($expected_flags, $unexpected_flags, $found_flags); + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + foreach ($columns as $column_def => $expected_flags) { + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { + printf("[002] %s [%d] %s\n", $column_def, + mysqli_errno($link), mysqli_error($link)); + continue; + } + + $create = sprintf('CREATE TABLE test(id INT, col1 %s)', $column_def); + if (!mysqli_query($link, $create)) { + // Server might not support it - skip + continue; + } + + if (!$res = mysqli_query($link, 'SELECT * FROM test')) { + printf("[003] Can't select from table, %s [%d] %s\n", $column_def, + mysqli_errno($link), mysqli_error($link)); + continue; + } + + $field = mysqli_fetch_field_direct($res, 1); + if (!is_object($field)) { + printf("[004] Fetching the meta data failed, %s [%d] %s\n", $column_def, + mysqli_errno($link), mysqli_error($link)); + continue; + } + if ($field->name != 'col1') { + printf("[005] Field information seems wrong, %s [%d] %s\n", $column_def, + mysqli_errno($link), mysqli_error($link)); + continue; + } + + /* + TODO + Unfortunately different server versions give you slightly different + results.The test does not yet fully reflect all server changes/bugs etc. + */ + switch ($column_def) { + case 'INT UNSIGNED NOT NULL': + case 'INT NOT NULL': + case 'CHAR(1) NOT NULL': + case 'SET("one", "two") NOT NULL': + case 'ENUM("one", "two") NOT NULL': + $version = mysqli_get_server_version($link); + if ($version < 50000) { + // TODO - check exact version! + $expected_flags = trim(str_replace('NO_DEFAULT_VALUE', '', $expected_flags)); + } + break; + + case 'BIT': + $version = mysqli_get_server_version($link); + if (($version <= 50114 && $version > 50100) || ($version == 50200)) { + // TODO - check exact version! + $expected_flags = trim(str_replace('UNSIGNED', '', $expected_flags)); + } + + default: + break; + } + + list($missing_flags, $unexpected_flags, $flags_found) = checkFlags($field->flags, $expected_flags, $flags); + if ($unexpected_flags) { + printf("[006] Found unexpected flags '%s' for %s, found '%s' with MySQL %s'\n", + $unexpected_flags, $column_def, $flags_found, mysqli_get_server_version($link)); + } + if ($missing_flags) { + printf("[007] The flags '%s' have not been reported for %s, found '%s'\n", + $missing_flags, $column_def, $flags_found); + var_dump($create); + var_dump(mysqli_get_server_version($link)); + die($missing_flags); + } + + mysqli_free_result($res); + } + + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { + printf("[008] %s [%d] %s\n", $column_def, + mysqli_errno($link), mysqli_error($link)); + } + + $column_def = array('col1 CHAR(1)', 'col2 CHAR(2)','INDEX idx_col1_col2(col1, col2)'); + $expected_flags = array('col1' => 'MULTIPLE_KEY PART_KEY', 'col2' => 'PART_KEY'); + $create = 'CREATE TABLE test(id INT, '; + foreach ($column_def as $k => $v) { + $create .= sprintf('%s, ', $v); + } + $create = sprintf('%s)', substr($create, 0, -2)); + + if (mysqli_query($link, $create)) { + if (!$res = mysqli_query($link, 'SELECT * FROM test')) { + printf("[009] Cannot run SELECT, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + } + // id column - skip it + $field = mysqli_fetch_field($res); + while ($field = mysqli_fetch_field($res)) { + if (!isset($expected_flags[$field->name])) { + printf("[010] Found unexpected field '%s'\n", $field->name); + } + list($missing_flags, $unexpected_flags, $flags_found) = checkFlags($field->flags, $expected_flags[$field->name], $flags); + if ($unexpected_flags) + printf("[011] Found unexpected flags '%s' for %s, found '%s'\n", + $unexpected_flags, $field->name, $flags_found); + if ($missing_flags) + printf("[012] The flags '%s' have not been reported for %s, found '%s'\n", + $missing_flags, $field->name, $flags_found); + } + } + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - require('table.inc'); - if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + require('table.inc'); + if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - // Make sure that client, connection and result charsets are all the - // same. Not sure whether this is strictly necessary. - if (!$mysqli->set_charset('utf8')) - printf("[%d] %s\n", $mysqli->errno, $mysqli->errno); + // Make sure that client, connection and result charsets are all the + // same. Not sure whether this is strictly necessary. + if (!$mysqli->set_charset('utf8')) + printf("[%d] %s\n", $mysqli->errno, $mysqli->errno); - $charsetInfo = $mysqli->get_charset(); + $charsetInfo = $mysqli->get_charset(); - if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { - printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); - } + if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) { + printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error); + } - var_dump($res->fetch_field()); + var_dump($res->fetch_field()); - $tmp = $res->fetch_field(); - var_dump($tmp); - if ($tmp->charsetnr != $charsetInfo->number) { - printf("[005] Expecting charset %s/%d got %d\n", - $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr); - } - if ($tmp->length != $charsetInfo->max_length) { - printf("[006] Expecting length %d got %d\n", - $charsetInfo->max_length, $tmp->max_length); - } - if ($tmp->db != $db) { - printf("[007] Expecting database '%s' got '%s'\n", - $db, $tmp->db); - } + $tmp = $res->fetch_field(); + var_dump($tmp); + if ($tmp->charsetnr != $charsetInfo->number) { + printf("[005] Expecting charset %s/%d got %d\n", + $charsetInfo->charset, $charsetInfo->number, $tmp->charsetnr); + } + if ($tmp->length != $charsetInfo->max_length) { + printf("[006] Expecting length %d got %d\n", + $charsetInfo->max_length, $tmp->max_length); + } + if ($tmp->db != $db) { + printf("[007] Expecting database '%s' got '%s'\n", + $db, $tmp->db); + } - var_dump($res->fetch_field()); + var_dump($res->fetch_field()); - $res->free_result(); + $res->free_result(); try { $res->fetch_field(); @@ -62,8 +62,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - $mysqli->close(); - print "done!"; + $mysqli->close(); + print "done!"; ?> --CLEAN-- --FILE-- type != $php_type) { - $code_name = 'unknown'; - foreach ($datatypes as $k => $v) { - if ($k == $field->type) { - $code_name = (is_array($v)) ? $v[0] : $v; - break; - } - } - printf("[006] Expecting %d for %s got code %d for %s\n", - $php_type, $sql_type, $field->type, $code_name); - return false; - } + if ($field->type != $php_type) { + $code_name = 'unknown'; + foreach ($datatypes as $k => $v) { + if ($k == $field->type) { + $code_name = (is_array($v)) ? $v[0] : $v; + break; + } + } + printf("[006] Expecting %d for %s got code %d for %s\n", + $php_type, $sql_type, $field->type, $code_name); + return false; + } - return true; - } + return true; + } - $datatypes = array( - MYSQLI_TYPE_TINY => array('TINYINT', 5), - MYSQLI_TYPE_SHORT => array('SMALLINT', 10), - MYSQLI_TYPE_LONG => 'MYSQLI_TYPE_LONG - TODO add testing', - MYSQLI_TYPE_FLOAT => array('FLOAT', '1.3'), - MYSQLI_TYPE_DOUBLE => array('DOUBLE', '1.4'), - MYSQLI_TYPE_TIMESTAMP => array('TIMESTAMP', '2007-08-20 18:34:00'), - MYSQLI_TYPE_LONGLONG => array('BIGINT', 100), - MYSQLI_TYPE_INT24 => array('MEDIUMINT', 10), - MYSQLI_TYPE_DATE => array('DATE', '2007-08-20'), - MYSQLI_TYPE_TIME => array('TIME', '18:41:38'), - MYSQLI_TYPE_DATETIME => array('DATETIME', '2007-08-20 18:42:01'), - MYSQLI_TYPE_YEAR => array('YEAR', '2007'), - MYSQLI_TYPE_ENUM => array('ENUM("everything", "is", "just", "wonderful")', 'is'), - // MYSQLI_TYPE_SET => array('SET("I", "smash", "the")', 'I,smash,the'), - string - // MYSQLI_TYPE_TINY_BLOB => array("TINYBLOB", "I got a tiny blog"), - blob - // MYSQLI_TYPE_MEDIUM_BLOB => array("MEDIUMBLOB", "No blob for masses"), - blob - // MYSQLI_TYPE_LONG_BLOB => array("LONGBLOB", "Small is beautiful?"), - blob - MYSQLI_TYPE_BLOB => array("LONGBLOB", 'MySQL does not report proper type. Use Length to distinct BLOB types'), - MYSQLI_TYPE_BLOB => array("MEDIUMBLOB", 'MySQL does not report proper type. Use Length to distinct BLOB types'), - MYSQLI_TYPE_BLOB => array("TINYBLOB", 'MySQL does not report proper type. Use Length to distinct BLOB types'), - MYSQLI_TYPE_BLOB => array("BLOB", 'silly'), - MYSQLI_TYPE_VAR_STRING => array("VARCHAR(32768)", 'varchar'), - MYSQLI_TYPE_STRING => 'MYSQLI_TYPE_STRING - TODO add testing', - MYSQLI_TYPE_STRING => array('CHAR(1)', 'a'), - MYSQLI_TYPE_STRING => array("SET('I', 'smash', 'the')", 'smash'), - MYSQLI_TYPE_NULL => 'MYSQLI_TYPE_NULL - TODO add testing', - MYSQLI_TYPE_NEWDATE => 'MYSQLI_TYPE_NEWDATE - TODO add testing', - MYSQLI_TYPE_INTERVAL => 'MYSQLI_TYPE_INTERVAL - TODO add testing', - MYSQLI_TYPE_GEOMETRY => 'MYSQLI_TYPE_GEOMETRY - TODO add testing', - ); + $datatypes = array( + MYSQLI_TYPE_TINY => array('TINYINT', 5), + MYSQLI_TYPE_SHORT => array('SMALLINT', 10), + MYSQLI_TYPE_LONG => 'MYSQLI_TYPE_LONG - TODO add testing', + MYSQLI_TYPE_FLOAT => array('FLOAT', '1.3'), + MYSQLI_TYPE_DOUBLE => array('DOUBLE', '1.4'), + MYSQLI_TYPE_TIMESTAMP => array('TIMESTAMP', '2007-08-20 18:34:00'), + MYSQLI_TYPE_LONGLONG => array('BIGINT', 100), + MYSQLI_TYPE_INT24 => array('MEDIUMINT', 10), + MYSQLI_TYPE_DATE => array('DATE', '2007-08-20'), + MYSQLI_TYPE_TIME => array('TIME', '18:41:38'), + MYSQLI_TYPE_DATETIME => array('DATETIME', '2007-08-20 18:42:01'), + MYSQLI_TYPE_YEAR => array('YEAR', '2007'), + MYSQLI_TYPE_ENUM => array('ENUM("everything", "is", "just", "wonderful")', 'is'), + // MYSQLI_TYPE_SET => array('SET("I", "smash", "the")', 'I,smash,the'), - string + // MYSQLI_TYPE_TINY_BLOB => array("TINYBLOB", "I got a tiny blog"), - blob + // MYSQLI_TYPE_MEDIUM_BLOB => array("MEDIUMBLOB", "No blob for masses"), - blob + // MYSQLI_TYPE_LONG_BLOB => array("LONGBLOB", "Small is beautiful?"), - blob + MYSQLI_TYPE_BLOB => array("LONGBLOB", 'MySQL does not report proper type. Use Length to distinct BLOB types'), + MYSQLI_TYPE_BLOB => array("MEDIUMBLOB", 'MySQL does not report proper type. Use Length to distinct BLOB types'), + MYSQLI_TYPE_BLOB => array("TINYBLOB", 'MySQL does not report proper type. Use Length to distinct BLOB types'), + MYSQLI_TYPE_BLOB => array("BLOB", 'silly'), + MYSQLI_TYPE_VAR_STRING => array("VARCHAR(32768)", 'varchar'), + MYSQLI_TYPE_STRING => 'MYSQLI_TYPE_STRING - TODO add testing', + MYSQLI_TYPE_STRING => array('CHAR(1)', 'a'), + MYSQLI_TYPE_STRING => array("SET('I', 'smash', 'the')", 'smash'), + MYSQLI_TYPE_NULL => 'MYSQLI_TYPE_NULL - TODO add testing', + MYSQLI_TYPE_NEWDATE => 'MYSQLI_TYPE_NEWDATE - TODO add testing', + MYSQLI_TYPE_INTERVAL => 'MYSQLI_TYPE_INTERVAL - TODO add testing', + MYSQLI_TYPE_GEOMETRY => 'MYSQLI_TYPE_GEOMETRY - TODO add testing', + ); - if ($IS_MYSQLND) { - $version = 50007 + 1; - } else { - $version = mysqli_get_client_version(); - } + if ($IS_MYSQLND) { + $version = 50007 + 1; + } else { + $version = mysqli_get_client_version(); + } - if ($version > 50002) { - $datatypes[MYSQLI_TYPE_NEWDECIMAL] = array('DECIMAL', '1.1'); - $datatypes[MYSQLI_TYPE_BIT] = array('BIT', 0); - } else { - $datatypes[MYSQLI_TYPE_DECIMAL] = array('DECIMAL', '1.1'); - } + if ($version > 50002) { + $datatypes[MYSQLI_TYPE_NEWDECIMAL] = array('DECIMAL', '1.1'); + $datatypes[MYSQLI_TYPE_BIT] = array('BIT', 0); + } else { + $datatypes[MYSQLI_TYPE_DECIMAL] = array('DECIMAL', '1.1'); + } - foreach ($datatypes as $php_type => $datatype) { - if (is_array($datatype)) - mysqli_field_datatypes($link, $datatype[0], $datatype[1], $php_type, $datatypes); - } + foreach ($datatypes as $php_type => $datatype) { + if (is_array($datatype)) + mysqli_field_datatypes($link, $datatype[0], $datatype[1], $php_type, $datatypes); + } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- $field) { - var_dump($field); - switch ($k) { - case 1: - /* label column, result set charset */ - if ($field->charsetnr != $charsetInfo->number) { - printf("[004] Expecting charset %s/%d got %d\n", - $charsetInfo->charset, - $charsetInfo->number, $field->charsetnr); - } - if ($field->length != $charsetInfo->max_length) { - printf("[005] Expecting length %d got %d\n", - $charsetInfo->max_length, - $field->max_length); - } - break; - } - } + $fields = mysqli_fetch_fields($res); + foreach ($fields as $k => $field) { + var_dump($field); + switch ($k) { + case 1: + /* label column, result set charset */ + if ($field->charsetnr != $charsetInfo->number) { + printf("[004] Expecting charset %s/%d got %d\n", + $charsetInfo->charset, + $charsetInfo->number, $field->charsetnr); + } + if ($field->length != $charsetInfo->max_length) { + printf("[005] Expecting length %d got %d\n", + $charsetInfo->max_length, + $field->max_length); + } + break; + } + } - mysqli_free_result($res); + mysqli_free_result($res); try { mysqli_fetch_fields($res); @@ -53,8 +53,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { - printf("[002] [%d] %s\n", $mysqli->errno, $mysqli->error); - } + require('table.inc'); + if (!$res = $mysqli->query("SELECT id, label FROM test ORDER BY id LIMIT 1")) { + printf("[002] [%d] %s\n", $mysqli->errno, $mysqli->error); + } - var_dump($res->lengths); - while ($row = $res->fetch_assoc()) - var_dump($res->lengths); - var_dump($res->lengths); + var_dump($res->lengths); + while ($row = $res->fetch_assoc()) + var_dump($res->lengths); + var_dump($res->lengths); - $res->free_result(); - try { - $res->lengths; - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } - $mysqli->close(); - print "done!"; + $res->free_result(); + try { + $res->lengths; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } + $mysqli->close(); + print "done!"; ?> --CLEAN-- --FILE-- ID !== "1") || ($obj->label !== "a") || (get_class($obj) != 'stdClass')) { - printf("[004] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } + $obj = mysqli_fetch_object($res); + if (($obj->ID !== "1") || ($obj->label !== "a") || (get_class($obj) != 'stdClass')) { + printf("[004] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } - class mysqli_fetch_object_test { + class mysqli_fetch_object_test { - public $a = null; - public $b = null; + public $a = null; + public $b = null; - public function toString() { - var_dump($this); - } - } + public function toString() { + var_dump($this); + } + } - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_test'); - if (($obj->ID !== "2") || ($obj->label !== "b") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_test')) { - printf("[005] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_test'); + if (($obj->ID !== "2") || ($obj->label !== "b") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_test')) { + printf("[005] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } - class mysqli_fetch_object_construct extends mysqli_fetch_object_test { + class mysqli_fetch_object_construct extends mysqli_fetch_object_test { - public function __construct($a, $b) { - $this->a = $a; - $this->b = $b; - } + public function __construct($a, $b) { + $this->a = $a; + $this->b = $b; + } - } + } - try { - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array()); - if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[006] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } - } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; - } + try { + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array()); + if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[006] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } - try { - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a')); - if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[007] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } - } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; - } + try { + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a')); + if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[007] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a', 'b')); - if (($obj->ID !== "5") || ($obj->label !== "e") || ($obj->a !== 'a') || ($obj->b !== 'b') || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[008] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($obj); - } + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a', 'b')); + if (($obj->ID !== "5") || ($obj->label !== "e") || ($obj->a !== 'a') || ($obj->b !== 'b') || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[008] Object seems wrong. [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($obj); + } - var_dump(mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a', 'b', 'c'))); - var_dump(mysqli_fetch_object($res)); + var_dump(mysqli_fetch_object($res, 'mysqli_fetch_object_construct', array('a', 'b', 'c'))); + var_dump(mysqli_fetch_object($res)); - mysqli_free_result($res); + mysqli_free_result($res); - if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST")) { - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST")) { + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_free_result($res); - try { + mysqli_free_result($res); + try { mysqli_fetch_object($res); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - /* - TODO - I'm using the procedural interface, this should not throw an exception. - Also, I did not ask to get exceptions using the mysqli_options() - */ - try { - if (false !== ($obj = @mysqli_fetch_object($res, 'mysqli_fetch_object_construct', 'a'))) - printf("[011] Should have failed\n"); - } catch (Error $e) { - handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); - } - - mysqli_free_result($res); - - if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - class mysqli_fetch_object_private_constructor extends mysqli_fetch_object_test { - - private function __construct($a, $b) { - $this->a = $a; - $this->b = $b; - } - } - /* - TODO - I think we should bail out here. The following line will give a Fatal error: Call to private ... from invalid context - var_dump($obj = new mysqli_fetch_object_private_constructor(1, 2)); - This does not fail. - */ - $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_private_constructor', array('a', 'b')); - mysqli_free_result($res); - - // Fatal error, script execution will end - var_dump(mysqli_fetch_object($res, 'this_class_does_not_exist')); - - - mysqli_close($link); - print "done!"; + if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + /* + TODO + I'm using the procedural interface, this should not throw an exception. + Also, I did not ask to get exceptions using the mysqli_options() + */ + try { + if (false !== ($obj = @mysqli_fetch_object($res, 'mysqli_fetch_object_construct', 'a'))) + printf("[011] Should have failed\n"); + } catch (Error $e) { + handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + } + + mysqli_free_result($res); + + if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + class mysqli_fetch_object_private_constructor extends mysqli_fetch_object_test { + + private function __construct($a, $b) { + $this->a = $a; + $this->b = $b; + } + } + /* + TODO + I think we should bail out here. The following line will give a Fatal error: Call to private ... from invalid context + var_dump($obj = new mysqli_fetch_object_private_constructor(1, 2)); + This does not fail. + */ + $obj = mysqli_fetch_object($res, 'mysqli_fetch_object_private_constructor', array('a', 'b')); + mysqli_free_result($res); + + // Fatal error, script execution will end + var_dump(mysqli_fetch_object($res, 'this_class_does_not_exist')); + + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage()); - } + printf("\nException with mysqli. Note that at all other places we throws errors but no exceptions unless the error mode has been changed:\n"); + try { + var_dump($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_test', array(1, 2))); + } catch (Exception $e) { + printf("Exception: %s\n", $e->getMessage()); + } - printf("\nFatal error with PHP (but no exception!):\n"); - var_dump($obj->mysqli_fetch_object_test(1, 2)); + printf("\nFatal error with PHP (but no exception!):\n"); + var_dump($obj->mysqli_fetch_object_test(1, 2)); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- getMessage() . "\n"; } - require('table.inc'); - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) { - printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - try { - if (!is_null($tmp = @$res->fetch_object($link, $link))) - printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - } catch (Error $e) { - handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); - } - - - try { - if (!is_null($tmp = @$res->fetch_object($link, $link, $link))) - printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - } catch (Error $e) { - handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); - } - - $obj = mysqli_fetch_object($res); - if (($obj->ID !== "1") || ($obj->label !== "a") || (get_class($obj) != 'stdClass')) { - printf("[007] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($obj); - } - - class mysqli_fetch_object_test { - - public $a = null; - public $b = null; - - public function toString() { - var_dump($this); - } - } - - $obj = $res->fetch_object('mysqli_fetch_object_test'); - if (($obj->ID !== "2") || ($obj->label !== "b") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_test')) { - printf("[008] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($obj); - } - - class mysqli_fetch_object_construct extends mysqli_fetch_object_test { - - public function __construct($a, $b) { - $this->a = $a; - $this->b = $b; - } - - } - - try { - $obj = $res->fetch_object('mysqli_fetch_object_construct', null); - - if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[009] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($obj); - } - } catch (Error $e) { - handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); - mysqli_fetch_object($res); - } - - try { - $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a')); - if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[010] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($obj); - } - } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; - } - - $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a', 'b')); - if (($obj->ID !== "5") || ($obj->label !== "e") || ($obj->a !== 'a') || ($obj->b !== 'b') || (get_class($obj) != 'mysqli_fetch_object_construct')) { - printf("[011] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); - var_dump($obj); - } - - var_dump($res->fetch_object('mysqli_fetch_object_construct', array('a', 'b', 'c'))); - var_dump(mysqli_fetch_object($res)); - - mysqli_free_result($res); - - if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST")) { - printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); - } - - mysqli_free_result($res); - - try { + require('table.inc'); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5")) { + printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + try { + if (!is_null($tmp = @$res->fetch_object($link, $link))) + printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + } catch (Error $e) { + handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + } + + + try { + if (!is_null($tmp = @$res->fetch_object($link, $link, $link))) + printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + } catch (Error $e) { + handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + } + + $obj = mysqli_fetch_object($res); + if (($obj->ID !== "1") || ($obj->label !== "a") || (get_class($obj) != 'stdClass')) { + printf("[007] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($obj); + } + + class mysqli_fetch_object_test { + + public $a = null; + public $b = null; + + public function toString() { + var_dump($this); + } + } + + $obj = $res->fetch_object('mysqli_fetch_object_test'); + if (($obj->ID !== "2") || ($obj->label !== "b") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_test')) { + printf("[008] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($obj); + } + + class mysqli_fetch_object_construct extends mysqli_fetch_object_test { + + public function __construct($a, $b) { + $this->a = $a; + $this->b = $b; + } + + } + + try { + $obj = $res->fetch_object('mysqli_fetch_object_construct', null); + + if (($obj->ID !== "3") || ($obj->label !== "c") || ($obj->a !== NULL) || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[009] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($obj); + } + } catch (Error $e) { + handle_catchable_fatal($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + mysqli_fetch_object($res); + } + + try { + $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a')); + if (($obj->ID !== "4") || ($obj->label !== "d") || ($obj->a !== 'a') || ($obj->b !== NULL) || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[010] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($obj); + } + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } + + $obj = $res->fetch_object('mysqli_fetch_object_construct', array('a', 'b')); + if (($obj->ID !== "5") || ($obj->label !== "e") || ($obj->a !== 'a') || ($obj->b !== 'b') || (get_class($obj) != 'mysqli_fetch_object_construct')) { + printf("[011] Object seems wrong. [%d] %s\n", $mysqli->errno, $mysqli->error); + var_dump($obj); + } + + var_dump($res->fetch_object('mysqli_fetch_object_construct', array('a', 'b', 'c'))); + var_dump(mysqli_fetch_object($res)); + + mysqli_free_result($res); + + if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST")) { + printf("[012] [%d] %s\n", $mysqli->errno, $mysqli->error); + } + + mysqli_free_result($res); + + try { mysqli_fetch_object($res); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; - } + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } - // Fatal error, script execution will end - var_dump($res->fetch_object('this_class_does_not_exist')); + // Fatal error, script execution will end + var_dump($res->fetch_object('this_class_does_not_exist')); - $mysqli->close(); - print "done!"; + $mysqli->close(); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- field_count); - var_dump(mysqli_field_count($link)); + if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'x')")) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($link->field_count); + var_dump(mysqli_field_count($link)); - if (!$res = mysqli_query($link, "SELECT NULL as _null, '' AS '', 'three' AS 'drei'")) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump(mysqli_field_count($link)); - mysqli_free_result($res); + if (!$res = mysqli_query($link, "SELECT NULL as _null, '' AS '', 'three' AS 'drei'")) + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump(mysqli_field_count($link)); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); try { mysqli_field_count($link); @@ -40,7 +40,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; --CLEAN-- --FILE-- charsetnr != $charsetInfo->number) { - printf("[004] Expecting charset %s/%d got %d\n", - $charsetInfo->charset, $charsetInfo->number, $field->charsetnr); - } - if ($field->length != $charsetInfo->max_length) { - printf("[005] Expecting length %d got %d\n", - $charsetInfo->max_length, $field->max_length); - } + var_dump(mysqli_field_seek($res, -1)); + var_dump(mysqli_fetch_field($res)); + var_dump(mysqli_field_seek($res, 0)); + var_dump(mysqli_fetch_field($res)); + var_dump(mysqli_field_seek($res, 1)); + + $field = mysqli_fetch_field($res); + var_dump($field); + /* label column, result set charset */ + if ($field->charsetnr != $charsetInfo->number) { + printf("[004] Expecting charset %s/%d got %d\n", + $charsetInfo->charset, $charsetInfo->number, $field->charsetnr); + } + if ($field->length != $charsetInfo->max_length) { + printf("[005] Expecting length %d got %d\n", + $charsetInfo->max_length, $field->max_length); + } - var_dump(mysqli_field_tell($res)); - var_dump(mysqli_field_seek($res, 2)); - var_dump(mysqli_fetch_field($res)); + var_dump(mysqli_field_tell($res)); + var_dump(mysqli_field_seek($res, 2)); + var_dump(mysqli_fetch_field($res)); - mysqli_free_result($res); + mysqli_free_result($res); - if (!$res = mysqli_query($link, "SELECT NULL as _null", MYSQLI_STORE_RESULT)) { - printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - var_dump(mysqli_field_seek($res, 0)); - var_dump(mysqli_fetch_field($res)); + if (!$res = mysqli_query($link, "SELECT NULL as _null", MYSQLI_STORE_RESULT)) { + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + var_dump(mysqli_field_seek($res, 0)); + var_dump(mysqli_fetch_field($res)); - mysqli_free_result($res); + mysqli_free_result($res); try { mysqli_field_seek($res, 0); @@ -107,8 +107,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- 3) { - printf("[011] Child has fetched more than three rows!\n"); - var_dump($client_row); - if (!mysqli_query($plink, sprintf($parent_sql, 'stop'))) { - printf("[012] Parent cannot inform child\n", mysqli_errno($plink), mysqli_error($plink)); - } - break 2; - } - - if (!$parent_row = mysqli_fetch_assoc($res)) { - printf("[013] Parent cannot fetch row %d\n", $num_rows, mysqli_errno($link), mysqli_error($link)); - if (!mysqli_query($plink, sprintf($parent_sql, 'stop'))) { - printf("[014] Parent cannot inform child\n", mysqli_errno($plink), mysqli_error($plink)); - } - break 2; - } - - ob_start(); - var_dump($parent_row); - $parent_row = ob_get_contents(); - ob_end_clean(); - - if ($parent_row != $client_row) { - printf("[015] Child indicates different results than parent.\n"); - var_dump($client_row); - var_dump($parent_row); - if (!mysqli_query($plink, sprintf($parent_sql, 'stop'))) { - printf("[016] Parent cannot inform child\n", mysqli_errno($plink), mysqli_error($plink)); - } - break 2; - } - - if (!mysqli_query($plink, sprintf($parent_sql, 'continue'))) { - printf("[017] Parent cannot inform child to continue.\n", mysqli_errno($plink), mysqli_error($plink)); - } - break; - } - } - mysqli_free_result($pres); - } - usleep(100); - } while (((time() - $start) < 5) && ($num_rows < 3)); - mysqli_close($plink); - $wait_id = pcntl_waitpid($pid, $status); - if (pcntl_wifexited($status) && (0 != ($tmp = pcntl_wexitstatus($status)))) { - printf("Exit code: %s\n", (pcntl_wifexited($status)) ? pcntl_wexitstatus($status) : 'n/a'); - printf("Signal: %s\n", (pcntl_wifsignaled($status)) ? pcntl_wtermsig($status) : 'n/a'); - printf("Stopped: %d\n", (pcntl_wifstopped($status)) ? pcntl_wstopsig($status) : 'n/a'); - } - break; - } - mysqli_free_result($res); - mysqli_close($link); - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[018] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - if (!$res = mysqli_query($link, "SELECT sender, msg FROM messages ORDER BY msg_id ASC")) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - while ($row = mysqli_fetch_assoc($res)) - printf("%10s %s\n", $row['sender'], substr($row['msg'], 0, 5)); - mysqli_free_result($res); - - print "done!"; + require_once("table.inc"); + + $res = mysqli_query($link, "SELECT 'dumped by the parent' AS message"); + $pid = pcntl_fork(); + switch ($pid) { + case -1: + printf("[001] Cannot fork child"); + break; + + case 0: + /* child */ + exit(0); + break; + + default: + /* parent */ + $status = null; + $wait_id = pcntl_waitpid($pid, $status); + if (pcntl_wifexited($status) && (0 != ($tmp = pcntl_wexitstatus($status)))) { + printf("Exit code: %s\n", (pcntl_wifexited($status)) ? pcntl_wexitstatus($status) : 'n/a'); + printf("Signal: %s\n", (pcntl_wifsignaled($status)) ? pcntl_wtermsig($status) : 'n/a'); + printf("Stopped: %d\n", (pcntl_wifstopped($status)) ? pcntl_wstopsig($status) : 'n/a'); + } + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + break; + } + + if (@mysqli_query($link, "SELECT id FROM test WHERE id = 1")) + printf("[003] Expecting error and closed connection, child exit should have closed connection\n"); + else if ((($errno = mysqli_errno($link)) == 0) || ('' == ($error = mysqli_error($link)))) + printf("[004] Expecting error string and error code from MySQL, got errno = %s/%s, error = %s/%s\n", + gettype($errno), $errno, gettype($error), $error); + + mysqli_close($link); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[005] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + /* non trivial tests require a message list for parent-child communication */ + if (!mysqli_query($link, "DROP TABLE IF EXISTS messages")) + printf("[006] [%d] %s\n", mysqli_error($link), mysqli_errno($link)); + + if (!mysqli_query($link, "CREATE TABLE messages( + msg_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + msg_time TIMESTAMP, + pid INT NOT NULL, + sender ENUM('child', 'parent') NOT NULL, + msg TEXT) ENGINE = InnoDB")) + printf("[007] [%d] %s\n", mysqli_error($link), mysqli_errno($link)); + + mysqli_autocommit($link, false); + if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 3", MYSQLI_USE_RESULT)) + printf("[008] [%d] %s\n", mysqli_error($link), mysqli_errno($link)); + + $pid = pcntl_fork(); + + switch ($pid) { + case -1: + printf("[009] Cannot fork child"); + break; + + case 0: + /* child */ + if (!($plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) || !mysqli_autocommit($plink, true)) + exit(mysqli_errno($plink)); + + $sql = sprintf("INSERT INTO messages(pid, sender, msg) VALUES (%d, 'child', '%%s')", posix_getpid()); + if (!mysqli_query($plink, sprintf($sql, 'start'))) + exit(mysqli_errno($plink)); + + $parent_sql = sprintf("SELECT msg_id, msg_time, msg FROM messages WHERE pid = %d AND sender = 'parent' ORDER BY msg_id DESC LIMIT 1", posix_getppid()); + $msg_id = 0; + while ($row = mysqli_fetch_assoc($res)) { + /* send row to parent */ + ob_start(); + var_dump($row); + $tmp = ob_get_contents(); + ob_end_clean(); + if (!mysqli_query($plink, sprintf($sql, $tmp))) + exit(mysqli_errno($plink)); + + /* let the parent reply... */ + $start = time(); + do { + usleep(100); + if (!$pres = mysqli_query($plink, $parent_sql)) + continue; + $tmp = mysqli_fetch_assoc($pres); + mysqli_free_result($pres); + if (!$tmp || $tmp['msg_id'] == $msg_id) + /* no new message */ + continue; + if ($tmp['msg'] == 'stop') + break 2; + $msg_id = $tmp['msg_id']; + break; + } while ((time() - $start) < 5); + + } + + if (!mysqli_query($plink, sprintf($sql, 'stop')) || !mysqli_commit($link)) + exit(mysqli_errno($plink)); + exit(0); + break; + + default: + /* parent */ + if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[010] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + $status = null; + $start = time(); + $sql = sprintf("SELECT msg_id, msg_time, msg FROM messages WHERE pid = %d AND sender = 'child' ORDER BY msg_id DESC LIMIT 1", $pid); + $parent_sql = sprintf("INSERT INTO messages (pid, sender, msg) VALUES (%d, 'parent', '%%s')", posix_getpid()); + $last_msg_id = 0; + $num_rows = 0; + do { + $wait_id = pcntl_waitpid($pid, $status, WNOHANG); + if ($pres = mysqli_query($plink, $sql)) { + $row = mysqli_fetch_assoc($pres); + if ($row && $row['msg_id'] != $last_msg_id) { + $last_msg_id = $row['msg_id']; + switch ($row['msg']) { + case 'start': + break; + case 'stop': + break 2; + default: + /* client has started fetching rows */ + $client_row = $row['msg']; + + $num_rows++; + if ($num_rows > 3) { + printf("[011] Child has fetched more than three rows!\n"); + var_dump($client_row); + if (!mysqli_query($plink, sprintf($parent_sql, 'stop'))) { + printf("[012] Parent cannot inform child\n", mysqli_errno($plink), mysqli_error($plink)); + } + break 2; + } + + if (!$parent_row = mysqli_fetch_assoc($res)) { + printf("[013] Parent cannot fetch row %d\n", $num_rows, mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($plink, sprintf($parent_sql, 'stop'))) { + printf("[014] Parent cannot inform child\n", mysqli_errno($plink), mysqli_error($plink)); + } + break 2; + } + + ob_start(); + var_dump($parent_row); + $parent_row = ob_get_contents(); + ob_end_clean(); + + if ($parent_row != $client_row) { + printf("[015] Child indicates different results than parent.\n"); + var_dump($client_row); + var_dump($parent_row); + if (!mysqli_query($plink, sprintf($parent_sql, 'stop'))) { + printf("[016] Parent cannot inform child\n", mysqli_errno($plink), mysqli_error($plink)); + } + break 2; + } + + if (!mysqli_query($plink, sprintf($parent_sql, 'continue'))) { + printf("[017] Parent cannot inform child to continue.\n", mysqli_errno($plink), mysqli_error($plink)); + } + break; + } + } + mysqli_free_result($pres); + } + usleep(100); + } while (((time() - $start) < 5) && ($num_rows < 3)); + mysqli_close($plink); + $wait_id = pcntl_waitpid($pid, $status); + if (pcntl_wifexited($status) && (0 != ($tmp = pcntl_wexitstatus($status)))) { + printf("Exit code: %s\n", (pcntl_wifexited($status)) ? pcntl_wexitstatus($status) : 'n/a'); + printf("Signal: %s\n", (pcntl_wifsignaled($status)) ? pcntl_wtermsig($status) : 'n/a'); + printf("Stopped: %d\n", (pcntl_wifstopped($status)) ? pcntl_wstopsig($status) : 'n/a'); + } + break; + } + mysqli_free_result($res); + mysqli_close($link); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[018] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!$res = mysqli_query($link, "SELECT sender, msg FROM messages ORDER BY msg_id ASC")) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + while ($row = mysqli_fetch_assoc($res)) + printf("%10s %s\n", $row['sender'], substr($row['msg'], 0, 5)); + mysqli_free_result($res); + + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- charset) || - !in_array(gettype($charset->charset), array("string", "unicode")) || - ($character_set_connection !== $charset->charset)) - printf("[016] Expecting string/%s, got %s/%s\n", $character_set_connection, gettype($charset->charset), $charset->charset); - if (!isset($charset->collation) || - !in_array(gettype($charset->collation), array("string", "unicode")) || - ($collation_connection !== $charset->collation)) - printf("[017] Expecting string/%s, got %s/%s\n", $collation_connection, gettype($charset->collation), $charset->collation); - - if (!isset($charset->dir) || - !is_string($charset->dir)) - printf("[019] Expecting string - ideally %s*, got %s/%s\n", $character_sets_dir, gettype($charset->dir), $charset->dir); - - if (!isset($charset->min_length) || - !(is_int($charset->min_length)) || - ($charset->min_length < 0) || - ($charset->min_length > $charset->max_length)) - printf("[020] Expecting int between 0 ... %d, got %s/%s\n", $charset->max_length, - gettype($charset->min_length), $charset->min_length); - - if (!isset($charset->number) || - !is_int($charset->number) || - ($charset->number !== (int)$id)) - printf("[021] Expecting int/%d, got %s/%s\n", $id, gettype($charset->number), $charset->number); - - if (!isset($charset->state) || - !is_int($charset->state)) - printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); - - mysqli_close($link); - - try { + require_once("connect.inc"); + + require('table.inc'); + + if (!$res = mysqli_query($link, 'SELECT version() AS server_version')) + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + $version = explode('.', $tmp['server_version']); + if (empty($version)) + printf("[005] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); + + if ($version[0] <= 4 && $version[1] < 1) + printf("[006] Need MySQL Server 4.1+ for the test!\n"); + + if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation')) + printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + if (!($character_set_connection = $tmp['charset']) || !($collation_connection = $tmp['collation'])) + printf("[008] Cannot determine current character set and collation\n"); + + if (!$res = mysqli_query($link, $sql = sprintf("SHOW CHARACTER SET LIKE '%s'", $character_set_connection))) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if (empty($tmp)) + printf("[010] Cannot fetch Maxlen and/or Comment, test will fail: $sql\n"); + + $maxlen = (isset($tmp['Maxlen'])) ? $tmp['Maxlen'] : ''; + $comment = (isset($tmp['Description'])) ? $tmp['Description'] : ''; + + if (!$res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $collation_connection))) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + if (!($id = $tmp['Id'])) + printf("[012] Cannot fetch Id/Number, test will fail\n"); + + if (!$res = mysqli_query($link, sprintf("SHOW VARIABLES LIKE 'character_sets_dir'"))) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + if (!($character_sets_dir = $tmp['Value'])) + printf("[014] Cannot fetch character_sets_dir, test will fail\n"); + + if (!is_object($charset = mysqli_get_charset($link))) + printf("[015] Expecting object/std_class, got %s/%s\n", gettype($charset), $charset); + + if (!isset($charset->charset) || + !in_array(gettype($charset->charset), array("string", "unicode")) || + ($character_set_connection !== $charset->charset)) + printf("[016] Expecting string/%s, got %s/%s\n", $character_set_connection, gettype($charset->charset), $charset->charset); + if (!isset($charset->collation) || + !in_array(gettype($charset->collation), array("string", "unicode")) || + ($collation_connection !== $charset->collation)) + printf("[017] Expecting string/%s, got %s/%s\n", $collation_connection, gettype($charset->collation), $charset->collation); + + if (!isset($charset->dir) || + !is_string($charset->dir)) + printf("[019] Expecting string - ideally %s*, got %s/%s\n", $character_sets_dir, gettype($charset->dir), $charset->dir); + + if (!isset($charset->min_length) || + !(is_int($charset->min_length)) || + ($charset->min_length < 0) || + ($charset->min_length > $charset->max_length)) + printf("[020] Expecting int between 0 ... %d, got %s/%s\n", $charset->max_length, + gettype($charset->min_length), $charset->min_length); + + if (!isset($charset->number) || + !is_int($charset->number) || + ($charset->number !== (int)$id)) + printf("[021] Expecting int/%d, got %s/%s\n", $id, gettype($charset->number), $charset->number); + + if (!isset($charset->state) || + !is_int($charset->state)) + printf("[022] Expecting int/any, got %s/%s\n", gettype($charset->state), $charset->state); + + mysqli_close($link); + + try { mysqli_get_charset($link); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index 5894789e3755..49fd7470d6c3 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -15,905 +15,905 @@ mysqlnd.collect_memory_statistics=1 mysqli.allow_local_infile=1 --FILE-- %s/%s, got %s/%s\n", - $test_counter, $desc, - $field, $expected[$field], gettype($expected[$field]), - $current[$field], gettype($current[$field])); - } - } else { - if ($current <= $expected) { - printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n", - $test_counter, $desc, $field, - $expected, gettype($expected), - $current, gettype($current)); - } - } - - } - - - require_once("connect.inc"); - - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); - - var_dump($info); - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - exit(1); - } - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); - - if (count($info) != count($new_info)) { - printf("[005] Expecting the same number of entries in the arrays\n"); - var_dump($info); - var_dump($new_info); - } - - $test_counter = 6; - - mysqli_get_client_stats_assert_gt('bytes_sent', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_gt('bytes_received', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_gt('packets_sent', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_gt('packets_received', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_gt('protocol_overhead_in', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_gt('protocol_overhead_out', $new_info, $info, $test_counter); - - // we assume the above as tested and in the following we check only those - mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, $info, $test_counter); - - /* we need to skip this test in unicode - we send set names utf8 during mysql_connect */ - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('ps_buffered_sets', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $new_info, $info, $test_counter); - - mysqli_get_client_stats_assert_eq('rows_skipped_ps', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('copy_on_write_saved', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('copy_on_write_performed', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('command_buffer_too_small', $new_info, $info, $test_counter); - // This is not a mistake that I use string(1) "1" here! Andrey did not go for int to avoid any - // issues for very large numbers and 32 vs. 64bit systems - mysqli_get_client_stats_assert_eq('connect_success', $new_info, "1", $test_counter); - mysqli_get_client_stats_assert_eq('connect_failure', $new_info, $info, $test_counter); - mysqli_get_client_stats_assert_eq('connection_reused', $new_info, $info, $test_counter); - - // No data fetched so far - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $new_info, "0", $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $new_info, "0", $test_counter); - - require('table.inc'); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); - - // fetch stats - $expected = $info; - - // buffered normal - print "Testing buffered normal...\n"; - if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test', MYSQLI_STORE_RESULT)) - printf("[%03d] SELECT COUNT() FROM test failed, [%d] %s\n", - ++$test_counter, mysqli_errno($link), mysqli_error($link)); - - $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1); - $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + 1); - - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); - - mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter); - - // real_data_* get incremented after mysqli_*fetch*() + /* + TODO + no_index_used - difficult to simulate because server/engine dependent + bad_index_used - difficult to simulate because server/engine dependent + flushed_normal_sets + flushed_ps_sets + explicit_close + implicit_close + disconnect_close + in_middle_of_command_close + explicit_free_result + implicit_free_result + explicit_stmt_close + implicit_stmt_close + */ + + function mysqli_get_client_stats_assert_eq($field, $current, $expected, &$test_counter, $desc = "") { + + $test_counter++; + if (is_array($current) && is_array($expected)) { + if ($current[$field] !== $expected[$field]) { + printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n", + $test_counter, $desc, + $field, $expected[$field], gettype($expected[$field]), + $current[$field], gettype($current[$field])); + } + } else if (is_array($current)) { + if ($current[$field] !== $expected) { + printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n", + $test_counter, $desc, + $field, $expected, gettype($expected), + $current[$field], gettype($current[$field])); + } + } else { + if ($current !== $expected) { + printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n", + $test_counter, $desc, + $field, $expected, gettype($expected), + $current, gettype($current)); + } + } + + } + + function mysqli_get_client_stats_assert_gt($field, $current, $expected, &$test_counter, $desc = "") { + + $test_counter++; + if (is_array($current) && is_array($expected)) { + if ($current[$field] <= $expected[$field]) { + printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n", + $test_counter, $desc, + $field, $expected[$field], gettype($expected[$field]), + $current[$field], gettype($current[$field])); + } + } else { + if ($current <= $expected) { + printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n", + $test_counter, $desc, $field, + $expected, gettype($expected), + $current, gettype($current)); + } + } + + } + + + require_once("connect.inc"); + + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[002] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); + + var_dump($info); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + exit(1); + } + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[004] Expecting array/any_non_empty, got %s/%s\n", gettype($new_info), $new_info); + + if (count($info) != count($new_info)) { + printf("[005] Expecting the same number of entries in the arrays\n"); + var_dump($info); + var_dump($new_info); + } + + $test_counter = 6; + + mysqli_get_client_stats_assert_gt('bytes_sent', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_gt('bytes_received', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_gt('packets_sent', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_gt('packets_received', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_gt('protocol_overhead_in', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_gt('protocol_overhead_out', $new_info, $info, $test_counter); + + // we assume the above as tested and in the following we check only those + mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, $info, $test_counter); + + /* we need to skip this test in unicode - we send set names utf8 during mysql_connect */ + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('ps_buffered_sets', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $new_info, $info, $test_counter); + + mysqli_get_client_stats_assert_eq('rows_skipped_ps', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('copy_on_write_saved', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('copy_on_write_performed', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('command_buffer_too_small', $new_info, $info, $test_counter); + // This is not a mistake that I use string(1) "1" here! Andrey did not go for int to avoid any + // issues for very large numbers and 32 vs. 64bit systems + mysqli_get_client_stats_assert_eq('connect_success', $new_info, "1", $test_counter); + mysqli_get_client_stats_assert_eq('connect_failure', $new_info, $info, $test_counter); + mysqli_get_client_stats_assert_eq('connection_reused', $new_info, $info, $test_counter); + + // No data fetched so far + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $new_info, "0", $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $new_info, "0", $test_counter); + + require('table.inc'); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + + // fetch stats + $expected = $info; + + // buffered normal + print "Testing buffered normal...\n"; + if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test', MYSQLI_STORE_RESULT)) + printf("[%03d] SELECT COUNT() FROM test failed, [%d] %s\n", + ++$test_counter, mysqli_errno($link), mysqli_error($link)); + + $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1); + $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + 1); + + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + + mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter); + + // real_data_* get incremented after mysqli_*fetch*() mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, "0", $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); - /* no change to rows_fetched_from_client_normal_buffered! */ - if (!$row = mysqli_fetch_assoc($res)) - printf("[%03d] fetch_assoc - SELECT COUNT() FROM test failed, [%d] %s\n", - ++$test_counter, mysqli_errno($link), mysqli_error($link)); + /* no change to rows_fetched_from_client_normal_buffered! */ + if (!$row = mysqli_fetch_assoc($res)) + printf("[%03d] fetch_assoc - SELECT COUNT() FROM test failed, [%d] %s\n", + ++$test_counter, mysqli_errno($link), mysqli_error($link)); - $expected['rows_fetched_from_client_normal_buffered'] = (string)($expected['rows_fetched_from_client_normal_buffered'] + 1); + $expected['rows_fetched_from_client_normal_buffered'] = (string)($expected['rows_fetched_from_client_normal_buffered'] + 1); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - // fetch will increment - mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); - $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); + // fetch will increment + mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); + $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); - $num_rows = $row['_num']; - mysqli_free_result($res); + $num_rows = $row['_num']; + mysqli_free_result($res); - print "Testing buffered normal... - SELECT id, label FROM test\n"; - if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_STORE_RESULT)) - printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n", - ++$test_counter, mysqli_errno($link), mysqli_error($link)); + print "Testing buffered normal... - SELECT id, label FROM test\n"; + if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_STORE_RESULT)) + printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n", + ++$test_counter, mysqli_errno($link), mysqli_error($link)); - assert(mysqli_num_rows($res) == $num_rows); + assert(mysqli_num_rows($res) == $num_rows); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows); - $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + $num_rows); - $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows); + $expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + $num_rows); + $expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter); - /* fetching none, but stats should not be affected - current implementation */ - mysqli_free_result($res); + /* fetching none, but stats should not be affected - current implementation */ + mysqli_free_result($res); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter); - print "Testing unbuffered normal...\n"; - if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT)) - printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n", - ++$test_counter, mysqli_errno($link), mysqli_error($link)); + print "Testing unbuffered normal...\n"; + if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT)) + printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n", + ++$test_counter, mysqli_errno($link), mysqli_error($link)); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - while ($row = mysqli_fetch_assoc($res)) - ; - mysqli_free_result($res); + while ($row = mysqli_fetch_assoc($res)) + ; + mysqli_free_result($res); - $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows); - $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows); - $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows); + $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows); + $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); - $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; + mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); + $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - print "Testing unbuffered normal... - SELECT id, label FROM test, not all fetched\n"; - if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT)) - printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n", - ++$test_counter, mysqli_errno($link), mysqli_error($link)); + print "Testing unbuffered normal... - SELECT id, label FROM test, not all fetched\n"; + if (!$res = mysqli_query($link, 'SELECT id, label FROM test', MYSQLI_USE_RESULT)) + printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n", + ++$test_counter, mysqli_errno($link), mysqli_error($link)); - for ($i = 0; $i < $num_rows - 1; $i++) - $row = mysqli_fetch_assoc($res); + for ($i = 0; $i < $num_rows - 1; $i++) + $row = mysqli_fetch_assoc($res); - $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows - 1); - $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows - 1); - $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows - 1); + $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + $num_rows - 1); + $expected['unbuffered_sets'] = (string)($expected['unbuffered_sets'] + 1); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); - $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; + mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); + $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - print "Testing if implicit fetching and cleaning happens...\n"; - mysqli_free_result($res); + print "Testing if implicit fetching and cleaning happens...\n"; + mysqli_free_result($res); - /* last row has been implicitly cleaned from the wire by freeing the result set */ - $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1); - $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + 1); - $expected['rows_skipped_normal'] = (string)($info['rows_skipped_normal'] + 1); - $expected['flushed_normal_sets'] = (string)($expected['flushed_normal_sets'] + 1); + /* last row has been implicitly cleaned from the wire by freeing the result set */ + $expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + 1); + $expected['rows_fetched_from_client_normal_unbuffered'] = (string)($expected['rows_fetched_from_client_normal_unbuffered'] + 1); + $expected['rows_skipped_normal'] = (string)($info['rows_skipped_normal'] + 1); + $expected['flushed_normal_sets'] = (string)($expected['flushed_normal_sets'] + 1); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_skipped_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_skipped_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter); - print "Testing buffered Prepared Statements...\n"; - if (!$stmt = mysqli_stmt_init($link)) - printf("[%03d] stmt_init() failed, [%d] %s\n", - ++$test_counter, mysqli_errno($link), mysqli_error($link)); + print "Testing buffered Prepared Statements...\n"; + if (!$stmt = mysqli_stmt_init($link)) + printf("[%03d] stmt_init() failed, [%d] %s\n", + ++$test_counter, mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[%03d] prepare/execute failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || + !mysqli_stmt_execute($stmt)) + printf("[%03d] prepare/execute failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - /* by default PS is unbuffered - no change */ - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); + /* by default PS is unbuffered - no change */ + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); - if (!mysqli_stmt_store_result($stmt)) - printf("[%03d] store_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_free_result($stmt); + if (!mysqli_stmt_store_result($stmt)) + printf("[%03d] store_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_free_result($stmt); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1); - $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows); + $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1); + $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); - print "Testing buffered Prepared Statements... - fetching all\n"; + print "Testing buffered Prepared Statements... - fetching all\n"; - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[%03d] prepare/execute failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || + !mysqli_stmt_execute($stmt)) + printf("[%03d] prepare/execute failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label)) - printf("[%03d] bind_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[%03d] bind_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_store_result($stmt)) - printf("[%03d] store_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_store_result($stmt)) + printf("[%03d] store_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - while (mysqli_stmt_fetch($stmt)) - ; + while (mysqli_stmt_fetch($stmt)) + ; - $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); - $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1); - $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows); + $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); + $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1); + $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); - $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; + mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); + $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); - mysqli_stmt_free_result($stmt); + mysqli_stmt_free_result($stmt); - print "Testing buffered Prepared Statements... - fetching all but one\n"; + print "Testing buffered Prepared Statements... - fetching all but one\n"; - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[%03d] prepare/execute failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || + !mysqli_stmt_execute($stmt)) + printf("[%03d] prepare/execute failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label)) - printf("[%03d] bind_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[%03d] bind_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_store_result($stmt)) - printf("[%03d] store_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_store_result($stmt)) + printf("[%03d] store_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - for ($i = 0; $i < $num_rows - 1; $i++) - mysqli_stmt_fetch($stmt); + for ($i = 0; $i < $num_rows - 1; $i++) + mysqli_stmt_fetch($stmt); - $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); - $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows - 1); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1); - $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows); + $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); + $expected['rows_fetched_from_client_ps_buffered'] = (string)($expected['rows_fetched_from_client_ps_buffered'] + $num_rows - 1); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1); + $expected['rows_buffered_from_client_ps'] = (string)($expected['rows_buffered_from_client_ps'] + $num_rows); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); - $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; + mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); + $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); - $expected['rows_skipped_ps'] = $info['rows_skipped_ps']; - mysqli_stmt_free_result($stmt); + $expected['rows_skipped_ps'] = $info['rows_skipped_ps']; + mysqli_stmt_free_result($stmt); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - /* buffered result set - no skipping possible! */ - mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter); + /* buffered result set - no skipping possible! */ + mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter); - print "Testing unbuffered Prepared Statements... - fetching all\n"; + print "Testing unbuffered Prepared Statements... - fetching all\n"; - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[%03d] prepare/execute failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || + !mysqli_stmt_execute($stmt)) + printf("[%03d] prepare/execute failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label)) - printf("[%03d] bind_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[%03d] bind_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $i = 0; - while (mysqli_stmt_fetch($stmt)) - $i++; - assert($num_rows = $i); + $i = 0; + while (mysqli_stmt_fetch($stmt)) + $i++; + assert($num_rows = $i); - $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); - $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1); + $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows); + $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1); - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); - mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); - $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; + mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); + $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); - mysqli_stmt_free_result($stmt); + mysqli_stmt_free_result($stmt); - print "Testing unbuffered Prepared Statements... - fetching all but one\n"; + print "Testing unbuffered Prepared Statements... - fetching all but one\n"; - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[%03d] prepare/execute failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') || + !mysqli_stmt_execute($stmt)) + printf("[%03d] prepare/execute failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label)) - printf("[%03d] bind_result failed, [%d] %s\n", - ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - for ($i = 0; $i < $num_rows - 1; $i++) - mysqli_stmt_fetch($stmt); - - $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows - 1); - $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows - 1); - $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); - $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1); - - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); - - mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); - $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; - - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); - - mysqli_stmt_free_result($stmt); - $expected['rows_skipped_ps'] = (string)($expected['rows_skipped_ps'] + 1); - $expected['flushed_ps_sets'] = (string)($expected['flushed_ps_sets'] + 1); - $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + 1); - - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); - - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); - - mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('flushed_ps_sets', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); - - /* - print "Checking for normal buffered side effects...\n"; - foreach ($info as $k => $v) - if ($info[$k] != $expected[$k]) - printf("$k - $v != %s\n", $expected[$k]); - */ - print "... done with fetch statistics\n"; - - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); - - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); - - // - // result_set_queries statistics - // - - if (!is_array($info = mysqli_get_client_stats()) || empty($info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($info), $info); - - if (!$res = mysqli_query($link, "SELECT id, label FROM test")) - printf("[%03d] SELECT failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - $rows = 0; - while ($row = mysqli_fetch_assoc($res)) - $rows++; - - if (0 == $rows) - printf("[%03d] Expecting at least one result, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - mysqli_free_result($res); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - - mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, (string)($info['result_set_queries'] + 1), $test_counter); - $info = $new_info; - - mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); - $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; - - // - // non_result_set_queries - DDL - // - - // CREATE TABLE, DROP TABLE - if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test")) - printf("[%03d] DROP TABLE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_query($link, "CREATE TABLE non_result_set_queries_test(id INT) ENGINE = " . $engine)) { - printf("[%03d] CREATE TABLE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - } else { - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'CREATE/DROP TABLE'); - } - $info = $new_info; - - // ALERT TABLE - if (!mysqli_query($link, "ALTER TABLE non_result_set_queries_test ADD label CHAR(1)")) { - printf("[%03d] ALTER TABLE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - } else { - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER TABLE'); - } - $info = $new_info; - - // CREATE INDEX, DROP INDEX - if (!mysqli_query($link, "CREATE INDEX idx_1 ON non_result_set_queries_test(id)")) { - printf("[%03d] CREATE INDEX failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - } else { - - if (!mysqli_query($link, "DROP INDEX idx_1 ON non_result_set_queries_test")) - printf("[%03d] DROP INDEX failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'DROP INDEX'); - } - $info = $new_info; - - // RENAME TABLE - if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test")) - printf("[%03d] Cleanup, DROP TABLE client_stats_test failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - $info = $new_info; - - if (!mysqli_query($link, "RENAME TABLE non_result_set_queries_test TO client_stats_test")) { - printf("[%03d] RENAME TABLE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - } else { - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'RENAME TABLE'); - - } - $info = $new_info; - - if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test")) - printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test")) - printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - // Let's see if we have privileges for CREATE DATABASE - mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats"); - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - $info = $new_info; - - - // CREATE, ALTER, DROP DATABASE - if (mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats")) { - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE'); - $info = $new_info; - - if (!mysqli_query($link, "ALTER DATABASE DEFAULT CHARACTER SET latin1")) - printf("[%03d] ALTER DATABASE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE'); - $info = $new_info; - - if (!mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats_")) - printf("[%03d] CREATE DATABASE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - $info = $new_info; - - if (!mysqli_query($link, "DROP DATABASE mysqli_get_client_stats_")) - printf("[%03d] DROP DATABASE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP DATABASE'); - $info = $new_info; - } - - // CREATE SERVER, ALTER SERVER, DROP SERVER - // We don't really try to use federated, we just want to see if the syntax works - mysqli_query($link, "DROP SERVER IF EXISTS myself"); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - $info = $new_info; - - $sql = sprintf("CREATE SERVER myself FOREIGN DATA WRAPPER mysql OPTIONS (user '%s', password '%s', database '%s')", - $user, $passwd, $db); - if (mysqli_query($link, $sql)) { - // server knows about it - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE SERVER'); - $info = $new_info; - - if (!mysqli_query($link, sprintf("ALTER SERVER myself OPTIONS(user '%s_')", $user))) - printf("[%03d] ALTER SERVER failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER SERVER'); - $info = $new_info; - - if (!mysqli_query($link, "DROP SERVER myself")) - printf("[%03d] DROP SERVER failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP SERVER'); - $info = $new_info; - } - - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); - - /* - We don't test the NDB ones. - 13.1. Data Definition Statements - 13.1.3. ALTER LOGFILE GROUP Syntax - 13.1.4. ALTER TABLESPACE Syntax - 13.1.9. CREATE LOGFILE GROUP Syntax - 13.1.10. CREATE TABLESPACE Syntax - 13.1.15. DROP LOGFILE GROUP Syntax - 13.1.16. DROP TABLESPACE Syntax - */ - - // - // DML - // - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - $info = $new_info; - - if (!mysqli_query($link, "INSERT INTO test(id) VALUES (100)")) - printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'INSERT'); - $info = $new_info; - - if (!mysqli_query($link, "UPDATE test SET label ='z' WHERE id = 100")) - printf("[%03d] UPDATE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'UPDATE'); - $info = $new_info; - - if (!mysqli_query($link, "REPLACE INTO test(id, label) VALUES (100, 'b')")) - printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'REPLACE'); - $info = $new_info; - - // NOTE: this will NOT update dbl_ddls counter - if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100")) - printf("[%03d] SELECT@dml failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter, 'SELECT@dml'); - $info = $new_info; - - if (!mysqli_query($link, "DELETE FROM test WHERE id = 100")) - printf("[%03d] DELETE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DELETE'); - $info = $new_info; - - if (!$res = mysqli_query($link, "TRUNCATE TABLE test")) - printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'TRUNCATE'); - $info = $new_info; - - - $file = tempnam(sys_get_temp_dir(), 'mysqli_test'); - if ($fp = fopen($file, 'w')) { - @fwrite($fp, '1;"a"'); - fclose($fp); - chmod($file, 0644); - $sql = sprintf('LOAD DATA LOCAL INFILE "%s" INTO TABLE test', mysqli_real_escape_string($link, $file)); - if (mysqli_query($link, $sql)) { - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'LOAD DATA LOCAL'); - $info = $new_info; - } - unlink($file); - } - - mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); - - /* - We skip those: - 13.2. Data Manipulation Statements - 13.2.2. DO Syntax - 13.2.3. HANDLER Syntax - 13.2.5. LOAD DATA INFILE Syntax - */ - mysqli_query($link, "DELETE FROM test"); - if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b')")) - printf("[%03d] Cannot insert new records, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) - printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_use_result($link))) - printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - while ($row = mysqli_fetch_assoc($res)) - ; - mysqli_free_result($res); - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, (string)($info['unbuffered_sets'] + 1), $test_counter, 'mysqli_use_result()'); - $info = $new_info; - - if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) - printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_store_result($link))) - printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter, - mysqli_errno($link), mysqli_error($link)); - - while ($row = mysqli_fetch_assoc($res)) - ; - mysqli_free_result($res); - if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) - printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", - ++$test_counter, gettype($new_info), $new_info); - mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()'); - $info = $new_info; - - mysqli_close($link); - - mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); - $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; - mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); - - /* - no_index_used - bad_index_used - flushed_normal_sets - flushed_ps_sets - explicit_close - implicit_close - disconnect_close - in_middle_of_command_close - explicit_free_result - implicit_free_result - explicit_stmt_close - implicit_stmt_close - */ - - print "done!"; + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[%03d] bind_result failed, [%d] %s\n", + ++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + for ($i = 0; $i < $num_rows - 1; $i++) + mysqli_stmt_fetch($stmt); + + $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows - 1); + $expected['rows_fetched_from_client_ps_unbuffered'] = (string)($expected['rows_fetched_from_client_ps_unbuffered'] + $num_rows - 1); + $expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1); + $expected['ps_unbuffered_sets'] = (string)($expected['ps_unbuffered_sets'] + 1); + + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + + mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter); + $expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps']; + + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('ps_unbuffered_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter); + + mysqli_stmt_free_result($stmt); + $expected['rows_skipped_ps'] = (string)($expected['rows_skipped_ps'] + 1); + $expected['flushed_ps_sets'] = (string)($expected['flushed_ps_sets'] + 1); + $expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + 1); + + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); + + mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('flushed_ps_sets', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter); + + /* + print "Checking for normal buffered side effects...\n"; + foreach ($info as $k => $v) + if ($info[$k] != $expected[$k]) + printf("$k - $v != %s\n", $expected[$k]); + */ + print "... done with fetch statistics\n"; + + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); + + // + // result_set_queries statistics + // + + if (!is_array($info = mysqli_get_client_stats()) || empty($info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($info), $info); + + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) + printf("[%03d] SELECT failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + $rows = 0; + while ($row = mysqli_fetch_assoc($res)) + $rows++; + + if (0 == $rows) + printf("[%03d] Expecting at least one result, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + mysqli_free_result($res); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + + mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, (string)($info['result_set_queries'] + 1), $test_counter); + $info = $new_info; + + mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); + $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; + + // + // non_result_set_queries - DDL + // + + // CREATE TABLE, DROP TABLE + if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test")) + printf("[%03d] DROP TABLE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_query($link, "CREATE TABLE non_result_set_queries_test(id INT) ENGINE = " . $engine)) { + printf("[%03d] CREATE TABLE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + } else { + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'CREATE/DROP TABLE'); + } + $info = $new_info; + + // ALERT TABLE + if (!mysqli_query($link, "ALTER TABLE non_result_set_queries_test ADD label CHAR(1)")) { + printf("[%03d] ALTER TABLE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + } else { + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER TABLE'); + } + $info = $new_info; + + // CREATE INDEX, DROP INDEX + if (!mysqli_query($link, "CREATE INDEX idx_1 ON non_result_set_queries_test(id)")) { + printf("[%03d] CREATE INDEX failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + } else { + + if (!mysqli_query($link, "DROP INDEX idx_1 ON non_result_set_queries_test")) + printf("[%03d] DROP INDEX failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 2), $test_counter, 'DROP INDEX'); + } + $info = $new_info; + + // RENAME TABLE + if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test")) + printf("[%03d] Cleanup, DROP TABLE client_stats_test failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + $info = $new_info; + + if (!mysqli_query($link, "RENAME TABLE non_result_set_queries_test TO client_stats_test")) { + printf("[%03d] RENAME TABLE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + } else { + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'RENAME TABLE'); + + } + $info = $new_info; + + if (!mysqli_query($link, "DROP TABLE IF EXISTS non_result_set_queries_test")) + printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_query($link, "DROP TABLE IF EXISTS client_stats_test")) + printf("[%03d] Cleanup, DROP TABLE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + // Let's see if we have privileges for CREATE DATABASE + mysqli_query($link, "DROP DATABASE IF EXISTS mysqli_get_client_stats"); + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + $info = $new_info; + + + // CREATE, ALTER, DROP DATABASE + if (mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats")) { + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE'); + $info = $new_info; + + if (!mysqli_query($link, "ALTER DATABASE DEFAULT CHARACTER SET latin1")) + printf("[%03d] ALTER DATABASE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE DATABASE'); + $info = $new_info; + + if (!mysqli_query($link, "CREATE DATABASE mysqli_get_client_stats_")) + printf("[%03d] CREATE DATABASE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + $info = $new_info; + + if (!mysqli_query($link, "DROP DATABASE mysqli_get_client_stats_")) + printf("[%03d] DROP DATABASE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP DATABASE'); + $info = $new_info; + } + + // CREATE SERVER, ALTER SERVER, DROP SERVER + // We don't really try to use federated, we just want to see if the syntax works + mysqli_query($link, "DROP SERVER IF EXISTS myself"); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + $info = $new_info; + + $sql = sprintf("CREATE SERVER myself FOREIGN DATA WRAPPER mysql OPTIONS (user '%s', password '%s', database '%s')", + $user, $passwd, $db); + if (mysqli_query($link, $sql)) { + // server knows about it + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE SERVER'); + $info = $new_info; + + if (!mysqli_query($link, sprintf("ALTER SERVER myself OPTIONS(user '%s_')", $user))) + printf("[%03d] ALTER SERVER failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'ALTER SERVER'); + $info = $new_info; + + if (!mysqli_query($link, "DROP SERVER myself")) + printf("[%03d] DROP SERVER failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DROP SERVER'); + $info = $new_info; + } + + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); + + /* + We don't test the NDB ones. + 13.1. Data Definition Statements + 13.1.3. ALTER LOGFILE GROUP Syntax + 13.1.4. ALTER TABLESPACE Syntax + 13.1.9. CREATE LOGFILE GROUP Syntax + 13.1.10. CREATE TABLESPACE Syntax + 13.1.15. DROP LOGFILE GROUP Syntax + 13.1.16. DROP TABLESPACE Syntax + */ + + // + // DML + // + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + $info = $new_info; + + if (!mysqli_query($link, "INSERT INTO test(id) VALUES (100)")) + printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'INSERT'); + $info = $new_info; + + if (!mysqli_query($link, "UPDATE test SET label ='z' WHERE id = 100")) + printf("[%03d] UPDATE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'UPDATE'); + $info = $new_info; + + if (!mysqli_query($link, "REPLACE INTO test(id, label) VALUES (100, 'b')")) + printf("[%03d] INSERT failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'REPLACE'); + $info = $new_info; + + // NOTE: this will NOT update dbl_ddls counter + if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100")) + printf("[%03d] SELECT@dml failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, $info, $test_counter, 'SELECT@dml'); + $info = $new_info; + + if (!mysqli_query($link, "DELETE FROM test WHERE id = 100")) + printf("[%03d] DELETE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'DELETE'); + $info = $new_info; + + if (!$res = mysqli_query($link, "TRUNCATE TABLE test")) + printf("[%03d] TRUNCATE failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'TRUNCATE'); + $info = $new_info; + + + $file = tempnam(sys_get_temp_dir(), 'mysqli_test'); + if ($fp = fopen($file, 'w')) { + @fwrite($fp, '1;"a"'); + fclose($fp); + chmod($file, 0644); + $sql = sprintf('LOAD DATA LOCAL INFILE "%s" INTO TABLE test', mysqli_real_escape_string($link, $file)); + if (mysqli_query($link, $sql)) { + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'LOAD DATA LOCAL'); + $info = $new_info; + } + unlink($file); + } + + mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter); + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); + + /* + We skip those: + 13.2. Data Manipulation Statements + 13.2.2. DO Syntax + 13.2.3. HANDLER Syntax + 13.2.5. LOAD DATA INFILE Syntax + */ + mysqli_query($link, "DELETE FROM test"); + if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b')")) + printf("[%03d] Cannot insert new records, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) + printf("[%03d] Cannot SELECT with mysqli_real_query(), [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_use_result($link))) + printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + while ($row = mysqli_fetch_assoc($res)) + ; + mysqli_free_result($res); + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('unbuffered_sets', $new_info, (string)($info['unbuffered_sets'] + 1), $test_counter, 'mysqli_use_result()'); + $info = $new_info; + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) + printf("[%03d] Cannot SELECT with mysqli_real_query() II, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link))) + printf("[%03d] mysqli_use_result() failed, [%d] %s\n", ++$test_counter, + mysqli_errno($link), mysqli_error($link)); + + while ($row = mysqli_fetch_assoc($res)) + ; + mysqli_free_result($res); + if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info)) + printf("[%03d] Expecting array/any_non_empty, got %s/%s\n", + ++$test_counter, gettype($new_info), $new_info); + mysqli_get_client_stats_assert_eq('buffered_sets', $new_info, (string)($info['buffered_sets'] + 1), $test_counter, 'mysqli_use_result()'); + $info = $new_info; + + mysqli_close($link); + + mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter); + $expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal']; + mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter); + + /* + no_index_used + bad_index_used + flushed_normal_sets + flushed_ps_sets + explicit_close + implicit_close + disconnect_close + in_middle_of_command_close + explicit_free_result + implicit_free_result + explicit_stmt_close + implicit_stmt_close + */ + + print "done!"; ?> --CLEAN-- --CLEAN-- $v) - if ($v != 0) { - printf("[003] Field %s should not have any other value but 0, got %s.\n", - $k, $v); - } + foreach ($after as $k => $v) + if ($v != 0) { + printf("[003] Field %s should not have any other value but 0, got %s.\n", + $k, $v); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --CLEAN-- --FILE-- 2); - mysqli_free_result($res); + $num_rows = mysqli_num_rows($res); + assert($num_rows > 2); + mysqli_free_result($res); - $before = mysqli_get_client_stats(); - printf("BEFORE: rows_skipped_normal = %d\n", $before['rows_skipped_normal']); + $before = mysqli_get_client_stats(); + printf("BEFORE: rows_skipped_normal = %d\n", $before['rows_skipped_normal']); - if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) - printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - /* fetch all rows but the last one */ - for ($i = 0; $i < $num_rows - 1; $i++) - $row = mysqli_fetch_assoc($res); + /* fetch all rows but the last one */ + for ($i = 0; $i < $num_rows - 1; $i++) + $row = mysqli_fetch_assoc($res); - /* enforce implicit cleaning of the wire and skipping the last row */ - mysqli_free_result($res); - $after = mysqli_get_client_stats(); - printf("AFTER: rows_skipped_normal = %d\n", $after['rows_skipped_normal']); + /* enforce implicit cleaning of the wire and skipping the last row */ + mysqli_free_result($res); + $after = mysqli_get_client_stats(); + printf("AFTER: rows_skipped_normal = %d\n", $after['rows_skipped_normal']); - if ($after['rows_skipped_normal'] != $before['rows_skipped_normal'] + 1) - printf("Statistics should show an increase of 1 for rows_skipped_normal, ". - "but before=%d after=%d\n", $before['rows_skipped_normal'], $after['rows_skipped_normal']); + if ($after['rows_skipped_normal'] != $before['rows_skipped_normal'] + 1) + printf("Statistics should show an increase of 1 for rows_skipped_normal, ". + "but before=%d after=%d\n", $before['rows_skipped_normal'], $after['rows_skipped_normal']); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --EXPECTF-- BEFORE: rows_skipped_normal = %d diff --git a/ext/mysqli/tests/mysqli_get_client_version.phpt b/ext/mysqli/tests/mysqli_get_client_version.phpt index dbf5e3004a13..88e1e85e1560 100644 --- a/ext/mysqli/tests/mysqli_get_client_version.phpt +++ b/ext/mysqli/tests/mysqli_get_client_version.phpt @@ -5,10 +5,10 @@ mysqli_get_client_version() --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_connection_stats.phpt b/ext/mysqli/tests/mysqli_get_connection_stats.phpt index 45d09b1baf6d..8f1ffb52c9ee 100644 --- a/ext/mysqli/tests/mysqli_get_connection_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_connection_stats.phpt @@ -14,63 +14,63 @@ if (!function_exists('mysqli_get_connection_stats')) { ?> --FILE-- &$v) { - if (strpos($k, "mem_") === 0) { - $v = 0; - } - } - foreach ($info2 as $k => &$v) { - if (strpos($k, "mem_") === 0) { - $v = 0; - } - } + foreach ($info as $k => &$v) { + if (strpos($k, "mem_") === 0) { + $v = 0; + } + } + foreach ($info2 as $k => &$v) { + if (strpos($k, "mem_") === 0) { + $v = 0; + } + } - if ($info !== $info2) { - printf("[005] The hashes should be identical except of the memory related fields\n"); - var_dump($info); - var_dump($info2); - } + if ($info !== $info2) { + printf("[005] The hashes should be identical except of the memory related fields\n"); + var_dump($info); + var_dump($info2); + } - if (!is_array($info = $link->get_connection_stats()) || empty($info)) - printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); + if (!is_array($info = $link->get_connection_stats()) || empty($info)) + printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); - foreach ($info as $k => &$v) { - if (strpos($k, "mem_") === 0) { - $v = 0; - } - } + foreach ($info as $k => &$v) { + if (strpos($k, "mem_") === 0) { + $v = 0; + } + } - if ($info !== $info2) { - printf("[007] The hashes should be identical except of the memory related fields\n"); - var_dump($info); - var_dump($info2); - } + if ($info !== $info2) { + printf("[007] The hashes should be identical except of the memory related fields\n"); + var_dump($info); + var_dump($info2); + } - mysqli_close($link); - require("table.inc"); + mysqli_close($link); + require("table.inc"); - if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) - printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); + if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info)) + printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info); - if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) - printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); + if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2)) + printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2); - // assuming the test is run in a plain-vanilla CLI environment - if ($info === $info2) { - printf("[010] The hashes should not be identical\n"); - var_dump($info); - var_dump($info2); - } + // assuming the test is run in a plain-vanilla CLI environment + if ($info === $info2) { + printf("[010] The hashes should not be identical\n"); + var_dump($info); + var_dump($info2); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- $v) - if ($v != 0) { - printf("[004] Field %s should not have any other value but 0, got %s.\n", - $k, $v); - } + foreach ($after as $k => $v) + if ($v != 0) { + printf("[004] Field %s should not have any other value but 0, got %s.\n", + $k, $v); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_host_info.phpt b/ext/mysqli/tests/mysqli_get_host_info.phpt index 534765808b46..072ebc87ade2 100644 --- a/ext/mysqli/tests/mysqli_get_host_info.phpt +++ b/ext/mysqli/tests/mysqli_get_host_info.phpt @@ -8,18 +8,18 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_server_info.phpt b/ext/mysqli/tests/mysqli_get_server_info.phpt index 25278528a605..3a1e08e02902 100644 --- a/ext/mysqli/tests/mysqli_get_server_info.phpt +++ b/ext/mysqli/tests/mysqli_get_server_info.phpt @@ -8,13 +8,13 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --CLEAN-- --FILE-- 50105 -- major_version*10000 + minor_version *100 + sub_version */ - /* < 30000 = pre 3.2.3, very unlikely! */ - if (!is_int($info = mysqli_get_server_version($link)) || ($info < (3 * 10000))) - printf("[003] Expecting int/any >= 30000, got %s/%s\n", gettype($info), $info); + require "table.inc"; + /* 5.1.5 -> 50105 -- major_version*10000 + minor_version *100 + sub_version */ + /* < 30000 = pre 3.2.3, very unlikely! */ + if (!is_int($info = mysqli_get_server_version($link)) || ($info < (3 * 10000))) + printf("[003] Expecting int/any >= 30000, got %s/%s\n", gettype($info), $info); - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_get_warnings.phpt b/ext/mysqli/tests/mysqli_get_warnings.phpt index b0076c185903..20b2607f39df 100644 --- a/ext/mysqli/tests/mysqli_get_warnings.phpt +++ b/ext/mysqli/tests/mysqli_get_warnings.phpt @@ -11,135 +11,135 @@ if (!$TEST_EXPERIMENTAL) ?> --FILE-- message)) || ('' == $warning->message)) /* NULL or not there at all */ - printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message); + if ((!is_string($warning->message)) || ('' == $warning->message)) /* NULL or not there at all */ + printf("[011] Expecting string/not empty, got %s/%s\n", gettype($warning->message), $warning->message); - if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */ - printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate); + if ((!is_string($warning->sqlstate)) || ('' == $warning->sqlstate)) /* NULL or not there at all */ + printf("[012] Expecting string/not empty, got %s/%s\n", gettype($warning->sqlstate), $warning->sqlstate); - if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */ - printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno); + if ((!is_int($warning->errno)) || (0 == $warning->errno)) /* NULL or not there at all */ + printf("[013] Expecting int/not 0, got %s/%s\n", gettype($warning->errno), $warning->errno); - if (false !== ($tmp = $warning->next())) - printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $warning->next())) + printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)")) - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000), (1000001)")) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (($tmp = mysqli_warning_count($link)) !== 2) - printf("[016] Expecting 2 warnings, got %d warnings", $tmp); + if (($tmp = mysqli_warning_count($link)) !== 2) + printf("[016] Expecting 2 warnings, got %d warnings", $tmp); - if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { - printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); - } + if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) { + printf("[017] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); + } - if (true !== ($tmp = $warning->next())) - printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $warning->next())) + printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = $warning->next())) - printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = $warning->next())) + printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - mysqli_close($link); + mysqli_close($link); - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[021] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if (!$mysqli->query("DROP TABLE IF EXISTS t1")) - printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$mysqli->query("DROP TABLE IF EXISTS t1")) + printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_object($warning = new mysqli_warning($mysqli))) - printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); + if (!is_object($warning = new mysqli_warning($mysqli))) + printf("[024] Expecting object/mysqli_warning, got %s/%s", gettype($warning), $warning); - if (!is_string($warning->message) || ('' == $warning->message)) - printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message); + if (!is_string($warning->message) || ('' == $warning->message)) + printf("[025] Expecting string, got %s/%s", gettype($warning->message), $warning->message); - if (!$mysqli->query("DROP TABLE t1")) - printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$mysqli->query("DROP TABLE t1")) + printf("[026] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - /* Yes, I really want to check if the object property is empty */ - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + /* Yes, I really want to check if the object property is empty */ + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[027] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $warning = new mysqli_warning($mysqli); - if (false !== ($tmp = $warning->next())) - printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + $warning = new mysqli_warning($mysqli); + if (false !== ($tmp = $warning->next())) + printf("[028] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if ('' != ($tmp = $warning->message)) - printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); + if ('' != ($tmp = $warning->message)) + printf("[029] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp); - if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[030] Cannot create mysqli object: [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if (!$mysqli->query("DROP TABLE IF EXISTS t1")) - printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$mysqli->query("DROP TABLE IF EXISTS t1")) + printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) - printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$mysqli->query("CREATE TABLE t1 (a smallint)")) + printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - /* out of range, three warnings */ - if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)")) - printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + /* out of range, three warnings */ + if (!$mysqli->query("INSERT IGNORE INTO t1(a) VALUES (65536), (65536), (65536)")) + printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $warning = new mysqli_warning($mysqli); - $i = 1; - while ($warning->next() && ('' != ($tmp = $warning->message))) { - $i++; - } - if (3 != $i) - printf("[034] Expecting three warnings, got %d warnings\n", $i); + $warning = new mysqli_warning($mysqli); + $i = 1; + while ($warning->next() && ('' != ($tmp = $warning->message))) { + $i++; + } + if (3 != $i) + printf("[034] Expecting three warnings, got %d warnings\n", $i); - $stmt = mysqli_stmt_init(); - $warning = new mysqli_warning($stmt); - if (false !== ($tmp = $warning->next())) - printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + $stmt = mysqli_stmt_init(); + $warning = new mysqli_warning($stmt); + if (false !== ($tmp = $warning->next())) + printf("[035] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> diff --git a/ext/mysqli/tests/mysqli_info.phpt b/ext/mysqli/tests/mysqli_info.phpt index b3a090b6e81e..e0736701ac4a 100644 --- a/ext/mysqli/tests/mysqli_info.phpt +++ b/ext/mysqli/tests/mysqli_info.phpt @@ -10,81 +10,81 @@ require_once('skipifconnectfailure.inc'); mysqli.allow_local_infile=1 --FILE-- = 100")) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "UPDATE test SET label = 'b' WHERE id >= 100")) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) - printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); + if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) + printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); - if (!$res = mysqli_query($link, "SELECT 1")) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "SELECT 1")) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp)) - printf("[014] Expecting null, got %s/%s\n", gettype($tmp), $tmp); - mysqli_free_result($res); + if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp)) + printf("[014] Expecting null, got %s/%s\n", gettype($tmp), $tmp); + mysqli_free_result($res); - // NOTE: no LOAD DATA INFILE test - if ($dir = sys_get_temp_dir()) { - do { - $file = $dir . '/' . 'mysqli_info_phpt.cvs'; - if (!$fp = fopen($file, 'w')) - /* ignore this error */ - break; + // NOTE: no LOAD DATA INFILE test + if ($dir = sys_get_temp_dir()) { + do { + $file = $dir . '/' . 'mysqli_info_phpt.cvs'; + if (!$fp = fopen($file, 'w')) + /* ignore this error */ + break; - if (!fwrite($fp, "100;'a';\n") || - !fwrite($fp, "101;'b';\n") || - !fwrite($fp, "102;'c';\n")) { - @unlink($file); - break; - } - fclose($fp); - if (!mysqli_query($link, "DELETE FROM test")) { - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } + if (!fwrite($fp, "100;'a';\n") || + !fwrite($fp, "101;'b';\n") || + !fwrite($fp, "102;'c';\n")) { + @unlink($file); + break; + } + fclose($fp); + if (!mysqli_query($link, "DELETE FROM test")) { + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } - if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) { - /* ok, because we might not be allowed to do this */ - @unlink($file); - break; - } + if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) { + /* ok, because we might not be allowed to do this */ + @unlink($file); + break; + } - if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) - printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); + if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp)) + printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp); - unlink($file); - } while (false); - } + unlink($file); + } while (false); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_insert_id.phpt b/ext/mysqli/tests/mysqli_insert_id.phpt index ba93ba41cadd..a9fc31998dcb 100644 --- a/ext/mysqli/tests/mysqli_insert_id.phpt +++ b/ext/mysqli/tests/mysqli_insert_id.phpt @@ -8,114 +8,114 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- 0, got %s/%s\n", gettype($last_id), $last_id); - - if (mysqli_query($link, "LOCK TABLE test WRITE")) { - /* we need exclusive access for a moment */ - /* let's hope nobody changes auto_increment_increment while this code executes */ - do { - if (mysqli_get_server_version($link) >= 50000) { - if (!$res = mysqli_query($link, 'SELECT @@auto_increment_increment AS inc')) { - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - if (!$row = mysqli_fetch_assoc($res)) { - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - mysqli_free_result($res); - $inc = $row['inc']; - } else { - $inc = 1; - } - - if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('b')")) { - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - if (($next_id = mysqli_insert_id($link)) <= $last_id) - /* - very likely a bug, but someone could have done something on the server - between the second last insert and the lock, therefore don't stop just bail - */ - printf("[014] Expecting int/any > %d, got %s/%s\n", $last_id, gettype($next_id), $next_id); - - $last_id = $next_id; - if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('c'), ('d'), ('e')")) { - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - /* - Note: For a multiple-row insert, LAST_INSERT_ID() and mysql_insert_id() actually - return the AUTO_INCREMENT key from the first of the inserted rows. This allows - multiple-row inserts to be reproduced correctly on other servers in a replication setup. - */ - if (($next_id = mysqli_insert_id($link)) != $last_id + $inc) { - printf("[016] Expecting int/%d, got %s/%s\n", $last_id + 1, gettype($next_id), $next_id); - break; - } - - if (!$res = mysqli_query($link, "SELECT LAST_INSERT_ID() AS last_id")) { - printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - if (!$row = mysqli_fetch_assoc($res)) { - printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - mysqli_free_result($res); - - if ($next_id != $row['last_id']) { - printf("[019] Something is wrong, check manually. Expecting %s got %s.\n", - $next_id, $row['last_id']); - break; - } - } while (false); - mysqli_query($link, "UNLOCK TABLE test"); - } - - if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (1000, 'a')")) { - printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - if (1000 !== ($tmp = mysqli_insert_id($link))) - printf("[021] Expecting int/1000, got %s/%s\n", gettype($tmp), $tmp); - - if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('b'), ('c')")) { - printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - if (1000 >= ($tmp = mysqli_insert_id($link))) - printf("[023] Expecting int/>1000, got %s/%s\n", gettype($tmp), $tmp); - - mysqli_close($link); + require_once("connect.inc"); + + require('table.inc'); + + if (0 !== ($tmp = mysqli_insert_id($link))) + printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + + if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1")) { + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (0 !== ($tmp = mysqli_insert_id($link))) + printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + mysqli_free_result($res); + + // no auto_increment column + if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')")) { + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (0 !== ($tmp = mysqli_insert_id($link))) + printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + + if (!$res = mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT")) { + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('a')")) { + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (($last_id = mysqli_insert_id($link)) <= 0) + printf("[010] Expecting int/any >0, got %s/%s\n", gettype($last_id), $last_id); + + if (mysqli_query($link, "LOCK TABLE test WRITE")) { + /* we need exclusive access for a moment */ + /* let's hope nobody changes auto_increment_increment while this code executes */ + do { + if (mysqli_get_server_version($link) >= 50000) { + if (!$res = mysqli_query($link, 'SELECT @@auto_increment_increment AS inc')) { + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + mysqli_free_result($res); + $inc = $row['inc']; + } else { + $inc = 1; + } + + if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('b')")) { + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + if (($next_id = mysqli_insert_id($link)) <= $last_id) + /* + very likely a bug, but someone could have done something on the server + between the second last insert and the lock, therefore don't stop just bail + */ + printf("[014] Expecting int/any > %d, got %s/%s\n", $last_id, gettype($next_id), $next_id); + + $last_id = $next_id; + if (!mysqli_query($link, "INSERT INTO test(label) VALUES ('c'), ('d'), ('e')")) { + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + /* + Note: For a multiple-row insert, LAST_INSERT_ID() and mysql_insert_id() actually + return the AUTO_INCREMENT key from the first of the inserted rows. This allows + multiple-row inserts to be reproduced correctly on other servers in a replication setup. + */ + if (($next_id = mysqli_insert_id($link)) != $last_id + $inc) { + printf("[016] Expecting int/%d, got %s/%s\n", $last_id + 1, gettype($next_id), $next_id); + break; + } + + if (!$res = mysqli_query($link, "SELECT LAST_INSERT_ID() AS last_id")) { + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + mysqli_free_result($res); + + if ($next_id != $row['last_id']) { + printf("[019] Something is wrong, check manually. Expecting %s got %s.\n", + $next_id, $row['last_id']); + break; + } + } while (false); + mysqli_query($link, "UNLOCK TABLE test"); + } + + if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (1000, 'a')")) { + printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (1000 !== ($tmp = mysqli_insert_id($link))) + printf("[021] Expecting int/1000, got %s/%s\n", gettype($tmp), $tmp); + + if (!$res = mysqli_query($link, "INSERT INTO test(label) VALUES ('b'), ('c')")) { + printf("[022] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + if (1000 >= ($tmp = mysqli_insert_id($link))) + printf("[023] Expecting int/>1000, got %s/%s\n", gettype($tmp), $tmp); + + mysqli_close($link); try { mysqli_insert_id($link); @@ -123,7 +123,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --CLEAN-- --FILE-- info != 'Records: 6 Duplicates: 0 Warnings: 0') { - printf("[008] mysqlnd used to be more verbose and used to support SELECT\n"); - } - } else { - if ($link->info != NULL) { - printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n"); - } - } + var_dump($error = mysqli_error($link)); + if (!is_string($error) || ('' === $error)) + printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); + var_dump($res); + var_dump($link); + if ($IS_MYSQLND) { + if ($link->info != 'Records: 6 Duplicates: 0 Warnings: 0') { + printf("[008] mysqlnd used to be more verbose and used to support SELECT\n"); + } + } else { + if ($link->info != NULL) { + printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n"); + } + } - mysqli_close($link); + mysqli_close($link); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - mysqli_kill($link, -1); - if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || - (!$tmp = mysqli_fetch_assoc($res))) { - printf("[011] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - var_dump($tmp); - mysqli_free_result($res); - mysqli_close($link); + mysqli_kill($link, -1); + if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || + (!$tmp = mysqli_fetch_assoc($res))) { + printf("[011] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + var_dump($tmp); + mysqli_free_result($res); + mysqli_close($link); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[012] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[012] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); + mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT LAST_INSERT_ID() AS _id"))) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - return NULL; - } - $row = $res->fetch_assoc(); - $res->close(); - - return $row['_id']; - } - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - if (!$link->query("DROP TABLE IF EXISTS test") || - !$link->query("CREATE TABLE test (id INT auto_increment, label varchar(10) not null, PRIMARY KEY (id)) ENGINE=MyISAM") || - !$link->query("INSERT INTO test (id, label) VALUES (null, 'a')")) { - printf("[002] [%d] %s\n", $link->errno, $link->error); - } - - $api_id = $link->insert_id; - $sql_id = get_sql_id($link); - printf("API: %d, SQL: %d\n", $api_id, $sql_id); - - if ($api_id < 1) - printf("[004] Expecting id > 0 got %d, [%d] %s\n", $api_id, $link->errno, $link->error) ; - if ($api_id != $sql_id) - printf("[005] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); - - // Not an INSERT, API value must become 0 - if (!($res = $link->query("SELECT 1 FROM DUAL"))) - printf("[006] [%d] %s\n", $link->errno, $link->error); - else - $res->close(); - - $api_id = $link->insert_id; - $new_sql_id = get_sql_id($link); - if (0 !== $api_id) { - printf("[007] API id should have been reset to 0 because previous query was SELECT, got API %d, SQL %d\n", - $api_id, $new_sql_id); - } - if ($new_sql_id != $sql_id) { - printf("[008] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); - } - - // Insert fails, LAST_INSERT_ID shall not change, API shall return 0 - if ($link->query("INSERT INTO test (id, label) VALUES (null, null)")) { - printf("[009] The INSERT did not fail as planned, [%d] %s\n", $link->errno, $link->error); - } - $api_id = $link->insert_id; - $new_sql_id = get_sql_id($link); - - if (0 !== $api_id) { - printf("[010] API id should have been reset to 0 because previous query was SELECT, got API %d, SQL %d\n", - $api_id, $new_sql_id); - } - if ($new_sql_id != $sql_id) { - printf("[011] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); - } - - // Sequence counter pattern... - if (!$link->query("UPDATE test SET id=LAST_INSERT_ID(id+1)")) - printf("[012] [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $new_sql_id = get_sql_id($link); - if ($api_id < 1) - printf("[013] Expecting id > 0 got %d, [%d] %s\n", $api_id, $link->errno, $link->error) ; - if ($api_id != $new_sql_id) - printf("[014] SQL id %d should be equal to API id %d\n", $new_sql_id, $api_id); - if ($sql_id == $new_sql_id) - printf("[015] SQL id %d should have had changed, got %d\n", $sql_id, $new_sql_id); - - $sql_id = $new_sql_id; - - // Not an INSERT (after UPDATE), API value must become 0 - if (!$link->query("SET @myvar=1")) - printf("[016] [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $new_sql_id = get_sql_id($link); - if (0 !== $api_id) { - printf("[017] API id should have been reset to 0 because previous query was SET, got API %d, SQL %d\n", - $api_id, $new_sql_id); - } - if ($new_sql_id != $sql_id) { - printf("[018] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); - } - - if (!$link->query("INSERT INTO test(id, label) VALUES (LAST_INSERT_ID(id + 1), 'b')")) - printf("[019] [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $sql_id = get_sql_id($link); - if ($api_id != $sql_id) - printf("[020] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); - - if (!$link->query("INSERT INTO test(label) VALUES ('c')")) - printf("[021] [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $sql_id = get_sql_id($link); - if ($api_id != $sql_id) - printf("[022] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); - - if (!($res = $link->query("SELECT id, label FROM test ORDER BY id ASC"))) - printf("[023] [%d] %s\n", $link->errno, $link->error); - - printf("Dumping table contents before INSERT...SELECT experiments...\n"); - while ($row = $res->fetch_assoc()) { - printf("id = %d, label = '%s'\n", $row['id'], $row['label']); - } - $res->close(); - - if (!$link->query("INSERT INTO test(label) SELECT CONCAT(label, id) FROM test ORDER BY id ASC")) - printf("[024] [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $sql_id = get_sql_id($link); - if ($api_id != $sql_id) - printf("[025] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); - - if ($link->query("INSERT INTO test(id, label) SELECT id, CONCAT(label, id) FROM test ORDER BY id ASC")) - printf("[026] INSERT should have failed because of duplicate PK value, [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $new_sql_id = get_sql_id($link); - if (0 !== $api_id) { - printf("[027] API id should have been reset to 0 because previous query failed, got API %d, SQL %d\n", - $api_id, $new_sql_id); - } - if ($new_sql_id != $sql_id) { - printf("[028] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); - } - - /* API insert id will be 101 because of UPDATE, SQL unchanged */ - if (!$link->query(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z') ON DUPLICATE KEY UPDATE id = 101", $sql_id) )) - printf("[029] [%d] %s\n", $link->errno, $link->error); - - $api_id = $link->insert_id; - $new_sql_id = get_sql_id($link); - if ($api_id != 101) - printf("[030] API id should be %d got %d\n", $sql_id, $api_id); - if ($new_sql_id != $sql_id) { - printf("[031] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); - } - - if (!($res = $link->query("SELECT id, label FROM test ORDER BY id ASC"))) - printf("[032] [%d] %s\n", $link->errno, $link->error); - - printf("Dumping table contents after INSERT...SELECT...\n"); - while ($row = $res->fetch_assoc()) { - printf("id = %d, label = '%s'\n", $row['id'], $row['label']); - } - $res->close(); - - print "done!"; + /* + CAUTION: the insert_id() API call is not supposed to return + the same value as a call to the LAST_INSERT_ID() SQL function. + It is not necessarily a bug if API and SQL function return different + values. Check the MySQL C API reference manual for details. + */ + require_once("connect.inc"); + + function get_sql_id($link) { + if (!($res = $link->query("SELECT LAST_INSERT_ID() AS _id"))) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + return NULL; + } + $row = $res->fetch_assoc(); + $res->close(); + + return $row['_id']; + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!$link->query("DROP TABLE IF EXISTS test") || + !$link->query("CREATE TABLE test (id INT auto_increment, label varchar(10) not null, PRIMARY KEY (id)) ENGINE=MyISAM") || + !$link->query("INSERT INTO test (id, label) VALUES (null, 'a')")) { + printf("[002] [%d] %s\n", $link->errno, $link->error); + } + + $api_id = $link->insert_id; + $sql_id = get_sql_id($link); + printf("API: %d, SQL: %d\n", $api_id, $sql_id); + + if ($api_id < 1) + printf("[004] Expecting id > 0 got %d, [%d] %s\n", $api_id, $link->errno, $link->error) ; + if ($api_id != $sql_id) + printf("[005] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); + + // Not an INSERT, API value must become 0 + if (!($res = $link->query("SELECT 1 FROM DUAL"))) + printf("[006] [%d] %s\n", $link->errno, $link->error); + else + $res->close(); + + $api_id = $link->insert_id; + $new_sql_id = get_sql_id($link); + if (0 !== $api_id) { + printf("[007] API id should have been reset to 0 because previous query was SELECT, got API %d, SQL %d\n", + $api_id, $new_sql_id); + } + if ($new_sql_id != $sql_id) { + printf("[008] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); + } + + // Insert fails, LAST_INSERT_ID shall not change, API shall return 0 + if ($link->query("INSERT INTO test (id, label) VALUES (null, null)")) { + printf("[009] The INSERT did not fail as planned, [%d] %s\n", $link->errno, $link->error); + } + $api_id = $link->insert_id; + $new_sql_id = get_sql_id($link); + + if (0 !== $api_id) { + printf("[010] API id should have been reset to 0 because previous query was SELECT, got API %d, SQL %d\n", + $api_id, $new_sql_id); + } + if ($new_sql_id != $sql_id) { + printf("[011] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); + } + + // Sequence counter pattern... + if (!$link->query("UPDATE test SET id=LAST_INSERT_ID(id+1)")) + printf("[012] [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $new_sql_id = get_sql_id($link); + if ($api_id < 1) + printf("[013] Expecting id > 0 got %d, [%d] %s\n", $api_id, $link->errno, $link->error) ; + if ($api_id != $new_sql_id) + printf("[014] SQL id %d should be equal to API id %d\n", $new_sql_id, $api_id); + if ($sql_id == $new_sql_id) + printf("[015] SQL id %d should have had changed, got %d\n", $sql_id, $new_sql_id); + + $sql_id = $new_sql_id; + + // Not an INSERT (after UPDATE), API value must become 0 + if (!$link->query("SET @myvar=1")) + printf("[016] [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $new_sql_id = get_sql_id($link); + if (0 !== $api_id) { + printf("[017] API id should have been reset to 0 because previous query was SET, got API %d, SQL %d\n", + $api_id, $new_sql_id); + } + if ($new_sql_id != $sql_id) { + printf("[018] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); + } + + if (!$link->query("INSERT INTO test(id, label) VALUES (LAST_INSERT_ID(id + 1), 'b')")) + printf("[019] [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $sql_id = get_sql_id($link); + if ($api_id != $sql_id) + printf("[020] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); + + if (!$link->query("INSERT INTO test(label) VALUES ('c')")) + printf("[021] [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $sql_id = get_sql_id($link); + if ($api_id != $sql_id) + printf("[022] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); + + if (!($res = $link->query("SELECT id, label FROM test ORDER BY id ASC"))) + printf("[023] [%d] %s\n", $link->errno, $link->error); + + printf("Dumping table contents before INSERT...SELECT experiments...\n"); + while ($row = $res->fetch_assoc()) { + printf("id = %d, label = '%s'\n", $row['id'], $row['label']); + } + $res->close(); + + if (!$link->query("INSERT INTO test(label) SELECT CONCAT(label, id) FROM test ORDER BY id ASC")) + printf("[024] [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $sql_id = get_sql_id($link); + if ($api_id != $sql_id) + printf("[025] SQL id %d should be equal to API id %d\n", $sql_id, $api_id); + + if ($link->query("INSERT INTO test(id, label) SELECT id, CONCAT(label, id) FROM test ORDER BY id ASC")) + printf("[026] INSERT should have failed because of duplicate PK value, [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $new_sql_id = get_sql_id($link); + if (0 !== $api_id) { + printf("[027] API id should have been reset to 0 because previous query failed, got API %d, SQL %d\n", + $api_id, $new_sql_id); + } + if ($new_sql_id != $sql_id) { + printf("[028] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); + } + + /* API insert id will be 101 because of UPDATE, SQL unchanged */ + if (!$link->query(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z') ON DUPLICATE KEY UPDATE id = 101", $sql_id) )) + printf("[029] [%d] %s\n", $link->errno, $link->error); + + $api_id = $link->insert_id; + $new_sql_id = get_sql_id($link); + if ($api_id != 101) + printf("[030] API id should be %d got %d\n", $sql_id, $api_id); + if ($new_sql_id != $sql_id) { + printf("[031] The servers LAST_INSERT_ID() changed unexpectedly from %d to %d\n", $sql_id, $new_sql_id); + } + + if (!($res = $link->query("SELECT id, label FROM test ORDER BY id ASC"))) + printf("[032] [%d] %s\n", $link->errno, $link->error); + + printf("Dumping table contents after INSERT...SELECT...\n"); + while ($row = $res->fetch_assoc()) { + printf("id = %d, label = '%s'\n", $row['id'], $row['label']); + } + $res->close(); + + print "done!"; ?> --CLEAN-- --CLEAN-- --FILE-- 41000 && !($ret = mysqli_more_results($link))) - printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); - do { - $res = mysqli_store_result($link); - mysqli_free_result($res); - if (mysqli_more_results($link)) - printf("%d\n", $i++); - } while (mysqli_next_result($link)); + if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) + printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); + do { + $res = mysqli_store_result($link); + mysqli_free_result($res); + if (mysqli_more_results($link)) + printf("%d\n", $i++); + } while (mysqli_next_result($link)); - if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - print "[010]\n"; - $i = 1; - if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) - printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); + if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3")) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + print "[010]\n"; + $i = 1; + if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link))) + printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret); - do { - $res = mysqli_use_result($link); - // NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function, - // you must fetch all rows before you can loop to the next result set! - // See also the MySQL Reference Manual: mysql_use_result() - while ($row = mysqli_fetch_array($res)) - ; - mysqli_free_result($res); - if (mysqli_more_results($link)) - printf("%d\n", $i++); - } while (mysqli_next_result($link)); + do { + $res = mysqli_use_result($link); + // NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function, + // you must fetch all rows before you can loop to the next result set! + // See also the MySQL Reference Manual: mysql_use_result() + while ($row = mysqli_fetch_array($res)) + ; + mysqli_free_result($res); + if (mysqli_more_results($link)) + printf("%d\n", $i++); + } while (mysqli_next_result($link)); - mysqli_close($link); + mysqli_close($link); try { mysqli_more_results($link); @@ -56,7 +56,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- $length) - if ($length <= 0) - printf("[017 - %d] Strange column lengths for column %d, got %d expecting any > 0\n", - $res_num, $k, $length); - } - } + foreach ($lengths as $k => $length) + if ($length <= 0) + printf("[017 - %d] Strange column lengths for column %d, got %d expecting any > 0\n", + $res_num, $k, $length); + } + } - if ($num_rows != 1) - printf("[018 - %d] Expecting 1 row, got %d rows\n", $num_rows); + if ($num_rows != 1) + printf("[018 - %d] Expecting 1 row, got %d rows\n", $num_rows); - $res_num++; + $res_num++; - mysqli_free_result($res); + mysqli_free_result($res); - } while (mysqli_next_result($link)); + } while (mysqli_next_result($link)); - if ($res_num != 4) - printf("[015] Expecting 3 result sets got %d result set[s]\n", $res_num); + if ($res_num != 4) + printf("[015] Expecting 3 result sets got %d result set[s]\n", $res_num); - mysqli_close($link); + mysqli_close($link); try { mysqli_multi_query($link, "SELECT id, label FROM test"); @@ -108,7 +108,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --EXPECT-- [002] [2006] MySQL server has gone away diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt index 7b69aff6173c..3825cd6bd8e6 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_long.phpt @@ -23,22 +23,22 @@ mysqlnd.net_read_timeout=12 max_execution_time=12 --FILE-- fetch_assoc()); + var_dump($res->fetch_assoc()); - mysqli_free_result($res); - mysqli_close($link); + mysqli_free_result($res); + mysqli_close($link); - print "done!"; + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt index df273c4f14ff..9d1e31657380 100644 --- a/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt +++ b/ext/mysqli/tests/mysqli_mysqlnd_read_timeout_zero.phpt @@ -23,21 +23,21 @@ max_execution_time=10 mysqlnd.net_read_timeout=0 --FILE-- fetch_assoc()); + var_dump($res->fetch_assoc()); - mysqli_free_result($res); - mysqli_close($link); + mysqli_free_result($res); + mysqli_close($link); - print "done!"; + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_next_result.phpt b/ext/mysqli/tests/mysqli_next_result.phpt index 36ab5959dce0..22e13f4e3f0e 100644 --- a/ext/mysqli/tests/mysqli_next_result.phpt +++ b/ext/mysqli/tests/mysqli_next_result.phpt @@ -8,52 +8,52 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- = 100; SELECT 1 AS a; ", 11, 1); + func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3); + func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2); + func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1); - mysqli_close($link); + mysqli_close($link); try { mysqli_next_result($link); @@ -61,7 +61,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_num_fields.phpt b/ext/mysqli/tests/mysqli_num_fields.phpt index 610d311db65e..df2161f68538 100644 --- a/ext/mysqli/tests/mysqli_num_fields.phpt +++ b/ext/mysqli/tests/mysqli_num_fields.phpt @@ -8,39 +8,39 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - } + } - func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5); - func_test_mysqli_num_fields($link, "SELECT id, label FROM test", 2, 10); - func_test_mysqli_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); - func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20, true); + func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5); + func_test_mysqli_num_fields($link, "SELECT id, label FROM test", 2, 10); + func_test_mysqli_num_fields($link, "SELECT 1 AS a, NULL AS b, 'foo' AS c", 3, 15); + func_test_mysqli_num_fields($link, "SELECT id FROM test", 1, 20, true); - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - } - } + } + } - func_test_mysqli_num_rows($link, "SELECT 1 AS a", 1, 5); - func_test_mysqli_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10); - func_test_mysqli_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", NULL, 15); - func_test_mysqli_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true); + func_test_mysqli_num_rows($link, "SELECT 1 AS a", 1, 5); + func_test_mysqli_num_rows($link, "SHOW VARIABLES LIKE '%nixnutz%'", 0, 10); + func_test_mysqli_num_rows($link, "INSERT INTO test(id, label) VALUES (100, 'z')", NULL, 15); + func_test_mysqli_num_rows($link, "SELECT id FROM test LIMIT 2", 2, 20, true); - if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) { + if ($res = mysqli_query($link, 'SELECT COUNT(id) AS num FROM test')) { - $row = mysqli_fetch_assoc($res); - mysqli_free_result($res); + $row = mysqli_fetch_assoc($res); + mysqli_free_result($res); - func_test_mysqli_num_rows($link, "SELECT id, label FROM test", (int)$row['num'], 25); + func_test_mysqli_num_rows($link, "SELECT id, label FROM test", (int)$row['num'], 25); - } else { - printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + } else { + printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; + print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; - if ($res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) { + if ($res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) { - $row = mysqli_fetch_row($res); - if (0 !== ($tmp = mysqli_num_rows($res))) - printf("[031] Expecting int/0, got %s/%d\n", gettype($tmp), $tmp); + $row = mysqli_fetch_row($res); + if (0 !== ($tmp = mysqli_num_rows($res))) + printf("[031] Expecting int/0, got %s/%d\n", gettype($tmp), $tmp); - mysqli_free_result($res); - } else { - printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + mysqli_free_result($res); + } else { + printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --EXPECTF-- object(mysqli)#%d (%d) { diff --git a/ext/mysqli/tests/mysqli_options.phpt b/ext/mysqli/tests/mysqli_options.phpt index 9894cf5a292a..bec663a64a72 100644 --- a/ext/mysqli/tests/mysqli_options.phpt +++ b/ext/mysqli/tests/mysqli_options.phpt @@ -8,94 +8,94 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- "MYSQLI_READ_DEFAULT_GROUP", - MYSQLI_READ_DEFAULT_FILE => "MYSQLI_READ_DEFAULT_FILE", - MYSQLI_OPT_CONNECT_TIMEOUT => "MYSQLI_OPT_CONNECT_TIMEOUT", - MYSQLI_OPT_LOCAL_INFILE => "MYSQLI_OPT_LOCAL_INFILE", - MYSQLI_INIT_COMMAND => "MYSQLI_INIT_COMMAND", - MYSQLI_SET_CHARSET_NAME => "MYSQLI_SET_CHARSET_NAME", - MYSQLI_OPT_SSL_VERIFY_SERVER_CERT => "MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", - ); - - if ($IS_MYSQLND && defined('MYSQLI_OPT_NET_CMD_BUFFER_SIZE')) - $valid_options[] = constant('MYSQLI_OPT_NET_CMD_BUFFER_SIZE'); - if ($IS_MYSQLND && defined('MYSQLI_OPT_NET_READ_BUFFER_SIZE')) - $valid_options[] = constant('MYSQLI_OPT_NET_READ_BUFFER_SIZE'); - if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) - $valid_options[] = constant('MYSQLI_OPT_INT_AND_FLOAT_NATIVE'); - - $link = mysqli_init(); - - /* set it twice, checking if memory for the previous one is correctly freed */ - mysqli_options($link, MYSQLI_SET_CHARSET_NAME, "utf8"); - mysqli_options($link, MYSQLI_SET_CHARSET_NAME, "latin1"); - - // print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; - var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); - var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); - var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); - var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); - var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, array('SET AUTOCOMMIT=0', 'SET AUTOCOMMIT=1'))); - - if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - if (!$res = mysqli_query($link2, 'SELECT version() AS server_version')) - printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); - $tmp = mysqli_fetch_assoc($res); - mysqli_free_result($res); - $version = explode('.', $tmp['server_version']); - if (empty($version)) - printf("[008] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); - - if ($version[0] <= 4 && $version[1] < 1) - printf("[009] Need MySQL Server 4.1+ for the test!\n"); - - if (!$res = mysqli_query($link2, "SHOW CHARACTER SET")) - printf("[010] Cannot get list of available character sets, [%d] %s\n", - mysqli_errno($link2), mysqli_error($link2)); - - $charsets = array(); - while ($row = mysqli_fetch_assoc($res)) - $charsets[] = $row; - mysqli_free_result($res); - mysqli_close($link2); - - foreach ($charsets as $charset) { - $k = $charset['Charset']; - /* The server currently 17.07.2007 can't handle data sent in ucs2 */ - /* The server currently 16.08.2010 can't handle data sent in utf16 and utf32 */ - if ($charset['Charset'] == 'ucs2' || $charset['Charset'] == 'utf16' || $charset['Charset'] == 'utf32') { - continue; - } - if (true !== mysqli_options($link, MYSQLI_SET_CHARSET_NAME, $charset['Charset'])) { - printf("[009] Setting charset name '%s' has failed\n", $charset['Charset']); - } - } - - var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); - var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); - var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); - var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); - var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); - - /* mysqli_real_connect() */ - var_dump("MYSQLI_CLIENT_SSL", mysqli_options($link, MYSQLI_CLIENT_SSL, 'not a mysqli_option')); - - mysqli_close($link); - - echo "Link closed\n"; - try { + require_once("connect.inc"); + + $valid_options = array( + MYSQLI_READ_DEFAULT_GROUP => "MYSQLI_READ_DEFAULT_GROUP", + MYSQLI_READ_DEFAULT_FILE => "MYSQLI_READ_DEFAULT_FILE", + MYSQLI_OPT_CONNECT_TIMEOUT => "MYSQLI_OPT_CONNECT_TIMEOUT", + MYSQLI_OPT_LOCAL_INFILE => "MYSQLI_OPT_LOCAL_INFILE", + MYSQLI_INIT_COMMAND => "MYSQLI_INIT_COMMAND", + MYSQLI_SET_CHARSET_NAME => "MYSQLI_SET_CHARSET_NAME", + MYSQLI_OPT_SSL_VERIFY_SERVER_CERT => "MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", + ); + + if ($IS_MYSQLND && defined('MYSQLI_OPT_NET_CMD_BUFFER_SIZE')) + $valid_options[] = constant('MYSQLI_OPT_NET_CMD_BUFFER_SIZE'); + if ($IS_MYSQLND && defined('MYSQLI_OPT_NET_READ_BUFFER_SIZE')) + $valid_options[] = constant('MYSQLI_OPT_NET_READ_BUFFER_SIZE'); + if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) + $valid_options[] = constant('MYSQLI_OPT_INT_AND_FLOAT_NATIVE'); + + $link = mysqli_init(); + + /* set it twice, checking if memory for the previous one is correctly freed */ + mysqli_options($link, MYSQLI_SET_CHARSET_NAME, "utf8"); + mysqli_options($link, MYSQLI_SET_CHARSET_NAME, "latin1"); + + // print "run_tests.php don't fool me with your 'ungreedy' expression '.+?'!\n"; + var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); + var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); + var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); + var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); + var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, array('SET AUTOCOMMIT=0', 'SET AUTOCOMMIT=1'))); + + if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!$res = mysqli_query($link2, 'SELECT version() AS server_version')) + printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + $tmp = mysqli_fetch_assoc($res); + mysqli_free_result($res); + $version = explode('.', $tmp['server_version']); + if (empty($version)) + printf("[008] Cannot determine server version, need MySQL Server 4.1+ for the test!\n"); + + if ($version[0] <= 4 && $version[1] < 1) + printf("[009] Need MySQL Server 4.1+ for the test!\n"); + + if (!$res = mysqli_query($link2, "SHOW CHARACTER SET")) + printf("[010] Cannot get list of available character sets, [%d] %s\n", + mysqli_errno($link2), mysqli_error($link2)); + + $charsets = array(); + while ($row = mysqli_fetch_assoc($res)) + $charsets[] = $row; + mysqli_free_result($res); + mysqli_close($link2); + + foreach ($charsets as $charset) { + $k = $charset['Charset']; + /* The server currently 17.07.2007 can't handle data sent in ucs2 */ + /* The server currently 16.08.2010 can't handle data sent in utf16 and utf32 */ + if ($charset['Charset'] == 'ucs2' || $charset['Charset'] == 'utf16' || $charset['Charset'] == 'utf32') { + continue; + } + if (true !== mysqli_options($link, MYSQLI_SET_CHARSET_NAME, $charset['Charset'])) { + printf("[009] Setting charset name '%s' has failed\n", $charset['Charset']); + } + } + + var_dump("MYSQLI_READ_DEFAULT_GROUP", mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf')); + var_dump("MYSQLI_READ_DEFAULT_FILE", mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf')); + var_dump("MYSQLI_OPT_CONNECT_TIMEOUT", mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10)); + var_dump("MYSQLI_OPT_LOCAL_INFILE", mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1)); + var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0')); + + /* mysqli_real_connect() */ + var_dump("MYSQLI_CLIENT_SSL", mysqli_options($link, MYSQLI_CLIENT_SSL, 'not a mysqli_option')); + + mysqli_close($link); + + echo "Link closed\n"; + try { mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1'); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECTF-- %s(25) "MYSQLI_READ_DEFAULT_GROUP" diff --git a/ext/mysqli/tests/mysqli_options_init_command.phpt b/ext/mysqli/tests/mysqli_options_init_command.phpt index 734adcf5c880..35e98e7e47e7 100644 --- a/ext/mysqli/tests/mysqli_options_init_command.phpt +++ b/ext/mysqli/tests/mysqli_options_init_command.phpt @@ -9,64 +9,64 @@ require_once('skipifconnectfailure.inc'); --FILE-- --CLEAN-- --FILE-- array('BIT(8)', 0), - 'TINYINT' => array('TINYINT', 120), - 'BOOL' => array('BOOL', 0), - 'BOOLEAN' => array('BOOLEAN', 1), - 'SMALLINT' => array('SMALLINT', 32000), - 'MEDIUMINT' => array('MEDIUMINT', 999), - 'INT' => array('INT', 999), - 'BIGINT' => array('BIGINT', 999), - 'FLOAT' => array('FLOAT', 1.3), - 'DOUBLE' => array('DOUBLE', -1.3), - ); - - foreach ($types as $name => $data) { - $link = mysqli_init(); - if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1)) { - printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { - printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - continue; - } - - - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - if (!mysqli_query($link, sprintf("CREATE TABLE test (id %s)", $data[0]))) { - printf("[004] TODO [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - if (!mysqli_query($link, sprintf("INSERT INTO test(id) VALUES (%f)", $data[1]))) { - printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - if (!$res = mysqli_query($link, "SELECT id FROM test")) { - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - $row = mysqli_fetch_assoc($res); - mysqli_free_result($res); - - if ($row['id'] !== $data[1]) { - printf("[007] Expecting %s - %s/%s got %s/%s\n", - $name, - $data[1], gettype($data[1]), $row['id'], gettype($row['id'])); - } - mysqli_close($link); - - $link = mysqli_init(); - if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 0)) { - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { - printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - continue; - } - - if (!$res = mysqli_query($link, "SELECT id FROM test")) { - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - continue; - } - - $row = mysqli_fetch_assoc($res); - mysqli_free_result($res); - - if (!is_string($row['id']) || ($row['id'] != $data[1])) { - printf("[011] Expecting %s - %s/string got %s/%s\n", - $name, - $data[1], $row['id'], gettype($row['id'])); - } - mysqli_close($link); - - } - - print "done!"; + require_once("connect.inc"); + + + $types = array( + 'BIT' => array('BIT(8)', 0), + 'TINYINT' => array('TINYINT', 120), + 'BOOL' => array('BOOL', 0), + 'BOOLEAN' => array('BOOLEAN', 1), + 'SMALLINT' => array('SMALLINT', 32000), + 'MEDIUMINT' => array('MEDIUMINT', 999), + 'INT' => array('INT', 999), + 'BIGINT' => array('BIGINT', 999), + 'FLOAT' => array('FLOAT', 1.3), + 'DOUBLE' => array('DOUBLE', -1.3), + ); + + foreach ($types as $name => $data) { + $link = mysqli_init(); + if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1)) { + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { + printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + continue; + } + + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + if (!mysqli_query($link, sprintf("CREATE TABLE test (id %s)", $data[0]))) { + printf("[004] TODO [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + if (!mysqli_query($link, sprintf("INSERT INTO test(id) VALUES (%f)", $data[1]))) { + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + if (!$res = mysqli_query($link, "SELECT id FROM test")) { + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + $row = mysqli_fetch_assoc($res); + mysqli_free_result($res); + + if ($row['id'] !== $data[1]) { + printf("[007] Expecting %s - %s/%s got %s/%s\n", + $name, + $data[1], gettype($data[1]), $row['id'], gettype($row['id'])); + } + mysqli_close($link); + + $link = mysqli_init(); + if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 0)) { + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) { + printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + continue; + } + + if (!$res = mysqli_query($link, "SELECT id FROM test")) { + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + continue; + } + + $row = mysqli_fetch_assoc($res); + mysqli_free_result($res); + + if (!is_string($row['id']) || ($row['id'] != $data[1])) { + printf("[011] Expecting %s - %s/string got %s/%s\n", + $name, + $data[1], $row['id'], gettype($row['id'])); + } + mysqli_close($link); + + } + + print "done!"; ?> --CLEAN-- close(); ?> --FILE-- query("SELECT id FROM test WHERE id = 1")) - printf("[002] [%d] %s\n", $link->errno, $link->error); + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!$row = mysqli_fetch_assoc($res)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } - if ($row['id'] != 1) { - printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); - } + if ($row['id'] != 1) { + printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } - $res->close(); - $link->close(); - } + $res->close(); + $link->close(); + } - print "done!"; + print "done!"; ?> --CLEAN-- close(); mysqlnd.sha256_server_public_key="test_sha256_ini" --FILE-- connect_errno) { - printf("[001] [%d] %s\n", $link->connect_errno, $link->connect_error); - } else { - if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) - printf("[002] [%d] %s\n", $link->errno, $link->error); + $link = new mysqli($host, 'shatest', 'shatest', $db, $port, $socket); + if ($link->connect_errno) { + printf("[001] [%d] %s\n", $link->connect_errno, $link->connect_error); + } else { + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[002] [%d] %s\n", $link->errno, $link->error); - if (!$row = mysqli_fetch_assoc($res)) { - printf("[003] [%d] %s\n", $link->errno, $link->error); - } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[003] [%d] %s\n", $link->errno, $link->error); + } - if ($row['id'] != 1) { - printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); - } - } - print "done!"; + if ($row['id'] != 1) { + printf("[004] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } + } + print "done!"; ?> --CLEAN-- close(); ?> --FILE-- options(MYSQLI_SERVER_PUBLIC_KEY, $file))) { - printf("[001] mysqli_options failed, [%d] %s\n", $link->errno, $link->error); - } + $link = mysqli_init(); + if (!($link->options(MYSQLI_SERVER_PUBLIC_KEY, $file))) { + printf("[001] mysqli_options failed, [%d] %s\n", $link->errno, $link->error); + } - if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) { - printf("[002] [%d] %s\n", $link->connect_errno, $link->connect_error); - } + if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) { + printf("[002] [%d] %s\n", $link->connect_errno, $link->connect_error); + } - if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) - printf("[003] [%d] %s\n", $link->errno, $link->error); + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[003] [%d] %s\n", $link->errno, $link->error); - if (!$row = mysqli_fetch_assoc($res)) { - printf("[004] [%d] %s\n", $link->errno, $link->error); - } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[004] [%d] %s\n", $link->errno, $link->error); + } - if ($row['id'] != 1) { - printf("[005] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); - } + if ($row['id'] != 1) { + printf("[005] Expecting 1 got %s/'%s'", gettype($row['id']), $row['id']); + } - $res->close(); - $link->close(); - } + $res->close(); + $link->close(); + } - print "done!"; + print "done!"; ?> --CLEAN-- close(); ?> --FILE-- options(MYSQLI_SERVER_PUBLIC_KEY, $file))) { - printf("[%03d + 001] mysqli_options failed, [%d] %s\n", $offset, $link->errno, $link->error); - return false; - } - - if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) { - printf("[%03d + 002] [%d] %s\n", $offset, $link->connect_errno, $link->connect_error); - return false; - } - - if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) - printf("[%03d + 003] [%d] %s\n", $offset, $link->errno, $link->error); - return false; - - if (!$row = mysqli_fetch_assoc($res)) { - printf("[%03d + 004] [%d] %s\n", $offset, $link->errno, $link->error); - return false; - } - - if ($row['id'] != 1) { - printf("[%03d + 005] Expecting 1 got %s/'%s'", $offset, gettype($row['id']), $row['id']); - return false; - } - - $res->close(); - $link->close(); - return true; - } - - $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); - if (file_exists($file) && is_readable($file)) { - - /* valid key */ - sha_connect(100, $host, $db, $port, $socket, $file); - - /* invalid key */ - $file_wrong = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_wrong" , @date("Ymd")); - - $key = file_get_contents($file); - $key = str_replace("A", "a", $key); - $key = str_replace("M", "m", $key); - @unlink($file_wrong); - if (!($fp = fopen($file_wrong, "w"))) { - printf("[002] Can't write public key file."); - } else { - fwrite($fp, $key); - fclose($fp); - sha_connect(200, $host, $db, $port, $socket, $file_wrong); - } - - /* empty file */ - @unlink($file_wrong); - if (!($fp = fopen($file_wrong, "w"))) { - printf("[003] Can't write public key file."); - } else { - fwrite($fp, ""); - fclose($fp); - sha_connect(300, $host, $db, $port, $socket, $file_wrong); - } - - /* file does not exist */ - @unlink($file_wrong); - sha_connect(400, $host, $db, $port, $socket, $file_wrong); - - } else { - printf("[001] Cannot read public key file."); - } - - print "done!"; + require_once("connect.inc"); + + function sha_connect($offset, $host, $db, $port, $socket, $file) { + + $link = mysqli_init(); + if (!($link->options(MYSQLI_SERVER_PUBLIC_KEY, $file))) { + printf("[%03d + 001] mysqli_options failed, [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + if (!$link->real_connect($host, 'shatest', 'shatest', $db, $port, $socket)) { + printf("[%03d + 002] [%d] %s\n", $offset, $link->connect_errno, $link->connect_error); + return false; + } + + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[%03d + 003] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + + if (!$row = mysqli_fetch_assoc($res)) { + printf("[%03d + 004] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + if ($row['id'] != 1) { + printf("[%03d + 005] Expecting 1 got %s/'%s'", $offset, gettype($row['id']), $row['id']); + return false; + } + + $res->close(); + $link->close(); + return true; + } + + $file = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_" , @date("Ymd")); + if (file_exists($file) && is_readable($file)) { + + /* valid key */ + sha_connect(100, $host, $db, $port, $socket, $file); + + /* invalid key */ + $file_wrong = sprintf("%s%s%s_%s", sys_get_temp_dir(), DIRECTORY_SEPARATOR, "test_sha256_wrong" , @date("Ymd")); + + $key = file_get_contents($file); + $key = str_replace("A", "a", $key); + $key = str_replace("M", "m", $key); + @unlink($file_wrong); + if (!($fp = fopen($file_wrong, "w"))) { + printf("[002] Can't write public key file."); + } else { + fwrite($fp, $key); + fclose($fp); + sha_connect(200, $host, $db, $port, $socket, $file_wrong); + } + + /* empty file */ + @unlink($file_wrong); + if (!($fp = fopen($file_wrong, "w"))) { + printf("[003] Can't write public key file."); + } else { + fwrite($fp, ""); + fclose($fp); + sha_connect(300, $host, $db, $port, $socket, $file_wrong); + } + + /* file does not exist */ + @unlink($file_wrong); + sha_connect(400, $host, $db, $port, $socket, $file_wrong); + + } else { + printf("[001] Cannot read public key file."); + } + + print "done!"; ?> --CLEAN-- thread_id) - printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$thread_id = $link->thread_id) + printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) - printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) + printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0)) - printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); + if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0)) + printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); - if ($thread_id == $new_thread_id) - printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); + if ($thread_id == $new_thread_id) + printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); - if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) || - !($row = mysqli_fetch_assoc($res))) - printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) || + !($row = mysqli_fetch_assoc($res))) + printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($row); - mysqli_free_result($res); + var_dump($row); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - if (!$link = new my_mysqli($phost, $user, $passwd, $db, $port, $socket)) - printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $phost, $user, $db, $port, $socket); + if (!$link = new my_mysqli($phost, $user, $passwd, $db, $port, $socket)) + printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $phost, $user, $db, $port, $socket); - if (!$thread_id = $link->thread_id) - printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$thread_id = $link->thread_id) + printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) - printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) + printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) - printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); + if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) + printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); - if ($thread_id == $new_thread_id) - printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); + if ($thread_id == $new_thread_id) + printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); - if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || - !($row = $res->fetch_assoc())) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || + !($row = $res->fetch_assoc())) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($row); - mysqli_free_result($res); + var_dump($row); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket))) - printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket))) + printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket)) - printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $phost, $user, $db, $port, $socket); + if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket)) + printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $phost, $user, $db, $port, $socket); - if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) - printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) + printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - printf("Flipping phost/host order\n"); + printf("Flipping phost/host order\n"); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (!$thread_id = mysqli_thread_id($link)) - printf("[017] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$thread_id = mysqli_thread_id($link)) + printf("[017] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = my_mysqli_real_connect($link, $phost, $user, $passwd, $db, $port, $socket))) - printf("[018] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = my_mysqli_real_connect($link, $phost, $user, $passwd, $db, $port, $socket))) + printf("[018] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0)) - printf("[019] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); + if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0)) + printf("[019] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); - if ($thread_id == $new_thread_id) - printf("[020] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); + if ($thread_id == $new_thread_id) + printf("[020] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); - if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) || - !($row = mysqli_fetch_assoc($res))) - printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) || + !($row = mysqli_fetch_assoc($res))) + printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($row); - mysqli_free_result($res); + var_dump($row); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) - printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) + printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (!$thread_id = $link->thread_id) - printf("[023] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$thread_id = $link->thread_id) + printf("[023] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = $link->real_connect($phost, $user, $passwd, $db, $port, $socket))) - printf("[024] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $link->real_connect($phost, $user, $passwd, $db, $port, $socket))) + printf("[024] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) - printf("[025] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); + if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0)) + printf("[025] Expecting int/any got %s/%s\n", gettype($tmp), $tmp); - if ($thread_id == $new_thread_id) - printf("[026] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); + if ($thread_id == $new_thread_id) + printf("[026] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id); - if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || - !($row = $res->fetch_assoc())) - printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || + !($row = $res->fetch_assoc())) + printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($row); - mysqli_free_result($res); + var_dump($row); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) - printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) + printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket))) - printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket))) + printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_pconn_disabled.phpt b/ext/mysqli/tests/mysqli_pconn_disabled.phpt index e8c592f9ff68..a59a43cbd59a 100644 --- a/ext/mysqli/tests/mysqli_pconn_disabled.phpt +++ b/ext/mysqli/tests/mysqli_pconn_disabled.phpt @@ -14,44 +14,44 @@ mysqli.max_persistent=2 mysqli.max_links=2 --FILE-- '%s'\n", $row['_test']); - mysqli_free_result($res); - - if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) - printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); - - $row = mysqli_fetch_assoc($res); - printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']); - mysqli_free_result($res); - - if ($link1 === $link2) - printf("[006] Links should not be identical\n"); - - mysqli_close($link1); - mysqli_close($link2); - print "done!"; + require_once("connect.inc"); + + $host = 'p:' . $host; + if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + // automatic downgrade to normal connections has failed + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n", + $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); + } + if (!mysqli_query($link1, "SET @pcondisabled = 'Connection 1'")) + printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n", + mysqli_errno($link1), mysqli_error($link1)); + + if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + // automatic downgrade to normal connections has failed + printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n", + $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); + } + + if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test')) + printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connecction 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']); + mysqli_free_result($res); + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connecction 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']); + mysqli_free_result($res); + + if ($link1 === $link2) + printf("[006] Links should not be identical\n"); + + mysqli_close($link1); + mysqli_close($link2); + print "done!"; ?> --EXPECTF-- Warning: my_mysqli_connect(): Persistent connections are disabled. Downgrading to normal in %s on line %d diff --git a/ext/mysqli/tests/mysqli_pconn_kill.phpt b/ext/mysqli/tests/mysqli_pconn_kill.phpt index d6fba4d8e3e5..abf2c838f8cd 100644 --- a/ext/mysqli/tests/mysqli_pconn_kill.phpt +++ b/ext/mysqli/tests/mysqli_pconn_kill.phpt @@ -12,84 +12,84 @@ mysqli.allow_persistent=1 mysqli.max_persistent=2 --FILE-- getMessage() . "\n"; } - if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - if (!$res3 = @mysqli_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1')) { - printf("[012] New persistent connection cannot execute queries, [%d] %s\n", @mysqli_errno($plink), @mysqli_error($plink)); - } - - @mysqli_free_result($res3); - @mysqli_close($plink); - mysqli_close($link); - - // remove the "p:" from the host variable - $host = substr($host, 2); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[013] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - if (!$res4 = mysqli_query($link, 'SELECT id FROM test ORDER BY id LIMIT 1')) - printf("[014] New regular connection cannot execute queries, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - mysqli_free_result($res4); - mysqli_close($link); - print "done!"; + if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + if (!$res3 = @mysqli_query($plink, 'SELECT id FROM test ORDER BY id LIMIT 1')) { + printf("[012] New persistent connection cannot execute queries, [%d] %s\n", @mysqli_errno($plink), @mysqli_error($plink)); + } + + @mysqli_free_result($res3); + @mysqli_close($plink); + mysqli_close($link); + + // remove the "p:" from the host variable + $host = substr($host, 2); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[013] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + if (!$res4 = mysqli_query($link, 'SELECT id FROM test ORDER BY id LIMIT 1')) + printf("[014] New regular connection cannot execute queries, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + mysqli_free_result($res4); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --CLEAN-- getMessage() . "\n"; - } + try { + mysqli_get_links_stats(1); + } catch (ArgumentCountError $exception) { + echo $exception->getMessage() . "\n"; + } - echo "Before pconnect:"; - var_dump(mysqli_get_links_stats()); + echo "Before pconnect:"; + var_dump(mysqli_get_links_stats()); - if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket)) - printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); + if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket)) + printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); - echo "After pconnect:"; - var_dump(mysqli_get_links_stats()); + echo "After pconnect:"; + var_dump(mysqli_get_links_stats()); - ob_start(); - phpinfo(); - $phpinfo = strip_tags(ob_get_contents()); - ob_end_clean(); + ob_start(); + phpinfo(); + $phpinfo = strip_tags(ob_get_contents()); + ob_end_clean(); - $phpinfo = substr($phpinfo, strpos($phpinfo, 'MysqlI Support => enabled'), 500); - if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) - printf("[002] Cannot get # active persistent links from phpinfo()\n"); - $num_plinks = $matches[1]; + $phpinfo = substr($phpinfo, strpos($phpinfo, 'MysqlI Support => enabled'), 500); + if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) + printf("[002] Cannot get # active persistent links from phpinfo()\n"); + $num_plinks = $matches[1]; - if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1')) - printf("[003] Cannot run query on persistent connection of second DB user, [%d] %s\n", - mysqli_errno($plink), mysqli_error($plink)); + if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1')) + printf("[003] Cannot run query on persistent connection of second DB user, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[004] Cannot run fetch result, [%d] %s\n", - mysqli_errno($plink), mysqli_error($plink)); - mysqli_free_result($res); - var_dump($row); + if (!$row = mysqli_fetch_assoc($res)) + printf("[004] Cannot run fetch result, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + mysqli_free_result($res); + var_dump($row); - // change the password for the second DB user and kill the persistent connection - if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest = "newpass"') && - !mysqli_query($link, 'SET PASSWORD FOR pcontest = PASSWORD("newpass")'))|| - !mysqli_query($link, 'FLUSH PRIVILEGES')) - printf("[005] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + // change the password for the second DB user and kill the persistent connection + if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest = "newpass"') && + !mysqli_query($link, 'SET PASSWORD FOR pcontest = PASSWORD("newpass")'))|| + !mysqli_query($link, 'FLUSH PRIVILEGES')) + printf("[005] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); // change the password for the second DB user and kill the persistent connection - if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = "newpass"') && - !mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = PASSWORD("newpass")')) || - !mysqli_query($link, 'FLUSH PRIVILEGES')) - printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - // persistent connections cannot be closed but only be killed - $pthread_id = mysqli_thread_id($plink); - if (!mysqli_query($link, sprintf('KILL %d', $pthread_id))) - printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - // give the server a second to really kill the thread - sleep(1); - - if (!$res = mysqli_query($link, "SHOW FULL PROCESSLIST")) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $running_threads = array(); - while ($row = mysqli_fetch_assoc($res)) - $running_threads[$row['Id']] = $row; - mysqli_free_result($res); - - if (isset($running_threads[$pthread_id])) - printf("[009] Persistent connection has not been killed\n"); - - echo "Before second pconnect:"; - var_dump(mysqli_get_links_stats()); - - // this fails and we have 0 (<= $num_plinks) connections - if ($plink = @my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket)) - printf("[010] Can connect using the old password, [%d] %s\n", - mysqli_connect_errno($link), mysqli_connect_error($link)); - - echo "After second pconnect:"; - var_dump(mysqli_get_links_stats()); - - ob_start(); - phpinfo(); - $phpinfo = strip_tags(ob_get_contents()); - ob_end_clean(); - $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500); - if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) - printf("[010] Cannot get # of active persistent links from phpinfo()\n"); - - var_dump(mysqli_get_links_stats()); - - $num_plinks_kill = $matches[1]; - $sstats = mysqli_get_links_stats(); - if ($sstats['active_plinks'] != $num_plinks_kill) { - printf("[010.2] Num of active plinks differ %s %s\n", $sstats['active_plinks'], $num_plinks_kill); - } - if ($num_plinks_kill > $num_plinks) - printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill); - - if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket)) - printf("[012] Cannot connect using the new password, [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); - - if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1')) - printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n", - mysqli_errno($plink), mysqli_error($plink)); - - if (!$row = mysqli_fetch_assoc($res)) - printf("[014] Cannot run fetch result, [%d] %s\n", - mysqli_errno($plink), mysqli_error($plink)); - mysqli_free_result($res); - var_dump($row); - - if ($plink2 = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket)) { - printf("[015] Can open more persistent connections than allowed, [%d] %s\n", - mysqli_connect_errno(), mysqli_connect_error()); - var_dump(mysqli_get_links_stats()); - } - - ob_start(); - phpinfo(); - $phpinfo = strip_tags(ob_get_contents()); - ob_end_clean(); - $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500); - if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) - printf("[016] Cannot get # of active persistent links from phpinfo()\n"); - - $num_plinks = $matches[1]; - if ($num_plinks > (int)ini_get('mysqli.max_persistent')) - printf("[017] mysqli.max_persistent=%d allows %d open connections!\n", ini_get('mysqli.max_persistent'),$num_plinks); + if ((!mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = "newpass"') && + !mysqli_query($link, 'SET PASSWORD FOR pcontest@localhost = PASSWORD("newpass")')) || + !mysqli_query($link, 'FLUSH PRIVILEGES')) + printf("[006] Cannot change PW of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + // persistent connections cannot be closed but only be killed + $pthread_id = mysqli_thread_id($plink); + if (!mysqli_query($link, sprintf('KILL %d', $pthread_id))) + printf("[007] Cannot KILL persistent connection of second DB user, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + // give the server a second to really kill the thread + sleep(1); + + if (!$res = mysqli_query($link, "SHOW FULL PROCESSLIST")) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $running_threads = array(); + while ($row = mysqli_fetch_assoc($res)) + $running_threads[$row['Id']] = $row; + mysqli_free_result($res); + + if (isset($running_threads[$pthread_id])) + printf("[009] Persistent connection has not been killed\n"); + + echo "Before second pconnect:"; + var_dump(mysqli_get_links_stats()); + + // this fails and we have 0 (<= $num_plinks) connections + if ($plink = @my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket)) + printf("[010] Can connect using the old password, [%d] %s\n", + mysqli_connect_errno($link), mysqli_connect_error($link)); + + echo "After second pconnect:"; + var_dump(mysqli_get_links_stats()); + + ob_start(); + phpinfo(); + $phpinfo = strip_tags(ob_get_contents()); + ob_end_clean(); + $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500); + if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) + printf("[010] Cannot get # of active persistent links from phpinfo()\n"); + + var_dump(mysqli_get_links_stats()); + + $num_plinks_kill = $matches[1]; + $sstats = mysqli_get_links_stats(); + if ($sstats['active_plinks'] != $num_plinks_kill) { + printf("[010.2] Num of active plinks differ %s %s\n", $sstats['active_plinks'], $num_plinks_kill); + } + if ($num_plinks_kill > $num_plinks) + printf("[011] Expecting Active Persistent Links < %d, got %d\n", $num_plinks, $num_plinks_kill); + + if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket)) + printf("[012] Cannot connect using the new password, [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + + if (!$res = mysqli_query($plink, 'SELECT id, label FROM test WHERE id = 1')) + printf("[013] Cannot run query on persistent connection of second DB user, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[014] Cannot run fetch result, [%d] %s\n", + mysqli_errno($plink), mysqli_error($plink)); + mysqli_free_result($res); + var_dump($row); + + if ($plink2 = my_mysqli_connect('p:' . $host, 'pcontest', 'newpass', $db, $port, $socket)) { + printf("[015] Can open more persistent connections than allowed, [%d] %s\n", + mysqli_connect_errno(), mysqli_connect_error()); + var_dump(mysqli_get_links_stats()); + } - mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest'); - mysqli_query($link, 'DROP USER pcontest'); - mysqli_close($link); - print "done!"; + ob_start(); + phpinfo(); + $phpinfo = strip_tags(ob_get_contents()); + ob_end_clean(); + $phpinfo = substr($phpinfo, stripos($phpinfo, 'MysqlI Support => enabled'), 500); + if (!preg_match('@Active Persistent Links\s+=>\s+(\d+)@ismU', $phpinfo, $matches)) + printf("[016] Cannot get # of active persistent links from phpinfo()\n"); + + $num_plinks = $matches[1]; + if ($num_plinks > (int)ini_get('mysqli.max_persistent')) + printf("[017] mysqli.max_persistent=%d allows %d open connections!\n", ini_get('mysqli.max_persistent'),$num_plinks); + + mysqli_query($link, 'REVOKE ALL PRIVILEGES, GRANT OPTION FROM pcontest'); + mysqli_query($link, 'DROP USER pcontest'); + mysqli_close($link); + print "done!"; ?> --CLEAN-- '%s'\n", $row['_test']); - mysqli_free_result($res); - - if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) - printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); - - $row = mysqli_fetch_assoc($res); - printf("Connection 2 (no reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']); - $thread_id = mysqli_thread_id($link2); - printf("Connection 2 (no reuse) - Thread ID -> '%s'\n", $thread_id); - mysqli_free_result($res); - - if (!mysqli_query($link2, 'SET @pcondisabled = "Connection 2"')) - printf("[006] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n", - mysqli_errno($link2), mysqli_error($link2)); - - if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) - printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); - - $row = mysqli_fetch_assoc($res); - printf("Connection 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']); - mysqli_free_result($res); - - mysqli_close($link2); - - /* reuse of existing persistent connection expected! */ - if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n", - $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); - } - - if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) - printf("[009] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); - - $row = mysqli_fetch_assoc($res); - printf("Connection 2 (reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']); - $thread_id_reuse = mysqli_thread_id($link2); - printf("Connection 2 (reuse) - Thread ID -> '%s'\n", $thread_id_reuse); - mysqli_free_result($res); - - if ($thread_id != $thread_id_reuse) - printf("[010] Seems as if we have got a new connection, connections should have been cached and reused!\n"); - - mysqli_close($link1); - mysqli_close($link2); - print "done!"; + require_once("connect.inc"); + + $host = 'p:' . $host; + if (!$link1 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n", + $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); + } + if (!mysqli_query($link1, 'SET @pcondisabled = "Connection 1"')) + printf("[002] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n", + mysqli_errno($link1), mysqli_error($link1)); + + if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n", + $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); + } + + if (!$res = mysqli_query($link1, 'SELECT @pcondisabled AS _test')) + printf("[004] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 1 - SELECT @pcondisabled -> '%s'\n", $row['_test']); + mysqli_free_result($res); + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[005] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 2 (no reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']); + $thread_id = mysqli_thread_id($link2); + printf("Connection 2 (no reuse) - Thread ID -> '%s'\n", $thread_id); + mysqli_free_result($res); + + if (!mysqli_query($link2, 'SET @pcondisabled = "Connection 2"')) + printf("[006] Cannot set user variable to check if we got the same persistent connection, [%d] %s\n", + mysqli_errno($link2), mysqli_error($link2)); + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 2 - SELECT @pcondisabled -> '%s'\n", $row['_test']); + mysqli_free_result($res); + + mysqli_close($link2); + + /* reuse of existing persistent connection expected! */ + if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[008] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n", + $host, $user, $db, $port, $socket, mysqli_connect_errno(), mysqli_connect_error()); + } + + if (!$res = mysqli_query($link2, 'SELECT @pcondisabled AS _test')) + printf("[009] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2)); + + $row = mysqli_fetch_assoc($res); + printf("Connection 2 (reuse) - SELECT @pcondisabled -> '%s'\n", $row['_test']); + $thread_id_reuse = mysqli_thread_id($link2); + printf("Connection 2 (reuse) - Thread ID -> '%s'\n", $thread_id_reuse); + mysqli_free_result($res); + + if ($thread_id != $thread_id_reuse) + printf("[010] Seems as if we have got a new connection, connections should have been cached and reused!\n"); + + mysqli_close($link1); + mysqli_close($link2); + print "done!"; ?> --EXPECTF-- Connection 1 - SELECT @pcondisabled -> 'Connection 1' diff --git a/ext/mysqli/tests/mysqli_pconn_twice.phpt b/ext/mysqli/tests/mysqli_pconn_twice.phpt index ca2acd1369c3..e388847507e9 100644 --- a/ext/mysqli/tests/mysqli_pconn_twice.phpt +++ b/ext/mysqli/tests/mysqli_pconn_twice.phpt @@ -13,57 +13,57 @@ mysqli.max_persistent=-1 mysqli.max_links=-1 --FILE-- real_connect($host, $user, $passwd, $db, $port, $socket))) - printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket))) + printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp); - /* it is undefined which pooled connection we get - thread ids may differ */ + /* it is undefined which pooled connection we get - thread ids may differ */ - if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || - !($row = $res->fetch_assoc())) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) || + !($row = $res->fetch_assoc())) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($row); - mysqli_free_result($res); + var_dump($row); + mysqli_free_result($res); - mysqli_close($link); + mysqli_close($link); - if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) - printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) + printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) - printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket))) + printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_pconnect.phpt b/ext/mysqli/tests/mysqli_pconnect.phpt index 3fb14d25d938..16fbb27e31f8 100644 --- a/ext/mysqli/tests/mysqli_pconnect.phpt +++ b/ext/mysqli/tests/mysqli_pconnect.phpt @@ -8,65 +8,65 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- 0) { - do { - $index = mt_rand(0, $num); - } while (!isset($connections[$index]) && $left > 0); - if (mt_rand(0, 1) > 0) { - $left--; - mysqli_close($connections[$index]); - unset($connections[$index]); - } else { - $left--; - if (!$connections[$index] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - } - flush(); - } + while (count($connections) && $left > 0) { + do { + $index = mt_rand(0, $num); + } while (!isset($connections[$index]) && $left > 0); + if (mt_rand(0, 1) > 0) { + $left--; + mysqli_close($connections[$index]); + unset($connections[$index]); + } else { + $left--; + if (!$connections[$index] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + } + flush(); + } - while (count($connections)) { - do { - $index = mt_rand(0, $num); - } while (!isset($connections[$index])); - mysqli_close($connections[$index]); - unset($connections[$index]); - } + while (count($connections)) { + do { + $index = mt_rand(0, $num); + } while (!isset($connections[$index])); + mysqli_close($connections[$index]); + unset($connections[$index]); + } - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_phpinfo.phpt b/ext/mysqli/tests/mysqli_phpinfo.phpt index 4f856f2b65c8..d1ecdea7966e 100644 --- a/ext/mysqli/tests/mysqli_phpinfo.phpt +++ b/ext/mysqli/tests/mysqli_phpinfo.phpt @@ -8,54 +8,54 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- $entry) - if (!stristr($phpinfo, $entry)) - printf("[010] Could not find entry for '%s'\n", $entry); - } + if ($IS_MYSQLND) { + $expected = array( + 'size', + 'mysqli.allow_local_infile', + 'mysqli.allow_persistent', 'mysqli.max_persistent' + ); + foreach ($expected as $k => $entry) + if (!stristr($phpinfo, $entry)) + printf("[010] Could not find entry for '%s'\n", $entry); + } - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_ping.phpt b/ext/mysqli/tests/mysqli_ping.phpt index aec065c3dee9..40a3115f3d3f 100644 --- a/ext/mysqli/tests/mysqli_ping.phpt +++ b/ext/mysqli/tests/mysqli_ping.phpt @@ -8,30 +8,30 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_poll.phpt b/ext/mysqli/tests/mysqli_poll.phpt index f6d99c8e1311..97b1a7e61ad7 100644 --- a/ext/mysqli/tests/mysqli_poll.phpt +++ b/ext/mysqli/tests/mysqli_poll.phpt @@ -12,103 +12,103 @@ if (!$IS_MYSQLND) ?> --FILE-- reap_async_query(); - } else { - $res = mysqli_reap_async_query($mysqli); - } - if (is_object($res)) { - printf("[%03d + 2] Can fetch resultset although no query has been run!\n", $offset); - } else if (mysqli_errno($mysqli) > 0) { - printf("[%03d + 3] Error indicated through links array: %d/%s", - $offset, mysqli_errno($mysqli), mysqli_error($mysqli)); - } else { - printf("[%03d + 4] Cannot fetch and no error set - non resultset query (no SELECT)!\n", $offset); - } - } - - foreach ($errors as $mysqli) - printf("[%03d + 5] Error on %d: %d/%s\n", - $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); - - foreach ($reject as $mysqli) - printf("[%03d + 6] Rejecting thread %d: %d/%s\n", - $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); - - } - - // Connections on which no query has been send - 1 - $link = get_connection(); - $links = array($link); - $errors = array($link); - $reject = array($link); - poll_async(12, $link, $links, $errors, $reject, 0, false); - mysqli_close($link); - - $link = get_connection(); - $links = array($link); - $errors = array($link); - $reject = array($link); - poll_async(13, $link, $links, $errors, $reject, 0, true); - mysqli_close($link); - - // Connections on which no query has been send - 2 - // Difference: pass $links twice - $link = get_connection(); - $links = array($link, $link); - $errors = array($link, $link); - $reject = array(); - poll_async(14, $link, $links, $errors, $reject, 0, false); - - // Connections on which no query has been send - 3 - // Difference: pass two connections - $link = get_connection(); - $links = array($link, get_connection()); - $errors = array($link, $link); - $reject = array(); - poll_async(15, $link, $links, $errors, $reject, 0, false); - - // Reference mess... - $link = get_connection(); - $links = array($link); - $errors = array($link); - $ref_errors =& $errors; - $reject = array(); - poll_async(16, $link, $links, $ref_errors, $reject, 0, false); - - print "done!"; + require_once('connect.inc'); + + function get_connection() { + global $host, $user, $passwd, $db, $port, $socket; + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + return $link; + } + + if (!$link = get_connection()) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + $read = $error = $reject = array($link); + if (0 !== ($tmp = (mysqli_poll($read, $error, $reject, 0, 1)))) + printf("[009] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + $read = $error = $reject = array($link); + if (false !== ($tmp = (mysqli_poll($read, $error, $reject, -1, 1)))) + printf("[010] Expecting false got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + $read = $error = $reject = array($link); + if (false !== ($tmp = (mysqli_poll($read, $error, $reject, 0, -1)))) + printf("[011] Expecting false got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) { + + if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000))) + printf("[%03d + 1] There should be %d links ready to read from, %d ready\n", + $exp_ready, $tmp); + + foreach ($links as $mysqli) { + if ($use_oo_syntax) { + $res = $mysqli->reap_async_query(); + } else { + $res = mysqli_reap_async_query($mysqli); + } + if (is_object($res)) { + printf("[%03d + 2] Can fetch resultset although no query has been run!\n", $offset); + } else if (mysqli_errno($mysqli) > 0) { + printf("[%03d + 3] Error indicated through links array: %d/%s", + $offset, mysqli_errno($mysqli), mysqli_error($mysqli)); + } else { + printf("[%03d + 4] Cannot fetch and no error set - non resultset query (no SELECT)!\n", $offset); + } + } + + foreach ($errors as $mysqli) + printf("[%03d + 5] Error on %d: %d/%s\n", + $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); + + foreach ($reject as $mysqli) + printf("[%03d + 6] Rejecting thread %d: %d/%s\n", + $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); + + } + + // Connections on which no query has been send - 1 + $link = get_connection(); + $links = array($link); + $errors = array($link); + $reject = array($link); + poll_async(12, $link, $links, $errors, $reject, 0, false); + mysqli_close($link); + + $link = get_connection(); + $links = array($link); + $errors = array($link); + $reject = array($link); + poll_async(13, $link, $links, $errors, $reject, 0, true); + mysqli_close($link); + + // Connections on which no query has been send - 2 + // Difference: pass $links twice + $link = get_connection(); + $links = array($link, $link); + $errors = array($link, $link); + $reject = array(); + poll_async(14, $link, $links, $errors, $reject, 0, false); + + // Connections on which no query has been send - 3 + // Difference: pass two connections + $link = get_connection(); + $links = array($link, get_connection()); + $errors = array($link, $link); + $reject = array(); + poll_async(15, $link, $links, $errors, $reject, 0, false); + + // Reference mess... + $link = get_connection(); + $links = array($link); + $errors = array($link); + $ref_errors =& $errors; + $reject = array(); + poll_async(16, $link, $links, $ref_errors, $reject, 0, false); + + print "done!"; ?> --EXPECTF-- Warning: mysqli_poll(): Negative values passed for sec and/or usec in %s on line %d diff --git a/ext/mysqli/tests/mysqli_poll_kill.phpt b/ext/mysqli/tests/mysqli_poll_kill.phpt index 7c10d13df15d..c796c06c703d 100644 --- a/ext/mysqli/tests/mysqli_poll_kill.phpt +++ b/ext/mysqli/tests/mysqli_poll_kill.phpt @@ -12,175 +12,175 @@ if (!$IS_MYSQLND) ?> --FILE-- errno > 0) { - printf("[005] Error: %d\n", $link->errno); - } - } - - // No error! - if (!is_array($errors) || !empty($errors)) - printf("[006] Expecting non-empty array got %s/%s\n", gettype($errors), var_export($errors, true)); - - if (!is_array($reject) || !empty($reject)) - printf("[007] Expecting empty array got %s/%s\n", gettype($reject), var_export($reject, true)); - - // Lets pass a dead connection - $links = array($link); - $errors = array($link); - $reject = array($link); - if (0 !== ($tmp = mysqli_poll($links, $errors, $reject, 1))) - printf("[008] There should be no connection ready! Returned %s/%s, expecting int/0.\n", - gettype($tmp), var_export($tmp, true)); - - if (!empty($errors)) - printf("[009] There should be no errors but one rejected connection\n"); - - foreach ($reject as $mysqli) - if (mysqli_thread_id($mysqli) != $thread_id) { - printf("[010] Rejected thread %d should have rejected thread %d\n", - mysqli_thread_id($mysqli), $thread_id); - } - - // Killing connection - 2 - - $link = get_connection(); - if (true !== ($tmp = mysqli_query($link, "SELECT 1", MYSQLI_ASYNC | MYSQLI_USE_RESULT))) - printf("[011] Expecting boolean/true got %s/%s\n", gettype($tmp), var_export($tmp, true)); - - usleep(100000); - $thread_id = mysqli_thread_id($link); - mysqli_kill(get_connection(), $thread_id); - - // Yes, 1 - fetch OK packet of kill! - $processed = 0; - $begin = microtime(true); - do { - $links = array($link, $link); - $errors = array($link, $link); - $reject = array($link, $link); - $ready = mysqli_poll($links, $errors, $reject, 1); - - if (!empty($errors)) { - foreach ($errors as $mysqli) { - printf("[012] Error on thread %d: %s/%s\n", - mysqli_thread_id($mysqli), - mysqli_errno($mysqli), - mysqli_error($mysqli)); - } - break; - } - - if (FALSE === $ready) { - printf("[013] MySQLi indicates some error\n"); - break; - } - - if (!empty($reject)) { - foreach ($reject as $mysqli) { - printf("[014] Rejecting thread %d: %s/%s\n", - mysqli_thread_id($mysqli), - mysqli_errno($mysqli), - mysqli_error($mysqli)); - } - $processed += count($reject); - } - - foreach ($links as $mysqli) { - if (is_object($res = mysqli_reap_async_query($mysqli))) { - printf("Fetching from thread %d...\n", mysqli_thread_id($mysqli)); - var_dump(mysqli_fetch_assoc($res)); - } else if (mysqli_errno($mysqli) > 0) { - printf("[015] %d/%s\n", mysqli_errno($mysqli), mysqli_error($mysqli)); - } - $processed++; - } - - if ((microtime(true) - $begin) > 5) { - printf("[016] Pulling the emergency break after 5s, something is wrong...\n"); - break; - } - - } while ($processed < 2); - - - // Killing connection - 3 - - $link = get_connection(); - $thread_id = mysqli_thread_id($link); - mysqli_kill(get_connection(), $thread_id); - // Sleep 0.1s to ensure the KILL gets recognized - usleep(100000); - if (false !== ($tmp = mysqli_query($link, "SELECT 1 AS 'processed before killed'", MYSQLI_ASYNC | MYSQLI_USE_RESULT))) - printf("[017] Expecting boolean/false got %s/%s\n", gettype($tmp), var_export($tmp, true)); - - $links = array($link); - $errors = array($link); - $reject = array($link); - - if (0 !== ($tmp = (mysqli_poll($links, $errors, $reject, 0, 10000)))) - printf("[018] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true)); - - if (!is_array($links) || empty($links)) - printf("[019] Expecting non-empty array got %s/%s\n", gettype($links), var_export($links, true)); - else - foreach ($links as $link) { - if (is_object($res = mysqli_reap_async_query($link))) { - // No, you cannot fetch the result - var_dump(mysqli_fetch_assoc($res)); - mysqli_free_result($res); - } else if ($link->errno > 0) { - // But you are supposed to handle the error the way its shown here! - printf("[020] Error: %d/%s\n", $link->errno, $link->error); - } - } - - // None of these will indicate an error, check errno on the list of returned connections! - if (!is_array($errors) || !empty($errors)) - printf("[021] Expecting non-empty array got %s/%s\n", gettype($errors), var_export($errors, true)); - - if (!is_array($reject) || !empty($reject)) - printf("[021] Expecting empty array got %s/%s\n", gettype($reject), var_export($reject, true)); - - - mysqli_close($link); - print "done!"; + require_once('connect.inc'); + + function get_connection() { + global $host, $user, $passwd, $db, $port, $socket; + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + return $link; + } + + // Killing connection - 1 + + $link = get_connection(); + if (true !== ($tmp = mysqli_query($link, "SELECT 1 AS 'processed before killed'", MYSQLI_ASYNC | MYSQLI_USE_RESULT))) + printf("[002] Expecting boolean/true got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + // Sleep 0.1s - the asynchronous query should have been processed after the wait period + usleep(100000); + $thread_id = mysqli_thread_id($link); + mysqli_kill(get_connection(), $thread_id); + + $links = array($link); + $errors = array($link); + $reject = array($link); + + // Yes, 1 - the asynchronous query should have been processed + if (1 !== ($tmp = (mysqli_poll($links, $errors, $reject, 0, 10000)))) + printf("[003] Expecting int/1 got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + if (!is_array($links) || empty($links)) + printf("[004] Expecting non-empty array got %s/%s\n", gettype($links), var_export($links, true)); + else + foreach ($links as $link) { + if (is_object($res = mysqli_reap_async_query($link))) { + // Yes, you can fetch a result - the query has been processed + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + } else if ($link->errno > 0) { + printf("[005] Error: %d\n", $link->errno); + } + } + + // No error! + if (!is_array($errors) || !empty($errors)) + printf("[006] Expecting non-empty array got %s/%s\n", gettype($errors), var_export($errors, true)); + + if (!is_array($reject) || !empty($reject)) + printf("[007] Expecting empty array got %s/%s\n", gettype($reject), var_export($reject, true)); + + // Lets pass a dead connection + $links = array($link); + $errors = array($link); + $reject = array($link); + if (0 !== ($tmp = mysqli_poll($links, $errors, $reject, 1))) + printf("[008] There should be no connection ready! Returned %s/%s, expecting int/0.\n", + gettype($tmp), var_export($tmp, true)); + + if (!empty($errors)) + printf("[009] There should be no errors but one rejected connection\n"); + + foreach ($reject as $mysqli) + if (mysqli_thread_id($mysqli) != $thread_id) { + printf("[010] Rejected thread %d should have rejected thread %d\n", + mysqli_thread_id($mysqli), $thread_id); + } + + // Killing connection - 2 + + $link = get_connection(); + if (true !== ($tmp = mysqli_query($link, "SELECT 1", MYSQLI_ASYNC | MYSQLI_USE_RESULT))) + printf("[011] Expecting boolean/true got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + usleep(100000); + $thread_id = mysqli_thread_id($link); + mysqli_kill(get_connection(), $thread_id); + + // Yes, 1 - fetch OK packet of kill! + $processed = 0; + $begin = microtime(true); + do { + $links = array($link, $link); + $errors = array($link, $link); + $reject = array($link, $link); + $ready = mysqli_poll($links, $errors, $reject, 1); + + if (!empty($errors)) { + foreach ($errors as $mysqli) { + printf("[012] Error on thread %d: %s/%s\n", + mysqli_thread_id($mysqli), + mysqli_errno($mysqli), + mysqli_error($mysqli)); + } + break; + } + + if (FALSE === $ready) { + printf("[013] MySQLi indicates some error\n"); + break; + } + + if (!empty($reject)) { + foreach ($reject as $mysqli) { + printf("[014] Rejecting thread %d: %s/%s\n", + mysqli_thread_id($mysqli), + mysqli_errno($mysqli), + mysqli_error($mysqli)); + } + $processed += count($reject); + } + + foreach ($links as $mysqli) { + if (is_object($res = mysqli_reap_async_query($mysqli))) { + printf("Fetching from thread %d...\n", mysqli_thread_id($mysqli)); + var_dump(mysqli_fetch_assoc($res)); + } else if (mysqli_errno($mysqli) > 0) { + printf("[015] %d/%s\n", mysqli_errno($mysqli), mysqli_error($mysqli)); + } + $processed++; + } + + if ((microtime(true) - $begin) > 5) { + printf("[016] Pulling the emergency break after 5s, something is wrong...\n"); + break; + } + + } while ($processed < 2); + + + // Killing connection - 3 + + $link = get_connection(); + $thread_id = mysqli_thread_id($link); + mysqli_kill(get_connection(), $thread_id); + // Sleep 0.1s to ensure the KILL gets recognized + usleep(100000); + if (false !== ($tmp = mysqli_query($link, "SELECT 1 AS 'processed before killed'", MYSQLI_ASYNC | MYSQLI_USE_RESULT))) + printf("[017] Expecting boolean/false got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + $links = array($link); + $errors = array($link); + $reject = array($link); + + if (0 !== ($tmp = (mysqli_poll($links, $errors, $reject, 0, 10000)))) + printf("[018] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + if (!is_array($links) || empty($links)) + printf("[019] Expecting non-empty array got %s/%s\n", gettype($links), var_export($links, true)); + else + foreach ($links as $link) { + if (is_object($res = mysqli_reap_async_query($link))) { + // No, you cannot fetch the result + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + } else if ($link->errno > 0) { + // But you are supposed to handle the error the way its shown here! + printf("[020] Error: %d/%s\n", $link->errno, $link->error); + } + } + + // None of these will indicate an error, check errno on the list of returned connections! + if (!is_array($errors) || !empty($errors)) + printf("[021] Expecting non-empty array got %s/%s\n", gettype($errors), var_export($errors, true)); + + if (!is_array($reject) || !empty($reject)) + printf("[021] Expecting empty array got %s/%s\n", gettype($reject), var_export($reject, true)); + + + mysqli_close($link); + print "done!"; ?> --XFAIL-- To be fixed later. Minor issue about fetching error message from killed line diff --git a/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt b/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt index bfe780a9cd1a..13dcb1209314 100644 --- a/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt +++ b/ext/mysqli/tests/mysqli_poll_mixing_insert_select.phpt @@ -12,150 +12,150 @@ if (!$IS_MYSQLND) ?> --FILE-- 3', - 'UPDATE_FIX test SET id = 101 WHERE id > 3', - 'DROP TABLE IF EXISTS bogus', - 'DELETE FROM test WHERE id = @a', - 'DELETE FROM test WHERE id = 1', - ); - - $link = get_connection(); - $have_proc = false; - mysqli_real_query($link, "DROP PROCEDURE IF EXISTS p"); - if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25), OUT ver_out VARCHAR(25)) BEGIN SELECT ver_in INTO ver_out; END;')) { - $have_proc = true; - $queries[] = "CALL p('myversion', @version)"; - } - mysqli_close($link); - - $links = array(); - for ($i = 0; $i < count($queries); $i++) { - - $link = get_connection(); - - if (true !== ($tmp = mysqli_query($link, $queries[$i], MYSQLI_ASYNC | MYSQLI_USE_RESULT))) - printf("[002] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true)); - - // WARNING KLUDGE NOTE - // Add a tiny delay to ensure that queries get executed in a certain order - // If your MySQL server is very slow the test may randomly fail! - usleep(20000); - - $links[mysqli_thread_id($link)] = array( - 'query' => $queries[$i], - 'link' => $link, - 'processed' => false, - ); - } - - $saved_errors = array(); - do { - $poll_links = $poll_errors = $poll_reject = array(); - foreach ($links as $thread_id => $link) { - if (!$link['processed']) { - $poll_links[] = $link['link']; - $poll_errors[] = $link['link']; - $poll_reject[] = $link['link']; - } - } - if (0 == count($poll_links)) - break; - - if (0 === ($num_ready = mysqli_poll($poll_links, $poll_errors, $poll_reject, 0, 200000))) - continue; - - if (!empty($poll_errors)) { - die(var_dump($poll_errors)); - } - - if (FALSE === $num_ready) { - die("Some mysqli indicated error"); - } - - foreach ($poll_links as $link) { - $thread_id = mysqli_thread_id($link); - $links[$thread_id]['processed'] = true; - - if (is_object($res = mysqli_reap_async_query($link))) { - // result set object - while ($row = mysqli_fetch_assoc($res)) { - // eat up all results - ; - } - mysqli_free_result($res); - } else { - // either there is no result (no SELECT) or there is an error - if (mysqli_errno($link) > 0) { - $saved_errors[$thread_id] = mysqli_errno($link); - printf("[003] '%s' caused %d\n", $links[$thread_id]['query'], mysqli_errno($link)); - } - } - } - - } while (true); - - // Checking if all lines are still usable - foreach ($links as $thread_id => $link) { - if (isset($saved_errors[$thread_id]) && - $saved_errors[$thread_id] != mysqli_errno($link['link'])) { - printf("[004] Error state not saved for query '%s', %d != %d\n", $link['query'], - $saved_errors[$thread_id], mysqli_errno($link['link'])); - } - - if (!$res = mysqli_query($link['link'], 'SELECT * FROM test WHERE id = 100')) - printf("[005] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true)); - if (!$row = mysqli_fetch_row($res)) - printf("[006] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true)); - - mysqli_free_result($res); - } - - if ($res = mysqli_query($link['link'], "SELECT * FROM test WHERE id = 100")) { - $row = mysqli_fetch_assoc($res); - var_dump($row); - mysqli_free_result($res); - } - - if ($have_proc && ($res = mysqli_query($link['link'], "SELECT @version as _version"))) { - $row = mysqli_fetch_assoc($res); - if ($row['_version'] != 'myversion') { - printf("[007] Check procedures\n"); - } - mysqli_free_result($res); - } - - foreach ($links as $link) - mysqli_close($link['link']); - - $link = get_connection(); - if (!mysqli_query($link, 'SELECT 1', MYSQLI_ASYNC)) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_query($link, 'SELECT 1', MYSQLI_ASYNC)) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - mysqli_close($link); - - print "done!"; + require_once('table.inc'); + + function get_connection() { + global $host, $user, $passwd, $db, $port, $socket; + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + return $link; + } + + + // Note: some queries will fail! They are supposed to fail. + $queries = array( + 'CREATE TABLE IF NOT EXISTS bogus(id INT)', + 'SET @a = 1', + 'SELECT * FROM test ORDER BY id ASC LIMIT 2', + "INSERT INTO test(id, label) VALUES (100, 'z')", + 'SELECT * FROM test ORDER BY id ASC LIMIT 2', + 'SELECT', + 'UPDATE test SET id = 101 WHERE id > 3', + 'UPDATE_FIX test SET id = 101 WHERE id > 3', + 'DROP TABLE IF EXISTS bogus', + 'DELETE FROM test WHERE id = @a', + 'DELETE FROM test WHERE id = 1', + ); + + $link = get_connection(); + $have_proc = false; + mysqli_real_query($link, "DROP PROCEDURE IF EXISTS p"); + if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25), OUT ver_out VARCHAR(25)) BEGIN SELECT ver_in INTO ver_out; END;')) { + $have_proc = true; + $queries[] = "CALL p('myversion', @version)"; + } + mysqli_close($link); + + $links = array(); + for ($i = 0; $i < count($queries); $i++) { + + $link = get_connection(); + + if (true !== ($tmp = mysqli_query($link, $queries[$i], MYSQLI_ASYNC | MYSQLI_USE_RESULT))) + printf("[002] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + // WARNING KLUDGE NOTE + // Add a tiny delay to ensure that queries get executed in a certain order + // If your MySQL server is very slow the test may randomly fail! + usleep(20000); + + $links[mysqli_thread_id($link)] = array( + 'query' => $queries[$i], + 'link' => $link, + 'processed' => false, + ); + } + + $saved_errors = array(); + do { + $poll_links = $poll_errors = $poll_reject = array(); + foreach ($links as $thread_id => $link) { + if (!$link['processed']) { + $poll_links[] = $link['link']; + $poll_errors[] = $link['link']; + $poll_reject[] = $link['link']; + } + } + if (0 == count($poll_links)) + break; + + if (0 === ($num_ready = mysqli_poll($poll_links, $poll_errors, $poll_reject, 0, 200000))) + continue; + + if (!empty($poll_errors)) { + die(var_dump($poll_errors)); + } + + if (FALSE === $num_ready) { + die("Some mysqli indicated error"); + } + + foreach ($poll_links as $link) { + $thread_id = mysqli_thread_id($link); + $links[$thread_id]['processed'] = true; + + if (is_object($res = mysqli_reap_async_query($link))) { + // result set object + while ($row = mysqli_fetch_assoc($res)) { + // eat up all results + ; + } + mysqli_free_result($res); + } else { + // either there is no result (no SELECT) or there is an error + if (mysqli_errno($link) > 0) { + $saved_errors[$thread_id] = mysqli_errno($link); + printf("[003] '%s' caused %d\n", $links[$thread_id]['query'], mysqli_errno($link)); + } + } + } + + } while (true); + + // Checking if all lines are still usable + foreach ($links as $thread_id => $link) { + if (isset($saved_errors[$thread_id]) && + $saved_errors[$thread_id] != mysqli_errno($link['link'])) { + printf("[004] Error state not saved for query '%s', %d != %d\n", $link['query'], + $saved_errors[$thread_id], mysqli_errno($link['link'])); + } + + if (!$res = mysqli_query($link['link'], 'SELECT * FROM test WHERE id = 100')) + printf("[005] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true)); + if (!$row = mysqli_fetch_row($res)) + printf("[006] Expecting true got %s/%s\n", gettype($tmp), var_export($tmp, true)); + + mysqli_free_result($res); + } + + if ($res = mysqli_query($link['link'], "SELECT * FROM test WHERE id = 100")) { + $row = mysqli_fetch_assoc($res); + var_dump($row); + mysqli_free_result($res); + } + + if ($have_proc && ($res = mysqli_query($link['link'], "SELECT @version as _version"))) { + $row = mysqli_fetch_assoc($res); + if ($row['_version'] != 'myversion') { + printf("[007] Check procedures\n"); + } + mysqli_free_result($res); + } + + foreach ($links as $link) + mysqli_close($link['link']); + + $link = get_connection(); + if (!mysqli_query($link, 'SELECT 1', MYSQLI_ASYNC)) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_query($link, 'SELECT 1', MYSQLI_ASYNC)) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + mysqli_close($link); + + print "done!"; ?> --CLEAN-- --FILE-- 10) { - printf("[002] The queries should have finished already\n"); - break; - } - // WARNING: All arrays point to the same object - this will give bogus results! - // The behaviour is in line with stream_select(). Be warned, be careful. - $links = $errors = $reject = array($mysqli1, $mysqli2); - if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { - continue; - } - - foreach ($links as $link) { - if ($res = mysqli_reap_async_query($link)) { - mysqli_free_result($res); - } - $processed++; - } - } while ($processed < 2); - - mysqli_close($mysqli1); - mysqli_close($mysqli2); - - $mysqli1 = get_connection(); - $mysqli2 = get_connection(); - - var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - - $processed = $loops = 0; - do { - $loops++; - if ($loops > 10) { - printf("[003] The queries should have finished already\n"); - break; - } - // WARNING: All arrays point to the same object - this will give bogus results! - $links = $errors = array($mysqli1, $mysqli2); - $reject = array($mysqli1, $mysqli2); - if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { - continue; - } - foreach ($links as $link) { - if ($res = mysqli_reap_async_query($link)) { - mysqli_free_result($res); - } - $processed++; - } - } while ($processed < 2); - - mysqli_close($mysqli1); - mysqli_close($mysqli2); - - $mysqli1 = get_connection(); - $mysqli2 = get_connection(); - - var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - - $processed = $loops = 0; - do { - $loops++; - if ($loops > 10) { - printf("[004] The queries should have finished already\n"); - break; - } - // WARNING: All arrays point to the same object - this will give bogus results! - $links = array($mysqli1, $mysqli2); - $errors = $reject = array($mysqli1, $mysqli2); - if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { - continue; - } - foreach ($links as $link) { - if ($res = mysqli_reap_async_query($link)) { - mysqli_free_result($res); - } - $processed++; - } - } while ($processed < 2); - - mysqli_close($mysqli1); - mysqli_close($mysqli2); - - // This is bogus code and bogus usage - OK to throw no errors! - $mysqli1 = get_connection(); - $mysqli2 = get_connection(); - - var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - $thread_id = mysqli_thread_id($mysqli2); - printf("Connection %d should be rejected...\n", $thread_id); - - $processed = $loops = 0; - do { - $loops++; - if ($loops > 10) { - printf("[005] The queries should have finished already\n"); - break; - } - $links = $errors = $reject = array($mysqli1, $mysqli2); - if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { - continue; - } - // WARNING: Due to the reference issue none of these should ever fire! - foreach ($reject as $link) { - printf("Connection %d was rejected...\n", mysqli_thread_id($link)); + require_once('connect.inc'); + + function get_connection() { + global $host, $user, $passwd, $db, $port, $socket; + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + return $link; + } + + + $mysqli1 = get_connection(); + $mysqli2 = get_connection(); + + var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + + $processed = $loops = 0; + do { + $loops++; + if ($loops > 10) { + printf("[002] The queries should have finished already\n"); + break; + } + // WARNING: All arrays point to the same object - this will give bogus results! + // The behaviour is in line with stream_select(). Be warned, be careful. + $links = $errors = $reject = array($mysqli1, $mysqli2); + if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { + continue; + } + + foreach ($links as $link) { + if ($res = mysqli_reap_async_query($link)) { + mysqli_free_result($res); + } + $processed++; + } + } while ($processed < 2); + + mysqli_close($mysqli1); + mysqli_close($mysqli2); + + $mysqli1 = get_connection(); + $mysqli2 = get_connection(); + + var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + + $processed = $loops = 0; + do { + $loops++; + if ($loops > 10) { + printf("[003] The queries should have finished already\n"); + break; + } + // WARNING: All arrays point to the same object - this will give bogus results! + $links = $errors = array($mysqli1, $mysqli2); + $reject = array($mysqli1, $mysqli2); + if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { + continue; + } + foreach ($links as $link) { + if ($res = mysqli_reap_async_query($link)) { + mysqli_free_result($res); + } + $processed++; + } + } while ($processed < 2); + + mysqli_close($mysqli1); + mysqli_close($mysqli2); + + $mysqli1 = get_connection(); + $mysqli2 = get_connection(); + + var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + + $processed = $loops = 0; + do { + $loops++; + if ($loops > 10) { + printf("[004] The queries should have finished already\n"); + break; + } + // WARNING: All arrays point to the same object - this will give bogus results! + $links = array($mysqli1, $mysqli2); + $errors = $reject = array($mysqli1, $mysqli2); + if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { + continue; + } + foreach ($links as $link) { + if ($res = mysqli_reap_async_query($link)) { + mysqli_free_result($res); + } + $processed++; + } + } while ($processed < 2); + + mysqli_close($mysqli1); + mysqli_close($mysqli2); + + // This is bogus code and bogus usage - OK to throw no errors! + $mysqli1 = get_connection(); + $mysqli2 = get_connection(); + + var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + $thread_id = mysqli_thread_id($mysqli2); + printf("Connection %d should be rejected...\n", $thread_id); + + $processed = $loops = 0; + do { + $loops++; + if ($loops > 10) { + printf("[005] The queries should have finished already\n"); + break; + } + $links = $errors = $reject = array($mysqli1, $mysqli2); + if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { + continue; + } + // WARNING: Due to the reference issue none of these should ever fire! + foreach ($reject as $link) { + printf("Connection %d was rejected...\n", mysqli_thread_id($link)); if (mysqli_thread_id($link) != $thread_id) { printf("[006] Connector %d should have been rejected. But also %d has been rejected.", $thread_id, mysqli_thread_id($link)); } - $processed++; - } - foreach ($errors as $link) { - printf("Connection %d has an error...\n", mysqli_thread_id($link)); - $processed++; - } - foreach ($links as $link) { - if ($res = mysqli_reap_async_query($link)) { - mysqli_free_result($res); - $processed++; - } - } - } while ($processed < 2); - - mysqli_close($mysqli1); - mysqli_close($mysqli2); - - $mysqli1 = get_connection(); - $mysqli2 = get_connection(); - - var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); - - $processed = $loops = 0; - $all = array($mysqli1, $mysqli2); - do { - $loops++; - if ($loops > 10) { - printf("[006] The queries should have finished already\n"); - break; - } - $links = $errors = $reject = $all; - ob_start(); - if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { - $tmp = ob_get_contents(); - ob_end_clean(); - if ($tmp != '') { - printf("Expected error:\n%s\n", $tmp); - break; - } - continue; - } - foreach ($links as $link) { - if ($res = mysqli_reap_async_query($link)) { - mysqli_free_result($res); - } - $processed++; - } - } while ($processed < 2); - - $ready = mysqli_poll($links, $errors, $reject, 0, 50000); - mysqli_close($mysqli1); - mysqli_close($mysqli2); - - print "done!"; + $processed++; + } + foreach ($errors as $link) { + printf("Connection %d has an error...\n", mysqli_thread_id($link)); + $processed++; + } + foreach ($links as $link) { + if ($res = mysqli_reap_async_query($link)) { + mysqli_free_result($res); + $processed++; + } + } + } while ($processed < 2); + + mysqli_close($mysqli1); + mysqli_close($mysqli2); + + $mysqli1 = get_connection(); + $mysqli2 = get_connection(); + + var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); + + $processed = $loops = 0; + $all = array($mysqli1, $mysqli2); + do { + $loops++; + if ($loops > 10) { + printf("[006] The queries should have finished already\n"); + break; + } + $links = $errors = $reject = $all; + ob_start(); + if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { + $tmp = ob_get_contents(); + ob_end_clean(); + if ($tmp != '') { + printf("Expected error:\n%s\n", $tmp); + break; + } + continue; + } + foreach ($links as $link) { + if ($res = mysqli_reap_async_query($link)) { + mysqli_free_result($res); + } + $processed++; + } + } while ($processed < 2); + + $ready = mysqli_poll($links, $errors, $reject, 0, 50000); + mysqli_close($mysqli1); + mysqli_close($mysqli2); + + print "done!"; ?> --EXPECTF-- bool(true) diff --git a/ext/mysqli/tests/mysqli_prepare.phpt b/ext/mysqli/tests/mysqli_prepare.phpt index c6400e0b17e1..7c2ab21d6b4e 100644 --- a/ext/mysqli/tests/mysqli_prepare.phpt +++ b/ext/mysqli/tests/mysqli_prepare.phpt @@ -8,97 +8,97 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- ?'))) - printf("[005] Expecting boolean/false, got %s, [%d] %s\n", gettype($tmp), mysqli_errno($link), mysqli_error($link)); + if (false !== ($tmp = mysqli_prepare($link, 'SELECT id FROM test WHERE id > ?'))) + printf("[005] Expecting boolean/false, got %s, [%d] %s\n", gettype($tmp), mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + mysqli_free_result($res); - if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id FROM test'))) || !mysqli_stmt_execute($stmt)) - printf("[006][%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id FROM test'))) || !mysqli_stmt_execute($stmt)) + printf("[006][%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!mysqli_query($link, "DROP TABLE IF EXISTS test2")) - printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test2")) + printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_object(($stmt = mysqli_prepare($link, 'CREATE TABLE test2(id INT) ENGINE =' . $engine))) || !mysqli_stmt_execute($stmt)) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + if (!is_object(($stmt = mysqli_prepare($link, 'CREATE TABLE test2(id INT) ENGINE =' . $engine))) || !mysqli_stmt_execute($stmt)) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, 'INSERT INTO test2(id) VALUES(?)')))) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object(($stmt = mysqli_prepare($link, 'INSERT INTO test2(id) VALUES(?)')))) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $id = 1; - if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + $id = 1; + if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, 'REPLACE INTO test2(id) VALUES (?)')))) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object(($stmt = mysqli_prepare($link, 'REPLACE INTO test2(id) VALUES (?)')))) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $id = 2; - if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + $id = 2; + if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt)) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, 'UPDATE test2 SET id = ? WHERE id = ?')))) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object(($stmt = mysqli_prepare($link, 'UPDATE test2 SET id = ? WHERE id = ?')))) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $id = 3; - $where = 2; - if (!mysqli_stmt_bind_param($stmt, 'ii', $id, $where) || !mysqli_stmt_execute($stmt)) - printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + $id = 3; + $where = 2; + if (!mysqli_stmt_bind_param($stmt, 'ii', $id, $where) || !mysqli_stmt_execute($stmt)) + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, 'DELETE FROM test2 WHERE id = ?')))) - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object(($stmt = mysqli_prepare($link, 'DELETE FROM test2 WHERE id = ?')))) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $where = 3; - if (!mysqli_stmt_bind_param($stmt, 'i', $where) || !mysqli_stmt_execute($stmt)) - printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + $where = 3; + if (!mysqli_stmt_bind_param($stmt, 'i', $where) || !mysqli_stmt_execute($stmt)) + printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, 'SET @testvar = ?')))) - printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object(($stmt = mysqli_prepare($link, 'SET @testvar = ?')))) + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $testvar = 'testvar'; - if (!mysqli_stmt_bind_param($stmt, 's', $testvar) || !mysqli_stmt_execute($stmt)) - printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + $testvar = 'testvar'; + if (!mysqli_stmt_bind_param($stmt, 's', $testvar) || !mysqli_stmt_execute($stmt)) + printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, "DO GET_LOCK('testlock', 1)")))) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_stmt_close($stmt); + if (!is_object(($stmt = mysqli_prepare($link, "DO GET_LOCK('testlock', 1)")))) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); - if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id, @testvar FROM test2')))) - printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!is_object(($stmt = mysqli_prepare($link, 'SELECT id, @testvar FROM test2')))) + printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $id = $testvar = null; - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $id, $testvar)) - printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - while (mysqli_stmt_fetch($stmt)) { - if (('testvar' !== $testvar) || (1 !== $id)) - printf("[022] Expecting 'testvar'/1, got %s/%s. [%d] %s\n", - $testvar, $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } + $id = $testvar = null; + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_bind_result($stmt, $id, $testvar)) + printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + while (mysqli_stmt_fetch($stmt)) { + if (('testvar' !== $testvar) || (1 !== $id)) + printf("[022] Expecting 'testvar'/1, got %s/%s. [%d] %s\n", + $testvar, $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } - var_dump(mysqli_stmt_prepare($stmt, 'SELECT 1; SELECT 2')); + var_dump(mysqli_stmt_prepare($stmt, 'SELECT 1; SELECT 2')); - mysqli_stmt_close($stmt); - mysqli_close($link); + mysqli_stmt_close($stmt); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- prepare(false))) - printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); - printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); + if (false !== ($tmp = $mysqli->prepare(false))) + printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); + printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); - if (false !== ($tmp = $mysqli->prepare(''))) - printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); - printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); + if (false !== ($tmp = $mysqli->prepare(''))) + printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp)); + printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) - printf("[001] [%d] %s\n", $link->errno, $link->error); - - $data = array(); - while ($row = $res->fetch_assoc()) { - $data[] = $row['column1']; - var_dump($row['column1']); - } - $res->free(); - - // Prepared Statements - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) - printf("[002] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->execute() || !$stmt->bind_result($column1)) - printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[004] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; - } - $stmt->close(); - - if ($IS_MYSQLND) { - /* - Advantage mysqlnd - - The metadata mysqlnd has available after prepare is better than - the one made available by the MySQL Client Library (libmysql). - "libmysql" will give wrong results and that is OK - - http://bugs.mysql.com/bug.php?id=47483 - */ - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) - printf("[005] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - /* Note: bind_result before execute */ - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[007] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; - } - $stmt->close(); - } - - // Regular (non-prepared) queries - print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n"; - if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) - printf("[008] [%d] %s\n", $link->errno, $link->error); - - $data = array(); - while ($row = $res->fetch_assoc()) { - $data[] = $row['column1']; - } - $res->free(); - - // Prepared Statements - if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) - printf("[009] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->execute() || !$stmt->bind_result($column1)) - printf("[010] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[011] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - var_dump($column1); - $index++; - } - $stmt->close(); - - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above... */ - if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) - printf("[012] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[013] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[014] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; - } - $stmt->close(); - } - - print "Using integer only...\n"; - if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) - printf("[015] [%d] %s\n", $link->errno, $link->error); - - $data = array(); - while ($row = $res->fetch_assoc()) { - $data[] = $row['column1']; - } - $res->free(); - - // Prepared Statements - if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) - printf("[016] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->execute() || !$stmt->bind_result($column1)) - printf("[017] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[018] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - var_dump($column1); - $index++; - } - $stmt->close(); - - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above */ - if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) - printf("[019] [%d] %s\n", $link->errno, $link->error); - - $column1 = null; - if (!$stmt->bind_result($column1) || !$stmt->execute()) - printf("[020] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[021] Row %d, expecting %s/%s got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; - } - $stmt->close(); - } - - print "Testing bind_param(), strings only...\n"; - $two = 'two'; - $three = 'three'; - if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?"))) - printf("[022] [%d] %s\n", $stmt->errno, $stmt->error); - - $column1 = null; - if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1)) - printf("[023] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - $data = array(); - while ($stmt->fetch()) { - $data[$index++] = $column1; - var_dump($column1); - } - $stmt->close(); - - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above */ - $two = 'two'; - $three = 'three'; - if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?"))) - printf("[024] [%d] %s\n", $stmt->errno, $stmt->error); - - $column1 = null; - if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) - printf("[025] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[26] Row %d, expecting %s/%s, got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; - } - $stmt->close(); - } - - print "Testing bind_param(), strings only, with CAST AS CHAR...\n"; - $two = 'two'; - $three = 'three beers are more than enough'; - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)"))) - printf("[027] [%d] %s\n", $stmt->errno, $stmt->error); - - $column1 = null; - if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1)) - printf("[028] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - $data = array(); - while ($stmt->fetch()) { - $data[$index++] = $column1; - var_dump($column1); - } - $stmt->close(); - - if ($IS_MYSQLND) { - /* Advantage mysqlnd - see above */ - $two = 'two'; - $three = 'three beers are more than enough'; - if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)"))) - printf("[029] [%d] %s\n", $stmt->errno, $stmt->error); - - $column1 = null; - if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) - printf("[030] [%d] %s\n", $stmt->errno, $stmt->error); - - $index = 0; - while ($stmt->fetch()) { - if ($data[$index] != $column1) { - printf("[31] Row %d, expecting %s/%s, got %s/%s\n", - $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); - } - $index++; - } - $stmt->close(); - } - - $link->close(); - - print "done!"; + require_once("connect.inc"); + require_once("table.inc"); + + // Regular (non-prepared) queries + print "Using CAST('somestring' AS CHAR)...\n"; + if (!($res = $link->query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) + printf("[001] [%d] %s\n", $link->errno, $link->error); + + $data = array(); + while ($row = $res->fetch_assoc()) { + $data[] = $row['column1']; + var_dump($row['column1']); + } + $res->free(); + + // Prepared Statements + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) + printf("[002] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->execute() || !$stmt->bind_result($column1)) + printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[004] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + $index++; + } + $stmt->close(); + + if ($IS_MYSQLND) { + /* + Advantage mysqlnd - + The metadata mysqlnd has available after prepare is better than + the one made available by the MySQL Client Library (libmysql). + "libmysql" will give wrong results and that is OK - + http://bugs.mysql.com/bug.php?id=47483 + */ + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)"))) + printf("[005] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + /* Note: bind_result before execute */ + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[007] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + $index++; + } + $stmt->close(); + } + + // Regular (non-prepared) queries + print "Mixing CAST('somestring'AS CHAR), integer and CAST(integer AS CHAR)...\n"; + if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) + printf("[008] [%d] %s\n", $link->errno, $link->error); + + $data = array(); + while ($row = $res->fetch_assoc()) { + $data[] = $row['column1']; + } + $res->free(); + + // Prepared Statements + if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) + printf("[009] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->execute() || !$stmt->bind_result($column1)) + printf("[010] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[011] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + var_dump($column1); + $index++; + } + $stmt->close(); + + if ($IS_MYSQLND) { + /* Advantage mysqlnd - see above... */ + if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST(2 AS CHAR)"))) + printf("[012] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[013] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[014] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + $index++; + } + $stmt->close(); + } + + print "Using integer only...\n"; + if (!($res = $link->query("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) + printf("[015] [%d] %s\n", $link->errno, $link->error); + + $data = array(); + while ($row = $res->fetch_assoc()) { + $data[] = $row['column1']; + } + $res->free(); + + // Prepared Statements + if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) + printf("[016] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->execute() || !$stmt->bind_result($column1)) + printf("[017] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[018] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + var_dump($column1); + $index++; + } + $stmt->close(); + + if ($IS_MYSQLND) { + /* Advantage mysqlnd - see above */ + if (!($stmt = $link->prepare("SELECT 1 AS column1 UNION SELECT 303 UNION SELECT 2"))) + printf("[019] [%d] %s\n", $link->errno, $link->error); + + $column1 = null; + if (!$stmt->bind_result($column1) || !$stmt->execute()) + printf("[020] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[021] Row %d, expecting %s/%s got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + $index++; + } + $stmt->close(); + } + + print "Testing bind_param(), strings only...\n"; + $two = 'two'; + $three = 'three'; + if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?"))) + printf("[022] [%d] %s\n", $stmt->errno, $stmt->error); + + $column1 = null; + if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1)) + printf("[023] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + $data = array(); + while ($stmt->fetch()) { + $data[$index++] = $column1; + var_dump($column1); + } + $stmt->close(); + + if ($IS_MYSQLND) { + /* Advantage mysqlnd - see above */ + $two = 'two'; + $three = 'three'; + if (!($stmt = $link->prepare("SELECT 'one' AS column1 UNION SELECT ? UNION SELECT ?"))) + printf("[024] [%d] %s\n", $stmt->errno, $stmt->error); + + $column1 = null; + if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) + printf("[025] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[26] Row %d, expecting %s/%s, got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + $index++; + } + $stmt->close(); + } + + print "Testing bind_param(), strings only, with CAST AS CHAR...\n"; + $two = 'two'; + $three = 'three beers are more than enough'; + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)"))) + printf("[027] [%d] %s\n", $stmt->errno, $stmt->error); + + $column1 = null; + if (!$stmt->bind_param('ss', $three, $two) || !$stmt->execute() || !$stmt->bind_result($column1)) + printf("[028] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + $data = array(); + while ($stmt->fetch()) { + $data[$index++] = $column1; + var_dump($column1); + } + $stmt->close(); + + if ($IS_MYSQLND) { + /* Advantage mysqlnd - see above */ + $two = 'two'; + $three = 'three beers are more than enough'; + if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST(? AS CHAR) UNION SELECT CAST(? AS CHAR)"))) + printf("[029] [%d] %s\n", $stmt->errno, $stmt->error); + + $column1 = null; + if (!$stmt->bind_param('ss', $three, $two) || !$stmt->bind_result($column1) || !$stmt->execute()) + printf("[030] [%d] %s\n", $stmt->errno, $stmt->error); + + $index = 0; + while ($stmt->fetch()) { + if ($data[$index] != $column1) { + printf("[31] Row %d, expecting %s/%s, got %s/%s\n", + $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1); + } + $index++; + } + $stmt->close(); + } + + $link->close(); + + print "done!"; ?> --EXPECT-- Using CAST('somestring' AS CHAR)... diff --git a/ext/mysqli/tests/mysqli_query.phpt b/ext/mysqli/tests/mysqli_query.phpt index be2f6f75a345..ba159cf9852e 100644 --- a/ext/mysqli/tests/mysqli_query.phpt +++ b/ext/mysqli/tests/mysqli_query.phpt @@ -8,87 +8,87 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- 50000) { - // let's try to play with stored procedures - mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'); - if (mysqli_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { - $res = mysqli_query($link, 'CALL p(@version)'); - $res = mysqli_query($link, 'SELECT @version AS p_version'); + if (mysqli_get_server_version($link) > 50000) { + // let's try to play with stored procedures + mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'); + if (mysqli_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { + $res = mysqli_query($link, 'CALL p(@version)'); + $res = mysqli_query($link, 'SELECT @version AS p_version'); - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { - printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { + printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } - mysqli_free_result($res); - } else { - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + mysqli_free_result($res); + } else { + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_query($link, 'DROP FUNCTION IF EXISTS f'); - if (mysqli_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { - $res = mysqli_query($link, 'SELECT f(VERSION()) AS f_version'); + mysqli_query($link, 'DROP FUNCTION IF EXISTS f'); + if (mysqli_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { + $res = mysqli_query($link, 'SELECT f(VERSION()) AS f_version'); - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { - printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { + printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } - mysqli_free_result($res); - } else { - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - } + mysqli_free_result($res); + } else { + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + } - if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT))) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT))) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); - if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT))) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT))) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); - if (false !== ($res = @mysqli_query($link, "SELECT id FROM test ORDER BY id", 1234))) - printf("[013] Invalid mode should return false got %s/%s, [%d] %s\n", - gettype($res), (is_object($res)) ? 'object' : $res, - mysqli_errno($link), mysqli_error($link)); + if (false !== ($res = @mysqli_query($link, "SELECT id FROM test ORDER BY id", 1234))) + printf("[013] Invalid mode should return false got %s/%s, [%d] %s\n", + gettype($res), (is_object($res)) ? 'object' : $res, + mysqli_errno($link), mysqli_error($link)); - mysqli_close($link); + mysqli_close($link); try { mysqli_query($link, "SELECT id FROM test"); @@ -96,7 +96,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - } - echo "--- Testing USE_RESULT ---\n"; - if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT))) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - else { - foreach ($res as $row) { - var_dump($row); - } - echo "======\n"; - foreach ($res as $row) { - var_dump($row); - } - mysqli_free_result($res); - } + } + echo "--- Testing USE_RESULT ---\n"; + if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT))) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + else { + foreach ($res as $row) { + var_dump($row); + } + echo "======\n"; + foreach ($res as $row) { + var_dump($row); + } + mysqli_free_result($res); + } - echo "--- Testing STORE_RESULT ---\n"; - if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT))) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - else { - foreach ($res as $row) { - var_dump($row); - } - echo "======\n"; - foreach ($res as $row) { - var_dump($row); - } - mysqli_free_result($res); - } + echo "--- Testing STORE_RESULT ---\n"; + if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT))) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + else { + foreach ($res as $row) { + var_dump($row); + } + echo "======\n"; + foreach ($res as $row) { + var_dump($row); + } + mysqli_free_result($res); + } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- 50000) { - // let's try to play with stored procedures - mysqli_query($link, 'DROP PROCEDURE IF EXISTS процедурка'); - if (mysqli_query($link, 'CREATE PROCEDURE процедурка(OUT верÑÐ¸Ñ VARCHAR(25)) BEGIN SELECT VERSION() INTO верÑиÑ; END;')) { - $res = mysqli_query($link, 'CALL процедурка(@version)'); - $res = mysqli_query($link, 'SELECT @version AS п_верÑиÑ'); + if (mysqli_get_server_version($link) > 50000) { + // let's try to play with stored procedures + mysqli_query($link, 'DROP PROCEDURE IF EXISTS процедурка'); + if (mysqli_query($link, 'CREATE PROCEDURE процедурка(OUT верÑÐ¸Ñ VARCHAR(25)) BEGIN SELECT VERSION() INTO верÑиÑ; END;')) { + $res = mysqli_query($link, 'CALL процедурка(@version)'); + $res = mysqli_query($link, 'SELECT @version AS п_верÑиÑ'); - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['п_верÑиÑ']) || ('' == $tmp['п_верÑиÑ'])) { - printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['п_верÑиÑ']) || ('' == $tmp['п_верÑиÑ'])) { + printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } - mysqli_free_result($res); - } else { - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + mysqli_free_result($res); + } else { + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_query($link, 'DROP FUNCTION IF EXISTS функцийка'); - if (mysqli_query($link, 'CREATE FUNCTION функцийка( параметър_верÑÐ¸Ñ VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN параметър_верÑиÑ;')) { - $res = mysqli_query($link, 'SELECT функцийка(VERSION()) AS Ñ„_верÑиÑ'); + mysqli_query($link, 'DROP FUNCTION IF EXISTS функцийка'); + if (mysqli_query($link, 'CREATE FUNCTION функцийка( параметър_верÑÐ¸Ñ VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN параметър_верÑиÑ;')) { + $res = mysqli_query($link, 'SELECT функцийка(VERSION()) AS Ñ„_верÑиÑ'); - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['Ñ„_верÑиÑ']) || ('' == $tmp['Ñ„_верÑиÑ'])) { - printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['Ñ„_верÑиÑ']) || ('' == $tmp['Ñ„_верÑиÑ'])) { + printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } - mysqli_free_result($res); - } else { - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - } + mysqli_free_result($res); + } else { + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + } - mysqli_close($link); + mysqli_close($link); - try { + try { mysqli_query($link, "SELECT id FROM test"); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECTF-- array(1) { diff --git a/ext/mysqli/tests/mysqli_real_connect.phpt b/ext/mysqli/tests/mysqli_real_connect.phpt index 6844db4f1fda..05aeca1f6fc1 100644 --- a/ext/mysqli/tests/mysqli_real_connect.phpt +++ b/ext/mysqli/tests/mysqli_real_connect.phpt @@ -10,143 +10,143 @@ require_once('skipifconnectfailure.inc'); mysqli.allow_local_infile=1 --FILE-- num_rows); - mysqli_next_result($link); - $res = mysqli_store_result($link); - var_dump($res->num_rows); - } - - - mysqli_close($link); - if (!$link = mysqli_init()) - printf("[018] mysqli_init() failed\n"); - - if (ini_get('open_basedir')) { - // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! - - if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt'; - if (!$fp = fopen($filename, 'w')) - printf("[020] Cannot open temporary file %s\n", $filename); - - fwrite($fp, '100;z'); - fclose($fp); - - // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? - if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) - printf("[021] LOAD DATA INFILE should have been forbidden!\n"); - - unlink($filename); - } - - mysqli_close($link); - var_dump($link); - - if ($IS_MYSQLND) { - ini_set('mysqli.default_host', 'p:' . $host); - $link = mysqli_init(); - if (!@mysqli_real_connect($link)) { - printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; - } else { - if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { - printf("[024] Result looks strange - check manually, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - mysqli_free_result($res); - mysqli_close($link); - } - - ini_set('mysqli.default_host', 'p:'); - $link = mysqli_init(); - if (@mysqli_real_connect($link)) { - printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; - mysqli_close($link); - } - @mysqli_close($link); - } - - try { + include("connect.inc"); + + // ( mysqli link [, string hostname [, string username [, string passwd [, string dbname [, int port [, string socket [, int flags]]]]]]] + if (!$link = mysqli_init()) + printf("[002] mysqli_init() failed\n"); + + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) + printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[004] mysqli_init() failed\n"); + + if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))) + printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket); + + // Run the following tests without an anoynmous MySQL user and use a password for the test user! + ini_set('mysqli.default_socket', $socket); + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) { + printf("[006] Usage of mysqli.default_socket failed\n"); + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[007] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_port', $port); + if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) { + printf("[008] Usage of mysqli.default_port failed\n"); + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[009] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_pw', $passwd); + if (!mysqli_real_connect($link, $host, $user)) { + printf("[010] Usage of mysqli.default_pw failed\n") ; + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[011] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_user', $user); + if (!mysqli_real_connect($link, $host)) { + printf("[012] Usage of mysqli.default_user failed\n") ; + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[011] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_host', $host); + if (!mysqli_real_connect($link)) { + printf("[014] Usage of mysqli.default_host failed\n") ; + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[015] mysqli_init() failed\n"); + } + + // CLIENT_MULTI_STATEMENTS - should be disabled silently + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536)) + printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if ($res = mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) { + printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n"); + var_dump($res->num_rows); + mysqli_next_result($link); + $res = mysqli_store_result($link); + var_dump($res->num_rows); + } + + + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[018] mysqli_init() failed\n"); + + if (ini_get('open_basedir')) { + // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! + + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt'; + if (!$fp = fopen($filename, 'w')) + printf("[020] Cannot open temporary file %s\n", $filename); + + fwrite($fp, '100;z'); + fclose($fp); + + // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? + if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) + printf("[021] LOAD DATA INFILE should have been forbidden!\n"); + + unlink($filename); + } + + mysqli_close($link); + var_dump($link); + + if ($IS_MYSQLND) { + ini_set('mysqli.default_host', 'p:' . $host); + $link = mysqli_init(); + if (!@mysqli_real_connect($link)) { + printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; + } else { + if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { + printf("[024] Result looks strange - check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } + mysqli_free_result($res); + mysqli_close($link); + } + + ini_set('mysqli.default_host', 'p:'); + $link = mysqli_init(); + if (@mysqli_real_connect($link)) { + printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); + } + @mysqli_close($link); + } + + try { mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- num_rows); - mysqli_next_result($link); - $res = mysqli_store_result($link); - var_dump($res->num_rows); - } - - - mysqli_close($link); - if (!$link = mysqli_init()) - printf("[018] mysqli_init() failed\n"); - - if (ini_get('open_basedir')) { - // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! - - if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt'; - if (!$fp = fopen($filename, 'w')) - printf("[020] Cannot open temporary file %s\n", $filename); - - fwrite($fp, '100;z'); - fclose($fp); - - // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? - if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) - printf("[021] LOAD DATA INFILE should have been forbidden!\n"); - - unlink($filename); - } - - mysqli_close($link); - - if ($IS_MYSQLND) { - $link = mysqli_init(); - if (!@mysqli_real_connect($link)) { - printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; - } else { - if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_fetch_assoc($res); - if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { - printf("[024] Result looks strange - check manually, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - mysqli_free_result($res); - mysqli_close($link); - } - - ini_set('mysqli.default_host', 'p:'); - $link = mysqli_init(); - if (@mysqli_real_connect($link)) { - printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; - mysqli_close($link); - } - } - - if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) - printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp); - - print "done!"; + require_once("connect.inc"); + $host = 'p:' . $host; + + if (!$link = mysqli_init()) + printf("[002] mysqli_init() failed\n"); + + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) + printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[004] mysqli_init() failed\n"); + + if (false !== ($tmp = mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))) + printf("[005] Expecting boolean/false got %s/%s. Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", gettype($tmp), $tmp, $host, $user . 'unknown_really', $db, $port, $socket); + + // Run the following tests without an anoynmous MySQL user and use a password for the test user! + ini_set('mysqli.default_socket', $socket); + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port)) { + printf("[006] Usage of mysqli.default_socket failed\n"); + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[007] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_port', $port); + if (!mysqli_real_connect($link, $host, $user, $passwd, $db)) { + printf("[008] Usage of mysqli.default_port failed\n"); + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[009] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_pw', $passwd); + if (!mysqli_real_connect($link, $host, $user)) { + printf("[010] Usage of mysqli.default_pw failed\n") ; + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[011] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_user', $user); + if (!mysqli_real_connect($link, $host)) { + printf("[012] Usage of mysqli.default_user failed\n") ; + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[011] mysqli_init() failed\n"); + } + + ini_set('mysqli.default_host', $host); + if (!mysqli_real_connect($link)) { + printf("[014] Usage of mysqli.default_host failed\n") ; + } else { + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[015] mysqli_init() failed\n"); + } + + // CLIENT_MULTI_STATEMENTS - should be disabled silently + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 65536)) + printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if ($res = mysqli_query($link, "SELECT 1 AS a; SELECT 2 AS b")) { + printf("[017] Should have failed. CLIENT_MULTI_STATEMENT should have been disabled.\n"); + var_dump($res->num_rows); + mysqli_next_result($link); + $res = mysqli_store_result($link); + var_dump($res->num_rows); + } + + + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[018] mysqli_init() failed\n"); + + if (ini_get('open_basedir')) { + // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! + + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt'; + if (!$fp = fopen($filename, 'w')) + printf("[020] Cannot open temporary file %s\n", $filename); + + fwrite($fp, '100;z'); + fclose($fp); + + // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? + if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) + printf("[021] LOAD DATA INFILE should have been forbidden!\n"); + + unlink($filename); + } + + mysqli_close($link); + + if ($IS_MYSQLND) { + $link = mysqli_init(); + if (!@mysqli_real_connect($link)) { + printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; + } else { + if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { + printf("[024] Result looks strange - check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } + mysqli_free_result($res); + mysqli_close($link); + } + + ini_set('mysqli.default_host', 'p:'); + $link = mysqli_init(); + if (@mysqli_real_connect($link)) { + printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); + } + } + + if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) + printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp); + + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt b/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt index 20384d9a0f00..97113b858e8e 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_big5.phpt @@ -18,57 +18,57 @@ mysqli_close($link); ?> --FILE-- --CLEAN-- --CLEAN-- --FILE-- --CLEAN-- --CLEAN-- --CLEAN-- --FILE-- --EXPECT-- array(1) { diff --git a/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt b/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt index 9e1562dba0e9..611590af27b8 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_sjis.phpt @@ -18,33 +18,33 @@ mysqli_close($link); --FILE-- --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt index d27c09359c37..acbbc4ed8521 100644 --- a/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt +++ b/ext/mysqli/tests/mysqli_real_escape_string_unicode.phpt @@ -8,59 +8,59 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- 50000) { - // let's try to play with stored procedures - mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p'); - if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; + if (mysqli_get_server_version($link) > 50000) { + // let's try to play with stored procedures + mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p'); + if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;')) { - mysqli_real_query($link, 'CALL p(@version)'); - mysqli_real_query($link, 'SELECT @version AS p_version'); - $res = mysqli_store_result($link); - - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { - printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - - mysqli_free_result($res); - } else { - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - mysqli_real_query($link, 'DROP FUNCTION IF EXISTS f'); - if (mysqli_real_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN + mysqli_real_query($link, 'CALL p(@version)'); + mysqli_real_query($link, 'SELECT @version AS p_version'); + $res = mysqli_store_result($link); + + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { + printf("[008a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } + + mysqli_free_result($res); + } else { + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + mysqli_real_query($link, 'DROP FUNCTION IF EXISTS f'); + if (mysqli_real_query($link, 'CREATE FUNCTION f( ver_param VARCHAR(25)) RETURNS VARCHAR(25) DETERMINISTIC RETURN ver_param;')) { - mysqli_real_query($link, 'SELECT f(VERSION()) AS f_version'); - $res = mysqli_store_result($link); - - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { - printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - - mysqli_free_result($res); - } else { - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - } + mysqli_real_query($link, 'SELECT f(VERSION()) AS f_version'); + $res = mysqli_store_result($link); + + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['f_version']) || ('' == $tmp['f_version'])) { + printf("[009a] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } + + mysqli_free_result($res); + } else { + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + } - mysqli_close($link); + mysqli_close($link); try { mysqli_real_query($link, "SELECT id FROM test"); @@ -78,7 +78,7 @@ ver_param;')) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- reap_async_query(); - } else { - $res = mysqli_reap_async_query($mysqli); - } - if (is_object($res)) { - printf("[%03d + 2] %s\n", $offset, var_export($res->fetch_assoc(), true)); - } else if (mysqli_errno($mysqli) > 0) { - printf("[%03d + 3] Error indicated through links array: %d/%s", - $offset, mysqli_errno($mysqli), mysqli_error($mysqli)); - } else { - printf("[%03d + 4] Cannot fetch and no error set - non resultset query (no SELECT)!\n", $offset); - } - } + foreach ($links as $mysqli) { + if ($use_oo_syntax) { + $res = $mysqli->reap_async_query(); + } else { + $res = mysqli_reap_async_query($mysqli); + } + if (is_object($res)) { + printf("[%03d + 2] %s\n", $offset, var_export($res->fetch_assoc(), true)); + } else if (mysqli_errno($mysqli) > 0) { + printf("[%03d + 3] Error indicated through links array: %d/%s", + $offset, mysqli_errno($mysqli), mysqli_error($mysqli)); + } else { + printf("[%03d + 4] Cannot fetch and no error set - non resultset query (no SELECT)!\n", $offset); + } + } - foreach ($errors as $mysqli) - printf("[%03d + 5] Error on %d: %d/%s\n", - $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); + foreach ($errors as $mysqli) + printf("[%03d + 5] Error on %d: %d/%s\n", + $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); - foreach ($reject as $mysqli) - printf("[%03d + 6] Rejecting thread %d: %d/%s\n", - $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); + foreach ($reject as $mysqli) + printf("[%03d + 6] Rejecting thread %d: %d/%s\n", + $offset, mysqli_thread_id($mysqli), mysqli_errno($mysqli), mysqli_error($mysqli)); - } + } - // Connections on which no query has been send - 1 - $link = get_connection(); - $link->query("SELECT 1 AS _one", MYSQLI_ASYNC | MYSQLI_STORE_RESULT); - $links = array($link); - $errors = array($link); - $reject = array($link); - poll_async(12, $link, $links, $errors, $reject, 1, false); - mysqli_close($link); + // Connections on which no query has been send - 1 + $link = get_connection(); + $link->query("SELECT 1 AS _one", MYSQLI_ASYNC | MYSQLI_STORE_RESULT); + $links = array($link); + $errors = array($link); + $reject = array($link); + poll_async(12, $link, $links, $errors, $reject, 1, false); + mysqli_close($link); - $link = get_connection(); - $link->query("SELECT 2 AS _two", MYSQLI_ASYNC | MYSQLI_USE_RESULT); - $links = array($link); - $errors = array($link); - $reject = array($link); - poll_async(13, $link, $links, $errors, $reject, 1, true); - mysqli_close($link); + $link = get_connection(); + $link->query("SELECT 2 AS _two", MYSQLI_ASYNC | MYSQLI_USE_RESULT); + $links = array($link); + $errors = array($link); + $reject = array($link); + poll_async(13, $link, $links, $errors, $reject, 1, true); + mysqli_close($link); - print "done!"; + print "done!"; ?> --EXPECT-- [012 + 2] array ( diff --git a/ext/mysqli/tests/mysqli_reconnect.phpt b/ext/mysqli/tests/mysqli_reconnect.phpt index 606d38028522..0ad110f0df25 100644 --- a/ext/mysqli/tests/mysqli_reconnect.phpt +++ b/ext/mysqli/tests/mysqli_reconnect.phpt @@ -12,119 +12,119 @@ if (stristr(mysqli_get_client_info(), 'mysqlnd')) mysqli.reconnect=1 --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_release_savepoint.phpt b/ext/mysqli/tests/mysqli_release_savepoint.phpt index 44a2bebb3552..a8b2cb1cf27a 100644 --- a/ext/mysqli/tests/mysqli_release_savepoint.phpt +++ b/ext/mysqli/tests/mysqli_release_savepoint.phpt @@ -15,48 +15,48 @@ if (!have_innodb($link)) ?> --FILE-- fetch_assoc()); + $res = mysqli_query($link, "SELECT * FROM test"); + var_dump($res->fetch_assoc()); - if (true !== ($tmp = mysqli_release_savepoint($link, 'my'))) - printf("[014] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link)); + if (true !== ($tmp = mysqli_release_savepoint($link, 'my'))) + printf("[014] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link)); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- ?"); - $id = 1; - mysqli_kill($link, mysqli_thread_id($link)); - mysqli_stmt_bind_param($stmt, "i", $id); - mysqli_stmt_close($stmt); - mysqli_close($link); - - /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */ - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); - $id = 1; - mysqli_stmt_bind_param($stmt, "i", $id); - // mysqli_kill($link, mysqli_thread_id($link)); - mysqli_stmt_execute($stmt); - mysqli_stmt_close($stmt); - mysqli_close($link); - - /* mysqli_kill() "trick" does not work for any of the following because of an E_COMMANDS_OUT_OF_SYNC */ - /* mysqli_stmt_bind_result() = mysql_stmt_bind_result() cannot be tested from PHP */ - /* mysqli_stmt_fetch() = mysql_stmt_fetch() cannot be tested from PHP */ - /* mysqli_stmt_result_metadata() = mysql_stmt_result_metadata() cannot be tested from PHP */ - /* mysqli_stmt_store_result() = mysql_stmt_store_result() cannot be tested from PHP */ - - // Check - mysqli_report(MYSQLI_REPORT_OFF); - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "FOO"); - - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); - $id = 1; - mysqli_kill($link, mysqli_thread_id($link)); - mysqli_stmt_bind_param($stmt, "i", $id); - mysqli_stmt_close($stmt); - mysqli_close($link); - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); - $id = 1; - mysqli_stmt_bind_param($stmt, "i", $id); - mysqli_kill($link, mysqli_thread_id($link)); - mysqli_stmt_execute($stmt); - mysqli_stmt_close($stmt); - mysqli_close($link); - - /* - MYSQLI_REPORT_STRICT - - MYSQLI_REPORT_STRICT ---> - php_mysqli_report_error() -> - MYSQLI_REPORT_MYSQL_ERROR, - MYSQLI_REPORT_STMT_ERROR -> - already tested - - php_mysqli_throw_sql_exception() -> - my_mysqli_real_connect() - my_mysqli_connect() - - can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result() - */ - mysqli_report(MYSQLI_REPORT_OFF); - mysqli_report(MYSQLI_REPORT_STRICT); - - try { - - if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) - printf("[012] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", - $host, $user . 'unknown_really', $db, $port, $socket); - mysqli_close($link); - - } catch (mysqli_sql_exception $e) { - printf("[013] %s\n", $e->getMessage()); - } - - try { - if (!$link = mysqli_init()) - printf("[014] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - - if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) - printf("[015] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", - $host, $user . 'unknown_really', $db, $port, $socket); - mysqli_close($link); - } catch (mysqli_sql_exception $e) { - printf("[016] %s\n", $e->getMessage()); - } - - /* - MYSQLI_REPORT_INDEX ---> - mysqli_query() - mysqli_stmt_execute() - mysqli_prepare() - mysqli_real_query() - mysqli_store_result() - mysqli_use_result() - - No test, because of to many prerequisites: - - Server needs to be started with and - --log-slow-queries --log-queries-not-using-indexes - - query must cause the warning on all MySQL versions - - TODO: - */ - $log_slow_queries = false; - $log_queries_not_using_indexes = false; - mysqli_report(MYSQLI_REPORT_OFF); - mysqli_report(MYSQLI_REPORT_INDEX); - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - - if (mysqli_get_server_version($link) <= 50600) { - // this might cause a warning - no index used - if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'")) - printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!$row = mysqli_fetch_assoc($res)) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $log_slow_query = ('ON' == $row['Value']); - - if (mysqli_get_server_version($link) >= 50111) { - // this might cause a warning - no index used - if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'")) - printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!$row = mysqli_fetch_assoc($res)) - printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - $log_queries_not_using_indexes = ('ON' == $row['Value']); - - if ($log_slow_queries && $log_queries_not_using_indexes) { - - for ($i = 100; $i < 20000; $i++) { - if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')")) - printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link)); - } - - // this might cause a warning - no index used - if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - mysqli_free_result($res); - } - } - } + require_once("connect.inc"); + + if (true !== ($tmp = mysqli_report(-1))) + printf("[002] Expecting boolean/true even for invalid flags, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ERROR))) + printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_STRICT))) + printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_INDEX))) + printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_ALL))) + printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = mysqli_report(MYSQLI_REPORT_OFF))) + printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + require('table.inc'); + + /* + Internal macro MYSQL_REPORT_ERROR + */ + mysqli_report(MYSQLI_REPORT_ERROR); + + mysqli_multi_query($link, "BAR; FOO;"); + mysqli_query($link, "FOO"); + mysqli_kill($link, -1); + + // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it + mysqli_prepare($link, "FOO"); + mysqli_real_query($link, "FOO"); + if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name")) + printf("[009] select_db should have failed\n"); + // mysqli_store_result() and mysqli_use_result() cannot be tested, because one would need to cause an error inside the C function to test it + + + // Check that none of the above would have caused any error messages if MYSQL_REPORT_ERROR would + // not have been set. If that would be the case, the test would be broken. + mysqli_report(MYSQLI_REPORT_OFF); + + mysqli_multi_query($link, "BAR; FOO;"); + mysqli_query($link, "FOO"); + mysqli_kill($link, -1); + mysqli_prepare($link, "FOO"); + mysqli_real_query($link, "FOO"); + mysqli_select_db($link, "Oh lord, let this be an unknown database name"); + + /* + Internal macro MYSQL_REPORT_STMT_ERROR + */ + + mysqli_report(MYSQLI_REPORT_ERROR); + + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, "FOO"); + + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $id = 1; + mysqli_kill($link, mysqli_thread_id($link)); + mysqli_stmt_bind_param($stmt, "i", $id); + mysqli_stmt_close($stmt); + mysqli_close($link); + + /* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */ + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $id = 1; + mysqli_stmt_bind_param($stmt, "i", $id); + // mysqli_kill($link, mysqli_thread_id($link)); + mysqli_stmt_execute($stmt); + mysqli_stmt_close($stmt); + mysqli_close($link); + + /* mysqli_kill() "trick" does not work for any of the following because of an E_COMMANDS_OUT_OF_SYNC */ + /* mysqli_stmt_bind_result() = mysql_stmt_bind_result() cannot be tested from PHP */ + /* mysqli_stmt_fetch() = mysql_stmt_fetch() cannot be tested from PHP */ + /* mysqli_stmt_result_metadata() = mysql_stmt_result_metadata() cannot be tested from PHP */ + /* mysqli_stmt_store_result() = mysql_stmt_store_result() cannot be tested from PHP */ + + // Check + mysqli_report(MYSQLI_REPORT_OFF); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, "FOO"); + + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $id = 1; + mysqli_kill($link, mysqli_thread_id($link)); + mysqli_stmt_bind_param($stmt, "i", $id); + mysqli_stmt_close($stmt); + mysqli_close($link); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?"); + $id = 1; + mysqli_stmt_bind_param($stmt, "i", $id); + mysqli_kill($link, mysqli_thread_id($link)); + mysqli_stmt_execute($stmt); + mysqli_stmt_close($stmt); + mysqli_close($link); + + /* + MYSQLI_REPORT_STRICT + + MYSQLI_REPORT_STRICT ---> + php_mysqli_report_error() -> + MYSQLI_REPORT_MYSQL_ERROR, + MYSQLI_REPORT_STMT_ERROR -> + already tested + + php_mysqli_throw_sql_exception() -> + my_mysqli_real_connect() + my_mysqli_connect() + + can't be tested: mysqli_query() via mysql_use_result()/mysql_store_result() + */ + mysqli_report(MYSQLI_REPORT_OFF); + mysqli_report(MYSQLI_REPORT_STRICT); + + try { + + if ($link = my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) + printf("[012] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + mysqli_close($link); + + } catch (mysqli_sql_exception $e) { + printf("[013] %s\n", $e->getMessage()); + } + + try { + if (!$link = mysqli_init()) + printf("[014] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) + printf("[015] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + mysqli_close($link); + } catch (mysqli_sql_exception $e) { + printf("[016] %s\n", $e->getMessage()); + } + + /* + MYSQLI_REPORT_INDEX ---> + mysqli_query() + mysqli_stmt_execute() + mysqli_prepare() + mysqli_real_query() + mysqli_store_result() + mysqli_use_result() + + No test, because of to many prerequisites: + - Server needs to be started with and + --log-slow-queries --log-queries-not-using-indexes + - query must cause the warning on all MySQL versions + + TODO: + */ + $log_slow_queries = false; + $log_queries_not_using_indexes = false; + mysqli_report(MYSQLI_REPORT_OFF); + mysqli_report(MYSQLI_REPORT_INDEX); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + if (mysqli_get_server_version($link) <= 50600) { + // this might cause a warning - no index used + if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_slow_queries'")) + printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $log_slow_query = ('ON' == $row['Value']); + + if (mysqli_get_server_version($link) >= 50111) { + // this might cause a warning - no index used + if (!$res = @mysqli_query($link, "SHOW VARIABLES LIKE 'log_queries_not_using_indexes'")) + printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $log_queries_not_using_indexes = ('ON' == $row['Value']); + + if ($log_slow_queries && $log_queries_not_using_indexes) { + + for ($i = 100; $i < 20000; $i++) { + if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES ($i, 'z')")) + printf("[022 - %d] [%d] %s\n", $i - 99, mysqli_errno($link), mysqli_error($link)); + } + + // this might cause a warning - no index used + if (!$res = @mysqli_query($link, "SELECT id, label FROM test WHERE id = 1323")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + mysqli_free_result($res); + } + } + } - // Maybe we've provoked an index message, maybe not. - // All we can do is make a few dummy calls to ensure that all codes gets executed which - // checks the flag. Functions to check: mysqli_query() - done above, - // mysqli_stmt_execute(), mysqli_prepare(), mysqli_real_query(), mysqli_store_result() - // mysqli_use_result(), mysqli_thread_safe(), mysqli_thread_id() - mysqli_report(MYSQLI_REPORT_OFF); - mysqli_close($link); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[024] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + // Maybe we've provoked an index message, maybe not. + // All we can do is make a few dummy calls to ensure that all codes gets executed which + // checks the flag. Functions to check: mysqli_query() - done above, + // mysqli_stmt_execute(), mysqli_prepare(), mysqli_real_query(), mysqli_store_result() + // mysqli_use_result(), mysqli_thread_safe(), mysqli_thread_id() + mysqli_report(MYSQLI_REPORT_OFF); + mysqli_close($link); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[024] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if (!$stmt = mysqli_stmt_init($link)) - printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt = mysqli_stmt_init($link)) + printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) - printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) + printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) - printf("[027] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[027] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - if (!mysqli_real_query($link, 'SELECT label, id FROM test')) - printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_real_query($link, 'SELECT label, id FROM test')) + printf("[028] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$res = mysqli_use_result($link)) - printf("[029] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_use_result($link)) + printf("[029] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + mysqli_free_result($res); - if (!mysqli_real_query($link, 'SELECT label, id FROM test')) - printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_real_query($link, 'SELECT label, id FROM test')) + printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$res = mysqli_store_result($link)) - printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_store_result($link)) + printf("[031] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + mysqli_free_result($res); - if (!$stmt = mysqli_prepare($link, 'SELECT id * 3 FROM test')) - printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - else - mysqli_stmt_close($stmt); + if (!$stmt = mysqli_prepare($link, 'SELECT id * 3 FROM test')) + printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + else + mysqli_stmt_close($stmt); - if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')", MYSQLI_USE_RESULT) || - !mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT)) - printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')", MYSQLI_USE_RESULT) || + !mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT)) + printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = mysqli_thread_id($link); + $tmp = mysqli_thread_id($link); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- = 50600) ?> --FILE-- getMessage()); - } + } catch (mysqli_sql_exception $e) { + printf("[011] %s\n", $e->getMessage()); + } - try { - if (!$link = mysqli_init()) - printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + try { + if (!$link = mysqli_init()) + printf("[012] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) - printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", - $host, $user . 'unknown_really', $db, $port, $socket); - mysqli_close($link); - } catch (mysqli_sql_exception $e) { - printf("[014] %s\n", $e->getMessage()); - } + if ($link = my_mysqli_real_connect($link, $host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) + printf("[013] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + mysqli_close($link); + } catch (mysqli_sql_exception $e) { + printf("[014] %s\n", $e->getMessage()); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- &$row['id'], - 'label' => $row['label'] . ''); - $references[$idx++]['id'] += 0; - } + $idx = 0; + while ($row = mysqli_fetch_assoc($res)) { + /* mysqlnd: force separation - create copies */ + $references[$idx] = array( + 'id' => &$row['id'], + 'label' => $row['label'] . ''); + $references[$idx++]['id'] += 0; + } - mysqli_close($link); + mysqli_close($link); - mysqli_data_seek($res, 0); - while ($row = mysqli_fetch_assoc($res)) { - /* mysqlnd: force separation - create copies */ - $references[$idx] = array( - 'id' => &$row['id'], - 'label' => $row['label'] . ''); - $references[$idx++]['id'] += 0; - } + mysqli_data_seek($res, 0); + while ($row = mysqli_fetch_assoc($res)) { + /* mysqlnd: force separation - create copies */ + $references[$idx] = array( + 'id' => &$row['id'], + 'label' => $row['label'] . ''); + $references[$idx++]['id'] += 0; + } - mysqli_free_result($res); + mysqli_free_result($res); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); - if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || - !($res = mysqli_use_result($link))) - printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) || + !($res = mysqli_use_result($link))) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - while ($row = mysqli_fetch_assoc($res)) { - /* mysqlnd: force separation - create copies*/ - $references[$idx] = array( - 'id' => &$row['id'], - 'label' => $row['label'] . ''); - $references[$idx]['id2'] = &$references[$idx]['id']; - $references[$idx]['id'] += 1; - $references[$idx++]['id2'] += 1; - } + while ($row = mysqli_fetch_assoc($res)) { + /* mysqlnd: force separation - create copies*/ + $references[$idx] = array( + 'id' => &$row['id'], + 'label' => $row['label'] . ''); + $references[$idx]['id2'] = &$references[$idx]['id']; + $references[$idx]['id'] += 1; + $references[$idx++]['id2'] += 1; + } - $references[$idx++] = &$res; - mysqli_free_result($res); + $references[$idx++] = &$res; + mysqli_free_result($res); - debug_zval_dump($references); + debug_zval_dump($references); - if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || - !($res = mysqli_use_result($link))) - printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) || + !($res = mysqli_use_result($link))) + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $tmp = array(); - while ($row = mysqli_fetch_assoc($res)) { - $tmp[] = $row; - } - $tmp = unserialize(serialize($tmp)); - debug_zval_dump($tmp); - mysqli_free_result($res); + $tmp = array(); + while ($row = mysqli_fetch_assoc($res)) { + $tmp[] = $row; + } + $tmp = unserialize(serialize($tmp)); + debug_zval_dump($tmp); + mysqli_free_result($res); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --EXPECTF-- array(1) refcount(%d){ diff --git a/ext/mysqli/tests/mysqli_result_unclonable.phpt b/ext/mysqli/tests/mysqli_result_unclonable.phpt index 6eff412a1d73..06f7d5899ddd 100644 --- a/ext/mysqli/tests/mysqli_result_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_result_unclonable.phpt @@ -8,17 +8,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_result in %s:%d diff --git a/ext/mysqli/tests/mysqli_rollback.phpt b/ext/mysqli/tests/mysqli_rollback.phpt index be5ac7870a98..92ab3e28b5c4 100644 --- a/ext/mysqli/tests/mysqli_rollback.phpt +++ b/ext/mysqli/tests/mysqli_rollback.phpt @@ -15,39 +15,39 @@ mysqli_rollback() ?> --FILE-- getMessage() . "\n"; } - print "done!\n"; + print "done!\n"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- select_db($db)) - printf("[012] Failed to set '%s' as current DB; [%d] %s\n", $link->errno, $link->error); + if (!$link->select_db($db)) + printf("[012] Failed to set '%s' as current DB; [%d] %s\n", $link->errno, $link->error); - if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$row = mysqli_fetch_assoc($res)) + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $current_db = $row['dbname']; + $current_db = $row['dbname']; - mysqli_report(MYSQLI_REPORT_OFF); - mysqli_select_db($link, 'I can not imagine that this database exists'); - mysqli_report(MYSQLI_REPORT_ERROR); + mysqli_report(MYSQLI_REPORT_OFF); + mysqli_select_db($link, 'I can not imagine that this database exists'); + mysqli_report(MYSQLI_REPORT_ERROR); - ob_start(); - mysqli_select_db($link, 'I can not imagine that this database exists'); - $output = ob_get_contents(); - ob_end_clean(); - if (!stristr($output, "1049") && !stristr($output, "1044") && !stristr($output, "1045")) { - /* Error: 1049 SQLSTATE: 42000 (ER_BAD_DB_ERROR) Message: Unknown database '%s' */ - /* Error: 1044 SQLSTATE: 42000 (ER_DBACCESS_DENIED_ERROR) Message: Access denied for user '%s'@'%s' to database '%s' */ - /* Error: 1045 SQLSTATE: 28000 (ER_ACCESS_DENIED_ERROR) Message: Access denied for user '%s'@'%s' (using password: %s) */ - echo $output; - } + ob_start(); + mysqli_select_db($link, 'I can not imagine that this database exists'); + $output = ob_get_contents(); + ob_end_clean(); + if (!stristr($output, "1049") && !stristr($output, "1044") && !stristr($output, "1045")) { + /* Error: 1049 SQLSTATE: 42000 (ER_BAD_DB_ERROR) Message: Unknown database '%s' */ + /* Error: 1044 SQLSTATE: 42000 (ER_DBACCESS_DENIED_ERROR) Message: Access denied for user '%s'@'%s' to database '%s' */ + /* Error: 1045 SQLSTATE: 28000 (ER_ACCESS_DENIED_ERROR) Message: Access denied for user '%s'@'%s' (using password: %s) */ + echo $output; + } - if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$row = mysqli_fetch_assoc($res)) + printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (strtolower($row['dbname']) != strtolower($current_db)) - printf("[017] Current DB should not change if set fails\n"); + if (strtolower($row['dbname']) != strtolower($current_db)) + printf("[017] Current DB should not change if set fails\n"); - if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) - printf("[018] [%d] %s\n"); + if (!$res = $link->query("SELECT id FROM test WHERE id = 1")) + printf("[018] [%d] %s\n"); - $row = $res->fetch_assoc(); - $res->free(); + $row = $res->fetch_assoc(); + $res->free(); - mysqli_close($link); + mysqli_close($link); try { mysqli_select_db($link, $db); @@ -94,7 +94,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!\n"; + print "done!\n"; ?> --CLEAN-- diff --git a/ext/mysqli/tests/mysqli_send_query.phpt b/ext/mysqli/tests/mysqli_send_query.phpt index 5cdb0a6b77a9..b8d5a1b801f4 100644 --- a/ext/mysqli/tests/mysqli_send_query.phpt +++ b/ext/mysqli/tests/mysqli_send_query.phpt @@ -14,38 +14,38 @@ if (!$TEST_EXPERIMENTAL) ?> --FILE-- getMessage() . "\n"; - } - print "done!"; + try { + mysqli_send_query($link, 'SELECT 1'); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } + print "done!"; ?> --EXPECTF-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_set_charset.phpt b/ext/mysqli/tests/mysqli_set_charset.phpt index 092e17b36cf7..43b8be3f0017 100644 --- a/ext/mysqli/tests/mysqli_set_charset.phpt +++ b/ext/mysqli/tests/mysqli_set_charset.phpt @@ -46,63 +46,63 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- bool(true) diff --git a/ext/mysqli/tests/mysqli_sqlstate.phpt b/ext/mysqli/tests/mysqli_sqlstate.phpt index 1d63e71da2a1..cf6097776350 100644 --- a/ext/mysqli/tests/mysqli_sqlstate.phpt +++ b/ext/mysqli/tests/mysqli_sqlstate.phpt @@ -8,17 +8,17 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_stat.phpt b/ext/mysqli/tests/mysqli_stat.phpt index 6369a366b3f0..dd0b3d24c988 100644 --- a/ext/mysqli/tests/mysqli_stat.phpt +++ b/ext/mysqli/tests/mysqli_stat.phpt @@ -8,15 +8,15 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --EXPECT-- mysqli object is already closed diff --git a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt index 2ba36389fde8..505acc68f1e8 100644 --- a/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt +++ b/ext/mysqli/tests/mysqli_stmt_affected_rows.phpt @@ -8,222 +8,222 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); - if (mysqli_get_client_version() > 50003) - $valid_attr["cursor_type"] = MYSQLI_STMT_ATTR_CURSOR_TYPE; + $valid_attr = array("max_length" => MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); + if (mysqli_get_client_version() > 50003) + $valid_attr["cursor_type"] = MYSQLI_STMT_ATTR_CURSOR_TYPE; - if ($IS_MYSQLND && mysqli_get_client_version() > 50007) - $valid_attr["prefetch_rows"] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; + if ($IS_MYSQLND && mysqli_get_client_version() > 50007) + $valid_attr["prefetch_rows"] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; - do { - $invalid_attr = mt_rand(0, 10000); - } while (in_array($invalid_attr, $valid_attr)); + do { + $invalid_attr = mt_rand(0, 10000); + } while (in_array($invalid_attr, $valid_attr)); - $stmt = mysqli_stmt_init($link); - mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); try { mysqli_stmt_attr_get($stmt, $invalid_attr); @@ -32,25 +32,25 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - foreach ($valid_attr as $k => $attr) { - if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) { - printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n", - gettype($tmp), $tmp, $k, $attr); - } - } + foreach ($valid_attr as $k => $attr) { + if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) { + printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n", + gettype($tmp), $tmp, $k, $attr); + } + } - $stmt->close(); + $stmt->close(); - foreach ($valid_attr as $k => $attr) { + foreach ($valid_attr as $k => $attr) { try { mysqli_stmt_attr_get($stmt, $attr); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - } + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- close(); - mysqli_close($link); - print "done!"; + $stmt = mysqli_stmt_init($link); + mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); + if (1 !== ($tmp = mysqli_stmt_attr_get($stmt, MYSQLI_STMT_ATTR_PREFETCH_ROWS))) { + printf("[001] Expecting int/1, got %s/%s for attribute %s/%s\n", + gettype($tmp), $tmp, $k, $attr); + } + $stmt->close(); + mysqli_close($link); + print "done!"; ?> --CLEAN-- 50003) || $IS_MYSQLND) { - $valid_attr[] = MYSQLI_STMT_ATTR_CURSOR_TYPE; - $valid_attr[] = MYSQLI_CURSOR_TYPE_NO_CURSOR; - $valid_attr[] = MYSQLI_CURSOR_TYPE_READ_ONLY; - $valid_attr[] = MYSQLI_CURSOR_TYPE_FOR_UPDATE; - $valid_attr[] = MYSQLI_CURSOR_TYPE_SCROLLABLE; - } + require('table.inc'); + + $valid_attr = array(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); + if ((mysqli_get_client_version() > 50003) || $IS_MYSQLND) { + $valid_attr[] = MYSQLI_STMT_ATTR_CURSOR_TYPE; + $valid_attr[] = MYSQLI_CURSOR_TYPE_NO_CURSOR; + $valid_attr[] = MYSQLI_CURSOR_TYPE_READ_ONLY; + $valid_attr[] = MYSQLI_CURSOR_TYPE_FOR_UPDATE; + $valid_attr[] = MYSQLI_CURSOR_TYPE_SCROLLABLE; + } - if ((mysqli_get_client_version() > 50007) || $IS_MYSQLND) - $valid_attr[] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; + if ((mysqli_get_client_version() > 50007) || $IS_MYSQLND) + $valid_attr[] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; - $stmt = mysqli_stmt_init($link); + $stmt = mysqli_stmt_init($link); try { mysqli_stmt_attr_set($stmt, 0, 0); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - $stmt->prepare("SELECT * FROM test"); - - mt_srand(microtime(true)); - - for ($i = -100; $i < 1000; $i++) { - if (in_array($i, $valid_attr)) - continue; - $invalid_attr = $i; - if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { - printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); - } - } - - for ($i = 0; $i < 2; $i++) { - do { - $invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX)); - } while (in_array($invalid_attr, $valid_attr)); - if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { - printf("[006b] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); - } - } - $stmt->close(); - - // - // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH - // - - - // expecting max_length not to be set and be 0 in all cases - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); - $stmt->execute(); - $stmt->store_result(); - $res = $stmt->result_metadata(); - $fields = $res->fetch_fields(); - $max_lengths = array(); - foreach ($fields as $k => $meta) { - $max_lengths[$meta->name] = $meta->max_length; - if ($meta->max_length !== 0) - printf("[007] max_length should be not set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); - } - $res->close(); - $stmt->close(); - - // expecting max_length to _be_ set - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); - $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1); - $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); - if ($res !== 1) - printf("[007.1] max_length should be 1, got %s\n", $res); - $stmt->execute(); - $stmt->store_result(); - $res = $stmt->result_metadata(); - $fields = $res->fetch_fields(); - $max_lengths = array(); - foreach ($fields as $k => $meta) { - $max_lengths[$meta->name] = $meta->max_length; - if ($meta->max_length === 0) - printf("[008] max_length should be set (!= 0), got %s for field %s\n", $meta->max_length, $meta->name); - } - $res->close(); - $stmt->close(); - - // expecting max_length not to be set - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); - $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 0); - $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); - if ($res !== 0) - printf("[008.1] max_length should be 0, got %s\n", $res); - $stmt->execute(); - $stmt->store_result(); - $res = $stmt->result_metadata(); - $fields = $res->fetch_fields(); - $max_lengths = array(); - foreach ($fields as $k => $meta) { - $max_lengths[$meta->name] = $meta->max_length; - if ($meta->max_length !== 0) - printf("[009] max_length should not be set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); - } - $res->close(); - $stmt->close(); - - // - // Cursors - // - - if (mysqli_get_client_version() > 50003) { - - $cursor_types = array( - MYSQLI_CURSOR_TYPE_NO_CURSOR, - MYSQLI_CURSOR_TYPE_READ_ONLY, - MYSQLI_CURSOR_TYPE_FOR_UPDATE, - MYSQLI_CURSOR_TYPE_SCROLLABLE - ); - do { - $invalid_cursor_type = mt_rand(-1000, 1000); - } while (in_array($invalid_cursor_type, $cursor_types)); - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); - - if (false !== ($tmp = @$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, $invalid_cursor_type))) - printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_FOR_UPDATE))) - printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_SCROLLABLE))) - printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) - printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) - printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - $stmt->close(); - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); - $stmt->execute(); - $id = $label = NULL; - $stmt->bind_result($id, $label); - $results = array(); - while ($stmt->fetch()) - $results[$id] = $label; - $stmt->close(); - if (empty($results)) - printf("[015] Results should not be empty, subsequent tests will probably fail!\n"); - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) - printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $stmt->execute(); - $id = $label = NULL; - $stmt->bind_result($id, $label); - $results2 = array(); - while ($stmt->fetch()) - $results2[$id] = $label; - $stmt->close(); - if ($results != $results2) { - printf("[017] Results should not differ. Dumping both result sets.\n"); - var_dump($results); - var_dump($results2); - } - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) - printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $stmt->execute(); - $id = $label = NULL; - $stmt->bind_result($id, $label); - $results2 = array(); - while ($stmt->fetch()) - $results2[$id] = $label; - $stmt->close(); - if ($results != $results2) { - printf("[019] Results should not differ. Dumping both result sets.\n"); - var_dump($results); - var_dump($results2); - } - - } - - - // - // MYSQLI_STMT_ATTR_PREFETCH_ROWS - // - - if (mysqli_get_client_version() > 50007) { - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1))) - printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $stmt->execute(); - $id = $label = NULL; - $stmt->bind_result($id, $label); - $results = array(); - while ($stmt->fetch()) - $results[$id] = $label; - $stmt->close(); - if (empty($results)) - printf("[021] Results should not be empty, subsequent tests will probably fail!\n"); - - /* prefetch is not supported - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); - if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, -1))) - printf("[022] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - $stmt->close(); - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT label FROM test"); - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, PHP_INT_MAX))) - printf("[023] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $stmt->close(); - - $stmt = mysqli_stmt_init($link); - $stmt->prepare("SELECT id, label FROM test"); - if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 2))) - printf("[024] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $stmt->execute(); - $id = $label = NULL; - $stmt->bind_result($id, $label); - $results2 = array(); - while ($stmt->fetch()) - $results2[$id] = $label; - $stmt->close(); - if ($results != $results2) { - printf("[025] Results should not differ. Dumping both result sets.\n"); - var_dump($results); - var_dump($results2); - } - */ - - } - - mysqli_close($link); - print "done!"; + $stmt->prepare("SELECT * FROM test"); + + mt_srand(microtime(true)); + + for ($i = -100; $i < 1000; $i++) { + if (in_array($i, $valid_attr)) + continue; + $invalid_attr = $i; + if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { + printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); + } + } + + for ($i = 0; $i < 2; $i++) { + do { + $invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX)); + } while (in_array($invalid_attr, $valid_attr)); + if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { + printf("[006b] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); + } + } + $stmt->close(); + + // + // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH + // + + + // expecting max_length not to be set and be 0 in all cases + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT label FROM test"); + $stmt->execute(); + $stmt->store_result(); + $res = $stmt->result_metadata(); + $fields = $res->fetch_fields(); + $max_lengths = array(); + foreach ($fields as $k => $meta) { + $max_lengths[$meta->name] = $meta->max_length; + if ($meta->max_length !== 0) + printf("[007] max_length should be not set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); + } + $res->close(); + $stmt->close(); + + // expecting max_length to _be_ set + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT label FROM test"); + $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1); + $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); + if ($res !== 1) + printf("[007.1] max_length should be 1, got %s\n", $res); + $stmt->execute(); + $stmt->store_result(); + $res = $stmt->result_metadata(); + $fields = $res->fetch_fields(); + $max_lengths = array(); + foreach ($fields as $k => $meta) { + $max_lengths[$meta->name] = $meta->max_length; + if ($meta->max_length === 0) + printf("[008] max_length should be set (!= 0), got %s for field %s\n", $meta->max_length, $meta->name); + } + $res->close(); + $stmt->close(); + + // expecting max_length not to be set + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT label FROM test"); + $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 0); + $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); + if ($res !== 0) + printf("[008.1] max_length should be 0, got %s\n", $res); + $stmt->execute(); + $stmt->store_result(); + $res = $stmt->result_metadata(); + $fields = $res->fetch_fields(); + $max_lengths = array(); + foreach ($fields as $k => $meta) { + $max_lengths[$meta->name] = $meta->max_length; + if ($meta->max_length !== 0) + printf("[009] max_length should not be set (= 0), got %s for field %s\n", $meta->max_length, $meta->name); + } + $res->close(); + $stmt->close(); + + // + // Cursors + // + + if (mysqli_get_client_version() > 50003) { + + $cursor_types = array( + MYSQLI_CURSOR_TYPE_NO_CURSOR, + MYSQLI_CURSOR_TYPE_READ_ONLY, + MYSQLI_CURSOR_TYPE_FOR_UPDATE, + MYSQLI_CURSOR_TYPE_SCROLLABLE + ); + do { + $invalid_cursor_type = mt_rand(-1000, 1000); + } while (in_array($invalid_cursor_type, $cursor_types)); + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT id, label FROM test"); + + if (false !== ($tmp = @$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, $invalid_cursor_type))) + printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_FOR_UPDATE))) + printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_SCROLLABLE))) + printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) + printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) + printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + $stmt->close(); + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT id, label FROM test"); + $stmt->execute(); + $id = $label = NULL; + $stmt->bind_result($id, $label); + $results = array(); + while ($stmt->fetch()) + $results[$id] = $label; + $stmt->close(); + if (empty($results)) + printf("[015] Results should not be empty, subsequent tests will probably fail!\n"); + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT id, label FROM test"); + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_NO_CURSOR))) + printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $stmt->execute(); + $id = $label = NULL; + $stmt->bind_result($id, $label); + $results2 = array(); + while ($stmt->fetch()) + $results2[$id] = $label; + $stmt->close(); + if ($results != $results2) { + printf("[017] Results should not differ. Dumping both result sets.\n"); + var_dump($results); + var_dump($results2); + } + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT id, label FROM test"); + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY))) + printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $stmt->execute(); + $id = $label = NULL; + $stmt->bind_result($id, $label); + $results2 = array(); + while ($stmt->fetch()) + $results2[$id] = $label; + $stmt->close(); + if ($results != $results2) { + printf("[019] Results should not differ. Dumping both result sets.\n"); + var_dump($results); + var_dump($results2); + } + + } + + + // + // MYSQLI_STMT_ATTR_PREFETCH_ROWS + // + + if (mysqli_get_client_version() > 50007) { + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT id, label FROM test"); + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1))) + printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $stmt->execute(); + $id = $label = NULL; + $stmt->bind_result($id, $label); + $results = array(); + while ($stmt->fetch()) + $results[$id] = $label; + $stmt->close(); + if (empty($results)) + printf("[021] Results should not be empty, subsequent tests will probably fail!\n"); + + /* prefetch is not supported + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT label FROM test"); + if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, -1))) + printf("[022] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + $stmt->close(); + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT label FROM test"); + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, PHP_INT_MAX))) + printf("[023] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $stmt->close(); + + $stmt = mysqli_stmt_init($link); + $stmt->prepare("SELECT id, label FROM test"); + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 2))) + printf("[024] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $stmt->execute(); + $id = $label = NULL; + $stmt->bind_result($id, $label); + $results2 = array(); + while ($stmt->fetch()) + $results2[$id] = $label; + $stmt->close(); + if ($results != $results2) { + printf("[025] Results should not differ. Dumping both result sets.\n"); + var_dump($results); + var_dump($results2); + } + */ + + } + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- prepare("SHOW STATUS WHERE 1 = ? AND 1 IN {$params}")) { + /* create a prepared statement */ + if ($stmt = $link->prepare("SHOW STATUS WHERE 1 = ? AND 1 IN {$params}")) { - $stmt->bind_param('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', $model, $cleanupIds[0], $cleanupIds[1], $cleanupIds[2], $cleanupIds[3], $cleanupIds[4], $cleanupIds[5], $cleanupIds[6], $cleanupIds[7], $cleanupIds[8], $cleanupIds[9], $cleanupIds[10], $cleanupIds[11], $cleanupIds[12], $cleanupIds[13], $cleanupIds[14], $cleanupIds[15], $cleanupIds[16], $cleanupIds[17], $cleanupIds[18], $cleanupIds[19], $cleanupIds[20], $cleanupIds[21], $cleanupIds[22], $cleanupIds[23], $cleanupIds[24], $cleanupIds[25], $cleanupIds[26], $cleanupIds[27], $cleanupIds[28], $cleanupIds[29], $cleanupIds[30], $cleanupIds[31], $cleanupIds[32], $cleanupIds[33], $cleanupIds[34], $cleanupIds[35], $cleanupIds[36], $cleanupIds[37], $cleanupIds[38], $cleanupIds[39], $cleanupIds[40], $cleanupIds[41], $cleanupIds[42], $cleanupIds[43], $cleanupIds[44], $cleanupIds[45], $cleanupIds[46], $cleanupIds[47], $cleanupIds[48], $cleanupIds[49], $cleanupIds[50], $cleanupIds[51], $cleanupIds[52], $cleanupIds[53], $cleanupIds[54], $cleanupIds[55], $cleanupIds[56], $cleanupIds[57], $cleanupIds[58], $cleanupIds[59], $cleanupIds[60], $cleanupIds[61], $cleanupIds[62], $cleanupIds[63], $cleanupIds[64], $cleanupIds[65], $cleanupIds[66], $cleanupIds[67], $cleanupIds[68], $cleanupIds[69], $cleanupIds[70], $cleanupIds[71], $cleanupIds[72], $cleanupIds[73], $cleanupIds[74], $cleanupIds[75], $cleanupIds[76], $cleanupIds[77], $cleanupIds[78], $cleanupIds[79], $cleanupIds[80], $cleanupIds[81], $cleanupIds[82], $cleanupIds[83], $cleanupIds[84], $cleanupIds[85], $cleanupIds[86], $cleanupIds[87], $cleanupIds[88], $cleanupIds[89], $cleanupIds[90], $cleanupIds[91], $cleanupIds[92], $cleanupIds[93], $cleanupIds[94], $cleanupIds[95], $cleanupIds[96], $cleanupIds[97], $cleanupIds[98], $cleanupIds[99], $cleanupIds[100], $cleanupIds[101], $cleanupIds[102], $cleanupIds[103], $cleanupIds[104], $cleanupIds[105], $cleanupIds[106], $cleanupIds[107], $cleanupIds[108], $cleanupIds[109], $cleanupIds[110], $cleanupIds[111], $cleanupIds[112], $cleanupIds[113], $cleanupIds[114], $cleanupIds[115], $cleanupIds[116], $cleanupIds[117], $cleanupIds[118], $cleanupIds[119], $cleanupIds[120], $cleanupIds[121], $cleanupIds[122], $cleanupIds[123], $cleanupIds[124], $cleanupIds[125], $cleanupIds[126], $cleanupIds[127], $cleanupIds[128], $cleanupIds[129], $cleanupIds[130], $cleanupIds[131], $cleanupIds[132], $cleanupIds[133], $cleanupIds[134], $cleanupIds[135], $cleanupIds[136], $cleanupIds[137], $cleanupIds[138], $cleanupIds[139], $cleanupIds[140], $cleanupIds[141], $cleanupIds[142], $cleanupIds[143], $cleanupIds[144], $cleanupIds[145], $cleanupIds[146], $cleanupIds[147], $cleanupIds[148], $cleanupIds[149], $cleanupIds[150], $cleanupIds[151], $cleanupIds[152], $cleanupIds[153], $cleanupIds[154], $cleanupIds[155], $cleanupIds[156], $cleanupIds[157], $cleanupIds[158], $cleanupIds[159], $cleanupIds[160], $cleanupIds[161], $cleanupIds[162], $cleanupIds[163], $cleanupIds[164], $cleanupIds[165], $cleanupIds[166], $cleanupIds[167], $cleanupIds[168], $cleanupIds[169], $cleanupIds[170], $cleanupIds[171], $cleanupIds[172], $cleanupIds[173], $cleanupIds[174], $cleanupIds[175], $cleanupIds[176], $cleanupIds[177], $cleanupIds[178], $cleanupIds[179], $cleanupIds[180], $cleanupIds[181], $cleanupIds[182], $cleanupIds[183], $cleanupIds[184], $cleanupIds[185], $cleanupIds[186], $cleanupIds[187], $cleanupIds[188], $cleanupIds[189], $cleanupIds[190], $cleanupIds[191], $cleanupIds[192], $cleanupIds[193], $cleanupIds[194], $cleanupIds[195], $cleanupIds[196], $cleanupIds[197], $cleanupIds[198], $cleanupIds[199], $cleanupIds[200], $cleanupIds[201], $cleanupIds[202], $cleanupIds[203], $cleanupIds[204], $cleanupIds[205], $cleanupIds[206], $cleanupIds[207], $cleanupIds[208], $cleanupIds[209], $cleanupIds[210], $cleanupIds[211], $cleanupIds[212], $cleanupIds[213], $cleanupIds[214], $cleanupIds[215], $cleanupIds[216], $cleanupIds[217], $cleanupIds[218], $cleanupIds[219], $cleanupIds[220], $cleanupIds[221], $cleanupIds[222], $cleanupIds[223], $cleanupIds[224], $cleanupIds[225], $cleanupIds[226], $cleanupIds[227], $cleanupIds[228], $cleanupIds[229], $cleanupIds[230], $cleanupIds[231], $cleanupIds[232], $cleanupIds[233], $cleanupIds[234], $cleanupIds[235], $cleanupIds[236], $cleanupIds[237], $cleanupIds[238], $cleanupIds[239], $cleanupIds[240], $cleanupIds[241], $cleanupIds[242], $cleanupIds[243], $cleanupIds[244], $cleanupIds[245], $cleanupIds[246], $cleanupIds[247], $cleanupIds[248], $cleanupIds[249], $cleanupIds[250], $cleanupIds[251], $cleanupIds[252], $cleanupIds[253], $cleanupIds[254], $cleanupIds[255], $cleanupIds[256], $cleanupIds[257], $cleanupIds[258], $cleanupIds[259], $cleanupIds[260], $cleanupIds[261], $cleanupIds[262], $cleanupIds[263], $cleanupIds[264], $cleanupIds[265], $cleanupIds[266], $cleanupIds[267], $cleanupIds[268], $cleanupIds[269], $cleanupIds[270], $cleanupIds[271], $cleanupIds[272], $cleanupIds[273], $cleanupIds[274], $cleanupIds[275], $cleanupIds[276], $cleanupIds[277], $cleanupIds[278], $cleanupIds[279], $cleanupIds[280], $cleanupIds[281], $cleanupIds[282], $cleanupIds[283], $cleanupIds[284], $cleanupIds[285], $cleanupIds[286], $cleanupIds[287], $cleanupIds[288], $cleanupIds[289], $cleanupIds[290], $cleanupIds[291], $cleanupIds[292], $cleanupIds[293], $cleanupIds[294], $cleanupIds[295], $cleanupIds[296], $cleanupIds[297], $cleanupIds[298], $cleanupIds[299], $cleanupIds[300], $cleanupIds[301], $cleanupIds[302], $cleanupIds[303], $cleanupIds[304], $cleanupIds[305], $cleanupIds[306], $cleanupIds[307], $cleanupIds[308], $cleanupIds[309], $cleanupIds[310], $cleanupIds[311], $cleanupIds[312], $cleanupIds[313], $cleanupIds[314], $cleanupIds[315], $cleanupIds[316], $cleanupIds[317], $cleanupIds[318], $cleanupIds[319], $cleanupIds[320], $cleanupIds[321], $cleanupIds[322], $cleanupIds[323], $cleanupIds[324], $cleanupIds[325], $cleanupIds[326], $cleanupIds[327], $cleanupIds[328], $cleanupIds[329], $cleanupIds[330], $cleanupIds[331], $cleanupIds[332], $cleanupIds[333], $cleanupIds[334], $cleanupIds[335], $cleanupIds[336], $cleanupIds[337], $cleanupIds[338], $cleanupIds[339], $cleanupIds[340], $cleanupIds[341], $cleanupIds[342], $cleanupIds[343], $cleanupIds[344], $cleanupIds[345], $cleanupIds[346], $cleanupIds[347], $cleanupIds[348], $cleanupIds[349], $cleanupIds[350], $cleanupIds[351], $cleanupIds[352], $cleanupIds[353], $cleanupIds[354], $cleanupIds[355], $cleanupIds[356], $cleanupIds[357], $cleanupIds[358], $cleanupIds[359], $cleanupIds[360], $cleanupIds[361], $cleanupIds[362], $cleanupIds[363], $cleanupIds[364], $cleanupIds[365], $cleanupIds[366], $cleanupIds[367], $cleanupIds[368], $cleanupIds[369], $cleanupIds[370], $cleanupIds[371], $cleanupIds[372], $cleanupIds[373], $cleanupIds[374], $cleanupIds[375], $cleanupIds[376], $cleanupIds[377], $cleanupIds[378], $cleanupIds[379], $cleanupIds[380], $cleanupIds[381], $cleanupIds[382], $cleanupIds[383], $cleanupIds[384], $cleanupIds[385], $cleanupIds[386], $cleanupIds[387], $cleanupIds[388], $cleanupIds[389], $cleanupIds[390], $cleanupIds[391], $cleanupIds[392], $cleanupIds[393], $cleanupIds[394], $cleanupIds[395], $cleanupIds[396], $cleanupIds[397], $cleanupIds[398], $cleanupIds[399], $cleanupIds[400], $cleanupIds[401], $cleanupIds[402], $cleanupIds[403], $cleanupIds[404], $cleanupIds[405], $cleanupIds[406], $cleanupIds[407], $cleanupIds[408], $cleanupIds[409], $cleanupIds[410], $cleanupIds[411], $cleanupIds[412], $cleanupIds[413], $cleanupIds[414], $cleanupIds[415], $cleanupIds[416], $cleanupIds[417], $cleanupIds[418], $cleanupIds[419], $cleanupIds[420], $cleanupIds[421], $cleanupIds[422], $cleanupIds[423], $cleanupIds[424], $cleanupIds[425], $cleanupIds[426], $cleanupIds[427], $cleanupIds[428], $cleanupIds[429], $cleanupIds[430], $cleanupIds[431], $cleanupIds[432], $cleanupIds[433], $cleanupIds[434], $cleanupIds[435], $cleanupIds[436], $cleanupIds[437], $cleanupIds[438], $cleanupIds[439], $cleanupIds[440], $cleanupIds[441], $cleanupIds[442], $cleanupIds[443], $cleanupIds[444], $cleanupIds[445], $cleanupIds[446], $cleanupIds[447], $cleanupIds[448], $cleanupIds[449], $cleanupIds[450], $cleanupIds[451], $cleanupIds[452], $cleanupIds[453], $cleanupIds[454], $cleanupIds[455], $cleanupIds[456], $cleanupIds[457], $cleanupIds[458], $cleanupIds[459], $cleanupIds[460], $cleanupIds[461], $cleanupIds[462], $cleanupIds[463], $cleanupIds[464], $cleanupIds[465], $cleanupIds[466], $cleanupIds[467], $cleanupIds[468], $cleanupIds[469], $cleanupIds[470], $cleanupIds[471], $cleanupIds[472], $cleanupIds[473], $cleanupIds[474], $cleanupIds[475], $cleanupIds[476], $cleanupIds[477], $cleanupIds[478], $cleanupIds[479], $cleanupIds[480], $cleanupIds[481], $cleanupIds[482], $cleanupIds[483], $cleanupIds[484], $cleanupIds[485], $cleanupIds[486], $cleanupIds[487], $cleanupIds[488], $cleanupIds[489], $cleanupIds[490], $cleanupIds[491], $cleanupIds[492], $cleanupIds[493], $cleanupIds[494], $cleanupIds[495], $cleanupIds[496], $cleanupIds[497], $cleanupIds[498], $cleanupIds[499], $cleanupIds[500], $cleanupIds[501], $cleanupIds[502], $cleanupIds[503], $cleanupIds[504], $cleanupIds[505], $cleanupIds[506], $cleanupIds[507], $cleanupIds[508], $cleanupIds[509], $cleanupIds[510], $cleanupIds[511], $cleanupIds[512], $cleanupIds[513], $cleanupIds[514], $cleanupIds[515], $cleanupIds[516], $cleanupIds[517], $cleanupIds[518], $cleanupIds[519], $cleanupIds[520], $cleanupIds[521], $cleanupIds[522], $cleanupIds[523], $cleanupIds[524], $cleanupIds[525], $cleanupIds[526], $cleanupIds[527], $cleanupIds[528], $cleanupIds[529], $cleanupIds[530], $cleanupIds[531], $cleanupIds[532], $cleanupIds[533], $cleanupIds[534], $cleanupIds[535], $cleanupIds[536], $cleanupIds[537], $cleanupIds[538], $cleanupIds[539], $cleanupIds[540], $cleanupIds[541], $cleanupIds[542], $cleanupIds[543], $cleanupIds[544], $cleanupIds[545], $cleanupIds[546], $cleanupIds[547], $cleanupIds[548], $cleanupIds[549], $cleanupIds[550], $cleanupIds[551], $cleanupIds[552], $cleanupIds[553], $cleanupIds[554], $cleanupIds[555], $cleanupIds[556], $cleanupIds[557], $cleanupIds[558], $cleanupIds[559], $cleanupIds[560], $cleanupIds[561], $cleanupIds[562], $cleanupIds[563], $cleanupIds[564], $cleanupIds[565], $cleanupIds[566], $cleanupIds[567], $cleanupIds[568], $cleanupIds[569], $cleanupIds[570], $cleanupIds[571], $cleanupIds[572], $cleanupIds[573], $cleanupIds[574], $cleanupIds[575], $cleanupIds[576], $cleanupIds[577], $cleanupIds[578], $cleanupIds[579], $cleanupIds[580], $cleanupIds[581], $cleanupIds[582], $cleanupIds[583], $cleanupIds[584], $cleanupIds[585], $cleanupIds[586], $cleanupIds[587], $cleanupIds[588], $cleanupIds[589], $cleanupIds[590], $cleanupIds[591], $cleanupIds[592], $cleanupIds[593], $cleanupIds[594], $cleanupIds[595], $cleanupIds[596], $cleanupIds[597], $cleanupIds[598], $cleanupIds[599], $cleanupIds[600], $cleanupIds[601], $cleanupIds[602], $cleanupIds[603], $cleanupIds[604], $cleanupIds[605], $cleanupIds[606], $cleanupIds[607], $cleanupIds[608], $cleanupIds[609], $cleanupIds[610], $cleanupIds[611], $cleanupIds[612], $cleanupIds[613], $cleanupIds[614], $cleanupIds[615], $cleanupIds[616], $cleanupIds[617], $cleanupIds[618], $cleanupIds[619], $cleanupIds[620], $cleanupIds[621], $cleanupIds[622], $cleanupIds[623], $cleanupIds[624], $cleanupIds[625], $cleanupIds[626], $cleanupIds[627], $cleanupIds[628], $cleanupIds[629], $cleanupIds[630], $cleanupIds[631], $cleanupIds[632], $cleanupIds[633], $cleanupIds[634], $cleanupIds[635], $cleanupIds[636], $cleanupIds[637], $cleanupIds[638], $cleanupIds[639], $cleanupIds[640], $cleanupIds[641], $cleanupIds[642], $cleanupIds[643], $cleanupIds[644], $cleanupIds[645], $cleanupIds[646], $cleanupIds[647], $cleanupIds[648], $cleanupIds[649], $cleanupIds[650], $cleanupIds[651], $cleanupIds[652], $cleanupIds[653], $cleanupIds[654], $cleanupIds[655], $cleanupIds[656], $cleanupIds[657], $cleanupIds[658], $cleanupIds[659], $cleanupIds[660], $cleanupIds[661], $cleanupIds[662], $cleanupIds[663], $cleanupIds[664], $cleanupIds[665], $cleanupIds[666], $cleanupIds[667], $cleanupIds[668], $cleanupIds[669], $cleanupIds[670], $cleanupIds[671], $cleanupIds[672], $cleanupIds[673], $cleanupIds[674], $cleanupIds[675], $cleanupIds[676], $cleanupIds[677], $cleanupIds[678], $cleanupIds[679], $cleanupIds[680], $cleanupIds[681], $cleanupIds[682], $cleanupIds[683], $cleanupIds[684], $cleanupIds[685], $cleanupIds[686], $cleanupIds[687], $cleanupIds[688], $cleanupIds[689], $cleanupIds[690], $cleanupIds[691], $cleanupIds[692], $cleanupIds[693], $cleanupIds[694], $cleanupIds[695], $cleanupIds[696], $cleanupIds[697], $cleanupIds[698], $cleanupIds[699], $cleanupIds[700], $cleanupIds[701], $cleanupIds[702], $cleanupIds[703], $cleanupIds[704], $cleanupIds[705], $cleanupIds[706], $cleanupIds[707], $cleanupIds[708], $cleanupIds[709], $cleanupIds[710], $cleanupIds[711], $cleanupIds[712], $cleanupIds[713], $cleanupIds[714], $cleanupIds[715], $cleanupIds[716], $cleanupIds[717], $cleanupIds[718], $cleanupIds[719], $cleanupIds[720], $cleanupIds[721], $cleanupIds[722], $cleanupIds[723], $cleanupIds[724], $cleanupIds[725], $cleanupIds[726], $cleanupIds[727], $cleanupIds[728], $cleanupIds[729], $cleanupIds[730], $cleanupIds[731], $cleanupIds[732], $cleanupIds[733], $cleanupIds[734], $cleanupIds[735], $cleanupIds[736], $cleanupIds[737], $cleanupIds[738], $cleanupIds[739], $cleanupIds[740], $cleanupIds[741], $cleanupIds[742], $cleanupIds[743], $cleanupIds[744], $cleanupIds[745], $cleanupIds[746], $cleanupIds[747], $cleanupIds[748], $cleanupIds[749], $cleanupIds[750], $cleanupIds[751], $cleanupIds[752], $cleanupIds[753], $cleanupIds[754], $cleanupIds[755], $cleanupIds[756], $cleanupIds[757], $cleanupIds[758], $cleanupIds[759], $cleanupIds[760], $cleanupIds[761], $cleanupIds[762], $cleanupIds[763], $cleanupIds[764], $cleanupIds[765], $cleanupIds[766], $cleanupIds[767], $cleanupIds[768], $cleanupIds[769], $cleanupIds[770], $cleanupIds[771], $cleanupIds[772], $cleanupIds[773], $cleanupIds[774], $cleanupIds[775], $cleanupIds[776], $cleanupIds[777], $cleanupIds[778], $cleanupIds[779], $cleanupIds[780], $cleanupIds[781], $cleanupIds[782], $cleanupIds[783], $cleanupIds[784], $cleanupIds[785], $cleanupIds[786], $cleanupIds[787], $cleanupIds[788], $cleanupIds[789], $cleanupIds[790], $cleanupIds[791], $cleanupIds[792], $cleanupIds[793], $cleanupIds[794], $cleanupIds[795], $cleanupIds[796], $cleanupIds[797], $cleanupIds[798], $cleanupIds[799], $cleanupIds[800], $cleanupIds[801], $cleanupIds[802], $cleanupIds[803], $cleanupIds[804], $cleanupIds[805], $cleanupIds[806], $cleanupIds[807], $cleanupIds[808], $cleanupIds[809], $cleanupIds[810], $cleanupIds[811], $cleanupIds[812], $cleanupIds[813], $cleanupIds[814], $cleanupIds[815], $cleanupIds[816], $cleanupIds[817], $cleanupIds[818], $cleanupIds[819], $cleanupIds[820], $cleanupIds[821], $cleanupIds[822], $cleanupIds[823], $cleanupIds[824], $cleanupIds[825], $cleanupIds[826], $cleanupIds[827], $cleanupIds[828], $cleanupIds[829], $cleanupIds[830], $cleanupIds[831], $cleanupIds[832], $cleanupIds[833], $cleanupIds[834], $cleanupIds[835], $cleanupIds[836], $cleanupIds[837], $cleanupIds[838], $cleanupIds[839], $cleanupIds[840], $cleanupIds[841], $cleanupIds[842], $cleanupIds[843], $cleanupIds[844], $cleanupIds[845], $cleanupIds[846], $cleanupIds[847], $cleanupIds[848], $cleanupIds[849], $cleanupIds[850], $cleanupIds[851], $cleanupIds[852], $cleanupIds[853], $cleanupIds[854], $cleanupIds[855], $cleanupIds[856], $cleanupIds[857], $cleanupIds[858], $cleanupIds[859], $cleanupIds[860], $cleanupIds[861], $cleanupIds[862], $cleanupIds[863], $cleanupIds[864], $cleanupIds[865], $cleanupIds[866], $cleanupIds[867], $cleanupIds[868], $cleanupIds[869], $cleanupIds[870], $cleanupIds[871], $cleanupIds[872], $cleanupIds[873], $cleanupIds[874], $cleanupIds[875], $cleanupIds[876], $cleanupIds[877], $cleanupIds[878], $cleanupIds[879], $cleanupIds[880], $cleanupIds[881], $cleanupIds[882], $cleanupIds[883], $cleanupIds[884], $cleanupIds[885], $cleanupIds[886], $cleanupIds[887], $cleanupIds[888], $cleanupIds[889], $cleanupIds[890], $cleanupIds[891], $cleanupIds[892], $cleanupIds[893], $cleanupIds[894], $cleanupIds[895], $cleanupIds[896], $cleanupIds[897], $cleanupIds[898], $cleanupIds[899], $cleanupIds[900], $cleanupIds[901], $cleanupIds[902], $cleanupIds[903], $cleanupIds[904], $cleanupIds[905], $cleanupIds[906], $cleanupIds[907], $cleanupIds[908], $cleanupIds[909], $cleanupIds[910], $cleanupIds[911], $cleanupIds[912], $cleanupIds[913], $cleanupIds[914], $cleanupIds[915], $cleanupIds[916], $cleanupIds[917], $cleanupIds[918], $cleanupIds[919], $cleanupIds[920], $cleanupIds[921], $cleanupIds[922], $cleanupIds[923], $cleanupIds[924], $cleanupIds[925], $cleanupIds[926], $cleanupIds[927], $cleanupIds[928], $cleanupIds[929], $cleanupIds[930], $cleanupIds[931], $cleanupIds[932], $cleanupIds[933], $cleanupIds[934], $cleanupIds[935], $cleanupIds[936], $cleanupIds[937], $cleanupIds[938], $cleanupIds[939], $cleanupIds[940], $cleanupIds[941], $cleanupIds[942], $cleanupIds[943], $cleanupIds[944], $cleanupIds[945], $cleanupIds[946], $cleanupIds[947], $cleanupIds[948], $cleanupIds[949], $cleanupIds[950], $cleanupIds[951], $cleanupIds[952], $cleanupIds[953], $cleanupIds[954], $cleanupIds[955], $cleanupIds[956], $cleanupIds[957], $cleanupIds[958], $cleanupIds[959], $cleanupIds[960], $cleanupIds[961], $cleanupIds[962], $cleanupIds[963], $cleanupIds[964], $cleanupIds[965], $cleanupIds[966], $cleanupIds[967], $cleanupIds[968], $cleanupIds[969], $cleanupIds[970], $cleanupIds[971], $cleanupIds[972], $cleanupIds[973], $cleanupIds[974], $cleanupIds[975], $cleanupIds[976], $cleanupIds[977], $cleanupIds[978], $cleanupIds[979], $cleanupIds[980], $cleanupIds[981], $cleanupIds[982], $cleanupIds[983], $cleanupIds[984], $cleanupIds[985], $cleanupIds[986], $cleanupIds[987], $cleanupIds[988], $cleanupIds[989], $cleanupIds[990], $cleanupIds[991], $cleanupIds[992], $cleanupIds[993], $cleanupIds[994], $cleanupIds[995], $cleanupIds[996], $cleanupIds[997], $cleanupIds[998], $cleanupIds[999], $cleanupIds[1000], $cleanupIds[1001], $cleanupIds[1002], $cleanupIds[1003], $cleanupIds[1004], $cleanupIds[1005], $cleanupIds[1006], $cleanupIds[1007], $cleanupIds[1008], $cleanupIds[1009], $cleanupIds[1010], $cleanupIds[1011], $cleanupIds[1012], $cleanupIds[1013], $cleanupIds[1014], $cleanupIds[1015], $cleanupIds[1016], $cleanupIds[1017], $cleanupIds[1018], $cleanupIds[1019], $cleanupIds[1020], $cleanupIds[1021], $cleanupIds[1022], $cleanupIds[1023], $cleanupIds[1024], $cleanupIds[1025], $cleanupIds[1026], $cleanupIds[1027], $cleanupIds[1028], $cleanupIds[1029], $cleanupIds[1030], $cleanupIds[1031], $cleanupIds[1032], $cleanupIds[1033], $cleanupIds[1034], $cleanupIds[1035], $cleanupIds[1036], $cleanupIds[1037], $cleanupIds[1038], $cleanupIds[1039], $cleanupIds[1040], $cleanupIds[1041], $cleanupIds[1042], $cleanupIds[1043], $cleanupIds[1044], $cleanupIds[1045], $cleanupIds[1046], $cleanupIds[1047], $cleanupIds[1048], $cleanupIds[1049], $cleanupIds[1050], $cleanupIds[1051], $cleanupIds[1052], $cleanupIds[1053], $cleanupIds[1054], $cleanupIds[1055], $cleanupIds[1056], $cleanupIds[1057], $cleanupIds[1058], $cleanupIds[1059], $cleanupIds[1060], $cleanupIds[1061], $cleanupIds[1062], $cleanupIds[1063], $cleanupIds[1064], $cleanupIds[1065], $cleanupIds[1066], $cleanupIds[1067], $cleanupIds[1068], $cleanupIds[1069], $cleanupIds[1070], $cleanupIds[1071], $cleanupIds[1072], $cleanupIds[1073], $cleanupIds[1074], $cleanupIds[1075], $cleanupIds[1076], $cleanupIds[1077], $cleanupIds[1078], $cleanupIds[1079], $cleanupIds[1080], $cleanupIds[1081], $cleanupIds[1082], $cleanupIds[1083], $cleanupIds[1084], $cleanupIds[1085], $cleanupIds[1086], $cleanupIds[1087], $cleanupIds[1088], $cleanupIds[1089], $cleanupIds[1090], $cleanupIds[1091], $cleanupIds[1092], $cleanupIds[1093], $cleanupIds[1094], $cleanupIds[1095], $cleanupIds[1096], $cleanupIds[1097], $cleanupIds[1098], $cleanupIds[1099], $cleanupIds[1100], $cleanupIds[1101], $cleanupIds[1102], $cleanupIds[1103], $cleanupIds[1104], $cleanupIds[1105], $cleanupIds[1106], $cleanupIds[1107], $cleanupIds[1108], $cleanupIds[1109], $cleanupIds[1110], $cleanupIds[1111], $cleanupIds[1112], $cleanupIds[1113], $cleanupIds[1114], $cleanupIds[1115], $cleanupIds[1116], $cleanupIds[1117], $cleanupIds[1118], $cleanupIds[1119], $cleanupIds[1120], $cleanupIds[1121], $cleanupIds[1122], $cleanupIds[1123], $cleanupIds[1124], $cleanupIds[1125], $cleanupIds[1126], $cleanupIds[1127], $cleanupIds[1128], $cleanupIds[1129], $cleanupIds[1130], $cleanupIds[1131], $cleanupIds[1132], $cleanupIds[1133], $cleanupIds[1134], $cleanupIds[1135], $cleanupIds[1136], $cleanupIds[1137], $cleanupIds[1138], $cleanupIds[1139], $cleanupIds[1140], $cleanupIds[1141], $cleanupIds[1142], $cleanupIds[1143], $cleanupIds[1144], $cleanupIds[1145], $cleanupIds[1146], $cleanupIds[1147], $cleanupIds[1148], $cleanupIds[1149], $cleanupIds[1150], $cleanupIds[1151], $cleanupIds[1152], $cleanupIds[1153], $cleanupIds[1154], $cleanupIds[1155], $cleanupIds[1156], $cleanupIds[1157], $cleanupIds[1158], $cleanupIds[1159], $cleanupIds[1160], $cleanupIds[1161], $cleanupIds[1162], $cleanupIds[1163], $cleanupIds[1164], $cleanupIds[1165], $cleanupIds[1166], $cleanupIds[1167], $cleanupIds[1168], $cleanupIds[1169], $cleanupIds[1170], $cleanupIds[1171], $cleanupIds[1172], $cleanupIds[1173], $cleanupIds[1174], $cleanupIds[1175], $cleanupIds[1176], $cleanupIds[1177], $cleanupIds[1178], $cleanupIds[1179], $cleanupIds[1180], $cleanupIds[1181], $cleanupIds[1182], $cleanupIds[1183], $cleanupIds[1184], $cleanupIds[1185], $cleanupIds[1186], $cleanupIds[1187], $cleanupIds[1188], $cleanupIds[1189], $cleanupIds[1190], $cleanupIds[1191], $cleanupIds[1192], $cleanupIds[1193], $cleanupIds[1194], $cleanupIds[1195], $cleanupIds[1196], $cleanupIds[1197], $cleanupIds[1198], $cleanupIds[1199], $cleanupIds[1200], $cleanupIds[1201], $cleanupIds[1202], $cleanupIds[1203], $cleanupIds[1204], $cleanupIds[1205], $cleanupIds[1206], $cleanupIds[1207], $cleanupIds[1208], $cleanupIds[1209], $cleanupIds[1210], $cleanupIds[1211], $cleanupIds[1212], $cleanupIds[1213], $cleanupIds[1214], $cleanupIds[1215], $cleanupIds[1216], $cleanupIds[1217], $cleanupIds[1218], $cleanupIds[1219], $cleanupIds[1220], $cleanupIds[1221], $cleanupIds[1222], $cleanupIds[1223], $cleanupIds[1224], $cleanupIds[1225], $cleanupIds[1226], $cleanupIds[1227], $cleanupIds[1228], $cleanupIds[1229], $cleanupIds[1230], $cleanupIds[1231], $cleanupIds[1232], $cleanupIds[1233], $cleanupIds[1234], $cleanupIds[1235], $cleanupIds[1236], $cleanupIds[1237], $cleanupIds[1238], $cleanupIds[1239], $cleanupIds[1240], $cleanupIds[1241], $cleanupIds[1242], $cleanupIds[1243], $cleanupIds[1244], $cleanupIds[1245], $cleanupIds[1246], $cleanupIds[1247], $cleanupIds[1248], $cleanupIds[1249], $cleanupIds[1250], $cleanupIds[1251], $cleanupIds[1252], $cleanupIds[1253], $cleanupIds[1254], $cleanupIds[1255], $cleanupIds[1256], $cleanupIds[1257], $cleanupIds[1258], $cleanupIds[1259], $cleanupIds[1260], $cleanupIds[1261], $cleanupIds[1262], $cleanupIds[1263], $cleanupIds[1264], $cleanupIds[1265], $cleanupIds[1266], $cleanupIds[1267], $cleanupIds[1268], $cleanupIds[1269], $cleanupIds[1270], $cleanupIds[1271], $cleanupIds[1272], $cleanupIds[1273], $cleanupIds[1274], $cleanupIds[1275], $cleanupIds[1276], $cleanupIds[1277], $cleanupIds[1278], $cleanupIds[1279], $cleanupIds[1280], $cleanupIds[1281], $cleanupIds[1282], $cleanupIds[1283], $cleanupIds[1284], $cleanupIds[1285], $cleanupIds[1286], $cleanupIds[1287], $cleanupIds[1288], $cleanupIds[1289], $cleanupIds[1290], $cleanupIds[1291], $cleanupIds[1292], $cleanupIds[1293], $cleanupIds[1294], $cleanupIds[1295], $cleanupIds[1296], $cleanupIds[1297], $cleanupIds[1298], $cleanupIds[1299], $cleanupIds[1300], $cleanupIds[1301], $cleanupIds[1302], $cleanupIds[1303], $cleanupIds[1304], $cleanupIds[1305], $cleanupIds[1306], $cleanupIds[1307], $cleanupIds[1308], $cleanupIds[1309], $cleanupIds[1310], $cleanupIds[1311], $cleanupIds[1312], $cleanupIds[1313], $cleanupIds[1314], $cleanupIds[1315], $cleanupIds[1316], $cleanupIds[1317], $cleanupIds[1318], $cleanupIds[1319], $cleanupIds[1320], $cleanupIds[1321], $cleanupIds[1322], $cleanupIds[1323], $cleanupIds[1324], $cleanupIds[1325], $cleanupIds[1326], $cleanupIds[1327], $cleanupIds[1328], $cleanupIds[1329], $cleanupIds[1330], $cleanupIds[1331], $cleanupIds[1332], $cleanupIds[1333], $cleanupIds[1334], $cleanupIds[1335], $cleanupIds[1336], $cleanupIds[1337], $cleanupIds[1338], $cleanupIds[1339], $cleanupIds[1340], $cleanupIds[1341], $cleanupIds[1342], $cleanupIds[1343], $cleanupIds[1344], $cleanupIds[1345], $cleanupIds[1346], $cleanupIds[1347], $cleanupIds[1348], $cleanupIds[1349], $cleanupIds[1350], $cleanupIds[1351], $cleanupIds[1352], $cleanupIds[1353], $cleanupIds[1354], $cleanupIds[1355], $cleanupIds[1356], $cleanupIds[1357], $cleanupIds[1358], $cleanupIds[1359], $cleanupIds[1360], $cleanupIds[1361], $cleanupIds[1362], $cleanupIds[1363], $cleanupIds[1364], $cleanupIds[1365], $cleanupIds[1366], $cleanupIds[1367], $cleanupIds[1368], $cleanupIds[1369], $cleanupIds[1370], $cleanupIds[1371], $cleanupIds[1372], $cleanupIds[1373], $cleanupIds[1374], $cleanupIds[1375], $cleanupIds[1376], $cleanupIds[1377], $cleanupIds[1378], $cleanupIds[1379], $cleanupIds[1380], $cleanupIds[1381], $cleanupIds[1382], $cleanupIds[1383], $cleanupIds[1384], $cleanupIds[1385], $cleanupIds[1386], $cleanupIds[1387], $cleanupIds[1388], $cleanupIds[1389], $cleanupIds[1390], $cleanupIds[1391], $cleanupIds[1392], $cleanupIds[1393], $cleanupIds[1394], $cleanupIds[1395], $cleanupIds[1396], $cleanupIds[1397], $cleanupIds[1398], $cleanupIds[1399], $cleanupIds[1400], $cleanupIds[1401], $cleanupIds[1402], $cleanupIds[1403], $cleanupIds[1404], $cleanupIds[1405], $cleanupIds[1406], $cleanupIds[1407], $cleanupIds[1408], $cleanupIds[1409], $cleanupIds[1410], $cleanupIds[1411], $cleanupIds[1412], $cleanupIds[1413], $cleanupIds[1414], $cleanupIds[1415], $cleanupIds[1416], $cleanupIds[1417], $cleanupIds[1418], $cleanupIds[1419], $cleanupIds[1420], $cleanupIds[1421], $cleanupIds[1422], $cleanupIds[1423], $cleanupIds[1424], $cleanupIds[1425], $cleanupIds[1426], $cleanupIds[1427], $cleanupIds[1428], $cleanupIds[1429], $cleanupIds[1430], $cleanupIds[1431], $cleanupIds[1432], $cleanupIds[1433], $cleanupIds[1434], $cleanupIds[1435], $cleanupIds[1436], $cleanupIds[1437], $cleanupIds[1438], $cleanupIds[1439], $cleanupIds[1440], $cleanupIds[1441], $cleanupIds[1442], $cleanupIds[1443], $cleanupIds[1444], $cleanupIds[1445], $cleanupIds[1446], $cleanupIds[1447], $cleanupIds[1448], $cleanupIds[1449], $cleanupIds[1450], $cleanupIds[1451], $cleanupIds[1452], $cleanupIds[1453], $cleanupIds[1454], $cleanupIds[1455], $cleanupIds[1456], $cleanupIds[1457], $cleanupIds[1458], $cleanupIds[1459], $cleanupIds[1460], $cleanupIds[1461], $cleanupIds[1462], $cleanupIds[1463], $cleanupIds[1464], $cleanupIds[1465], $cleanupIds[1466], $cleanupIds[1467], $cleanupIds[1468], $cleanupIds[1469], $cleanupIds[1470], $cleanupIds[1471], $cleanupIds[1472], $cleanupIds[1473], $cleanupIds[1474], $cleanupIds[1475], $cleanupIds[1476], $cleanupIds[1477], $cleanupIds[1478], $cleanupIds[1479], $cleanupIds[1480], $cleanupIds[1481], $cleanupIds[1482], $cleanupIds[1483], $cleanupIds[1484], $cleanupIds[1485], $cleanupIds[1486], $cleanupIds[1487], $cleanupIds[1488], $cleanupIds[1489], $cleanupIds[1490], $cleanupIds[1491], $cleanupIds[1492], $cleanupIds[1493], $cleanupIds[1494], $cleanupIds[1495], $cleanupIds[1496], $cleanupIds[1497], $cleanupIds[1498], $cleanupIds[1499], $cleanupIds[1500], $cleanupIds[1501], $cleanupIds[1502], $cleanupIds[1503], $cleanupIds[1504], $cleanupIds[1505], $cleanupIds[1506], $cleanupIds[1507], $cleanupIds[1508], $cleanupIds[1509], $cleanupIds[1510], $cleanupIds[1511], $cleanupIds[1512], $cleanupIds[1513], $cleanupIds[1514], $cleanupIds[1515], $cleanupIds[1516], $cleanupIds[1517], $cleanupIds[1518], $cleanupIds[1519], $cleanupIds[1520], $cleanupIds[1521], $cleanupIds[1522], $cleanupIds[1523], $cleanupIds[1524], $cleanupIds[1525], $cleanupIds[1526], $cleanupIds[1527], $cleanupIds[1528], $cleanupIds[1529], $cleanupIds[1530], $cleanupIds[1531], $cleanupIds[1532], $cleanupIds[1533], $cleanupIds[1534], $cleanupIds[1535], $cleanupIds[1536], $cleanupIds[1537], $cleanupIds[1538], $cleanupIds[1539], $cleanupIds[1540], $cleanupIds[1541], $cleanupIds[1542], $cleanupIds[1543], $cleanupIds[1544], $cleanupIds[1545], $cleanupIds[1546], $cleanupIds[1547], $cleanupIds[1548], $cleanupIds[1549], $cleanupIds[1550], $cleanupIds[1551], $cleanupIds[1552], $cleanupIds[1553], $cleanupIds[1554], $cleanupIds[1555], $cleanupIds[1556], $cleanupIds[1557], $cleanupIds[1558], $cleanupIds[1559], $cleanupIds[1560], $cleanupIds[1561], $cleanupIds[1562], $cleanupIds[1563], $cleanupIds[1564], $cleanupIds[1565], $cleanupIds[1566], $cleanupIds[1567], $cleanupIds[1568], $cleanupIds[1569], $cleanupIds[1570], $cleanupIds[1571], $cleanupIds[1572], $cleanupIds[1573], $cleanupIds[1574], $cleanupIds[1575], $cleanupIds[1576], $cleanupIds[1577], $cleanupIds[1578], $cleanupIds[1579], $cleanupIds[1580], $cleanupIds[1581], $cleanupIds[1582], $cleanupIds[1583], $cleanupIds[1584], $cleanupIds[1585], $cleanupIds[1586], $cleanupIds[1587], $cleanupIds[1588], $cleanupIds[1589], $cleanupIds[1590], $cleanupIds[1591], $cleanupIds[1592], $cleanupIds[1593], $cleanupIds[1594], $cleanupIds[1595], $cleanupIds[1596], $cleanupIds[1597], $cleanupIds[1598], $cleanupIds[1599], $cleanupIds[1600], $cleanupIds[1601], $cleanupIds[1602], $cleanupIds[1603], $cleanupIds[1604], $cleanupIds[1605], $cleanupIds[1606], $cleanupIds[1607], $cleanupIds[1608], $cleanupIds[1609], $cleanupIds[1610], $cleanupIds[1611], $cleanupIds[1612], $cleanupIds[1613], $cleanupIds[1614], $cleanupIds[1615], $cleanupIds[1616], $cleanupIds[1617], $cleanupIds[1618], $cleanupIds[1619], $cleanupIds[1620], $cleanupIds[1621], $cleanupIds[1622], $cleanupIds[1623], $cleanupIds[1624], $cleanupIds[1625], $cleanupIds[1626], $cleanupIds[1627], $cleanupIds[1628], $cleanupIds[1629], $cleanupIds[1630], $cleanupIds[1631], $cleanupIds[1632], $cleanupIds[1633], $cleanupIds[1634], $cleanupIds[1635], $cleanupIds[1636], $cleanupIds[1637], $cleanupIds[1638], $cleanupIds[1639], $cleanupIds[1640], $cleanupIds[1641], $cleanupIds[1642], $cleanupIds[1643], $cleanupIds[1644], $cleanupIds[1645], $cleanupIds[1646], $cleanupIds[1647], $cleanupIds[1648], $cleanupIds[1649], $cleanupIds[1650], $cleanupIds[1651], $cleanupIds[1652], $cleanupIds[1653], $cleanupIds[1654], $cleanupIds[1655], $cleanupIds[1656], $cleanupIds[1657], $cleanupIds[1658], $cleanupIds[1659], $cleanupIds[1660], $cleanupIds[1661], $cleanupIds[1662], $cleanupIds[1663], $cleanupIds[1664], $cleanupIds[1665], $cleanupIds[1666], $cleanupIds[1667], $cleanupIds[1668], $cleanupIds[1669], $cleanupIds[1670], $cleanupIds[1671], $cleanupIds[1672], $cleanupIds[1673], $cleanupIds[1674], $cleanupIds[1675], $cleanupIds[1676], $cleanupIds[1677], $cleanupIds[1678], $cleanupIds[1679], $cleanupIds[1680], $cleanupIds[1681], $cleanupIds[1682], $cleanupIds[1683], $cleanupIds[1684], $cleanupIds[1685], $cleanupIds[1686], $cleanupIds[1687], $cleanupIds[1688], $cleanupIds[1689], $cleanupIds[1690], $cleanupIds[1691], $cleanupIds[1692], $cleanupIds[1693], $cleanupIds[1694], $cleanupIds[1695], $cleanupIds[1696], $cleanupIds[1697], $cleanupIds[1698], $cleanupIds[1699], $cleanupIds[1700], $cleanupIds[1701], $cleanupIds[1702], $cleanupIds[1703], $cleanupIds[1704], $cleanupIds[1705], $cleanupIds[1706], $cleanupIds[1707], $cleanupIds[1708], $cleanupIds[1709], $cleanupIds[1710], $cleanupIds[1711], $cleanupIds[1712], $cleanupIds[1713], $cleanupIds[1714], $cleanupIds[1715], $cleanupIds[1716], $cleanupIds[1717], $cleanupIds[1718], $cleanupIds[1719], $cleanupIds[1720], $cleanupIds[1721], $cleanupIds[1722], $cleanupIds[1723], $cleanupIds[1724], $cleanupIds[1725], $cleanupIds[1726], $cleanupIds[1727], $cleanupIds[1728], $cleanupIds[1729], $cleanupIds[1730], $cleanupIds[1731], $cleanupIds[1732], $cleanupIds[1733], $cleanupIds[1734], $cleanupIds[1735], $cleanupIds[1736], $cleanupIds[1737], $cleanupIds[1738], $cleanupIds[1739], $cleanupIds[1740], $cleanupIds[1741], $cleanupIds[1742], $cleanupIds[1743], $cleanupIds[1744], $cleanupIds[1745], $cleanupIds[1746], $cleanupIds[1747], $cleanupIds[1748], $cleanupIds[1749], $cleanupIds[1750], $cleanupIds[1751], $cleanupIds[1752], $cleanupIds[1753], $cleanupIds[1754], $cleanupIds[1755], $cleanupIds[1756], $cleanupIds[1757], $cleanupIds[1758], $cleanupIds[1759], $cleanupIds[1760], $cleanupIds[1761], $cleanupIds[1762], $cleanupIds[1763], $cleanupIds[1764], $cleanupIds[1765], $cleanupIds[1766], $cleanupIds[1767], $cleanupIds[1768], $cleanupIds[1769], $cleanupIds[1770], $cleanupIds[1771], $cleanupIds[1772], $cleanupIds[1773], $cleanupIds[1774], $cleanupIds[1775], $cleanupIds[1776], $cleanupIds[1777], $cleanupIds[1778], $cleanupIds[1779], $cleanupIds[1780], $cleanupIds[1781], $cleanupIds[1782], $cleanupIds[1783], $cleanupIds[1784], $cleanupIds[1785], $cleanupIds[1786], $cleanupIds[1787], $cleanupIds[1788], $cleanupIds[1789], $cleanupIds[1790], $cleanupIds[1791], $cleanupIds[1792], $cleanupIds[1793], $cleanupIds[1794], $cleanupIds[1795], $cleanupIds[1796], $cleanupIds[1797], $cleanupIds[1798], $cleanupIds[1799], $cleanupIds[1800], $cleanupIds[1801], $cleanupIds[1802], $cleanupIds[1803], $cleanupIds[1804], $cleanupIds[1805], $cleanupIds[1806], $cleanupIds[1807], $cleanupIds[1808], $cleanupIds[1809], $cleanupIds[1810], $cleanupIds[1811], $cleanupIds[1812], $cleanupIds[1813], $cleanupIds[1814], $cleanupIds[1815], $cleanupIds[1816], $cleanupIds[1817], $cleanupIds[1818], $cleanupIds[1819], $cleanupIds[1820], $cleanupIds[1821], $cleanupIds[1822], $cleanupIds[1823], $cleanupIds[1824], $cleanupIds[1825], $cleanupIds[1826], $cleanupIds[1827], $cleanupIds[1828], $cleanupIds[1829], $cleanupIds[1830], $cleanupIds[1831], $cleanupIds[1832], $cleanupIds[1833], $cleanupIds[1834], $cleanupIds[1835], $cleanupIds[1836], $cleanupIds[1837], $cleanupIds[1838], $cleanupIds[1839], $cleanupIds[1840], $cleanupIds[1841], $cleanupIds[1842], $cleanupIds[1843], $cleanupIds[1844], $cleanupIds[1845], $cleanupIds[1846], $cleanupIds[1847], $cleanupIds[1848], $cleanupIds[1849], $cleanupIds[1850], $cleanupIds[1851], $cleanupIds[1852], $cleanupIds[1853], $cleanupIds[1854], $cleanupIds[1855], $cleanupIds[1856], $cleanupIds[1857], $cleanupIds[1858], $cleanupIds[1859], $cleanupIds[1860], $cleanupIds[1861], $cleanupIds[1862], $cleanupIds[1863], $cleanupIds[1864], $cleanupIds[1865], $cleanupIds[1866], $cleanupIds[1867], $cleanupIds[1868], $cleanupIds[1869], $cleanupIds[1870], $cleanupIds[1871], $cleanupIds[1872], $cleanupIds[1873], $cleanupIds[1874], $cleanupIds[1875], $cleanupIds[1876], $cleanupIds[1877], $cleanupIds[1878], $cleanupIds[1879], $cleanupIds[1880], $cleanupIds[1881], $cleanupIds[1882], $cleanupIds[1883], $cleanupIds[1884], $cleanupIds[1885], $cleanupIds[1886], $cleanupIds[1887], $cleanupIds[1888], $cleanupIds[1889], $cleanupIds[1890], $cleanupIds[1891], $cleanupIds[1892], $cleanupIds[1893], $cleanupIds[1894], $cleanupIds[1895], $cleanupIds[1896], $cleanupIds[1897], $cleanupIds[1898], $cleanupIds[1899], $cleanupIds[1900], $cleanupIds[1901], $cleanupIds[1902], $cleanupIds[1903], $cleanupIds[1904], $cleanupIds[1905], $cleanupIds[1906], $cleanupIds[1907], $cleanupIds[1908], $cleanupIds[1909], $cleanupIds[1910], $cleanupIds[1911], $cleanupIds[1912], $cleanupIds[1913], $cleanupIds[1914], $cleanupIds[1915], $cleanupIds[1916], $cleanupIds[1917], $cleanupIds[1918], $cleanupIds[1919], $cleanupIds[1920], $cleanupIds[1921], $cleanupIds[1922], $cleanupIds[1923], $cleanupIds[1924], $cleanupIds[1925], $cleanupIds[1926], $cleanupIds[1927], $cleanupIds[1928], $cleanupIds[1929], $cleanupIds[1930], $cleanupIds[1931], $cleanupIds[1932], $cleanupIds[1933], $cleanupIds[1934], $cleanupIds[1935], $cleanupIds[1936], $cleanupIds[1937], $cleanupIds[1938], $cleanupIds[1939], $cleanupIds[1940], $cleanupIds[1941], $cleanupIds[1942], $cleanupIds[1943], $cleanupIds[1944], $cleanupIds[1945], $cleanupIds[1946], $cleanupIds[1947], $cleanupIds[1948], $cleanupIds[1949], $cleanupIds[1950], $cleanupIds[1951], $cleanupIds[1952], $cleanupIds[1953], $cleanupIds[1954], $cleanupIds[1955], $cleanupIds[1956], $cleanupIds[1957], $cleanupIds[1958], $cleanupIds[1959], $cleanupIds[1960], $cleanupIds[1961], $cleanupIds[1962], $cleanupIds[1963], $cleanupIds[1964], $cleanupIds[1965], $cleanupIds[1966], $cleanupIds[1967], $cleanupIds[1968], $cleanupIds[1969], $cleanupIds[1970], $cleanupIds[1971], $cleanupIds[1972], $cleanupIds[1973], $cleanupIds[1974], $cleanupIds[1975], $cleanupIds[1976], $cleanupIds[1977], $cleanupIds[1978], $cleanupIds[1979], $cleanupIds[1980], $cleanupIds[1981], $cleanupIds[1982], $cleanupIds[1983], $cleanupIds[1984], $cleanupIds[1985], $cleanupIds[1986], $cleanupIds[1987], $cleanupIds[1988], $cleanupIds[1989], $cleanupIds[1990], $cleanupIds[1991], $cleanupIds[1992], $cleanupIds[1993], $cleanupIds[1994], $cleanupIds[1995], $cleanupIds[1996], $cleanupIds[1997], $cleanupIds[1998], $cleanupIds[1999], $cleanupIds[2000], $cleanupIds[2001], $cleanupIds[2002], $cleanupIds[2003], $cleanupIds[2004], $cleanupIds[2005], $cleanupIds[2006]); + $stmt->bind_param('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', $model, $cleanupIds[0], $cleanupIds[1], $cleanupIds[2], $cleanupIds[3], $cleanupIds[4], $cleanupIds[5], $cleanupIds[6], $cleanupIds[7], $cleanupIds[8], $cleanupIds[9], $cleanupIds[10], $cleanupIds[11], $cleanupIds[12], $cleanupIds[13], $cleanupIds[14], $cleanupIds[15], $cleanupIds[16], $cleanupIds[17], $cleanupIds[18], $cleanupIds[19], $cleanupIds[20], $cleanupIds[21], $cleanupIds[22], $cleanupIds[23], $cleanupIds[24], $cleanupIds[25], $cleanupIds[26], $cleanupIds[27], $cleanupIds[28], $cleanupIds[29], $cleanupIds[30], $cleanupIds[31], $cleanupIds[32], $cleanupIds[33], $cleanupIds[34], $cleanupIds[35], $cleanupIds[36], $cleanupIds[37], $cleanupIds[38], $cleanupIds[39], $cleanupIds[40], $cleanupIds[41], $cleanupIds[42], $cleanupIds[43], $cleanupIds[44], $cleanupIds[45], $cleanupIds[46], $cleanupIds[47], $cleanupIds[48], $cleanupIds[49], $cleanupIds[50], $cleanupIds[51], $cleanupIds[52], $cleanupIds[53], $cleanupIds[54], $cleanupIds[55], $cleanupIds[56], $cleanupIds[57], $cleanupIds[58], $cleanupIds[59], $cleanupIds[60], $cleanupIds[61], $cleanupIds[62], $cleanupIds[63], $cleanupIds[64], $cleanupIds[65], $cleanupIds[66], $cleanupIds[67], $cleanupIds[68], $cleanupIds[69], $cleanupIds[70], $cleanupIds[71], $cleanupIds[72], $cleanupIds[73], $cleanupIds[74], $cleanupIds[75], $cleanupIds[76], $cleanupIds[77], $cleanupIds[78], $cleanupIds[79], $cleanupIds[80], $cleanupIds[81], $cleanupIds[82], $cleanupIds[83], $cleanupIds[84], $cleanupIds[85], $cleanupIds[86], $cleanupIds[87], $cleanupIds[88], $cleanupIds[89], $cleanupIds[90], $cleanupIds[91], $cleanupIds[92], $cleanupIds[93], $cleanupIds[94], $cleanupIds[95], $cleanupIds[96], $cleanupIds[97], $cleanupIds[98], $cleanupIds[99], $cleanupIds[100], $cleanupIds[101], $cleanupIds[102], $cleanupIds[103], $cleanupIds[104], $cleanupIds[105], $cleanupIds[106], $cleanupIds[107], $cleanupIds[108], $cleanupIds[109], $cleanupIds[110], $cleanupIds[111], $cleanupIds[112], $cleanupIds[113], $cleanupIds[114], $cleanupIds[115], $cleanupIds[116], $cleanupIds[117], $cleanupIds[118], $cleanupIds[119], $cleanupIds[120], $cleanupIds[121], $cleanupIds[122], $cleanupIds[123], $cleanupIds[124], $cleanupIds[125], $cleanupIds[126], $cleanupIds[127], $cleanupIds[128], $cleanupIds[129], $cleanupIds[130], $cleanupIds[131], $cleanupIds[132], $cleanupIds[133], $cleanupIds[134], $cleanupIds[135], $cleanupIds[136], $cleanupIds[137], $cleanupIds[138], $cleanupIds[139], $cleanupIds[140], $cleanupIds[141], $cleanupIds[142], $cleanupIds[143], $cleanupIds[144], $cleanupIds[145], $cleanupIds[146], $cleanupIds[147], $cleanupIds[148], $cleanupIds[149], $cleanupIds[150], $cleanupIds[151], $cleanupIds[152], $cleanupIds[153], $cleanupIds[154], $cleanupIds[155], $cleanupIds[156], $cleanupIds[157], $cleanupIds[158], $cleanupIds[159], $cleanupIds[160], $cleanupIds[161], $cleanupIds[162], $cleanupIds[163], $cleanupIds[164], $cleanupIds[165], $cleanupIds[166], $cleanupIds[167], $cleanupIds[168], $cleanupIds[169], $cleanupIds[170], $cleanupIds[171], $cleanupIds[172], $cleanupIds[173], $cleanupIds[174], $cleanupIds[175], $cleanupIds[176], $cleanupIds[177], $cleanupIds[178], $cleanupIds[179], $cleanupIds[180], $cleanupIds[181], $cleanupIds[182], $cleanupIds[183], $cleanupIds[184], $cleanupIds[185], $cleanupIds[186], $cleanupIds[187], $cleanupIds[188], $cleanupIds[189], $cleanupIds[190], $cleanupIds[191], $cleanupIds[192], $cleanupIds[193], $cleanupIds[194], $cleanupIds[195], $cleanupIds[196], $cleanupIds[197], $cleanupIds[198], $cleanupIds[199], $cleanupIds[200], $cleanupIds[201], $cleanupIds[202], $cleanupIds[203], $cleanupIds[204], $cleanupIds[205], $cleanupIds[206], $cleanupIds[207], $cleanupIds[208], $cleanupIds[209], $cleanupIds[210], $cleanupIds[211], $cleanupIds[212], $cleanupIds[213], $cleanupIds[214], $cleanupIds[215], $cleanupIds[216], $cleanupIds[217], $cleanupIds[218], $cleanupIds[219], $cleanupIds[220], $cleanupIds[221], $cleanupIds[222], $cleanupIds[223], $cleanupIds[224], $cleanupIds[225], $cleanupIds[226], $cleanupIds[227], $cleanupIds[228], $cleanupIds[229], $cleanupIds[230], $cleanupIds[231], $cleanupIds[232], $cleanupIds[233], $cleanupIds[234], $cleanupIds[235], $cleanupIds[236], $cleanupIds[237], $cleanupIds[238], $cleanupIds[239], $cleanupIds[240], $cleanupIds[241], $cleanupIds[242], $cleanupIds[243], $cleanupIds[244], $cleanupIds[245], $cleanupIds[246], $cleanupIds[247], $cleanupIds[248], $cleanupIds[249], $cleanupIds[250], $cleanupIds[251], $cleanupIds[252], $cleanupIds[253], $cleanupIds[254], $cleanupIds[255], $cleanupIds[256], $cleanupIds[257], $cleanupIds[258], $cleanupIds[259], $cleanupIds[260], $cleanupIds[261], $cleanupIds[262], $cleanupIds[263], $cleanupIds[264], $cleanupIds[265], $cleanupIds[266], $cleanupIds[267], $cleanupIds[268], $cleanupIds[269], $cleanupIds[270], $cleanupIds[271], $cleanupIds[272], $cleanupIds[273], $cleanupIds[274], $cleanupIds[275], $cleanupIds[276], $cleanupIds[277], $cleanupIds[278], $cleanupIds[279], $cleanupIds[280], $cleanupIds[281], $cleanupIds[282], $cleanupIds[283], $cleanupIds[284], $cleanupIds[285], $cleanupIds[286], $cleanupIds[287], $cleanupIds[288], $cleanupIds[289], $cleanupIds[290], $cleanupIds[291], $cleanupIds[292], $cleanupIds[293], $cleanupIds[294], $cleanupIds[295], $cleanupIds[296], $cleanupIds[297], $cleanupIds[298], $cleanupIds[299], $cleanupIds[300], $cleanupIds[301], $cleanupIds[302], $cleanupIds[303], $cleanupIds[304], $cleanupIds[305], $cleanupIds[306], $cleanupIds[307], $cleanupIds[308], $cleanupIds[309], $cleanupIds[310], $cleanupIds[311], $cleanupIds[312], $cleanupIds[313], $cleanupIds[314], $cleanupIds[315], $cleanupIds[316], $cleanupIds[317], $cleanupIds[318], $cleanupIds[319], $cleanupIds[320], $cleanupIds[321], $cleanupIds[322], $cleanupIds[323], $cleanupIds[324], $cleanupIds[325], $cleanupIds[326], $cleanupIds[327], $cleanupIds[328], $cleanupIds[329], $cleanupIds[330], $cleanupIds[331], $cleanupIds[332], $cleanupIds[333], $cleanupIds[334], $cleanupIds[335], $cleanupIds[336], $cleanupIds[337], $cleanupIds[338], $cleanupIds[339], $cleanupIds[340], $cleanupIds[341], $cleanupIds[342], $cleanupIds[343], $cleanupIds[344], $cleanupIds[345], $cleanupIds[346], $cleanupIds[347], $cleanupIds[348], $cleanupIds[349], $cleanupIds[350], $cleanupIds[351], $cleanupIds[352], $cleanupIds[353], $cleanupIds[354], $cleanupIds[355], $cleanupIds[356], $cleanupIds[357], $cleanupIds[358], $cleanupIds[359], $cleanupIds[360], $cleanupIds[361], $cleanupIds[362], $cleanupIds[363], $cleanupIds[364], $cleanupIds[365], $cleanupIds[366], $cleanupIds[367], $cleanupIds[368], $cleanupIds[369], $cleanupIds[370], $cleanupIds[371], $cleanupIds[372], $cleanupIds[373], $cleanupIds[374], $cleanupIds[375], $cleanupIds[376], $cleanupIds[377], $cleanupIds[378], $cleanupIds[379], $cleanupIds[380], $cleanupIds[381], $cleanupIds[382], $cleanupIds[383], $cleanupIds[384], $cleanupIds[385], $cleanupIds[386], $cleanupIds[387], $cleanupIds[388], $cleanupIds[389], $cleanupIds[390], $cleanupIds[391], $cleanupIds[392], $cleanupIds[393], $cleanupIds[394], $cleanupIds[395], $cleanupIds[396], $cleanupIds[397], $cleanupIds[398], $cleanupIds[399], $cleanupIds[400], $cleanupIds[401], $cleanupIds[402], $cleanupIds[403], $cleanupIds[404], $cleanupIds[405], $cleanupIds[406], $cleanupIds[407], $cleanupIds[408], $cleanupIds[409], $cleanupIds[410], $cleanupIds[411], $cleanupIds[412], $cleanupIds[413], $cleanupIds[414], $cleanupIds[415], $cleanupIds[416], $cleanupIds[417], $cleanupIds[418], $cleanupIds[419], $cleanupIds[420], $cleanupIds[421], $cleanupIds[422], $cleanupIds[423], $cleanupIds[424], $cleanupIds[425], $cleanupIds[426], $cleanupIds[427], $cleanupIds[428], $cleanupIds[429], $cleanupIds[430], $cleanupIds[431], $cleanupIds[432], $cleanupIds[433], $cleanupIds[434], $cleanupIds[435], $cleanupIds[436], $cleanupIds[437], $cleanupIds[438], $cleanupIds[439], $cleanupIds[440], $cleanupIds[441], $cleanupIds[442], $cleanupIds[443], $cleanupIds[444], $cleanupIds[445], $cleanupIds[446], $cleanupIds[447], $cleanupIds[448], $cleanupIds[449], $cleanupIds[450], $cleanupIds[451], $cleanupIds[452], $cleanupIds[453], $cleanupIds[454], $cleanupIds[455], $cleanupIds[456], $cleanupIds[457], $cleanupIds[458], $cleanupIds[459], $cleanupIds[460], $cleanupIds[461], $cleanupIds[462], $cleanupIds[463], $cleanupIds[464], $cleanupIds[465], $cleanupIds[466], $cleanupIds[467], $cleanupIds[468], $cleanupIds[469], $cleanupIds[470], $cleanupIds[471], $cleanupIds[472], $cleanupIds[473], $cleanupIds[474], $cleanupIds[475], $cleanupIds[476], $cleanupIds[477], $cleanupIds[478], $cleanupIds[479], $cleanupIds[480], $cleanupIds[481], $cleanupIds[482], $cleanupIds[483], $cleanupIds[484], $cleanupIds[485], $cleanupIds[486], $cleanupIds[487], $cleanupIds[488], $cleanupIds[489], $cleanupIds[490], $cleanupIds[491], $cleanupIds[492], $cleanupIds[493], $cleanupIds[494], $cleanupIds[495], $cleanupIds[496], $cleanupIds[497], $cleanupIds[498], $cleanupIds[499], $cleanupIds[500], $cleanupIds[501], $cleanupIds[502], $cleanupIds[503], $cleanupIds[504], $cleanupIds[505], $cleanupIds[506], $cleanupIds[507], $cleanupIds[508], $cleanupIds[509], $cleanupIds[510], $cleanupIds[511], $cleanupIds[512], $cleanupIds[513], $cleanupIds[514], $cleanupIds[515], $cleanupIds[516], $cleanupIds[517], $cleanupIds[518], $cleanupIds[519], $cleanupIds[520], $cleanupIds[521], $cleanupIds[522], $cleanupIds[523], $cleanupIds[524], $cleanupIds[525], $cleanupIds[526], $cleanupIds[527], $cleanupIds[528], $cleanupIds[529], $cleanupIds[530], $cleanupIds[531], $cleanupIds[532], $cleanupIds[533], $cleanupIds[534], $cleanupIds[535], $cleanupIds[536], $cleanupIds[537], $cleanupIds[538], $cleanupIds[539], $cleanupIds[540], $cleanupIds[541], $cleanupIds[542], $cleanupIds[543], $cleanupIds[544], $cleanupIds[545], $cleanupIds[546], $cleanupIds[547], $cleanupIds[548], $cleanupIds[549], $cleanupIds[550], $cleanupIds[551], $cleanupIds[552], $cleanupIds[553], $cleanupIds[554], $cleanupIds[555], $cleanupIds[556], $cleanupIds[557], $cleanupIds[558], $cleanupIds[559], $cleanupIds[560], $cleanupIds[561], $cleanupIds[562], $cleanupIds[563], $cleanupIds[564], $cleanupIds[565], $cleanupIds[566], $cleanupIds[567], $cleanupIds[568], $cleanupIds[569], $cleanupIds[570], $cleanupIds[571], $cleanupIds[572], $cleanupIds[573], $cleanupIds[574], $cleanupIds[575], $cleanupIds[576], $cleanupIds[577], $cleanupIds[578], $cleanupIds[579], $cleanupIds[580], $cleanupIds[581], $cleanupIds[582], $cleanupIds[583], $cleanupIds[584], $cleanupIds[585], $cleanupIds[586], $cleanupIds[587], $cleanupIds[588], $cleanupIds[589], $cleanupIds[590], $cleanupIds[591], $cleanupIds[592], $cleanupIds[593], $cleanupIds[594], $cleanupIds[595], $cleanupIds[596], $cleanupIds[597], $cleanupIds[598], $cleanupIds[599], $cleanupIds[600], $cleanupIds[601], $cleanupIds[602], $cleanupIds[603], $cleanupIds[604], $cleanupIds[605], $cleanupIds[606], $cleanupIds[607], $cleanupIds[608], $cleanupIds[609], $cleanupIds[610], $cleanupIds[611], $cleanupIds[612], $cleanupIds[613], $cleanupIds[614], $cleanupIds[615], $cleanupIds[616], $cleanupIds[617], $cleanupIds[618], $cleanupIds[619], $cleanupIds[620], $cleanupIds[621], $cleanupIds[622], $cleanupIds[623], $cleanupIds[624], $cleanupIds[625], $cleanupIds[626], $cleanupIds[627], $cleanupIds[628], $cleanupIds[629], $cleanupIds[630], $cleanupIds[631], $cleanupIds[632], $cleanupIds[633], $cleanupIds[634], $cleanupIds[635], $cleanupIds[636], $cleanupIds[637], $cleanupIds[638], $cleanupIds[639], $cleanupIds[640], $cleanupIds[641], $cleanupIds[642], $cleanupIds[643], $cleanupIds[644], $cleanupIds[645], $cleanupIds[646], $cleanupIds[647], $cleanupIds[648], $cleanupIds[649], $cleanupIds[650], $cleanupIds[651], $cleanupIds[652], $cleanupIds[653], $cleanupIds[654], $cleanupIds[655], $cleanupIds[656], $cleanupIds[657], $cleanupIds[658], $cleanupIds[659], $cleanupIds[660], $cleanupIds[661], $cleanupIds[662], $cleanupIds[663], $cleanupIds[664], $cleanupIds[665], $cleanupIds[666], $cleanupIds[667], $cleanupIds[668], $cleanupIds[669], $cleanupIds[670], $cleanupIds[671], $cleanupIds[672], $cleanupIds[673], $cleanupIds[674], $cleanupIds[675], $cleanupIds[676], $cleanupIds[677], $cleanupIds[678], $cleanupIds[679], $cleanupIds[680], $cleanupIds[681], $cleanupIds[682], $cleanupIds[683], $cleanupIds[684], $cleanupIds[685], $cleanupIds[686], $cleanupIds[687], $cleanupIds[688], $cleanupIds[689], $cleanupIds[690], $cleanupIds[691], $cleanupIds[692], $cleanupIds[693], $cleanupIds[694], $cleanupIds[695], $cleanupIds[696], $cleanupIds[697], $cleanupIds[698], $cleanupIds[699], $cleanupIds[700], $cleanupIds[701], $cleanupIds[702], $cleanupIds[703], $cleanupIds[704], $cleanupIds[705], $cleanupIds[706], $cleanupIds[707], $cleanupIds[708], $cleanupIds[709], $cleanupIds[710], $cleanupIds[711], $cleanupIds[712], $cleanupIds[713], $cleanupIds[714], $cleanupIds[715], $cleanupIds[716], $cleanupIds[717], $cleanupIds[718], $cleanupIds[719], $cleanupIds[720], $cleanupIds[721], $cleanupIds[722], $cleanupIds[723], $cleanupIds[724], $cleanupIds[725], $cleanupIds[726], $cleanupIds[727], $cleanupIds[728], $cleanupIds[729], $cleanupIds[730], $cleanupIds[731], $cleanupIds[732], $cleanupIds[733], $cleanupIds[734], $cleanupIds[735], $cleanupIds[736], $cleanupIds[737], $cleanupIds[738], $cleanupIds[739], $cleanupIds[740], $cleanupIds[741], $cleanupIds[742], $cleanupIds[743], $cleanupIds[744], $cleanupIds[745], $cleanupIds[746], $cleanupIds[747], $cleanupIds[748], $cleanupIds[749], $cleanupIds[750], $cleanupIds[751], $cleanupIds[752], $cleanupIds[753], $cleanupIds[754], $cleanupIds[755], $cleanupIds[756], $cleanupIds[757], $cleanupIds[758], $cleanupIds[759], $cleanupIds[760], $cleanupIds[761], $cleanupIds[762], $cleanupIds[763], $cleanupIds[764], $cleanupIds[765], $cleanupIds[766], $cleanupIds[767], $cleanupIds[768], $cleanupIds[769], $cleanupIds[770], $cleanupIds[771], $cleanupIds[772], $cleanupIds[773], $cleanupIds[774], $cleanupIds[775], $cleanupIds[776], $cleanupIds[777], $cleanupIds[778], $cleanupIds[779], $cleanupIds[780], $cleanupIds[781], $cleanupIds[782], $cleanupIds[783], $cleanupIds[784], $cleanupIds[785], $cleanupIds[786], $cleanupIds[787], $cleanupIds[788], $cleanupIds[789], $cleanupIds[790], $cleanupIds[791], $cleanupIds[792], $cleanupIds[793], $cleanupIds[794], $cleanupIds[795], $cleanupIds[796], $cleanupIds[797], $cleanupIds[798], $cleanupIds[799], $cleanupIds[800], $cleanupIds[801], $cleanupIds[802], $cleanupIds[803], $cleanupIds[804], $cleanupIds[805], $cleanupIds[806], $cleanupIds[807], $cleanupIds[808], $cleanupIds[809], $cleanupIds[810], $cleanupIds[811], $cleanupIds[812], $cleanupIds[813], $cleanupIds[814], $cleanupIds[815], $cleanupIds[816], $cleanupIds[817], $cleanupIds[818], $cleanupIds[819], $cleanupIds[820], $cleanupIds[821], $cleanupIds[822], $cleanupIds[823], $cleanupIds[824], $cleanupIds[825], $cleanupIds[826], $cleanupIds[827], $cleanupIds[828], $cleanupIds[829], $cleanupIds[830], $cleanupIds[831], $cleanupIds[832], $cleanupIds[833], $cleanupIds[834], $cleanupIds[835], $cleanupIds[836], $cleanupIds[837], $cleanupIds[838], $cleanupIds[839], $cleanupIds[840], $cleanupIds[841], $cleanupIds[842], $cleanupIds[843], $cleanupIds[844], $cleanupIds[845], $cleanupIds[846], $cleanupIds[847], $cleanupIds[848], $cleanupIds[849], $cleanupIds[850], $cleanupIds[851], $cleanupIds[852], $cleanupIds[853], $cleanupIds[854], $cleanupIds[855], $cleanupIds[856], $cleanupIds[857], $cleanupIds[858], $cleanupIds[859], $cleanupIds[860], $cleanupIds[861], $cleanupIds[862], $cleanupIds[863], $cleanupIds[864], $cleanupIds[865], $cleanupIds[866], $cleanupIds[867], $cleanupIds[868], $cleanupIds[869], $cleanupIds[870], $cleanupIds[871], $cleanupIds[872], $cleanupIds[873], $cleanupIds[874], $cleanupIds[875], $cleanupIds[876], $cleanupIds[877], $cleanupIds[878], $cleanupIds[879], $cleanupIds[880], $cleanupIds[881], $cleanupIds[882], $cleanupIds[883], $cleanupIds[884], $cleanupIds[885], $cleanupIds[886], $cleanupIds[887], $cleanupIds[888], $cleanupIds[889], $cleanupIds[890], $cleanupIds[891], $cleanupIds[892], $cleanupIds[893], $cleanupIds[894], $cleanupIds[895], $cleanupIds[896], $cleanupIds[897], $cleanupIds[898], $cleanupIds[899], $cleanupIds[900], $cleanupIds[901], $cleanupIds[902], $cleanupIds[903], $cleanupIds[904], $cleanupIds[905], $cleanupIds[906], $cleanupIds[907], $cleanupIds[908], $cleanupIds[909], $cleanupIds[910], $cleanupIds[911], $cleanupIds[912], $cleanupIds[913], $cleanupIds[914], $cleanupIds[915], $cleanupIds[916], $cleanupIds[917], $cleanupIds[918], $cleanupIds[919], $cleanupIds[920], $cleanupIds[921], $cleanupIds[922], $cleanupIds[923], $cleanupIds[924], $cleanupIds[925], $cleanupIds[926], $cleanupIds[927], $cleanupIds[928], $cleanupIds[929], $cleanupIds[930], $cleanupIds[931], $cleanupIds[932], $cleanupIds[933], $cleanupIds[934], $cleanupIds[935], $cleanupIds[936], $cleanupIds[937], $cleanupIds[938], $cleanupIds[939], $cleanupIds[940], $cleanupIds[941], $cleanupIds[942], $cleanupIds[943], $cleanupIds[944], $cleanupIds[945], $cleanupIds[946], $cleanupIds[947], $cleanupIds[948], $cleanupIds[949], $cleanupIds[950], $cleanupIds[951], $cleanupIds[952], $cleanupIds[953], $cleanupIds[954], $cleanupIds[955], $cleanupIds[956], $cleanupIds[957], $cleanupIds[958], $cleanupIds[959], $cleanupIds[960], $cleanupIds[961], $cleanupIds[962], $cleanupIds[963], $cleanupIds[964], $cleanupIds[965], $cleanupIds[966], $cleanupIds[967], $cleanupIds[968], $cleanupIds[969], $cleanupIds[970], $cleanupIds[971], $cleanupIds[972], $cleanupIds[973], $cleanupIds[974], $cleanupIds[975], $cleanupIds[976], $cleanupIds[977], $cleanupIds[978], $cleanupIds[979], $cleanupIds[980], $cleanupIds[981], $cleanupIds[982], $cleanupIds[983], $cleanupIds[984], $cleanupIds[985], $cleanupIds[986], $cleanupIds[987], $cleanupIds[988], $cleanupIds[989], $cleanupIds[990], $cleanupIds[991], $cleanupIds[992], $cleanupIds[993], $cleanupIds[994], $cleanupIds[995], $cleanupIds[996], $cleanupIds[997], $cleanupIds[998], $cleanupIds[999], $cleanupIds[1000], $cleanupIds[1001], $cleanupIds[1002], $cleanupIds[1003], $cleanupIds[1004], $cleanupIds[1005], $cleanupIds[1006], $cleanupIds[1007], $cleanupIds[1008], $cleanupIds[1009], $cleanupIds[1010], $cleanupIds[1011], $cleanupIds[1012], $cleanupIds[1013], $cleanupIds[1014], $cleanupIds[1015], $cleanupIds[1016], $cleanupIds[1017], $cleanupIds[1018], $cleanupIds[1019], $cleanupIds[1020], $cleanupIds[1021], $cleanupIds[1022], $cleanupIds[1023], $cleanupIds[1024], $cleanupIds[1025], $cleanupIds[1026], $cleanupIds[1027], $cleanupIds[1028], $cleanupIds[1029], $cleanupIds[1030], $cleanupIds[1031], $cleanupIds[1032], $cleanupIds[1033], $cleanupIds[1034], $cleanupIds[1035], $cleanupIds[1036], $cleanupIds[1037], $cleanupIds[1038], $cleanupIds[1039], $cleanupIds[1040], $cleanupIds[1041], $cleanupIds[1042], $cleanupIds[1043], $cleanupIds[1044], $cleanupIds[1045], $cleanupIds[1046], $cleanupIds[1047], $cleanupIds[1048], $cleanupIds[1049], $cleanupIds[1050], $cleanupIds[1051], $cleanupIds[1052], $cleanupIds[1053], $cleanupIds[1054], $cleanupIds[1055], $cleanupIds[1056], $cleanupIds[1057], $cleanupIds[1058], $cleanupIds[1059], $cleanupIds[1060], $cleanupIds[1061], $cleanupIds[1062], $cleanupIds[1063], $cleanupIds[1064], $cleanupIds[1065], $cleanupIds[1066], $cleanupIds[1067], $cleanupIds[1068], $cleanupIds[1069], $cleanupIds[1070], $cleanupIds[1071], $cleanupIds[1072], $cleanupIds[1073], $cleanupIds[1074], $cleanupIds[1075], $cleanupIds[1076], $cleanupIds[1077], $cleanupIds[1078], $cleanupIds[1079], $cleanupIds[1080], $cleanupIds[1081], $cleanupIds[1082], $cleanupIds[1083], $cleanupIds[1084], $cleanupIds[1085], $cleanupIds[1086], $cleanupIds[1087], $cleanupIds[1088], $cleanupIds[1089], $cleanupIds[1090], $cleanupIds[1091], $cleanupIds[1092], $cleanupIds[1093], $cleanupIds[1094], $cleanupIds[1095], $cleanupIds[1096], $cleanupIds[1097], $cleanupIds[1098], $cleanupIds[1099], $cleanupIds[1100], $cleanupIds[1101], $cleanupIds[1102], $cleanupIds[1103], $cleanupIds[1104], $cleanupIds[1105], $cleanupIds[1106], $cleanupIds[1107], $cleanupIds[1108], $cleanupIds[1109], $cleanupIds[1110], $cleanupIds[1111], $cleanupIds[1112], $cleanupIds[1113], $cleanupIds[1114], $cleanupIds[1115], $cleanupIds[1116], $cleanupIds[1117], $cleanupIds[1118], $cleanupIds[1119], $cleanupIds[1120], $cleanupIds[1121], $cleanupIds[1122], $cleanupIds[1123], $cleanupIds[1124], $cleanupIds[1125], $cleanupIds[1126], $cleanupIds[1127], $cleanupIds[1128], $cleanupIds[1129], $cleanupIds[1130], $cleanupIds[1131], $cleanupIds[1132], $cleanupIds[1133], $cleanupIds[1134], $cleanupIds[1135], $cleanupIds[1136], $cleanupIds[1137], $cleanupIds[1138], $cleanupIds[1139], $cleanupIds[1140], $cleanupIds[1141], $cleanupIds[1142], $cleanupIds[1143], $cleanupIds[1144], $cleanupIds[1145], $cleanupIds[1146], $cleanupIds[1147], $cleanupIds[1148], $cleanupIds[1149], $cleanupIds[1150], $cleanupIds[1151], $cleanupIds[1152], $cleanupIds[1153], $cleanupIds[1154], $cleanupIds[1155], $cleanupIds[1156], $cleanupIds[1157], $cleanupIds[1158], $cleanupIds[1159], $cleanupIds[1160], $cleanupIds[1161], $cleanupIds[1162], $cleanupIds[1163], $cleanupIds[1164], $cleanupIds[1165], $cleanupIds[1166], $cleanupIds[1167], $cleanupIds[1168], $cleanupIds[1169], $cleanupIds[1170], $cleanupIds[1171], $cleanupIds[1172], $cleanupIds[1173], $cleanupIds[1174], $cleanupIds[1175], $cleanupIds[1176], $cleanupIds[1177], $cleanupIds[1178], $cleanupIds[1179], $cleanupIds[1180], $cleanupIds[1181], $cleanupIds[1182], $cleanupIds[1183], $cleanupIds[1184], $cleanupIds[1185], $cleanupIds[1186], $cleanupIds[1187], $cleanupIds[1188], $cleanupIds[1189], $cleanupIds[1190], $cleanupIds[1191], $cleanupIds[1192], $cleanupIds[1193], $cleanupIds[1194], $cleanupIds[1195], $cleanupIds[1196], $cleanupIds[1197], $cleanupIds[1198], $cleanupIds[1199], $cleanupIds[1200], $cleanupIds[1201], $cleanupIds[1202], $cleanupIds[1203], $cleanupIds[1204], $cleanupIds[1205], $cleanupIds[1206], $cleanupIds[1207], $cleanupIds[1208], $cleanupIds[1209], $cleanupIds[1210], $cleanupIds[1211], $cleanupIds[1212], $cleanupIds[1213], $cleanupIds[1214], $cleanupIds[1215], $cleanupIds[1216], $cleanupIds[1217], $cleanupIds[1218], $cleanupIds[1219], $cleanupIds[1220], $cleanupIds[1221], $cleanupIds[1222], $cleanupIds[1223], $cleanupIds[1224], $cleanupIds[1225], $cleanupIds[1226], $cleanupIds[1227], $cleanupIds[1228], $cleanupIds[1229], $cleanupIds[1230], $cleanupIds[1231], $cleanupIds[1232], $cleanupIds[1233], $cleanupIds[1234], $cleanupIds[1235], $cleanupIds[1236], $cleanupIds[1237], $cleanupIds[1238], $cleanupIds[1239], $cleanupIds[1240], $cleanupIds[1241], $cleanupIds[1242], $cleanupIds[1243], $cleanupIds[1244], $cleanupIds[1245], $cleanupIds[1246], $cleanupIds[1247], $cleanupIds[1248], $cleanupIds[1249], $cleanupIds[1250], $cleanupIds[1251], $cleanupIds[1252], $cleanupIds[1253], $cleanupIds[1254], $cleanupIds[1255], $cleanupIds[1256], $cleanupIds[1257], $cleanupIds[1258], $cleanupIds[1259], $cleanupIds[1260], $cleanupIds[1261], $cleanupIds[1262], $cleanupIds[1263], $cleanupIds[1264], $cleanupIds[1265], $cleanupIds[1266], $cleanupIds[1267], $cleanupIds[1268], $cleanupIds[1269], $cleanupIds[1270], $cleanupIds[1271], $cleanupIds[1272], $cleanupIds[1273], $cleanupIds[1274], $cleanupIds[1275], $cleanupIds[1276], $cleanupIds[1277], $cleanupIds[1278], $cleanupIds[1279], $cleanupIds[1280], $cleanupIds[1281], $cleanupIds[1282], $cleanupIds[1283], $cleanupIds[1284], $cleanupIds[1285], $cleanupIds[1286], $cleanupIds[1287], $cleanupIds[1288], $cleanupIds[1289], $cleanupIds[1290], $cleanupIds[1291], $cleanupIds[1292], $cleanupIds[1293], $cleanupIds[1294], $cleanupIds[1295], $cleanupIds[1296], $cleanupIds[1297], $cleanupIds[1298], $cleanupIds[1299], $cleanupIds[1300], $cleanupIds[1301], $cleanupIds[1302], $cleanupIds[1303], $cleanupIds[1304], $cleanupIds[1305], $cleanupIds[1306], $cleanupIds[1307], $cleanupIds[1308], $cleanupIds[1309], $cleanupIds[1310], $cleanupIds[1311], $cleanupIds[1312], $cleanupIds[1313], $cleanupIds[1314], $cleanupIds[1315], $cleanupIds[1316], $cleanupIds[1317], $cleanupIds[1318], $cleanupIds[1319], $cleanupIds[1320], $cleanupIds[1321], $cleanupIds[1322], $cleanupIds[1323], $cleanupIds[1324], $cleanupIds[1325], $cleanupIds[1326], $cleanupIds[1327], $cleanupIds[1328], $cleanupIds[1329], $cleanupIds[1330], $cleanupIds[1331], $cleanupIds[1332], $cleanupIds[1333], $cleanupIds[1334], $cleanupIds[1335], $cleanupIds[1336], $cleanupIds[1337], $cleanupIds[1338], $cleanupIds[1339], $cleanupIds[1340], $cleanupIds[1341], $cleanupIds[1342], $cleanupIds[1343], $cleanupIds[1344], $cleanupIds[1345], $cleanupIds[1346], $cleanupIds[1347], $cleanupIds[1348], $cleanupIds[1349], $cleanupIds[1350], $cleanupIds[1351], $cleanupIds[1352], $cleanupIds[1353], $cleanupIds[1354], $cleanupIds[1355], $cleanupIds[1356], $cleanupIds[1357], $cleanupIds[1358], $cleanupIds[1359], $cleanupIds[1360], $cleanupIds[1361], $cleanupIds[1362], $cleanupIds[1363], $cleanupIds[1364], $cleanupIds[1365], $cleanupIds[1366], $cleanupIds[1367], $cleanupIds[1368], $cleanupIds[1369], $cleanupIds[1370], $cleanupIds[1371], $cleanupIds[1372], $cleanupIds[1373], $cleanupIds[1374], $cleanupIds[1375], $cleanupIds[1376], $cleanupIds[1377], $cleanupIds[1378], $cleanupIds[1379], $cleanupIds[1380], $cleanupIds[1381], $cleanupIds[1382], $cleanupIds[1383], $cleanupIds[1384], $cleanupIds[1385], $cleanupIds[1386], $cleanupIds[1387], $cleanupIds[1388], $cleanupIds[1389], $cleanupIds[1390], $cleanupIds[1391], $cleanupIds[1392], $cleanupIds[1393], $cleanupIds[1394], $cleanupIds[1395], $cleanupIds[1396], $cleanupIds[1397], $cleanupIds[1398], $cleanupIds[1399], $cleanupIds[1400], $cleanupIds[1401], $cleanupIds[1402], $cleanupIds[1403], $cleanupIds[1404], $cleanupIds[1405], $cleanupIds[1406], $cleanupIds[1407], $cleanupIds[1408], $cleanupIds[1409], $cleanupIds[1410], $cleanupIds[1411], $cleanupIds[1412], $cleanupIds[1413], $cleanupIds[1414], $cleanupIds[1415], $cleanupIds[1416], $cleanupIds[1417], $cleanupIds[1418], $cleanupIds[1419], $cleanupIds[1420], $cleanupIds[1421], $cleanupIds[1422], $cleanupIds[1423], $cleanupIds[1424], $cleanupIds[1425], $cleanupIds[1426], $cleanupIds[1427], $cleanupIds[1428], $cleanupIds[1429], $cleanupIds[1430], $cleanupIds[1431], $cleanupIds[1432], $cleanupIds[1433], $cleanupIds[1434], $cleanupIds[1435], $cleanupIds[1436], $cleanupIds[1437], $cleanupIds[1438], $cleanupIds[1439], $cleanupIds[1440], $cleanupIds[1441], $cleanupIds[1442], $cleanupIds[1443], $cleanupIds[1444], $cleanupIds[1445], $cleanupIds[1446], $cleanupIds[1447], $cleanupIds[1448], $cleanupIds[1449], $cleanupIds[1450], $cleanupIds[1451], $cleanupIds[1452], $cleanupIds[1453], $cleanupIds[1454], $cleanupIds[1455], $cleanupIds[1456], $cleanupIds[1457], $cleanupIds[1458], $cleanupIds[1459], $cleanupIds[1460], $cleanupIds[1461], $cleanupIds[1462], $cleanupIds[1463], $cleanupIds[1464], $cleanupIds[1465], $cleanupIds[1466], $cleanupIds[1467], $cleanupIds[1468], $cleanupIds[1469], $cleanupIds[1470], $cleanupIds[1471], $cleanupIds[1472], $cleanupIds[1473], $cleanupIds[1474], $cleanupIds[1475], $cleanupIds[1476], $cleanupIds[1477], $cleanupIds[1478], $cleanupIds[1479], $cleanupIds[1480], $cleanupIds[1481], $cleanupIds[1482], $cleanupIds[1483], $cleanupIds[1484], $cleanupIds[1485], $cleanupIds[1486], $cleanupIds[1487], $cleanupIds[1488], $cleanupIds[1489], $cleanupIds[1490], $cleanupIds[1491], $cleanupIds[1492], $cleanupIds[1493], $cleanupIds[1494], $cleanupIds[1495], $cleanupIds[1496], $cleanupIds[1497], $cleanupIds[1498], $cleanupIds[1499], $cleanupIds[1500], $cleanupIds[1501], $cleanupIds[1502], $cleanupIds[1503], $cleanupIds[1504], $cleanupIds[1505], $cleanupIds[1506], $cleanupIds[1507], $cleanupIds[1508], $cleanupIds[1509], $cleanupIds[1510], $cleanupIds[1511], $cleanupIds[1512], $cleanupIds[1513], $cleanupIds[1514], $cleanupIds[1515], $cleanupIds[1516], $cleanupIds[1517], $cleanupIds[1518], $cleanupIds[1519], $cleanupIds[1520], $cleanupIds[1521], $cleanupIds[1522], $cleanupIds[1523], $cleanupIds[1524], $cleanupIds[1525], $cleanupIds[1526], $cleanupIds[1527], $cleanupIds[1528], $cleanupIds[1529], $cleanupIds[1530], $cleanupIds[1531], $cleanupIds[1532], $cleanupIds[1533], $cleanupIds[1534], $cleanupIds[1535], $cleanupIds[1536], $cleanupIds[1537], $cleanupIds[1538], $cleanupIds[1539], $cleanupIds[1540], $cleanupIds[1541], $cleanupIds[1542], $cleanupIds[1543], $cleanupIds[1544], $cleanupIds[1545], $cleanupIds[1546], $cleanupIds[1547], $cleanupIds[1548], $cleanupIds[1549], $cleanupIds[1550], $cleanupIds[1551], $cleanupIds[1552], $cleanupIds[1553], $cleanupIds[1554], $cleanupIds[1555], $cleanupIds[1556], $cleanupIds[1557], $cleanupIds[1558], $cleanupIds[1559], $cleanupIds[1560], $cleanupIds[1561], $cleanupIds[1562], $cleanupIds[1563], $cleanupIds[1564], $cleanupIds[1565], $cleanupIds[1566], $cleanupIds[1567], $cleanupIds[1568], $cleanupIds[1569], $cleanupIds[1570], $cleanupIds[1571], $cleanupIds[1572], $cleanupIds[1573], $cleanupIds[1574], $cleanupIds[1575], $cleanupIds[1576], $cleanupIds[1577], $cleanupIds[1578], $cleanupIds[1579], $cleanupIds[1580], $cleanupIds[1581], $cleanupIds[1582], $cleanupIds[1583], $cleanupIds[1584], $cleanupIds[1585], $cleanupIds[1586], $cleanupIds[1587], $cleanupIds[1588], $cleanupIds[1589], $cleanupIds[1590], $cleanupIds[1591], $cleanupIds[1592], $cleanupIds[1593], $cleanupIds[1594], $cleanupIds[1595], $cleanupIds[1596], $cleanupIds[1597], $cleanupIds[1598], $cleanupIds[1599], $cleanupIds[1600], $cleanupIds[1601], $cleanupIds[1602], $cleanupIds[1603], $cleanupIds[1604], $cleanupIds[1605], $cleanupIds[1606], $cleanupIds[1607], $cleanupIds[1608], $cleanupIds[1609], $cleanupIds[1610], $cleanupIds[1611], $cleanupIds[1612], $cleanupIds[1613], $cleanupIds[1614], $cleanupIds[1615], $cleanupIds[1616], $cleanupIds[1617], $cleanupIds[1618], $cleanupIds[1619], $cleanupIds[1620], $cleanupIds[1621], $cleanupIds[1622], $cleanupIds[1623], $cleanupIds[1624], $cleanupIds[1625], $cleanupIds[1626], $cleanupIds[1627], $cleanupIds[1628], $cleanupIds[1629], $cleanupIds[1630], $cleanupIds[1631], $cleanupIds[1632], $cleanupIds[1633], $cleanupIds[1634], $cleanupIds[1635], $cleanupIds[1636], $cleanupIds[1637], $cleanupIds[1638], $cleanupIds[1639], $cleanupIds[1640], $cleanupIds[1641], $cleanupIds[1642], $cleanupIds[1643], $cleanupIds[1644], $cleanupIds[1645], $cleanupIds[1646], $cleanupIds[1647], $cleanupIds[1648], $cleanupIds[1649], $cleanupIds[1650], $cleanupIds[1651], $cleanupIds[1652], $cleanupIds[1653], $cleanupIds[1654], $cleanupIds[1655], $cleanupIds[1656], $cleanupIds[1657], $cleanupIds[1658], $cleanupIds[1659], $cleanupIds[1660], $cleanupIds[1661], $cleanupIds[1662], $cleanupIds[1663], $cleanupIds[1664], $cleanupIds[1665], $cleanupIds[1666], $cleanupIds[1667], $cleanupIds[1668], $cleanupIds[1669], $cleanupIds[1670], $cleanupIds[1671], $cleanupIds[1672], $cleanupIds[1673], $cleanupIds[1674], $cleanupIds[1675], $cleanupIds[1676], $cleanupIds[1677], $cleanupIds[1678], $cleanupIds[1679], $cleanupIds[1680], $cleanupIds[1681], $cleanupIds[1682], $cleanupIds[1683], $cleanupIds[1684], $cleanupIds[1685], $cleanupIds[1686], $cleanupIds[1687], $cleanupIds[1688], $cleanupIds[1689], $cleanupIds[1690], $cleanupIds[1691], $cleanupIds[1692], $cleanupIds[1693], $cleanupIds[1694], $cleanupIds[1695], $cleanupIds[1696], $cleanupIds[1697], $cleanupIds[1698], $cleanupIds[1699], $cleanupIds[1700], $cleanupIds[1701], $cleanupIds[1702], $cleanupIds[1703], $cleanupIds[1704], $cleanupIds[1705], $cleanupIds[1706], $cleanupIds[1707], $cleanupIds[1708], $cleanupIds[1709], $cleanupIds[1710], $cleanupIds[1711], $cleanupIds[1712], $cleanupIds[1713], $cleanupIds[1714], $cleanupIds[1715], $cleanupIds[1716], $cleanupIds[1717], $cleanupIds[1718], $cleanupIds[1719], $cleanupIds[1720], $cleanupIds[1721], $cleanupIds[1722], $cleanupIds[1723], $cleanupIds[1724], $cleanupIds[1725], $cleanupIds[1726], $cleanupIds[1727], $cleanupIds[1728], $cleanupIds[1729], $cleanupIds[1730], $cleanupIds[1731], $cleanupIds[1732], $cleanupIds[1733], $cleanupIds[1734], $cleanupIds[1735], $cleanupIds[1736], $cleanupIds[1737], $cleanupIds[1738], $cleanupIds[1739], $cleanupIds[1740], $cleanupIds[1741], $cleanupIds[1742], $cleanupIds[1743], $cleanupIds[1744], $cleanupIds[1745], $cleanupIds[1746], $cleanupIds[1747], $cleanupIds[1748], $cleanupIds[1749], $cleanupIds[1750], $cleanupIds[1751], $cleanupIds[1752], $cleanupIds[1753], $cleanupIds[1754], $cleanupIds[1755], $cleanupIds[1756], $cleanupIds[1757], $cleanupIds[1758], $cleanupIds[1759], $cleanupIds[1760], $cleanupIds[1761], $cleanupIds[1762], $cleanupIds[1763], $cleanupIds[1764], $cleanupIds[1765], $cleanupIds[1766], $cleanupIds[1767], $cleanupIds[1768], $cleanupIds[1769], $cleanupIds[1770], $cleanupIds[1771], $cleanupIds[1772], $cleanupIds[1773], $cleanupIds[1774], $cleanupIds[1775], $cleanupIds[1776], $cleanupIds[1777], $cleanupIds[1778], $cleanupIds[1779], $cleanupIds[1780], $cleanupIds[1781], $cleanupIds[1782], $cleanupIds[1783], $cleanupIds[1784], $cleanupIds[1785], $cleanupIds[1786], $cleanupIds[1787], $cleanupIds[1788], $cleanupIds[1789], $cleanupIds[1790], $cleanupIds[1791], $cleanupIds[1792], $cleanupIds[1793], $cleanupIds[1794], $cleanupIds[1795], $cleanupIds[1796], $cleanupIds[1797], $cleanupIds[1798], $cleanupIds[1799], $cleanupIds[1800], $cleanupIds[1801], $cleanupIds[1802], $cleanupIds[1803], $cleanupIds[1804], $cleanupIds[1805], $cleanupIds[1806], $cleanupIds[1807], $cleanupIds[1808], $cleanupIds[1809], $cleanupIds[1810], $cleanupIds[1811], $cleanupIds[1812], $cleanupIds[1813], $cleanupIds[1814], $cleanupIds[1815], $cleanupIds[1816], $cleanupIds[1817], $cleanupIds[1818], $cleanupIds[1819], $cleanupIds[1820], $cleanupIds[1821], $cleanupIds[1822], $cleanupIds[1823], $cleanupIds[1824], $cleanupIds[1825], $cleanupIds[1826], $cleanupIds[1827], $cleanupIds[1828], $cleanupIds[1829], $cleanupIds[1830], $cleanupIds[1831], $cleanupIds[1832], $cleanupIds[1833], $cleanupIds[1834], $cleanupIds[1835], $cleanupIds[1836], $cleanupIds[1837], $cleanupIds[1838], $cleanupIds[1839], $cleanupIds[1840], $cleanupIds[1841], $cleanupIds[1842], $cleanupIds[1843], $cleanupIds[1844], $cleanupIds[1845], $cleanupIds[1846], $cleanupIds[1847], $cleanupIds[1848], $cleanupIds[1849], $cleanupIds[1850], $cleanupIds[1851], $cleanupIds[1852], $cleanupIds[1853], $cleanupIds[1854], $cleanupIds[1855], $cleanupIds[1856], $cleanupIds[1857], $cleanupIds[1858], $cleanupIds[1859], $cleanupIds[1860], $cleanupIds[1861], $cleanupIds[1862], $cleanupIds[1863], $cleanupIds[1864], $cleanupIds[1865], $cleanupIds[1866], $cleanupIds[1867], $cleanupIds[1868], $cleanupIds[1869], $cleanupIds[1870], $cleanupIds[1871], $cleanupIds[1872], $cleanupIds[1873], $cleanupIds[1874], $cleanupIds[1875], $cleanupIds[1876], $cleanupIds[1877], $cleanupIds[1878], $cleanupIds[1879], $cleanupIds[1880], $cleanupIds[1881], $cleanupIds[1882], $cleanupIds[1883], $cleanupIds[1884], $cleanupIds[1885], $cleanupIds[1886], $cleanupIds[1887], $cleanupIds[1888], $cleanupIds[1889], $cleanupIds[1890], $cleanupIds[1891], $cleanupIds[1892], $cleanupIds[1893], $cleanupIds[1894], $cleanupIds[1895], $cleanupIds[1896], $cleanupIds[1897], $cleanupIds[1898], $cleanupIds[1899], $cleanupIds[1900], $cleanupIds[1901], $cleanupIds[1902], $cleanupIds[1903], $cleanupIds[1904], $cleanupIds[1905], $cleanupIds[1906], $cleanupIds[1907], $cleanupIds[1908], $cleanupIds[1909], $cleanupIds[1910], $cleanupIds[1911], $cleanupIds[1912], $cleanupIds[1913], $cleanupIds[1914], $cleanupIds[1915], $cleanupIds[1916], $cleanupIds[1917], $cleanupIds[1918], $cleanupIds[1919], $cleanupIds[1920], $cleanupIds[1921], $cleanupIds[1922], $cleanupIds[1923], $cleanupIds[1924], $cleanupIds[1925], $cleanupIds[1926], $cleanupIds[1927], $cleanupIds[1928], $cleanupIds[1929], $cleanupIds[1930], $cleanupIds[1931], $cleanupIds[1932], $cleanupIds[1933], $cleanupIds[1934], $cleanupIds[1935], $cleanupIds[1936], $cleanupIds[1937], $cleanupIds[1938], $cleanupIds[1939], $cleanupIds[1940], $cleanupIds[1941], $cleanupIds[1942], $cleanupIds[1943], $cleanupIds[1944], $cleanupIds[1945], $cleanupIds[1946], $cleanupIds[1947], $cleanupIds[1948], $cleanupIds[1949], $cleanupIds[1950], $cleanupIds[1951], $cleanupIds[1952], $cleanupIds[1953], $cleanupIds[1954], $cleanupIds[1955], $cleanupIds[1956], $cleanupIds[1957], $cleanupIds[1958], $cleanupIds[1959], $cleanupIds[1960], $cleanupIds[1961], $cleanupIds[1962], $cleanupIds[1963], $cleanupIds[1964], $cleanupIds[1965], $cleanupIds[1966], $cleanupIds[1967], $cleanupIds[1968], $cleanupIds[1969], $cleanupIds[1970], $cleanupIds[1971], $cleanupIds[1972], $cleanupIds[1973], $cleanupIds[1974], $cleanupIds[1975], $cleanupIds[1976], $cleanupIds[1977], $cleanupIds[1978], $cleanupIds[1979], $cleanupIds[1980], $cleanupIds[1981], $cleanupIds[1982], $cleanupIds[1983], $cleanupIds[1984], $cleanupIds[1985], $cleanupIds[1986], $cleanupIds[1987], $cleanupIds[1988], $cleanupIds[1989], $cleanupIds[1990], $cleanupIds[1991], $cleanupIds[1992], $cleanupIds[1993], $cleanupIds[1994], $cleanupIds[1995], $cleanupIds[1996], $cleanupIds[1997], $cleanupIds[1998], $cleanupIds[1999], $cleanupIds[2000], $cleanupIds[2001], $cleanupIds[2002], $cleanupIds[2003], $cleanupIds[2004], $cleanupIds[2005], $cleanupIds[2006]); - /* execute query */ - $stmt->execute(); + /* execute query */ + $stmt->execute(); - /* close statement */ - $stmt->close(); - } + /* close statement */ + $stmt->close(); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- query($drop) || !$link->query($create)) { - printf("[%03d + 01] [%d] %s\n", $offset, $link->errno, $link->error); - return false; - } - printf("... table created\n"); - - if (!$stmt = $link->prepare($insert)) { - printf("[%03d + 02] [%d] %s\n", $offset, $link->errno, $link->error); - return false; - } - if ($stmt->param_count != $num_params * $rows) { - printf("[%03d + 03] Parameter count should be %d but got %d\n", $offset, $num_params * $rows, $stmt->param_count); - return false; - } - printf("... statement with %d parameters prepared\n", $stmt->param_count); - - if ($eval) { - if (!eval($stmt_bind_param)) { - printf("[%03d + 03] [%d] %s\n", $offset, $stmt->errno, $stmt->error); - return false; - } - } else { - $param_ref = array($stmt_types); - for ($i = 0; $i < $rows; $i++) - for ($j = 0; $j < $num_params; $j++) - $param_ref[] = &$params[($i * $rows) + $j]; - - if (!call_user_func_array(array($stmt, 'bind_param'), $param_ref)) { - printf("[%03d + 03] [%d] %s\n", $offset, $stmt->errno, $stmt->error); - return false; - } - } - if ($stmt->param_count != $num_params * $rows) { - printf("[%03d + 03] Parameter count should be %d but got %d\n", $offset, $num_params * $rows, $stmt->param_count); - return false; - } - - if (!$stmt->execute()) { - printf("[%03d + 04] [%d] %s\n", $offset, $stmt->errno, $stmt->error); - return false; - } - printf("Statement done\n"); - - $stmt->close(); - - if (!($res = $link->query("SELECT * FROM test"))) { - printf("[%03d + 05] [%d] %s\n", $offset, $link->errno, $link->error); - return false; - } - - $row = $res->fetch_row(); - $res->close(); - - for ($i = 0; $i < $num_params; $i++) { - if ($row[$i + 1] != $i) { - printf("[%03d + 06] [%d] %s\n", $offset, $link->errno, $link->error); - } - } - - return true; - } - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } - - var_dump(bind_many(10, $link, 273, 240, true)); - var_dump(bind_many(20, $link, 273, 240, false)); - mysqli_close($link); - print "done!"; + require_once("connect.inc"); + + function bind_many($offset, $link, $num_params, $rows, $eval = true) { + + $drop = "DROP TABLE IF EXISTS test"; + $create = "CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, "; + $insert = "INSERT INTO test"; + $columns = ""; + $values = ""; + $stmt_params = ""; + $params = array(); + for ($i = 0; $i < $num_params; $i++) { + $create .= "col" . $i . " INT, "; + $columns .= "col" . $i . ", "; + $values .= "?, "; + $stmt_params .= '$params[' . $i . '], '; + for ($j = 0; $j < $rows; $j++) + $params[($j * $rows) + $i] = $i; + } + $create = substr($create, 0, -2) . ")"; + + $stmt_types = str_repeat("i", $num_params * $rows); + $stmt_params = substr(str_repeat($stmt_params, $rows), 0, -2); + $values = substr($values, 0, -2); + $insert .= "(" . substr($columns, 0, -2) . ") VALUES "; + $insert .= substr(str_repeat("(" . $values . "), ", $rows), 0, -2); + + $stmt_bind_param = 'return mysqli_stmt_bind_param($stmt, "' . $stmt_types . '", ' . $stmt_params . ');'; + + printf("Testing %d columns with %d rows...\n", $num_params, $rows); + + if (!$link->query($drop) || !$link->query($create)) { + printf("[%03d + 01] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + printf("... table created\n"); + + if (!$stmt = $link->prepare($insert)) { + printf("[%03d + 02] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + if ($stmt->param_count != $num_params * $rows) { + printf("[%03d + 03] Parameter count should be %d but got %d\n", $offset, $num_params * $rows, $stmt->param_count); + return false; + } + printf("... statement with %d parameters prepared\n", $stmt->param_count); + + if ($eval) { + if (!eval($stmt_bind_param)) { + printf("[%03d + 03] [%d] %s\n", $offset, $stmt->errno, $stmt->error); + return false; + } + } else { + $param_ref = array($stmt_types); + for ($i = 0; $i < $rows; $i++) + for ($j = 0; $j < $num_params; $j++) + $param_ref[] = &$params[($i * $rows) + $j]; + + if (!call_user_func_array(array($stmt, 'bind_param'), $param_ref)) { + printf("[%03d + 03] [%d] %s\n", $offset, $stmt->errno, $stmt->error); + return false; + } + } + if ($stmt->param_count != $num_params * $rows) { + printf("[%03d + 03] Parameter count should be %d but got %d\n", $offset, $num_params * $rows, $stmt->param_count); + return false; + } + + if (!$stmt->execute()) { + printf("[%03d + 04] [%d] %s\n", $offset, $stmt->errno, $stmt->error); + return false; + } + printf("Statement done\n"); + + $stmt->close(); + + if (!($res = $link->query("SELECT * FROM test"))) { + printf("[%03d + 05] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + $row = $res->fetch_row(); + $res->close(); + + for ($i = 0; $i < $num_params; $i++) { + if ($row[$i + 1] != $i) { + printf("[%03d + 06] [%d] %s\n", $offset, $link->errno, $link->error); + } + } + + return true; + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } + + var_dump(bind_many(10, $link, 273, 240, true)); + var_dump(bind_many(20, $link, 273, 240, false)); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- 600) - printf("[009] Function seems to be leaking, because it used %d bytes. During tests it used only 92 bytes.", $tmp); - } - - $id = 100; - $label = "z"; - if (!mysqli_stmt_execute($stmt)) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - mysqli_stmt_close($stmt); - - if (!($res = mysqli_query($link, "SELECT id, label FROM test WHERE id = " . $id))) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $row = mysqli_fetch_assoc($res); - if (($row['id'] != $id) || ($row['label'] != $label)) - printf("[012] Expecting '%s'/%s', got '%s'/%s'!\n", $id, $label, $row['id'], $row['label']); - mysqli_free_result($res); - - function func_mysqli_stmt_bind_datatype($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $alternative = null) { - - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { - printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { - // don't bail - it might be that the server does not support the data type - return false; - } - - if (!$stmt = mysqli_stmt_init($link)) { - printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUE (?, ?)")) { - printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - $id = 1; - if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { - printf("[%03d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - if (!mysqli_stmt_execute($stmt)) { - printf("[%03d] [%d] %s\n", $offset + 4, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - mysqli_stmt_close($stmt); - - if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { - printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!$row = mysqli_fetch_assoc($res)) { - printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if ($alternative) { - if (($row['id'] != $id) || (($row['label'] != $bind_value) && ($row['label'] != $alternative))) { - printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s' (%s), got '%s'/'%s'\n", - $offset + 6, $bind_type, $sql_type, - $id, $bind_value, gettype($bind_value), $row['id'], $row['label']); - return false; - } - } else { - if (($row['id'] != $id) || ($row['label'] != $bind_value)) { - printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s', got '%s'/'%s'\n", - $offset + 6, $bind_type, $sql_type, - $id, $bind_value, $row['id'], $row['label']); - return false; - } - } - - mysqli_free_result($res); - return true; - } - - function func_mysqli_stmt_bind_make_string($len) { - - $ret = ''; - for ($i = 0; $i < $len; $i++) - $ret .= chr(mt_rand(65, 90)); - - return $ret; - } - - func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", -11, 20); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", NULL, 30); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", 1, 40); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", NULL, 50); - - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", 1, 60); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", NULL, 70); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", 0, 80); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", NULL, 90); - - func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", -32768, 100); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", 32767, 110); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", NULL, 120); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 130); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 140); - - func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", -8388608, 150); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", 8388607, 160); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", NULL, 170); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", 16777215, 180); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", NULL, 190); - - func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", -2147483648, 200); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", 2147483647, 210); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", NULL, 220); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, PHP_INT_MAX) : 1, 230); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "INTEGER UNSIGNED", 4294967295, 240); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", NULL, 250); - - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 260); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", NULL, 270); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", PHP_INT_MAX, 280); - func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT UNSIGNED", NULL, 290); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT", "-9223372036854775808", 900); - // ?? func_mysqli_stmt_bind_datatype($link, $engine, "d", "BIGINT", -9223372036854775808, 910); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 920); + /* + The way we test the INSERT and data types overlaps with + the mysqli_stmt_bind_result test in large parts. There is only + one difference. This test uses mysqli_query()/mysqli_fetch_assoc() to + fetch the inserted values. This way we test + mysqli_query()/mysqli_fetch_assoc() for all possible data types + in this file and we test mysqli_stmt_bind_result() in the other + test -- therefore the "duplicate" makes some sense to me. + */ + require_once("connect.inc"); + + require('table.inc'); + + $stmt = mysqli_stmt_init($link); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = null; + $label = null; + + /* + libmysql gives a less descriptive error message but mysqlnd, + we did not unify the error messages but ignore this slight difference silently + */ + if (!false === ($tmp = @mysqli_stmt_bind_param($stmt, " ", $tmp))) + printf("[003d] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!false === ($tmp = @mysqli_stmt_bind_param($stmt, "", $id, $label))) + printf("[003a] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + /* TODO: somehwhat undocumented syntax! */ + $param = array($id); + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) + printf("[003b] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + $param = array($id, $label, $id); + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) + printf("[003c] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id))) + printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id, $label))) + printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "aa", $id, $label))) + printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "ia", $id, $label))) + printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (function_exists("memory_get_usage")) { + $mem = memory_get_usage(); + for ($i = 0; $i < 20000; $i++) { + if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[008][$i] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } + if (($tmp = (memory_get_usage() - $mem)) > 600) + printf("[009] Function seems to be leaking, because it used %d bytes. During tests it used only 92 bytes.", $tmp); + } + + $id = 100; + $label = "z"; + if (!mysqli_stmt_execute($stmt)) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + mysqli_stmt_close($stmt); + + if (!($res = mysqli_query($link, "SELECT id, label FROM test WHERE id = " . $id))) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $row = mysqli_fetch_assoc($res); + if (($row['id'] != $id) || ($row['label'] != $label)) + printf("[012] Expecting '%s'/%s', got '%s'/%s'!\n", $id, $label, $row['id'], $row['label']); + mysqli_free_result($res); + + function func_mysqli_stmt_bind_datatype($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $alternative = null) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail - it might be that the server does not support the data type + return false; + } + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUE (?, ?)")) { + printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + $id = 1; + if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { + printf("[%03d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%03d] [%d] %s\n", $offset + 4, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + mysqli_stmt_close($stmt); + + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { + printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$row = mysqli_fetch_assoc($res)) { + printf("[%03d] [%d] %s\n", $offset + 5, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($alternative) { + if (($row['id'] != $id) || (($row['label'] != $bind_value) && ($row['label'] != $alternative))) { + printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s' (%s), got '%s'/'%s'\n", + $offset + 6, $bind_type, $sql_type, + $id, $bind_value, gettype($bind_value), $row['id'], $row['label']); + return false; + } + } else { + if (($row['id'] != $id) || ($row['label'] != $bind_value)) { + printf("[%03d] Testing '%s', '%s': expecting '%s'/'%s', got '%s'/'%s'\n", + $offset + 6, $bind_type, $sql_type, + $id, $bind_value, $row['id'], $row['label']); + return false; + } + } + + mysqli_free_result($res); + return true; + } + + function func_mysqli_stmt_bind_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", -11, 20); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT", NULL, 30); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", 1, 40); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "TINYINT UNSIGNED", NULL, 50); + + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", 1, 60); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOL", NULL, 70); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", 0, 80); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BOOLEAN", NULL, 90); + + func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", -32768, 100); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", 32767, 110); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT", NULL, 120); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 130); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 140); + + func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", -8388608, 150); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", 8388607, 160); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT", NULL, 170); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", 16777215, 180); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "MEDIUMINT UNSIGNED", NULL, 190); + + func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", -2147483648, 200); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", 2147483647, 210); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER", NULL, 220); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, PHP_INT_MAX) : 1, 230); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "INTEGER UNSIGNED", 4294967295, 240); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "INTEGER UNSIGNED", NULL, 250); + + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 260); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", NULL, 270); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT", PHP_INT_MAX, 280); + func_mysqli_stmt_bind_datatype($link, $engine, "i", "BIGINT UNSIGNED", NULL, 290); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT", "-9223372036854775808", 900); + // ?? func_mysqli_stmt_bind_datatype($link, $engine, "d", "BIGINT", -9223372036854775808, 910); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 920); /* - ?? - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 300); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 320); - */ - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", NULL, 310); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 330); - if (2147483647 == PHP_INT_MAX) { - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", PHP_INT_MAX, 930, '2.14748e+09'); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -1 * PHP_INT_MAX + 1, 940, '-2.14748e+09'); - } - func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT", "-9223372036854775808", 300, '-9.22337e+18'); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT UNSIGNED", "18446744073709551615", 320, '1.84467e+19'); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -10.01, 950); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 10.01, 960); - - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", NULL, 350); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 370); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); - - /* - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); - */ - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", -99999999.99, 380); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 390); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", 99999999.99, 400); - func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 410); - - // don't care about date() strict TZ warnings... - func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", @date('Y-m-d'), 420); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 430); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", NULL, 440); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 450); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 460); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", NULL, 470); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 480); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", @date('H:i:s'), 490); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 500); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", NULL, 510); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", @date('Y'), 520); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR NOT NULL", @date('Y'), 530); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", NULL, 540); - - $string255 = func_mysqli_stmt_bind_make_string(255); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", "a", 550); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(255)", $string255, 560); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1) NOT NULL", "a", 570); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", NULL, 580); - - $string65k = func_mysqli_stmt_bind_make_string(65535); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", "a", 590); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(255)", $string255, 600); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(65635)", $string65k, 610); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 620); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", NULL, 630); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", "a", 640); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", chr(0), 650); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1) NOT NULL", "b", 660); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", NULL, 670); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", "a", 680); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", chr(0), 690); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 700); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", NULL, 710); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", "a", 720); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", chr(0), 730); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB NOT NULL", "b", 740); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", NULL, 750); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", "a", 760); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT NOT NULL", "a", 770); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", NULL, 780); - - // Note: you cannot insert any blob values this way. But you can check the API at least partly this way - // Extra BLOB tests are in mysqli_stmt_send_long() - func_mysqli_stmt_bind_datatype($link, $engine, "b", "BLOB", "", 790); - func_mysqli_stmt_bind_datatype($link, $engine, "b", "TEXT", "", 800); - func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMBLOB", "", 810); - func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMTEXT", "", 820); - func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGBLOB", "", 830); - func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGTEXT", "", 840); - - func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", "a", 850); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", NULL, 860); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", "a", 870); - func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", NULL, 880); - - if (mysqli_get_server_version($link) >= 50600) - func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", "13:27:34.123456", 890, "13:27:34"); - - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[2000] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = null; - $label = null; - if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) - printf("[2001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - mysqli_stmt_execute($stmt); - - if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) - printf("[2002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - mysqli_stmt_close($stmt); - include("table.inc"); - - if (!$stmt = mysqli_stmt_init($link)) - printf("[2003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[2004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (true !== ($tmp = $stmt->bind_param('is', $id, $label))) - printf("[2005] Expecting boolean/true got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, - $stmt->errno, $stmt->error); - - $id = 100; $label = 'z'; - if (!$stmt->execute()) - printf("[2006] [%d] %s\n", $stmt->errno, $stmt->error); - - if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100")) - printf("[2007] Expecting record 100/z, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!$row = mysqli_fetch_assoc($res)) - printf("[2008] Expecting row, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if ($row['id'] != 100 || $row['label'] != 'z') { - printf("[2009] Row seems wrong, dumping record\n"); - var_dump($row); - } - mysqli_free_result($res); - - $value_list = array(array('id' => 101, 'label' => 'a'), array('id' => 102, 'label' => 'b')); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[2010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + ?? + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 300); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 320); + */ + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", NULL, 310); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 330); + if (2147483647 == PHP_INT_MAX) { + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", PHP_INT_MAX, 930, '2.14748e+09'); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -1 * PHP_INT_MAX + 1, 940, '-2.14748e+09'); + } + func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT", "-9223372036854775808", 300, '-9.22337e+18'); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "FLOAT UNSIGNED", "18446744073709551615", 320, '1.84467e+19'); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT", -10.01, 950); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "FLOAT UNSIGNED", 10.01, 960); + + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", NULL, 350); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 370); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); + + /* + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2)", -99999999.99, 340); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", 99999999.99, 360); + */ + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", -99999999.99, 380); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 390); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", 99999999.99, 400); + func_mysqli_stmt_bind_datatype($link, $engine, "d", "DECIMAL(10,2)", NULL, 410); + + // don't care about date() strict TZ warnings... + func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", @date('Y-m-d'), 420); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 430); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATE", NULL, 440); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 450); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 460); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "DATETIME", NULL, 470); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 480); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", @date('H:i:s'), 490); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 500); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", NULL, 510); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", @date('Y'), 520); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR NOT NULL", @date('Y'), 530); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "YEAR", NULL, 540); + + $string255 = func_mysqli_stmt_bind_make_string(255); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", "a", 550); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(255)", $string255, 560); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1) NOT NULL", "a", 570); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "CHAR(1)", NULL, 580); + + $string65k = func_mysqli_stmt_bind_make_string(65535); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", "a", 590); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(255)", $string255, 600); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(65635)", $string65k, 610); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 620); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARCHAR(1)", NULL, 630); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", "a", 640); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", chr(0), 650); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1) NOT NULL", "b", 660); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "BINARY(1)", NULL, 670); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", "a", 680); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", chr(0), 690); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 700); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "VARBINARY(1)", NULL, 710); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", "a", 720); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", chr(0), 730); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB NOT NULL", "b", 740); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYBLOB", NULL, 750); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", "a", 760); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT NOT NULL", "a", 770); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TINYTEXT", NULL, 780); + + // Note: you cannot insert any blob values this way. But you can check the API at least partly this way + // Extra BLOB tests are in mysqli_stmt_send_long() + func_mysqli_stmt_bind_datatype($link, $engine, "b", "BLOB", "", 790); + func_mysqli_stmt_bind_datatype($link, $engine, "b", "TEXT", "", 800); + func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMBLOB", "", 810); + func_mysqli_stmt_bind_datatype($link, $engine, "b", "MEDIUMTEXT", "", 820); + func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGBLOB", "", 830); + func_mysqli_stmt_bind_datatype($link, $engine, "b", "LONGTEXT", "", 840); + + func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", "a", 850); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "ENUM('a', 'b')", NULL, 860); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", "a", 870); + func_mysqli_stmt_bind_datatype($link, $engine, "s", "SET('a', 'b')", NULL, 880); + + if (mysqli_get_server_version($link) >= 50600) + func_mysqli_stmt_bind_datatype($link, $engine, "s", "TIME", "13:27:34.123456", 890, "13:27:34"); + + $stmt = mysqli_stmt_init($link); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[2000] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = null; + $label = null; + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[2001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + mysqli_stmt_execute($stmt); + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[2002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + mysqli_stmt_close($stmt); + include("table.inc"); + + if (!$stmt = mysqli_stmt_init($link)) + printf("[2003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[2004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (true !== ($tmp = $stmt->bind_param('is', $id, $label))) + printf("[2005] Expecting boolean/true got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, + $stmt->errno, $stmt->error); + + $id = 100; $label = 'z'; + if (!$stmt->execute()) + printf("[2006] [%d] %s\n", $stmt->errno, $stmt->error); + + if (!$res = mysqli_query($link, "SELECT id, label FROM test WHERE id = 100")) + printf("[2007] Expecting record 100/z, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[2008] Expecting row, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if ($row['id'] != 100 || $row['label'] != 'z') { + printf("[2009] Row seems wrong, dumping record\n"); + var_dump($row); + } + mysqli_free_result($res); + + $value_list = array(array('id' => 101, 'label' => 'a'), array('id' => 102, 'label' => 'b')); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[2010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); foreach ($value_list as $k => $values) { - if (!mysqli_stmt_bind_param($stmt, 'is', $values['id'], $values['label'])) { - printf("[2011] bind_param() failed for id = %d, [%d] %s\n", - $values['id'], mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - continue; - } - if (!$stmt->execute()) - printf("[2012] [%d] execute() failed for id = %d, [%d] %s\n", - $values['id'], mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!$res = mysqli_query($link, sprintf("SELECT label FROM test WHERE id = %d", $values['id']))) - printf("[2013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[2014] Cannot find row id = %d\n", $values['id']); - else if (isset($row['label']) && ($values['label'] != $row['label'])) - printf("[2015] Expecting label = %s, got label = %s\n", $values['label'], $row['label']); - - mysqli_free_result($res); - } - - mysqli_stmt_close($stmt); - mysqli_close($link); - - print "done!"; + if (!mysqli_stmt_bind_param($stmt, 'is', $values['id'], $values['label'])) { + printf("[2011] bind_param() failed for id = %d, [%d] %s\n", + $values['id'], mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + continue; + } + if (!$stmt->execute()) + printf("[2012] [%d] execute() failed for id = %d, [%d] %s\n", + $values['id'], mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!$res = mysqli_query($link, sprintf("SELECT label FROM test WHERE id = %d", $values['id']))) + printf("[2013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$row = mysqli_fetch_assoc($res)) + printf("[2014] Cannot find row id = %d\n", $values['id']); + else if (isset($row['label']) && ($values['label'] != $row['label'])) + printf("[2015] Expecting label = %s, got label = %s\n", $values['label'], $row['label']); + + mysqli_free_result($res); + } + + mysqli_stmt_close($stmt); + mysqli_close($link); + + print "done!"; ?> --CLEAN-- --FILE-- &$stmt, - 1 => &$types, - 2 => &$id - ); - if (!call_user_func_array('mysqli_stmt_bind_param', $params)) - printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, procedural, using references for everything\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $types = 'i'; - $id = 1; - $params = array( - 0 => &$types, - 1 => &$id - ); - if (!call_user_func_array(array($stmt, 'bind_param'), $params)) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, object oriented, using references for everything\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $types = 'i'; - $id = 1; - $params = array( - 0 => $types, - 1 => &$id - ); - if (!call_user_func_array(array($stmt, 'bind_param'), $params)) - printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, object oriented, using variable for types. using references for bound parameter\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = 1; - $params = array( - 0 => 'i', - 1 => &$id - ); - if (!call_user_func_array(array($stmt, 'bind_param'), $params)) - printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[023] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, object oriented, using constant for types. using references for bound parameter\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $types = 'i'; - $id = 1; - $params = array( - 0 => &$stmt, - 1 => $types, - 2 => &$id - ); - if (!call_user_func_array('mysqli_stmt_bind_param', $params)) - printf("[027] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[029] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, procedural, using references for everything but using variable for types\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $types = 'i'; - $id = 1; - $params = array( - 0 => $stmt, - 1 => $types, - 2 => &$id - ); - if (!call_user_func_array('mysqli_stmt_bind_param', $params)) - printf("[027] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[029] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, procedural, using references for bound parameter, using variables for resource and types\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $types = 'i'; - $id = 1; - $params = array( - 0 => $stmt, - 1 => $types, - 2 => &$id - ); - if (!call_user_func_array('mysqli_stmt_bind_param', $params)) - printf("[032] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[033] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, procedural, using references for bound parameter, using variables for resource and types\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[035] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[036] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = 1; - $params = array( - 0 => $stmt, - 1 => 'i', - 2 => &$id - ); - if (!call_user_func_array('mysqli_stmt_bind_param', $params)) - printf("[037] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[038] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[039] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, procedural, using references for bound parameter, using variable for resource, using constant for types\n"; - var_dump($id); - var_dump($label); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[040] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[041] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = 1; - if (!call_user_func_array('mysqli_stmt_bind_param', array($stmt, 'i', &$id))) - printf("[042] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[043] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label) || - (true !== mysqli_stmt_fetch($stmt))) - printf("[044] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - print "Call user func, procedural, using references for bound parameter, using variable for resource, using constant for types, array\n"; - var_dump($id); - var_dump($label); - - // - // Any of those shall fail - see also bugs.php.net/43568 - // - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[045] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[046] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = 1; - $params = array( - 0 => 'i', - 1 => &$id - ); - if (!call_user_func_array(array($stmt, 'bind_param'), $params)) - printf("[047] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[048] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt)); - - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[049] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) - printf("[050] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $types = 'i'; - $id = 1; - $params = array( - 0 => $stmt, - 1 => 'i', - 2 => &$id - ); - if (!call_user_func_array('mysqli_stmt_bind_param', $params)) - printf("[051] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!mysqli_stmt_execute($stmt)) - printf("[052] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt)); - - print "done!"; + require('connect.inc'); + require('table.inc'); + + if (!$stmt = mysqli_stmt_init($link)) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = 1; + if (!mysqli_stmt_bind_param($stmt, 'i', $id) || + !mysqli_stmt_execute($stmt)) + printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Regular, procedural, using variables\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => &$stmt, + 1 => &$types, + 2 => &$id + ); + if (!call_user_func_array('mysqli_stmt_bind_param', $params)) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, procedural, using references for everything\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => &$types, + 1 => &$id + ); + if (!call_user_func_array(array($stmt, 'bind_param'), $params)) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, object oriented, using references for everything\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => $types, + 1 => &$id + ); + if (!call_user_func_array(array($stmt, 'bind_param'), $params)) + printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, object oriented, using variable for types. using references for bound parameter\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = 1; + $params = array( + 0 => 'i', + 1 => &$id + ); + if (!call_user_func_array(array($stmt, 'bind_param'), $params)) + printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[023] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, object oriented, using constant for types. using references for bound parameter\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => &$stmt, + 1 => $types, + 2 => &$id + ); + if (!call_user_func_array('mysqli_stmt_bind_param', $params)) + printf("[027] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[029] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, procedural, using references for everything but using variable for types\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[026] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => $stmt, + 1 => $types, + 2 => &$id + ); + if (!call_user_func_array('mysqli_stmt_bind_param', $params)) + printf("[027] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[029] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, procedural, using references for bound parameter, using variables for resource and types\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[030] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => $stmt, + 1 => $types, + 2 => &$id + ); + if (!call_user_func_array('mysqli_stmt_bind_param', $params)) + printf("[032] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[033] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, procedural, using references for bound parameter, using variables for resource and types\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[035] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[036] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = 1; + $params = array( + 0 => $stmt, + 1 => 'i', + 2 => &$id + ); + if (!call_user_func_array('mysqli_stmt_bind_param', $params)) + printf("[037] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[038] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[039] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, procedural, using references for bound parameter, using variable for resource, using constant for types\n"; + var_dump($id); + var_dump($label); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[040] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[041] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = 1; + if (!call_user_func_array('mysqli_stmt_bind_param', array($stmt, 'i', &$id))) + printf("[042] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[043] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label) || + (true !== mysqli_stmt_fetch($stmt))) + printf("[044] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + print "Call user func, procedural, using references for bound parameter, using variable for resource, using constant for types, array\n"; + var_dump($id); + var_dump($label); + + // + // Any of those shall fail - see also bugs.php.net/43568 + // + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[045] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[046] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = 1; + $params = array( + 0 => 'i', + 1 => &$id + ); + if (!call_user_func_array(array($stmt, 'bind_param'), $params)) + printf("[047] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[048] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt)); + + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[049] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test WHERE id = ?')) + printf("[050] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $types = 'i'; + $id = 1; + $params = array( + 0 => $stmt, + 1 => 'i', + 2 => &$id + ); + if (!call_user_func_array('mysqli_stmt_bind_param', $params)) + printf("[051] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[052] [%d] (Message might vary with MySQL Server version, e.g. No data supplied for parameters in prepared statement)\n", mysqli_stmt_errno($stmt)); + + print "done!"; ?> --CLEAN-- --FILE-- set_charset('latin1'); + require('table.inc'); + $link->set_charset('latin1'); - class foo { - // @var $bar string - public $bar; - } + class foo { + // @var $bar string + public $bar; + } - $foo = new foo; - $foo->bar = "фубар"; + $foo = new foo; + $foo->bar = "фубар"; - echo "Test 1:\n"; - $stmt = $link->prepare("SELECT ? FOO"); - var_dump($foo); // here you can see the bar member var being a string - $stmt->bind_param("s", $foo->bar); - var_dump($foo); // this will show $foo->bar being a reference string - $stmt->bind_result($one); - $stmt->execute(); - $stmt->fetch(); - $stmt->free_result(); - echo("$one\n\n"); + echo "Test 1:\n"; + $stmt = $link->prepare("SELECT ? FOO"); + var_dump($foo); // here you can see the bar member var being a string + $stmt->bind_param("s", $foo->bar); + var_dump($foo); // this will show $foo->bar being a reference string + $stmt->bind_result($one); + $stmt->execute(); + $stmt->fetch(); + $stmt->free_result(); + echo("$one\n\n"); - // it is getting worse. Binding the same var twice with different - // types you can get unexpected results (e.g. binary trash for the - // string and misc data for the integer. See next 2 tests. + // it is getting worse. Binding the same var twice with different + // types you can get unexpected results (e.g. binary trash for the + // string and misc data for the integer. See next 2 tests. - echo "Test 2:\n"; - $stmt = $link->prepare("SELECT ? FOO, ? BAR"); - var_dump($foo); - $stmt->bind_param("si", $foo->bar, $foo->bar); - echo "---\n"; - var_dump($foo); - echo "---\n"; - $stmt->execute(); - var_dump($foo); - echo "---\n"; - $stmt->bind_result($one, $two); - $stmt->fetch(); - $stmt->free_result(); - echo("$one - $two\n\n"); + echo "Test 2:\n"; + $stmt = $link->prepare("SELECT ? FOO, ? BAR"); + var_dump($foo); + $stmt->bind_param("si", $foo->bar, $foo->bar); + echo "---\n"; + var_dump($foo); + echo "---\n"; + $stmt->execute(); + var_dump($foo); + echo "---\n"; + $stmt->bind_result($one, $two); + $stmt->fetch(); + $stmt->free_result(); + echo("$one - $two\n\n"); - echo "Test 3:\n"; - $stmt = $link->prepare("SELECT ? FOO, ? BAR"); - var_dump($foo); - $stmt->bind_param("is", $foo->bar, $foo->bar); - var_dump($foo); - $stmt->bind_result($one, $two); - $stmt->execute(); - $stmt->fetch(); - $stmt->free_result(); - echo("$one - $two\n\n"); - echo "done!"; + echo "Test 3:\n"; + $stmt = $link->prepare("SELECT ? FOO, ? BAR"); + var_dump($foo); + $stmt->bind_param("is", $foo->bar, $foo->bar); + var_dump($foo); + $stmt->bind_result($one, $two); + $stmt->execute(); + $stmt->fetch(); + $stmt->free_result(); + echo("$one - $two\n\n"); + echo "done!"; ?> --CLEAN-- query("SELECT @@max_allowed_packet")->fetch_row(); - if (!$link->query("SET GLOBAL max_allowed_packet=(2<<29)")) { - if (1227 == mysqli_errno($link)) { - /* [1227] Access denied; you need the SUPER privilege for this operation */ - $cols = 10; - } else { - $cols = 10; - printf("[002] Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - } - mysqli_close($link); + list($old_max_allowed_packet) = $link->query("SELECT @@max_allowed_packet")->fetch_row(); + if (!$link->query("SET GLOBAL max_allowed_packet=(2<<29)")) { + if (1227 == mysqli_errno($link)) { + /* [1227] Access denied; you need the SUPER privilege for this operation */ + $cols = 10; + } else { + $cols = 10; + printf("[002] Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + } + mysqli_close($link); - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - exit(1); - } + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + exit(1); + } - if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { - printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - exit(1); - } + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { + printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + exit(1); + } - $str = array(); - for ($i = 1; $i <= $cols; $i++) { - $str[] ="a$i BLOB"; - } - $link->query("CREATE TABLE test(" . implode(" , ", $str) . ") ENGINE=MyISAM"); - if (mysqli_errno($link)) { - printf("Failed to create the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - die(""); - } - $stmt = $link->prepare("INSERT INTO test VALUES(".str_repeat("?, ", $cols-1) . "?)"); - var_dump($stmt->id); - $s = str_repeat("a", 2 << 12); - $eval_str="\$stmt->bind_param(\"".str_repeat("s",$cols)."\", "; - for ($i = 1; $i < $cols; $i++) { - $eval_str.="\$s,"; - } - $eval_str.="\$s"; - $eval_str.=");"; - eval($eval_str); - printf("executing\n"); - if (!$stmt->execute()) { - printf("failed"); - printf("Failed to execute: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } else { - var_dump(true); - } + $str = array(); + for ($i = 1; $i <= $cols; $i++) { + $str[] ="a$i BLOB"; + } + $link->query("CREATE TABLE test(" . implode(" , ", $str) . ") ENGINE=MyISAM"); + if (mysqli_errno($link)) { + printf("Failed to create the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + die(""); + } + $stmt = $link->prepare("INSERT INTO test VALUES(".str_repeat("?, ", $cols-1) . "?)"); + var_dump($stmt->id); + $s = str_repeat("a", 2 << 12); + $eval_str="\$stmt->bind_param(\"".str_repeat("s",$cols)."\", "; + for ($i = 1; $i < $cols; $i++) { + $eval_str.="\$s,"; + } + $eval_str.="\$s"; + $eval_str.=");"; + eval($eval_str); + printf("executing\n"); + if (!$stmt->execute()) { + printf("failed"); + printf("Failed to execute: [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } else { + var_dump(true); + } - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - if (!$link->query("SET GLOBAL max_allowed_packet=$old_max_allowed_packet")) { - if (1227 != mysqli_errno($link)) - printf("Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } + if (!$link->query("SET GLOBAL max_allowed_packet=$old_max_allowed_packet")) { + if (1227 != mysqli_errno($link)) + printf("Failed to set max_allowed_packet the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- label = 'y'; - $id_ref = &$GLOBALS['id']; - $label_ref = &$label->label; - if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) - printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (true !== @mysqli_stmt_execute($stmt)) - printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - findRow(29, $link, $id_ref, $label_ref); - - $id = 103; - $label_a = &$label_b; - $label_b = &$label_a; - $label_a = 'z'; - - if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_b))) - printf("[030] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (true !== mysqli_stmt_execute($stmt)) - printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - findRow(32, $link, $id, $label_b); - - class foo { - public $foo; - function __construct() { - $this->foo = &$this->bar; - } - } - class bar extends foo { - public $bar = 'v'; - } - $bar = new bar(); - $id++; - $label = &$GLOBALS['bar']->foo; - - if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) - printf("[033] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (true !== mysqli_stmt_execute($stmt)) - printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - findRow(35, $link, $id, $label); - - mysqli_stmt_close($stmt); - mysqli_close($link); - print "done!"; + require('table.inc'); + + function findRow($offset, $link, $id, $label) { + + $sql = sprintf("SELECT id, label FROM test WHERE id = '%d' AND label = '%s'", + $id, $label); + if (!$res = mysqli_query($link, $sql)) { + printf("[%03d + 1] %s failed, [%d] %s\n", + $offset, $sql, mysqli_errno($link), mysqli_error($link)); + return false; + } + if (!$row = mysqli_fetch_assoc($res)) { + printf("[%03d + 2] fetch for %s failed, [%d] %s\n", + $offset, $sql, mysqli_errno($link), mysqli_error($link)); + return false; + } + + mysqli_free_result($res); + if ($row['id'] != $id) { + printf("[%03d + 3] Expecting %s/%s got %s/%s\n", + $offset, gettype($id), $id, + gettype($row['id']), $row['id'] + ); + return false; + } + + if ($row['label'] != $label) { + printf("[%03d + 4] Expecting %s/%s got %s/%s\n", + $offset, gettype($label), $label, + gettype($row['label']), $row['label'] + ); + return false; + } + + $sql = sprintf("DELETE FROM test WHERE id = '%d' AND label = '%s'", + $id, $label); + if (!mysqli_query($link, $sql)) { + printf("[%03d + 5] %s failed, [%d] %s\n", + $offset, $sql, mysqli_errno($link), mysqli_error($link)); + return false; + } + + return true; + } + // or we will get dups around [28] + mysqli_query($link, "ALTER TABLE test DROP PRIMARY KEY"); + + $stmt = mysqli_stmt_init($link); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = 100; + $label = 'v'; + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + // no need to check the return value, will bail and make EXPECTF fail if need be + findRow(4, $link, $id, $label); + + $id++; + $label_ref = &$label; + $label = 'w'; + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_ref))) + printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(7, $link, $id, $label_ref); + + $id++; + $label_ref_ref = &$label_ref; + $label = 'x'; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_ref_ref))) + printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(9, $link, $id, $label_ref_ref); + + $id = 9; + $label = $id; + $label_num = &$label; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_num))) + printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(12, $link, $id, $label_num); + + $label_num = &$id; + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_num))) + printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(15, $link, $id, $label_num); + + $label = 9; + $id = &$label; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[015] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(17, $link, $id, $label); + + $base = 9; + $id = &$base; + $label = &$id; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[018] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(20, $link, $id, $label); + + $id_ref = &$id; + $label_ref = &$label; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) + printf("[021] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(23, $link, $id_ref, $label_ref); + + $id_ref_ref = &$GLOBALS['id_ref']; + $label_ref_ref = &$GLOBALS['label_ref_ref']; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref_ref, $label_ref_ref))) + printf("[024] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[025] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(26, $link, $id_ref_ref, $label_ref_ref); + + unset($id); + unset($label); + $id = 102; + $label = new stdClass(); + $label->label = 'y'; + $id_ref = &$GLOBALS['id']; + $label_ref = &$label->label; + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id_ref, $label_ref))) + printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (true !== @mysqli_stmt_execute($stmt)) + printf("[028] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(29, $link, $id_ref, $label_ref); + + $id = 103; + $label_a = &$label_b; + $label_b = &$label_a; + $label_a = 'z'; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label_b))) + printf("[030] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[031] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(32, $link, $id, $label_b); + + class foo { + public $foo; + function __construct() { + $this->foo = &$this->bar; + } + } + class bar extends foo { + public $bar = 'v'; + } + $bar = new bar(); + $id++; + $label = &$GLOBALS['bar']->foo; + + if (true !== ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[033] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== mysqli_stmt_execute($stmt)) + printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + findRow(35, $link, $id, $label); + + mysqli_stmt_close($stmt); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- char works */ - bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 1, 2, 40); - /* type juggling - note that string->integer works */ - bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', '1', '2', 50); - /* type juggling - note that string->float works*/ - bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', '1.01', '1.02', 60); - - /* now, let's have two columns of different type and do type juggling */ - /* - what the test will do is: - 1) col1 INT, col2 CHAR(1) + require('table.inc'); + + function bind_twice($link, $engine, $sql_type1, $sql_type2, $bind_type1, $bind_type2, $bind_value1, $bind_value2, $offset) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%03d + 1] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + mysqli_autocommit($link, true); + + $sql = sprintf("CREATE TABLE test(col1 %s, col2 %s) ENGINE=%s", $sql_type1, $sql_type2, $engine); + if (!mysqli_query($link, $sql)) { + printf("[%03d + 2] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%03d + 3] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(col1, col2) VALUES (?, ?)")) { + printf("[%03d + 4] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value1)) { + printf("[%03d + 5] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%03d + 6] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_bind_param($stmt, $bind_type1 . $bind_type2, $bind_value1, $bind_value2)) { + printf("[%03d + 7] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + if (!mysqli_stmt_execute($stmt)) { + printf("[%03d + 8] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + mysqli_stmt_close($stmt); + if (!$res = mysqli_query($link, "SELECT col1, col2 FROM test")) { + printf("[%03d + 9] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (2 !== ($tmp = mysqli_num_rows($res))) { + printf("[%03d + 10] Expecting 2 rows, got %d rows [%d] %s\n", $offset, $tmp, mysqli_errno($link), mysqli_error($link)); + } + + $row = mysqli_fetch_assoc($res); + if (($row['col1'] != $bind_value1) || ($row['col2'] != $bind_value1)) { + printf("[%03d + 11] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", + $offset, $bind_value1, $bind_value1, + $row['col1'], $row['col2'], + mysqli_errno($link), mysqli_error($link)); + return false; + } + + $row = mysqli_fetch_assoc($res); + if (($row['col1'] != $bind_value1) || ($row['col2'] != $bind_value2)) { + printf("[%03d + 12] Expecting col1 = %s, col2 = %s got col1 = %s, col2 = %s - [%d] %s\n", + $offset, $bind_value1, $bind_value2, + $row['col1'], $row['col2'], + mysqli_errno($link), mysqli_error($link)); + return false; + } + mysqli_free_result($res); + return true; + } + + bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 'a', 'b', 10); + bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', 1, 2, 20); + bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', 1.01, 1.02, 30); + + /* type juggling - note that int->char works */ + bind_twice($link, $engine, 'CHAR(1)', 'CHAR(1)', 's', 's', 1, 2, 40); + /* type juggling - note that string->integer works */ + bind_twice($link, $engine, 'INT', 'INT', 'i', 'i', '1', '2', 50); + /* type juggling - note that string->float works*/ + bind_twice($link, $engine, 'FLOAT', 'FLOAT', 'd', 'd', '1.01', '1.02', 60); + + /* now, let's have two columns of different type and do type juggling */ + /* + what the test will do is: + 1) col1 INT, col2 CHAR(1) 2) bind_param('is', 1, 1) 3) execute() - 4) bind_param('is', 1, 'a') - 5) execute() + 4) bind_param('is', 1, 'a') + 5) execute() - col1 INT, col2 INT + col1 INT, col2 INT bind_param('ii', '1', '2') --> OK (int column, string value) - bind_param('ii', 1, 2) --> OK (int column, int value) + bind_param('ii', 1, 2) --> OK (int column, int value) col1 CHAR(1), col2 CHAR(2) bind_param('ss', 1, 2) --> OK (string column, int value) - So, what about: - col1 INT, COL2 CHAR(1) - bind_param('is', 1, 1) ---> ?? - */ - bind_twice($link, $engine, 'INT', 'CHAR(1)', 'i', 's', 1, 'a', 70); + So, what about: + col1 INT, COL2 CHAR(1) + bind_param('is', 1, 1) ---> ?? + */ + bind_twice($link, $engine, 'INT', 'CHAR(1)', 'i', 's', 1, 'a', 70); - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) - printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id))) - printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) - printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label, $foo))) - printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - - if (!mysqli_stmt_execute($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - while (mysqli_stmt_fetch($stmt)) { - var_dump($id); - var_dump($label); - } - mysqli_stmt_close($stmt); - - - function func_mysqli_stmt_bind_result($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $type_hint = null) { - - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { - printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { - // don't bail - column type might not be supported by the server, ignore this - return false; - } - - if (!$stmt = mysqli_stmt_init($link)) { - printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { - printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - $id = null; - if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { - printf("[%04d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); - return false; - } - - for ($id = 1; $id < 4; $id++) { - if (!mysqli_stmt_execute($stmt)) { - printf("[%04d] [%d] %s\n", $offset + 3 + $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); - return false; - } - } - mysqli_stmt_close($stmt); - - $stmt = mysqli_stmt_init($link); - - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { - printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); - return false; - } - - if (!mysqli_stmt_execute($stmt)) { - printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); - return false; - } - - $result = mysqli_stmt_result_metadata($stmt); - - $bind_res = null; - if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) { - printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); - return false; - } - $num = 0; - $fields = mysqli_fetch_fields($result); - - while (mysqli_stmt_fetch($stmt)) { - if (!gettype($bind_res)=="unicode") { - if ($bind_res !== $bind_value && (!$type_hint || ($type_hint !== gettype($bind_res)))) { - printf("[%04d] [%d] Expecting %s/'%s' [type hint = %s], got %s/'%s'\n", - $offset + 10, $num, - gettype($bind_value), $bind_value, $type_hint, - gettype($bind_res), $bind_res); - mysqli_stmt_close($stmt); - return false; - } - } - $num++; - } - - if ($num != 3) { - printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", - $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); - mysqli_stmt_close($stmt); - return false; - } - - mysqli_stmt_close($stmt); - return true; - } - - - function func_mysqli_stmt_bind_make_string($len) { - - $ret = ''; - for ($i = 0; $i < $len; $i++) - $ret .= chr(mt_rand(65, 90)); - - return $ret; - } - - func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", -11, 20); - func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", NULL, 40); - func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", 1, 60); - func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", NULL, 80); - - func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", 1, 100); - func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", NULL, 120); - func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", 0, 140); - func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", NULL, 160); - - func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", -32768, 180); - func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", 32767, 200); - func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", NULL, 220); - func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 240); - func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 260); - - func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", -8388608, 280, "integer"); - func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", 8388607, 300, "integer"); - func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", NULL, 320); - func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", 16777215, 340, "integer"); - func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", NULL, 360); - - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? max(-1 * PHP_INT_MAX + 1, -2147483648) : 1, 380); - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", -2147483647, 400, "integer"); - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? min(2147483647, PHP_INT_MAX) : 1, 420); - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", NULL, 440); - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, 2147483647) : 1, 460); - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", 4294967295, 480, (defined("PHP_INT_MAX") && (4294967295 > PHP_INT_MAX)) ? "string" : null); - func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); - - /* test is broken too: we bind "integer" but value is a float - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); - */ - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", NULL, 540); - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1, 1780); - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); - func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); - func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); - func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); - - func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); - func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", NULL, 620); - func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); - func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); - - // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. - $tmp = strval('-99999999.99'); - func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); - func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); - $tmp = strval('99999999.99'); - func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); - func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); - $tmp = strval('-99999999.99'); - func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); - func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); - $tmp = strval('99999999.99'); - func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); - func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); - - // don't care about date() strict TZ warnings... - func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); - func_mysqli_stmt_bind_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); - func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", NULL, 880); - - func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); - func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); - func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", NULL, 940); - - func_mysqli_stmt_bind_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); - - func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); - func_mysqli_stmt_bind_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); - func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", NULL, 1020); - - $tmp = intval(@date('Y')); - func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); - func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); - func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", NULL, 1080); - - $string255 = func_mysqli_stmt_bind_make_string(255); - func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", "a", 1110, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(255)", $string255, 1120, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", NULL, 1160); - - $string65k = func_mysqli_stmt_bind_make_string(65535); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); - - func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", "a", 1280); - func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); - func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); - func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", NULL, 1340); - - func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); - func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); - - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", "a", 1440); - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", NULL, 1500); - - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", "a", 1520, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", NULL, 1560, 'string'); - - // Note: you cannot insert any blob values this way. But you can check the API at least partly this way - // Extra BLOB tests are in mysqli_stmt_send_long() - func_mysqli_stmt_bind_result($link, $engine, "b", "BLOB", "", 1580); - func_mysqli_stmt_bind_result($link, $engine, "b", "TEXT", "", 1600, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMBLOB", "", 1620); - func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, 'string'); - - /* Is this one related? http://bugs.php.net/bug.php?id=35759 */ - if (($IS_MYSQLND) || (!$IS_MYSQLND && (ini_get('memory_limit') > 4294967296))) { - /* NOTE: the MySQL Client Library - not mysqlnd - will allocate - a hugge max_length(type) = 4GB bind buffer */ - func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660); - func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, 'string'); - } - - func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, 'string'); - func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, 'string'); - - if (mysqli_get_server_version($link) >= 50600) - func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", "13:31:34.123456", 1770, "13:31:34"); - - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (1000, 'z')")) - printf("[3001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $id = null; - if (false !== @mysqli_stmt_bind_result($stmt, $id)) - printf("[3002] Bind result should not be allowed"); - - mysqli_stmt_close($stmt); - - mysqli_close($link); - print "done!"; + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) + printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id))) + printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label, $foo))) + printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + while (mysqli_stmt_fetch($stmt)) { + var_dump($id); + var_dump($label); + } + mysqli_stmt_close($stmt); + + + function func_mysqli_stmt_bind_result($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $type_hint = null) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail - column type might not be supported by the server, ignore this + return false; + } + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + $id = null; + if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { + printf("[%04d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + for ($id = 1; $id < 4; $id++) { + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 3 + $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + } + mysqli_stmt_close($stmt); + + $stmt = mysqli_stmt_init($link); + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + $result = mysqli_stmt_result_metadata($stmt); + + $bind_res = null; + if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) { + printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + $num = 0; + $fields = mysqli_fetch_fields($result); + + while (mysqli_stmt_fetch($stmt)) { + if (!gettype($bind_res)=="unicode") { + if ($bind_res !== $bind_value && (!$type_hint || ($type_hint !== gettype($bind_res)))) { + printf("[%04d] [%d] Expecting %s/'%s' [type hint = %s], got %s/'%s'\n", + $offset + 10, $num, + gettype($bind_value), $bind_value, $type_hint, + gettype($bind_res), $bind_res); + mysqli_stmt_close($stmt); + return false; + } + } + $num++; + } + + if ($num != 3) { + printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", + $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); + mysqli_stmt_close($stmt); + return false; + } + + mysqli_stmt_close($stmt); + return true; + } + + + function func_mysqli_stmt_bind_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", -11, 20); + func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT", NULL, 40); + func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", 1, 60); + func_mysqli_stmt_bind_result($link, $engine, "i", "TINYINT UNSIGNED", NULL, 80); + + func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", 1, 100); + func_mysqli_stmt_bind_result($link, $engine, "i", "BOOL", NULL, 120); + func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", 0, 140); + func_mysqli_stmt_bind_result($link, $engine, "i", "BOOLEAN", NULL, 160); + + func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", -32768, 180); + func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", 32767, 200); + func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT", NULL, 220); + func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 240); + func_mysqli_stmt_bind_result($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 260); + + func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", -8388608, 280, "integer"); + func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", 8388607, 300, "integer"); + func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT", NULL, 320); + func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", 16777215, 340, "integer"); + func_mysqli_stmt_bind_result($link, $engine, "d", "MEDIUMINT UNSIGNED", NULL, 360); + + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? max(-1 * PHP_INT_MAX + 1, -2147483648) : 1, 380); + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", -2147483647, 400, "integer"); + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? min(2147483647, PHP_INT_MAX) : 1, 420); + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER", NULL, 440); + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, 2147483647) : 1, 460); + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", 4294967295, 480, (defined("PHP_INT_MAX") && (4294967295 > PHP_INT_MAX)) ? "string" : null); + func_mysqli_stmt_bind_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); + + /* test is broken too: we bind "integer" but value is a float + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); + */ + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", NULL, 540); + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1, 1780); + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); + func_mysqli_stmt_bind_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); + func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); + func_mysqli_stmt_bind_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); + + func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); + func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT", NULL, 620); + func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); + func_mysqli_stmt_bind_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); + + // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. + $tmp = strval('-99999999.99'); + func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); + func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); + $tmp = strval('99999999.99'); + func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); + func_mysqli_stmt_bind_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); + $tmp = strval('-99999999.99'); + func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); + func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); + $tmp = strval('99999999.99'); + func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); + func_mysqli_stmt_bind_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); + + // don't care about date() strict TZ warnings... + func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); + func_mysqli_stmt_bind_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); + func_mysqli_stmt_bind_result($link, $engine, "s", "DATE", NULL, 880); + + func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); + func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); + func_mysqli_stmt_bind_result($link, $engine, "s", "DATETIME", NULL, 940); + + func_mysqli_stmt_bind_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); + + func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); + func_mysqli_stmt_bind_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); + func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", NULL, 1020); + + $tmp = intval(@date('Y')); + func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); + func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); + func_mysqli_stmt_bind_result($link, $engine, "s", "YEAR", NULL, 1080); + + $string255 = func_mysqli_stmt_bind_make_string(255); + func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", "a", 1110, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(255)", $string255, 1120, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "CHAR(1)", NULL, 1160); + + $string65k = func_mysqli_stmt_bind_make_string(65535); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); + + func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", "a", 1280); + func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); + func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); + func_mysqli_stmt_bind_result($link, $engine, "s", "BINARY(1)", NULL, 1340); + + func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); + func_mysqli_stmt_bind_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); + + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", "a", 1440); + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYBLOB", NULL, 1500); + + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", "a", 1520, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "TINYTEXT", NULL, 1560, 'string'); + + // Note: you cannot insert any blob values this way. But you can check the API at least partly this way + // Extra BLOB tests are in mysqli_stmt_send_long() + func_mysqli_stmt_bind_result($link, $engine, "b", "BLOB", "", 1580); + func_mysqli_stmt_bind_result($link, $engine, "b", "TEXT", "", 1600, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMBLOB", "", 1620); + func_mysqli_stmt_bind_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, 'string'); + + /* Is this one related? http://bugs.php.net/bug.php?id=35759 */ + if (($IS_MYSQLND) || (!$IS_MYSQLND && (ini_get('memory_limit') > 4294967296))) { + /* NOTE: the MySQL Client Library - not mysqlnd - will allocate + a hugge max_length(type) = 4GB bind buffer */ + func_mysqli_stmt_bind_result($link, $engine, "b", "LONGBLOB", "", 1660); + func_mysqli_stmt_bind_result($link, $engine, "b", "LONGTEXT", "", 1680, 'string'); + } + + func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, 'string'); + func_mysqli_stmt_bind_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, 'string'); + + if (mysqli_get_server_version($link) >= 50600) + func_mysqli_stmt_bind_result($link, $engine, "s", "TIME", "13:31:34.123456", 1770, "13:31:34"); + + $stmt = mysqli_stmt_init($link); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (1000, 'z')")) + printf("[3001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = null; + if (false !== @mysqli_stmt_bind_result($stmt, $id)) + printf("[3002] Bind result should not be allowed"); + + mysqli_stmt_close($stmt); + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- = 1; $bitval = $bitval / 2) { - if (($dec / $bitval) >= 1) { - $bin .= '1'; - $dec -= $bitval; - } else { - $bin .= '0'; - } - } - return $bin; - } - - if (!$link_ins = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - if (!$link_sel = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - for ($bits = 1; $bits <= 46; $bits++) { - - if (1 == $bits) - $max_value = 1; - else - $max_value = pow(2, $bits) - 1; - - if (!mysqli_query($link_ins, "DROP TABLE IF EXISTS test")) { - printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); - } - - if (!mysqli_query($link_ins, sprintf("CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE = %s", $bits, $bits, $engine))) { - // don't bail - column type might not be supported by the server, ignore this - continue; - } - if (!$stmt_ins = mysqli_stmt_init($link_ins)) { - printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); - continue; - } - - if (!mysqli_stmt_prepare($stmt_ins, "INSERT INTO test(id, bit_value) VALUES (?, ?)")) { - printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); - mysqli_stmt_close($stmt_ins); - continue; - } - - if (!($stmt_sel = mysqli_stmt_init($link_sel))) { - printf("[006 - %d] [%d] %s\n", $bits, mysqli_errno($link_sel), mysqli_error($link_sel)); - mysqli_stmt_close($stmt_ins); - continue; - } - - $tests = 0; - $rand_max = mt_getrandmax(); - while ($tests < 10) { - - $tests++; - if (1 == $tests) - $value = 0; - else if (2 == $tests) - $value = $max_value; - else { - if ($max_value > $rand_max) { - $max_loops = floor($max_value/$rand_max); - $num_loops = mt_rand(1, $max_loops); - $value = 0; - for ($i = 0; $i < $num_loops; $i++) - $value += mt_rand(0, $rand_max); - } else { - $value = mt_rand(0, $max_value); - } - } - - $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); - for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) - ; - $bin2 = substr($bin, $i, strlen($bin)); - - if (!mysqli_stmt_bind_param($stmt_ins, "dd", $value, $value)) { - printf("[007 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); - mysqli_stmt_close($stmt_ins); - continue; - } - if (!mysqli_stmt_execute($stmt_ins)) { - printf("[008 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); - break; - } - $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value, bit_value + 0 AS _bit_value0, bit_null FROM test WHERE id = %s", $value); - if ((!mysqli_stmt_prepare($stmt_sel, $sql)) || - (!mysqli_stmt_execute($stmt_sel))) { - printf("[009 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); - break; - } - - $row = array('id' => -1, '_bin' => - 1, 'bit_value' => -1, '_bit_value0' => -1, 'bit_null' => -1); - if (!mysqli_stmt_bind_result($stmt_sel, $row['id'], $row['_bin'], $row['bit_value'], $row['_bit_value0'], $row['bit_null'])) { - printf("[010 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); - break; - } - - if (!($ret = mysqli_stmt_fetch($stmt_sel))) { - printf("[011 - %d] mysqli_stmt_fetch() has failed for %d bits - ret = %s/%s, [%d] %s, [%d] %s\n", - $bits, $bits, - gettype($ret), $ret, - mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel), - mysqli_errno($link_sel), mysqli_errno($link_sel) - ); - break; - } - - if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { - debug_zval_dump($row); - printf("[012 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", - $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); - break; - } - if ($value != $row['bit_value']) { - debug_zval_dump($row); - printf("[013 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); - break; - } - - if (null !== $row['bit_null']) { - debug_zval_dump($row); - printf("[014 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); - break; - } - - } - - mysqli_stmt_close($stmt_ins); - mysqli_stmt_close($stmt_sel); - } - - mysqli_close($link_ins); - mysqli_close($link_sel); - print "done!"; + require_once("connect.inc"); + + function dec32bin($dec, $bits) { + + $maxval = pow(2, $bits); + $bin = ''; + for ($bitval = $maxval; $bitval >= 1; $bitval = $bitval / 2) { + if (($dec / $bitval) >= 1) { + $bin .= '1'; + $dec -= $bitval; + } else { + $bin .= '0'; + } + } + return $bin; + } + + if (!$link_ins = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + if (!$link_sel = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + for ($bits = 1; $bits <= 46; $bits++) { + + if (1 == $bits) + $max_value = 1; + else + $max_value = pow(2, $bits) - 1; + + if (!mysqli_query($link_ins, "DROP TABLE IF EXISTS test")) { + printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); + } + + if (!mysqli_query($link_ins, sprintf("CREATE TABLE test(id BIGINT, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE = %s", $bits, $bits, $engine))) { + // don't bail - column type might not be supported by the server, ignore this + continue; + } + if (!$stmt_ins = mysqli_stmt_init($link_ins)) { + printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link_ins), mysqli_error($link_ins)); + continue; + } + + if (!mysqli_stmt_prepare($stmt_ins, "INSERT INTO test(id, bit_value) VALUES (?, ?)")) { + printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); + mysqli_stmt_close($stmt_ins); + continue; + } + + if (!($stmt_sel = mysqli_stmt_init($link_sel))) { + printf("[006 - %d] [%d] %s\n", $bits, mysqli_errno($link_sel), mysqli_error($link_sel)); + mysqli_stmt_close($stmt_ins); + continue; + } + + $tests = 0; + $rand_max = mt_getrandmax(); + while ($tests < 10) { + + $tests++; + if (1 == $tests) + $value = 0; + else if (2 == $tests) + $value = $max_value; + else { + if ($max_value > $rand_max) { + $max_loops = floor($max_value/$rand_max); + $num_loops = mt_rand(1, $max_loops); + $value = 0; + for ($i = 0; $i < $num_loops; $i++) + $value += mt_rand(0, $rand_max); + } else { + $value = mt_rand(0, $max_value); + } + } + + $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); + for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) + ; + $bin2 = substr($bin, $i, strlen($bin)); + + if (!mysqli_stmt_bind_param($stmt_ins, "dd", $value, $value)) { + printf("[007 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); + mysqli_stmt_close($stmt_ins); + continue; + } + if (!mysqli_stmt_execute($stmt_ins)) { + printf("[008 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_ins), mysqli_stmt_error($stmt_ins)); + break; + } + $sql = sprintf("SELECT id, BIN(bit_value) AS _bin, bit_value, bit_value + 0 AS _bit_value0, bit_null FROM test WHERE id = %s", $value); + if ((!mysqli_stmt_prepare($stmt_sel, $sql)) || + (!mysqli_stmt_execute($stmt_sel))) { + printf("[009 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); + break; + } + + $row = array('id' => -1, '_bin' => - 1, 'bit_value' => -1, '_bit_value0' => -1, 'bit_null' => -1); + if (!mysqli_stmt_bind_result($stmt_sel, $row['id'], $row['_bin'], $row['bit_value'], $row['_bit_value0'], $row['bit_null'])) { + printf("[010 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel)); + break; + } + + if (!($ret = mysqli_stmt_fetch($stmt_sel))) { + printf("[011 - %d] mysqli_stmt_fetch() has failed for %d bits - ret = %s/%s, [%d] %s, [%d] %s\n", + $bits, $bits, + gettype($ret), $ret, + mysqli_stmt_errno($stmt_sel), mysqli_stmt_error($stmt_sel), + mysqli_errno($link_sel), mysqli_errno($link_sel) + ); + break; + } + + if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { + debug_zval_dump($row); + printf("[012 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", + $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); + break; + } + if ($value != $row['bit_value']) { + debug_zval_dump($row); + printf("[013 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); + break; + } + + if (null !== $row['bit_null']) { + debug_zval_dump($row); + printf("[014 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); + break; + } + + } + + mysqli_stmt_close($stmt_ins); + mysqli_stmt_close($stmt_sel); + } + + mysqli_close($link_ins); + mysqli_close($link_sel); + print "done!"; ?> --CLEAN-- $v) { - if (!mysqli_stmt_fetch($stmt)) { - break; - } - if ($result !== $v) { - printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n", - $offset + 8, - $k, - gettype($v), $v, - gettype($result), $result, - $order_by_col, - $format, $sql); - } - } - - } - - mysqli_stmt_free_result($stmt); - mysqli_stmt_close($stmt); - - return true; - } - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect - [%d] %s\n", - mysqli_connect_errno(), - mysqli_connect_error()); - - /* select from dual - pseudo table */ - test_format($link, 'FORMAT(1.01, 0)', 'DUAL', null, '1', 10); - test_format($link, 'FORMAT(1.23, 1)', 'DUAL', null, '1.2', 20); - test_format($link, 'FORMAT(1.23, 2)', 'DUAL', null, '1.23', 30); - test_format($link, 'FORMAT(1234.567, 3)', 'DUAL', null, '1,234.567', 40); - /* no typo! */ - test_format($link, 'FORMAT(1234.567, 4)', 'DUAL', null, '1,234.5670', 50); - - mysqli_close($link); - require_once('table.inc'); - - /* select from existing table */ - test_format($link, 'FORMAT(id, 0)', 'test', null, '1', 60); - test_format($link, 'FORMAT(id + 0.1, 1)', 'test', null, '1.1', 70); - test_format($link, 'FORMAT(id + 0.01, 2)', 'test', null, '1.01', 80); - - /* create new table and select from it */ - $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 100); - - $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 110); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120); - - $expected = create_table($link, 'TINYINT', -128, 127, $engine, 130); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140); - - $expected = create_table($link, 'SMALLINT UNSIGNED', 0, 65535, $engine, 150); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160); - - $expected = create_table($link, 'MEDIUMINT', 0, 8388607, $engine, 170); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 180); - - $expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 200); - - $expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 220); - - $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230); - foreach ($expected as $k => $v) - $expected[$k] = number_format(round($v), 0, '.', ','); - test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240); - - // http://bugs.php.net/bug.php?id=42378 - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { - printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - - if (mysqli_query($link, "CREATE TABLE `test` ( + require_once("connect.inc"); + + function create_table($link, $column, $min, $max, $engine, $offset) { + + if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { + printf("[%03d] Cannot drop table test, [%d] %s\n", + $offset, + mysqli_errno($link), mysqli_error($link)); + return array(); + } + + $sql = sprintf("CREATE TABLE test(id INT AUTO_INCREMENT PRIMARY KEY, col1 %s) ENGINE=%s", + $column, $engine); + if (!mysqli_query($link, $sql)) { + printf("[%03d] Cannot create table test, [%d] %s\n", + $offset + 1, + mysqli_errno($link), mysqli_error($link)); + return array(); + } + + $values = array(); + for ($i = 1; $i <= 100; $i++) { + $col1 = mt_rand($min, $max); + $values[$i] = $col1; + $sql = sprintf("INSERT INTO test(id, col1) VALUES (%d, %f)", + $i, $col1); + if (!mysqli_query($link, $sql)) { + printf("[%03d] Cannot insert data, [%d] %s\n", + $offset + 2, + mysqli_errno($link), mysqli_error($link)); + return array(); + } + } + + return $values; + } + + function test_format($link, $format, $from, $order_by, $expected, $offset) { + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%03d] Cannot create PS, [%d] %s\n", + $offset, + mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($order_by) + $sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by); + else + $sql = sprintf('SELECT %s AS _format FROM %s', $format, $from); + + if (!mysqli_stmt_prepare($stmt, $sql)) { + printf("[%03d] Cannot prepare PS, [%d] %s\n", + $offset + 1, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%03d] Cannot execute PS, [%d] %s\n", + $offset + 2, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_store_result($stmt)) { + printf("[%03d] Cannot store result set, [%d] %s\n", + $offset + 3, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!is_array($expected)) { + + $result = null; + if (!mysqli_stmt_bind_result($stmt, $result)) { + printf("[%03d] Cannot bind result, [%d] %s\n", + $offset + 4, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_fetch($stmt)) { + printf("[%03d] Cannot fetch result,, [%d] %s\n", + $offset + 5, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if ($result !== $expected) { + printf("[%03d] Expecting %s/%s got %s/%s with %s - %s.\n", + $offset + 6, + gettype($expected), $expected, + gettype($result), $result, + $format, $sql); + } + + } else { + + $order_by_col = $result = null; + if (!mysqli_stmt_bind_result($stmt, $order_by_col, $result)) { + printf("[%03d] Cannot bind result, [%d] %s\n", + $offset + 7, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + foreach ($expected as $k => $v) { + if (!mysqli_stmt_fetch($stmt)) { + break; + } + if ($result !== $v) { + printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n", + $offset + 8, + $k, + gettype($v), $v, + gettype($result), $result, + $order_by_col, + $format, $sql); + } + } + + } + + mysqli_stmt_free_result($stmt); + mysqli_stmt_close($stmt); + + return true; + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect - [%d] %s\n", + mysqli_connect_errno(), + mysqli_connect_error()); + + /* select from dual - pseudo table */ + test_format($link, 'FORMAT(1.01, 0)', 'DUAL', null, '1', 10); + test_format($link, 'FORMAT(1.23, 1)', 'DUAL', null, '1.2', 20); + test_format($link, 'FORMAT(1.23, 2)', 'DUAL', null, '1.23', 30); + test_format($link, 'FORMAT(1234.567, 3)', 'DUAL', null, '1,234.567', 40); + /* no typo! */ + test_format($link, 'FORMAT(1234.567, 4)', 'DUAL', null, '1,234.5670', 50); + + mysqli_close($link); + require_once('table.inc'); + + /* select from existing table */ + test_format($link, 'FORMAT(id, 0)', 'test', null, '1', 60); + test_format($link, 'FORMAT(id + 0.1, 1)', 'test', null, '1.1', 70); + test_format($link, 'FORMAT(id + 0.01, 2)', 'test', null, '1.01', 80); + + /* create new table and select from it */ + $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 100); + + $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 110); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120); + + $expected = create_table($link, 'TINYINT', -128, 127, $engine, 130); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140); + + $expected = create_table($link, 'SMALLINT UNSIGNED', 0, 65535, $engine, 150); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160); + + $expected = create_table($link, 'MEDIUMINT', 0, 8388607, $engine, 170); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 180); + + $expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 200); + + $expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 220); + + $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240); + + // http://bugs.php.net/bug.php?id=42378 + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + + if (mysqli_query($link, "CREATE TABLE `test` ( `targetport` int(11) NOT NULL default '0', `sources` double(17,4) default NULL, `current_sources` double(17,4) default NULL, @@ -222,116 +222,116 @@ memory_limit=83886080 PRIMARY KEY (`targetport`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1")) { - do { - $values = array(); - for ($i = 0; $i < 200; $i++) { - $current_targets = mt_rand(-100000, 100000) / 10; - do { - $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL'; - } while (isset($values[$trend])); - - $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', - $i, - $current_targets, - (mt_rand(0, 1) > 0) ? mt_rand(0, 1000) : 'NULL', - $trend); - if (!mysqli_query($link, $sql)) { - printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break 2; - } - if ($current_targets > 0 && $trend !== 'NULL') - $values[$trend] = $i; - } - krsort($values); - - if (!$stmt = mysqli_stmt_init($link)) { - printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - - if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { - printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - if (!mysqli_stmt_execute($stmt)) { - printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - if (!mysqli_stmt_store_result($stmt)) { - printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - $trend = $targetport = $format = null; - if (!mysqli_stmt_bind_result($stmt, $trend, $targetport, $format)) { - - printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - foreach ($values as $exp_trend => $exp_targetport) { - if (!mysqli_stmt_fetch($stmt)) { - break; - } - if ($targetport != $exp_targetport) { - printf("[306] Values fetched from MySQL seem to be wrong, check manually\n"); - printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format); - } - } - mysqli_stmt_free_result($stmt); - mysqli_stmt_close($stmt); - - // same but OO interface - if (!$stmt = mysqli_stmt_init($link)) { - printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - break; - } - - if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { - printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - if (!$stmt->execute()) { - printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - if (!$stmt->store_result()) { - printf("[310] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - $trend = $targetport = $format = null; - if (!$stmt->bind_result($trend, $targetport, $format)) { - - printf("[311] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); - break; - } - - foreach ($values as $exp_trend => $exp_targetport) { - if (!$stmt->fetch()) { - break; - } - if ($targetport != $exp_targetport) { - printf("[312] Values fetched from MySQL seem to be wrong, check manually\n"); - printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format); - } - } - $stmt->free_result(); - $stmt->close(); - - } while (false); - - } else { - var_dump(mysqli_error($link)); - } - - - mysqli_close($link); - print "done!"; + do { + $values = array(); + for ($i = 0; $i < 200; $i++) { + $current_targets = mt_rand(-100000, 100000) / 10; + do { + $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL'; + } while (isset($values[$trend])); + + $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', + $i, + $current_targets, + (mt_rand(0, 1) > 0) ? mt_rand(0, 1000) : 'NULL', + $trend); + if (!mysqli_query($link, $sql)) { + printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break 2; + } + if ($current_targets > 0 && $trend !== 'NULL') + $values[$trend] = $i; + } + krsort($values); + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[302] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + + if (!mysqli_stmt_prepare($stmt, 'SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { + printf("[303] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[304] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!mysqli_stmt_store_result($stmt)) { + printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + $trend = $targetport = $format = null; + if (!mysqli_stmt_bind_result($stmt, $trend, $targetport, $format)) { + + printf("[305] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + foreach ($values as $exp_trend => $exp_targetport) { + if (!mysqli_stmt_fetch($stmt)) { + break; + } + if ($targetport != $exp_targetport) { + printf("[306] Values fetched from MySQL seem to be wrong, check manually\n"); + printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format); + } + } + mysqli_stmt_free_result($stmt); + mysqli_stmt_close($stmt); + + // same but OO interface + if (!$stmt = mysqli_stmt_init($link)) { + printf("[307] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + break; + } + + if (!$stmt->prepare('SELECT trend, targetport, FORMAT(trend, 2) FROM test WHERE current_targets > 0 AND trend IS NOT NULL ORDER BY trend DESC LIMIT 100')) { + printf("[308] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!$stmt->execute()) { + printf("[309] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + if (!$stmt->store_result()) { + printf("[310] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + $trend = $targetport = $format = null; + if (!$stmt->bind_result($trend, $targetport, $format)) { + + printf("[311] [%d] %s\n", mysqli_stmt_errno($link), mysqli_stmt_error($link)); + break; + } + + foreach ($values as $exp_trend => $exp_targetport) { + if (!$stmt->fetch()) { + break; + } + if ($targetport != $exp_targetport) { + printf("[312] Values fetched from MySQL seem to be wrong, check manually\n"); + printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format); + } + } + $stmt->free_result(); + $stmt->close(); + + } while (false); + + } else { + var_dump(mysqli_error($link)); + } + + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- id = null; - $obj->label = null; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $obj->id, $obj->label))) - printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - var_dump($obj->id); - var_dump($obj->label); - - - print "reference, simple object w reference...\n"; - unset($id); unset($label); unset($obj); - $obj = new stdClass(); - $obj->id = null; - $obj->label = null; - $id = &$obj->id; - $label = &$obj->label; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) - printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - var_dump($obj->id); - var_dump($obj->label); - - print "reference, simple object w reference, change after bind...\n"; - unset($id); unset($label); unset($obj); - $obj = new stdClass(); - $obj->id = null; - $obj->label = null; - $id = &$obj->id; - $label = &$obj->label; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) - printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - $label = &$obj->id; - $id = null; - - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - var_dump($obj->id); - var_dump($id); - var_dump($obj->label); - var_dump($label); - - print "reference, one level, change after bind...\n"; - unset($id); unset($label); unset($id_ref); unset($label_ref); - $id = null; - $id_ref = &$id; - $label = null; - $label_ref = &$label; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) - printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - - $id_ref = 1; - $label_ref = 1; - - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id_ref); - var_dump($id); - var_dump($label_ref); - var_dump($label); - - print "reference, circle...\n"; - unset($id); unset($label_a); unset($label_b); - $id = null; - $label_a = &$label_b; - $label_b = &$label_a; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_a))) - printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - var_dump($id); - var_dump($label_a); - var_dump($label_b); - - print "reference, object, forward declaration...\n"; - unset($bar); unset($id); unset($label_ref); - class foo { - public $foo; - public function __construct() { - $this->foo = &$this->bar; - } - } - class bar extends foo { - public $bar = null; - } - $bar = new bar(); - $id = null; - $label_ref = &$bar->bar; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_ref))) - printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - var_dump($id); - var_dump($bar); - var_dump($label_ref); - - print "references, object, private...\n"; - unset($bar); unset($id); unset($label); - class mega_bar extends bar { - private $id; - public $id_ref; - public function __construct() { - parent::__construct(); - $this->id_ref = &$this->id; - } - } - $bar = new mega_bar(); - $id = &$bar->id_ref; - $label = &$bar->foo; - - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) - printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) - printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id); - var_dump($label); - var_dump($bar); - - mysqli_stmt_close($stmt); - mysqli_close($link); - - print "done!"; + print "reference, one level...\n"; + unset($id); unset($id_ref); unset($label); unset($label_ref); + $id = null; + $id_ref = &$id; + $label = null; + $label_ref = &$label; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) + printf("[004] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + var_dump($id_ref); + var_dump($id); + var_dump($label_ref); + var_dump($label); + + + print "reference, two levels...\n"; + unset($id); unset($id_ref); unset($id_ref_ref); unset($label); unset($label_ref); unset($label_ref_ref); + $id = null; + $id_ref = &$id; + $id_ref_ref = &$id_ref; + $label = null; + $label_ref = &$label; + $label_ref_ref = &$label_ref; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref_ref, $label_ref_ref))) + printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + var_dump($id_ref_ref); + var_dump($id_ref); + var_dump($id); + var_dump($label_ref_ref); + var_dump($label_ref); + var_dump($label); + + print "reference, \$GLOBALS...\n"; + unset($id); unset($id_ref); unset($label); unset($label_ref); + $id = 100; + $id_ref = &$GLOBALS['id']; + $label = null; + $label_ref = &$GLOBALS['label']; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) + printf("[008] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + var_dump($id_ref); + var_dump($id); + var_dump($label_ref); + var_dump($label); + + print "reference, same target...\n"; + $id = null; + $label = &$id; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[010] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + var_dump($id); + var_dump($label); + + print "reference, simple object...\n"; + unset($obj); + $obj = new stdClass(); + $obj->id = null; + $obj->label = null; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $obj->id, $obj->label))) + printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + var_dump($obj->id); + var_dump($obj->label); + + + print "reference, simple object w reference...\n"; + unset($id); unset($label); unset($obj); + $obj = new stdClass(); + $obj->id = null; + $obj->label = null; + $id = &$obj->id; + $label = &$obj->label; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + var_dump($obj->id); + var_dump($obj->label); + + print "reference, simple object w reference, change after bind...\n"; + unset($id); unset($label); unset($obj); + $obj = new stdClass(); + $obj->id = null; + $obj->label = null; + $id = &$obj->id; + $label = &$obj->label; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + $label = &$obj->id; + $id = null; + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + var_dump($obj->id); + var_dump($id); + var_dump($obj->label); + var_dump($label); + + print "reference, one level, change after bind...\n"; + unset($id); unset($label); unset($id_ref); unset($label_ref); + $id = null; + $id_ref = &$id; + $label = null; + $label_ref = &$label; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id_ref, $label_ref))) + printf("[014] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + + $id_ref = 1; + $label_ref = 1; + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + var_dump($id_ref); + var_dump($id); + var_dump($label_ref); + var_dump($label); + + print "reference, circle...\n"; + unset($id); unset($label_a); unset($label_b); + $id = null; + $label_a = &$label_b; + $label_b = &$label_a; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_a))) + printf("[016] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + var_dump($id); + var_dump($label_a); + var_dump($label_b); + + print "reference, object, forward declaration...\n"; + unset($bar); unset($id); unset($label_ref); + class foo { + public $foo; + public function __construct() { + $this->foo = &$this->bar; + } + } + class bar extends foo { + public $bar = null; + } + $bar = new bar(); + $id = null; + $label_ref = &$bar->bar; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label_ref))) + printf("[018] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + var_dump($id); + var_dump($bar); + var_dump($label_ref); + + print "references, object, private...\n"; + unset($bar); unset($id); unset($label); + class mega_bar extends bar { + private $id; + public $id_ref; + public function __construct() { + parent::__construct(); + $this->id_ref = &$this->id; + } + } + $bar = new mega_bar(); + $id = &$bar->id_ref; + $label = &$bar->foo; + + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt) || mysqli_stmt_fetch($stmt)) + printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + var_dump($id); + var_dump($label); + var_dump($bar); + + mysqli_stmt_close($stmt); + mysqli_close($link); + + print "done!"; ?> --CLEAN-- --FILE-- length; - if ($length > strlen($insert)) { + $meta = $meta[0]; + $length = $meta->length; + if ($length > strlen($insert)) { - $expected = str_repeat('0', $length - strlen($insert)); - $expected .= $insert; - if ($expected !== $result) { - printf("[%03d] Expecting '%s' got '%s'\n", $offset, $expected, $result); - return false; - } + $expected = str_repeat('0', $length - strlen($insert)); + $expected .= $insert; + if ($expected !== $result) { + printf("[%03d] Expecting '%s' got '%s'\n", $offset, $expected, $result); + return false; + } - } else if ($length <= 1) { - printf("[%03d] Length reported is too small to run test\n", $offset); - return false; - } + } else if ($length <= 1) { + printf("[%03d] Length reported is too small to run test\n", $offset); + return false; + } - return true; - } + return true; + } - /* - We map those to PHP numeric types - - no padding/filling done. Neither with libmysql nor with mysqlnd. - zerofill(2, $link, 'TINYINT'); - zerofill(3, $link, 'SMALLINT'); - zerofill(4, $link, 'MEDIUMINT'); - zerofill(5, $link, 'INT'); - zerofill(6, $link, 'INTEGER'); - zerofill(7, $link, 'BIGINT'); - zerofill(8, $link, 'FLOAT'); - zerofill(9, $link, 'DOUBLE'); - zerofill(10, $link, 'DOUBLE PRECISION'); - */ - zerofill(11, $link, 'DECIMAL'); - zerofill(12, $link, 'DEC'); + /* + We map those to PHP numeric types - + no padding/filling done. Neither with libmysql nor with mysqlnd. + zerofill(2, $link, 'TINYINT'); + zerofill(3, $link, 'SMALLINT'); + zerofill(4, $link, 'MEDIUMINT'); + zerofill(5, $link, 'INT'); + zerofill(6, $link, 'INTEGER'); + zerofill(7, $link, 'BIGINT'); + zerofill(8, $link, 'FLOAT'); + zerofill(9, $link, 'DOUBLE'); + zerofill(10, $link, 'DOUBLE PRECISION'); + */ + zerofill(11, $link, 'DECIMAL'); + zerofill(12, $link, 'DEC'); - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_close($stmt))) - printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_close($stmt))) + printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); try { mysqli_stmt_close($stmt); @@ -34,47 +34,47 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - if (!$stmt = mysqli_stmt_init($link)) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt = mysqli_stmt_init($link)) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; - if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = $label = null; + if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 100; $label = 'z'; - if (!mysqli_stmt_execute($stmt)) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = 100; $label = 'z'; + if (!mysqli_stmt_execute($stmt)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_kill($link, mysqli_thread_id($link)); + mysqli_kill($link, mysqli_thread_id($link)); - if (true !== ($tmp = mysqli_stmt_close($stmt))) - printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_close($stmt))) + printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - mysqli_close($link); + mysqli_close($link); - require('table.inc'); - if (!$stmt = mysqli_stmt_init($link)) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + require('table.inc'); + if (!$stmt = mysqli_stmt_init($link)) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = $label = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label)) - printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) - printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt)) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_kill($link, mysqli_thread_id($link)); + mysqli_kill($link, mysqli_thread_id($link)); - if (true !== ($tmp = mysqli_stmt_close($stmt))) - printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_close($stmt))) + printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $id = null; - if (!mysqli_stmt_bind_result($stmt, $id)) - printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = null; + if (!mysqli_stmt_bind_result($stmt, $id)) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_store_result($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_store_result($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 2))) - printf("[009] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 2))) + printf("[009] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_fetch($stmt)) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_fetch($stmt)) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id); + var_dump($id); - if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 0))) - printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (!is_null($tmp = mysqli_stmt_data_seek($stmt, 0))) + printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_fetch($stmt)) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_fetch($stmt)) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id); + var_dump($id); - if (!is_null($tmp = mysqli_stmt_data_seek($stmt, mysqli_stmt_num_rows($stmt) + 100))) - printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (!is_null($tmp = mysqli_stmt_data_seek($stmt, mysqli_stmt_num_rows($stmt) + 100))) + printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - if (mysqli_stmt_fetch($stmt)) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (mysqli_stmt_fetch($stmt)) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id); + var_dump($id); - if (false !== ($tmp = mysqli_stmt_data_seek($stmt, -1))) - printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = mysqli_stmt_data_seek($stmt, -1))) + printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - if (mysqli_stmt_fetch($stmt)) - printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (mysqli_stmt_fetch($stmt)) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id); + var_dump($id); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_data_seek($stmt, 0); @@ -75,8 +75,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- query("use $db"); - $c2->query("use $db"); - $c1->query("drop table if exists type_change"); - $c1->query("create table type_change(a int, b char(10)) ENGINE = " . $engine); - $c1->query("insert into type_change values (1, 'one'), (2, 'two')"); - $s1 = $c1->prepare("select a from type_change order by a"); - var_dump($s1->execute(), $s1->bind_result($col1)); - echo "---- Row 1\n"; - var_dump($s1->fetch()); - var_dump($col1); - echo "---- Row 2\n"; - var_dump($s1->fetch()); - var_dump($col1); - echo "---- Row 3\n"; - var_dump($s1->fetch()); - echo "----\n"; + $c1->query("use $db"); + $c2->query("use $db"); + $c1->query("drop table if exists type_change"); + $c1->query("create table type_change(a int, b char(10)) ENGINE = " . $engine); + $c1->query("insert into type_change values (1, 'one'), (2, 'two')"); + $s1 = $c1->prepare("select a from type_change order by a"); + var_dump($s1->execute(), $s1->bind_result($col1)); + echo "---- Row 1\n"; + var_dump($s1->fetch()); + var_dump($col1); + echo "---- Row 2\n"; + var_dump($s1->fetch()); + var_dump($col1); + echo "---- Row 3\n"; + var_dump($s1->fetch()); + echo "----\n"; - echo "ALTER\n"; - var_dump($c2->query("alter table type_change drop a")); - var_dump($s1->execute()); - var_dump($c1->error); + echo "ALTER\n"; + var_dump($c2->query("alter table type_change drop a")); + var_dump($s1->execute()); + var_dump($c1->error); - echo "---- Row 1\n"; - var_dump($s1->fetch()); - var_dump($col1); - echo "---- Row 2\n"; - var_dump($s1->fetch()); - var_dump($col1); - echo "---- Row 3\n"; - var_dump($s1->fetch()); - echo "----\n"; + echo "---- Row 1\n"; + var_dump($s1->fetch()); + var_dump($col1); + echo "---- Row 2\n"; + var_dump($s1->fetch()); + var_dump($col1); + echo "---- Row 3\n"; + var_dump($s1->fetch()); + echo "----\n"; - echo "done!"; + echo "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) - printf("[005] Statement should have failed!\n"); + if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id")) + printf("[005] Statement should have failed!\n"); - // stmt object status test + // stmt object status test try { mysqli_stmt_execute($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) - printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[008] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[008] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) - printf("[009] [%d] %s\n", mysqli_stmt_execute($stmt), mysqli_stmt_execute($stmt)); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) + printf("[009] [%d] %s\n", mysqli_stmt_execute($stmt), mysqli_stmt_execute($stmt)); - // no input variables bound - if (false !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + // no input variables bound + if (false !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - $id = 100; - $label = "z"; - if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = 100; + $label = "z"; + if (!mysqli_stmt_bind_param($stmt, "is", $id, $label)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - // calling reset between executions - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + // calling reset between executions + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT ?")) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT ?")) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $limit = 1; - if (!mysqli_stmt_bind_param($stmt, "i", $limit)) - printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $limit = 1; + if (!mysqli_stmt_bind_param($stmt, "i", $limit)) + printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[016] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[016] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = null; - if (!mysqli_stmt_bind_result($stmt, $id) || !mysqli_stmt_fetch($stmt)) - printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = null; + if (!mysqli_stmt_bind_result($stmt, $id) || !mysqli_stmt_fetch($stmt)) + printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if ($id !== 1) - printf("[018] Expecting int/1 got %s/%s\n", gettype($id), $id); + if ($id !== 1) + printf("[018] Expecting int/1 got %s/%s\n", gettype($id), $id); - if (true !== ($tmp = mysqli_stmt_reset($stmt))) - printf("[019] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_reset($stmt))) + printf("[019] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[020] Expecting boolean/true after reset to prepare status, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[020] Expecting boolean/true after reset to prepare status, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = null; - if (!mysqli_stmt_fetch($stmt)) - printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = null; + if (!mysqli_stmt_fetch($stmt)) + printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if ($id !== 1) - printf("[022] Expecting int/1 got %s/%s\n", gettype($id), $id); + if ($id !== 1) + printf("[022] Expecting int/1 got %s/%s\n", gettype($id), $id); - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) - printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1")) + printf("[024] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[025] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[025] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_reset($stmt))) - printf("[026] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_reset($stmt))) + printf("[026] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump(mysqli_stmt_execute($stmt)); - var_dump(mysqli_stmt_fetch($stmt)); + var_dump(mysqli_stmt_execute($stmt)); + var_dump(mysqli_stmt_fetch($stmt)); - mysqli_kill($link, mysqli_thread_id($link)); + mysqli_kill($link, mysqli_thread_id($link)); - if (false !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[027] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_execute($stmt); @@ -129,8 +129,8 @@ if (mysqli_get_server_version($link) <= 40100) { echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- query("SELECT 1")) - printf("[013] [%d] %s\n", $link->errno, $link->error); + if (!$link->query("SELECT 1")) + printf("[013] [%d] %s\n", $link->errno, $link->error); - } else { - printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); - } + } else { + printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); + } - if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) - printf("[014] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p')) + printf("[014] [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); - if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25)) BEGIN SELECT ver_in AS _ver_out; SELECT 1 AS _more; END;')) { - // two result sets - if (!$stmt = mysqli_prepare($link, 'CALL p(?)')) - printf("[015] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25)) BEGIN SELECT ver_in AS _ver_out; SELECT 1 AS _more; END;')) { + // two result sets + if (!$stmt = mysqli_prepare($link, 'CALL p(?)')) + printf("[015] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - $version = 'myversion'; - if (!mysqli_stmt_bind_param($stmt, 's', $version)) - printf("[016] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $version = 'myversion'; + if (!mysqli_stmt_bind_param($stmt, 's', $version)) + printf("[016] Cannot bind input parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) - printf("[017] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[017] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $version = NULL; - if (!mysqli_stmt_bind_result($stmt, $version) || - !mysqli_stmt_fetch($stmt)) - printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $version = NULL; + if (!mysqli_stmt_bind_result($stmt, $version) || + !mysqli_stmt_fetch($stmt)) + printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if ($version !== "myversion") - printf("[019] Results seem wrong, got %s, [%d] %s\n", - $version, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if ($version !== "myversion") + printf("[019] Results seem wrong, got %s, [%d] %s\n", + $version, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_more_results($link) || !mysqli_next_result($link)) - printf("[020] [%d] %s\n", $link->errno, $link->error); + if (!mysqli_more_results($link) || !mysqli_next_result($link)) + printf("[020] [%d] %s\n", $link->errno, $link->error); - $more = NULL; - if (!mysqli_stmt_bind_result($stmt, $more) || - !mysqli_stmt_fetch($stmt)) - printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $more = NULL; + if (!mysqli_stmt_bind_result($stmt, $more) || + !mysqli_stmt_fetch($stmt)) + printf("[021] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if ($more !== 1) - printf("[022] Results seem wrong, got %s, [%d] %s\n", - $more, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if ($more !== 1) + printf("[022] Results seem wrong, got %s, [%d] %s\n", + $more, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_close($stmt)) - printf("[023] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_close($stmt)) + printf("[023] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!$link->query("SELECT 1")) - printf("[024] [%d] %s\n", $link->errno, $link->error); + if (!$link->query("SELECT 1")) + printf("[024] [%d] %s\n", $link->errno, $link->error); - } else { - printf("[025] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); - } + } else { + printf("[025] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- query("SELECT 1")) - printf("[013] [%d] %s\n", $link->errno, $link->error); + if (!$res = $link->query("SELECT 1")) + printf("[013] [%d] %s\n", $link->errno, $link->error); - } else { - printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); - } + } else { + printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link)); + } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - // FIXME - different versions return different values ?! - if ((NULL !== ($tmp = mysqli_stmt_fetch($stmt))) && (false !== $tmp)) - printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), $tmp); + // FIXME - different versions return different values ?! + if ((NULL !== ($tmp = mysqli_stmt_fetch($stmt))) && (false !== $tmp)) + printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_execute($stmt)) - printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_fetch($stmt))) - printf("[008] NULL, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_fetch($stmt))) + printf("[008] NULL, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = NULL; - $label = NULL; - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) - printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + $id = NULL; + $label = NULL; + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (true !== ($tmp = mysqli_stmt_fetch($stmt))) - printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_fetch($stmt))) + printf("[013] Expecting boolean/true, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_kill($link, mysqli_thread_id($link))) - printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_kill($link, mysqli_thread_id($link))) + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (true !== ($tmp = mysqli_stmt_fetch($stmt))) - printf("[015] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_fetch($stmt))) + printf("[015] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_fetch($stmt); @@ -73,9 +73,9 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- --CLEAN-- --FILE-- type != MYSQLI_TYPE_GEOMETRY) { - printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type); - } - - $num = 0; - $rows = array(); - while (true === @mysqli_stmt_fetch($stmt)) { - $rows[] = array('id' => $id, 'label' => $bind_res); - $num++; - } - - if ($num != 3) { - printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", - $offset + 17, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); - return false; - } - mysqli_stmt_close($stmt); - - foreach ($rows as $row) { - if (!$stmt = mysqli_stmt_init($link)) { - printf("[%04d] [%d] %s\n", $offset + 10, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { - printf("[%04d] [%d] %s\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - $new_id = $row['id'] + 10; - if (!mysqli_stmt_bind_param($stmt, "is", $new_id, $row['label'])) { - printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - if (!mysqli_stmt_execute($stmt)) { - printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - mysqli_stmt_close($stmt); - - if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d", - $new_id))) { - printf("[%04d] [%d] %s\n", $offset + 14, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!$row_normal = mysqli_fetch_assoc($res_normal)) { - printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if ($row_normal['label'] != $row['label']) { - printf("[%04d] PS and non-PS return different data.\n", $offset + 16); - return false; - } - mysqli_free_result($res_normal); - } - - return true; - } - - $geomFromText = $link->server_version >= 80000 ? "ST_GeomFromText" : "GeomFromText"; - func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "$geomFromText('POINT(2 2)')", 20); - func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "$geomFromText('POINT(1 1)')", 40); - func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "$geomFromText('LINESTRING(0 0,1 1,2 2)')", 60); - func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "$geomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80); - func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "$geomFromText('MULTIPOINT(1 1, 2 2)')", 100); - func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "$geomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120); - func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "$geomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140); - func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "$geomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160); - - mysqli_close($link); - print "done!"; + require('connect.inc'); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + function func_mysqli_stmt_fetch_geom($link, $engine, $sql_type, $bind_value, $offset) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail - column type might not be supported by the server, ignore this + return false; + } + + for ($id = 1; $id < 4; $id++) { + $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, %s)", $id, $bind_value); + if (!mysqli_query($link, $sql)) { + printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link)); + } + } + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_store_result($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + if (!mysqli_stmt_bind_result($stmt, $id, $bind_res)) { + printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + $result = mysqli_stmt_result_metadata($stmt); + $fields = mysqli_fetch_fields($result); + if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) { + printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type); + } + + $num = 0; + $rows = array(); + while (true === @mysqli_stmt_fetch($stmt)) { + $rows[] = array('id' => $id, 'label' => $bind_res); + $num++; + } + + if ($num != 3) { + printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", + $offset + 17, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); + return false; + } + mysqli_stmt_close($stmt); + + foreach ($rows as $row) { + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 10, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + $new_id = $row['id'] + 10; + if (!mysqli_stmt_bind_param($stmt, "is", $new_id, $row['label'])) { + printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + mysqli_stmt_close($stmt); + + if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d", + $new_id))) { + printf("[%04d] [%d] %s\n", $offset + 14, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$row_normal = mysqli_fetch_assoc($res_normal)) { + printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($row_normal['label'] != $row['label']) { + printf("[%04d] PS and non-PS return different data.\n", $offset + 16); + return false; + } + mysqli_free_result($res_normal); + } + + return true; + } + + $geomFromText = $link->server_version >= 80000 ? "ST_GeomFromText" : "GeomFromText"; + func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "$geomFromText('POINT(2 2)')", 20); + func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "$geomFromText('POINT(1 1)')", 40); + func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "$geomFromText('LINESTRING(0 0,1 1,2 2)')", 60); + func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "$geomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80); + func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "$geomFromText('MULTIPOINT(1 1, 2 2)')", 100); + func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "$geomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120); + func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "$geomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140); + func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "$geomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160); + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (mysqli_stmt_prepare($stmt, '')) - printf("[004] Prepare should fail for an empty statement\n"); + if (mysqli_stmt_prepare($stmt, '')) + printf("[004] Prepare should fail for an empty statement\n"); - try { + try { mysqli_stmt_field_count($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, 'SELECT 1')) - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_prepare($stmt, 'SELECT 1')) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, 'SELECT 1, 2')) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_prepare($stmt, 'SELECT 1, 2')) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test')) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (2 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, 'SELECT label FROM test') || - !mysqli_stmt_execute($stmt)) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_prepare($stmt, 'SELECT label FROM test') || + !mysqli_stmt_execute($stmt)) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - $label = null; - if (mysqli_stmt_bind_param($stmt, "s", $label)) - printf("[014] expected error - got ok\n"); - while (mysqli_stmt_fetch($stmt)) - if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[015] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); + $label = null; + if (mysqli_stmt_bind_param($stmt, "s", $label)) + printf("[014] expected error - got ok\n"); + while (mysqli_stmt_fetch($stmt)) + if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[015] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id) VALUES (100)')) - printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[017] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id) VALUES (100)')) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[017] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'z' WHERE id = 1") || - !mysqli_stmt_execute($stmt)) - printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'z' WHERE id = 1") || + !mysqli_stmt_execute($stmt)) + printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) - printf("[019] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = mysqli_stmt_field_count($stmt))) + printf("[019] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_prepare($stmt, 'SELECT id FROM test'); @@ -77,15 +77,15 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - try { + try { mysqli_stmt_field_count($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) - printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) + printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_execute($stmt)) - printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) - printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) + printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = mysqli_stmt_store_result($stmt))) - printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = mysqli_stmt_store_result($stmt))) + printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt = mysqli_stmt_init($link)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_store_result($stmt))) - printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_store_result($stmt))) + printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) - printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) + printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_free_result($stmt); @@ -67,9 +67,9 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - // FIXME - different versions return different values ?! - if ((NULL !== ($tmp = mysqli_stmt_get_result($stmt))) && (false !== $tmp)) - printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + // FIXME - different versions return different values ?! + if ((NULL !== ($tmp = mysqli_stmt_get_result($stmt))) && (false !== $tmp)) + printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - if (!mysqli_stmt_execute($stmt)) - printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_store_result($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_store_result($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (is_object($tmp = mysqli_stmt_store_result($stmt))) - printf("[009] non-object, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (is_object($tmp = mysqli_stmt_store_result($stmt))) + printf("[009] non-object, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt = mysqli_stmt_init($link)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - // stmt object status test + // stmt object status test try { mysqli_stmt_fetch($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - // FIXME - different versions return different values ?! - if ((NULL !== ($tmp = mysqli_stmt_get_result($stmt))) && (false !== $tmp)) - printf("[013] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + // FIXME - different versions return different values ?! + if ((NULL !== ($tmp = mysqli_stmt_get_result($stmt))) && (false !== $tmp)) + printf("[013] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - if (!mysqli_stmt_execute($stmt)) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!is_object($tmp = mysqli_stmt_get_result($stmt))) - printf("[016] NULL, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (!is_object($tmp = mysqli_stmt_get_result($stmt))) + printf("[016] NULL, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - mysqli_free_result($tmp); - mysqli_stmt_close($stmt); + mysqli_free_result($tmp); + mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt = mysqli_stmt_init($link)) + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - // stmt object status test + // stmt object status test try { mysqli_stmt_get_result($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) + printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (false !== ($tmp = mysqli_stmt_get_result($stmt))) - printf("[020] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (false !== ($tmp = mysqli_stmt_get_result($stmt))) + printf("[020] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - if (!mysqli_stmt_execute($stmt)) - printf("[023] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[023] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!is_object($tmp = mysqli_stmt_get_result($stmt))) - printf("[024] Expecting object, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (!is_object($tmp = mysqli_stmt_get_result($stmt))) + printf("[024] Expecting object, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - if (false !== ($tmp = mysqli_stmt_fetch($stmt))) - printf("[025] false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (false !== ($tmp = mysqli_stmt_fetch($stmt))) + printf("[025] false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) { - printf("[026] [%d] [%s]\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - printf("[027] [%d] [%s]\n", mysqli_errno($link), mysqli_error($link)); - printf("[028] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - } + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) { + printf("[026] [%d] [%s]\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + printf("[027] [%d] [%s]\n", mysqli_errno($link), mysqli_error($link)); + printf("[028] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + } - if (false !== ($tmp = mysqli_stmt_fetch($stmt))) - printf("[029] false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (false !== ($tmp = mysqli_stmt_fetch($stmt))) + printf("[029] false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt = mysqli_stmt_init($link)) + printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) - printf("[033] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2")) + printf("[033] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) - printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[034] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = NULL; - $label = NULL; - if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) - printf("[035] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + $id = NULL; + $label = NULL; + if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) + printf("[035] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - if (!is_object($tmp = $result = mysqli_stmt_get_result($stmt))) - printf("[036] Expecting array, got %s/%s, [%d] %s\n", - gettype($tmp), var_export($tmp, 1), - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!is_object($tmp = $result = mysqli_stmt_get_result($stmt))) + printf("[036] Expecting array, got %s/%s, [%d] %s\n", + gettype($tmp), var_export($tmp, 1), + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (false !== ($tmp = mysqli_stmt_fetch($stmt))) - printf("[037] Expecting boolean/false, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (false !== ($tmp = mysqli_stmt_fetch($stmt))) + printf("[037] Expecting boolean/false, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - printf("[038] [%d] [%s]\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - printf("[039] [%d] [%s]\n", mysqli_errno($link), mysqli_error($link)); - while ($row = mysqli_fetch_assoc($result)) { - var_dump($row); - } - mysqli_free_result($result); + printf("[038] [%d] [%s]\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + printf("[039] [%d] [%s]\n", mysqli_errno($link), mysqli_error($link)); + while ($row = mysqli_fetch_assoc($result)) { + var_dump($row); + } + mysqli_free_result($result); - if (!mysqli_kill($link, mysqli_thread_id($link))) - printf("[040] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_kill($link, mysqli_thread_id($link))) + printf("[040] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (false !== ($tmp = mysqli_stmt_get_result($stmt))) - printf("[041] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); + if (false !== ($tmp = mysqli_stmt_get_result($stmt))) + printf("[041] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1)); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - try { + try { mysqli_stmt_fetch($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))) { - printf("[024] Unknown result set type %s\n", $res->type); - } - if ($res->type !== MYSQLI_STORE_RESULT) - printf("[025] Expecting int/%d got %s/%s", MYSQLI_STORE_RESULT, gettype($res->type), $res->type); - - mysqli_free_result($res); - mysqli_stmt_close($stmt); - mysqli_close($link); + /* + NOTE: no datatype tests here! This is done by + mysqli_stmt_bind_result.phpt already. Restrict + this test case to the basics. + */ + require_once("connect.inc"); + + require('table.inc'); + + if (!$stmt = mysqli_stmt_init($link)) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[007] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + while ($row = mysqli_fetch_assoc($res)) + var_dump($row); + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + + if (false !== ($res = mysqli_stmt_get_result($stmt))) { + printf("[008] boolean/false got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + mysqli_stmt_execute($stmt); + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[009] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + while ($row = mysqli_fetch_assoc($res)) + var_dump($row); + var_dump(mysqli_fetch_assoc($res)); + mysqli_free_result($res); + + mysqli_stmt_close($stmt); + + if (!($stmt = mysqli_stmt_init($link)) || + !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || + !mysqli_stmt_execute($stmt)) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_fetch($stmt)) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (false !== ($res = mysqli_stmt_get_result($stmt))) { + printf("[013] boolean/false got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + mysqli_stmt_close($stmt); + + if (!($stmt = mysqli_stmt_init($link)) || + !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || + !mysqli_stmt_execute($stmt)) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[015] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_fetch($stmt)) + printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + mysqli_stmt_close($stmt); + + if (!($stmt = mysqli_stmt_init($link)) || + !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || + !mysqli_stmt_execute($stmt)) + printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[019] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + $id = $label = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[020] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $row = mysqli_fetch_assoc($res); + if (NULL !== $id || NULL !== $label) + printf("[021] Bound variables should not have been set\n"); + mysqli_free_result($res); + + mysqli_stmt_close($stmt); + + if (!($stmt = mysqli_stmt_init($link)) || + !mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2") || + !mysqli_stmt_execute($stmt)) + printf("[022] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[023] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + if (!in_array($res->type, array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT))) { + printf("[024] Unknown result set type %s\n", $res->type); + } + if ($res->type !== MYSQLI_STORE_RESULT) + printf("[025] Expecting int/%d got %s/%s", MYSQLI_STORE_RESULT, gettype($res->type), $res->type); + + mysqli_free_result($res); + mysqli_stmt_close($stmt); + mysqli_close($link); try { mysqli_stmt_get_result($stmt); @@ -138,7 +138,7 @@ if (!function_exists('mysqli_stmt_get_result')) echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- = 1; $bitval = $bitval / 2) { - if (($dec / $bitval) >= 1) { - $bin .= '1'; - $dec -= $bitval; - } else { - $bin .= '0'; - } - } - return $bin; - } - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - - for ($bits = 1; $bits <= 46; $bits++) { - if (1 == $bits) - $max_value = 1; - else - $max_value = pow(2, $bits) - 1; - - if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || - !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id BIGINT UNSIGNED, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE="%s"', $bits, $bits, $engine))) - printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); - - if (!$stmt = mysqli_stmt_init($link)) - printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - - $tests = 0; - $rand_max = mt_getrandmax(); - while ($tests < 10) { - - $tests++; - if (1 == $tests) - $value = 0; - else if (2 == $tests) - $value = $max_value; - else { - if ($max_value > $rand_max) { - $max_loops = floor($max_value/$rand_max); - $num_loops = mt_rand(1, $max_loops); - $value = 0; - for ($i = 0; $i < $num_loops; $i++) - $value += mt_rand(0, $rand_max); - } else { - $value = mt_rand(0, $max_value); - } - } - - $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); - $sql = sprintf("INSERT INTO test(id, bit_value) VALUES (%s, b'%s')", $value, $bin); - for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) - ; - $bin2 = substr($bin, $i, strlen($bin)); - - if (!mysqli_stmt_prepare($stmt, $sql) || - !mysqli_stmt_execute($stmt)) - printf("[004 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - $sql = sprintf("SELECT bin(bit_value) AS _bin, id, bit_value, bit_null FROM test WHERE id = %s", $value); - if (!mysqli_stmt_prepare($stmt, $sql) || - !mysqli_stmt_execute($stmt)) - printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!$res = mysqli_stmt_get_result($stmt)) - printf("[006 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - - if (!$row = mysqli_fetch_assoc($res)) - printf("[007 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); - - if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { - debug_zval_dump($row); - printf("[008 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", - $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); - break; - } - if ($value != $row['bit_value']) { - debug_zval_dump($row); - printf("%10s %64s\n%10s %64s\n", '_bin', $row['_bin'], 'insert', $bin); - printf("[009 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); - break; - } - - if (null !== $row['bit_null']) { - debug_zval_dump($row); - printf("[010 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); - break; - } - - } - - mysqli_stmt_close($stmt); - - } - - mysqli_close($link); - print "done!"; + require('connect.inc'); + + function dec32bin($dec, $bits) { + + $maxval = pow(2, $bits); + $bin = ''; + for ($bitval = $maxval; $bitval >= 1; $bitval = $bitval / 2) { + if (($dec / $bitval) >= 1) { + $bin .= '1'; + $dec -= $bitval; + } else { + $bin .= '0'; + } + } + return $bin; + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + + for ($bits = 1; $bits <= 46; $bits++) { + if (1 == $bits) + $max_value = 1; + else + $max_value = pow(2, $bits) - 1; + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id BIGINT UNSIGNED, bit_value BIT(%d) NOT NULL, bit_null BIT(%d) DEFAULT NULL) ENGINE="%s"', $bits, $bits, $engine))) + printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link)); + + if (!$stmt = mysqli_stmt_init($link)) + printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + + $tests = 0; + $rand_max = mt_getrandmax(); + while ($tests < 10) { + + $tests++; + if (1 == $tests) + $value = 0; + else if (2 == $tests) + $value = $max_value; + else { + if ($max_value > $rand_max) { + $max_loops = floor($max_value/$rand_max); + $num_loops = mt_rand(1, $max_loops); + $value = 0; + for ($i = 0; $i < $num_loops; $i++) + $value += mt_rand(0, $rand_max); + } else { + $value = mt_rand(0, $max_value); + } + } + + $bin = ($bits < 32) ? decbin($value) : dec32bin($value, $bits); + $sql = sprintf("INSERT INTO test(id, bit_value) VALUES (%s, b'%s')", $value, $bin); + for ($i = 0; ($i < strlen($bin)) && ($bin[$i] == '0'); $i++) + ; + $bin2 = substr($bin, $i, strlen($bin)); + + if (!mysqli_stmt_prepare($stmt, $sql) || + !mysqli_stmt_execute($stmt)) + printf("[004 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + $sql = sprintf("SELECT bin(bit_value) AS _bin, id, bit_value, bit_null FROM test WHERE id = %s", $value); + if (!mysqli_stmt_prepare($stmt, $sql) || + !mysqli_stmt_execute($stmt)) + printf("[005 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!$res = mysqli_stmt_get_result($stmt)) + printf("[006 - %d] [%d] %s\n", $bits, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[007 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + + if (($value != $row['id']) || (($bin != $row['_bin']) && ($bin2 != $row['_bin']))) { + debug_zval_dump($row); + printf("[008 - %d] Insert of %s in BIT(%d) column might have failed. id = %s, bin = %s (%s/%s)\n", + $bits, $value, $bits, $row['id'], $row['_bin'], $bin, $bin2); + break; + } + if ($value != $row['bit_value']) { + debug_zval_dump($row); + printf("%10s %64s\n%10s %64s\n", '_bin', $row['_bin'], 'insert', $bin); + printf("[009 - %d] Expecting %s got %s\n", $bits, $value, $row['bit_value']); + break; + } + + if (null !== $row['bit_null']) { + debug_zval_dump($row); + printf("[010 - %d] Expecting null got %s/%s\n", $bits, gettype($row['bit_value']), $row['bit_value']); + break; + } + + } + + mysqli_stmt_close($stmt); + + } + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- field_count, - $res->field_count); + printf("%s %s\n", + $res_meta->field_count, + $res->field_count); - mysqli_stmt_close($stmt); - mysqli_close($link); - print "done!"; + mysqli_stmt_close($stmt); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- type != MYSQLI_TYPE_GEOMETRY) { - printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type); - } - - $num = 0; - while ($row = mysqli_fetch_assoc($res)) { - $bind_res = &$row['label']; - - if (!$stmt2 = mysqli_stmt_init($link)) { - printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test(id, label) VALUES (?, ?)")) { - printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); - return false; - } - - $id = $row['id'] + 10; - if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) { - printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); - return false; - } - - if (!mysqli_stmt_execute($stmt2)) { - printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); - return false; - } - mysqli_stmt_close($stmt2); - - if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d", - $row['id'] + 10))) { - printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!$row_normal = mysqli_fetch_assoc($res_normal)) { - printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if ($row_normal['label'] != $bind_res) { - printf("[%04d] PS and non-PS return different data.\n", $offset + 17); - return false; - } - mysqli_free_result($res_normal); - $num++; - } - - if ($num != 3) { - printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", - $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); - mysqli_free_result($res); - mysqli_stmt_close($stmt); - return false; - } - mysqli_free_result($res); - mysqli_stmt_close($stmt); - - return true; - } - - $geomFromText = $link->server_version >= 80000 ? "ST_GeomFromText" : "GeomFromText"; - func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "$geomFromText('POINT(2 2)')", 20); - func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "$geomFromText('POINT(1 1)')", 40); - func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "$geomFromText('LINESTRING(0 0,1 1,2 2)')", 60); - func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "$geomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80); - func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "$geomFromText('MULTIPOINT(1 1, 2 2)')", 100); - func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "$geomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120); - func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "$geomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140); - func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "$geomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160); - - mysqli_close($link); - print "done!"; + require('connect.inc'); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + function func_mysqli_stmt_get_result_geom($link, $engine, $sql_type, $bind_value, $offset) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail - column type might not be supported by the server, ignore this + return false; + } + + for ($id = 1; $id < 4; $id++) { + $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, %s)", $id, $bind_value); + if (!mysqli_query($link, $sql)) { + printf("[%04d] [%d] %s\n", $offset + 2 + $id, mysqli_errno($link), mysqli_error($link)); + } + } + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 6, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + if (!$res = mysqli_stmt_get_result($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + $result = mysqli_stmt_result_metadata($stmt); + $fields = mysqli_fetch_fields($result); + if ($fields[1]->type != MYSQLI_TYPE_GEOMETRY) { + printf("[%04d] [%d] %s wrong type %d\n", $offset + 10, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $fields[1]->type); + } + + $num = 0; + while ($row = mysqli_fetch_assoc($res)) { + $bind_res = &$row['label']; + + if (!$stmt2 = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 11, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt2, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 12, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); + return false; + } + + $id = $row['id'] + 10; + if (!mysqli_stmt_bind_param($stmt2, "is", $id, $bind_res)) { + printf("[%04d] [%d] %s\n", $offset + 13, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); + return false; + } + + if (!mysqli_stmt_execute($stmt2)) { + printf("[%04d] [%d] %s\n", $offset + 14, mysqli_stmt_errno($stmt2), mysqli_stmt_error($stmt2)); + return false; + } + mysqli_stmt_close($stmt2); + + if (!$res_normal = mysqli_query($link, sprintf("SELECT id, label FROM test WHERE id = %d", + $row['id'] + 10))) { + printf("[%04d] [%d] %s\n", $offset + 15, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$row_normal = mysqli_fetch_assoc($res_normal)) { + printf("[%04d] [%d] %s\n", $offset + 16, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if ($row_normal['label'] != $bind_res) { + printf("[%04d] PS and non-PS return different data.\n", $offset + 17); + return false; + } + mysqli_free_result($res_normal); + $num++; + } + + if ($num != 3) { + printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", + $offset + 18, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); + mysqli_free_result($res); + mysqli_stmt_close($stmt); + return false; + } + mysqli_free_result($res); + mysqli_stmt_close($stmt); + + return true; + } + + $geomFromText = $link->server_version >= 80000 ? "ST_GeomFromText" : "GeomFromText"; + func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "$geomFromText('POINT(2 2)')", 20); + func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "$geomFromText('POINT(1 1)')", 40); + func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "$geomFromText('LINESTRING(0 0,1 1,2 2)')", 60); + func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "$geomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80); + func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "$geomFromText('MULTIPOINT(1 1, 2 2)')", 100); + func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "$geomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120); + func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "$geomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140); + func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "$geomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160); + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- field_count())) - printf("[010] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); - - if (($tmp1 = $res_meta->field_count()) !== $tmp2) - printf("[011] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); - */ - - if (($tmp1 = mysqli_field_tell($res)) !== ($tmp2 = $res_meta->current_field)) - printf("[012] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); - - if (0 !== $tmp1) - printf("[013] Expecting int/0 got %s/%s\n", gettype($tmp1), $tmp1); - - $fields = array(); - while ($info = $res->fetch_field()) - $fields['res'][] = $info; - var_dump($info); - while ($info = $res_meta->fetch_field()) - $fields['meta'][] = $info; - var_dump($info); - $fields['all_res'] = $res->fetch_fields(); - $fields['all_meta'] = $res_meta->fetch_fields(); - - if (count($fields['res']) != count($fields['meta'])) { - printf("[014] stmt_get_result indicates %d fields, stmt_result_metadata indicates %d fields\n", - count($fields['res']), - count($fields['meta'])); - } - - foreach ($fields['res'] as $k => $info) { - printf("%s\n", $info->name); - if ($info->name !== $fields['meta'][$k]->name) - printf("[015 - %d] Expecting name %s/%s got %s/%s\n", - $k, gettype($info->name), $info->name, gettype($fields['meta'][$k]->name), $fields['meta'][$k]->name); - - if ($info->orgname !== $fields['meta'][$k]->orgname) - printf("[016 - %d] Expecting orgname %s/%s got %s/%s\n", - $k, gettype($info->orgname), $info->orgname, gettype($fields['meta'][$k]->orgname), $fields['meta'][$k]->orgname); - - if ($info->table !== $fields['meta'][$k]->table) - printf("[017 - %d] Expecting table %s/%s got %s/%s\n", - $k, gettype($info->table), $info->table, gettype($fields['meta'][$k]->table), $fields['meta'][$k]->table); - - if ($info->orgtable !== $fields['meta'][$k]->orgtable) - printf("[018 - %d] Expecting orgtable %s/%s got %s/%s\n", - $k, gettype($info->orgtable), $info->orgtable, gettype($fields['meta'][$k]->orgtable), $fields['meta'][$k]->orgtable); - - if ($info->def !== $fields['meta'][$k]->def) - printf("[019 - %d] Expecting def %s/%s got %s/%s\n", - $k, gettype($info->def), $info->def, gettype($fields['meta'][$k]->def), $fields['meta'][$k]->def); + require('table.inc'); + + if (!$stmt = mysqli_stmt_init($link)) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 3")) + printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[004] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + if (!is_object($res_meta = mysqli_stmt_result_metadata($stmt)) || + 'mysqli_result' != get_class($res_meta)) { + printf("[005] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + var_dump(mysqli_fetch_assoc($res)); + var_dump(mysqli_fetch_assoc($res_meta)); + + mysqli_free_result($res); + mysqli_free_result($res_meta); + mysqli_stmt_close($stmt); + + // !mysqli_stmt_prepare($stmt, "SELECT id, label, id + 1 as _id, concat(label, '_') _label FROM test as _test ORDER BY id ASC LIMIT 3") || + if (!($stmt = mysqli_stmt_init($link)) || + !mysqli_stmt_prepare($stmt, "SELECT id , label, id + 1 AS _id, label AS _label, null AS _null, CONCAT(label, '_') _label_concat FROM test _test ORDER BY id ASC LIMIT 3") || + !mysqli_stmt_execute($stmt)) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[007] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + if (!is_object($res_meta = mysqli_stmt_result_metadata($stmt)) || + 'mysqli_result' != get_class($res_meta)) { + printf("[008] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + if (($tmp1 = mysqli_num_fields($res)) !== ($tmp2 = mysqli_num_fields($res_meta))) { + printf("[009] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); + } + + /* + if (($tmp1 = mysqli_field_count($link)) !== ($tmp2 = $res->field_count())) + printf("[010] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); + + if (($tmp1 = $res_meta->field_count()) !== $tmp2) + printf("[011] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); + */ + + if (($tmp1 = mysqli_field_tell($res)) !== ($tmp2 = $res_meta->current_field)) + printf("[012] %s/%s !== %s/%s\n", gettype($tmp1), $tmp1, gettype($tmp2), $tmp2); + + if (0 !== $tmp1) + printf("[013] Expecting int/0 got %s/%s\n", gettype($tmp1), $tmp1); + + $fields = array(); + while ($info = $res->fetch_field()) + $fields['res'][] = $info; + var_dump($info); + while ($info = $res_meta->fetch_field()) + $fields['meta'][] = $info; + var_dump($info); + $fields['all_res'] = $res->fetch_fields(); + $fields['all_meta'] = $res_meta->fetch_fields(); + + if (count($fields['res']) != count($fields['meta'])) { + printf("[014] stmt_get_result indicates %d fields, stmt_result_metadata indicates %d fields\n", + count($fields['res']), + count($fields['meta'])); + } + + foreach ($fields['res'] as $k => $info) { + printf("%s\n", $info->name); + if ($info->name !== $fields['meta'][$k]->name) + printf("[015 - %d] Expecting name %s/%s got %s/%s\n", + $k, gettype($info->name), $info->name, gettype($fields['meta'][$k]->name), $fields['meta'][$k]->name); + + if ($info->orgname !== $fields['meta'][$k]->orgname) + printf("[016 - %d] Expecting orgname %s/%s got %s/%s\n", + $k, gettype($info->orgname), $info->orgname, gettype($fields['meta'][$k]->orgname), $fields['meta'][$k]->orgname); + + if ($info->table !== $fields['meta'][$k]->table) + printf("[017 - %d] Expecting table %s/%s got %s/%s\n", + $k, gettype($info->table), $info->table, gettype($fields['meta'][$k]->table), $fields['meta'][$k]->table); + + if ($info->orgtable !== $fields['meta'][$k]->orgtable) + printf("[018 - %d] Expecting orgtable %s/%s got %s/%s\n", + $k, gettype($info->orgtable), $info->orgtable, gettype($fields['meta'][$k]->orgtable), $fields['meta'][$k]->orgtable); + + if ($info->def !== $fields['meta'][$k]->def) + printf("[019 - %d] Expecting def %s/%s got %s/%s\n", + $k, gettype($info->def), $info->def, gettype($fields['meta'][$k]->def), $fields['meta'][$k]->def); /* - if ($info->max_length !== $fields['meta'][$k]->max_length) - printf("[020 - %d] Expecting max_length %s/%s got %s/%s\n", - $k, gettype($info->max_length), $info->max_length, gettype($fields['meta'][$k]->max_length), $fields['meta'][$k]->max_length); + if ($info->max_length !== $fields['meta'][$k]->max_length) + printf("[020 - %d] Expecting max_length %s/%s got %s/%s\n", + $k, gettype($info->max_length), $info->max_length, gettype($fields['meta'][$k]->max_length), $fields['meta'][$k]->max_length); */ - if ($info->length !== $fields['meta'][$k]->length) - printf("[021 - %d] Expecting length %s/%s got %s/%s\n", - $k, gettype($info->length), $info->length, gettype($fields['meta'][$k]->length), $fields['meta'][$k]->length); - - if ($info->charsetnr !== $fields['meta'][$k]->charsetnr) - printf("[022 - %d] Expecting charsetnr %s/%s got %s/%s\n", - $k, gettype($info->charsetnr), $info->charsetnr, gettype($fields['meta'][$k]->charsetnr), $fields['meta'][$k]->charsetnr); - - if ($info->flags !== $fields['meta'][$k]->flags) - printf("[023 - %d] Expecting flags %s/%s got %s/%s\n", - $k, gettype($info->flags), $info->flags, gettype($fields['meta'][$k]->flags), $fields['meta'][$k]->flags); - - if ($info->type !== $fields['meta'][$k]->type) - printf("[024 - %d] Expecting type %s/%s got %s/%s\n", - $k, gettype($info->type), $info->type, gettype($fields['meta'][$k]->type), $fields['meta'][$k]->type); - - if ($info->decimals !== $fields['meta'][$k]->decimals) - printf("[025 - %d] Expecting decimals %s/%s got %s/%s\n", - $k, getdecimals($info->decimals), $info->decimals, getdecimals($fields['meta'][$k]->decimals), $fields['meta'][$k]->decimals); - - /* Make them equal for the check */ - $tmp = $fields['all_res'][$k]->max_length; - $fields['all_res'][$k]->max_length = $fields['all_meta'][$k]->max_length; - - if ($fields['all_res'][$k] != $fields['all_meta'][$k]) { - printf("[026 - %d] fetch_fields() seems to have returned different data, dumping\n", $k); - var_dump($fields['all_res'][$k]); - var_dump($fields['all_meta'][$k]); - } - $fields['all_res'][$k]->max_length = $tmp; - } - - $num = count($fields['res']); - for ($i = 0; $i < 100; $i++) { - $pos = mt_rand(-1, $num + 1); - if ($pos >= 0 && $pos < $num) { - if (true !== mysqli_field_seek($res, $pos)) - printf("[027] field_seek(res) failed\n"); - if (true !== $res_meta->field_seek($pos)) - printf("[028] field_seek(res__meta) failed\n"); - - $tmp1 = $res->fetch_field(); - $tmp2 = mysqli_fetch_field($res_meta); - $tmp2->max_length = $tmp1->max_length; - if ($tmp1 != $tmp2) { - printf("[029] Field info differs, dumping data\n"); - var_dump($tmp1); - var_dump($tmp2); - } - - if ($tmp1 != $fields['res'][$pos]) { - printf("[030] Field info differs, dumping data\n"); - var_dump($tmp1); - var_dump($fields['res'][$pos]); - } - - $pos++; - if ($pos !== ($tmp = mysqli_field_tell($res))) - printf("[031] Expecting %s/%s got %s/%s\n", - gettype($pos), $pos, gettype($tmp), $tmp); - - if ($pos !== ($tmp = mysqli_field_tell($res_meta))) - printf("[032] Expecting %s/%s got %s/%s\n", - gettype($pos), $pos, gettype($tmp), $tmp); - } else { - - if (false !== @mysqli_field_seek($res, $pos)) - printf("[033] field_seek(%d) did not fail\n", $pos); - if (false !== @mysqli_field_seek($res_meta, $pos)) - printf("[034] field_seek(%d) did not fail\n", $pos); - } - } - - $res->free_result(); - mysqli_free_result($res_meta); - - try { + if ($info->length !== $fields['meta'][$k]->length) + printf("[021 - %d] Expecting length %s/%s got %s/%s\n", + $k, gettype($info->length), $info->length, gettype($fields['meta'][$k]->length), $fields['meta'][$k]->length); + + if ($info->charsetnr !== $fields['meta'][$k]->charsetnr) + printf("[022 - %d] Expecting charsetnr %s/%s got %s/%s\n", + $k, gettype($info->charsetnr), $info->charsetnr, gettype($fields['meta'][$k]->charsetnr), $fields['meta'][$k]->charsetnr); + + if ($info->flags !== $fields['meta'][$k]->flags) + printf("[023 - %d] Expecting flags %s/%s got %s/%s\n", + $k, gettype($info->flags), $info->flags, gettype($fields['meta'][$k]->flags), $fields['meta'][$k]->flags); + + if ($info->type !== $fields['meta'][$k]->type) + printf("[024 - %d] Expecting type %s/%s got %s/%s\n", + $k, gettype($info->type), $info->type, gettype($fields['meta'][$k]->type), $fields['meta'][$k]->type); + + if ($info->decimals !== $fields['meta'][$k]->decimals) + printf("[025 - %d] Expecting decimals %s/%s got %s/%s\n", + $k, getdecimals($info->decimals), $info->decimals, getdecimals($fields['meta'][$k]->decimals), $fields['meta'][$k]->decimals); + + /* Make them equal for the check */ + $tmp = $fields['all_res'][$k]->max_length; + $fields['all_res'][$k]->max_length = $fields['all_meta'][$k]->max_length; + + if ($fields['all_res'][$k] != $fields['all_meta'][$k]) { + printf("[026 - %d] fetch_fields() seems to have returned different data, dumping\n", $k); + var_dump($fields['all_res'][$k]); + var_dump($fields['all_meta'][$k]); + } + $fields['all_res'][$k]->max_length = $tmp; + } + + $num = count($fields['res']); + for ($i = 0; $i < 100; $i++) { + $pos = mt_rand(-1, $num + 1); + if ($pos >= 0 && $pos < $num) { + if (true !== mysqli_field_seek($res, $pos)) + printf("[027] field_seek(res) failed\n"); + if (true !== $res_meta->field_seek($pos)) + printf("[028] field_seek(res__meta) failed\n"); + + $tmp1 = $res->fetch_field(); + $tmp2 = mysqli_fetch_field($res_meta); + $tmp2->max_length = $tmp1->max_length; + if ($tmp1 != $tmp2) { + printf("[029] Field info differs, dumping data\n"); + var_dump($tmp1); + var_dump($tmp2); + } + + if ($tmp1 != $fields['res'][$pos]) { + printf("[030] Field info differs, dumping data\n"); + var_dump($tmp1); + var_dump($fields['res'][$pos]); + } + + $pos++; + if ($pos !== ($tmp = mysqli_field_tell($res))) + printf("[031] Expecting %s/%s got %s/%s\n", + gettype($pos), $pos, gettype($tmp), $tmp); + + if ($pos !== ($tmp = mysqli_field_tell($res_meta))) + printf("[032] Expecting %s/%s got %s/%s\n", + gettype($pos), $pos, gettype($tmp), $tmp); + } else { + + if (false !== @mysqli_field_seek($res, $pos)) + printf("[033] field_seek(%d) did not fail\n", $pos); + if (false !== @mysqli_field_seek($res_meta, $pos)) + printf("[034] field_seek(%d) did not fail\n", $pos); + } + } + + $res->free_result(); + mysqli_free_result($res_meta); + + try { mysqli_fetch_field($res); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); - try { + try { mysqli_fetch_field($res); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - try { + try { mysqli_fetch_field($res); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- fetch_field()) { - var_dump($field); - $i++; - if (2 == $i) { - /* - Label column, result set charset. - All of the following columns are "too hot" - too server dependent - */ - if ($field->charsetnr != $charsetInfo->number) { - printf("[004] Expecting charset %s/%d got %d\n", - $charsetInfo->charset, - $charsetInfo->number, $field->charsetnr); - } - if ($field->length != $charsetInfo->max_length) { - printf("[005] Expecting length %d got %d\n", - $charsetInfo->max_length, $field->max_length); - } - } - } + $i = 0; + while ($field = $res->fetch_field()) { + var_dump($field); + $i++; + if (2 == $i) { + /* + Label column, result set charset. + All of the following columns are "too hot" - too server dependent + */ + if ($field->charsetnr != $charsetInfo->number) { + printf("[004] Expecting charset %s/%d got %d\n", + $charsetInfo->charset, + $charsetInfo->number, $field->charsetnr); + } + if ($field->length != $charsetInfo->max_length) { + printf("[005] Expecting length %d got %d\n", + $charsetInfo->max_length, $field->max_length); + } + } + } - mysqli_stmt_close($stmt); - mysqli_close($link); - print "done!"; + mysqli_stmt_close($stmt); + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- prepare('SHOW ENGINES') || - !$stmt->execute()) - printf("[002] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->prepare('SHOW ENGINES') || + !$stmt->execute()) + printf("[002] [%d] %s\n", $stmt->errno, $stmt->error); - if (!$res = $stmt->get_result()) - printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$res = $stmt->get_result()) + printf("[003] [%d] %s\n", $stmt->errno, $stmt->error); - $engines = mysqli_fetch_all($res, MYSQLI_NUM); - if (empty($engines)) { - printf("[004] It is very unlikely that SHOW ENGINES returns no data, check manually\n"); - } else { - $found = false; - foreach ($engines as $k => $engine) - foreach ($engine as $k => $v) - if (stristr($v, 'MyISAM')) { - $found = true; - break; - } - if (!$found) - printf("[005] It is very unlikely that SHOW ENGINES does not show MyISAM, check manually\n"); - } - mysqli_free_result($res); - } + $engines = mysqli_fetch_all($res, MYSQLI_NUM); + if (empty($engines)) { + printf("[004] It is very unlikely that SHOW ENGINES returns no data, check manually\n"); + } else { + $found = false; + foreach ($engines as $k => $engine) + foreach ($engine as $k => $v) + if (stristr($v, 'MyISAM')) { + $found = true; + break; + } + if (!$found) + printf("[005] It is very unlikely that SHOW ENGINES does not show MyISAM, check manually\n"); + } + mysqli_free_result($res); + } - if (mysqli_query($link, 'PREPARE mystmt FROM "DESCRIBE test id"')) { - mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); + if (mysqli_query($link, 'PREPARE mystmt FROM "DESCRIBE test id"')) { + mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); - if (!$stmt->prepare('DESCRIBE test id') || - !$stmt->execute()) - printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->prepare('DESCRIBE test id') || + !$stmt->execute()) + printf("[006] [%d] %s\n", $stmt->errno, $stmt->error); - if (!$res = $stmt->get_result()) - printf("[007] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$res = $stmt->get_result()) + printf("[007] [%d] %s\n", $stmt->errno, $stmt->error); - $description = mysqli_fetch_assoc($res); - if ($description['Field'] != 'id') { - printf("[008] Returned data seems wrong, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - var_dump($description); - } - mysqli_free_result($res); - } + $description = mysqli_fetch_assoc($res); + if ($description['Field'] != 'id') { + printf("[008] Returned data seems wrong, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($description); + } + mysqli_free_result($res); + } - if (mysqli_query($link, 'PREPARE mystmt FROM "EXPLAIN SELECT id FROM test"')) { - mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); + if (mysqli_query($link, 'PREPARE mystmt FROM "EXPLAIN SELECT id FROM test"')) { + mysqli_query($link, 'DEALLOCATE PREPARE mystmt'); - if (!$stmt->prepare('EXPLAIN SELECT id FROM test') || - !$stmt->execute()) - printf("[009] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$stmt->prepare('EXPLAIN SELECT id FROM test') || + !$stmt->execute()) + printf("[009] [%d] %s\n", $stmt->errno, $stmt->error); - if (!$res = $stmt->get_result()) - printf("[010] [%d] %s\n", $stmt->errno, $stmt->error); + if (!$res = $stmt->get_result()) + printf("[010] [%d] %s\n", $stmt->errno, $stmt->error); - $tmp = mysqli_fetch_assoc($res); - if (empty($tmp)) - printf("[011] Empty EXPLAIN result set seems wrong, check manually, [%d] %s\n", - mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); - } - mysqli_close($link); + $tmp = mysqli_fetch_assoc($res); + if (empty($tmp)) + printf("[011] Empty EXPLAIN result set seems wrong, check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + mysqli_free_result($res); + } + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- num_rows) - printf("[005] Expecting 3 rows, got %s/%s rows\n", gettype($res->num_rows), $res->num_rows); - - if (2 !== $res->field_count) - printf("[006] Expecting 2 fields, got %s/%s rows\n", gettype($res->field_count), $res->field_count); - - if (0 !== $res->current_field) - printf("[006] Expecting offset 0, got %s/%s rows\n", gettype($res->current_field), $res->current_field); - - for ($i = 2; $i > 0; $i--) { - if (!$res->data_seek($i)) - printf("[007] Cannot seek to position %d, [%d] %s\n", - $i, mysqli_stmt_errno($stmt), $stmt->error); - $row = $res->fetch_array(MYSQLI_BOTH); - if (($row[0] !== $row['id']) || ($row[0] !== $i + 1)) { - printf("[008] Record looks wrong, dumping data\n"); - var_dump($row); - } else { - unset($row[0]); - unset($row['id']); - } - if ($row[1] !== $row['label']) { - printf("[009] Record looks wrong, dumping data\n"); - var_dump($row); - } else { - unset($row[1]); - unset($row['label']); - } - if (!empty($row)) { - printf("[010] Not empty, dumping unexpected data\n"); - var_dump($row); - } - } - - if (false !== ($tmp = $res->data_seek(-1))) - printf("[011] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); - - if (false !== ($tmp = $res->data_seek($res->num_rows + 1))) - printf("[012] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); - - for ($i = 0; $i < 100; $i++) { - /* intentionally out of range! */ - $pos = mt_rand(-1, 4); - $tmp = mysqli_data_seek($res, $pos); - if (($pos >= 0 && $pos < 3)) { - if (true !== $tmp) - printf("[015] Expecting boolan/true got %s/%s\n", gettype($tmp), $tmp); - $row = $res->fetch_array(MYSQLI_NUM); - if ($row[0] !== $pos + 1) - printf("[016] Expecting id = %d for pos %d got %s/%s\n", - $pos + 1, $pos, gettype($row[0]), $row[0]); - } else { - if (false !== $tmp) - printf("[014] Expecting boolan/false got %s/%s\n", gettype($tmp), $tmp); - } - } - - mysqli_stmt_close($stmt); - - if (true !== ($tmp = mysqli_data_seek($res, 0))) - printf("[015] Expecting boolan/true got %s/%s\n", gettype($tmp), $tmp); - - if (!is_array($row = $res->fetch_array(MYSQLI_NUM))) - printf("[016] Expecting array got %s/%s\n", gettype($tmp), $tmp); - - mysqli_free_result($res); + require('table.inc'); + + if (!$stmt = mysqli_stmt_init($link)) + printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 3")) + printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!mysqli_stmt_execute($stmt)) + printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + + if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) { + printf("[004] Expecting object/mysqli_result got %s/%s, [%d] %s\n", + gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + + if (3 !== $res->num_rows) + printf("[005] Expecting 3 rows, got %s/%s rows\n", gettype($res->num_rows), $res->num_rows); + + if (2 !== $res->field_count) + printf("[006] Expecting 2 fields, got %s/%s rows\n", gettype($res->field_count), $res->field_count); + + if (0 !== $res->current_field) + printf("[006] Expecting offset 0, got %s/%s rows\n", gettype($res->current_field), $res->current_field); + + for ($i = 2; $i > 0; $i--) { + if (!$res->data_seek($i)) + printf("[007] Cannot seek to position %d, [%d] %s\n", + $i, mysqli_stmt_errno($stmt), $stmt->error); + $row = $res->fetch_array(MYSQLI_BOTH); + if (($row[0] !== $row['id']) || ($row[0] !== $i + 1)) { + printf("[008] Record looks wrong, dumping data\n"); + var_dump($row); + } else { + unset($row[0]); + unset($row['id']); + } + if ($row[1] !== $row['label']) { + printf("[009] Record looks wrong, dumping data\n"); + var_dump($row); + } else { + unset($row[1]); + unset($row['label']); + } + if (!empty($row)) { + printf("[010] Not empty, dumping unexpected data\n"); + var_dump($row); + } + } + + if (false !== ($tmp = $res->data_seek(-1))) + printf("[011] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); + + if (false !== ($tmp = $res->data_seek($res->num_rows + 1))) + printf("[012] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); + + for ($i = 0; $i < 100; $i++) { + /* intentionally out of range! */ + $pos = mt_rand(-1, 4); + $tmp = mysqli_data_seek($res, $pos); + if (($pos >= 0 && $pos < 3)) { + if (true !== $tmp) + printf("[015] Expecting boolan/true got %s/%s\n", gettype($tmp), $tmp); + $row = $res->fetch_array(MYSQLI_NUM); + if ($row[0] !== $pos + 1) + printf("[016] Expecting id = %d for pos %d got %s/%s\n", + $pos + 1, $pos, gettype($row[0]), $row[0]); + } else { + if (false !== $tmp) + printf("[014] Expecting boolan/false got %s/%s\n", gettype($tmp), $tmp); + } + } + + mysqli_stmt_close($stmt); + + if (true !== ($tmp = mysqli_data_seek($res, 0))) + printf("[015] Expecting boolan/true got %s/%s\n", gettype($tmp), $tmp); + + if (!is_array($row = $res->fetch_array(MYSQLI_NUM))) + printf("[016] Expecting array got %s/%s\n", gettype($tmp), $tmp); + + mysqli_free_result($res); try { mysqli_data_seek($res, 0); @@ -106,7 +106,7 @@ if (!function_exists('mysqli_stmt_get_result')) echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); try { mysqli_data_seek($res, 0); @@ -120,7 +120,7 @@ if (!function_exists('mysqli_stmt_get_result')) echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- PHP_INT_MAX)) ? "string" : null); - func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); - - /* test is broken too: we bind "integer" but value is a float - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); - */ - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", NULL, 540); - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -1, 1780); - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); - func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); - func_mysqli_stmt_get_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); - func_mysqli_stmt_get_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); - - func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); - func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT", NULL, 620); - func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); - func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); - - // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. - $tmp = strval('-99999999.99'); - func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); - func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); - $tmp = strval('99999999.99'); - func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); - func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); - $tmp = strval('-99999999.99'); - func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); - func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); - $tmp = strval('99999999.99'); - func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); - func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); - - // don't care about date() strict TZ warnings... - func_mysqli_stmt_get_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); - func_mysqli_stmt_get_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); - func_mysqli_stmt_get_result($link, $engine, "s", "DATE", NULL, 880); - - func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); - func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); - func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME", NULL, 940); - - func_mysqli_stmt_get_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); - - func_mysqli_stmt_get_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); - func_mysqli_stmt_get_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); - func_mysqli_stmt_get_result($link, $engine, "s", "TIME", NULL, 1020); - - $tmp = intval(@date('Y')); - func_mysqli_stmt_get_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); - func_mysqli_stmt_get_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); - func_mysqli_stmt_get_result($link, $engine, "s", "YEAR", NULL, 1080); - - $string255 = func_mysqli_stmt_bind_make_string(255); - func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1)", "a", 1110, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(255)", $string255, 1120, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1)", NULL, 1160); - - $string65k = func_mysqli_stmt_bind_make_string(65535); - func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); - - func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", "a", 1280); - func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); - func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); - func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", NULL, 1340); - - func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); - func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); - func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); - func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); - - func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", "a", 1440); - func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); - func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); - func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", NULL, 1500); - - func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT", "a", 1520, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT", NULL, 1560, 'string'); - - // Note: you cannot insert any blob values this way. But you can check the API at least partly this way - // Extra BLOB tests are in mysqli_stmt_send_long() - func_mysqli_stmt_get_result($link, $engine, "b", "BLOB", "", 1580); - func_mysqli_stmt_get_result($link, $engine, "b", "TEXT", "", 1600, 'string'); - func_mysqli_stmt_get_result($link, $engine, "b", "MEDIUMBLOB", "", 1620); - func_mysqli_stmt_get_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, 'string'); - - /* Is this one related? http://bugs.php.net/bug.php?id=35759 */ - func_mysqli_stmt_get_result($link, $engine, "b", "LONGBLOB", "", 1660); - func_mysqli_stmt_get_result($link, $engine, "b", "LONGTEXT", "", 1680, 'string'); - - func_mysqli_stmt_get_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, 'string'); - func_mysqli_stmt_get_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, 'string'); - - mysqli_close($link); - print "done!"; + require('connect.inc'); + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + function func_mysqli_stmt_get_result($link, $engine, $bind_type, $sql_type, $bind_value, $offset, $type_hint = null) { + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, sprintf("CREATE TABLE test(id INT, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + // don't bail - column type might not be supported by the server, ignore this + return false; + } + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)")) { + printf("[%04d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + $id = null; + if (!mysqli_stmt_bind_param($stmt, "i" . $bind_type, $id, $bind_value)) { + printf("[%04d] [%d] %s\n", $offset + 3, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + for ($id = 1; $id < 4; $id++) { + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 3 + $id, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + } + mysqli_stmt_close($stmt); + + $stmt = mysqli_stmt_init($link); + + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 7, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 8, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + + $result = mysqli_stmt_result_metadata($stmt); + + if (!$res = mysqli_stmt_get_result($stmt)) { + printf("[%04d] [%d] %s\n", $offset + 9, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + mysqli_stmt_close($stmt); + return false; + } + $num = 0; + $fields = mysqli_fetch_fields($result); + + while ($row = mysqli_fetch_assoc($res)) { + $bind_res = &$row['label']; + if (!gettype($bind_res) == 'unicode') { + if ($bind_res !== $bind_value && (!$type_hint || ($type_hint !== gettype($bind_res)))) { + printf("[%04d] [%d] Expecting %s/'%s' [type hint = %s], got %s/'%s'\n", + $offset + 10, $num, + gettype($bind_value), $bind_value, $type_hint, + gettype($bind_res), $bind_res); + mysqli_free_result($res); + mysqli_stmt_close($stmt); + return false; + } + } + $num++; + } + + if ($num != 3) { + printf("[%04d] [%d] %s, expecting 3 results, got only %d results\n", + $offset + 11, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt), $num); + mysqli_free_result($res); + mysqli_stmt_close($stmt); + return false; + } + + mysqli_free_result($res); + mysqli_stmt_close($stmt); + return true; + } + + + function func_mysqli_stmt_bind_make_string($len) { + + $ret = ''; + for ($i = 0; $i < $len; $i++) + $ret .= chr(mt_rand(65, 90)); + + return $ret; + } + + func_mysqli_stmt_get_result($link, $engine, "i", "TINYINT", -11, 20); + func_mysqli_stmt_get_result($link, $engine, "i", "TINYINT", NULL, 40); + func_mysqli_stmt_get_result($link, $engine, "i", "TINYINT UNSIGNED", 1, 60); + func_mysqli_stmt_get_result($link, $engine, "i", "TINYINT UNSIGNED", NULL, 80); + + func_mysqli_stmt_get_result($link, $engine, "i", "BOOL", 1, 100); + func_mysqli_stmt_get_result($link, $engine, "i", "BOOL", NULL, 120); + func_mysqli_stmt_get_result($link, $engine, "i", "BOOLEAN", 0, 140); + func_mysqli_stmt_get_result($link, $engine, "i", "BOOLEAN", NULL, 160); + + func_mysqli_stmt_get_result($link, $engine, "i", "SMALLINT", -32768, 180); + func_mysqli_stmt_get_result($link, $engine, "i", "SMALLINT", 32767, 200); + func_mysqli_stmt_get_result($link, $engine, "i", "SMALLINT", NULL, 220); + func_mysqli_stmt_get_result($link, $engine, "i", "SMALLINT UNSIGNED", 65535, 240); + func_mysqli_stmt_get_result($link, $engine, "i", "SMALLINT UNSIGNED", NULL, 260); + + func_mysqli_stmt_get_result($link, $engine, "d", "MEDIUMINT", -8388608, 280, "integer"); + func_mysqli_stmt_get_result($link, $engine, "d", "MEDIUMINT", 8388607, 300, "integer"); + func_mysqli_stmt_get_result($link, $engine, "d", "MEDIUMINT", NULL, 320); + func_mysqli_stmt_get_result($link, $engine, "d", "MEDIUMINT UNSIGNED", 16777215, 340, "integer"); + func_mysqli_stmt_get_result($link, $engine, "d", "MEDIUMINT UNSIGNED", NULL, 360); + + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? max(-1 * PHP_INT_MAX + 1, -2147483648) : 1, 380); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER", -2147483647, 400, "integer"); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER", (defined("PHP_INT_MAX")) ? min(2147483647, PHP_INT_MAX) : 1, 420); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER", NULL, 440); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER UNSIGNED", (defined("PHP_INT_MAX")) ? min(4294967295, 2147483647) : 1, 460); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER UNSIGNED", 4294967295, 480, (defined("PHP_INT_MAX") && (4294967295 > PHP_INT_MAX)) ? "string" : null); + func_mysqli_stmt_get_result($link, $engine, "i", "INTEGER UNSIGNED", NULL, 500); + + /* test is broken too: we bind "integer" but value is a float + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -9223372036854775808, 520); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", 18446744073709551615, 560); + */ + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", NULL, 540); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", NULL, 580); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -1, 1780); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", 1, 1800); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT", -1 * PHP_INT_MAX + 1, 1820); + func_mysqli_stmt_get_result($link, $engine, "i", "BIGINT UNSIGNED", PHP_INT_MAX, 1840); + func_mysqli_stmt_get_result($link, $engine, "s", "BIGINT UNSIGNED", "18446744073709551615", 1860); + func_mysqli_stmt_get_result($link, $engine, "s", "BIGINT", "-9223372036854775808", 1880); + + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT", -9223372036854775808 - 1.1, 600); + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT", NULL, 620); + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT UNSIGNED", 18446744073709551615 + 1.1, 640); + func_mysqli_stmt_get_result($link, $engine, "d", "FLOAT UNSIGNED ", NULL, 660); + + // Yes, we need the temporary variable. The PHP casting will fouls us otherwise. + $tmp = strval('-99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2)", $tmp, 680, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2)", NULL, 700); + $tmp = strval('99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", $tmp , 720, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DOUBLE(10,2) UNSIGNED", NULL, 740); + $tmp = strval('-99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 760, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 780); + $tmp = strval('99999999.99'); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", $tmp, 800, "string"); + func_mysqli_stmt_get_result($link, $engine, "d", "DECIMAL(10,2)", NULL, 820); + + // don't care about date() strict TZ warnings... + func_mysqli_stmt_get_result($link, $engine, "s", "DATE", @date('Y-m-d'), 840); + func_mysqli_stmt_get_result($link, $engine, "s", "DATE NOT NULL", @date('Y-m-d'), 860); + func_mysqli_stmt_get_result($link, $engine, "s", "DATE", NULL, 880); + + func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME", @date('Y-m-d H:i:s'), 900); + func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME NOT NULL", @date('Y-m-d H:i:s'), 920); + func_mysqli_stmt_get_result($link, $engine, "s", "DATETIME", NULL, 940); + + func_mysqli_stmt_get_result($link, $engine, "s", "TIMESTAMP", @date('Y-m-d H:i:s'), 960); + + func_mysqli_stmt_get_result($link, $engine, "s", "TIME", @date('H:i:s'), 980); + func_mysqli_stmt_get_result($link, $engine, "s", "TIME NOT NULL", @date('H:i:s'), 1000); + func_mysqli_stmt_get_result($link, $engine, "s", "TIME", NULL, 1020); + + $tmp = intval(@date('Y')); + func_mysqli_stmt_get_result($link, $engine, "s", "YEAR", $tmp, 1040, "integer"); + func_mysqli_stmt_get_result($link, $engine, "s", "YEAR NOT NULL", $tmp, 1060, "integer"); + func_mysqli_stmt_get_result($link, $engine, "s", "YEAR", NULL, 1080); + + $string255 = func_mysqli_stmt_bind_make_string(255); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1)", "a", 1110, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(255)", $string255, 1120, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1) NOT NULL", "a", 1140, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "CHAR(1)", NULL, 1160); + + $string65k = func_mysqli_stmt_bind_make_string(65535); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1)", "a", 1180, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(255)", $string255, 1200, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(65635)", $string65k, 1220, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1) NOT NULL", "a", 1240, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "VARCHAR(1)", NULL, 1260); + + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", "a", 1280); + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", chr(0), 1300); + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1) NOT NULL", "b", 1320); + func_mysqli_stmt_get_result($link, $engine, "s", "BINARY(1)", NULL, 1340); + + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", "a", 1360); + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", chr(0), 1380); + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1) NOT NULL", "b", 1400); + func_mysqli_stmt_get_result($link, $engine, "s", "VARBINARY(1)", NULL, 1420); + + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", "a", 1440); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", chr(0), 1460); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB NOT NULL", "b", 1480); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYBLOB", NULL, 1500); + + func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT", "a", 1520, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT NOT NULL", "a", 1540, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "TINYTEXT", NULL, 1560, 'string'); + + // Note: you cannot insert any blob values this way. But you can check the API at least partly this way + // Extra BLOB tests are in mysqli_stmt_send_long() + func_mysqli_stmt_get_result($link, $engine, "b", "BLOB", "", 1580); + func_mysqli_stmt_get_result($link, $engine, "b", "TEXT", "", 1600, 'string'); + func_mysqli_stmt_get_result($link, $engine, "b", "MEDIUMBLOB", "", 1620); + func_mysqli_stmt_get_result($link, $engine, "b", "MEDIUMTEXT", "", 1640, 'string'); + + /* Is this one related? http://bugs.php.net/bug.php?id=35759 */ + func_mysqli_stmt_get_result($link, $engine, "b", "LONGBLOB", "", 1660); + func_mysqli_stmt_get_result($link, $engine, "b", "LONGTEXT", "", 1680, 'string'); + + func_mysqli_stmt_get_result($link, $engine, "s", "ENUM('a', 'b')", "a", 1700, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "ENUM('a', 'b')", NULL, 1720, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "SET('a', 'b')", "a", 1740, 'string'); + func_mysqli_stmt_get_result($link, $engine, "s", "SET('a', 'b')", NULL, 1760, 'string'); + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SET sql_mode=''") || !mysqli_stmt_execute($stmt)) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SET sql_mode=''") || !mysqli_stmt_execute($stmt)) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || !mysqli_stmt_execute($stmt)) - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "DROP TABLE IF EXISTS test") || !mysqli_stmt_execute($stmt)) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) - printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) + printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, "CREATE TABLE test(id SMALLINT, label CHAR(1))") || !mysqli_stmt_execute($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "CREATE TABLE test(id SMALLINT, label CHAR(1))") || !mysqli_stmt_execute($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) - printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + if (false !== ($tmp = mysqli_stmt_get_warnings($stmt))) + printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100000, 'a'), (100001, 'b')") || - !mysqli_stmt_execute($stmt)) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100000, 'a'), (100001, 'b')") || + !mysqli_stmt_execute($stmt)) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!is_object($warning = mysqli_stmt_get_warnings($stmt))) - printf("[011] Expecting mysqli_warning object, got %s/%s\n", gettype($warning), $warning); + if (!is_object($warning = mysqli_stmt_get_warnings($stmt))) + printf("[011] Expecting mysqli_warning object, got %s/%s\n", gettype($warning), $warning); - if ('mysqli_warning' !== get_class($warning)) - printf("[012] Expecting object of type mysqli_warning got type '%s'", get_class($warning)); + if ('mysqli_warning' !== get_class($warning)) + printf("[012] Expecting object of type mysqli_warning got type '%s'", get_class($warning)); - if (!method_exists($warning, 'next')) - printf("[013] Object mysqli_warning seems to lack method next()\n"); + if (!method_exists($warning, 'next')) + printf("[013] Object mysqli_warning seems to lack method next()\n"); - $i = 0; - do { + $i = 0; + do { - if ('' == $warning->message) - printf("[014 - %d] Message should not be empty\n", $i); + if ('' == $warning->message) + printf("[014 - %d] Message should not be empty\n", $i); - if ('' == $warning->sqlstate) - printf("[015 - %d] SQL State should not be empty\n", $i); + if ('' == $warning->sqlstate) + printf("[015 - %d] SQL State should not be empty\n", $i); - if (0 == $warning->errno) - printf("[016 - %d] Error number should not be zero\n", $i); + if (0 == $warning->errno) + printf("[016 - %d] Error number should not be zero\n", $i); - $i++; + $i++; - } while ($warning->next()); + } while ($warning->next()); - if (2 != $i) - printf("[017] Expected 2 warnings, got %d warnings\n", $i); + if (2 != $i) + printf("[017] Expected 2 warnings, got %d warnings\n", $i); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_get_warnings($stmt); @@ -92,8 +92,8 @@ mysqli_query($link, "DROP TABLE IF EXISTS test"); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); try { mysqli_stmt_init($link); @@ -37,7 +37,7 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1") || - !mysqli_stmt_execute($stmt)) { - printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1") || + !mysqli_stmt_execute($stmt)) { + printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } - if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) - printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) + printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + mysqli_stmt_close($stmt); - // no auto_increment column - $stmt = mysqli_stmt_init($link); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'a')") || - !mysqli_stmt_execute($stmt)) { - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } + // no auto_increment column + $stmt = mysqli_stmt_init($link); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'a')") || + !mysqli_stmt_execute($stmt)) { + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } - if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) - printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + if (0 !== ($tmp = mysqli_stmt_insert_id($stmt))) + printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); - if (mysqli_get_server_version($link) > 50000 && - (!mysqli_stmt_prepare($stmt, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT") || - !mysqli_stmt_execute($stmt))) { - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } else if (mysqli_get_server_version($link) < 50000){ - mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT"); - } + if (mysqli_get_server_version($link) > 50000 && + (!mysqli_stmt_prepare($stmt, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT") || + !mysqli_stmt_execute($stmt))) { + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } else if (mysqli_get_server_version($link) < 50000){ + mysqli_query($link, "ALTER TABLE test MODIFY id INT NOT NULL AUTO_INCREMENT"); + } - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES ('a')") || - !mysqli_stmt_execute($stmt)) { - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - if (0 === ($tmp = mysqli_stmt_insert_id($stmt))) - printf("[010] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); - mysqli_stmt_close($stmt); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES ('a')") || + !mysqli_stmt_execute($stmt)) { + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + if (0 === ($tmp = mysqli_stmt_insert_id($stmt))) + printf("[010] Expecting int/any non zero, got %s/%s\n", gettype($tmp), $tmp); + mysqli_stmt_close($stmt); - mysqli_close($link); + mysqli_close($link); - try { + try { mysqli_stmt_insert_id($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query('DROP PROCEDURE IF EXISTS p123')) { - printf("[001] [%d] %s\n", $link->error, $link->errno); - } - - if (!$link->query("CREATE PROCEDURE p123() BEGIN SELECT id+12, CONCAT_WS('-',label,'ahoi') FROM test ORDER BY id LIMIT 1; SELECT id + 42, CONCAT_WS('---',label, label) FROM test ORDER BY id LIMIT 1; END")) { - printf("[002] [%d] %s\n", $link->error, $link->errno); - } - - if (!($stmt = $link->prepare("CALL p123"))) { - printf("[003] [%d] %s\n", $stmt->error, $stmt->errno); - } - - if (!$stmt->execute()) { - printf("[005] [%d] %s\n", $stmt->error, $stmt->errno); - } - - $c_id = NULL; - $c_label = NULL; - if (!$stmt->bind_result($c_id, $c_label)) { - printf("[004] [%d] %s\n", $stmt->error, $stmt->errno); - } - var_dump("pre:",$c_id, $c_label); - - if (!$stmt->fetch()) { - printf("[006] [%d] %s\n", $stmt->error, $stmt->errno); - } - - var_dump("post:",$c_id, $c_label); - - if ($stmt->fetch()) { - printf("[007] Shouldn't have fetched anything\n"); - var_dump($c_id, $c_label); - } - - if ($stmt->fetch()) { - printf("[008] No more rows expected\n"); - } - - if (!$stmt->more_results()) { - printf("[009] Expected more results\n"); - } else { - var_dump("[009] next_result:", $stmt->next_result()); - } - - if (!$stmt->bind_result($c_id, $c_label)) { - printf("[010] [%d] %s\n", $stmt->error, $stmt->errno); - } - var_dump("pre:",$c_id, $c_label); - - if (!$stmt->fetch()) { - printf("[011] [%d] %s\n", $stmt->error, $stmt->errno); - } - - var_dump("post:",$c_id, $c_label); - - if ($stmt->fetch()) { - printf("[012] No more rows expected\n"); - } - - if (!$stmt->more_results()) { - printf("[013] Expected more results\n"); - } else { - var_dump("[013] next_result:", $stmt->next_result()); - } - - if ($stmt->more_results()) { - printf("[014] No more results expected\n"); - } else { - printf("[014] No result, as expected\n"); - } - - $stmt->close(); - $link->close(); - - - echo "done"; + require_once("connect.inc"); + require('table.inc'); + + $stmt = mysqli_stmt_init($link); + if (!$link->query('DROP PROCEDURE IF EXISTS p123')) { + printf("[001] [%d] %s\n", $link->error, $link->errno); + } + + if (!$link->query("CREATE PROCEDURE p123() BEGIN SELECT id+12, CONCAT_WS('-',label,'ahoi') FROM test ORDER BY id LIMIT 1; SELECT id + 42, CONCAT_WS('---',label, label) FROM test ORDER BY id LIMIT 1; END")) { + printf("[002] [%d] %s\n", $link->error, $link->errno); + } + + if (!($stmt = $link->prepare("CALL p123"))) { + printf("[003] [%d] %s\n", $stmt->error, $stmt->errno); + } + + if (!$stmt->execute()) { + printf("[005] [%d] %s\n", $stmt->error, $stmt->errno); + } + + $c_id = NULL; + $c_label = NULL; + if (!$stmt->bind_result($c_id, $c_label)) { + printf("[004] [%d] %s\n", $stmt->error, $stmt->errno); + } + var_dump("pre:",$c_id, $c_label); + + if (!$stmt->fetch()) { + printf("[006] [%d] %s\n", $stmt->error, $stmt->errno); + } + + var_dump("post:",$c_id, $c_label); + + if ($stmt->fetch()) { + printf("[007] Shouldn't have fetched anything\n"); + var_dump($c_id, $c_label); + } + + if ($stmt->fetch()) { + printf("[008] No more rows expected\n"); + } + + if (!$stmt->more_results()) { + printf("[009] Expected more results\n"); + } else { + var_dump("[009] next_result:", $stmt->next_result()); + } + + if (!$stmt->bind_result($c_id, $c_label)) { + printf("[010] [%d] %s\n", $stmt->error, $stmt->errno); + } + var_dump("pre:",$c_id, $c_label); + + if (!$stmt->fetch()) { + printf("[011] [%d] %s\n", $stmt->error, $stmt->errno); + } + + var_dump("post:",$c_id, $c_label); + + if ($stmt->fetch()) { + printf("[012] No more rows expected\n"); + } + + if (!$stmt->more_results()) { + printf("[013] Expected more results\n"); + } else { + var_dump("[013] next_result:", $stmt->next_result()); + } + + if ($stmt->more_results()) { + printf("[014] No more results expected\n"); + } else { + printf("[014] No result, as expected\n"); + } + + $stmt->close(); + $link->close(); + + + echo "done"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - function func_test_mysqli_stmt_param_count($stmt, $query, $expected, $offset) { + function func_test_mysqli_stmt_param_count($stmt, $query, $expected, $offset) { - if (!mysqli_stmt_prepare($stmt, $query)) { - printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); - return false; - } + if (!mysqli_stmt_prepare($stmt, $query)) { + printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); + return false; + } - if ($expected !== ($tmp = mysqli_stmt_param_count($stmt))) - printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, - gettype($expected), $expected, - gettype($tmp), $tmp); - return true; - } + if ($expected !== ($tmp = mysqli_stmt_param_count($stmt))) + printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, + gettype($expected), $expected, + gettype($tmp), $tmp); + return true; + } - func_test_mysqli_stmt_param_count($stmt, "SELECT 1 AS a", 0, 10); - func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id) VALUES (?)", 1, 20); - func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, ?)", 2, 30); - func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, '?')", 1, 40); + func_test_mysqli_stmt_param_count($stmt, "SELECT 1 AS a", 0, 10); + func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id) VALUES (?)", 1, 20); + func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, ?)", 2, 30); + func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, '?')", 1, 40); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_param_count($stmt); @@ -48,9 +48,9 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) - printf("[005] Expecting boolean/true, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))) + printf("[005] Expecting boolean/true, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = mysqli_stmt_reset($stmt))) - printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_reset($stmt))) + printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (true !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - $id = null; - if (!mysqli_stmt_bind_result($stmt, $id)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = null; + if (!mysqli_stmt_bind_result($stmt, $id)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_fetch($stmt)) - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_fetch($stmt)) + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - var_dump($id); - mysqli_stmt_close($stmt); - if (!$stmt = mysqli_stmt_init($link)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($id); + mysqli_stmt_close($stmt); + if (!$stmt = mysqli_stmt_init($link)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, label BLOB, PRIMARY KEY(id))")) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT, label BLOB, PRIMARY KEY(id))")) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES (?)")) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(label) VALUES (?)")) + printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $label = null; - if (!mysqli_stmt_bind_param($stmt, "b", $label)) - printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $label = null; + if (!mysqli_stmt_bind_param($stmt, "b", $label)) + printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $label = 'abc'; - for ($i = 0; $i < 10; $i++) { - if (!mysqli_stmt_send_long_data($stmt, 0, $label)) - printf("[015 - %d] [%d] %s\n", $i, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } + $label = 'abc'; + for ($i = 0; $i < 10; $i++) { + if (!mysqli_stmt_send_long_data($stmt, 0, $label)) + printf("[015 - %d] [%d] %s\n", $i, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } - if (!mysqli_stmt_reset($stmt)) - printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_reset($stmt)) + printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_execute($stmt)) - printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_execute($stmt)) + printf("[017] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!$res = mysqli_query($link, "SELECT label FROM test")) - printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$res = mysqli_query($link, "SELECT label FROM test")) + printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!$row = mysqli_fetch_assoc($res)) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$row = mysqli_fetch_assoc($res)) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); + mysqli_free_result($res); - if ($row['label'] != '') - printf("[020] Expecting empty string, got string/%s\n", $row['label']); + if ($row['label'] != '') + printf("[020] Expecting empty string, got string/%s\n", $row['label']); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_reset($stmt); @@ -93,8 +93,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) - printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test")) + printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!is_object(($res = mysqli_stmt_result_metadata($stmt)))) - printf("[006] Expecting object, got %s/%s\n", gettype($tmp), $tmp); + if (!is_object(($res = mysqli_stmt_result_metadata($stmt)))) + printf("[006] Expecting object, got %s/%s\n", gettype($tmp), $tmp); - if (2 !== ($tmp = mysqli_num_fields($res))) - printf("[007] Expecting int/2, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + if (2 !== ($tmp = mysqli_num_fields($res))) + printf("[007] Expecting int/2, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); - if (!is_object($field0_fetch = mysqli_fetch_field($res))) - printf("[008] Expecting object, got %s/%s, [%d] %s\n", - gettype($field0_fetch), $field0_fetch, mysqli_errno($link), mysqli_error($link)); + if (!is_object($field0_fetch = mysqli_fetch_field($res))) + printf("[008] Expecting object, got %s/%s, [%d] %s\n", + gettype($field0_fetch), $field0_fetch, mysqli_errno($link), mysqli_error($link)); - if (!is_object($field0_direct = mysqli_fetch_field_direct($res, 0))) - printf("[009] Expecting object, got %s/%s, [%d] %s\n", - gettype($field0_direct), $field0_direct, mysqli_errno($link), mysqli_error($link)); + if (!is_object($field0_direct = mysqli_fetch_field_direct($res, 0))) + printf("[009] Expecting object, got %s/%s, [%d] %s\n", + gettype($field0_direct), $field0_direct, mysqli_errno($link), mysqli_error($link)); - if ($field0_fetch != $field0_direct) { - printf("[010] mysqli_fetch_field() differs from mysqli_fetch_field_direct()\n"); - var_dump($field0_fetch); - var_dump($field0_direct); - } + if ($field0_fetch != $field0_direct) { + printf("[010] mysqli_fetch_field() differs from mysqli_fetch_field_direct()\n"); + var_dump($field0_fetch); + var_dump($field0_direct); + } - var_dump($field0_fetch); + var_dump($field0_fetch); - if (!is_array($tmp = mysqli_fetch_fields($res))) - printf("[011] Expecting array, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + if (!is_array($tmp = mysqli_fetch_fields($res))) + printf("[011] Expecting array, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); - if (empty($tmp[0]) || empty($tmp[1]) || $tmp[0] != $field0_direct) { - printf("[012] mysqli_fetch_fields() return value is suspicious\n"); - var_dump($tmp); - } + if (empty($tmp[0]) || empty($tmp[1]) || $tmp[0] != $field0_direct) { + printf("[012] mysqli_fetch_fields() return value is suspicious\n"); + var_dump($tmp); + } - if (!mysqli_field_seek($res, 1)) - printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!mysqli_field_seek($res, 1)) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!is_object($field1_direct = mysqli_fetch_field_direct($res, 1))) - printf("[014] Expecting object, got %s/%s, [%d] %s\n", - gettype($field1_direct), $field1_direct, mysqli_errno($link), mysqli_error($link)); + if (!is_object($field1_direct = mysqli_fetch_field_direct($res, 1))) + printf("[014] Expecting object, got %s/%s, [%d] %s\n", + gettype($field1_direct), $field1_direct, mysqli_errno($link), mysqli_error($link)); - if ($tmp[1] != $field1_direct) { - printf("[015] mysqli_fetch_field_direct() differs from mysqli_fetch_fields()\n"); - var_dump($field1_direct); - var_dump($tmp); - } + if ($tmp[1] != $field1_direct) { + printf("[015] mysqli_fetch_field_direct() differs from mysqli_fetch_fields()\n"); + var_dump($field1_direct); + var_dump($tmp); + } - if (1 !== ($tmp = mysqli_field_tell($res))) - printf("[016] Expecting int/1, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + if (1 !== ($tmp = mysqli_field_tell($res))) + printf("[016] Expecting int/1, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); - mysqli_free_result($res); - mysqli_stmt_close($stmt); + mysqli_free_result($res); + mysqli_stmt_close($stmt); - try { + try { mysqli_stmt_result_metadata($stmt); } catch (Error $exception) { echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- mysqli_num_fields($res), - 'fetch_field' => mysqli_fetch_field($res), - 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), - 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), - 'fetch_fields' => count(mysqli_fetch_fields($res)), - 'field_count' => $res->field_count, - 'field_seek-1' => @mysqli_field_seek($res, -1), - 'field_seek0' => mysqli_field_seek($res, 0), - 'field_tell' => mysqli_field_tell($res), - ); - if (is_object($meta['fetch_field'])) { - $meta['fetch_field']->charsetnr = 'ignore'; - $meta['fetch_field']->flags = 'ignore'; - } - if (is_object($meta['fetch_field_direct0'])) { - $meta['fetch_field_direct0']->charsetnr = 'ignore'; - $meta['fetch_field_direct0']->flags = 'ignore'; - } - if (is_object($meta['fetch_field_direct1'])) { - $meta['fetch_field_direct1']->charsetnr = 'ignore'; - $meta['fetch_field_direct1']->flags = 'ignore'; - } - mysqli_free_result($res); - - if ($meta != $expected_lib) { - printf("[%04d - %s] Metadata differs from expected values\n", - $offset + 5, $sql); - var_dump($meta); - var_dump($expected_lib); - return false; - } - } - - if (function_exists('mysqli_stmt_get_result')) { - /* mysqlnd only */ - if (!mysqli_stmt_execute($stmt)) { - printf("[%04d - %s] [%d] %s\n", - $offset + 6, $sql, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - $res = mysqli_stmt_get_result($stmt); - if (false === $res && !empty($expected_mysqlnd)) { - printf("[%04d - %s] Expecting resultset [%d] %s\n", - $offset + 7, $sql, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } else if (empty($expected_mysqlnd) && false !== $res) { - printf("[%04d - %s] Unexpected resultset [%d] %s\n", - $offset + 8, $sql, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - - if (!is_object($res)) { - printf("[%04d - %s] [%d] %s\n", - $offset + 9, $sql, - mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - return false; - } - if ('mysqli_result' != get_class($res)) { - printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", - $offset + 10, $sql, - get_class($res)); - return false; - } - - $meta_res = array( - 'num_fields' => mysqli_num_fields($res), - 'fetch_field' => mysqli_fetch_field($res), - 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), - 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), - 'fetch_fields' => count(mysqli_fetch_fields($res)), - 'field_count' => mysqli_field_count($link), - 'field_seek-1' => @mysqli_field_seek($res, -1), - 'field_seek0' => mysqli_field_seek($res, 0), - 'field_tell' => mysqli_field_tell($res), - ); - if (is_object($meta_res['fetch_field'])) { - $meta_res['fetch_field']->charsetnr = 'ignore'; - $meta_res['fetch_field']->flags = 'ignore'; - } - if (is_object($meta_res['fetch_field_direct0'])) { - $meta_res['fetch_field_direct0']->charsetnr = 'ignore'; - $meta_res['fetch_field_direct0']->flags = 'ignore'; - } - if (is_object($meta_res['fetch_field_direct1'])) { - $meta_res['fetch_field_direct1']->charsetnr = 'ignore'; - $meta_res['fetch_field_direct1']->flags = 'ignore'; - } - mysqli_free_result($res); - if ($check_mysqlnd && $meta_res != $expected_mysqlnd) { - printf("[%04d - %s] Metadata differs from expected\n", - $offset + 11, $sql); - var_dump($meta_res); - var_dump($expected_mysqlnd); - } else { - if ($meta_res['field_count'] < 1) { - printf("[%04d - %s] Metadata seems wrong, no fields?\n", - $offset + 12, $sql); - var_dump($meta_res); - var_dump(mysqli_fetch_assoc($res)); - } - } - - if ($compare && $meta_res != $meta) { - printf("[%04d - %s] Metadata returned by mysqli_stmt_result_metadata() and mysqli_stmt_get_result() differ\n", - $offset + 13, $sql); - var_dump($meta_res); - var_dump($meta); - } - - } - - mysqli_stmt_close($stmt); - return true; - } - - /* Note: very weak testing, we accept almost any result */ - - testStatement(100, $link, 'ANALYZE TABLE test', array(), array(1), false, false); - testStatement(120, $link, 'OPTIMIZE TABLE test', array(), array(1), false, false); - testStatement(140, $link, 'REPAIR TABLE test', array(), array(1), false, false); - - testStatement(160, $link, 'SHOW AUTHORS', array(), array(1), false, false); - testStatement(180, $link, 'SHOW CHARACTER SET', array(), array(1), false, false); - testStatement(200, $link, 'SHOW COLLATION', array(), array(1), false, false); - testStatement(220, $link, 'SHOW CONTRIBUTORS', array(), array(1), false, false); - testStatement(240, $link, 'SHOW CREATE DATABASE ' . $db, array(), array(1), false, false); - testStatement(260, $link, 'SHOW DATABASES', array(), array(1), false, false); - testStatement(280, $link, 'SHOW ENGINE InnoDB STATUS', array(), array(1), false, false); - testStatement(300, $link, 'SHOW ENGINES', array(), array(1), false, false); - testStatement(320, $link, 'SHOW PLUGINS', array(), array(1), false, false); - testStatement(340, $link, 'SHOW PROCESSLIST', array(), array(1), false, false); - testStatement(360, $link, 'SHOW FULL PROCESSLIST', array(), array(1), false, false); - testStatement(380, $link, 'SHOW STATUS', array(), array(1), false, false); - testStatement(400, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); - testStatement(420, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); - testStatement(440, $link, 'SHOW TABLES', array(), array(1), false, false); - testStatement(460, $link, 'SHOW OPEN TABLES', array(), array(1), false, false); - testStatement(460, $link, 'SHOW VARIABLES', array(), array(1), false, false); - - $field0 = new stdClass(); - $field0->name = 'id'; - $field0->orgname = 'id'; - $field0->table = 'test'; - $field0->orgtable = 'test'; - $field0->def = ''; - $field0->max_length = 0; - $field0->length = 11; - $field0->charsetnr = 'ignore'; - $field0->flags = 'ignore'; - $field0->type = MYSQLI_TYPE_LONG; - $field0->decimals = 0; - $meta_lib = array( - 'num_fields' => 1, - 'fetch_field' => $field0, - 'fetch_field_direct0' => $field0, - 'fetch_field_direct1' => false, - 'fetch_fields' => 1, - 'field_count' => 1, - 'field_seek-1' => false, - 'field_seek0' => true, - 'field_tell' => 0, - ); - $meta_mysqlnd = $meta_lib; - testStatement(480, $link, 'SELECT id FROM test', $meta_lib, $meta_mysqlnd, true, true); - - testStatement(500, $link, 'CHECKSUM TABLE test', array(), array(1), false, false); - - mysqli_close($link); - print "done!"; + require('table.inc'); + + function testStatement($offset, $link, $sql, $expected_lib, $expected_mysqlnd, $check_mysqlnd, $compare) { + + if (!$stmt = mysqli_stmt_init($link)) { + printf("[%04d - %s] [%d] %s\n", + $offset, $sql, + mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!@mysqli_stmt_prepare($stmt, $sql)) { + /* Not all server versions will support all statements */ + /* Failing to prepare is OK */ + return true; + } + + if (empty($expected_lib) && (false !== $res)) { + printf("[%04d - %s] No metadata expected\n", + $offset + 1, $sql); + return false; + } else if (!empty($expected_lib) && (false == $res)) { + printf("[%04d - %s] Metadata expected\n", + $offset + 2, $sql); + return false; + } + if (!empty($expected_lib)) { + if (!is_object($res)) { + printf("[%04d - %s] [%d] %s\n", + $offset + 3, $sql, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + if (get_class($res) != 'mysqli_result') { + printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", + $offset + 4, $sql, get_class($res)); + return false; + } + + $meta = array( + 'num_fields' => mysqli_num_fields($res), + 'fetch_field' => mysqli_fetch_field($res), + 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), + 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), + 'fetch_fields' => count(mysqli_fetch_fields($res)), + 'field_count' => $res->field_count, + 'field_seek-1' => @mysqli_field_seek($res, -1), + 'field_seek0' => mysqli_field_seek($res, 0), + 'field_tell' => mysqli_field_tell($res), + ); + if (is_object($meta['fetch_field'])) { + $meta['fetch_field']->charsetnr = 'ignore'; + $meta['fetch_field']->flags = 'ignore'; + } + if (is_object($meta['fetch_field_direct0'])) { + $meta['fetch_field_direct0']->charsetnr = 'ignore'; + $meta['fetch_field_direct0']->flags = 'ignore'; + } + if (is_object($meta['fetch_field_direct1'])) { + $meta['fetch_field_direct1']->charsetnr = 'ignore'; + $meta['fetch_field_direct1']->flags = 'ignore'; + } + mysqli_free_result($res); + + if ($meta != $expected_lib) { + printf("[%04d - %s] Metadata differs from expected values\n", + $offset + 5, $sql); + var_dump($meta); + var_dump($expected_lib); + return false; + } + } + + if (function_exists('mysqli_stmt_get_result')) { + /* mysqlnd only */ + if (!mysqli_stmt_execute($stmt)) { + printf("[%04d - %s] [%d] %s\n", + $offset + 6, $sql, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + $res = mysqli_stmt_get_result($stmt); + if (false === $res && !empty($expected_mysqlnd)) { + printf("[%04d - %s] Expecting resultset [%d] %s\n", + $offset + 7, $sql, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } else if (empty($expected_mysqlnd) && false !== $res) { + printf("[%04d - %s] Unexpected resultset [%d] %s\n", + $offset + 8, $sql, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + + if (!is_object($res)) { + printf("[%04d - %s] [%d] %s\n", + $offset + 9, $sql, + mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + return false; + } + if ('mysqli_result' != get_class($res)) { + printf("[%04d - %s] Expecting object/mysqli_result got object/%s\n", + $offset + 10, $sql, + get_class($res)); + return false; + } + + $meta_res = array( + 'num_fields' => mysqli_num_fields($res), + 'fetch_field' => mysqli_fetch_field($res), + 'fetch_field_direct0' => mysqli_fetch_field_direct($res, 0), + 'fetch_field_direct1' => @mysqli_fetch_field_direct($res, 1), + 'fetch_fields' => count(mysqli_fetch_fields($res)), + 'field_count' => mysqli_field_count($link), + 'field_seek-1' => @mysqli_field_seek($res, -1), + 'field_seek0' => mysqli_field_seek($res, 0), + 'field_tell' => mysqli_field_tell($res), + ); + if (is_object($meta_res['fetch_field'])) { + $meta_res['fetch_field']->charsetnr = 'ignore'; + $meta_res['fetch_field']->flags = 'ignore'; + } + if (is_object($meta_res['fetch_field_direct0'])) { + $meta_res['fetch_field_direct0']->charsetnr = 'ignore'; + $meta_res['fetch_field_direct0']->flags = 'ignore'; + } + if (is_object($meta_res['fetch_field_direct1'])) { + $meta_res['fetch_field_direct1']->charsetnr = 'ignore'; + $meta_res['fetch_field_direct1']->flags = 'ignore'; + } + mysqli_free_result($res); + if ($check_mysqlnd && $meta_res != $expected_mysqlnd) { + printf("[%04d - %s] Metadata differs from expected\n", + $offset + 11, $sql); + var_dump($meta_res); + var_dump($expected_mysqlnd); + } else { + if ($meta_res['field_count'] < 1) { + printf("[%04d - %s] Metadata seems wrong, no fields?\n", + $offset + 12, $sql); + var_dump($meta_res); + var_dump(mysqli_fetch_assoc($res)); + } + } + + if ($compare && $meta_res != $meta) { + printf("[%04d - %s] Metadata returned by mysqli_stmt_result_metadata() and mysqli_stmt_get_result() differ\n", + $offset + 13, $sql); + var_dump($meta_res); + var_dump($meta); + } + + } + + mysqli_stmt_close($stmt); + return true; + } + + /* Note: very weak testing, we accept almost any result */ + + testStatement(100, $link, 'ANALYZE TABLE test', array(), array(1), false, false); + testStatement(120, $link, 'OPTIMIZE TABLE test', array(), array(1), false, false); + testStatement(140, $link, 'REPAIR TABLE test', array(), array(1), false, false); + + testStatement(160, $link, 'SHOW AUTHORS', array(), array(1), false, false); + testStatement(180, $link, 'SHOW CHARACTER SET', array(), array(1), false, false); + testStatement(200, $link, 'SHOW COLLATION', array(), array(1), false, false); + testStatement(220, $link, 'SHOW CONTRIBUTORS', array(), array(1), false, false); + testStatement(240, $link, 'SHOW CREATE DATABASE ' . $db, array(), array(1), false, false); + testStatement(260, $link, 'SHOW DATABASES', array(), array(1), false, false); + testStatement(280, $link, 'SHOW ENGINE InnoDB STATUS', array(), array(1), false, false); + testStatement(300, $link, 'SHOW ENGINES', array(), array(1), false, false); + testStatement(320, $link, 'SHOW PLUGINS', array(), array(1), false, false); + testStatement(340, $link, 'SHOW PROCESSLIST', array(), array(1), false, false); + testStatement(360, $link, 'SHOW FULL PROCESSLIST', array(), array(1), false, false); + testStatement(380, $link, 'SHOW STATUS', array(), array(1), false, false); + testStatement(400, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); + testStatement(420, $link, 'SHOW TABLE STATUS', array(), array(1), false, false); + testStatement(440, $link, 'SHOW TABLES', array(), array(1), false, false); + testStatement(460, $link, 'SHOW OPEN TABLES', array(), array(1), false, false); + testStatement(460, $link, 'SHOW VARIABLES', array(), array(1), false, false); + + $field0 = new stdClass(); + $field0->name = 'id'; + $field0->orgname = 'id'; + $field0->table = 'test'; + $field0->orgtable = 'test'; + $field0->def = ''; + $field0->max_length = 0; + $field0->length = 11; + $field0->charsetnr = 'ignore'; + $field0->flags = 'ignore'; + $field0->type = MYSQLI_TYPE_LONG; + $field0->decimals = 0; + $meta_lib = array( + 'num_fields' => 1, + 'fetch_field' => $field0, + 'fetch_field_direct0' => $field0, + 'fetch_field_direct1' => false, + 'fetch_fields' => 1, + 'field_count' => 1, + 'field_seek-1' => false, + 'field_seek0' => true, + 'field_tell' => 0, + ); + $meta_mysqlnd = $meta_lib; + testStatement(480, $link, 'SELECT id FROM test', $meta_lib, $meta_mysqlnd, true, true); + + testStatement(500, $link, 'CHECKSUM TABLE test', array(), array(1), false, false); + + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- --FILE-- $max_allowed_packet); + assert(strlen($blob2) > $max_allowed_packet); - if (true != ($tmp = mysqli_stmt_send_long_data($stmt, 1, $blob2))) - printf("[011] Expecting boolean/false, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (true != ($tmp = mysqli_stmt_send_long_data($stmt, 1, $blob2))) + printf("[011] Expecting boolean/false, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 2; - if (false !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[012] Expecting boolean/false, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - */ - mysqli_stmt_close($stmt); - mysqli_close($link); + $id = 2; + if (false !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[012] Expecting boolean/false, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + */ + mysqli_stmt_close($stmt); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- $max_allowed_packet); + assert(strlen($blob2) > $max_allowed_packet); - if (false !== ($tmp = mysqli_stmt_send_long_data($stmt, 1, $blob2))) - printf("[011] Expecting boolean/false, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (false !== ($tmp = mysqli_stmt_send_long_data($stmt, 1, $blob2))) + printf("[011] Expecting boolean/false, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - $id = 2; - if (false !== ($tmp = mysqli_stmt_execute($stmt))) - printf("[012] Expecting boolean/false, got %s/%s, [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - } - */ - mysqli_stmt_close($stmt); - mysqli_close($link); + $id = 2; + if (false !== ($tmp = mysqli_stmt_execute($stmt))) + printf("[012] Expecting boolean/false, got %s/%s, [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } + */ + mysqli_stmt_close($stmt); + mysqli_close($link); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test")) - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test")) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if ('00000' !== ($tmp = mysqli_stmt_sqlstate($stmt))) - printf("[007] Expecting string/00000, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if ('00000' !== ($tmp = mysqli_stmt_sqlstate($stmt))) + printf("[007] Expecting string/00000, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (mysqli_stmt_prepare($stmt, "SELECT believe_me FROM i_dont_belive_that_this_table_exists")) - printf("[008] Should fail! [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (mysqli_stmt_prepare($stmt, "SELECT believe_me FROM i_dont_belive_that_this_table_exists")) + printf("[008] Should fail! [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if ('' === ($tmp = mysqli_stmt_sqlstate($stmt))) - printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if ('' === ($tmp = mysqli_stmt_sqlstate($stmt))) + printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt); try { mysqli_stmt_sqlstate($stmt); @@ -42,8 +42,8 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - print "done!"; + mysqli_close($link); + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')") || - !mysqli_stmt_execute($stmt)) - printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (100, 'z')") || + !mysqli_stmt_execute($stmt)) + printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (true !== ($tmp = @mysqli_stmt_store_result($stmt))) - printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = @mysqli_stmt_store_result($stmt))) + printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test ORDER BY id') || - !mysqli_stmt_execute($stmt)) - printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test ORDER BY id') || + !mysqli_stmt_execute($stmt)) + printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!$link_buf = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) - printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + if (!$link_buf = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - if (!$stmt_buf = mysqli_stmt_init($link_buf)) - printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + if (!$stmt_buf = mysqli_stmt_init($link_buf)) + printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test ORDER BY id") || - !mysqli_stmt_execute($stmt_buf)) - printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); + if (!mysqli_stmt_prepare($stmt_buf, "SELECT id, label FROM test ORDER BY id") || + !mysqli_stmt_execute($stmt_buf)) + printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); - $id = $label = $id_buf = $label_buf = null; - if (!mysqli_stmt_bind_result($stmt, $id, $label)) - printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + $id = $label = $id_buf = $label_buf = null; + if (!mysqli_stmt_bind_result($stmt, $id, $label)) + printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (!mysqli_stmt_bind_result($stmt_buf, $id_buf, $label_buf)) - printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); + if (!mysqli_stmt_bind_result($stmt_buf, $id_buf, $label_buf)) + printf("[013] [%d] %s\n", mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); - while (mysqli_stmt_fetch($stmt)) { - if (!mysqli_stmt_fetch($stmt_buf)) { - printf("[014] Unbuffered statement indicates more rows than buffered, [%d] %s\n", - mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); - } - if ($id !== $id_buf) - printf("[015] unbuffered '%s'/%s, buffered '%s'/%s\n", - $id, gettype($id), $id_buf, gettype($id_buf)); - if ($label !== $label_buf) - printf("[016] unbuffered '%s'/%s, buffered '%s'/%s\n", - $label, gettype($label), $label_buf, gettype($label_buf)); - } + while (mysqli_stmt_fetch($stmt)) { + if (!mysqli_stmt_fetch($stmt_buf)) { + printf("[014] Unbuffered statement indicates more rows than buffered, [%d] %s\n", + mysqli_stmt_errno($stmt_buf), mysqli_stmt_error($stmt_buf)); + } + if ($id !== $id_buf) + printf("[015] unbuffered '%s'/%s, buffered '%s'/%s\n", + $id, gettype($id), $id_buf, gettype($id_buf)); + if ($label !== $label_buf) + printf("[016] unbuffered '%s'/%s, buffered '%s'/%s\n", + $label, gettype($label), $label_buf, gettype($label_buf)); + } - mysqli_stmt_close($stmt); - mysqli_stmt_close($stmt_buf); + mysqli_stmt_close($stmt); + mysqli_stmt_close($stmt_buf); try { mysqli_stmt_store_result($stmt); @@ -72,9 +72,9 @@ require_once('skipifconnectfailure.inc'); echo $exception->getMessage() . "\n"; } - mysqli_close($link); - mysqli_close($link_buf); - print "done!"; + mysqli_close($link); + mysqli_close($link_buf); + print "done!"; ?> --CLEAN-- --FILE-- --EXPECTF-- Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_stmt in %s:%d diff --git a/ext/mysqli/tests/mysqli_store_result.phpt b/ext/mysqli/tests/mysqli_store_result.phpt index 2d9f504eefd7..6fa2d140f5c9 100644 --- a/ext/mysqli/tests/mysqli_store_result.phpt +++ b/ext/mysqli/tests/mysqli_store_result.phpt @@ -8,38 +8,38 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --CLEAN-- fetch_assoc()); - - if (true !== ($tmp = mysqli_data_seek($res, 0))) - printf("[006] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); - - while ($row = $res->fetch_assoc()) { - printf("id = %d, label = %s\n", $row['id'], $row['label']); - } - - mysqli_free_result($res); - mysqli_close($link); - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } - - - if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) - printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) - printf("[009] Expecting object, got %s/%s. [%d] %s\n", - gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + require_once("connect.inc"); + + $tmp = NULL; + $link = NULL; + + require('table.inc'); + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) + printf("[004] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + + if (true !== ($tmp = mysqli_data_seek($res, 2))) + printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + + var_dump($res->fetch_assoc()); + + if (true !== ($tmp = mysqli_data_seek($res, 0))) + printf("[006] Expecting boolean/true, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + + while ($row = $res->fetch_assoc()) { + printf("id = %d, label = %s\n", $row['id'], $row['label']); + } + + mysqli_free_result($res); + mysqli_close($link); + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } + + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id")) + printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) + printf("[009] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - $no_result = 0; - for ($i = 0; $i < 1000; $i++) { - $idx = mt_rand(-100, 100); - if (true === @mysqli_data_seek($res, $idx)) { - $row = $res->fetch_assoc(); - if (!isset($row['id']) || !isset($row['label'])) { - printf("[010] Brute force seek %d returned %d\n", $idx, var_export($row, true)); - } - } else { - $no_result++; - } - } - printf("No result: %d\n", $no_result); - - /* implicit free, implicit store */ - /* meta and fetch lengths code */ - if (!$res = mysqli_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2")) - printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - printf("Default\n"); - var_dump(mysqli_fetch_lengths($res)); - $fields = $res->fetch_fields(); - while ($row = $res->fetch_assoc()) { - var_dump(mysqli_fetch_lengths($res)); - } - var_dump(mysqli_fetch_lengths($res)); - - if (!$res = mysqli_real_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2")) - printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) - printf("[013] Expecting object, got %s/%s. [%d] %s\n", - gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - - printf("Copy\n"); - var_dump(mysqli_fetch_lengths($res)); - $fields_copy = $res->fetch_fields(); - while ($row = $res->fetch_assoc()) { - var_dump(mysqli_fetch_lengths($res)); - } - var_dump(mysqli_fetch_lengths($res)); - - /* There's no need for in-depth testing here. If you want in-depth switch mysqlnd - globally to copy mode and run all the tests */ - foreach ($fields as $k => $field_info) { - if ($fields_copy[$k] != $field_info) { - printf("[014] Metadata seems to differ, dumping\n"); - var_dump($field_info); - var_dump($fields_copy[$k]); - } - } - - /* fetch all */ - - if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2")) - printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) - printf("[016] Expecting object, got %s/%s. [%d] %s\n", - gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - - foreach (mysqli_fetch_all($res, MYSQLI_ASSOC) as $row) { - printf("id = %d label = %s\n", $row['id'], $row['label']); - } - - if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2")) - printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) - printf("[018] Expecting object, got %s/%s. [%d] %s\n", - gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - - /* provoke out of sync */ - if (!mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2")) - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - var_dump($res->fetch_assoc()); - - if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) - printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) - printf("[021] Expecting object, got %s/%s. [%d] %s\n", - gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - - /* user conn killed, res associated with conn, fetch from res */ - unset($link); - var_dump($res->fetch_assoc()); - - - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } - - if (!$res = mysqli_real_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')")) - printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA); - - if (mysqli_get_server_version($link) > 50000) { - // let's try to play with stored procedures - mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p'); - if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) READS SQL DATA BEGIN SELECT id FROM test WHERE id >= 100 ORDER BY id; SELECT id + 1, label FROM test WHERE id > 0 AND id < 3 ORDER BY id; SELECT VERSION() INTO ver_param; + $no_result = 0; + for ($i = 0; $i < 1000; $i++) { + $idx = mt_rand(-100, 100); + if (true === @mysqli_data_seek($res, $idx)) { + $row = $res->fetch_assoc(); + if (!isset($row['id']) || !isset($row['label'])) { + printf("[010] Brute force seek %d returned %d\n", $idx, var_export($row, true)); + } + } else { + $no_result++; + } + } + printf("No result: %d\n", $no_result); + + /* implicit free, implicit store */ + /* meta and fetch lengths code */ + if (!$res = mysqli_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2")) + printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + printf("Default\n"); + var_dump(mysqli_fetch_lengths($res)); + $fields = $res->fetch_fields(); + while ($row = $res->fetch_assoc()) { + var_dump(mysqli_fetch_lengths($res)); + } + var_dump(mysqli_fetch_lengths($res)); + + if (!$res = mysqli_real_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2")) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) + printf("[013] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + + printf("Copy\n"); + var_dump(mysqli_fetch_lengths($res)); + $fields_copy = $res->fetch_fields(); + while ($row = $res->fetch_assoc()) { + var_dump(mysqli_fetch_lengths($res)); + } + var_dump(mysqli_fetch_lengths($res)); + + /* There's no need for in-depth testing here. If you want in-depth switch mysqlnd + globally to copy mode and run all the tests */ + foreach ($fields as $k => $field_info) { + if ($fields_copy[$k] != $field_info) { + printf("[014] Metadata seems to differ, dumping\n"); + var_dump($field_info); + var_dump($fields_copy[$k]); + } + } + + /* fetch all */ + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2")) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) + printf("[016] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + + foreach (mysqli_fetch_all($res, MYSQLI_ASSOC) as $row) { + printf("id = %d label = %s\n", $row['id'], $row['label']); + } + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2")) + printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) + printf("[018] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + + /* provoke out of sync */ + if (!mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2")) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + var_dump($res->fetch_assoc()); + + if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2")) + printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA))) + printf("[021] Expecting object, got %s/%s. [%d] %s\n", + gettype($res), $res, mysqli_errno($link), mysqli_error($link)); + + /* user conn killed, res associated with conn, fetch from res */ + unset($link); + var_dump($res->fetch_assoc()); + + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } + + if (!$res = mysqli_real_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA); + + if (mysqli_get_server_version($link) > 50000) { + // let's try to play with stored procedures + mysqli_real_query($link, 'DROP PROCEDURE IF EXISTS p'); + if (mysqli_real_query($link, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) READS SQL DATA BEGIN SELECT id FROM test WHERE id >= 100 ORDER BY id; SELECT id + 1, label FROM test WHERE id > 0 AND id < 3 ORDER BY id; SELECT VERSION() INTO ver_param; END;')) { - mysqli_multi_query($link, "CALL p(@version)"); - do { - if ($res = $link->store_result(MYSQLI_STORE_RESULT_COPY_DATA)) { - printf("---\n"); - var_dump($res->fetch_all()); - $res->free(); - } else { - if ($link->errno) { - echo "Store failed: (" . $link->errno . ") " . $link->error; - } - } - } while ($link->more_results() && $link->next_result()); - mysqli_real_query($link, 'SELECT @version AS p_version'); - $res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA); - - $tmp = mysqli_fetch_assoc($res); - if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { - printf("[024] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - var_dump($tmp); - } - - mysqli_free_result($res); - } else { - printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - } - } - - print "done!"; + mysqli_multi_query($link, "CALL p(@version)"); + do { + if ($res = $link->store_result(MYSQLI_STORE_RESULT_COPY_DATA)) { + printf("---\n"); + var_dump($res->fetch_all()); + $res->free(); + } else { + if ($link->errno) { + echo "Store failed: (" . $link->errno . ") " . $link->error; + } + } + } while ($link->more_results() && $link->next_result()); + mysqli_real_query($link, 'SELECT @version AS p_version'); + $res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA); + + $tmp = mysqli_fetch_assoc($res); + if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) { + printf("[024] Expecting array [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } + + mysqli_free_result($res); + } else { + printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + } + + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --EXPECT-- done! diff --git a/ext/mysqli/tests/mysqli_unclonable.phpt b/ext/mysqli/tests/mysqli_unclonable.phpt index a6bb1946c783..d7f42c2f6e54 100644 --- a/ext/mysqli/tests/mysqli_unclonable.phpt +++ b/ext/mysqli/tests/mysqli_unclonable.phpt @@ -8,16 +8,16 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- --EXPECTF-- Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli in %s:%d diff --git a/ext/mysqli/tests/mysqli_use_result.phpt b/ext/mysqli/tests/mysqli_use_result.phpt index 26ad3aabb465..1b679d142d3a 100644 --- a/ext/mysqli/tests/mysqli_use_result.phpt +++ b/ext/mysqli/tests/mysqli_use_result.phpt @@ -8,38 +8,38 @@ require_once('skipifconnectfailure.inc'); ?> --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getMessage() . "\n"; } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- --CLEAN-- getName()); - printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 'no'); - printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' : 'no'); - printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 'yes' : 'no'); - printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 'no'); - printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 'no'); - printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no'); - printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' : 'no'); - printf("Modifiers: '%d'\n", $class->getModifiers()); - printf("Parent Class: '%s'\n", $class->getParentClass()); - printf("Extension: '%s'\n", $class->getExtensionName()); - - if ($method = $class->getConstructor()) - inspectMethod($method); - - if ($methods = $class->getMethods()) { - $tmp = array(); - foreach ($methods as $method) - $tmp[$method->getName()] = $method; - - ksort($tmp, SORT_STRING); - foreach ($tmp as $method) - inspectMethod($method); - } - - if ($properties = $class->getProperties()) { - $tmp = array(); - foreach ($properties as $prop) - $tmp[$prop->getName()] = $prop; - ksort($tmp, SORT_STRING); - foreach ($tmp as $prop) - inspectProperty($prop); - } - - - if ($properties = $class->getDefaultProperties()) { - ksort($properties, SORT_STRING); - foreach ($properties as $name => $v) - printf("Default property '%s'\n", $name); - } - - if ($properties = $class->getStaticProperties()) { - ksort($properties, SORT_STRING); - foreach ($properties as $name => $v) - printf("Static property '%s'\n", $name); - } - - if ($constants = $class->getConstants()) { - ksort($constants, SORT_STRING); - foreach ($constant as $name => $value) - printf("Constant '%s' = '%s'\n", $name, $value); - } - - } - - function inspectProperty(&$prop) { - - printf("\nInspecting property '%s'\n", $prop->getName()); - printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no'); - printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no'); - printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 'no'); - printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no'); - printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no'); - printf("Modifiers: %d\n", $prop->getModifiers()); - // printf("Value\n"); var_export($prop->getValue()); - - } - - function inspectMethod(&$method) { - - printf("\nInspecting method '%s'\n", $method->getName()); - printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no'); - printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 'no'); - printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no'); - printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 'no'); - printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 'no'); - printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no'); - printf("isConstructor: %s\n", ($method->isConstructor()) ? 'yes' : 'no'); - printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' : 'no'); - printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 'no'); - printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 'yes' : 'no'); - printf("returnsReference: %s\n", ($method->returnsReference()) ? 'yes' : 'no'); - printf("Modifiers: %d\n", $method->getModifiers()); - printf("Number of Parameters: %d\n", $method->getNumberOfParameters()); - printf("Number of Required Parameters: %d\n", $method->getNumberOfRequiredParameters()); - - if ($params = $method->getParameters()) { - $tmp = array(); - foreach ($params as $k => $param) - $tmp[$param->getName()] = $param; + function inspectClass($class) { + + /* not used: public ReflectionClass[] getInterfaces() */ + + printf("\nInspecting class '%s'\n", $class->getName()); + printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 'no'); + printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' : 'no'); + printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 'yes' : 'no'); + printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 'no'); + printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 'no'); + printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no'); + printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' : 'no'); + printf("Modifiers: '%d'\n", $class->getModifiers()); + printf("Parent Class: '%s'\n", $class->getParentClass()); + printf("Extension: '%s'\n", $class->getExtensionName()); + + if ($method = $class->getConstructor()) + inspectMethod($method); + + if ($methods = $class->getMethods()) { + $tmp = array(); + foreach ($methods as $method) + $tmp[$method->getName()] = $method; + + ksort($tmp, SORT_STRING); + foreach ($tmp as $method) + inspectMethod($method); + } + + if ($properties = $class->getProperties()) { + $tmp = array(); + foreach ($properties as $prop) + $tmp[$prop->getName()] = $prop; + ksort($tmp, SORT_STRING); + foreach ($tmp as $prop) + inspectProperty($prop); + } + + + if ($properties = $class->getDefaultProperties()) { + ksort($properties, SORT_STRING); + foreach ($properties as $name => $v) + printf("Default property '%s'\n", $name); + } + + if ($properties = $class->getStaticProperties()) { + ksort($properties, SORT_STRING); + foreach ($properties as $name => $v) + printf("Static property '%s'\n", $name); + } + + if ($constants = $class->getConstants()) { + ksort($constants, SORT_STRING); + foreach ($constant as $name => $value) + printf("Constant '%s' = '%s'\n", $name, $value); + } + + } + + function inspectProperty(&$prop) { + + printf("\nInspecting property '%s'\n", $prop->getName()); + printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no'); + printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no'); + printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 'no'); + printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no'); + printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no'); + printf("Modifiers: %d\n", $prop->getModifiers()); + // printf("Value\n"); var_export($prop->getValue()); + + } + + function inspectMethod(&$method) { + + printf("\nInspecting method '%s'\n", $method->getName()); + printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no'); + printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 'no'); + printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no'); + printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 'no'); + printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 'no'); + printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no'); + printf("isConstructor: %s\n", ($method->isConstructor()) ? 'yes' : 'no'); + printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' : 'no'); + printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 'no'); + printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 'yes' : 'no'); + printf("returnsReference: %s\n", ($method->returnsReference()) ? 'yes' : 'no'); + printf("Modifiers: %d\n", $method->getModifiers()); + printf("Number of Parameters: %d\n", $method->getNumberOfParameters()); + printf("Number of Required Parameters: %d\n", $method->getNumberOfRequiredParameters()); + + if ($params = $method->getParameters()) { + $tmp = array(); + foreach ($params as $k => $param) + $tmp[$param->getName()] = $param; // ksort($tmp, SORT_STRING); - foreach ($tmp as $param) - inspectParameter($method, $param); - } + foreach ($tmp as $param) + inspectParameter($method, $param); + } - if ($static = $method->getStaticVariables()) { - sort($static, SORT_STRING); - printf("Static variables: %s\n", implode('/', $static)); - } + if ($static = $method->getStaticVariables()) { + sort($static, SORT_STRING); + printf("Static variables: %s\n", implode('/', $static)); + } - } + } - function inspectParameter(&$method, &$param) { + function inspectParameter(&$method, &$param) { - printf("\nInspecting parameter '%s' of method '%s'\n", - $param->getName(), $method->getName()); - printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no'); - printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 'no'); - printf("isPassedByReference: %s\n", ($param->isPassedByReference()) ? 'yes' : 'no'); - printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 'no'); - printf("isDefaultValueAvailable: %s\n", ($param->isDefaultValueAvailable()) ? 'yes' : 'no'); - // printf("getDefaultValue: %s\n", ($param->getDefaultValue()) ? 'yes' : 'no'); + printf("\nInspecting parameter '%s' of method '%s'\n", + $param->getName(), $method->getName()); + printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no'); + printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 'no'); + printf("isPassedByReference: %s\n", ($param->isPassedByReference()) ? 'yes' : 'no'); + printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 'no'); + printf("isDefaultValueAvailable: %s\n", ($param->isDefaultValueAvailable()) ? 'yes' : 'no'); + // printf("getDefaultValue: %s\n", ($param->getDefaultValue()) ? 'yes' : 'no'); - } + } ?> diff --git a/ext/mysqli/tests/skipif.inc b/ext/mysqli/tests/skipif.inc index 5562aab84ba0..a5a5df14c266 100644 --- a/ext/mysqli/tests/skipif.inc +++ b/ext/mysqli/tests/skipif.inc @@ -1,5 +1,5 @@ diff --git a/ext/mysqli/tests/skipifconnectfailure.inc b/ext/mysqli/tests/skipifconnectfailure.inc index 32a976357c03..ccde567baa89 100644 --- a/ext/mysqli/tests/skipifconnectfailure.inc +++ b/ext/mysqli/tests/skipifconnectfailure.inc @@ -1,10 +1,10 @@ diff --git a/ext/mysqli/tests/skipifemb.inc b/ext/mysqli/tests/skipifemb.inc index ad143a42a469..2b7941d8254c 100644 --- a/ext/mysqli/tests/skipifemb.inc +++ b/ext/mysqli/tests/skipifemb.inc @@ -1,5 +1,5 @@ embedded) - die("skip test doesn't run with embedded server"); + $driver = new mysqli_driver(); + if ($driver->embedded) + die("skip test doesn't run with embedded server"); ?> diff --git a/ext/mysqli/tests/skipifnotemb.inc b/ext/mysqli/tests/skipifnotemb.inc index fa5fb9f0a34a..e88e4238360c 100644 --- a/ext/mysqli/tests/skipifnotemb.inc +++ b/ext/mysqli/tests/skipifnotemb.inc @@ -1,5 +1,5 @@ embedded) - die("skip test for with embedded server only"); + $driver = new mysqli_driver(); + if (!$driver->embedded) + die("skip test for with embedded server only"); ?> diff --git a/ext/mysqli/tests/table.inc b/ext/mysqli/tests/table.inc index e0d7a06c57fe..16b688f74b33 100644 --- a/ext/mysqli/tests/table.inc +++ b/ext/mysqli/tests/table.inc @@ -2,27 +2,27 @@ require_once('connect.inc'); if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - exit(1); + printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + exit(1); } if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) { - printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - exit(1); + printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + exit(1); } if (!mysqli_query($link, 'SET SESSION sql_mode=\'\'')) { - printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - exit(1); + printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + exit(1); } if (!mysqli_query($link, 'CREATE TABLE test(id INT DEFAULT 0, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) { - printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - exit(1); + printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + exit(1); } if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')")) { - printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); + printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link)); } ?> diff --git a/ext/oci8/tests/array_bind_014.phpt b/ext/oci8/tests/array_bind_014.phpt index ca5823bc0f71..abf7907739bc 100644 --- a/ext/oci8/tests/array_bind_014.phpt +++ b/ext/oci8/tests/array_bind_014.phpt @@ -47,8 +47,8 @@ $statement = oci_parse($c, $create_pkg_body); oci_execute($statement); for ($i = 1; $i < 6; $i++) { - $statement = oci_parse($c, "INSERT INTO bind_test VALUES (".$i.")"); - oci_execute($statement); + $statement = oci_parse($c, "INSERT INTO bind_test VALUES (".$i.")"); + oci_execute($statement); } $statement = oci_parse($c, "BEGIN array_bind_014_pkg.iobind(:c1); END;"); diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt index fbd1d65bd22f..f405155980cb 100644 --- a/ext/oci8/tests/bind_char_1.phpt +++ b/ext/oci8/tests/bind_char_1.phpt @@ -20,11 +20,11 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_char_tab", - "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))", - "insert into bind_char_tab values (1, 'abc', NULL)", - "insert into bind_char_tab values (2, NULL, 'abc')", - "insert into bind_char_tab values (3, NULL, 'abc ')" + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))", + "insert into bind_char_tab values (1, 'abc', NULL)", + "insert into bind_char_tab values (2, NULL, 'abc')", + "insert into bind_char_tab values (3, NULL, 'abc ')" ); oci8_test_sql_execute($c, $stmtarray); @@ -39,32 +39,32 @@ echo "Test 1.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "\n\n*** NULL data tests against CHAR ***\n"; @@ -74,32 +74,32 @@ echo "Test 2.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "\n\n*** Non-null Data Tests against VARCHAR2***\n"; @@ -110,32 +110,32 @@ echo "Test 3.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "\n\n*** NULL data tests against VARCHAR2 ***\n"; @@ -146,55 +146,55 @@ echo "Test 4.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); function do_e_q($s) { - echo " Querying:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; - return; - } - while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { - foreach ($row as $item) { - echo " :" . $item . ":\n"; - } - } + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } } // Cleanup $stmtarray = array( - "drop table bind_char_tab" + "drop table bind_char_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_1_11gR1.phpt b/ext/oci8/tests/bind_char_1_11gR1.phpt index ea49c96b7559..d281833a77db 100644 --- a/ext/oci8/tests/bind_char_1_11gR1.phpt +++ b/ext/oci8/tests/bind_char_1_11gR1.phpt @@ -22,11 +22,11 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_char_tab", - "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))", - "insert into bind_char_tab values (1, 'abc', NULL)", - "insert into bind_char_tab values (2, NULL, 'abc')", - "insert into bind_char_tab values (3, NULL, 'abc ')" + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))", + "insert into bind_char_tab values (1, 'abc', NULL)", + "insert into bind_char_tab values (2, NULL, 'abc')", + "insert into bind_char_tab values (3, NULL, 'abc ')" ); oci8_test_sql_execute($c, $stmtarray); @@ -41,32 +41,32 @@ echo "Test 1.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "\n\n*** NULL data tests against CHAR ***\n"; @@ -76,32 +76,32 @@ echo "Test 2.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c1 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 2.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "\n\n*** Non-null Data Tests against VARCHAR2***\n"; @@ -112,32 +112,32 @@ echo "Test 3.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 3.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "\n\n*** NULL data tests against VARCHAR2 ***\n"; @@ -148,55 +148,55 @@ echo "Test 4.1: Type: default. Length: default\n"; $s = oci_parse($c, "select * from bind_char_tab where c2 = :bv"); $r = oci_bind_by_name($s, ":bv", $bv1); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 4.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); function do_e_q($s) { - echo " Querying:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; - return; - } - while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { - foreach ($row as $item) { - echo " :" . $item . ":\n"; - } - } + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } } // Cleanup $stmtarray = array( - "drop table bind_char_tab" + "drop table bind_char_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt index 8200dcf3687f..1e5fb08a94de 100644 --- a/ext/oci8/tests/bind_char_2.phpt +++ b/ext/oci8/tests/bind_char_2.phpt @@ -20,10 +20,10 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "alter session set nls_date_format='YYYY-MM-DD'", - "drop table bind_char_tab", - "create table bind_char_tab (id number, c1 date)", - "insert into bind_char_tab values (1, '2008-04-20')", + "alter session set nls_date_format='YYYY-MM-DD'", + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 date)", + "insert into bind_char_tab values (1, '2008-04-20')", ); oci8_test_sql_execute($c, $stmtarray); @@ -41,49 +41,49 @@ if ($r) echo "Test 1.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); function do_e_q($s) { - echo " Querying:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; - return; - } - while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { - foreach ($row as $item) { - echo " :" . $item . ":\n"; - } - } + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } } // Cleanup $stmtarray = array( - "drop table bind_char_tab" + "drop table bind_char_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_2_11gR1.phpt b/ext/oci8/tests/bind_char_2_11gR1.phpt index 3ee9648221ae..11ed50fb8379 100644 --- a/ext/oci8/tests/bind_char_2_11gR1.phpt +++ b/ext/oci8/tests/bind_char_2_11gR1.phpt @@ -20,10 +20,10 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "alter session set nls_date_format='YYYY-MM-DD'", - "drop table bind_char_tab", - "create table bind_char_tab (id number, c1 date)", - "insert into bind_char_tab values (1, '2008-04-20')", + "alter session set nls_date_format='YYYY-MM-DD'", + "drop table bind_char_tab", + "create table bind_char_tab (id number, c1 date)", + "insert into bind_char_tab values (1, '2008-04-20')", ); oci8_test_sql_execute($c, $stmtarray); @@ -41,49 +41,49 @@ if ($r) echo "Test 1.2: Type: AFC. Length: default\n"; $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.3: Type: AFC: Length: 0\n"; $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.4: Type: AFC: Length: strlen\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.5: Type: AFC. Length: strlen-1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); echo "Test 1.6: Type: AFC. Length: strlen+1\n"; $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e_q($s); + do_e_q($s); function do_e_q($s) { - echo " Querying:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; - return; - } - while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { - foreach ($row as $item) { - echo " :" . $item . ":\n"; - } - } + echo " Querying:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']." Exiting Query\n"; + return; + } + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + foreach ($row as $item) { + echo " :" . $item . ":\n"; + } + } } // Cleanup $stmtarray = array( - "drop table bind_char_tab" + "drop table bind_char_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt index f4d8c1f24218..62f767367e5c 100644 --- a/ext/oci8/tests/bind_char_3.phpt +++ b/ext/oci8/tests/bind_char_3.phpt @@ -20,7 +20,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;", + "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;", ); oci8_test_sql_execute($c, $stmtarray); @@ -33,7 +33,7 @@ $s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; @@ -41,7 +41,7 @@ echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -50,7 +50,7 @@ echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -60,7 +60,7 @@ echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -69,7 +69,7 @@ echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -78,7 +78,7 @@ echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -87,7 +87,7 @@ echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -98,7 +98,7 @@ echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -106,7 +106,7 @@ echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -116,7 +116,7 @@ echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -126,7 +126,7 @@ echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -136,7 +136,7 @@ echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -146,7 +146,7 @@ echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -156,7 +156,7 @@ echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -168,7 +168,7 @@ echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -177,7 +177,7 @@ echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -187,7 +187,7 @@ echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -197,7 +197,7 @@ echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -206,7 +206,7 @@ echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -216,26 +216,26 @@ echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); function do_e($s) { - echo " Executing:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']."\n"; - return; - } + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } } // Cleanup $stmtarray = array( - "drop function bind_char_3_fn" + "drop function bind_char_3_fn" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_3_11gR1.phpt b/ext/oci8/tests/bind_char_3_11gR1.phpt index 1adcae2a7445..c80910119949 100644 --- a/ext/oci8/tests/bind_char_3_11gR1.phpt +++ b/ext/oci8/tests/bind_char_3_11gR1.phpt @@ -20,7 +20,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;", + "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;", ); oci8_test_sql_execute($c, $stmtarray); @@ -33,7 +33,7 @@ $s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; @@ -41,7 +41,7 @@ echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -50,7 +50,7 @@ echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -60,7 +60,7 @@ echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -69,7 +69,7 @@ echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -78,7 +78,7 @@ echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -87,7 +87,7 @@ echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -98,7 +98,7 @@ echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -106,7 +106,7 @@ echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -116,7 +116,7 @@ echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -126,7 +126,7 @@ echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -136,7 +136,7 @@ echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -146,7 +146,7 @@ echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -156,7 +156,7 @@ echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -168,7 +168,7 @@ echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -177,7 +177,7 @@ echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -187,7 +187,7 @@ echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -197,7 +197,7 @@ echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -206,7 +206,7 @@ echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -216,26 +216,26 @@ echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); function do_e($s) { - echo " Executing:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']."\n"; - return; - } + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } } // Cleanup $stmtarray = array( - "drop function bind_char_3_fn" + "drop function bind_char_3_fn" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt index 218f0b03cf3c..627ba45e8657 100644 --- a/ext/oci8/tests/bind_char_4.phpt +++ b/ext/oci8/tests/bind_char_4.phpt @@ -22,7 +22,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 as begin return p1; end;", + "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 as begin return p1; end;", ); oci8_test_sql_execute($c, $stmtarray); @@ -35,7 +35,7 @@ $s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; @@ -43,7 +43,7 @@ echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -52,7 +52,7 @@ echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -62,7 +62,7 @@ echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -71,7 +71,7 @@ echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -80,7 +80,7 @@ echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -89,7 +89,7 @@ echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -100,7 +100,7 @@ echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -108,7 +108,7 @@ echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -118,7 +118,7 @@ echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -128,7 +128,7 @@ echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -138,7 +138,7 @@ echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -148,7 +148,7 @@ echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -158,7 +158,7 @@ echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -170,7 +170,7 @@ echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -179,7 +179,7 @@ echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -189,7 +189,7 @@ echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -199,7 +199,7 @@ echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -208,7 +208,7 @@ echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -218,26 +218,26 @@ echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); function do_e($s) { - echo " Executing:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']."\n"; - return; - } + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } } // Cleanup $stmtarray = array( - "drop function bind_char_3_fn" + "drop function bind_char_3_fn" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_char_4_11gR1.phpt b/ext/oci8/tests/bind_char_4_11gR1.phpt index 51350e533e61..e40887c450c6 100644 --- a/ext/oci8/tests/bind_char_4_11gR1.phpt +++ b/ext/oci8/tests/bind_char_4_11gR1.phpt @@ -22,7 +22,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 as begin return p1; end;", + "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 as begin return p1; end;", ); oci8_test_sql_execute($c, $stmtarray); @@ -35,7 +35,7 @@ $s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;"); $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n"; @@ -43,7 +43,7 @@ echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -52,7 +52,7 @@ echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -62,7 +62,7 @@ echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -71,7 +71,7 @@ echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -80,7 +80,7 @@ echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -89,7 +89,7 @@ echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input) $bv1 = 'abc'; $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -100,7 +100,7 @@ echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -108,7 +108,7 @@ echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -118,7 +118,7 @@ echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -128,7 +128,7 @@ echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -138,7 +138,7 @@ echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -148,7 +148,7 @@ echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -158,7 +158,7 @@ echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. $bv1 = ''; $r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -170,7 +170,7 @@ echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -179,7 +179,7 @@ echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -189,7 +189,7 @@ echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -199,7 +199,7 @@ echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -208,7 +208,7 @@ echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); @@ -218,26 +218,26 @@ echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. $bv1 = null; $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC); if ($r) - do_e($s); + do_e($s); var_dump($bv1, $bv2); function do_e($s) { - echo " Executing:\n"; - - $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - echo " Oci_execute error ORA-".$m['code']."\n"; - return; - } + echo " Executing:\n"; + + $r = @oci_execute($s); + if (!$r) { + $m = oci_error($s); + echo " Oci_execute error ORA-".$m['code']."\n"; + return; + } } // Cleanup $stmtarray = array( - "drop function bind_char_3_fn" + "drop function bind_char_3_fn" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_misccoltypes.phpt b/ext/oci8/tests/bind_misccoltypes.phpt index 698549768517..928256ad6bc9 100644 --- a/ext/oci8/tests/bind_misccoltypes.phpt +++ b/ext/oci8/tests/bind_misccoltypes.phpt @@ -16,9 +16,9 @@ $stmtarray = array( "alter session set nls_date_format = 'DD-MON-YY'", - "drop table bind_misccoltypes_tab", + "drop table bind_misccoltypes_tab", - "create table bind_misccoltypes_tab ( + "create table bind_misccoltypes_tab ( id number, char_t char(1), char_t10 char(10), @@ -260,7 +260,7 @@ check_col($c, 'date_t', 60); // Clean up $stmtarray = array( - "drop table bind_misccoltypes_tab" + "drop table bind_misccoltypes_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_misccoltypes_errs.phpt b/ext/oci8/tests/bind_misccoltypes_errs.phpt index 84bdba3d8dd7..4f5de46e805a 100644 --- a/ext/oci8/tests/bind_misccoltypes_errs.phpt +++ b/ext/oci8/tests/bind_misccoltypes_errs.phpt @@ -10,9 +10,9 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_misccoltypes_errs_tab", + "drop table bind_misccoltypes_errs_tab", - "create table bind_misccoltypes_errs_tab ( + "create table bind_misccoltypes_errs_tab ( id number, char_t char(1), char_t10 char(10), @@ -108,7 +108,7 @@ check_col($c, 'varchar2_t10', 7); // Clean up $stmtarray = array( - "drop table bind_misccoltypes_errs_tab" + "drop table bind_misccoltypes_errs_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_number.phpt b/ext/oci8/tests/bind_number.phpt index 298f487f8558..851f2da6057c 100644 --- a/ext/oci8/tests/bind_number.phpt +++ b/ext/oci8/tests/bind_number.phpt @@ -14,26 +14,26 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_number_tab", - "create table bind_number_tab ( - id number, - number_t6 number(6), - float_t float, - binary_float_t binary_float, - binary_double_t binary_double, - decimal_t decimal, - integer_t integer)" + "drop table bind_number_tab", + "create table bind_number_tab ( + id number, + number_t6 number(6), + float_t float, + binary_float_t binary_float, + binary_double_t binary_double, + decimal_t decimal, + integer_t integer)" ); oci8_test_sql_execute($c, $stmtarray); function check_col($c, $colname, $id) { - $s = oci_parse($c, "select $colname from bind_number_tab where id = :id"); - oci_bind_by_name($s, ":id", $id); - oci_execute($s); - oci_fetch_all($s, $r); - var_dump($r); + $s = oci_parse($c, "select $colname from bind_number_tab where id = :id"); + oci_bind_by_name($s, ":id", $id); + oci_execute($s); + oci_fetch_all($s, $r); + var_dump($r); } // Run Test @@ -123,7 +123,7 @@ check_col($c, 'integer_t', 76); // Clean up $stmtarray = array( - "drop table bind_number_tab" + "drop table bind_number_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_query.phpt b/ext/oci8/tests/bind_query.phpt index f9566627c53e..9c1fa3d8d16b 100644 --- a/ext/oci8/tests/bind_query.phpt +++ b/ext/oci8/tests/bind_query.phpt @@ -10,10 +10,10 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_query_tab", - "create table bind_query_tab (empno number(4), ename varchar2(10), sal number(7,2))", - "insert into bind_query_tab values (7934, 'MILLER', 1300)", - "insert into bind_query_tab values (7902, 'FORD', 3000)" + "drop table bind_query_tab", + "create table bind_query_tab (empno number(4), ename varchar2(10), sal number(7,2))", + "insert into bind_query_tab values (7934, 'MILLER', 1300)", + "insert into bind_query_tab values (7902, 'FORD', 3000)" ); oci8_test_sql_execute($c, $stmtarray); @@ -56,7 +56,7 @@ while (oci_fetch($s)) { // Clean up $stmtarray = array( - "drop table bind_query_tab" + "drop table bind_query_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_rowid.phpt b/ext/oci8/tests/bind_rowid.phpt index 40e5b5e90e46..1652326356dd 100644 --- a/ext/oci8/tests/bind_rowid.phpt +++ b/ext/oci8/tests/bind_rowid.phpt @@ -9,19 +9,19 @@ require(__DIR__."/connect.inc"); function do_query($c) { - $s = oci_parse($c, 'select address from rid_tab order by id'); - $id = 1; - oci_execute($s, OCI_DEFAULT); - while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { - var_dump($row); - } + $s = oci_parse($c, 'select address from rid_tab order by id'); + $id = 1; + oci_execute($s, OCI_DEFAULT); + while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) { + var_dump($row); + } } $stmtarray = array( - "drop table rid_tab", - "create table rid_tab (id number, address varchar2(40))", - "insert into rid_tab (id, address) values (1, 'original text #1')", - "insert into rid_tab (id, address) values (2, 'original text #2')" + "drop table rid_tab", + "create table rid_tab (id number, address varchar2(40))", + "insert into rid_tab (id, address) values (1, 'original text #1')", + "insert into rid_tab (id, address) values (2, 'original text #2')" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_sqltafc.phpt b/ext/oci8/tests/bind_sqltafc.phpt index a858ed5398d8..8b4fea93bf26 100644 --- a/ext/oci8/tests/bind_sqltafc.phpt +++ b/ext/oci8/tests/bind_sqltafc.phpt @@ -10,9 +10,9 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_sqltafc_tab", - "create table bind_sqltafc_tab (id number, char_t char(1), char_t10 char(10), varchar2_t10 varchar2(10), number_t number)", - "insert into bind_sqltafc_tab values (0, 'a', 'abcd', 'efghij', 1.1)" + "drop table bind_sqltafc_tab", + "create table bind_sqltafc_tab (id number, char_t char(1), char_t10 char(10), varchar2_t10 varchar2(10), number_t number)", + "insert into bind_sqltafc_tab values (0, 'a', 'abcd', 'efghij', 1.1)" ); oci8_test_sql_execute($c, $stmtarray); @@ -79,7 +79,7 @@ q($c, 6); // Clean up $stmtarray = array( - "drop table bind_sqltafc_tab" + "drop table bind_sqltafc_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_sqltint.phpt b/ext/oci8/tests/bind_sqltint.phpt index a9d7d954fbfc..a25265f90a82 100644 --- a/ext/oci8/tests/bind_sqltint.phpt +++ b/ext/oci8/tests/bind_sqltint.phpt @@ -10,7 +10,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_sqltint_tab", + "drop table bind_sqltint_tab", "create table bind_sqltint_tab ( id number, @@ -208,7 +208,7 @@ var_dump($p2); // Clean up $stmtarray = array( - "drop table bind_sqltint_tab" + "drop table bind_sqltint_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_sqltnum.phpt b/ext/oci8/tests/bind_sqltnum.phpt index 7a13cd45ce8c..3f8e371ea342 100644 --- a/ext/oci8/tests/bind_sqltnum.phpt +++ b/ext/oci8/tests/bind_sqltnum.phpt @@ -16,7 +16,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_sqltnum_tab", + "drop table bind_sqltnum_tab", "create table bind_sqltnum_tab ( id number, @@ -165,7 +165,7 @@ check_col($c, 'number_t92', 50); // Clean up $stmtarray = array( - "drop table bind_sqltnum_tab" + "drop table bind_sqltnum_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bind_sqltnum_11g.phpt b/ext/oci8/tests/bind_sqltnum_11g.phpt index 76b2a553f496..3686127fbc4b 100644 --- a/ext/oci8/tests/bind_sqltnum_11g.phpt +++ b/ext/oci8/tests/bind_sqltnum_11g.phpt @@ -16,7 +16,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bind_sqltnum_tab", + "drop table bind_sqltnum_tab", "create table bind_sqltnum_tab ( id number, @@ -165,7 +165,7 @@ check_col($c, 'number_t92', 50); // Clean up $stmtarray = array( - "drop table bind_sqltnum_tab" + "drop table bind_sqltnum_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug27303_1.phpt b/ext/oci8/tests/bug27303_1.phpt index 6310185b7f4d..a0e254a7539a 100644 --- a/ext/oci8/tests/bug27303_1.phpt +++ b/ext/oci8/tests/bug27303_1.phpt @@ -37,9 +37,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); diff --git a/ext/oci8/tests/bug27303_1_11gR1.phpt b/ext/oci8/tests/bug27303_1_11gR1.phpt index 1c9296bef8c1..35495a81da96 100644 --- a/ext/oci8/tests/bug27303_1_11gR1.phpt +++ b/ext/oci8/tests/bug27303_1_11gR1.phpt @@ -35,9 +35,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt index 039f0e4acc68..3674b724863a 100644 --- a/ext/oci8/tests/bug27303_2.phpt +++ b/ext/oci8/tests/bug27303_2.phpt @@ -39,9 +39,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); diff --git a/ext/oci8/tests/bug27303_2_11gR1.phpt b/ext/oci8/tests/bug27303_2_11gR1.phpt index 4c9a175edd0d..1abb66538aec 100644 --- a/ext/oci8/tests/bug27303_2_11gR1.phpt +++ b/ext/oci8/tests/bug27303_2_11gR1.phpt @@ -39,9 +39,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); diff --git a/ext/oci8/tests/bug27303_3.phpt b/ext/oci8/tests/bug27303_3.phpt index dfc85e08b7d1..347a1a93d91d 100644 --- a/ext/oci8/tests/bug27303_3.phpt +++ b/ext/oci8/tests/bug27303_3.phpt @@ -14,8 +14,8 @@ $create_st[] = "create sequence myseq"; $create_st[] = "create table mytab (mydata varchar2(20), seqcol number)"; foreach ($create_st as $statement) { - $stmt = oci_parse($c, $statement); - @oci_execute($stmt); + $stmt = oci_parse($c, $statement); + @oci_execute($stmt); } define('MYLIMIT', 200); @@ -31,9 +31,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv, 5, SQLT_INT); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); @@ -43,8 +43,8 @@ $drop_st[] = "drop sequence myseq"; $drop_st[] = "drop table mytab"; foreach ($create_st as $statement) { - $stmt = oci_parse($c, $statement); - oci_execute($stmt); + $stmt = oci_parse($c, $statement); + oci_execute($stmt); } echo "Done\n"; diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt index 5ee709042854..e51f3cdc7525 100644 --- a/ext/oci8/tests/bug27303_4.phpt +++ b/ext/oci8/tests/bug27303_4.phpt @@ -36,9 +36,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv, 0 ); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); diff --git a/ext/oci8/tests/bug27303_4_11gR1.phpt b/ext/oci8/tests/bug27303_4_11gR1.phpt index 290f26d76475..bd5e2571fc01 100644 --- a/ext/oci8/tests/bug27303_4_11gR1.phpt +++ b/ext/oci8/tests/bug27303_4_11gR1.phpt @@ -34,9 +34,9 @@ $r = OCIBindByName($stid, ':MYBV', $mybv, 0 ); if (!$r) { echo "Bind error"; die; } for ($i = 1; $i < MYLIMIT; $i++) { - $r = OCIExecute($stid, OCI_DEFAULT); - if (!$r) { echo "Execute error"; die; } - var_dump($mybv); + $r = OCIExecute($stid, OCI_DEFAULT); + if (!$r) { echo "Execute error"; die; } + var_dump($mybv); } OCICommit($c); diff --git a/ext/oci8/tests/bug32325.phpt b/ext/oci8/tests/bug32325.phpt index 1dbe8cc6ce68..3665f01edc79 100644 --- a/ext/oci8/tests/bug32325.phpt +++ b/ext/oci8/tests/bug32325.phpt @@ -23,8 +23,8 @@ oci8_test_sql_execute($c, $stmtarray); $collection = oci_new_collection($c, "BUG32325_T"); $sql = "begin - select bug32325_t(1,2,3,4) into :list from dual; - end;"; + select bug32325_t(1,2,3,4) into :list from dual; + end;"; $stmt = oci_parse($c, $sql); diff --git a/ext/oci8/tests/bug36010.phpt b/ext/oci8/tests/bug36010.phpt index 83288dd355ef..0947d3f6fbd5 100644 --- a/ext/oci8/tests/bug36010.phpt +++ b/ext/oci8/tests/bug36010.phpt @@ -12,11 +12,11 @@ require __DIR__.'/connect.inc'; function f($conn) { - $sql = "begin :p_clob := 'lob string'; end;"; - $stid = oci_parse($conn, $sql); - $clob = oci_new_descriptor($conn, OCI_D_LOB); - oci_bind_by_name($stid, ":p_clob", $clob, -1, OCI_B_CLOB); - $r = oci_execute($stid, OCI_DEFAULT); + $sql = "begin :p_clob := 'lob string'; end;"; + $stid = oci_parse($conn, $sql); + $clob = oci_new_descriptor($conn, OCI_D_LOB); + oci_bind_by_name($stid, ":p_clob", $clob, -1, OCI_B_CLOB); + $r = oci_execute($stid, OCI_DEFAULT); } f($c); diff --git a/ext/oci8/tests/bug36096.phpt b/ext/oci8/tests/bug36096.phpt index 1cf5e9106ccf..eba558e08c23 100644 --- a/ext/oci8/tests/bug36096.phpt +++ b/ext/oci8/tests/bug36096.phpt @@ -11,10 +11,10 @@ $sql = "SELECT 'ABC' FROM DUAL WHERE 1<>1"; $stmt = oci_parse($c, $sql); if(oci_execute($stmt, OCI_COMMIT_ON_SUCCESS)){ - var_dump(oci_fetch($stmt)); - var_dump(oci_result($stmt, 1)); - var_dump(oci_field_name($stmt, 1)); - var_dump(oci_field_type($stmt, 1)); + var_dump(oci_fetch($stmt)); + var_dump(oci_result($stmt, 1)); + var_dump(oci_field_name($stmt, 1)); + var_dump(oci_field_type($stmt, 1)); } echo "Done\n"; diff --git a/ext/oci8/tests/bug36403.phpt b/ext/oci8/tests/bug36403.phpt index ed7fad889a41..60819aa42360 100644 --- a/ext/oci8/tests/bug36403.phpt +++ b/ext/oci8/tests/bug36403.phpt @@ -12,8 +12,8 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table bug36403_tab", - "create table bug36403_tab (c1 number, col2 number, column3 number, col4 number)" + "drop table bug36403_tab", + "create table bug36403_tab (c1 number, col2 number, column3 number, col4 number)" ); oci8_test_sql_execute($c, $stmtarray); @@ -25,7 +25,7 @@ echo "Test 1\n"; $s = oci_parse($c, "select * from bug36403_tab"); oci_execute($s, OCI_DESCRIBE_ONLY); for ($i = oci_num_fields($s); $i > 0; $i--) { - echo oci_field_name($s, $i) . "\n"; + echo oci_field_name($s, $i) . "\n"; } echo "Test 2\n"; @@ -37,7 +37,7 @@ $row = oci_fetch_array($s); // Clean up $stmtarray = array( - "drop table bug36403_tab" + "drop table bug36403_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug37220.phpt b/ext/oci8/tests/bug37220.phpt index 11ee2b23b602..ce0ac0a50382 100644 --- a/ext/oci8/tests/bug37220.phpt +++ b/ext/oci8/tests/bug37220.phpt @@ -13,8 +13,8 @@ require __DIR__.'/connect.inc'; // Initialization $stmtarray = array( - "create table bug37220_tab( mycolumn xmltype not null)", - "insert into bug37220_tab values(xmltype(''))" + "create table bug37220_tab( mycolumn xmltype not null)", + "insert into bug37220_tab values(xmltype(''))" ); oci8_test_sql_execute($c, $stmtarray); @@ -24,8 +24,8 @@ oci8_test_sql_execute($c, $stmtarray); // bug37220_tab a normal Oracle table) $query = "UPDATE bug37220_tab - SET bug37220_tab.mycolumn = updateXML(bug37220_tab.mycolumn,'/THETAG',xmltype.createXML(:data)) - WHERE existsNode(bug37220_tab.mycolumn,'/THETAG[@myID=\"1234\"]') = 1"; + SET bug37220_tab.mycolumn = updateXML(bug37220_tab.mycolumn,'/THETAG',xmltype.createXML(:data)) + WHERE existsNode(bug37220_tab.mycolumn,'/THETAG[@myID=\"1234\"]') = 1"; $stmt = oci_parse ($c, $query); $clob = oci_new_descriptor($c, OCI_D_LOB); oci_bind_by_name($stmt, ':data', $clob, -1, OCI_B_CLOB); @@ -42,16 +42,16 @@ $stmt = oci_parse ($c, $query); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { - foreach ($row as $item) { - echo trim($item)."\n"; - } - echo "\n"; + foreach ($row as $item) { + echo trim($item)."\n"; + } + echo "\n"; } // Cleanup $stmtarray = array( - "drop table bug37220_tab" + "drop table bug37220_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug38173.phpt b/ext/oci8/tests/bug38173.phpt index 2d4cb7c33bf7..087e6a7485e4 100644 --- a/ext/oci8/tests/bug38173.phpt +++ b/ext/oci8/tests/bug38173.phpt @@ -26,15 +26,15 @@ oci_execute($s1); oci_execute($s2); for($i=0; $i < 5; $i++) { - $insert = "INSERT INTO t1 VALUES(".$i.")"; - $s = oci_parse($c, $insert); - oci_execute($s); + $insert = "INSERT INTO t1 VALUES(".$i.")"; + $s = oci_parse($c, $insert); + oci_execute($s); } for($i=0; $i < 5; $i++) { - $insert = "INSERT INTO t2 VALUES(".$i.")"; - $s = oci_parse($c, $insert); - oci_execute($s); + $insert = "INSERT INTO t2 VALUES(".$i.")"; + $s = oci_parse($c, $insert); + oci_execute($s); } $query =" diff --git a/ext/oci8/tests/bug41069.phpt b/ext/oci8/tests/bug41069.phpt index af322ba7d1de..49d2905a4d6a 100644 --- a/ext/oci8/tests/bug41069.phpt +++ b/ext/oci8/tests/bug41069.phpt @@ -10,46 +10,46 @@ if ($test_drcp) die("skip DRCP does not support shared database links"); --INI-- oci8.default_prefetch=5 --FILE-- - $field) { - echo "\nColumn $name\n"; - var_dump(oci_field_is_null($s, $name)); - var_dump(oci_field_name($s, $name)); - var_dump(oci_field_type($s, $name)); - var_dump(oci_field_type_raw($s, $name)); - var_dump(oci_field_scale($s, $name)); - var_dump(oci_field_precision($s, $name)); - var_dump(oci_field_size($s, $name)); + echo "\nColumn $name\n"; + var_dump(oci_field_is_null($s, $name)); + var_dump(oci_field_name($s, $name)); + var_dump(oci_field_type($s, $name)); + var_dump(oci_field_type_raw($s, $name)); + var_dump(oci_field_scale($s, $name)); + var_dump(oci_field_precision($s, $name)); + var_dump(oci_field_size($s, $name)); } // Cleanup diff --git a/ext/oci8/tests/bug42496_1.phpt b/ext/oci8/tests/bug42496_1.phpt index b3d6cf0203b6..9db7d720e9f1 100644 --- a/ext/oci8/tests/bug42496_1.phpt +++ b/ext/oci8/tests/bug42496_1.phpt @@ -14,11 +14,11 @@ require __DIR__.'/connect.inc'; // Initialization $stmtarray = array( - "DROP table bug42496_1_tab", - "CREATE table bug42496_1_tab(c1 CLOB, c2 CLOB)", - "INSERT INTO bug42496_1_tab VALUES('test1', 'test1')", - "INSERT INTO bug42496_1_tab VALUES('test2', 'test2')", - "INSERT INTO bug42496_1_tab VALUES('test3', 'test3')" + "DROP table bug42496_1_tab", + "CREATE table bug42496_1_tab(c1 CLOB, c2 CLOB)", + "INSERT INTO bug42496_1_tab VALUES('test1', 'test1')", + "INSERT INTO bug42496_1_tab VALUES('test2', 'test2')", + "INSERT INTO bug42496_1_tab VALUES('test3', 'test3')" ); oci8_test_sql_execute($c, $stmtarray); @@ -28,17 +28,17 @@ oci8_test_sql_execute($c, $stmtarray); echo "Test 1\n"; for ($i = 0; $i < 15000; $i++) { - $s = oci_parse($c, "SELECT * from bug42496_1_tab"); - oci_define_by_name($s, "C1", $col1); - oci_define_by_name($s, "C2", $col2); - if (oci_execute($s)) { - $arr = array(); - while ($arr = oci_fetch_assoc($s)) { - $arr['C1']->free(); - $arr['C2']->free(); - } - } - oci_free_statement($s); + $s = oci_parse($c, "SELECT * from bug42496_1_tab"); + oci_define_by_name($s, "C1", $col1); + oci_define_by_name($s, "C2", $col2); + if (oci_execute($s)) { + $arr = array(); + while ($arr = oci_fetch_assoc($s)) { + $arr['C1']->free(); + $arr['C2']->free(); + } + } + oci_free_statement($s); } echo "Done\n"; @@ -46,7 +46,7 @@ echo "Done\n"; // Cleanup $stmtarray = array( - "DROP table bug42496_1_tab" + "DROP table bug42496_1_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug42496_2.phpt b/ext/oci8/tests/bug42496_2.phpt index bcb407660171..52c42f8bcfdd 100644 --- a/ext/oci8/tests/bug42496_2.phpt +++ b/ext/oci8/tests/bug42496_2.phpt @@ -14,11 +14,11 @@ require __DIR__.'/connect.inc'; // Initialization $stmtarray = array( - "DROP table bug42496_2_tab", - "CREATE table bug42496_2_tab(c1 CLOB, c2 CLOB)", - "INSERT INTO bug42496_2_tab VALUES('test1', 'test1')", - "INSERT INTO bug42496_2_tab VALUES('test2', 'test2')", - "INSERT INTO bug42496_2_tab VALUES('test3', 'test3')" + "DROP table bug42496_2_tab", + "CREATE table bug42496_2_tab(c1 CLOB, c2 CLOB)", + "INSERT INTO bug42496_2_tab VALUES('test1', 'test1')", + "INSERT INTO bug42496_2_tab VALUES('test2', 'test2')", + "INSERT INTO bug42496_2_tab VALUES('test3', 'test3')" ); oci8_test_sql_execute($c, $stmtarray); @@ -28,15 +28,15 @@ oci8_test_sql_execute($c, $stmtarray); echo "Test 2\n"; for ($i = 0; $i < 15000; $i++) { - $s = oci_parse($c, "SELECT * from bug42496_2_tab"); - if (oci_execute($s)) { - $arr = array(); - while ($arr = oci_fetch_assoc($s)) { - $arr['C1']->free(); - $arr['C2']->free(); - } - } - oci_free_statement($s); + $s = oci_parse($c, "SELECT * from bug42496_2_tab"); + if (oci_execute($s)) { + $arr = array(); + while ($arr = oci_fetch_assoc($s)) { + $arr['C1']->free(); + $arr['C2']->free(); + } + } + oci_free_statement($s); } echo "Done\n"; @@ -44,7 +44,7 @@ echo "Done\n"; // Cleanup $stmtarray = array( - "DROP table bug42496_2_tab" + "DROP table bug42496_2_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug43497.phpt b/ext/oci8/tests/bug43497.phpt index 29ff9e6a5c62..45325f6b4426 100644 --- a/ext/oci8/tests/bug43497.phpt +++ b/ext/oci8/tests/bug43497.phpt @@ -18,8 +18,8 @@ function sessionid($c) // determines and returns current session ID $stmt = oci_parse($c, $query); if (oci_execute($stmt, OCI_DEFAULT)) { - $row = oci_fetch($stmt); - return oci_result($stmt, 1); + $row = oci_fetch($stmt); + return oci_result($stmt, 1); } return null; @@ -33,10 +33,10 @@ function templobs($c, $sid) // returns number of temporary LOBs $stmt = oci_parse($c, $query); if (oci_execute($stmt, OCI_DEFAULT)) { - $row = oci_fetch($stmt); - $val = oci_result($stmt, 1); - oci_free_statement($stmt); - return $val; + $row = oci_fetch($stmt); + $val = oci_result($stmt, 1); + oci_free_statement($stmt); + return $val; } return null; } @@ -47,14 +47,14 @@ function readxmltab_ex($c) { $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); - $cntchk = 0; - if (oci_execute($stmt)) { - while ($result = oci_fetch_array($stmt, OCI_NUM)) { - $result[0]->free(); // cleanup properly - ++$cntchk; - } - } - echo "Loop count check = $cntchk\n"; + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM)) { + $result[0]->free(); // cleanup properly + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; } // Read all XML data using explicit LOB locator but without freeing the temp lobs @@ -62,13 +62,13 @@ function readxmltab_ex_nofree($c) { $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); - $cntchk = 0; - if (oci_execute($stmt)) { - while ($result = oci_fetch_array($stmt, OCI_NUM)) { - ++$cntchk; - } - } - echo "Loop count check = $cntchk\n"; + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM)) { + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; } // Read all XML data using implicit LOB locator @@ -76,18 +76,18 @@ function readxmltab_im($c) { $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab"); - $cntchk = 0; - if (oci_execute($stmt)) { - while ($result = oci_fetch_array($stmt, OCI_NUM+OCI_RETURN_LOBS)) { - ++$cntchk; - } - } - echo "Loop count check = $cntchk\n"; + $cntchk = 0; + if (oci_execute($stmt)) { + while ($result = oci_fetch_array($stmt, OCI_NUM+OCI_RETURN_LOBS)) { + ++$cntchk; + } + } + echo "Loop count check = $cntchk\n"; } function createxmltab($c) // create table w/ field of XML type { - @dropxmltab($c); + @dropxmltab($c); $stmt = oci_parse($c, "create table bug43497_tab (id number primary key, xml xmltype)"); oci_execute($stmt); } @@ -101,31 +101,31 @@ function dropxmltab($c) // delete table function fillxmltab($c) { - for ($id = 1; $id <= 100; $id++) { - - // create an XML element string with random data - $s = ""; - for ($j = 0; $j < 128; $j++) { - $s .= rand(); - } - $s .= "\n"; - for ($j = 0; $j < 4; $j++) { - $s .= $s; - } - $data = "" . $s . ""; - - // insert XML data into database - - $stmt = oci_parse($c, "insert into bug43497_tab(id, xml) values (:id, sys.xmltype.createxml(:xml))"); - oci_bind_by_name($stmt, ":id", $id); - $clob = oci_new_descriptor($c, OCI_D_LOB); - oci_bind_by_name($stmt, ":xml", $clob, -1, OCI_B_CLOB); - $clob->writetemporary($data); - oci_execute($stmt); - - $clob->close(); - $clob->free(); - } + for ($id = 1; $id <= 100; $id++) { + + // create an XML element string with random data + $s = ""; + for ($j = 0; $j < 128; $j++) { + $s .= rand(); + } + $s .= "\n"; + for ($j = 0; $j < 4; $j++) { + $s .= $s; + } + $data = "" . $s . ""; + + // insert XML data into database + + $stmt = oci_parse($c, "insert into bug43497_tab(id, xml) values (:id, sys.xmltype.createxml(:xml))"); + oci_bind_by_name($stmt, ":id", $id); + $clob = oci_new_descriptor($c, OCI_D_LOB); + oci_bind_by_name($stmt, ":xml", $clob, -1, OCI_B_CLOB); + $clob->writetemporary($data); + oci_execute($stmt); + + $clob->close(); + $clob->free(); + } } diff --git a/ext/oci8/tests/bug44008.phpt b/ext/oci8/tests/bug44008.phpt index 0b031aef902d..faf26f472e24 100644 --- a/ext/oci8/tests/bug44008.phpt +++ b/ext/oci8/tests/bug44008.phpt @@ -13,9 +13,9 @@ require __DIR__.'/connect.inc'; // Initialization $stmtarray = array( - "create or replace procedure bug44008_proc (p in out clob) - as begin p := 'A'; - end;" + "create or replace procedure bug44008_proc (p in out clob) + as begin p := 'A'; + end;" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug44113.phpt b/ext/oci8/tests/bug44113.phpt index ec6668db3d04..ca2a03e9145a 100644 --- a/ext/oci8/tests/bug44113.phpt +++ b/ext/oci8/tests/bug44113.phpt @@ -14,7 +14,7 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "create or replace type bug44113_list_t as table of number" + "create or replace type bug44113_list_t as table of number" ); oci8_test_sql_execute($c, $stmtarray); @@ -24,10 +24,10 @@ oci8_test_sql_execute($c, $stmtarray); // timeout limit on slow networks. for ($x = 0; $x < 70000; $x++) { - if (!($var = oci_new_collection($c, 'BUG44113_LIST_T'))) { - print "Failed new collection creation on $x\n"; - break; - } + if (!($var = oci_new_collection($c, 'BUG44113_LIST_T'))) { + print "Failed new collection creation on $x\n"; + break; + } } print "Completed $x\n"; @@ -35,7 +35,7 @@ print "Completed $x\n"; // Cleanup $stmtarray = array( - "drop type bug44113_list_t" + "drop type bug44113_list_t" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug44206.phpt b/ext/oci8/tests/bug44206.phpt index 069a8404232e..2b051771e25b 100644 --- a/ext/oci8/tests/bug44206.phpt +++ b/ext/oci8/tests/bug44206.phpt @@ -14,24 +14,24 @@ require __DIR__.'/connect.inc'; for ($x = 0; $x < 400; $x++) { - $stmt = "select cursor (select $x from dual) a, - cursor (select $x from dual) b - from dual"; - $s = oci_parse($c, $stmt); - $r = oci_execute($s); + $stmt = "select cursor (select $x from dual) a, + cursor (select $x from dual) b + from dual"; + $s = oci_parse($c, $stmt); + $r = oci_execute($s); if (!$r) { echo "Exiting $x\n"; exit; } - $mode = OCI_ASSOC | OCI_RETURN_NULLS; - $result = oci_fetch_array($s, $mode); - oci_execute($result['A']); - oci_execute($result['B']); - oci_fetch_array($result['A'], $mode); - oci_fetch_array($result['B'], $mode); - oci_free_statement($result['A']); - oci_free_statement($result['B']); - oci_free_statement($s); + $mode = OCI_ASSOC | OCI_RETURN_NULLS; + $result = oci_fetch_array($s, $mode); + oci_execute($result['A']); + oci_execute($result['B']); + oci_fetch_array($result['A'], $mode); + oci_fetch_array($result['B'], $mode); + oci_free_statement($result['A']); + oci_free_statement($result['B']); + oci_free_statement($s); } echo "Completed $x\n"; diff --git a/ext/oci8/tests/bug46994.phpt b/ext/oci8/tests/bug46994.phpt index e7208904f856..ace65b8bd279 100644 --- a/ext/oci8/tests/bug46994.phpt +++ b/ext/oci8/tests/bug46994.phpt @@ -13,15 +13,15 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "create or replace procedure bug46994_proc1(p1 in out nocopy clob) is - begin - dbms_lob.trim(p1, 0); - dbms_lob.writeappend(p1, 26, 'This should be the output.'); + "create or replace procedure bug46994_proc1(p1 in out nocopy clob) is + begin + dbms_lob.trim(p1, 0); + dbms_lob.writeappend(p1, 26, 'This should be the output.'); end bug46994_proc1;", - "create or replace procedure bug46994_proc2(p1 in out nocopy clob) is - begin - dbms_lob.trim(p1, 0); - dbms_lob.writeappend(p1, 37, 'The output should be even longer now.'); + "create or replace procedure bug46994_proc2(p1 in out nocopy clob) is + begin + dbms_lob.trim(p1, 0); + dbms_lob.writeappend(p1, 37, 'The output should be even longer now.'); end bug46994_proc2;" ); @@ -60,8 +60,8 @@ var_dump($myclob->load()); // Use cached size code path // Cleanup $stmtarray = array( - "drop procedure bug46994_proc1", - "drop procedure bug46994_proc2" + "drop procedure bug46994_proc1", + "drop procedure bug46994_proc2" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug68298.phpt b/ext/oci8/tests/bug68298.phpt index fae4a4f2febd..f0fc201bb50b 100644 --- a/ext/oci8/tests/bug68298.phpt +++ b/ext/oci8/tests/bug68298.phpt @@ -11,8 +11,8 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); require(__DIR__.'/connect.inc'); $stmtarray = array( - "DROP TABLE BUG68298", - "CREATE TABLE BUG68298 (COL1 NUMBER(20))" + "DROP TABLE BUG68298", + "CREATE TABLE BUG68298 (COL1 NUMBER(20))" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/bug71422.phpt b/ext/oci8/tests/bug71422.phpt index 48341a4ccb10..798981ed0b86 100644 --- a/ext/oci8/tests/bug71422.phpt +++ b/ext/oci8/tests/bug71422.phpt @@ -10,9 +10,9 @@ if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(__DIR__.'/connect.inc'); $stmtarray = array( - "DROP TABLE BUG71422_TEST", - "CREATE TABLE BUG71422_TEST (TEST_ID NUMBER(*,0) NOT NULL, LABEL VARCHAR2(50 CHAR), CONSTRAINT BUG71422_TEST_PK PRIMARY KEY (TEST_ID))", - "INSERT INTO BUG71422_TEST (TEST_ID, LABEL) VALUES (1, 'Foo')" + "DROP TABLE BUG71422_TEST", + "CREATE TABLE BUG71422_TEST (TEST_ID NUMBER(*,0) NOT NULL, LABEL VARCHAR2(50 CHAR), CONSTRAINT BUG71422_TEST_PK PRIMARY KEY (TEST_ID))", + "INSERT INTO BUG71422_TEST (TEST_ID, LABEL) VALUES (1, 'Foo')" ); oci8_test_sql_execute($c, $stmtarray); @@ -20,7 +20,7 @@ oci8_test_sql_execute($c, $stmtarray); $stmt = oci_parse($c, 'SELECT LABEL AS RAW_QUERY FROM BUG71422_TEST WHERE TEST_ID=1'); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { - var_dump($row); + var_dump($row); } $stmt = oci_parse($c, 'SELECT LABEL AS NUMERIC_BIND_PARAMETER FROM BUG71422_TEST WHERE TEST_ID=:test_id'); @@ -28,7 +28,7 @@ $value = 1; oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_INT); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { - var_dump($row); + var_dump($row); } $stmt = oci_parse($c, 'SELECT LABEL AS STRING_BIND_PARAMETER FROM BUG71422_TEST WHERE TEST_ID=:test_id'); @@ -36,13 +36,13 @@ $value = 1; oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_CHR); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { - var_dump($row); + var_dump($row); } // Cleanup $stmtarray = array( - "DROP TABLE BUG71422_TEST" + "DROP TABLE BUG71422_TEST" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/coll_009.phpt b/ext/oci8/tests/coll_009.phpt index e55a4a210c81..2707fbccf7e4 100644 --- a/ext/oci8/tests/coll_009.phpt +++ b/ext/oci8/tests/coll_009.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_009_func.phpt b/ext/oci8/tests/coll_009_func.phpt index fca04599e205..5b3e08579aa4 100644 --- a/ext/oci8/tests/coll_009_func.phpt +++ b/ext/oci8/tests/coll_009_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_010.phpt b/ext/oci8/tests/coll_010.phpt index 33e1b6fd1879..42bd788a81c1 100644 --- a/ext/oci8/tests/coll_010.phpt +++ b/ext/oci8/tests/coll_010.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_010_func.phpt b/ext/oci8/tests/coll_010_func.phpt index 2f672835387c..9ef6c222503e 100644 --- a/ext/oci8/tests/coll_010_func.phpt +++ b/ext/oci8/tests/coll_010_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_011.phpt b/ext/oci8/tests/coll_011.phpt index 13c4613b006f..562de0889f81 100644 --- a/ext/oci8/tests/coll_011.phpt +++ b/ext/oci8/tests/coll_011.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_011_func.phpt b/ext/oci8/tests/coll_011_func.phpt index bc6bd6ea7385..ca43336ffc8d 100644 --- a/ext/oci8/tests/coll_011_func.phpt +++ b/ext/oci8/tests/coll_011_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_012.phpt b/ext/oci8/tests/coll_012.phpt index 615a3aad7a8b..be0439e8baf6 100644 --- a/ext/oci8/tests/coll_012.phpt +++ b/ext/oci8/tests/coll_012.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_012_func.phpt b/ext/oci8/tests/coll_012_func.phpt index 41a708410930..fa6a026d16a0 100644 --- a/ext/oci8/tests/coll_012_func.phpt +++ b/ext/oci8/tests/coll_012_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_013.phpt b/ext/oci8/tests/coll_013.phpt index ef3af0a8e73a..1e943bf57ebf 100644 --- a/ext/oci8/tests/coll_013.phpt +++ b/ext/oci8/tests/coll_013.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_013_func.phpt b/ext/oci8/tests/coll_013_func.phpt index bb6d7083e3fe..417bfdb18f2f 100644 --- a/ext/oci8/tests/coll_013_func.phpt +++ b/ext/oci8/tests/coll_013_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_014.phpt b/ext/oci8/tests/coll_014.phpt index 0af0ead32927..697d306818c4 100644 --- a/ext/oci8/tests/coll_014.phpt +++ b/ext/oci8/tests/coll_014.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_014_func.phpt b/ext/oci8/tests/coll_014_func.phpt index 24b0bbf8bafc..fc9df35a7cfa 100644 --- a/ext/oci8/tests/coll_014_func.phpt +++ b/ext/oci8/tests/coll_014_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_015.phpt b/ext/oci8/tests/coll_015.phpt index 2ed2375eccdd..d3bffd2fe5bc 100644 --- a/ext/oci8/tests/coll_015.phpt +++ b/ext/oci8/tests/coll_015.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_015_func.phpt b/ext/oci8/tests/coll_015_func.phpt index a9c16aec0171..3685a28b96a1 100644 --- a/ext/oci8/tests/coll_015_func.phpt +++ b/ext/oci8/tests/coll_015_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_016.phpt b/ext/oci8/tests/coll_016.phpt index 80059688b3be..d4b19efb432a 100644 --- a/ext/oci8/tests/coll_016.phpt +++ b/ext/oci8/tests/coll_016.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_016_func.phpt b/ext/oci8/tests/coll_016_func.phpt index da26428d8d87..95ed0588dc55 100644 --- a/ext/oci8/tests/coll_016_func.phpt +++ b/ext/oci8/tests/coll_016_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_017.phpt b/ext/oci8/tests/coll_017.phpt index 81fdfb2553a1..0bd730934f3a 100644 --- a/ext/oci8/tests/coll_017.phpt +++ b/ext/oci8/tests/coll_017.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/coll_017_func.phpt b/ext/oci8/tests/coll_017_func.phpt index c582eb0f8daa..e3d9be2a4314 100644 --- a/ext/oci8/tests/coll_017_func.phpt +++ b/ext/oci8/tests/coll_017_func.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require __DIR__."/connect.inc"; $ora_sql = "DROP TYPE - ".$type_name." - "; + ".$type_name." + "; $statement = OCIParse($c,$ora_sql); @OCIExecute($statement); diff --git a/ext/oci8/tests/commit_001.phpt b/ext/oci8/tests/commit_001.phpt index de4682eefc12..d99a6b3cbf89 100644 --- a/ext/oci8/tests/commit_001.phpt +++ b/ext/oci8/tests/commit_001.phpt @@ -14,20 +14,20 @@ require(__DIR__.'/create_table.inc'); $insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } /* check with OCI_NO_AUTO_COMMIT mode */ for ($i = 0; $i<3; $i++) { - if (!oci_execute($s, OCI_NO_AUTO_COMMIT)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s, OCI_NO_AUTO_COMMIT)) { + die("oci_execute(insert) failed!\n"); + } } for ($i = 0; $i<3; $i++) { - if (!oci_execute($s, OCI_DEFAULT)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s, OCI_DEFAULT)) { + die("oci_execute(insert) failed!\n"); + } } @@ -36,19 +36,19 @@ var_dump(oci_rollback($c)); $select_sql = "select * from ".$schema.$table_name.""; if (!($select = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } /* oci_fetch_all */ if (!oci_execute($select)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch_all($select, $all)); var_dump($all); /* ocifetchstatement */ if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } $insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)"; @@ -67,7 +67,7 @@ var_dump(oci_commit($c)); /* oci_fetch_all */ if (!oci_execute($select)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch_all($select, $all)); var_dump($all); diff --git a/ext/oci8/tests/commit_002.phpt b/ext/oci8/tests/commit_002.phpt index 143b0077fe31..4696f3b55617 100644 --- a/ext/oci8/tests/commit_002.phpt +++ b/ext/oci8/tests/commit_002.phpt @@ -13,8 +13,8 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table commit_002_tab", - "create table commit_002_tab + "drop table commit_002_tab", + "create table commit_002_tab ( x int constraint commit_002_tab_check_x check ( x > 0 ) deferrable initially immediate, y int constraint commit_002_tab_check_y check ( y > 0 ) deferrable initially deferred)" ); @@ -54,7 +54,7 @@ if (!$r) { // Clean up $stmtarray = array( - "drop table commit_002_tab" + "drop table commit_002_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/commit_old.phpt b/ext/oci8/tests/commit_old.phpt index 658cfd24b312..bfbae9b59741 100644 --- a/ext/oci8/tests/commit_old.phpt +++ b/ext/oci8/tests/commit_old.phpt @@ -14,13 +14,13 @@ require __DIR__.'/create_table.inc'; $insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; if (!($s = ociparse($c, $insert_sql))) { - die("ociparse(insert) failed!\n"); + die("ociparse(insert) failed!\n"); } for ($i = 0; $i<3; $i++) { - if (!ociexecute($s, OCI_DEFAULT)) { - die("ociexecute(insert) failed!\n"); - } + if (!ociexecute($s, OCI_DEFAULT)) { + die("ociexecute(insert) failed!\n"); + } } var_dump(ocirollback($c)); @@ -28,18 +28,18 @@ var_dump(ocirollback($c)); $select_sql = "SELECT * FROM ".$schema.$table_name.""; if (!($select = ociparse($c, $select_sql))) { - die("ociparse(select) failed!\n"); + die("ociparse(select) failed!\n"); } if (!oci_execute($select)) { - die("ociexecute(select) failed!\n"); + die("ociexecute(select) failed!\n"); } var_dump(ocifetchstatement($select, $all)); var_dump($all); /* ocifetchstatement */ if (!ociexecute($s)) { - die("ociexecute(select) failed!\n"); + die("ociexecute(select) failed!\n"); } $insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; @@ -57,7 +57,7 @@ for ($i = 0; $i<3; $i++) { var_dump(ocicommit($c)); if (!ociexecute($select)) { - die("ociexecute(select) failed!\n"); + die("ociexecute(select) failed!\n"); } var_dump(ocifetchstatement($select, $all)); var_dump($all); diff --git a/ext/oci8/tests/conn_attr.inc b/ext/oci8/tests/conn_attr.inc index f05f3bc06443..c2e3c364420b 100644 --- a/ext/oci8/tests/conn_attr.inc +++ b/ext/oci8/tests/conn_attr.inc @@ -30,29 +30,29 @@ if ((isset($matches[1]) && $matches[1] >= 11)) { foreach ($stmtarray as $stmt) { $s = oci_parse($c, $stmt); $r = @oci_execute($s); - if (!$r) { - $m = oci_error($s); - if (!in_array($m['code'], array( // ignore expected errors + if (!$r) { + $m = oci_error($s); + if (!in_array($m['code'], array( // ignore expected errors 942 // table or view does not exist , 1918 // user does not exist , 2289 // sequence does not exist , 4080 // trigger does not exist , 38802 // edition does not exist ))) { - echo "Error:" . $stmt . PHP_EOL . $m['message'] . PHP_EOL; + echo "Error:" . $stmt . PHP_EOL . $m['message'] . PHP_EOL; if ($m['code'] == 38807) { echo "You appear to already have an edition in use that prevents this PHP test from running. Query DBA_EDITIONS to see existing editions.". PHP_EOL; } die; - } - } + } + } } function get_attr($conn,$attr) { $sel_stmt="select " .$attr. " from v\$session where sid = - (select sid from v\$session where audsid = - sys_context('userenv','sessionid')) order by 1"; + (select sid from v\$session where audsid = + sys_context('userenv','sessionid')) order by 1"; $s2 = oci_parse($conn,$sel_stmt); oci_execute($s2,OCI_DEFAULT); while (oci_fetch($s2)) { @@ -66,10 +66,10 @@ function get_attr($conn,$attr) function get_conn($conn_type) { - $user = $GLOBALS['testuser']; - $password = $GLOBALS['testpassword']; - $dbase = $GLOBALS['dbase']; - switch($conn_type) { + $user = $GLOBALS['testuser']; + $password = $GLOBALS['testpassword']; + $dbase = $GLOBALS['dbase']; + switch($conn_type) { case 1: echo "Testing with oci_connect()\n"; return(oci_connect($user,$password,$dbase)); @@ -82,41 +82,41 @@ function get_conn($conn_type) echo "Testing with oci_new_connect()\n"; return(oci_new_connect($user,$password,$dbase)); break; - } + } } function set_attr($conn,$attr,$sufix) { - if (!strcmp($attr,'MODULE')) - $r = oci_set_module_name($conn,'PHP TEST'.$sufix); - else if (!strcmp($attr,'ACTION')) + if (!strcmp($attr,'MODULE')) + $r = oci_set_module_name($conn,'PHP TEST'.$sufix); + else if (!strcmp($attr,'ACTION')) $r = oci_set_action($conn,'TASK'.$sufix); - else if (!strcmp($attr,'CLIENT_INFO')) + else if (!strcmp($attr,'CLIENT_INFO')) $r = oci_set_client_info($conn,'INFO1'.$sufix); - else if (!strcmp($attr,'CLIENT_IDENTIFIER')) + else if (!strcmp($attr,'CLIENT_IDENTIFIER')) $r = oci_set_client_identifier($conn,'ID00'.$sufix); - else - echo "Pass one of the above four attributes!!!\n"; - if ($r) { - echo "Value of $attr has been set successfully\n"; + else + echo "Pass one of the above four attributes!!!\n"; + if ($r) { + echo "Value of $attr has been set successfully\n"; } - //Do a round-trip here - oci_server_version($conn); - return $r; + //Do a round-trip here + oci_server_version($conn); + return $r; } function set_edit_attr($value) { - $r = oci_set_edition($value); + $r = oci_set_edition($value); if ($r) { - echo " The value of edition has been successfully set\n"; + echo " The value of edition has been successfully set\n"; } - return $r; + return $r; } function get_edit_attr ($conn) { - $sel_stmt = "select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual"; + $sel_stmt = "select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual"; $s2 = oci_parse($conn,$sel_stmt); oci_execute($s2,OCI_DEFAULT); while (oci_fetch($s2)) { @@ -126,8 +126,8 @@ function get_edit_attr ($conn) { function get_sys_attr($conn,$attr) { - $sel_stmt="select " .$attr. " from v\$session where sid = - (select sid from v\$session where audsid = sys_context('userenv','sessionid')) order by 1"; + $sel_stmt="select " .$attr. " from v\$session where sid = + (select sid from v\$session where audsid = sys_context('userenv','sessionid')) order by 1"; $s2 = oci_parse($conn,$sel_stmt); oci_execute($s2,OCI_DEFAULT); while (oci_fetch($s2)) { @@ -136,14 +136,14 @@ function get_sys_attr($conn,$attr) } function clean_up($c) { - $stmtarray = array( + $stmtarray = array( "drop edition myedition1 cascade", "drop edition myedition cascade", "drop user " . $GLOBALS['testuser'] . " cascade", - ); + ); - foreach ($stmtarray as $stmt) { + foreach ($stmtarray as $stmt) { $s = oci_parse($c, $stmt); @oci_execute($s); - } + } } diff --git a/ext/oci8/tests/conn_attr_1.phpt b/ext/oci8/tests/conn_attr_1.phpt index 1c1f767398d7..ce23b2b5aace 100644 --- a/ext/oci8/tests/conn_attr_1.phpt +++ b/ext/oci8/tests/conn_attr_1.phpt @@ -36,19 +36,19 @@ echo"**Test 1.2 - Set and get values for the attributes **************\n"; $conn1 = get_conn(1); //oci_connect() foreach($attr_array as $attr) { - set_attr($conn1,$attr,1); + set_attr($conn1,$attr,1); get_attr($conn1,$attr); } $conn2 = get_conn(2); //oci_pconnect() foreach($attr_array as $attr) { - set_attr($conn2,$attr,2); + set_attr($conn2,$attr,2); get_attr($conn2,$attr); } $conn3 = get_conn(3); //oci_new_connect() foreach($attr_array as $attr) { - set_attr($conn3,$attr,3); + set_attr($conn3,$attr,3); get_attr($conn3,$attr); } diff --git a/ext/oci8/tests/conn_attr_2.phpt b/ext/oci8/tests/conn_attr_2.phpt index 898bd52bcd43..61d59093b150 100644 --- a/ext/oci8/tests/conn_attr_2.phpt +++ b/ext/oci8/tests/conn_attr_2.phpt @@ -29,21 +29,21 @@ echo"**Set values using pconnect-1**\n"; var_dump($pc1 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { - set_attr($pc1,$attr,100); + set_attr($pc1,$attr,100); } // using pc1 again echo"\n**Get values using pconnect-2**\n"; var_dump($pc3 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { - get_attr($pc3,$attr); + get_attr($pc3,$attr); } // Get with different pconnect echo"\n**Get values using pconnect-3**\n"; var_dump($pc2 = oci_pconnect($testuser,$testpassword,$dbase,'UTF8')); foreach($attr_array as $attr) { - get_attr($pc2,$attr); + get_attr($pc2,$attr); } oci_close($pc1); @@ -54,7 +54,7 @@ oci_close($pc3); echo "\n**Re-open a pconnect()**\n"; var_dump($pc4 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { - get_attr($pc4,$attr); + get_attr($pc4,$attr); } oci_close($pc4); @@ -68,10 +68,10 @@ if (!$sys_c1) { var_dump($e); } } else { - set_attr($sys_c1,'ACTION',10); - get_sys_attr($sys_c1,'ACTION'); - get_attr($sys_c1,'ACTION'); - oci_close($sys_c1); + set_attr($sys_c1,'ACTION',10); + get_sys_attr($sys_c1,'ACTION'); + get_attr($sys_c1,'ACTION'); + oci_close($sys_c1); } clean_up($c); diff --git a/ext/oci8/tests/conn_attr_4.phpt b/ext/oci8/tests/conn_attr_4.phpt index 46a219c05da4..7a7f5269eb0c 100644 --- a/ext/oci8/tests/conn_attr_4.phpt +++ b/ext/oci8/tests/conn_attr_4.phpt @@ -59,16 +59,16 @@ echo "\nSetting to different values \n"; $values_array = array(1000,NULL,'this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!'); foreach($values_array as $val ) { - oci_set_module_name($c1,$val); - oci_set_client_identifier($c1,$val); - oci_set_client_info($c1,$val); - $r = oci_set_action($c1,$val); - if ($r) { - echo "Values set successfully to $val\n"; - foreach($attr_array as $attr) { + oci_set_module_name($c1,$val); + oci_set_client_identifier($c1,$val); + oci_set_client_info($c1,$val); + $r = oci_set_action($c1,$val); + if ($r) { + echo "Values set successfully to $val\n"; + foreach($attr_array as $attr) { get_attr($c1,$attr); } - } + } } clean_up($c); diff --git a/ext/oci8/tests/connect.phpt b/ext/oci8/tests/connect.phpt index d534e4487102..f13d6fd421ce 100644 --- a/ext/oci8/tests/connect.phpt +++ b/ext/oci8/tests/connect.phpt @@ -8,10 +8,10 @@ oci_connect() require __DIR__."/connect.inc"; if (!empty($dbase)) { - var_dump(oci_connect($user, $password, $dbase)); + var_dump(oci_connect($user, $password, $dbase)); } else { - var_dump(oci_connect($user, $password)); + var_dump(oci_connect($user, $password)); } echo "Done\n"; diff --git a/ext/oci8/tests/connect_1.phpt b/ext/oci8/tests/connect_1.phpt index 6d76c8ddcc65..297b0897b6b4 100644 --- a/ext/oci8/tests/connect_1.phpt +++ b/ext/oci8/tests/connect_1.phpt @@ -8,17 +8,17 @@ oci_pconnect() & oci_new_connect() require __DIR__."/connect.inc"; if (!empty($dbase)) { - var_dump($c1 = oci_pconnect($user, $password, $dbase)); + var_dump($c1 = oci_pconnect($user, $password, $dbase)); } else { - var_dump($c1 = oci_pconnect($user, $password)); + var_dump($c1 = oci_pconnect($user, $password)); } if (!empty($dbase)) { - var_dump($c2 = oci_new_connect($user, $password, $dbase)); + var_dump($c2 = oci_new_connect($user, $password, $dbase)); } else { - var_dump($c2 = oci_new_connect($user, $password)); + var_dump($c2 = oci_new_connect($user, $password)); } var_dump(oci_close($c1)); diff --git a/ext/oci8/tests/connect_1_old.phpt b/ext/oci8/tests/connect_1_old.phpt index 2014d59fe324..3ce756f51cac 100644 --- a/ext/oci8/tests/connect_1_old.phpt +++ b/ext/oci8/tests/connect_1_old.phpt @@ -8,17 +8,17 @@ ociplogon() & ocinlogon() require __DIR__."/connect.inc"; if (!empty($dbase)) { - var_dump($c1 = ociplogon($user, $password, $dbase)); + var_dump($c1 = ociplogon($user, $password, $dbase)); } else { - var_dump($c1 = ociplogon($user, $password)); + var_dump($c1 = ociplogon($user, $password)); } if (!empty($dbase)) { - var_dump($c2 = ocinlogon($user, $password, $dbase)); + var_dump($c2 = ocinlogon($user, $password, $dbase)); } else { - var_dump($c2 = ocinlogon($user, $password)); + var_dump($c2 = ocinlogon($user, $password)); } var_dump(ocilogoff($c1)); diff --git a/ext/oci8/tests/connect_old.phpt b/ext/oci8/tests/connect_old.phpt index a2012bfd194f..c55197fca175 100644 --- a/ext/oci8/tests/connect_old.phpt +++ b/ext/oci8/tests/connect_old.phpt @@ -8,10 +8,10 @@ ocilogon() require __DIR__."/connect.inc"; if (!empty($dbase)) { - var_dump(ocilogon($user, $password, $dbase)); + var_dump(ocilogon($user, $password, $dbase)); } else { - var_dump(ocilogon($user, $password)); + var_dump(ocilogon($user, $password)); } echo "Done\n"; diff --git a/ext/oci8/tests/connect_scope1.phpt b/ext/oci8/tests/connect_scope1.phpt index aefee2f882e7..684103b9f31e 100644 --- a/ext/oci8/tests/connect_scope1.phpt +++ b/ext/oci8/tests/connect_scope1.phpt @@ -10,14 +10,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table connect_scope1_tab", - "create table connect_scope1_tab (c1 number)", + "drop table connect_scope1_tab", + "create table connect_scope1_tab (c1 number)", ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -27,15 +27,15 @@ echo "Test 1 - oci_connect\n"; function f() { - global $user, $password, $dbase; - - if (!empty($dbase)) - $c = oci_connect($user,$password,$dbase); - else - $c = oci_connect($user,$password); - $s = oci_parse($c, "insert into connect_scope1_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - return($s); // this keeps the connection refcount positive so the connection isn't closed + global $user, $password, $dbase; + + if (!empty($dbase)) + $c = oci_connect($user,$password,$dbase); + else + $c = oci_connect($user,$password); + $s = oci_parse($c, "insert into connect_scope1_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + return($s); // this keeps the connection refcount positive so the connection isn't closed } $s2 = f(); @@ -60,7 +60,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table connect_scope1_tab" + "drop table connect_scope1_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope2.phpt b/ext/oci8/tests/connect_scope2.phpt index aa192b145908..9a2de41e30bd 100644 --- a/ext/oci8/tests/connect_scope2.phpt +++ b/ext/oci8/tests/connect_scope2.phpt @@ -10,14 +10,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table connect_scope2_tab", - "create table connect_scope2_tab (c1 number)", + "drop table connect_scope2_tab", + "create table connect_scope2_tab (c1 number)", ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -27,15 +27,15 @@ echo "Test 1 - oci_pconnect\n"; function f() { - global $user, $password, $dbase; - - if (!empty($dbase)) - $c = oci_pconnect($user,$password,$dbase); - else - $c = oci_pconnect($user,$password); - $s = oci_parse($c, "insert into connect_scope2_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - return($s); // this keeps the connection refcount positive so the connection isn't closed + global $user, $password, $dbase; + + if (!empty($dbase)) + $c = oci_pconnect($user,$password,$dbase); + else + $c = oci_pconnect($user,$password); + $s = oci_parse($c, "insert into connect_scope2_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + return($s); // this keeps the connection refcount positive so the connection isn't closed } $s2 = f(); @@ -60,7 +60,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table connect_scope2_tab" + "drop table connect_scope2_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope_try1.phpt b/ext/oci8/tests/connect_scope_try1.phpt index d3628f9eaad2..54f4cc552b00 100644 --- a/ext/oci8/tests/connect_scope_try1.phpt +++ b/ext/oci8/tests/connect_scope_try1.phpt @@ -12,14 +12,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table scope_try1_tab", - "create table scope_try1_tab (c1 number)" + "drop table scope_try1_tab", + "create table scope_try1_tab (c1 number)" ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -33,28 +33,28 @@ set_error_handler(function($x, $y) { throw new Exception($y, $x); }); try { - if (!empty($dbase)) - $c = oci_connect($user,$password,$dbase); - else - $c = oci_connect($user,$password); - $s = oci_parse($c, "insert into scope_try1_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - $s = oci_parse($c, "insert into scope_try1_tab values (ABC)"); // syntax error -> throws exception - oci_execute($s, OCI_DEFAULT); // no commit + if (!empty($dbase)) + $c = oci_connect($user,$password,$dbase); + else + $c = oci_connect($user,$password); + $s = oci_parse($c, "insert into scope_try1_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try1_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit } catch (Exception $e) { - echo "Caught Exception: ". $e->getMessage(), "\n"; - var_dump($c); + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); - // Verify data is not yet committed - $s1 = oci_parse($c1, "select * from scope_try1_tab"); - oci_execute($s1); - oci_fetch_all($s1, $r); - var_dump($r); + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try1_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); - // Now commit - oci_commit($c); + // Now commit + oci_commit($c); } // Verify data was committed in the Catch block @@ -67,7 +67,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table scope_try1_tab" + "drop table scope_try1_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope_try2.phpt b/ext/oci8/tests/connect_scope_try2.phpt index 76e6909f446e..2ec7b78c5fff 100644 --- a/ext/oci8/tests/connect_scope_try2.phpt +++ b/ext/oci8/tests/connect_scope_try2.phpt @@ -12,14 +12,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table scope_try2_tab", - "create table scope_try2_tab (c1 number)" + "drop table scope_try2_tab", + "create table scope_try2_tab (c1 number)" ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -33,28 +33,28 @@ set_error_handler(function($x, $y) { throw new Exception($y, $x); }); try { - if (!empty($dbase)) - $c = oci_connect($user,$password,$dbase); - else - $c = oci_connect($user,$password); - $s = oci_parse($c, "insert into scope_try2_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - $s = oci_parse($c, "insert into scope_try2_tab values (ABC)"); // syntax error -> throws exception - oci_execute($s, OCI_DEFAULT); // no commit + if (!empty($dbase)) + $c = oci_connect($user,$password,$dbase); + else + $c = oci_connect($user,$password); + $s = oci_parse($c, "insert into scope_try2_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try2_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit } catch (Exception $e) { - echo "Caught Exception: ". $e->getMessage(), "\n"; - var_dump($c); + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); - // Verify data is not yet committed - $s1 = oci_parse($c1, "select * from scope_try2_tab"); - oci_execute($s1); - oci_fetch_all($s1, $r); - var_dump($r); + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try2_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); - // Now commit - oci_commit($c); + // Now commit + oci_commit($c); } // Verify data was committed in the Catch block @@ -67,7 +67,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table scope_try2_tab" + "drop table scope_try2_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope_try3.phpt b/ext/oci8/tests/connect_scope_try3.phpt index d9cbfce35514..7c09750410ab 100644 --- a/ext/oci8/tests/connect_scope_try3.phpt +++ b/ext/oci8/tests/connect_scope_try3.phpt @@ -12,14 +12,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table scope_try3_tab", - "create table scope_try3_tab (c1 number)" + "drop table scope_try3_tab", + "create table scope_try3_tab (c1 number)" ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -33,28 +33,28 @@ set_error_handler(function($x, $y) { throw new Exception($y, $x); }); try { - if (!empty($dbase)) - $c = oci_new_connect($user,$password,$dbase); - else - $c = oci_new_connect($user,$password); - $s = oci_parse($c, "insert into scope_try3_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - $s = oci_parse($c, "insert into scope_try3_tab values (ABC)"); // syntax error -> throws exception - oci_execute($s, OCI_DEFAULT); // no commit + if (!empty($dbase)) + $c = oci_new_connect($user,$password,$dbase); + else + $c = oci_new_connect($user,$password); + $s = oci_parse($c, "insert into scope_try3_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try3_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit } catch (Exception $e) { - echo "Caught Exception: ". $e->getMessage(), "\n"; - var_dump($c); + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); - // Verify data is not yet committed - $s1 = oci_parse($c1, "select * from scope_try3_tab"); - oci_execute($s1); - oci_fetch_all($s1, $r); - var_dump($r); + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try3_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); - // Now commit - oci_commit($c); + // Now commit + oci_commit($c); } // Verify data was committed in the Catch block @@ -67,7 +67,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table scope_try3_tab" + "drop table scope_try3_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope_try4.phpt b/ext/oci8/tests/connect_scope_try4.phpt index cdefe36ee9d4..04f82712a84f 100644 --- a/ext/oci8/tests/connect_scope_try4.phpt +++ b/ext/oci8/tests/connect_scope_try4.phpt @@ -12,14 +12,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table scope_try4_tab", - "create table scope_try4_tab (c1 number)" + "drop table scope_try4_tab", + "create table scope_try4_tab (c1 number)" ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -33,28 +33,28 @@ set_error_handler(function($x, $y) { throw new Exception($y, $x); }); try { - if (!empty($dbase)) - $c = oci_new_connect($user,$password,$dbase); - else - $c = oci_new_connect($user,$password); - $s = oci_parse($c, "insert into scope_try4_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - $s = oci_parse($c, "insert into scope_try4_tab values (ABC)"); // syntax error -> throws exception - oci_execute($s, OCI_DEFAULT); // no commit + if (!empty($dbase)) + $c = oci_new_connect($user,$password,$dbase); + else + $c = oci_new_connect($user,$password); + $s = oci_parse($c, "insert into scope_try4_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try4_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit } catch (Exception $e) { - echo "Caught Exception: ". $e->getMessage(), "\n"; - var_dump($c); + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); - // Verify data is not yet committed - $s1 = oci_parse($c1, "select * from scope_try4_tab"); - oci_execute($s1); - oci_fetch_all($s1, $r); - var_dump($r); + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try4_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); - // Now commit - oci_commit($c); + // Now commit + oci_commit($c); } // Verify data was committed in the Catch block @@ -67,7 +67,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table scope_try4_tab" + "drop table scope_try4_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope_try5.phpt b/ext/oci8/tests/connect_scope_try5.phpt index 1e99d0a2e105..43b7ff00494f 100644 --- a/ext/oci8/tests/connect_scope_try5.phpt +++ b/ext/oci8/tests/connect_scope_try5.phpt @@ -12,14 +12,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table scope_try5_tab", - "create table scope_try5_tab (c1 number)" + "drop table scope_try5_tab", + "create table scope_try5_tab (c1 number)" ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -33,28 +33,28 @@ set_error_handler(function($x, $y) { throw new Exception($y, $x); }); try { - if (!empty($dbase)) - $c = oci_pconnect($user,$password,$dbase); - else - $c = oci_pconnect($user,$password); - $s = oci_parse($c, "insert into scope_try5_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - $s = oci_parse($c, "insert into scope_try5_tab values (ABC)"); // syntax error -> throws exception - oci_execute($s, OCI_DEFAULT); // no commit + if (!empty($dbase)) + $c = oci_pconnect($user,$password,$dbase); + else + $c = oci_pconnect($user,$password); + $s = oci_parse($c, "insert into scope_try5_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try5_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit } catch (Exception $e) { - echo "Caught Exception: ". $e->getMessage(), "\n"; - var_dump($c); + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); - // Verify data is not yet committed - $s1 = oci_parse($c1, "select * from scope_try5_tab"); - oci_execute($s1); - oci_fetch_all($s1, $r); - var_dump($r); + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try5_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); - // Now commit - oci_commit($c); + // Now commit + oci_commit($c); } // Verify data was committed in the Catch block @@ -67,7 +67,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table scope_try5_tab" + "drop table scope_try5_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_scope_try6.phpt b/ext/oci8/tests/connect_scope_try6.phpt index 84ea97ac4337..fc31bddfd89f 100644 --- a/ext/oci8/tests/connect_scope_try6.phpt +++ b/ext/oci8/tests/connect_scope_try6.phpt @@ -12,14 +12,14 @@ require(__DIR__.'/details.inc'); // Initialization $stmtarray = array( - "drop table scope_try6_tab", - "create table scope_try6_tab (c1 number)" + "drop table scope_try6_tab", + "create table scope_try6_tab (c1 number)" ); if (!empty($dbase)) - $c1 = oci_new_connect($user,$password,$dbase); + $c1 = oci_new_connect($user,$password,$dbase); else - $c1 = oci_new_connect($user,$password); + $c1 = oci_new_connect($user,$password); oci8_test_sql_execute($c1, $stmtarray); @@ -33,28 +33,28 @@ set_error_handler(function($x, $y) { throw new Exception($y, $x); }); try { - if (!empty($dbase)) - $c = oci_pconnect($user,$password,$dbase); - else - $c = oci_pconnect($user,$password); - $s = oci_parse($c, "insert into scope_try6_tab values (1)"); - oci_execute($s, OCI_DEFAULT); // no commit - $s = oci_parse($c, "insert into scope_try6_tab values (ABC)"); // syntax error -> throws exception - oci_execute($s, OCI_DEFAULT); // no commit + if (!empty($dbase)) + $c = oci_pconnect($user,$password,$dbase); + else + $c = oci_pconnect($user,$password); + $s = oci_parse($c, "insert into scope_try6_tab values (1)"); + oci_execute($s, OCI_DEFAULT); // no commit + $s = oci_parse($c, "insert into scope_try6_tab values (ABC)"); // syntax error -> throws exception + oci_execute($s, OCI_DEFAULT); // no commit } catch (Exception $e) { - echo "Caught Exception: ". $e->getMessage(), "\n"; - var_dump($c); + echo "Caught Exception: ". $e->getMessage(), "\n"; + var_dump($c); - // Verify data is not yet committed - $s1 = oci_parse($c1, "select * from scope_try6_tab"); - oci_execute($s1); - oci_fetch_all($s1, $r); - var_dump($r); + // Verify data is not yet committed + $s1 = oci_parse($c1, "select * from scope_try6_tab"); + oci_execute($s1); + oci_fetch_all($s1, $r); + var_dump($r); - // Now commit - oci_commit($c); + // Now commit + oci_commit($c); } // Verify data was committed in the Catch block @@ -67,7 +67,7 @@ var_dump($r); // Cleanup $stmtarray = array( - "drop table scope_try6_tab" + "drop table scope_try6_tab" ); oci8_test_sql_execute($c1, $stmtarray); diff --git a/ext/oci8/tests/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt index b6fc0087b1c0..203fd57e9235 100644 --- a/ext/oci8/tests/connect_without_oracle_home.phpt +++ b/ext/oci8/tests/connect_without_oracle_home.phpt @@ -23,10 +23,10 @@ ORACLE_HOME="" require __DIR__."/details.inc"; if (!empty($dbase)) { - var_dump(oci_connect($user, $password, $dbase)); + var_dump(oci_connect($user, $password, $dbase)); } else { - var_dump(oci_connect($user, $password)); + var_dump(oci_connect($user, $password)); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_11.phpt b/ext/oci8/tests/connect_without_oracle_home_11.phpt index f40675c9c137..85ac99387708 100644 --- a/ext/oci8/tests/connect_without_oracle_home_11.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_11.phpt @@ -26,10 +26,10 @@ ORACLE_HOME="" require __DIR__."/details.inc"; if (!empty($dbase)) { - var_dump(oci_connect($user, $password, $dbase)); + var_dump(oci_connect($user, $password, $dbase)); } else { - var_dump(oci_connect($user, $password)); + var_dump(oci_connect($user, $password)); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_old.phpt b/ext/oci8/tests/connect_without_oracle_home_old.phpt index d311ffaab16c..bd217acd7728 100644 --- a/ext/oci8/tests/connect_without_oracle_home_old.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_old.phpt @@ -19,10 +19,10 @@ ORACLE_HOME="" require __DIR__."/details.inc"; if (!empty($dbase)) { - var_dump(ocilogon($user, $password, $dbase)); + var_dump(ocilogon($user, $password, $dbase)); } else { - var_dump(ocilogon($user, $password)); + var_dump(ocilogon($user, $password)); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt index 1c10fd6e1c85..243741bfdea3 100644 --- a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt @@ -26,10 +26,10 @@ ORACLE_HOME="" require __DIR__."/details.inc"; if (!empty($dbase)) { - var_dump(ocilogon($user, $password, $dbase)); + var_dump(ocilogon($user, $password, $dbase)); } else { - var_dump(ocilogon($user, $password)); + var_dump(ocilogon($user, $password)); } ?> diff --git a/ext/oci8/tests/cursors.phpt b/ext/oci8/tests/cursors.phpt index 8a33f51649a4..a9fa0dcb41e4 100644 --- a/ext/oci8/tests/cursors.phpt +++ b/ext/oci8/tests/cursors.phpt @@ -14,17 +14,17 @@ require __DIR__."/create_table.inc"; $insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } for ($i = 0; $i<3; $i++) { - if (!oci_execute($s)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } } if (!oci_commit($c)) { - die("oci_commit() failed!\n"); + die("oci_commit() failed!\n"); } $sql = "select CURSOR(select * from ".$schema.$table_name.") as curs FROM dual"; @@ -33,13 +33,13 @@ $stmt = oci_parse($c, $sql); oci_execute($stmt); while ($data = oci_fetch_assoc($stmt)) { - oci_execute($data["CURS"]); - $subdata = oci_fetch_assoc($data["CURS"]); - var_dump($subdata); - var_dump(oci_cancel($data["CURS"])); - $subdata = oci_fetch_assoc($data["CURS"]); - var_dump($subdata); - var_dump(oci_cancel($data["CURS"])); + oci_execute($data["CURS"]); + $subdata = oci_fetch_assoc($data["CURS"]); + var_dump($subdata); + var_dump(oci_cancel($data["CURS"])); + $subdata = oci_fetch_assoc($data["CURS"]); + var_dump($subdata); + var_dump(oci_cancel($data["CURS"])); } require __DIR__."/drop_table.inc"; diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt index b130da5165c1..7c5c668f62d9 100644 --- a/ext/oci8/tests/cursors_old.phpt +++ b/ext/oci8/tests/cursors_old.phpt @@ -30,13 +30,13 @@ $stmt = ociparse($c, $sql); ociexecute($stmt); while ($result = ocifetchinto($stmt, $data, OCI_ASSOC)) { - ociexecute($data["CURS"]); - ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); - var_dump($subdata); - var_dump(ocicancel($data["CURS"])); - ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); - var_dump($subdata); - var_dump(ocicancel($data["CURS"])); + ociexecute($data["CURS"]); + ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); + var_dump($subdata); + var_dump(ocicancel($data["CURS"])); + ocifetchinto($data["CURS"], $subdata, OCI_ASSOC); + var_dump($subdata); + var_dump(ocicancel($data["CURS"])); } // Cleanup diff --git a/ext/oci8/tests/dbmsoutput.phpt b/ext/oci8/tests/dbmsoutput.phpt index ff40df1a3881..01ba9db0b526 100644 --- a/ext/oci8/tests/dbmsoutput.phpt +++ b/ext/oci8/tests/dbmsoutput.phpt @@ -71,20 +71,20 @@ function getdbmsoutput_do($c) function getdbmsoutput_do2($c) { - $orignumlines = $numlines = 100; - $s = oci_parse($c, "begin dbms_output.get_lines(:lines, :numlines); end;"); - $r = oci_bind_by_name($s, ":numlines", $numlines); - $res = array(); - while ($numlines >= $orignumlines) { - oci_bind_array_by_name($s, ":lines", $lines, $numlines, 255, SQLT_CHR); - oci_execute($s); - if ($numlines == 0) { - break; - } - $res = array_merge($res, array_slice($lines, 0, $numlines)); - unset($lines); - } - return $res; + $orignumlines = $numlines = 100; + $s = oci_parse($c, "begin dbms_output.get_lines(:lines, :numlines); end;"); + $r = oci_bind_by_name($s, ":numlines", $numlines); + $res = array(); + while ($numlines >= $orignumlines) { + oci_bind_array_by_name($s, ":lines", $lines, $numlines, 255, SQLT_CHR); + oci_execute($s); + if ($numlines == 0) { + break; + } + $res = array_merge($res, array_slice($lines, 0, $numlines)); + unset($lines); + } + return $res; } function getdbmsoutput_pl($c) @@ -124,7 +124,7 @@ var_dump(getdbmsoutput_pl($c)); // Clean up $stmtarray = array( - "drop procedure dbmsoutput_proc" + "drop procedure dbmsoutput_proc" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt index a197639af67b..f66eeb969803 100644 --- a/ext/oci8/tests/debug.phpt +++ b/ext/oci8/tests/debug.phpt @@ -10,10 +10,10 @@ require(__DIR__."/details.inc"); oci_internal_debug(true); if (!empty($dbase)) { - oci_connect($user, $password, $dbase); + oci_connect($user, $password, $dbase); } else { - oci_connect($user, $password); + oci_connect($user, $password); } oci_internal_debug(false); diff --git a/ext/oci8/tests/default_prefetch0.phpt b/ext/oci8/tests/default_prefetch0.phpt index 6a6232871343..4dce73431cb3 100644 --- a/ext/oci8/tests/default_prefetch0.phpt +++ b/ext/oci8/tests/default_prefetch0.phpt @@ -26,11 +26,11 @@ oci8_test_sql_execute($c, $stmtarray); $select_sql = "select * from default_prefetch_tab"; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch($s)); diff --git a/ext/oci8/tests/default_prefetch1.phpt b/ext/oci8/tests/default_prefetch1.phpt index ca9590a82f20..dbe92e75f471 100644 --- a/ext/oci8/tests/default_prefetch1.phpt +++ b/ext/oci8/tests/default_prefetch1.phpt @@ -26,11 +26,11 @@ oci8_test_sql_execute($c, $stmtarray); $select_sql = "select * from default_prefetch1_tab"; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch($s)); diff --git a/ext/oci8/tests/default_prefetch2.phpt b/ext/oci8/tests/default_prefetch2.phpt index 1d2a80b84585..6d01fb1bac31 100644 --- a/ext/oci8/tests/default_prefetch2.phpt +++ b/ext/oci8/tests/default_prefetch2.phpt @@ -26,13 +26,13 @@ oci8_test_sql_execute($c, $stmtarray); $select_sql = "select * from default_prefetch2_tab"; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } var_dump(oci_set_prefetch($s, 10)); if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch($s)); diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt index e3f19e63376b..8fd459e10ed0 100644 --- a/ext/oci8/tests/define.phpt +++ b/ext/oci8/tests/define.phpt @@ -29,7 +29,7 @@ oci_define_by_name($stmt, "STRING", $string, 20); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($string); + var_dump($string); } // Cleanup diff --git a/ext/oci8/tests/define0.phpt b/ext/oci8/tests/define0.phpt index c59b24ee76cb..fecbf237572c 100644 --- a/ext/oci8/tests/define0.phpt +++ b/ext/oci8/tests/define0.phpt @@ -29,7 +29,7 @@ $string = ''; oci_define_by_name($stmt, "STRING", $string, 20); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($string); + var_dump($string); } echo "Test 2\n"; diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt index 28c4b7f1f477..37efddafb91e 100644 --- a/ext/oci8/tests/define1.phpt +++ b/ext/oci8/tests/define1.phpt @@ -32,7 +32,7 @@ var_dump(oci_define_by_name($stmt, "")); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($string); + var_dump($string); } // Cleanup diff --git a/ext/oci8/tests/define2.phpt b/ext/oci8/tests/define2.phpt index a018bbcb449a..9dbac4620bf5 100644 --- a/ext/oci8/tests/define2.phpt +++ b/ext/oci8/tests/define2.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require(__DIR__."/connect.inc"); $stmtarray = array( - "drop table phptestrawtable", - "create table phptestrawtable( id number(10), fileimage raw(1000))" + "drop table phptestrawtable", + "create table phptestrawtable( id number(10), fileimage raw(1000))" ); oci8_test_sql_execute($c, $stmtarray); @@ -34,8 +34,8 @@ var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi)); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($fi); - echo "file md5:" . md5($fi) . "\n"; + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; } echo "Test 2\n"; @@ -44,8 +44,8 @@ var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi)); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($fi); - echo "file md5:" . md5($fi) . "\n"; + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; } echo "Test 3 - test repeatability\n"; @@ -54,8 +54,8 @@ var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_STR)); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($fi); - echo "file md5:" . md5($fi) . "\n"; + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; } echo "Test 4 - wrong type\n"; @@ -64,8 +64,8 @@ var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fi, SQLT_RSET)); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($fi); - echo "file md5:" . md5($fi) . "\n"; + var_dump($fi); + echo "file md5:" . md5($fi) . "\n"; } // Cleanup diff --git a/ext/oci8/tests/define3.phpt b/ext/oci8/tests/define3.phpt index 669ae39d93e2..e70f63693836 100644 --- a/ext/oci8/tests/define3.phpt +++ b/ext/oci8/tests/define3.phpt @@ -11,8 +11,8 @@ require(__DIR__.'/skipif.inc'); require(__DIR__."/connect.inc"); $stmtarray = array( - "drop table phpdefblobtable", - "create table phpdefblobtable (id number(10), fileimage blob)" + "drop table phpdefblobtable", + "create table phpdefblobtable (id number(10), fileimage blob)" ); oci8_test_sql_execute($c, $stmtarray); @@ -76,7 +76,7 @@ while (oci_fetch($stmt)) { } $stmtarray = array( - "drop table phpdefblobtable" + "drop table phpdefblobtable" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/define4.phpt b/ext/oci8/tests/define4.phpt index 25296f96d38b..d7ffc3fd5809 100644 --- a/ext/oci8/tests/define4.phpt +++ b/ext/oci8/tests/define4.phpt @@ -30,12 +30,12 @@ oci_execute($stmt); echo "Test 2\n"; while (oci_fetch($stmt)) { - var_dump(oci_result($stmt, 'VALUE')); - var_dump($string); - var_dump(oci_result($stmt, 'STRING')); - var_dump($string); - var_dump(oci_result($stmt, 'VALUE')); - var_dump(oci_result($stmt, 'STRING')); + var_dump(oci_result($stmt, 'VALUE')); + var_dump($string); + var_dump(oci_result($stmt, 'STRING')); + var_dump($string); + var_dump(oci_result($stmt, 'VALUE')); + var_dump(oci_result($stmt, 'STRING')); } echo "Test 3\n"; diff --git a/ext/oci8/tests/define5.phpt b/ext/oci8/tests/define5.phpt index 2dd9980d4555..3f1e57741b43 100644 --- a/ext/oci8/tests/define5.phpt +++ b/ext/oci8/tests/define5.phpt @@ -25,8 +25,8 @@ $stmt = oci_parse($c, "select string from define5_tab where id = 1"); oci_execute($stmt); var_dump(oci_define_by_name($stmt, "STRING", $string)); while (oci_fetch($stmt)) { - var_dump($string); // gives NULL - var_dump(oci_result($stmt, 'STRING')); + var_dump($string); // gives NULL + var_dump(oci_result($stmt, 'STRING')); } echo "Test 2 - normal define order\n"; @@ -35,15 +35,15 @@ var_dump(oci_define_by_name($stmt, "STRING", $string)); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($string); + var_dump($string); } echo "Test 3 - no new define done\n"; $stmt = oci_parse($c, "select string from define5_tab where id = 2"); oci_execute($stmt); while (oci_fetch($stmt)) { - var_dump($string); // not updated with new value - var_dump(oci_result($stmt, 'STRING')); + var_dump($string); // not updated with new value + var_dump(oci_result($stmt, 'STRING')); } // Cleanup diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt index 634a86d37042..25458e128306 100644 --- a/ext/oci8/tests/define_old.phpt +++ b/ext/oci8/tests/define_old.phpt @@ -29,7 +29,7 @@ ocidefinebyname($stmt, "STRING", $string, 20); ociexecute($stmt); while (ocifetch($stmt)) { - var_dump($string); + var_dump($string); } // Cleanup diff --git a/ext/oci8/tests/descriptors.phpt b/ext/oci8/tests/descriptors.phpt index 193e1e76f83a..44d4ab0a01c0 100644 --- a/ext/oci8/tests/descriptors.phpt +++ b/ext/oci8/tests/descriptors.phpt @@ -12,11 +12,11 @@ require __DIR__.'/connect.inc'; require __DIR__.'/create_table.inc'; $ora_sql = "INSERT INTO - ".$schema.$table_name." (blob) - VALUES (empty_blob()) - RETURNING - blob - INTO :v_blob "; + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; $statement = oci_parse($c,$ora_sql); $blob = oci_new_descriptor($c,OCI_D_LOB); diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc index 731b562d0ab3..101ebfcd79f8 100644 --- a/ext/oci8/tests/details.inc +++ b/ext/oci8/tests/details.inc @@ -12,32 +12,32 @@ */ if (file_exists(dirname(__FILE__)."/details_local.inc")) { - include(dirname(__FILE__)."/details_local.inc"); // this file is not part of the source distribution; make it your own local variant of details.inc + include(dirname(__FILE__)."/details_local.inc"); // this file is not part of the source distribution; make it your own local variant of details.inc } else { - if (false !== getenv('PHP_OCI8_TEST_DB')) { - $user = getenv('PHP_OCI8_TEST_USER'); // Database username for tests - $password = getenv('PHP_OCI8_TEST_PASS'); // Password for $user - $dbase = getenv('PHP_OCI8_TEST_DB'); // Database connection string - $test_drcp = getenv('PHP_OCI8_TEST_DRCP'); - if (false !== $test_drcp && 0 == strcasecmp($test_drcp,'TRUE')) { - $test_drcp = TRUE; - } else { - $test_drcp = FALSE; - } - } else { - $user = "system"; - $password = "oracle"; - $dbase = "localhost/XE"; - $test_drcp = FALSE; - } + if (false !== getenv('PHP_OCI8_TEST_DB')) { + $user = getenv('PHP_OCI8_TEST_USER'); // Database username for tests + $password = getenv('PHP_OCI8_TEST_PASS'); // Password for $user + $dbase = getenv('PHP_OCI8_TEST_DB'); // Database connection string + $test_drcp = getenv('PHP_OCI8_TEST_DRCP'); + if (false !== $test_drcp && 0 == strcasecmp($test_drcp,'TRUE')) { + $test_drcp = TRUE; + } else { + $test_drcp = FALSE; + } + } else { + $user = "system"; + $password = "oracle"; + $dbase = "localhost/XE"; + $test_drcp = FALSE; + } - /* - * Common object names for scripts to use - */ + /* + * Common object names for scripts to use + */ - $table_name = "tb".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5); - $type_name = strtoupper("tp".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5)); - $schema = ''; + $table_name = "tb".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5); + $type_name = strtoupper("tp".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5)); + $schema = ''; } @@ -59,14 +59,14 @@ if (!function_exists('oci8_test_sql_execute')) { if (!$r) { $m = oci_error($s); if (!in_array($m['code'], array( // ignore expected errors - 942 // table or view does not exist + 942 // table or view does not exist , 1918 // user does not exist , 2024 // database link not found , 2289 // sequence does not exist , 4080 // trigger does not exist , 38802 // edition does not exist ))) { - echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL; + echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL; } } } diff --git a/ext/oci8/tests/drcp_characterset.phpt b/ext/oci8/tests/drcp_characterset.phpt index c5a5339e04de..fdcacead930d 100644 --- a/ext/oci8/tests/drcp_characterset.phpt +++ b/ext/oci8/tests/drcp_characterset.phpt @@ -31,17 +31,17 @@ var_dump($p2); //character sets if((int)$c1 === (int)$c2) - echo "First and third connections share a resource: NOT OK\n"; + echo "First and third connections share a resource: NOT OK\n"; else - echo "First and third connections are different: OK\n"; + echo "First and third connections are different: OK\n"; // The two connections p1 and p2 should not share resources as they use different //character sets if((int)$p1 === (int)$p2) - echo "Second and fourth connections share a resource: NOT OK\n"; + echo "Second and fourth connections share a resource: NOT OK\n"; else - echo "Second and fourth connections are different: OK\n"; + echo "Second and fourth connections are different: OK\n"; // Close all the connections oci_close($c1); diff --git a/ext/oci8/tests/drcp_conn_close1.phpt b/ext/oci8/tests/drcp_conn_close1.phpt index 71a070eadbec..b1afb4779b23 100644 --- a/ext/oci8/tests/drcp_conn_close1.phpt +++ b/ext/oci8/tests/drcp_conn_close1.phpt @@ -30,9 +30,9 @@ oci_close($conn2); // Compare the resource numbers if ($rn1 === $rn2) - echo "Both connections share a resource : OK\n"; + echo "Both connections share a resource : OK\n"; else - echo "Both connections are different : NOT OK\n"; + echo "Both connections are different : NOT OK\n"; echo "Done\n"; diff --git a/ext/oci8/tests/drcp_conn_close2.phpt b/ext/oci8/tests/drcp_conn_close2.phpt index 7939e53d9e58..cb4df083a644 100644 --- a/ext/oci8/tests/drcp_conn_close2.phpt +++ b/ext/oci8/tests/drcp_conn_close2.phpt @@ -31,9 +31,9 @@ oci_close($conn2); // Compare the resource numbers if ($rn1 === $rn2) - echo "Both connections share a resource : NOT OK\n"; + echo "Both connections share a resource : NOT OK\n"; else - echo "Both connections are different : OK\n"; + echo "Both connections are different : OK\n"; echo "Done\n"; diff --git a/ext/oci8/tests/drcp_functions.inc b/ext/oci8/tests/drcp_functions.inc index 320026486e17..595f82da1f2c 100644 --- a/ext/oci8/tests/drcp_functions.inc +++ b/ext/oci8/tests/drcp_functions.inc @@ -4,90 +4,90 @@ function drcp_create_table($conn) { - $create_sql = "CREATE TABLE DRCPTEST (id NUMBER, name VARCHAR2(10), dept VARCHAR2(10))"; - $statement = oci_parse($conn, $create_sql); - oci_execute($statement); + $create_sql = "CREATE TABLE DRCPTEST (id NUMBER, name VARCHAR2(10), dept VARCHAR2(10))"; + $statement = oci_parse($conn, $create_sql); + oci_execute($statement); - $id_values = array(100,101,102,103,104,105,106,107,108); - $name_values = array("WIILIAMS","JOHN","SMITH","JONES","ADAMS","ROBERT", - "BILL","LAWSON","MARY"); - $dept_values = array("ACCOUNTS","HR","HR","ADMIN","ACCOUNTS","HR", - "ACCOUNTS","HR","ACCOUNTS"); - for($i=0; $i<8; $i++) { - $insert = "INSERT INTO DRCPTEST VALUES(".$id_values[$i].",'". $name_values[$i]."','".$dept_values[$i]."')"; - $s = oci_parse($conn, $insert); - oci_execute($s); - } + $id_values = array(100,101,102,103,104,105,106,107,108); + $name_values = array("WIILIAMS","JOHN","SMITH","JONES","ADAMS","ROBERT", + "BILL","LAWSON","MARY"); + $dept_values = array("ACCOUNTS","HR","HR","ADMIN","ACCOUNTS","HR", + "ACCOUNTS","HR","ACCOUNTS"); + for($i=0; $i<8; $i++) { + $insert = "INSERT INTO DRCPTEST VALUES(".$id_values[$i].",'". $name_values[$i]."','".$dept_values[$i]."')"; + $s = oci_parse($conn, $insert); + oci_execute($s); + } } function drcp_drop_table($conn) { - $ora_sql = "DROP TABLE DRCPTEST"; - $statement = oci_parse($conn, $ora_sql); - oci_execute($statement); + $ora_sql = "DROP TABLE DRCPTEST"; + $statement = oci_parse($conn, $ora_sql); + oci_execute($statement); } function drcp_update_table($conn) { - $update_stmt ="Update drcptest set dept ='NEWDEPT' where id = 105"; - $s1 = oci_parse($conn,$update_stmt); - oci_execute($s1,OCI_DEFAULT); - echo "Update done-- DEPT value has been set to NEWDEPT\n"; + $update_stmt ="Update drcptest set dept ='NEWDEPT' where id = 105"; + $s1 = oci_parse($conn,$update_stmt); + oci_execute($s1,OCI_DEFAULT); + echo "Update done-- DEPT value has been set to NEWDEPT\n"; } function drcp_select_value($conn) { - $sel_stmt="select dept from drcptest where id=105"; - $s2 = oci_parse($conn,$sel_stmt); - oci_execute($s2,OCI_DEFAULT); - while(oci_fetch($s2)) { - echo "The value of DEPT for id 105 is ".oci_result($s2,1)."\n"; - } + $sel_stmt="select dept from drcptest where id=105"; + $s2 = oci_parse($conn,$sel_stmt); + oci_execute($s2,OCI_DEFAULT); + while(oci_fetch($s2)) { + echo "The value of DEPT for id 105 is ".oci_result($s2,1)."\n"; + } } function drcp_select_packagevar($conn) { - $sel_stmt="select drcp_test_package.f1 as f1 from dual"; - $s2 = oci_parse($conn, $sel_stmt); - oci_define_by_name($s2,'f1',$ret_num); - oci_execute($s2); - while(oci_fetch($s2)) { - echo " The value of the package variable is ".oci_result($s2,1)."\n"; - } + $sel_stmt="select drcp_test_package.f1 as f1 from dual"; + $s2 = oci_parse($conn, $sel_stmt); + oci_define_by_name($s2,'f1',$ret_num); + oci_execute($s2); + while(oci_fetch($s2)) { + echo " The value of the package variable is ".oci_result($s2,1)."\n"; + } } function drcp_set_packagevar($conn,$num) { - $set_stmt = "begin drcp_test_package.p1($num); end;"; - $s1 = oci_parse($conn,$set_stmt); - oci_execute($s1); - echo " Package variable value set to " .$num."\n"; + $set_stmt = "begin drcp_test_package.p1($num); end;"; + $s1 = oci_parse($conn,$set_stmt); + oci_execute($s1); + echo " Package variable value set to " .$num."\n"; } function drcp_create_package($c) { - $create_package_stmt = "create or replace package drcp_test_package as - var int :=0; - procedure p1(var1 int); - function f1 return number; - end;"; - $s1 = oci_parse($c, $create_package_stmt); - oci_execute($s1); + $create_package_stmt = "create or replace package drcp_test_package as + var int :=0; + procedure p1(var1 int); + function f1 return number; + end;"; + $s1 = oci_parse($c, $create_package_stmt); + oci_execute($s1); - $package_body = "create or replace package body drcp_test_package as - procedure p1(var1 int) is - begin - var :=var1; - end; - function f1 return number is - begin - return drcp_test_package.var; - end; - end;"; + $package_body = "create or replace package body drcp_test_package as + procedure p1(var1 int) is + begin + var :=var1; + end; + function f1 return number is + begin + return drcp_test_package.var; + end; + end;"; - $s2 = oci_parse($c, $package_body); - oci_execute($s2); + $s2 = oci_parse($c, $package_body); + oci_execute($s2); } ?> diff --git a/ext/oci8/tests/drcp_newconnect.phpt b/ext/oci8/tests/drcp_newconnect.phpt index cf4b6de17b53..3c41edbb738a 100644 --- a/ext/oci8/tests/drcp_newconnect.phpt +++ b/ext/oci8/tests/drcp_newconnect.phpt @@ -24,9 +24,9 @@ $rn2 = (int)$c2; // rn1 and rn2 should be different. if ($rn1 === $rn2) - echo "First and second connections share a resource: Not OK\n"; + echo "First and second connections share a resource: Not OK\n"; else - echo "First and second connections are different OK\n"; + echo "First and second connections are different OK\n"; // Close the connections oci_close($c1); diff --git a/ext/oci8/tests/drcp_pconn_close1.phpt b/ext/oci8/tests/drcp_pconn_close1.phpt index df0caa2433dc..e4849169aefb 100644 --- a/ext/oci8/tests/drcp_pconn_close1.phpt +++ b/ext/oci8/tests/drcp_pconn_close1.phpt @@ -29,9 +29,9 @@ oci_close($conn2); // Compare the resource numbers if ($rn1 === $rn2) - echo "Both connections share a resource : OK\n"; + echo "Both connections share a resource : OK\n"; else - echo "Both connections are different : NOT OK\n"; + echo "Both connections are different : NOT OK\n"; echo "Done\n"; diff --git a/ext/oci8/tests/drcp_pconn_close2.phpt b/ext/oci8/tests/drcp_pconn_close2.phpt index 02bed683582c..4961cb9545d8 100644 --- a/ext/oci8/tests/drcp_pconn_close2.phpt +++ b/ext/oci8/tests/drcp_pconn_close2.phpt @@ -31,9 +31,9 @@ oci_close($conn2); // Compare the resource numbers if ($rn1 === $rn2) - echo "Both connections share a resource : NOT OK\n"; + echo "Both connections share a resource : NOT OK\n"; else - echo "Both connections are different : OK\n"; + echo "Both connections are different : OK\n"; echo "Done\n"; diff --git a/ext/oci8/tests/drcp_scope1.phpt b/ext/oci8/tests/drcp_scope1.phpt index 78e2e900c935..807c352a2029 100644 --- a/ext/oci8/tests/drcp_scope1.phpt +++ b/ext/oci8/tests/drcp_scope1.phpt @@ -42,32 +42,32 @@ function2($user,$password,$dbase,$conn_type); function function1($user,$password,$dbase,$conn_type) { - switch($conn_type) - { - case 1: - var_dump($conn1 = oci_new_connect($user,$password,$dbase)); - break; - case 2: - var_dump($conn1 = oci_connect($user,$password,$dbase)); - break; - } - drcp_update_table($conn1); + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_update_table($conn1); } // This is the second scope function function2($user,$password,$dbase,$conn_type) { - switch($conn_type) - { - case 1: - var_dump($conn1 = oci_new_connect($user,$password,$dbase)); - break; - case 2: - var_dump($conn1 = oci_connect($user,$password,$dbase)); - break; - } - drcp_select_value($conn1); + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_select_value($conn1); } drcp_drop_table($c); diff --git a/ext/oci8/tests/drcp_scope2.phpt b/ext/oci8/tests/drcp_scope2.phpt index 05a4c558ec98..99e102075d49 100644 --- a/ext/oci8/tests/drcp_scope2.phpt +++ b/ext/oci8/tests/drcp_scope2.phpt @@ -42,32 +42,32 @@ function2($user,$password,$dbase,$conn_type); function function1($user,$password,$dbase,$conn_type) { - switch($conn_type) - { - case 1: - var_dump($conn1 = oci_new_connect($user,$password,$dbase)); - break; - case 2: - var_dump($conn1 = oci_connect($user,$password,$dbase)); - break; - } - drcp_update_table($conn1); + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_update_table($conn1); } // This is the second scope function function2($user,$password,$dbase,$conn_type) { - switch($conn_type) - { - case 1: - var_dump($conn1 = oci_new_connect($user,$password,$dbase)); - break; - case 2: - var_dump($conn1 = oci_connect($user,$password,$dbase)); - break; - } - drcp_select_value($conn1); + switch($conn_type) + { + case 1: + var_dump($conn1 = oci_new_connect($user,$password,$dbase)); + break; + case 2: + var_dump($conn1 = oci_connect($user,$password,$dbase)); + break; + } + drcp_select_value($conn1); } drcp_drop_table($c); oci_close($c); diff --git a/ext/oci8/tests/drcp_scope3.phpt b/ext/oci8/tests/drcp_scope3.phpt index 975f87bed989..8d97d48e998b 100644 --- a/ext/oci8/tests/drcp_scope3.phpt +++ b/ext/oci8/tests/drcp_scope3.phpt @@ -32,16 +32,16 @@ function2($user,$password,$dbase); function function1($user,$password,$dbase) { - var_dump($c = oci_pconnect($user,$password,$dbase)); - drcp_update_table($c); + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_update_table($c); } // This is the second scope function function2($user,$password,$dbase) { - var_dump($c = oci_pconnect($user,$password,$dbase)); - drcp_select_value($c); + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_select_value($c); } drcp_drop_table($c); diff --git a/ext/oci8/tests/drcp_scope4.phpt b/ext/oci8/tests/drcp_scope4.phpt index dced1c3f1c14..abc631a43775 100644 --- a/ext/oci8/tests/drcp_scope4.phpt +++ b/ext/oci8/tests/drcp_scope4.phpt @@ -35,16 +35,16 @@ function2($user,$password,$dbase); function function1($user,$password,$dbase) { - var_dump($c = oci_pconnect($user,$password,$dbase)); - drcp_update_table($c); + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_update_table($c); } // This is the second scope function function2($user,$password,$dbase) { - var_dump($c = oci_pconnect($user,$password,$dbase)); - drcp_select_value($c); + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_select_value($c); } drcp_drop_table($c); diff --git a/ext/oci8/tests/drcp_scope5.phpt b/ext/oci8/tests/drcp_scope5.phpt index d3ccb56da067..b84853423a0b 100644 --- a/ext/oci8/tests/drcp_scope5.phpt +++ b/ext/oci8/tests/drcp_scope5.phpt @@ -35,17 +35,17 @@ function2($user,$password,$dbase); function function1($user,$password,$dbase) { - var_dump($c = oci_pconnect($user,$password,$dbase)); - drcp_update_table($c); + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_update_table($c); } // This is the second scope function function2($user,$password,$dbase) { - var_dump($c = oci_pconnect($user,$password,$dbase)); - drcp_select_value($c); - oci_commit($c); + var_dump($c = oci_pconnect($user,$password,$dbase)); + drcp_select_value($c); + oci_commit($c); } drcp_drop_table($c); diff --git a/ext/oci8/tests/driver_name.phpt b/ext/oci8/tests/driver_name.phpt index 29b2cef52058..c9d1181ef6ea 100644 --- a/ext/oci8/tests/driver_name.phpt +++ b/ext/oci8/tests/driver_name.phpt @@ -43,7 +43,7 @@ echo "Done\n"; function get_attr($conn) { - $sel_stmt = "select client_driver + $sel_stmt = "select client_driver from v\$session_connect_info sci, v\$session s where sci.client_driver is not null and sci.sid = s.sid diff --git a/ext/oci8/tests/driver_name_11gR2.phpt b/ext/oci8/tests/driver_name_11gR2.phpt index bb82b92fa3b4..6eb2e0d6e7cf 100644 --- a/ext/oci8/tests/driver_name_11gR2.phpt +++ b/ext/oci8/tests/driver_name_11gR2.phpt @@ -40,7 +40,7 @@ echo "Done\n"; function get_attr($conn) { - $sel_stmt = "select client_driver + $sel_stmt = "select client_driver from v\$session_connect_info sci, v\$session s where sci.client_driver is not null and sci.sid = s.sid diff --git a/ext/oci8/tests/edition_1.phpt b/ext/oci8/tests/edition_1.phpt index 9bdf699a70ab..b75dfe4350f0 100644 --- a/ext/oci8/tests/edition_1.phpt +++ b/ext/oci8/tests/edition_1.phpt @@ -39,11 +39,11 @@ $testpassword = 'testuser'; require(__DIR__."/conn_attr.inc"); function select_fn($conn) { - $s = oci_parse($conn,"select * from view_ed"); - oci_execute($s); - while ($row = oci_fetch_row($s)) { - var_dump($row); - } + $s = oci_parse($conn,"select * from view_ed"); + oci_execute($s); + while ($row = oci_fetch_row($s)) { + var_dump($row); + } } /* Create a editon MYEDITION create a view view_ed in MYEDITION1. diff --git a/ext/oci8/tests/edition_2.phpt b/ext/oci8/tests/edition_2.phpt index 1aebe1a03b0e..a556fb4a17d8 100644 --- a/ext/oci8/tests/edition_2.phpt +++ b/ext/oci8/tests/edition_2.phpt @@ -87,12 +87,12 @@ oci_close($c5); echo "\n\n**Test 1.4 - with different type of values *********\n"; $values_array = array(123,NULL,'NO EDITION','edition name which has more than thirty chars!!!edition name which has more than thirty chars!!!'); foreach ($values_array as $val ) { - set_edit_attr($val); - $c1 = get_conn(1); //oci_connect() - if ($c1) { - get_edit_attr($c1); - oci_close($c1); - } + set_edit_attr($val); + $c1 = get_conn(1); //oci_connect() + if ($c1) { + get_edit_attr($c1); + oci_close($c1); + } } echo "\n\n**Test 1.5 - Negative case with an invalid string value. *********\n"; @@ -149,7 +149,7 @@ echo "Done\n"; function set_scope() { - $r = set_edit_attr('MYEDITION1'); + $r = set_edit_attr('MYEDITION1'); } function get_scope() { @@ -158,8 +158,8 @@ function get_scope() { $m = oci_error(); die("Error:" . $m['message']); } - get_edit_attr($sc1); - oci_close($sc1); + get_edit_attr($sc1); + oci_close($sc1); } ?> --EXPECTF-- diff --git a/ext/oci8/tests/error_parse.phpt b/ext/oci8/tests/error_parse.phpt index 199282661847..548ed3bfc0ea 100644 --- a/ext/oci8/tests/error_parse.phpt +++ b/ext/oci8/tests/error_parse.phpt @@ -15,49 +15,49 @@ require(__DIR__.'/details.inc'); // Test parse error for normal connection if (!empty($dbase)) { - $c1 = oci_connect($user,$password,$dbase); + $c1 = oci_connect($user,$password,$dbase); } else { - $c1 = oci_connect($user,$password); + $c1 = oci_connect($user,$password); } $s = @oci_parse($c1, "select ' from dual"); if (!$s) { - echo "Normal connection: Parse error\n"; - $m = oci_error($c1); - var_dump($m); + echo "Normal connection: Parse error\n"; + $m = oci_error($c1); + var_dump($m); } // Test parse error for new connection if (!empty($dbase)) { - $c2 = oci_new_connect($user,$password,$dbase); + $c2 = oci_new_connect($user,$password,$dbase); } else { - $c2 = oci_new_connect($user,$password); + $c2 = oci_new_connect($user,$password); } $s = @oci_parse($c2, "select ' from dual"); if (!$s) { - echo "New connection: Parse error\n"; - $m = oci_error($c2); - var_dump($m); + echo "New connection: Parse error\n"; + $m = oci_error($c2); + var_dump($m); } // Test parse error for persistent connection if (!empty($dbase)) { - $c3 = oci_pconnect($user,$password,$dbase); + $c3 = oci_pconnect($user,$password,$dbase); } else { - $c3 = oci_pconnect($user,$password); + $c3 = oci_pconnect($user,$password); } $s = @oci_parse($c3, "select ' from dual"); if (!$s) { - echo "Persistent connection: Parse error\n"; - $m = oci_error($c3); - var_dump($m); + echo "Persistent connection: Parse error\n"; + $m = oci_error($c3); + var_dump($m); } // Verify that passing no connection doesn't affect future calls diff --git a/ext/oci8/tests/extauth_01.phpt b/ext/oci8/tests/extauth_01.phpt index f90562d11869..db23097d82d5 100644 --- a/ext/oci8/tests/extauth_01.phpt +++ b/ext/oci8/tests/extauth_01.phpt @@ -18,8 +18,8 @@ echo "Test 1\n"; $c = oci_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -27,8 +27,8 @@ echo "Test 2\n"; $c = oci_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -36,8 +36,8 @@ echo "Test 3\n"; $c = oci_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -45,8 +45,8 @@ echo "Test 4\n"; $c = oci_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -54,8 +54,8 @@ echo "Test 5\n"; $c = oci_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -63,8 +63,8 @@ echo "Test 6\n"; $c = oci_connect('', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -72,8 +72,8 @@ echo "Test 7\n"; $c = oci_connect('/', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -81,8 +81,8 @@ echo "Test 8\n"; $c = oci_connect('/', null, 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -90,8 +90,8 @@ echo "Test 9\n"; $c = oci_connect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -99,8 +99,8 @@ echo "Test 10\n"; $c = oci_connect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); diff --git a/ext/oci8/tests/extauth_02.phpt b/ext/oci8/tests/extauth_02.phpt index 11b522e4d76b..c8c3dd672533 100644 --- a/ext/oci8/tests/extauth_02.phpt +++ b/ext/oci8/tests/extauth_02.phpt @@ -17,8 +17,8 @@ echo "Test 1\n"; $c = oci_new_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -26,8 +26,8 @@ echo "Test 2\n"; $c = oci_new_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -35,8 +35,8 @@ echo "Test 3\n"; $c = oci_new_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -44,8 +44,8 @@ echo "Test 4\n"; $c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -53,8 +53,8 @@ echo "Test 5\n"; $c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -62,8 +62,8 @@ echo "Test 6\n"; $c = oci_new_connect('', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -71,8 +71,8 @@ echo "Test 7\n"; $c = oci_new_connect('/', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -80,8 +80,8 @@ echo "Test 8\n"; $c = oci_new_connect('/', null, 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -89,8 +89,8 @@ echo "Test 9\n"; $c = oci_new_connect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -98,8 +98,8 @@ echo "Test 10\n"; $c = oci_new_connect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); diff --git a/ext/oci8/tests/extauth_03.phpt b/ext/oci8/tests/extauth_03.phpt index 7cb80e261e92..863f94499b4f 100644 --- a/ext/oci8/tests/extauth_03.phpt +++ b/ext/oci8/tests/extauth_03.phpt @@ -17,8 +17,8 @@ echo "Test 1\n"; $c = oci_pconnect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -26,8 +26,8 @@ echo "Test 2\n"; $c = oci_pconnect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -35,8 +35,8 @@ echo "Test 3\n"; $c = oci_pconnect('notemtpy', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -44,8 +44,8 @@ echo "Test 4\n"; $c = oci_pconnect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -53,8 +53,8 @@ echo "Test 5\n"; $c = oci_pconnect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -62,8 +62,8 @@ echo "Test 6\n"; $c = oci_pconnect('', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -71,8 +71,8 @@ echo "Test 7\n"; $c = oci_pconnect('/', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -80,8 +80,8 @@ echo "Test 8\n"; $c = oci_pconnect('/', null, 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -89,8 +89,8 @@ echo "Test 9\n"; $c = oci_pconnect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -98,8 +98,8 @@ echo "Test 10\n"; $c = oci_pconnect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); diff --git a/ext/oci8/tests/extauth_04.phpt b/ext/oci8/tests/extauth_04.phpt index edb2fbd9123c..5f4e64fc84a3 100644 --- a/ext/oci8/tests/extauth_04.phpt +++ b/ext/oci8/tests/extauth_04.phpt @@ -14,8 +14,8 @@ echo "Test 1\n"; $c = oci_connect('/', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -23,8 +23,8 @@ echo "Test 2\n"; $c = oci_new_connect('/', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); @@ -32,8 +32,8 @@ echo "Test 3\n"; $c = oci_pconnect('/', '', 'anything', null, OCI_CRED_EXT); if (!$c) { - $m = oci_error(); - var_dump($m); + $m = oci_error(); + var_dump($m); } var_dump($c); diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt index eeba992db216..eae30bad23a9 100644 --- a/ext/oci8/tests/fetch.phpt +++ b/ext/oci8/tests/fetch.phpt @@ -22,18 +22,18 @@ oci8_test_sql_execute($c, $stmtarray); // Run Test if (!($s = oci_parse($c, "select * from fetch_tab"))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while(ocifetch($s)) { - $row = ociresult($s, 1); - $row1 = ociresult($s, 2); - var_dump($row); - var_dump($row1); + $row = ociresult($s, 1); + $row1 = ociresult($s, 2); + var_dump($row); + var_dump($row1); } // Cleanup diff --git a/ext/oci8/tests/fetch_all1.phpt b/ext/oci8/tests/fetch_all1.phpt index 2d27f8e02b8e..b531364109fc 100644 --- a/ext/oci8/tests/fetch_all1.phpt +++ b/ext/oci8/tests/fetch_all1.phpt @@ -20,19 +20,19 @@ $stmtarray = array( oci8_test_sql_execute($c, $stmtarray); if (!($s = oci_parse($c, "select * from fetch_all_tab"))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } /* oci_fetch_all */ if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch_all($s, $all)); var_dump($all); /* ocifetchstatement */ if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(ocifetchstatement($s, $all)); diff --git a/ext/oci8/tests/fetch_all2.phpt b/ext/oci8/tests/fetch_all2.phpt index cafd0eb5096b..c9f5175c58a4 100644 --- a/ext/oci8/tests/fetch_all2.phpt +++ b/ext/oci8/tests/fetch_all2.phpt @@ -16,7 +16,7 @@ $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)"; $s = oci_parse($c, $insert_sql); for ($i = 0; $i<3; $i++) { - oci_execute($s); + oci_execute($s); } oci_commit($c); diff --git a/ext/oci8/tests/fetch_all4.phpt b/ext/oci8/tests/fetch_all4.phpt index 4edc82069817..039cb9ff4747 100644 --- a/ext/oci8/tests/fetch_all4.phpt +++ b/ext/oci8/tests/fetch_all4.phpt @@ -10,9 +10,9 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table fetch_all4_tab", - "create table fetch_all4_tab (mycol1 number, mycol2 varchar2(20))", - "insert into fetch_all4_tab values (1, 'abc')" + "drop table fetch_all4_tab", + "create table fetch_all4_tab (mycol1 number, mycol2 varchar2(20))", + "insert into fetch_all4_tab values (1, 'abc')" ); oci8_test_sql_execute($c, $stmtarray); @@ -39,7 +39,7 @@ var_dump($row); // Clean up $stmtarray = array( - "drop table fetch_all4_tab" + "drop table fetch_all4_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/fetch_all5.phpt b/ext/oci8/tests/fetch_all5.phpt index e8e1ba475737..86d451c98bb5 100644 --- a/ext/oci8/tests/fetch_all5.phpt +++ b/ext/oci8/tests/fetch_all5.phpt @@ -10,11 +10,11 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table fetch_all5_tab", - "create table fetch_all5_tab (mycol1 number, mycol2 varchar2(20))", - "insert into fetch_all5_tab values (1, 'abc')", - "insert into fetch_all5_tab values (2, 'def')", - "insert into fetch_all5_tab values (3, 'ghi')" + "drop table fetch_all5_tab", + "create table fetch_all5_tab (mycol1 number, mycol2 varchar2(20))", + "insert into fetch_all5_tab values (1, 'abc')", + "insert into fetch_all5_tab values (2, 'def')", + "insert into fetch_all5_tab values (3, 'ghi')" ); oci8_test_sql_execute($c, $stmtarray); @@ -48,7 +48,7 @@ var_dump($res); // Clean up $stmtarray = array( - "drop table fetch_all5_tab" + "drop table fetch_all5_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/fetch_array.phpt b/ext/oci8/tests/fetch_array.phpt index b7f327dcd40e..ff74ad767397 100644 --- a/ext/oci8/tests/fetch_array.phpt +++ b/ext/oci8/tests/fetch_array.phpt @@ -14,17 +14,17 @@ require __DIR__.'/create_table.inc'; $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } for ($i = 0; $i<3; $i++) { - if (!oci_execute($s)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } } if (!oci_commit($c)) { - die("oci_commit() failed!\n"); + die("oci_commit() failed!\n"); } echo "Test 1\n"; @@ -32,68 +32,68 @@ echo "Test 1\n"; $select_sql = "SELECT * FROM ".$schema."".$table_name.""; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s)) { - var_dump($row); + var_dump($row); } echo "Test 2\n"; if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s, OCI_NUM)) { - var_dump($row); + var_dump($row); } echo "Test 3\n"; if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s, OCI_ASSOC)) { - var_dump($row); + var_dump($row); } echo "Test 4\n"; if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s, OCI_BOTH)) { - var_dump($row); + var_dump($row); } echo "Test 5\n"; if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s, OCI_RETURN_LOBS)) { - var_dump($row); + var_dump($row); } echo "Test 6\n"; if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s, OCI_RETURN_NULLS)) { - var_dump($row); + var_dump($row); } echo "Test 7\n"; if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) { - var_dump($row); + var_dump($row); } require __DIR__.'/drop_table.inc'; diff --git a/ext/oci8/tests/fetch_assoc.phpt b/ext/oci8/tests/fetch_assoc.phpt index e891858efab7..bf0c1a0f1891 100644 --- a/ext/oci8/tests/fetch_assoc.phpt +++ b/ext/oci8/tests/fetch_assoc.phpt @@ -8,11 +8,11 @@ oci_fetch_assoc() require __DIR__."/connect.inc"; $stmtarray = array( - "drop table fetch_assoc_tab", - "create table fetch_assoc_tab (id number, value number, dummy varchar2(20))", - "insert into fetch_assoc_tab values (1,1,null)", - "insert into fetch_assoc_tab values (1,1,null)", - "insert into fetch_assoc_tab values (1,1,null)" + "drop table fetch_assoc_tab", + "create table fetch_assoc_tab (id number, value number, dummy varchar2(20))", + "insert into fetch_assoc_tab values (1,1,null)", + "insert into fetch_assoc_tab values (1,1,null)", + "insert into fetch_assoc_tab values (1,1,null)" ); oci8_test_sql_execute($c, $stmtarray); @@ -20,20 +20,20 @@ oci8_test_sql_execute($c, $stmtarray); $select_sql = "select * from fetch_assoc_tab"; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_assoc($s)) { - var_dump($row); + var_dump($row); } // Clean up $stmtarray = array( - "drop table fetch_assoc_tab" + "drop table fetch_assoc_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt index 04f6743a75b4..634e7379ef05 100644 --- a/ext/oci8/tests/fetch_into.phpt +++ b/ext/oci8/tests/fetch_into.phpt @@ -22,19 +22,19 @@ oci8_test_sql_execute($c, $stmtarray); // Run Test if (!($s = oci_parse($c, "select * from fetch_into_tab"))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } /* ocifetchinto */ if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(ocifetchinto($s, $all)); var_dump($all); /* ocifetchinto */ if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(ocifetchinto($s, $all, OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS)); var_dump($all); diff --git a/ext/oci8/tests/fetch_into1.phpt b/ext/oci8/tests/fetch_into1.phpt index 97e511869e11..27591eaa9761 100644 --- a/ext/oci8/tests/fetch_into1.phpt +++ b/ext/oci8/tests/fetch_into1.phpt @@ -14,27 +14,27 @@ require __DIR__.'/create_table.inc'; $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, string) VALUES (1, 1, NULL)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } for ($i = 0; $i<20; $i++) { - if (!oci_execute($s)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } } if (!oci_commit($c)) { - die("oci_commit() failed!\n"); + die("oci_commit() failed!\n"); } $select_sql = "SELECT * FROM ".$schema."".$table_name.""; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(ocifetchinto($s, $all, OCI_NUM)); var_dump($all); diff --git a/ext/oci8/tests/fetch_into2.phpt b/ext/oci8/tests/fetch_into2.phpt index b79e28235057..8c166e1eca97 100644 --- a/ext/oci8/tests/fetch_into2.phpt +++ b/ext/oci8/tests/fetch_into2.phpt @@ -14,27 +14,27 @@ require __DIR__.'/create_table.inc'; $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value, string) VALUES (1, 1, NULL)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } for ($i = 0; $i<20; $i++) { - if (!oci_execute($s)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } } if (!oci_commit($c)) { - die("oci_commit() failed!\n"); + die("oci_commit() failed!\n"); } $select_sql = "SELECT * FROM ".$schema."".$table_name.""; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(ocifetchinto($s)); var_dump($all); diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt index b50b65d480f4..6dcc1f2c5c3c 100644 --- a/ext/oci8/tests/fetch_row.phpt +++ b/ext/oci8/tests/fetch_row.phpt @@ -22,14 +22,14 @@ oci8_test_sql_execute($c, $stmtarray); // Run Test if (!($s = oci_parse($c, "select * from fetch_row_tab"))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } while ($row = oci_fetch_row($s)) { - var_dump($row); + var_dump($row); } // Cleanup diff --git a/ext/oci8/tests/field_funcs.phpt b/ext/oci8/tests/field_funcs.phpt index 1432dcd4c02d..76ff3d4f9f26 100644 --- a/ext/oci8/tests/field_funcs.phpt +++ b/ext/oci8/tests/field_funcs.phpt @@ -14,41 +14,41 @@ require __DIR__.'/create_table.inc'; $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)"; if (!($s = oci_parse($c, $insert_sql))) { - die("oci_parse(insert) failed!\n"); + die("oci_parse(insert) failed!\n"); } for ($i = 0; $i<3; $i++) { - if (!oci_execute($s)) { - die("oci_execute(insert) failed!\n"); - } + if (!oci_execute($s)) { + die("oci_execute(insert) failed!\n"); + } } if (!oci_commit($c)) { - die("oci_commit() failed!\n"); + die("oci_commit() failed!\n"); } $select_sql = "SELECT * FROM ".$schema."".$table_name.""; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } $row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); var_dump($row); foreach ($row as $num => $field) { - $num++; - var_dump(oci_field_is_null($s, $num)); - var_dump(oci_field_name($s, $num)); - var_dump(oci_field_type($s, $num)); - var_dump(oci_field_type_raw($s, $num)); - var_dump(oci_field_scale($s, $num)); - var_dump(oci_field_precision($s, $num)); - var_dump(oci_field_size($s, $num)); + $num++; + var_dump(oci_field_is_null($s, $num)); + var_dump(oci_field_name($s, $num)); + var_dump(oci_field_type($s, $num)); + var_dump(oci_field_type_raw($s, $num)); + var_dump(oci_field_scale($s, $num)); + var_dump(oci_field_precision($s, $num)); + var_dump(oci_field_size($s, $num)); } diff --git a/ext/oci8/tests/field_funcs2.phpt b/ext/oci8/tests/field_funcs2.phpt index 896a63d11beb..623bc3d835d7 100644 --- a/ext/oci8/tests/field_funcs2.phpt +++ b/ext/oci8/tests/field_funcs2.phpt @@ -11,26 +11,26 @@ $s = oci_parse($c, 'drop table field_funcs2_tab'); @oci_execute($s); $t = array("C01" => "NUMBER", - "C02" => "NUMBER(*,1)", - "C03" => "NUMBER(9)", - "C04" => "NUMBER(9,2)", - "C05" => "NUMBER(9,1)", - "C06" => "NUMBER(7,-2)", - "C07" => "DECIMAL(4,9)", - "C08" => "NUMERIC(4,9)", - "C09" => "DECIMAL(4)", - "C10" => "INTEGER", - "C11" => "INT", - "C12" => "SMALLINT", - "C13" => "FLOAT", - "C14" => "FLOAT(9)", - "C15" => "DOUBLE PRECISION", - "C16" => "REAL", - ); + "C02" => "NUMBER(*,1)", + "C03" => "NUMBER(9)", + "C04" => "NUMBER(9,2)", + "C05" => "NUMBER(9,1)", + "C06" => "NUMBER(7,-2)", + "C07" => "DECIMAL(4,9)", + "C08" => "NUMERIC(4,9)", + "C09" => "DECIMAL(4)", + "C10" => "INTEGER", + "C11" => "INT", + "C12" => "SMALLINT", + "C13" => "FLOAT", + "C14" => "FLOAT(9)", + "C15" => "DOUBLE PRECISION", + "C16" => "REAL", + ); $stmt = "create table field_funcs2_tab (\n"; foreach ($t as $colname => $type) { - $stmt .= "$colname $type,\n"; + $stmt .= "$colname $type,\n"; } $stmt[strlen($stmt)-2] = ")"; @@ -41,10 +41,10 @@ $s = oci_parse($c, "select * from field_funcs2_tab"); oci_execute($s); for ($i = 1; $i <= oci_num_fields($s); $i++) { - $name = oci_field_name($s, $i); - $precision = oci_field_precision($s, $i); - $scale = oci_field_scale($s, $i); - echo "$name ".$t[$name] .": precision $precision, scale $scale\n"; + $name = oci_field_name($s, $i); + $precision = oci_field_precision($s, $i); + $scale = oci_field_scale($s, $i); + echo "$name ".$t[$name] .": precision $precision, scale $scale\n"; } echo "Done\n"; diff --git a/ext/oci8/tests/field_funcs3.phpt b/ext/oci8/tests/field_funcs3.phpt index 965b22497397..75d050321ef5 100644 --- a/ext/oci8/tests/field_funcs3.phpt +++ b/ext/oci8/tests/field_funcs3.phpt @@ -25,31 +25,31 @@ oci8_test_sql_execute($c, $stmtarray); $select_sql = "select * from field_funcs3_tab"; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } $row = oci_fetch_array($s, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); var_dump($row); foreach ($row as $num => $field) { - $num++; - var_dump(oci_field_is_null($s, $num)); - var_dump(oci_field_name($s, $num)); - var_dump(oci_field_type($s, $num)); - var_dump(oci_field_type_raw($s, $num)); - var_dump(oci_field_scale($s, $num)); - var_dump(oci_field_precision($s, $num)); - var_dump(oci_field_size($s, $num)); + $num++; + var_dump(oci_field_is_null($s, $num)); + var_dump(oci_field_name($s, $num)); + var_dump(oci_field_type($s, $num)); + var_dump(oci_field_type_raw($s, $num)); + var_dump(oci_field_scale($s, $num)); + var_dump(oci_field_precision($s, $num)); + var_dump(oci_field_size($s, $num)); } // Clean up $stmtarray = array( - "drop table field_funcs3_tab" + "drop table field_funcs3_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/field_funcs_old.phpt b/ext/oci8/tests/field_funcs_old.phpt index 6417de15cd71..afb6dc62e1d4 100644 --- a/ext/oci8/tests/field_funcs_old.phpt +++ b/ext/oci8/tests/field_funcs_old.phpt @@ -14,41 +14,41 @@ require __DIR__.'/create_table.inc'; $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)"; if (!($s = ociparse($c, $insert_sql))) { - die("ociparse(insert) failed!\n"); + die("ociparse(insert) failed!\n"); } for ($i = 0; $i<3; $i++) { - if (!ociexecute($s)) { - die("ociexecute(insert) failed!\n"); - } + if (!ociexecute($s)) { + die("ociexecute(insert) failed!\n"); + } } if (!ocicommit($c)) { - die("ocicommit() failed!\n"); + die("ocicommit() failed!\n"); } $select_sql = "SELECT * FROM ".$schema."".$table_name.""; if (!($s = ociparse($c, $select_sql))) { - die("ociparse(select) failed!\n"); + die("ociparse(select) failed!\n"); } if (!ociexecute($s)) { - die("ociexecute(select) failed!\n"); + die("ociexecute(select) failed!\n"); } ocifetchinto($s, $row, OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS); var_dump($row); foreach ($row as $num => $field) { - $num++; - var_dump(ocicolumnisnull($s, $num)); - var_dump(ocicolumnname($s, $num)); - var_dump(ocicolumntype($s, $num)); - var_dump(ocicolumntyperaw($s, $num)); - var_dump(ocicolumnscale($s, $num)); - var_dump(ocicolumnprecision($s, $num)); - var_dump(ocicolumnsize($s, $num)); + $num++; + var_dump(ocicolumnisnull($s, $num)); + var_dump(ocicolumnname($s, $num)); + var_dump(ocicolumntype($s, $num)); + var_dump(ocicolumntyperaw($s, $num)); + var_dump(ocicolumnscale($s, $num)); + var_dump(ocicolumnprecision($s, $num)); + var_dump(ocicolumnsize($s, $num)); } diff --git a/ext/oci8/tests/lob_001.phpt b/ext/oci8/tests/lob_001.phpt index 72352ef2cfad..3e9c061ee002 100644 Binary files a/ext/oci8/tests/lob_001.phpt and b/ext/oci8/tests/lob_001.phpt differ diff --git a/ext/oci8/tests/lob_002.phpt b/ext/oci8/tests/lob_002.phpt index d91428522847..156fd668d3ed 100644 --- a/ext/oci8/tests/lob_002.phpt +++ b/ext/oci8/tests/lob_002.phpt @@ -13,8 +13,8 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table lob_002_tab", - "create table lob_002_tab (id number, b1 BLOB)", + "drop table lob_002_tab", + "create table lob_002_tab (id number, b1 BLOB)", ); oci8_test_sql_execute($c, $stmtarray); @@ -47,7 +47,7 @@ var_dump(strlen($row[0])); // Cleanup $stmtarray = array( - "drop table lob_002_tab" + "drop table lob_002_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/lob_008.phpt b/ext/oci8/tests/lob_008.phpt index 53b75302efbf..57fce9513064 100644 --- a/ext/oci8/tests/lob_008.phpt +++ b/ext/oci8/tests/lob_008.phpt @@ -37,7 +37,7 @@ var_dump($row = oci_fetch_array($s)); $len = 0; while (!$row[0]->eof()) { - $len += strlen($row[0]->read(1024)); + $len += strlen($row[0]->read(1024)); } var_dump($len); diff --git a/ext/oci8/tests/lob_009.phpt b/ext/oci8/tests/lob_009.phpt index 090503f9276f..56d2495a622d 100644 --- a/ext/oci8/tests/lob_009.phpt +++ b/ext/oci8/tests/lob_009.phpt @@ -35,7 +35,7 @@ oci_execute($s, OCI_DEFAULT); var_dump($row = oci_fetch_array($s)); while (!$row[0]->eof()) { - var_dump(str_replace("\r", "", $row[0]->read(1024))); + var_dump(str_replace("\r", "", $row[0]->read(1024))); } require __DIR__.'/drop_table.inc'; diff --git a/ext/oci8/tests/lob_010.phpt b/ext/oci8/tests/lob_010.phpt index b4a0a77d1e88..50924e5516b9 100644 --- a/ext/oci8/tests/lob_010.phpt +++ b/ext/oci8/tests/lob_010.phpt @@ -34,7 +34,7 @@ oci_execute($s, OCI_DEFAULT); $row = oci_fetch_array($s); while (!$row[0]->eof()) { - var_dump($row[0]->read(1024)); + var_dump($row[0]->read(1024)); } require __DIR__.'/drop_table.inc'; diff --git a/ext/oci8/tests/lob_018.phpt b/ext/oci8/tests/lob_018.phpt index e61879072650..2feab1a3f387 100644 --- a/ext/oci8/tests/lob_018.phpt +++ b/ext/oci8/tests/lob_018.phpt @@ -13,8 +13,8 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table lob_018_tab", - "create table lob_018_tab (mykey number, lob_1 clob)", + "drop table lob_018_tab", + "create table lob_018_tab (mykey number, lob_1 clob)", ); oci8_test_sql_execute($c, $stmtarray); @@ -45,8 +45,8 @@ $statement = oci_parse ($c, $query); oci_execute($statement, OCI_DEFAULT); while ($row = oci_fetch_array($statement, OCI_ASSOC)) { - $result = $row['LOB_1']->load(); - var_dump($result); + $result = $row['LOB_1']->load(); + var_dump($result); } echo "Test 2\n"; @@ -56,8 +56,8 @@ $statement = oci_parse ($c, $query); oci_execute($statement, OCI_DEFAULT); while ($row = oci_fetch_array($statement, OCI_ASSOC)) { - $result = $row['LOB_1']->load(); - var_dump($result); + $result = $row['LOB_1']->load(); + var_dump($result); } echo "Test 3 - bind with SQLT_CLOB (an alias for OCI_B_CLOB)\n"; @@ -76,8 +76,8 @@ $statement = oci_parse ($c, $query); oci_execute($statement, OCI_DEFAULT); while ($row = oci_fetch_array($statement, OCI_ASSOC)) { - $result = $row['LOB_1']->load(); - var_dump($result); + $result = $row['LOB_1']->load(); + var_dump($result); } // Cleanup diff --git a/ext/oci8/tests/lob_022.phpt b/ext/oci8/tests/lob_022.phpt index 3de78dcd2a90..e353eda52696 100644 --- a/ext/oci8/tests/lob_022.phpt +++ b/ext/oci8/tests/lob_022.phpt @@ -48,8 +48,8 @@ $statement = oci_parse ($c, $query); oci_execute($statement, OCI_DEFAULT); while ($row = oci_fetch_array($statement, OCI_ASSOC)) { - $result = $row['LOB_1']->load(); - var_dump($result); + $result = $row['LOB_1']->load(); + var_dump($result); } $query = 'SELECT * FROM lob_test ORDER BY mykey DESC'; @@ -57,8 +57,8 @@ $statement = oci_parse ($c, $query); oci_execute($statement, OCI_DEFAULT); while ($row = oci_fetch_array($statement, OCI_ASSOC)) { - $result = $row['LOB_1']->load(); - var_dump($result); + $result = $row['LOB_1']->load(); + var_dump($result); } $drop = "DROP table lob_test"; diff --git a/ext/oci8/tests/lob_023.phpt b/ext/oci8/tests/lob_023.phpt index 8093ab63af8e..f8b295a441ec 100644 --- a/ext/oci8/tests/lob_023.phpt +++ b/ext/oci8/tests/lob_023.phpt @@ -40,7 +40,7 @@ oci_execute($s, OCI_DEFAULT); var_dump($row = oci_fetch_array($s)); while (!$row[0]->eof()) { - var_dump(str_replace("\r", "", $row[0]->read(1024))); + var_dump(str_replace("\r", "", $row[0]->read(1024))); } require __DIR__.'/drop_table.inc'; diff --git a/ext/oci8/tests/lob_027.phpt b/ext/oci8/tests/lob_027.phpt index ec759ccb0a9d..ccea9b30cbd0 100644 --- a/ext/oci8/tests/lob_027.phpt +++ b/ext/oci8/tests/lob_027.phpt @@ -39,15 +39,15 @@ oci_commit($c); for ($i = 5; $i >= 0; $i--) { - $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; - $s = oci_parse($c, $select_sql); - oci_execute($s, OCI_DEFAULT); + $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; + $s = oci_parse($c, $select_sql); + oci_execute($s, OCI_DEFAULT); - $row = oci_fetch_array($s); - var_dump($row['BLOB']->load()); - var_dump($row['BLOB']->truncate(($i-1)*10)); + $row = oci_fetch_array($s); + var_dump($row['BLOB']->load()); + var_dump($row['BLOB']->truncate(($i-1)*10)); - oci_commit($c); + oci_commit($c); } $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; diff --git a/ext/oci8/tests/lob_040.phpt b/ext/oci8/tests/lob_040.phpt index 2c0d361a593b..3711c4b54d98 100644 --- a/ext/oci8/tests/lob_040.phpt +++ b/ext/oci8/tests/lob_040.phpt @@ -14,8 +14,8 @@ require(__DIR__.'/connect.inc'); require(__DIR__.'/create_table.inc'); for ($i = 0; $i < NUMLOBS; $i++) { - $s = oci_parse($c, "insert into ".$schema.$table_name." (id, clob) values(".$i.", '".$i."aaaa".$i.$i."aaaaaaaaaaaaaaaaaaaaaaaaaaaz')"); - oci_execute($s); + $s = oci_parse($c, "insert into ".$schema.$table_name." (id, clob) values(".$i.", '".$i."aaaa".$i.$i."aaaaaaaaaaaaaaaaaaaaaaaaaaaz')"); + oci_execute($s); } echo "Test 1: CLOB as locator\n"; @@ -25,15 +25,15 @@ oci_execute($s); $row = array(); for ($i = 0; $i < NUMLOBS; $i++) { - $row[$i] = oci_fetch_array($s, OCI_NUM); + $row[$i] = oci_fetch_array($s, OCI_NUM); } for ($i = 0; $i < NUMLOBS; $i++) { - echo "Row $i Size: " . $row[$i][0]->size() . "\n"; - echo "Pos 1: " . $row[$i][0]->tell() . "\n"; - echo "Data: " . $row[$i][0]->read(5) . "\n"; - echo "Pos 2: " . $row[$i][0]->tell() . "\n"; - echo "Data: " . $row[$i][0]->read(12) . "\n"; + echo "Row $i Size: " . $row[$i][0]->size() . "\n"; + echo "Pos 1: " . $row[$i][0]->tell() . "\n"; + echo "Data: " . $row[$i][0]->read(5) . "\n"; + echo "Pos 2: " . $row[$i][0]->tell() . "\n"; + echo "Data: " . $row[$i][0]->read(12) . "\n"; } echo "Done\n"; diff --git a/ext/oci8/tests/lob_041.phpt b/ext/oci8/tests/lob_041.phpt index dd0bfd58be0f..e2bf5fbaa199 100644 --- a/ext/oci8/tests/lob_041.phpt +++ b/ext/oci8/tests/lob_041.phpt @@ -13,9 +13,9 @@ require __DIR__.'/connect.inc'; // Initialization $stmtarray = array( - "DROP table lob_041_tab", - "CREATE table lob_041_tab(c1 CLOB)", - "INSERT INTO lob_041_tab VALUES('test data')" + "DROP table lob_041_tab", + "CREATE table lob_041_tab(c1 CLOB)", + "INSERT INTO lob_041_tab VALUES('test data')" ); oci8_test_sql_execute($c, $stmtarray); @@ -57,7 +57,7 @@ var_dump($data); echo "Done\n"; $stmtarray = array( - "DROP table lob_041_tab" + "DROP table lob_041_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/lob_043.phpt b/ext/oci8/tests/lob_043.phpt index 32b4ccdbdc9b..c0f8973dfd14 100644 --- a/ext/oci8/tests/lob_043.phpt +++ b/ext/oci8/tests/lob_043.phpt @@ -14,9 +14,9 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table lob_043_tab", - "create table lob_043_tab(id number, c1 clob)", - "begin + "drop table lob_043_tab", + "create table lob_043_tab(id number, c1 clob)", + "begin for i in 1..50000 loop insert into lob_043_tab (id, c1) values (i, i || ' abcdefghijklmnopq'); end loop; @@ -70,7 +70,7 @@ $r = f2($c); // Clean up $stmtarray = array( - "drop table lob_043_tab" + "drop table lob_043_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/lob_044.phpt b/ext/oci8/tests/lob_044.phpt index cec6b126ffd4..242eef195da4 100644 --- a/ext/oci8/tests/lob_044.phpt +++ b/ext/oci8/tests/lob_044.phpt @@ -13,8 +13,8 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table lob_044_tab", - "create table lob_044_tab (blob BLOB)", + "drop table lob_044_tab", + "create table lob_044_tab (blob BLOB)", ); oci8_test_sql_execute($c, $stmtarray); @@ -51,7 +51,7 @@ var_dump($row[0]->read(10000)); // Clean up $stmtarray = array( - "drop table lob_044_tab" + "drop table lob_044_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt index b3f3bfce0c02..1e8d8c83aa19 100644 --- a/ext/oci8/tests/password.phpt +++ b/ext/oci8/tests/password.phpt @@ -14,8 +14,8 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode"); require(__DIR__."/connect.inc"); $stmtarray = array( - "drop user testuser_pw cascade", - "create user testuser_pw identified by testuserpwd", + "drop user testuser_pw cascade", + "create user testuser_pw identified by testuserpwd", "grant connect, create session to testuser_pw" ); @@ -41,21 +41,21 @@ $rn3 = (int)$c3; // Connections should differ if ($rn1 == $rn2) { - echo "First and second connections share a resource: Not OK\n"; - var_dump($c1); + echo "First and second connections share a resource: Not OK\n"; + var_dump($c1); } else { - echo "First and second connections are different: OK\n"; + echo "First and second connections are different: OK\n"; } // Connections should be the same if ($rn1 == $rn3) { - echo "First and third connections share a resource: OK\n"; + echo "First and third connections share a resource: OK\n"; } else { - echo "First and third connections are different: Not OK\n"; - var_dump($c1); - var_dump($c2); + echo "First and third connections are different: Not OK\n"; + var_dump($c1); + var_dump($c2); } echo "Done\n"; diff --git a/ext/oci8/tests/password_2.phpt b/ext/oci8/tests/password_2.phpt index b3e9e3058f9f..b47fad57f39d 100644 --- a/ext/oci8/tests/password_2.phpt +++ b/ext/oci8/tests/password_2.phpt @@ -14,7 +14,7 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode"); require(__DIR__."/connect.inc"); $stmtarray = array( - "drop user testuser_pw2 cascade", + "drop user testuser_pw2 cascade", "create user testuser_pw2 identified by testuserpwd", "grant connect, create session to testuser_pw2" ); @@ -40,21 +40,21 @@ $rn3 = (int)$c3; // Connections should differ if ($rn1 == $rn2) { - echo "First and second connections share a resource: Not OK\n"; - var_dump($c1); + echo "First and second connections share a resource: Not OK\n"; + var_dump($c1); } else { - echo "First and second connections are different: OK\n"; + echo "First and second connections are different: OK\n"; } // Connections should be the same if ($rn1 == $rn3) { - echo "First and third connections share a resource: OK\n"; + echo "First and third connections share a resource: OK\n"; } else { - echo "First and third connections are different: Not OK\n"; - var_dump($c1); - var_dump($c2); + echo "First and third connections are different: Not OK\n"; + var_dump($c1); + var_dump($c2); } echo "Done\n"; diff --git a/ext/oci8/tests/pecl_bug10194.phpt b/ext/oci8/tests/pecl_bug10194.phpt index c0265af34fde..d4b0707abc21 100644 --- a/ext/oci8/tests/pecl_bug10194.phpt +++ b/ext/oci8/tests/pecl_bug10194.phpt @@ -34,7 +34,7 @@ $row = oci_fetch_assoc($statement); $string = str_repeat("test", 32768*4*4); for ($i = 0; $i < 8; $i++) { - $row['CLOB']->write($string); + $row['CLOB']->write($string); } oci_commit($c); diff --git a/ext/oci8/tests/pecl_bug6109.phpt b/ext/oci8/tests/pecl_bug6109.phpt index f5cee7065d81..b529058ff87a 100644 --- a/ext/oci8/tests/pecl_bug6109.phpt +++ b/ext/oci8/tests/pecl_bug6109.phpt @@ -15,12 +15,12 @@ $s = oci_parse($c, 'delete from table_does_not_exist'); $r = @oci_execute($s); if ($r) { - echo "whoops - table does exist\n"; + echo "whoops - table does exist\n"; } else { - for ($i = 0; $i < 5; $i++) { - $err = oci_error($s); - echo ($i) .' -> '.$err['message'] ."\n"; - } + for ($i = 0; $i < 5; $i++) { + $err = oci_error($s); + echo ($i) .' -> '.$err['message'] ."\n"; + } } // Cleanup diff --git a/ext/oci8/tests/pecl_bug8816.phpt b/ext/oci8/tests/pecl_bug8816.phpt index 30b76265dcdf..dda6b9f8b108 100644 --- a/ext/oci8/tests/pecl_bug8816.phpt +++ b/ext/oci8/tests/pecl_bug8816.phpt @@ -29,17 +29,17 @@ $values = array("1234567890111111111", "122222222222222", "985456745674567654567 $i = 0; foreach ($values as $val) { - $i++; - $insert = "INSERT INTO t1 VALUES($i, ".$val.")"; - $s = oci_parse($c, $insert); - oci_execute($s); + $i++; + $insert = "INSERT INTO t1 VALUES($i, ".$val.")"; + $s = oci_parse($c, $insert); + oci_execute($s); } foreach ($values as $val) { - $insert = "INSERT INTO t2 VALUES($i, ".$val.")"; - $s = oci_parse($c, $insert); - oci_execute($s); - $i--; + $insert = "INSERT INTO t2 VALUES($i, ".$val.")"; + $s = oci_parse($c, $insert); + oci_execute($s); + $i--; } $query =" @@ -56,7 +56,7 @@ $sth = oci_parse($c, $query); oci_execute($sth); while ( $row = oci_fetch_assoc($sth) ) { - var_dump($row); + var_dump($row); } $s1 = oci_parse($c, $drop_1); diff --git a/ext/oci8/tests/prefetch.phpt b/ext/oci8/tests/prefetch.phpt index fa71b5ac6a65..2bf1153adaf5 100644 --- a/ext/oci8/tests/prefetch.phpt +++ b/ext/oci8/tests/prefetch.phpt @@ -24,13 +24,13 @@ oci8_test_sql_execute($c, $stmtarray); $select_sql = "select * from prefetch_tab"; if (!($s = oci_parse($c, $select_sql))) { - die("oci_parse(select) failed!\n"); + die("oci_parse(select) failed!\n"); } var_dump(oci_set_prefetch($s, 10)); if (!oci_execute($s)) { - die("oci_execute(select) failed!\n"); + die("oci_execute(select) failed!\n"); } var_dump(oci_fetch($s)); diff --git a/ext/oci8/tests/prefetch_old.phpt b/ext/oci8/tests/prefetch_old.phpt index 58bdae756589..1fdf01305e6d 100644 --- a/ext/oci8/tests/prefetch_old.phpt +++ b/ext/oci8/tests/prefetch_old.phpt @@ -20,19 +20,19 @@ oci8_test_sql_execute($c, $stmtarray); // Run Test if (!ocicommit($c)) { - die("ocicommit() failed!\n"); + die("ocicommit() failed!\n"); } $select_sql = "select * from prefetch_old_tab"; if (!($s = ociparse($c, $select_sql))) { - die("ociparse(select) failed!\n"); + die("ociparse(select) failed!\n"); } var_dump(ocisetprefetch($s, 10)); if (!ociexecute($s)) { - die("ociexecute(select) failed!\n"); + die("ociexecute(select) failed!\n"); } var_dump(ocifetch($s)); diff --git a/ext/oci8/tests/refcur_prefetch_1.phpt b/ext/oci8/tests/refcur_prefetch_1.phpt index 1f00b9b031b8..911a4810633f 100644 --- a/ext/oci8/tests/refcur_prefetch_1.phpt +++ b/ext/oci8/tests/refcur_prefetch_1.phpt @@ -23,25 +23,25 @@ require(__DIR__."/connect.inc"); // Creates the necessary package and tables. $stmtarray = array( - "DROP TABLE refcurtest", - "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", + "DROP TABLE refcurtest", + "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", "CREATE or REPLACE PACKAGE refcurpkg is type refcursortype is ref cursor; procedure open_ref_cur(cur1 out refcursortype); procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2); end refcurpkg;", "CREATE or REPLACE PACKAGE body refcurpkg is - procedure open_ref_cur(cur1 out refcursortype) is + procedure open_ref_cur(cur1 out refcursortype) is begin - open cur1 for select * from refcurtest order by c1; - end open_ref_cur; - procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, - c2 out varchar2) is - begin - fetch cur1 into c1,c2; - end fetch_ref_cur; + open cur1 for select * from refcurtest order by c1; + end open_ref_cur; + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, + c2 out varchar2) is + begin + fetch cur1 into c1,c2; + end fetch_ref_cur; end refcurpkg;" - ); + ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/refcur_prefetch_2.phpt b/ext/oci8/tests/refcur_prefetch_2.phpt index 10f0764a7a71..69146914a4bf 100644 --- a/ext/oci8/tests/refcur_prefetch_2.phpt +++ b/ext/oci8/tests/refcur_prefetch_2.phpt @@ -23,25 +23,25 @@ require __DIR__."/connect.inc"; // Creates the necessary package and tables. $stmtarray = array( - "DROP TABLE refcurtest", - "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", + "DROP TABLE refcurtest", + "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", "CREATE or REPLACE PACKAGE refcurpkg is type refcursortype is ref cursor; procedure open_ref_cur(cur1 out refcursortype); procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2); end refcurpkg;", "CREATE or REPLACE PACKAGE body refcurpkg is - procedure open_ref_cur(cur1 out refcursortype) is + procedure open_ref_cur(cur1 out refcursortype) is begin - open cur1 for select * from refcurtest order by c1; - end open_ref_cur; - procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, - c2 out varchar2) is - begin - fetch cur1 into c1,c2; - end fetch_ref_cur; + open cur1 for select * from refcurtest order by c1; + end open_ref_cur; + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, + c2 out varchar2) is + begin + fetch cur1 into c1,c2; + end fetch_ref_cur; end refcurpkg;" - ); + ); oci8_test_sql_execute($c, $stmtarray); @@ -130,7 +130,7 @@ var_dump($c2); function print_roundtrips($c) { $sql_stmt = "select value from v\$mystat a,v\$statname c where - a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; + a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; $s = oci_parse($c,$sql_stmt); oci_define_by_name($s,"VALUE",$value); oci_execute($s); diff --git a/ext/oci8/tests/refcur_prefetch_4.phpt b/ext/oci8/tests/refcur_prefetch_4.phpt index 8aee48cfeed4..6c0b1b26d077 100644 --- a/ext/oci8/tests/refcur_prefetch_4.phpt +++ b/ext/oci8/tests/refcur_prefetch_4.phpt @@ -23,9 +23,9 @@ require __DIR__."/connect.inc"; // Creates the necessary package and tables. $stmtarray = array( - "DROP TABLE refcurtest", + "DROP TABLE refcurtest", - "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", + "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))", "CREATE or REPLACE PACKAGE refcurpkg is type refcursortype is ref cursor; @@ -34,16 +34,16 @@ $stmtarray = array( end refcurpkg;", "CREATE or REPLACE PACKAGE body refcurpkg is - procedure open_ref_cur(cur1 out refcursortype) is + procedure open_ref_cur(cur1 out refcursortype) is begin - open cur1 for select * from refcurtest order by c1; - end open_ref_cur; - procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, c2 out varchar2) is - begin - fetch cur1 into c1,c2; - end fetch_ref_cur; + open cur1 for select * from refcurtest order by c1; + end open_ref_cur; + procedure fetch_ref_cur(cur1 in refcursortype, c1 out number, c2 out varchar2) is + begin + fetch cur1 into c1,c2; + end fetch_ref_cur; end refcurpkg;" - ); + ); oci8_test_sql_execute($c, $stmtarray); @@ -134,7 +134,7 @@ var_dump($c2); function print_roundtrips($c) { $sql_stmt = "select value from v\$mystat a,v\$statname c where - a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; + a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'"; $s = oci_parse($c,$sql_stmt); oci_define_by_name($s,"VALUE",$value); oci_execute($s); diff --git a/ext/oci8/tests/serverversion.phpt b/ext/oci8/tests/serverversion.phpt index 2667cc553927..d2a781e6a300 100644 --- a/ext/oci8/tests/serverversion.phpt +++ b/ext/oci8/tests/serverversion.phpt @@ -8,10 +8,10 @@ oci_server_version() require __DIR__."/connect.inc"; if (!empty($dbase)) { - var_dump($c = oci_connect($user, $password, $dbase)); + var_dump($c = oci_connect($user, $password, $dbase)); } else { - var_dump($c = oci_connect($user, $password)); + var_dump($c = oci_connect($user, $password)); } $v = oci_server_version($c); diff --git a/ext/oci8/tests/statement_type.phpt b/ext/oci8/tests/statement_type.phpt index e294cac60ec0..d8e67727503a 100644 --- a/ext/oci8/tests/statement_type.phpt +++ b/ext/oci8/tests/statement_type.phpt @@ -12,8 +12,8 @@ $sqls = Array( "DELETE FROM table WHERE id = 1", "INSERT INTO table VALUES(1)", "UPDATE table SET id = 1", - "DROP TABLE table", - "CREATE OR REPLACE PROCEDURE myproc(v1 NUMBER) as BEGIN DBMS_OUTPUT.PUT_LINE(v1); END;", + "DROP TABLE table", + "CREATE OR REPLACE PROCEDURE myproc(v1 NUMBER) as BEGIN DBMS_OUTPUT.PUT_LINE(v1); END;", "CREATE TABLE table (id NUMBER)", "ALTER TABLE table ADD (col1 NUMBER)", "BEGIN NULL; END;", @@ -24,8 +24,8 @@ $sqls = Array( ); foreach ($sqls as $sql) { - $s = oci_parse($c, $sql); - var_dump(oci_statement_type($s)); + $s = oci_parse($c, $sql); + var_dump(oci_statement_type($s)); } echo "Done\n"; diff --git a/ext/oci8/tests/statement_type_old.phpt b/ext/oci8/tests/statement_type_old.phpt index aa0565e27bf7..b095bc245f0c 100644 --- a/ext/oci8/tests/statement_type_old.phpt +++ b/ext/oci8/tests/statement_type_old.phpt @@ -8,10 +8,10 @@ ocistatementtype() require __DIR__."/connect.inc"; if (!empty($dbase)) { - var_dump($c = ocilogon($user, $password, $dbase)); + var_dump($c = ocilogon($user, $password, $dbase)); } else { - var_dump($c = ocilogon($user, $password)); + var_dump($c = ocilogon($user, $password)); } $sqls = Array( @@ -19,8 +19,8 @@ $sqls = Array( "DELETE FROM table WHERE id = 1", "INSERT INTO table VALUES(1)", "UPDATE table SET id = 1", - "DROP TABLE table", - "CREATE OR REPLACE PROCEDURE myproc(v1 NUMBER) as BEGIN DBMS_OUTPUT.PUT_LINE(v1); END;", + "DROP TABLE table", + "CREATE OR REPLACE PROCEDURE myproc(v1 NUMBER) as BEGIN DBMS_OUTPUT.PUT_LINE(v1); END;", "CREATE TABLE table (id NUMBER)", "ALTER TABLE table ADD (col1 NUMBER)", "BEGIN NULL; END;", @@ -31,8 +31,8 @@ $sqls = Array( ); foreach ($sqls as $sql) { - $s = ociparse($c, $sql); - var_dump(ocistatementtype($s)); + $s = ociparse($c, $sql); + var_dump(ocistatementtype($s)); } echo "Done\n"; diff --git a/ext/oci8/tests/testping.phpt b/ext/oci8/tests/testping.phpt index 2c64c440d7c0..589b5c21b0dc 100644 --- a/ext/oci8/tests/testping.phpt +++ b/ext/oci8/tests/testping.phpt @@ -10,12 +10,12 @@ oci8.ping_interval=0 require(__DIR__.'/details.inc'); for ($i = 0; $i < 2; $i++) { - if (!empty($dbase)) { - $c = oci_pconnect($user,$password,$dbase); - } - else { - $c = oci_pconnect($user,$password); - } + if (!empty($dbase)) { + $c = oci_pconnect($user,$password,$dbase); + } + else { + $c = oci_pconnect($user,$password); + } } echo "Done\n"; diff --git a/ext/oci8/tests/xmltype_01.phpt b/ext/oci8/tests/xmltype_01.phpt index debbe14f83b6..a99a39223ed0 100644 --- a/ext/oci8/tests/xmltype_01.phpt +++ b/ext/oci8/tests/xmltype_01.phpt @@ -14,37 +14,37 @@ require(__DIR__."/connect.inc"); // Initialization $stmtarray = array( - "drop table xtt", - "create table xtt - (xt_id number, xt_spec xmltype) - xmltype xt_spec store as clob", - "insert into xtt (xt_id, xt_spec) values - (1, - xmltype(' - - 1 - Big - 12345 - 20 - Curved - Red - N - Tiny - Steel - '))" + "drop table xtt", + "create table xtt + (xt_id number, xt_spec xmltype) + xmltype xt_spec store as clob", + "insert into xtt (xt_id, xt_spec) values + (1, + xmltype(' + + 1 + Big + 12345 + 20 + Curved + Red + N + Tiny + Steel + '))" ); oci8_test_sql_execute($c, str_replace("\r", "", $stmtarray)); function do_query($c) { - $s = oci_parse($c, 'select XMLType.getClobVal(xt_spec) - from xtt where xt_id = 1'); - oci_execute($s); - $row = oci_fetch_row($s); - $data = $row[0]->load(); - var_dump($data); - return($data); + $s = oci_parse($c, 'select XMLType.getClobVal(xt_spec) + from xtt where xt_id = 1'); + oci_execute($s); + $row = oci_fetch_row($s); + $data = $row[0]->load(); + var_dump($data); + return($data); } // Check @@ -58,8 +58,8 @@ $sx->Nice = 'Y'; // Insert changes using a temporary CLOB $s = oci_parse($c, 'update xtt - set xt_spec = XMLType(:clob) - where xt_id = 1'); + set xt_spec = XMLType(:clob) + where xt_id = 1'); $lob = oci_new_descriptor($c, OCI_D_LOB); oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB); $lob->writeTemporary($sx->asXml()); @@ -73,7 +73,7 @@ $data = do_query($c); // Cleanup $stmtarray = array( - "drop table xtt", + "drop table xtt", ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/xmltype_02.phpt b/ext/oci8/tests/xmltype_02.phpt index 7e11654b4db5..6b701b0c93fe 100644 --- a/ext/oci8/tests/xmltype_02.phpt +++ b/ext/oci8/tests/xmltype_02.phpt @@ -14,8 +14,8 @@ require(__DIR__.'/connect.inc'); // Initialization $stmtarray = array( - "drop table xmltype_02_tab", - "create table xmltype_02_tab (warehouse_id number, warehouse_spec xmltype)", + "drop table xmltype_02_tab", + "create table xmltype_02_tab (warehouse_id number, warehouse_spec xmltype)", ); oci8_test_sql_execute($c, $stmtarray); @@ -101,7 +101,7 @@ $row[0]->free(); // Clean up $stmtarray = array( - "drop table xmltype_02_tab" + "drop table xmltype_02_tab" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/odbc/tests/bug47803.phpt b/ext/odbc/tests/bug47803.phpt index 8069d5141f3f..f13da017ba6d 100644 --- a/ext/odbc/tests/bug47803.phpt +++ b/ext/odbc/tests/bug47803.phpt @@ -8,9 +8,9 @@ Bug #47803 Executing prepared statements is successful only for the first two st include __DIR__ . "/config.inc"; $create_table = "CREATE TABLE FOO( - [PAR_ID] [int] NOT NULL, - [PAR_INT] [int] NULL, - [PAR_CHR] [varchar](500) NULL + [PAR_ID] [int] NOT NULL, + [PAR_INT] [int] NULL, + [PAR_CHR] [varchar](500) NULL )"; $inserts = "INSERT INTO FOO @@ -19,16 +19,16 @@ $inserts = "INSERT INTO FOO ,[PAR_CHR]) VALUES (1,14,''), - (2,30,''), - (3,7,''), - (4,7,''), - (5,0,''), - (6,0,''), - (7,20130901,''), - (8,20140201,''), - (9,20140201,''), - (10,20140620,''), - (11,221,'')"; + (2,30,''), + (3,7,''), + (4,7,''), + (5,0,''), + (6,0,''), + (7,20130901,''), + (8,20140201,''), + (9,20140201,''), + (10,20140620,''), + (11,221,'')"; date_default_timezone_set('Europe/Warsaw'); @@ -40,47 +40,47 @@ odbc_exec($link, $create_table); odbc_exec($link, $inserts); $upd_params = array( - array('id'=>1, 'name'=>'test 1'), - array('id'=>2, 'name'=>'test 2'), - array('id'=>3, 'name'=>'test 3'), - array('id'=>4, 'name'=>'test 4'), - array('id'=>5, 'name'=>'test 5'), - array('id'=>10, 'name'=>'test 10'), - array('id'=>9, 'name'=>'test 9'), - array('id'=>8, 'name'=>'test 8'), - array('id'=>7, 'name'=>'test 7'), - array('id'=>6, 'name'=>'test 6'), + array('id'=>1, 'name'=>'test 1'), + array('id'=>2, 'name'=>'test 2'), + array('id'=>3, 'name'=>'test 3'), + array('id'=>4, 'name'=>'test 4'), + array('id'=>5, 'name'=>'test 5'), + array('id'=>10, 'name'=>'test 10'), + array('id'=>9, 'name'=>'test 9'), + array('id'=>8, 'name'=>'test 8'), + array('id'=>7, 'name'=>'test 7'), + array('id'=>6, 'name'=>'test 6'), ); $sql = "UPDATE FOO SET [PAR_CHR] = ? WHERE [PAR_ID] = ?"; $result = odbc_prepare($link, $sql); if (!$result) { - print ('[sql] prep: '.$sql); - goto out; + print ('[sql] prep: '.$sql); + goto out; } foreach ($upd_params as &$k) { - if(!odbc_execute($result, array($k['name'], $k['id']))) { - print ('[sql] exec: '."array({$k['name']}, {$k['id']})"); - goto out; - } + if(!odbc_execute($result, array($k['name'], $k['id']))) { + print ('[sql] exec: '."array({$k['name']}, {$k['id']})"); + goto out; + } } odbc_free_result($result); $sql = "SELECT * FROM FOO WHERE [PAR_ID] = ?"; $result = odbc_prepare($link, $sql); if (!$result) { - print ('[sql] prep: '.$sql); - goto out; + print ('[sql] prep: '.$sql); + goto out; } foreach ($upd_params as $k) { - if(!odbc_execute($result, array($k['id']))) { - print ('[sql] exec: '."array({$k['id']})"); - goto out; - } - while (($r = odbc_fetch_array($result)) !== false) { - var_dump($r); - } + if(!odbc_execute($result, array($k['id']))) { + print ('[sql] exec: '."array({$k['id']})"); + goto out; + } + while (($r = odbc_fetch_array($result)) !== false) { + var_dump($r); + } } out: diff --git a/ext/odbc/tests/bug60616.phpt b/ext/odbc/tests/bug60616.phpt index 16536881afce..9d98d46b08c5 100644 --- a/ext/odbc/tests/bug60616.phpt +++ b/ext/odbc/tests/bug60616.phpt @@ -31,31 +31,31 @@ odbc_exec($conn, "INSERT INTO FOO(ID, CHAR_COL, VARCHAR_COL, TEXT_COL) VALUES (2 $res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC'); while(odbc_fetch_row($res)) { - $char_col = odbc_result($res, "CHAR_COL"); - $varchar_col = odbc_result($res, "VARCHAR_COL"); - $id = odbc_result($res, "ID"); - $text_col = ""; - while (($chunk=odbc_result($res, "TEXT_COL")) !== false) { - $text_col .= $chunk; - } + $char_col = odbc_result($res, "CHAR_COL"); + $varchar_col = odbc_result($res, "VARCHAR_COL"); + $id = odbc_result($res, "ID"); + $text_col = ""; + while (($chunk=odbc_result($res, "TEXT_COL")) !== false) { + $text_col .= $chunk; + } - if ($id == 1) { - $euc_jp_check = $euc_jp . str_repeat(" ", (200 - mb_strlen($euc_jp))); - if (strcmp($char_col, $euc_jp_check) == 0 && strcmp($varchar_col, $euc_jp) == 0 && - strcmp($text_col, $euc_jp) == 0) { - print "EUC-JP matched\n"; - } else { - print "EUC-JP mismatched\n"; - } - } else { - $ascii_check = $ascii . str_repeat(" ", (200 - strlen($ascii))); - if (strcmp($char_col, $ascii_check) == 0 && strcmp($varchar_col, $ascii) == 0 && - strcmp($text_col, $ascii) == 0) { - print "ASCII matched\n"; - } else { - print "ASCII mismatched\n"; - } - } + if ($id == 1) { + $euc_jp_check = $euc_jp . str_repeat(" ", (200 - mb_strlen($euc_jp))); + if (strcmp($char_col, $euc_jp_check) == 0 && strcmp($varchar_col, $euc_jp) == 0 && + strcmp($text_col, $euc_jp) == 0) { + print "EUC-JP matched\n"; + } else { + print "EUC-JP mismatched\n"; + } + } else { + $ascii_check = $ascii . str_repeat(" ", (200 - strlen($ascii))); + if (strcmp($char_col, $ascii_check) == 0 && strcmp($varchar_col, $ascii) == 0 && + strcmp($text_col, $ascii) == 0) { + print "ASCII matched\n"; + } else { + print "ASCII mismatched\n"; + } + } } ?> diff --git a/ext/odbc/tests/bug68087.phpt b/ext/odbc/tests/bug68087.phpt index 3bc18125a686..64b232d9bcf4 100644 --- a/ext/odbc/tests/bug68087.phpt +++ b/ext/odbc/tests/bug68087.phpt @@ -22,23 +22,23 @@ odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (2, 'helloag $res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC'); while(odbc_fetch_row($res)) { - $id = odbc_result($res, "ID"); - $varchar_col = odbc_result($res, "VARCHAR_COL"); - $date = odbc_result($res, "DATE_COL"); - - if ($id == 1) { - if ($date != $id_1_date) { - print "Date_1 mismatched\n"; - } else { - print "Date_1 matched\n"; - } - } else { - if ($date != $id_2_date) { - print "Date_2 mismatched\n"; - } else { - print "Date_2 matched\n"; - } - } + $id = odbc_result($res, "ID"); + $varchar_col = odbc_result($res, "VARCHAR_COL"); + $date = odbc_result($res, "DATE_COL"); + + if ($id == 1) { + if ($date != $id_1_date) { + print "Date_1 mismatched\n"; + } else { + print "Date_1 matched\n"; + } + } else { + if ($date != $id_2_date) { + print "Date_2 mismatched\n"; + } else { + print "Date_2 matched\n"; + } + } } ?> diff --git a/ext/odbc/tests/bug69354.phpt b/ext/odbc/tests/bug69354.phpt index ea27af41d43e..cf4e9114ada0 100644 --- a/ext/odbc/tests/bug69354.phpt +++ b/ext/odbc/tests/bug69354.phpt @@ -17,12 +17,12 @@ odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL) VALUES (1, '" . str_repeat("a $res = odbc_exec($conn,"select VARCHAR_COL from FOO"); if ($res) { - if (odbc_fetch_row($res)) { - $ret = odbc_result($res,'varchar_col'); - echo strlen($ret), "\n"; - echo $ret[0], "\n"; - echo $ret[strlen($ret)-1], "\n"; - } + if (odbc_fetch_row($res)) { + $ret = odbc_result($res,'varchar_col'); + echo strlen($ret), "\n"; + echo $ret[0], "\n"; + echo $ret[strlen($ret)-1], "\n"; + } } ?> --EXPECT-- diff --git a/ext/odbc/tests/bug71171.phpt b/ext/odbc/tests/bug71171.phpt index b18d86218c4c..f7a856d14c12 100644 --- a/ext/odbc/tests/bug71171.phpt +++ b/ext/odbc/tests/bug71171.phpt @@ -17,7 +17,7 @@ odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL) VALUES (1, '" . chr(0x81) . " $res = odbc_exec($conn,"SELECT ID FROM FOO WHERE VARCHAR_COL = '" . chr(0x81) . "'"); if ($res) { - while($record = odbc_fetch_array($res)) var_dump($record); + while($record = odbc_fetch_array($res)) var_dump($record); } odbc_close($conn); diff --git a/ext/odbc/tests/bug73448.phpt b/ext/odbc/tests/bug73448.phpt index e0a3629700a8..ea6c585c0fe7 100644 --- a/ext/odbc/tests/bug73448.phpt +++ b/ext/odbc/tests/bug73448.phpt @@ -10,28 +10,28 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); $sqlCommandList = array( - "/* empty batch is without error */", - "/* non existent procedure xy */ execute xy", - "/* empty batch,error message is not empty */", - "/* valid select with result */ select * from sys.sysobjects", - "/* another erroneous query */ SELECT * FROM zwiebelfleisch", - "/* valid select with result */ select * from sys.sysobjects", + "/* empty batch is without error */", + "/* non existent procedure xy */ execute xy", + "/* empty batch,error message is not empty */", + "/* valid select with result */ select * from sys.sysobjects", + "/* another erroneous query */ SELECT * FROM zwiebelfleisch", + "/* valid select with result */ select * from sys.sysobjects", ); foreach ($sqlCommandList as $exampleNumber => $sql) { - $r = @odbc_exec($conn, $sql); + $r = @odbc_exec($conn, $sql); - if (false === $r) { - $e = odbc_errormsg($conn); - $n = odbc_error($conn); + if (false === $r) { + $e = odbc_errormsg($conn); + $n = odbc_error($conn); - var_dump($sql, $n, $e); - echo "\n"; - } + var_dump($sql, $n, $e); + echo "\n"; + } - if ($r) { - odbc_free_result($r); - } + if ($r) { + odbc_free_result($r); + } } diff --git a/ext/odbc/tests/config.inc b/ext/odbc/tests/config.inc index d9da63d0b70c..78be4b2d99ad 100644 --- a/ext/odbc/tests/config.inc +++ b/ext/odbc/tests/config.inc @@ -8,11 +8,11 @@ $user = getenv("ODBC_TEST_USER"); $pass = getenv("ODBC_TEST_PASS"); if (false === $dsn) { - $dsn = 'myodbc3'; + $dsn = 'myodbc3'; } if (false === $user) { - $user = 'root'; + $user = 'root'; } if (false == $pass) { - $pass = ''; + $pass = ''; } diff --git a/ext/odbc/tests/skipif.inc b/ext/odbc/tests/skipif.inc index 4cd13d0be651..a2c9a4aade63 100644 --- a/ext/odbc/tests/skipif.inc +++ b/ext/odbc/tests/skipif.inc @@ -6,5 +6,5 @@ include 'config.inc'; $conn = @odbc_connect($dsn, $user, $pass); if (!$conn) { - die('skip could not connect'); + die('skip could not connect'); } diff --git a/ext/opcache/tests/blacklist.inc b/ext/opcache/tests/blacklist.inc index a9db75141941..65adb91cede6 100644 --- a/ext/opcache/tests/blacklist.inc +++ b/ext/opcache/tests/blacklist.inc @@ -1,3 +1,3 @@ diff --git a/ext/opcache/tests/bug64353.phpt b/ext/opcache/tests/bug64353.phpt index 42cb45c91562..bfb332e26edf 100644 --- a/ext/opcache/tests/bug64353.phpt +++ b/ext/opcache/tests/bug64353.phpt @@ -9,16 +9,16 @@ opcache.enable_cli=1 --FILE-- datalen; - stream_bucket_append($out, $bucket); - } - return PSFS_PASS_ON; - } + public function filter($in, $out, &$consumed, $closing) { + if (!class_exists("Test")) { + eval("class Test extends ArrayObject {}"); + } + while ($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } } stream_filter_register('bug.test', 'BugLoader'); diff --git a/ext/opcache/tests/bug65665.phpt b/ext/opcache/tests/bug65665.phpt index ac5c18dd8354..bcdd0e6da1e2 100644 --- a/ext/opcache/tests/bug65665.phpt +++ b/ext/opcache/tests/bug65665.phpt @@ -8,108 +8,108 @@ opcache.enable_cli=1 --FILE-- 1); var_dump(foo(PHP_VERSION)); diff --git a/ext/opcache/tests/bug66334.phpt b/ext/opcache/tests/bug66334.phpt index b2c6d7b92c19..33e3847e347e 100644 --- a/ext/opcache/tests/bug66334.phpt +++ b/ext/opcache/tests/bug66334.phpt @@ -11,9 +11,9 @@ enable_dl=0 --FILE-- diff --git a/ext/opcache/tests/bug70207.phpt b/ext/opcache/tests/bug70207.phpt index 2b6e48a2d4b2..a73b7a691617 100644 --- a/ext/opcache/tests/bug70207.phpt +++ b/ext/opcache/tests/bug70207.phpt @@ -10,7 +10,7 @@ opcache.file_update_protection=0 --FILE-- {self::LOG_LEVEL}('test'); - } + const LOG_LEVEL = 'Info'; + public function test() + { + $logger = new \Logger(); + $logger->{self::LOG_LEVEL}('test'); + } } $b = new B; diff --git a/ext/opcache/tests/bug73583.phpt b/ext/opcache/tests/bug73583.phpt index e947b451c98d..f533e9caf56f 100644 --- a/ext/opcache/tests/bug73583.phpt +++ b/ext/opcache/tests/bug73583.phpt @@ -10,9 +10,9 @@ opcache.file_update_protection=0 --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/bug73746.phpt b/ext/opcache/tests/bug73746.phpt index 4f115575cf46..c95aed8076d6 100644 --- a/ext/opcache/tests/bug73746.phpt +++ b/ext/opcache/tests/bug73746.phpt @@ -8,19 +8,19 @@ namespace Core\Bundle\Service\Property\Room\Rooms; class CountryMapping { - const CZ = 'CZ'; - const EN = 'EN'; + const CZ = 'CZ'; + const EN = 'EN'; - public function get(string $countryIsoCode = null) : string // Works correctly if return type is removed - { - switch (strtoupper($countryIsoCode)) { - case 'CZ': - case 'SK': - return self::CZ; // Works correctly if changed to CountryMapping::CZ - default: - return self::EN; // Works correctly if changed to CountryMapping::EN - } - } + public function get(string $countryIsoCode = null) : string // Works correctly if return type is removed + { + switch (strtoupper($countryIsoCode)) { + case 'CZ': + case 'SK': + return self::CZ; // Works correctly if changed to CountryMapping::CZ + default: + return self::EN; // Works correctly if changed to CountryMapping::EN + } + } } $mapping = new CountryMapping(); diff --git a/ext/opcache/tests/bug73789.phpt b/ext/opcache/tests/bug73789.phpt index d5efeb403d0c..5d5cb92f2038 100644 --- a/ext/opcache/tests/bug73789.phpt +++ b/ext/opcache/tests/bug73789.phpt @@ -7,26 +7,26 @@ Bug #73789 (Strange behavior of class constants in switch/case block) 100) { - return $type; - } - return self::T_STRING; - case $value === '.': - return self::T_DOT; - default: - } - return $type; - } + const T_NONE = 1; + const T_STRING = 2; + const T_DOT = 8; + public function getType($value): int + { + $type = self::T_NONE; + switch (true) { + case ctype_alpha($value[0]): + $name = 'Lexer::T_' . strtoupper($value); + $type = constant($name); + if ($type > 100) { + return $type; + } + return self::T_STRING; + case $value === '.': + return self::T_DOT; + default: + } + return $type; + } } var_dump((new Lexer())->getType("dot")); ?> diff --git a/ext/opcache/tests/bug74019.phpt b/ext/opcache/tests/bug74019.phpt index 210e223c82c5..0392963a8b9a 100644 --- a/ext/opcache/tests/bug74019.phpt +++ b/ext/opcache/tests/bug74019.phpt @@ -9,12 +9,12 @@ opcache.enable_cli=1 --EXPECT-- diff --git a/ext/opcache/tests/bug74456.phpt b/ext/opcache/tests/bug74456.phpt index 9c9a286e2f13..10f9b04058d7 100644 --- a/ext/opcache/tests/bug74456.phpt +++ b/ext/opcache/tests/bug74456.phpt @@ -11,7 +11,7 @@ opcache.optimization_level=-1 function small_numbers() { - return [0,1,2]; + return [0,1,2]; } list ($zero, $one, $two) = small_numbers(); diff --git a/ext/opcache/tests/bug74596.phpt b/ext/opcache/tests/bug74596.phpt index ed1c1b4504ad..8a1dc1718935 100644 --- a/ext/opcache/tests/bug74596.phpt +++ b/ext/opcache/tests/bug74596.phpt @@ -15,14 +15,14 @@ opcache.revalidate_path=1 file_put_contents(__DIR__ . "/bug74596_1.php", << CODE @@ -32,14 +32,14 @@ file_put_contents(__DIR__ . "/bug74596_2.php", "ok\n"); class ufilter extends php_user_filter { - function filter($in, $out, &$consumed, $closing) - { - include_once __DIR__ . "/bug74596_1.php"; - while ($bucket = stream_bucket_make_writeable($in)) { - stream_bucket_append($out, $bucket); - } - return PSFS_PASS_ON; - } + function filter($in, $out, &$consumed, $closing) + { + include_once __DIR__ . "/bug74596_1.php"; + while ($bucket = stream_bucket_make_writeable($in)) { + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } } stream_filter_register("ufilter", "ufilter"); diff --git a/ext/opcache/tests/bug74980.phpt b/ext/opcache/tests/bug74980.phpt index e82e234bddab..df77206d7b2f 100644 --- a/ext/opcache/tests/bug74980.phpt +++ b/ext/opcache/tests/bug74980.phpt @@ -11,16 +11,16 @@ opcache.enable_cli=1 class A { - static function foo() - { - while ($undef) { - $arr[][] = NULL; - } + static function foo() + { + while ($undef) { + $arr[][] = NULL; + } - foreach ($arr as $a) { - bar($a + []); - } - } + foreach ($arr as $a) { + bar($a + []); + } + } } diff --git a/ext/opcache/tests/bug75230.phpt b/ext/opcache/tests/bug75230.phpt index 13100b367983..ce67bb06b935 100644 --- a/ext/opcache/tests/bug75230.phpt +++ b/ext/opcache/tests/bug75230.phpt @@ -9,8 +9,8 @@ opcache.optimization_level=-1 --FILE-- $v ) { - if ( is_array( $v ) ) { - $value[$k] = wp_slash( $v ); - } else { - $value[$k] = addslashes( $v ); - } - } - } else { - $value = addslashes( $value ); - } + if ( is_array( $value ) ) { + foreach ( $value as $k => $v ) { + if ( is_array( $v ) ) { + $value[$k] = wp_slash( $v ); + } else { + $value[$k] = addslashes( $v ); + } + } + } else { + $value = addslashes( $value ); + } - return $value; + return $value; } function addslashes_gpc($gpc) { - return wp_slash($gpc); + return wp_slash($gpc); } var_dump(addslashes_gpc(array(array("test")))); diff --git a/ext/opcache/tests/bug75370.phpt b/ext/opcache/tests/bug75370.phpt index d576f592d4dc..5cc344e3f627 100644 --- a/ext/opcache/tests/bug75370.phpt +++ b/ext/opcache/tests/bug75370.phpt @@ -10,9 +10,9 @@ opcache.optimization_level=-1 getName(), ['UTC', 'Z'], true)) - ) { - $msg = 'Date objects must have UTC as their timezone'; - throw new \UnexpectedValueException($msg); - } + if ($tz !== null + || ($tz instanceof \DateTimeZone && !in_array($tz->getName(), ['UTC', 'Z'], true)) + ) { + $msg = 'Date objects must have UTC as their timezone'; + throw new \UnexpectedValueException($msg); + } - return null; + return null; } var_dump(createFromFormat('m/d/Y', '12/07/2017', null)); diff --git a/ext/opcache/tests/bug75687.phpt b/ext/opcache/tests/bug75687.phpt index 67cf8288a978..1d9c55f96c7f 100644 --- a/ext/opcache/tests/bug75687.phpt +++ b/ext/opcache/tests/bug75687.phpt @@ -11,9 +11,9 @@ opcache.optimization_level=-1 function x($y) { - if (is_array($y)) { - $z = is_array($y) ? array() : array($y); - } + if (is_array($y)) { + $z = is_array($y) ? array() : array($y); + } } ?> okey diff --git a/ext/opcache/tests/bug75938.phpt b/ext/opcache/tests/bug75938.phpt index cfe6a655036d..7fba940e97b5 100644 --- a/ext/opcache/tests/bug75938.phpt +++ b/ext/opcache/tests/bug75938.phpt @@ -5,11 +5,11 @@ Bug #75938: Modulus value not stored in variable --FILE-- diff --git a/ext/opcache/tests/bug76074.phpt b/ext/opcache/tests/bug76074.phpt index d12ebb26fa98..94c79beff6e7 100644 --- a/ext/opcache/tests/bug76074.phpt +++ b/ext/opcache/tests/bug76074.phpt @@ -6,8 +6,8 @@ Bug #76074 (opcache corrupts variable in for-loop) diff --git a/ext/opcache/tests/bug76477.phpt b/ext/opcache/tests/bug76477.phpt index 39bff0d46c54..7978ce4d7b1c 100644 --- a/ext/opcache/tests/bug76477.phpt +++ b/ext/opcache/tests/bug76477.phpt @@ -11,9 +11,9 @@ opcache.optimization_level=-1 testString(); function testString() { - $token = "ABC"; - $lengthBytes = strlenb($token); - var_dump($lengthBytes == 0); + $token = "ABC"; + $lengthBytes = strlenb($token); + var_dump($lengthBytes == 0); } function strlenb() { return call_user_func_array("strlen", func_get_args()); } diff --git a/ext/opcache/tests/bug77058.phpt b/ext/opcache/tests/bug77058.phpt index 22a36d1e3d9a..18d510bbde8d 100644 --- a/ext/opcache/tests/bug77058.phpt +++ b/ext/opcache/tests/bug77058.phpt @@ -3,7 +3,7 @@ Bug #77058: Type inference in opcache causes side effects --SKIPIF-- --FILE-- - diff --git a/ext/opcache/tests/bug77266.phpt b/ext/opcache/tests/bug77266.phpt index 8e225b848061..08fc74f96dcf 100644 --- a/ext/opcache/tests/bug77266.phpt +++ b/ext/opcache/tests/bug77266.phpt @@ -10,21 +10,21 @@ opcache.optimization_level=-1 0 ) { - $v = explode(':', $value); - if (!$serverMonitors[$v[0]]['m']) { - $serverMonitors[$v[0]]['m'] = new ServerMonitor($v[0]); - } + $serverMonitors = array(); + $listCount = count($lockList); + if ( is_array($lockList) && $listCount > 0 ) { + $v = explode(':', $value); + if (!$serverMonitors[$v[0]]['m']) { + $serverMonitors[$v[0]]['m'] = new ServerMonitor($v[0]); + } - } + } - } + } } ?> diff --git a/ext/opcache/tests/bug77743.phpt b/ext/opcache/tests/bug77743.phpt index b73da2baafa1..f9075a3a7fdf 100644 --- a/ext/opcache/tests/bug77743.phpt +++ b/ext/opcache/tests/bug77743.phpt @@ -6,12 +6,12 @@ Bug #77743: Incorrect pi node insertion for jmpznz with identical successors --CLEAN-- diff --git a/ext/opcache/tests/bug78986.phpt b/ext/opcache/tests/bug78986.phpt index 9479460f7640..420c828aa4dc 100644 --- a/ext/opcache/tests/bug78986.phpt +++ b/ext/opcache/tests/bug78986.phpt @@ -11,7 +11,7 @@ class TestClass2 { class TestClass extends TestClass2 { var $test = [ - TEST_TEST => 'test' + TEST_TEST => 'test' ]; } diff --git a/ext/opcache/tests/compact_literals.phpt b/ext/opcache/tests/compact_literals.phpt index 0aabb22b5018..0963c2770586 100644 --- a/ext/opcache/tests/compact_literals.phpt +++ b/ext/opcache/tests/compact_literals.phpt @@ -11,10 +11,10 @@ opcache.optimization_level=-1 echo "array key hash" . ":" . PHP_EOL; $array = array( - "1" => "one", - "2" => "two", - "one" => 1, - "two" => 2, + "1" => "one", + "2" => "two", + "one" => 1, + "two" => 2, ); unset($array["one"]); @@ -24,9 +24,9 @@ print_r($array); echo "function define" . ":" . PHP_EOL; if (!function_exists("dummy")) { - function dummy() { - var_dump(__FUNCTION__); - } + function dummy() { + var_dump(__FUNCTION__); + } } dummy(); @@ -35,22 +35,22 @@ $dummy = function () { var_dump("lambda" . "dummy"); }; $dummy(); if (!class_exists("A")) { - class A { - public static $name = "A"; - public static function say($n = "name") { - var_dump(static::$name); - } - } + class A { + public static $name = "A"; + public static function say($n = "name") { + var_dump(static::$name); + } + } } class B extends A { - public static $name = "B"; + public static $name = "B"; } if (!class_exists("C")) { - class C extends B { - public static $name = "C"; - } + class C extends B { + public static $name = "C"; + } } A::say(); @@ -60,7 +60,7 @@ B::say(); C::say(); function get_eol_define() { - define("MY_EOL", PHP_EOL); + define("MY_EOL", PHP_EOL); } get_eol_define(); define("EOL", MY_EOL); @@ -71,17 +71,17 @@ echo "define " . "TEST" . EOL; define("TEST", "TEST"); class E { - public static $E="EP"; - const E="E"; - const TEST="NULL"; + public static $E="EP"; + const E="E"; + const TEST="NULL"; } class F { - const F="F"; - public static $E="FEP"; - const E="FE"; - const TEST="FALSE"; - public static $F = "FP"; + const F="F"; + public static $E="FEP"; + const E="FE"; + const TEST="FALSE"; + public static $F = "FP"; } var_dump(TEST); //"TEST" @@ -97,25 +97,25 @@ var_dumP(F::$E); //"FEP" echo "propertes and methods" . EOL; class CH { - const H = "H"; - public function h() { - var_dump(self::H); - } + const H = "H"; + public function h() { + var_dump(self::H); + } } class CI { - const H = "I"; - public function h() { - var_dump(self::H); - } + const H = "I"; + public function h() { + var_dump(self::H); + } } function change(&$obj) { - $obj = new CH; + $obj = new CH; } function geti() { - return new CI; + return new CI; } $h = new CH; diff --git a/ext/opcache/tests/issue0183.phpt b/ext/opcache/tests/issue0183.phpt index 9e18f6d2e83c..26da4d97cc87 100644 --- a/ext/opcache/tests/issue0183.phpt +++ b/ext/opcache/tests/issue0183.phpt @@ -11,15 +11,15 @@ opcache.optimization_level=-1 a=1; - $a->b=2; - $b=&$a; + $a = array(1,2,3); + $b=&$a; + $b=1; + $a = new stdClass; + $a->a=1; + $a->b=2; + $b=&$a; } foo(); echo "ok\n"; diff --git a/ext/opcache/tests/jit/assign_027.phpt b/ext/opcache/tests/jit/assign_027.phpt index 20e4f65442e8..a704e3cdd67e 100644 --- a/ext/opcache/tests/jit/assign_027.phpt +++ b/ext/opcache/tests/jit/assign_027.phpt @@ -13,7 +13,7 @@ opcache.jit_buffer_size=1M function foo() { $persons = 2; for ($i=0; $i<$persons; $i++) { - $children = 2; + $children = 2; } } foo(); diff --git a/ext/opcache/tests/jit/assign_033.phpt b/ext/opcache/tests/jit/assign_033.phpt index 5bda1f0192c5..918f3b6b5762 100644 --- a/ext/opcache/tests/jit/assign_033.phpt +++ b/ext/opcache/tests/jit/assign_033.phpt @@ -13,11 +13,11 @@ opcache.protect_memory=1 $closure(), - 'b' => [$closure() => [],], - ]; + 'b' => [$closure() => [],], + ]; $x = $arr; unset($x['b'][$closure()]['d']); diff --git a/ext/opcache/tests/jit/assign_036.phpt b/ext/opcache/tests/jit/assign_036.phpt index a35516d6ea96..f7065f0d5e78 100644 --- a/ext/opcache/tests/jit/assign_036.phpt +++ b/ext/opcache/tests/jit/assign_036.phpt @@ -12,28 +12,28 @@ opcache.protect_memory=1 --FILE-- $propName); - $newType = \gettype($propValue); - if ($propValue === 'false') - { - $newType = 'boolean'; - $propValue = \false; - } - elseif ($propValue === 'true') - { - $newType = 'boolean'; - $propValue = \true; - } - if ($oldType !== $newType) - { - $tmp = $propValue; - \settype($tmp, $newType); - } - $this->propName = $propValue; - } + public $result = "string"; + function __set($propName, $propValue) + { + $oldType = \gettype($this->$propName); + $newType = \gettype($propValue); + if ($propValue === 'false') + { + $newType = 'boolean'; + $propValue = \false; + } + elseif ($propValue === 'true') + { + $newType = 'boolean'; + $propValue = \true; + } + if ($oldType !== $newType) + { + $tmp = $propValue; + \settype($tmp, $newType); + } + $this->propName = $propValue; + } } $a = new A; $a->result = "okey"; diff --git a/ext/opcache/tests/jit/assign_dim_002.phpt b/ext/opcache/tests/jit/assign_dim_002.phpt index 845414b7bb22..135df921237b 100644 --- a/ext/opcache/tests/jit/assign_dim_002.phpt +++ b/ext/opcache/tests/jit/assign_dim_002.phpt @@ -10,63 +10,63 @@ opcache.jit_buffer_size=1M --FILE-- "dummy"); + $array = array(PHP_INT_MAX => "dummy"); try { $array[] = array(); } catch (Error $e) { echo $e->getMessage(), "\n"; } - $array = new ArrayObject(); - $array[index()] = 1; - $array[offset()] = 2; + $array = new ArrayObject(); + $array[index()] = 1; + $array[offset()] = 2; - var_dump($array); + var_dump($array); } foo3(); function index() { - return 2; + return 2; } function offset() { - return "a"; + return "a"; } function foo4() { - $array = array(); - $array[] = array(); - $array[0][] = 1; - $array[0][1] = 1; - var_dump($array); + $array = array(); + $array[] = array(); + $array[0][] = 1; + $array[0][1] = 1; + var_dump($array); try { $array[function() {}] = 2; } catch (Error $e) { echo $e->getMessage(), "\n"; } - var_dump($array); + var_dump($array); - $array2[][] = 3; - var_dump($array); + $array2[][] = 3; + var_dump($array); } foo4(); diff --git a/ext/opcache/tests/jit/bug77857.phpt b/ext/opcache/tests/jit/bug77857.phpt index 028ea04aa8d1..9b9a80f5333c 100644 --- a/ext/opcache/tests/jit/bug77857.phpt +++ b/ext/opcache/tests/jit/bug77857.phpt @@ -11,14 +11,14 @@ opcache.jit=1205 --FILE-- diff --git a/ext/opcache/tests/jit/cmp_003.phpt b/ext/opcache/tests/jit/cmp_003.phpt index 342d794c2e1a..60698dea0403 100644 --- a/ext/opcache/tests/jit/cmp_003.phpt +++ b/ext/opcache/tests/jit/cmp_003.phpt @@ -11,12 +11,12 @@ opcache.protect_memory=1 --FILE-- = $b ? 1 : 0); if ($a == $b) { } else { - echo "1\n"; + echo "1\n"; } if ($a != $b) { } else { - echo "2\n"; + echo "2\n"; } if ($a < $b) { } else { - echo "3\n"; + echo "3\n"; } if ($a > $b) { } else { - echo "4\n"; + echo "4\n"; } if ($a <= $b) { } else { - echo "5\n"; + echo "5\n"; } if ($a >= $b) { } else { - echo "6\n"; + echo "6\n"; } var_dump($i == $b ? 1 : 0); var_dump($i != $b ? 1 : 0); @@ -67,27 +67,27 @@ var_dump($i <= $b ? 1 : 0); var_dump($i >= $b ? 1 : 0); if ($i == $b) { } else { - echo "1\n"; + echo "1\n"; } if ($i != $b) { } else { - echo "2\n"; + echo "2\n"; } if ($i < $b) { } else { - echo "3\n"; + echo "3\n"; } if ($i > $b) { } else { - echo "4\n"; + echo "4\n"; } if ($i <= $b) { } else { - echo "5\n"; + echo "5\n"; } if ($i >= $b) { } else { - echo "6\n"; + echo "6\n"; } var_dump($a == $b && t()); var_dump($a != $b && t()); diff --git a/ext/opcache/tests/jit/cmp_004.phpt b/ext/opcache/tests/jit/cmp_004.phpt index 3d1fb97b85bf..9a5772e37893 100644 --- a/ext/opcache/tests/jit/cmp_004.phpt +++ b/ext/opcache/tests/jit/cmp_004.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- = 1 : $x > 1)) { - return 1; - } - return 0; + if (($test ? $x >= 1 : $x > 1)) { + return 1; + } + return 0; } var_dump(foo(true, 9)); ?> diff --git a/ext/opcache/tests/jit/const_001.phpt b/ext/opcache/tests/jit/const_001.phpt index ef97b45c2334..67c9a0d12184 100644 --- a/ext/opcache/tests/jit/const_001.phpt +++ b/ext/opcache/tests/jit/const_001.phpt @@ -11,12 +11,12 @@ opcache.protect_memory=1 --FILE-- diff --git a/ext/opcache/tests/jit/fetch_dim_func_args_001.phpt b/ext/opcache/tests/jit/fetch_dim_func_args_001.phpt index a1ac1d35ccb2..b2e58c44b474 100644 --- a/ext/opcache/tests/jit/fetch_dim_func_args_001.phpt +++ b/ext/opcache/tests/jit/fetch_dim_func_args_001.phpt @@ -12,9 +12,9 @@ opcache.jit_buffer_size=1M namespace A; class A { - public function change(array $config) { - $config['keys'] = array_keys($config["a"]);; - } + public function change(array $config) { + $config['keys'] = array_keys($config["a"]);; + } } $a = new A(); diff --git a/ext/opcache/tests/jit/fetch_dim_r_001.phpt b/ext/opcache/tests/jit/fetch_dim_r_001.phpt index d38cf6096d9c..232f62cf75dc 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_001.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_001.phpt @@ -11,23 +11,23 @@ opcache.jit_buffer_size=1M --FILE-- 4,"ab"=>5,"2x"=>6); - var_dump($a[0]); - var_dump($a[2]); - var_dump($a[1.0]); - var_dump($a["0"]); - var_dump($a["2"]); - var_dump($a[false]); - var_dump($a[true]); - var_dump($a[null]); - var_dump($a["ab"]); - $x = "a"; - $y = "b"; - var_dump($a[$x . $y]); - var_dump($a["2x"]); - $x = "2"; - $y = "x"; - var_dump($a[$x . $y]); + $a = array(1,2,3,""=>4,"ab"=>5,"2x"=>6); + var_dump($a[0]); + var_dump($a[2]); + var_dump($a[1.0]); + var_dump($a["0"]); + var_dump($a["2"]); + var_dump($a[false]); + var_dump($a[true]); + var_dump($a[null]); + var_dump($a["ab"]); + $x = "a"; + $y = "b"; + var_dump($a[$x . $y]); + var_dump($a["2x"]); + $x = "2"; + $y = "x"; + var_dump($a[$x . $y]); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/fetch_dim_r_002.phpt b/ext/opcache/tests/jit/fetch_dim_r_002.phpt index 36ec162ce504..178071b115ac 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_002.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_002.phpt @@ -11,8 +11,8 @@ opcache.jit_buffer_size=1M --FILE-- 4,"ab"=>5,"2x"=>6); - var_dump($a[$n]); + $a = array(1,2,3,""=>4,"ab"=>5,"2x"=>6); + var_dump($a[$n]); } foo(0); foo(2); diff --git a/ext/opcache/tests/jit/fetch_dim_r_003.phpt b/ext/opcache/tests/jit/fetch_dim_r_003.phpt index 2e82cb926c66..263871523626 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_003.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_003.phpt @@ -11,23 +11,23 @@ opcache.jit_buffer_size=1M --FILE-- a); - var_dump($obj); - foo2($obj->b); - var_dump($obj); - foo3($obj->a, "2" . "3"); - foo3($obj->a, $obj->b); - var_dump($obj); + foo($obj->a); + var_dump($obj); + foo2($obj->b); + var_dump($obj); + foo3($obj->a, "2" . "3"); + foo3($obj->a, $obj->b); + var_dump($obj); - $a = &$obj->a; - $a = fopen(__FILE__, "r"); - var_dump($obj); + $a = &$obj->a; + $a = fopen(__FILE__, "r"); + var_dump($obj); $d = array(); try { @@ -54,7 +54,7 @@ function bar() { } catch (Error $err) { echo $err->getMessage(), "\n"; } - var_dump($d); + var_dump($d); $e = NULL; try { @@ -62,7 +62,7 @@ function bar() { } catch (Error $err) { echo $err->getMessage(), "\n"; } - var_dump($e); + var_dump($e); $f = ""; try { @@ -70,7 +70,7 @@ function bar() { } catch (Error $err) { echo $err->getMessage(), "\n"; } - var_dump($f); + var_dump($f); } bar(); diff --git a/ext/opcache/tests/jit/fetch_obj_003.phpt b/ext/opcache/tests/jit/fetch_obj_003.phpt index 9232ccd64b4e..de51b45fa7bc 100644 --- a/ext/opcache/tests/jit/fetch_obj_003.phpt +++ b/ext/opcache/tests/jit/fetch_obj_003.phpt @@ -10,22 +10,22 @@ opcache.jit_buffer_size=1M --FILE-- a = 1; - unset($x->a); - $x->a += 2; - var_dump($x); + $x = new C; + $x->a = 1; + unset($x->a); + $x->a += 2; + var_dump($x); } function bar() { - $x = new C; - $x->a = 1; - $x->b = 2; - unset($x->a); - $x->a += 2; - var_dump($x); + $x = new C; + $x->a = 1; + $x->b = 2; + unset($x->a); + $x->a += 2; + var_dump($x); } foo(); bar(); diff --git a/ext/opcache/tests/jit/fetch_obj_004.phpt b/ext/opcache/tests/jit/fetch_obj_004.phpt index 10e459b09311..ec4d74f0e613 100644 --- a/ext/opcache/tests/jit/fetch_obj_004.phpt +++ b/ext/opcache/tests/jit/fetch_obj_004.phpt @@ -10,22 +10,22 @@ opcache.jit_buffer_size=1M --FILE-- a = 1; - unset($x->a); - $x->a = 3; - var_dump($x); + $x = new C; + $x->a = 1; + unset($x->a); + $x->a = 3; + var_dump($x); } function bar() { - $x = new C; - $x->a = 1; - $x->b = 2; - unset($x->a); - $x->a = 3; - var_dump($x); + $x = new C; + $x->a = 1; + $x->b = 2; + unset($x->a); + $x->a = 3; + var_dump($x); } foo(); bar(); diff --git a/ext/opcache/tests/jit/inc_001.phpt b/ext/opcache/tests/jit/inc_001.phpt index 7010533e6bd3..c3807303e7ba 100644 --- a/ext/opcache/tests/jit/inc_001.phpt +++ b/ext/opcache/tests/jit/inc_001.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 --FILE-- mem - var_dump($x); + $x = 1; + $x += 0; + ++$x; // mem -> mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_002.phpt b/ext/opcache/tests/jit/inc_002.phpt index a6962d1cac74..4d2757ca752e 100644 --- a/ext/opcache/tests/jit/inc_002.phpt +++ b/ext/opcache/tests/jit/inc_002.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- mem - var_dump($x); +function foo() { + $x = 1; + ++$x; // reg -> mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_003.phpt b/ext/opcache/tests/jit/inc_003.phpt index d0a022d635d1..9842527be7b6 100644 --- a/ext/opcache/tests/jit/inc_003.phpt +++ b/ext/opcache/tests/jit/inc_003.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 --FILE-- reg - return $x; + $x = 1; + $x += 0; + ++$x; // mem -> reg + return $x; } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_004.phpt b/ext/opcache/tests/jit/inc_004.phpt index 5c560fc95fe1..643102053747 100644 --- a/ext/opcache/tests/jit/inc_004.phpt +++ b/ext/opcache/tests/jit/inc_004.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- reg - return $x; +function foo() { + $x = 1; + ++$x; // reg -> reg + return $x; } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_005.phpt b/ext/opcache/tests/jit/inc_005.phpt index 99c2b2b85825..d784b092e91e 100644 --- a/ext/opcache/tests/jit/inc_005.phpt +++ b/ext/opcache/tests/jit/inc_005.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 --FILE-- mem, mem - var_dump($x); + $x = 1; + $x += 0; + var_dump(++$x); // mem -> mem, mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_006.phpt b/ext/opcache/tests/jit/inc_006.phpt index 3cb61691edcd..3ecff9e13d25 100644 --- a/ext/opcache/tests/jit/inc_006.phpt +++ b/ext/opcache/tests/jit/inc_006.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- mem, mem - var_dump($x); +function foo() { + $x = 1; + var_dump(++$x); // reg -> mem, mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_007.phpt b/ext/opcache/tests/jit/inc_007.phpt index 4ca3f44400f2..bb1634d731dd 100644 --- a/ext/opcache/tests/jit/inc_007.phpt +++ b/ext/opcache/tests/jit/inc_007.phpt @@ -12,9 +12,9 @@ opcache.protect_memory=1 --FILE-- reg, reg + $x = 1; + $x += 0; + return ++$x; // mem -> reg, reg } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_008.phpt b/ext/opcache/tests/jit/inc_008.phpt index 1c1daae8273e..d008cb094dd2 100644 --- a/ext/opcache/tests/jit/inc_008.phpt +++ b/ext/opcache/tests/jit/inc_008.phpt @@ -11,9 +11,9 @@ opcache.protect_memory=1 --FILE-- reg, reg +function foo() { + $x = 1; + return ++$x; // reg -> reg, reg } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_009.phpt b/ext/opcache/tests/jit/inc_009.phpt index 06920f7bde68..e600cba7ad52 100644 --- a/ext/opcache/tests/jit/inc_009.phpt +++ b/ext/opcache/tests/jit/inc_009.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 --FILE-- mem - var_dump($x); + $x = 1.0; + $x += 0; + ++$x; // mem -> mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_010.phpt b/ext/opcache/tests/jit/inc_010.phpt index 0d4800efac84..105387d924e1 100644 --- a/ext/opcache/tests/jit/inc_010.phpt +++ b/ext/opcache/tests/jit/inc_010.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- mem - var_dump($x); +function foo() { + $x = 1.0; + ++$x; // reg -> mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_011.phpt b/ext/opcache/tests/jit/inc_011.phpt index 2cf9678af3e1..d91c487965ee 100644 --- a/ext/opcache/tests/jit/inc_011.phpt +++ b/ext/opcache/tests/jit/inc_011.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 --FILE-- reg - return $x; + $x = 1.0; + $x += 0; + ++$x; // mem -> reg + return $x; } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_012.phpt b/ext/opcache/tests/jit/inc_012.phpt index bbae1ed78fb5..14fb5c1b9051 100644 --- a/ext/opcache/tests/jit/inc_012.phpt +++ b/ext/opcache/tests/jit/inc_012.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- reg - return $x; +function foo() { + $x = 1.0; + ++$x; // reg -> reg + return $x; } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_013.phpt b/ext/opcache/tests/jit/inc_013.phpt index c07bddc66cf0..2c2e5f09203a 100644 --- a/ext/opcache/tests/jit/inc_013.phpt +++ b/ext/opcache/tests/jit/inc_013.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 --FILE-- mem, mem - var_dump($x); + $x = 1.0; + $x += 0; + var_dump(++$x); // mem -> mem, mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_014.phpt b/ext/opcache/tests/jit/inc_014.phpt index d026fae27f01..e6f31f32f337 100644 --- a/ext/opcache/tests/jit/inc_014.phpt +++ b/ext/opcache/tests/jit/inc_014.phpt @@ -11,10 +11,10 @@ opcache.protect_memory=1 --FILE-- mem, mem - var_dump($x); +function foo() { + $x = 1.0; + var_dump(++$x); // reg -> mem, mem + var_dump($x); } foo(); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_015.phpt b/ext/opcache/tests/jit/inc_015.phpt index acbc8050c7eb..d841dc0c9c8d 100644 --- a/ext/opcache/tests/jit/inc_015.phpt +++ b/ext/opcache/tests/jit/inc_015.phpt @@ -12,9 +12,9 @@ opcache.protect_memory=1 --FILE-- reg, reg + $x = 1.0; + $x += 0; + return ++$x; // mem -> reg, reg } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_016.phpt b/ext/opcache/tests/jit/inc_016.phpt index 2deabbdd5a46..c1a6302e9275 100644 --- a/ext/opcache/tests/jit/inc_016.phpt +++ b/ext/opcache/tests/jit/inc_016.phpt @@ -11,9 +11,9 @@ opcache.protect_memory=1 --FILE-- reg, reg +function foo() { + $x = 1.0; + return ++$x; // reg -> reg, reg } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_017.phpt b/ext/opcache/tests/jit/inc_017.phpt index 5da8842fc2f9..c52e01804861 100644 --- a/ext/opcache/tests/jit/inc_017.phpt +++ b/ext/opcache/tests/jit/inc_017.phpt @@ -11,9 +11,9 @@ opcache.protect_memory=1 --FILE-- reg, reg +function foo() { + $x = true; + return ++$x; // reg -> reg, reg } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_018.phpt b/ext/opcache/tests/jit/inc_018.phpt index 6ddb4c3174fb..c992fa528d59 100644 --- a/ext/opcache/tests/jit/inc_018.phpt +++ b/ext/opcache/tests/jit/inc_018.phpt @@ -11,9 +11,9 @@ opcache.protect_memory=1 --FILE-- reg, reg +function foo() { + $x = false; + return ++$x; // reg -> reg, reg } var_dump(foo()); --EXPECT-- diff --git a/ext/opcache/tests/jit/inc_019.phpt b/ext/opcache/tests/jit/inc_019.phpt index 42e83cc93ea8..e147ef6f2f03 100644 --- a/ext/opcache/tests/jit/inc_019.phpt +++ b/ext/opcache/tests/jit/inc_019.phpt @@ -12,14 +12,14 @@ opcache.protect_memory=1 --FILE-- $value) { - if (is_int($key)) { - $key++; - } - if (isset($row[$key])) { - return false; - } - } - return true; + foreach ($row as $key => $value) { + if (is_int($key)) { + $key++; + } + if (isset($row[$key])) { + return false; + } + } + return true; } ?> OK diff --git a/ext/opcache/tests/jit/jmpz_001.phpt b/ext/opcache/tests/jit/jmpz_001.phpt index 46aa0f8825f3..2772942f39cb 100644 --- a/ext/opcache/tests/jit/jmpz_001.phpt +++ b/ext/opcache/tests/jit/jmpz_001.phpt @@ -14,10 +14,10 @@ namespace A; function test() { - $modelData = array(); - $ret = false || - ((is_array($modelData) || $modelData instanceof \Countable) && true) || false; - return $ret; + $modelData = array(); + $ret = false || + ((is_array($modelData) || $modelData instanceof \Countable) && true) || false; + return $ret; } var_dump(test()); diff --git a/ext/opcache/tests/jit/mod_001.phpt b/ext/opcache/tests/jit/mod_001.phpt index 88d8bfc76768..d9dd638f6345 100644 --- a/ext/opcache/tests/jit/mod_001.phpt +++ b/ext/opcache/tests/jit/mod_001.phpt @@ -11,7 +11,7 @@ opcache.protect_memory=1 --FILE-- getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(mod(125, 0)); + var_dump(mod(125, 0)); } catch (Throwable $e) { - echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; + echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/mod_002.phpt b/ext/opcache/tests/jit/mod_002.phpt index d06645f783d7..9dada5e400c4 100644 --- a/ext/opcache/tests/jit/mod_002.phpt +++ b/ext/opcache/tests/jit/mod_002.phpt @@ -11,19 +11,19 @@ opcache.protect_memory=1 --FILE-- getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(mod0(125)); + var_dump(mod0(125)); } catch (Throwable $e) { - echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; + echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/recv_001.phpt b/ext/opcache/tests/jit/recv_001.phpt index 1f02ff3381e5..2213da5f574d 100644 --- a/ext/opcache/tests/jit/recv_001.phpt +++ b/ext/opcache/tests/jit/recv_001.phpt @@ -14,7 +14,7 @@ opcache.protect_memory=1 function test(array $args, $short_options, $long_options = null) { - echo "okey"; + echo "okey"; } test(array(), "d:e", 222, 3434); diff --git a/ext/opcache/tests/jit/reg_alloc_002.phpt b/ext/opcache/tests/jit/reg_alloc_002.phpt index 0a6d0a4bff57..559315618808 100644 --- a/ext/opcache/tests/jit/reg_alloc_002.phpt +++ b/ext/opcache/tests/jit/reg_alloc_002.phpt @@ -12,10 +12,10 @@ opcache.protect_memory=1 evalParameters = array("a" => "okey"); - extract($this->evalParameters, EXTR_SKIP); - echo $a; - return false; - } + private $evalParameters; + public function evaluate() { + $this->evalParameters = array("a" => "okey"); + extract($this->evalParameters, EXTR_SKIP); + echo $a; + return false; + } } $a = new A(); diff --git a/ext/opcache/tests/jit/shift_left_001.phpt b/ext/opcache/tests/jit/shift_left_001.phpt index b0328b1765b6..4447d0943e6f 100644 --- a/ext/opcache/tests/jit/shift_left_001.phpt +++ b/ext/opcache/tests/jit/shift_left_001.phpt @@ -11,21 +11,21 @@ opcache.protect_memory=1 --FILE-- getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(shl(1, -1)); + var_dump(shl(1, -1)); } catch (Throwable $e) { - echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; + echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/shift_left_002.phpt b/ext/opcache/tests/jit/shift_left_002.phpt index 4b617530c54c..a6478373b969 100644 --- a/ext/opcache/tests/jit/shift_left_002.phpt +++ b/ext/opcache/tests/jit/shift_left_002.phpt @@ -11,33 +11,33 @@ opcache.protect_memory=1 --FILE-- getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(shlNEG(1)); + var_dump(shlNEG(1)); } catch (Throwable $e) { - echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; + echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/shift_right_001.phpt b/ext/opcache/tests/jit/shift_right_001.phpt index 9a5f2eb6d5b1..01a547b9eaf0 100644 --- a/ext/opcache/tests/jit/shift_right_001.phpt +++ b/ext/opcache/tests/jit/shift_right_001.phpt @@ -11,26 +11,26 @@ opcache.protect_memory=1 --FILE-- > $b; + return $a >> $b; } var_dump(shr(256, 0)); var_dump(shr(256, 1)); var_dump(shr(256, 2)); var_dump(shr(-8, 2)); try { - var_dump(shr(1, 64)); + var_dump(shr(1, 64)); } catch (Throwable $e) { - echo "Exception " . $e->getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(shr(-1, 64)); + var_dump(shr(-1, 64)); } catch (Throwable $e) { - echo "Exception " . $e->getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(shr(1, -1)); + var_dump(shr(1, -1)); } catch (Throwable $e) { - echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; + echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/shift_right_002.phpt b/ext/opcache/tests/jit/shift_right_002.phpt index 1fea4e1c4b70..3d86a08116c7 100644 --- a/ext/opcache/tests/jit/shift_right_002.phpt +++ b/ext/opcache/tests/jit/shift_right_002.phpt @@ -11,38 +11,38 @@ opcache.protect_memory=1 --FILE-- > 0; + return $a >> 0; } function shr1(int $a) { - return $a >> 1; + return $a >> 1; } function shr2(int $a) { - return $a >> 2; + return $a >> 2; } function shr64(int $a) { - return $a >> 64; + return $a >> 64; } function shrNEG(int $a) { - return $a >> -1; + return $a >> -1; } var_dump(shr0(256)); var_dump(shr1(256)); var_dump(shr2(256)); var_dump(shr2(-8)); try { - var_dump(shr64(1)); + var_dump(shr64(1)); } catch (Throwable $e) { - echo "Exception " . $e->getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(shr64(-1)); + var_dump(shr64(-1)); } catch (Throwable $e) { - echo "Exception " . $e->getMessage() . "\n"; + echo "Exception " . $e->getMessage() . "\n"; } try { - var_dump(shrNEG(1)); + var_dump(shrNEG(1)); } catch (Throwable $e) { - echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; + echo "Exception (" . get_class($e) . "): " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/type_check_001.phpt b/ext/opcache/tests/jit/type_check_001.phpt index c8ef2cf08ba5..6573f0ebdc52 100644 --- a/ext/opcache/tests/jit/type_check_001.phpt +++ b/ext/opcache/tests/jit/type_check_001.phpt @@ -10,15 +10,15 @@ opcache.jit_buffer_size=1M --FILE-- getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/opcache/tests/jit/unreachable_block.phpt b/ext/opcache/tests/jit/unreachable_block.phpt index d452484a3ffc..cf60efaef3c6 100644 --- a/ext/opcache/tests/jit/unreachable_block.phpt +++ b/ext/opcache/tests/jit/unreachable_block.phpt @@ -15,7 +15,7 @@ class A { { switch ($this->returnType) { case 'float': return $this->returnTypeNullable ? null : 0; - default: return; + default: return; } } } diff --git a/ext/opcache/tests/opt/block_pass_002.phpt b/ext/opcache/tests/opt/block_pass_002.phpt index ef7bf479c5b1..38722ea49bd5 100644 --- a/ext/opcache/tests/opt/block_pass_002.phpt +++ b/ext/opcache/tests/opt/block_pass_002.phpt @@ -9,9 +9,9 @@ opcache.optimization_level=-1 --FILE-- OK diff --git a/ext/opcache/tests/opt/dce_001.phpt b/ext/opcache/tests/opt/dce_001.phpt index 1afc3eba062e..77a3da680916 100644 --- a/ext/opcache/tests/opt/dce_001.phpt +++ b/ext/opcache/tests/opt/dce_001.phpt @@ -11,9 +11,9 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/dce_002.phpt b/ext/opcache/tests/opt/dce_002.phpt index fb1c070b351f..002ada627ded 100644 --- a/ext/opcache/tests/opt/dce_002.phpt +++ b/ext/opcache/tests/opt/dce_002.phpt @@ -11,12 +11,12 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/dce_003.phpt b/ext/opcache/tests/opt/dce_003.phpt index 0de39c042c03..a60e982b9591 100644 --- a/ext/opcache/tests/opt/dce_003.phpt +++ b/ext/opcache/tests/opt/dce_003.phpt @@ -11,8 +11,8 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/dce_004.phpt b/ext/opcache/tests/opt/dce_004.phpt index 90bfc52d9746..d595c17acb50 100644 --- a/ext/opcache/tests/opt/dce_004.phpt +++ b/ext/opcache/tests/opt/dce_004.phpt @@ -11,10 +11,10 @@ opcache.preload= --FILE-- foo = $x; + $a = new A; + $a->foo = $x; } --EXPECTF-- $_main: ; (lines=1, args=0, vars=0, tmps=0) diff --git a/ext/opcache/tests/opt/dce_006.phpt b/ext/opcache/tests/opt/dce_006.phpt index c84805247a2a..c595f9088d14 100644 --- a/ext/opcache/tests/opt/dce_006.phpt +++ b/ext/opcache/tests/opt/dce_006.phpt @@ -11,11 +11,11 @@ opcache.preload= --FILE-- foo = $x; + $a = new A; + $a->foo = $x; } --EXPECTF-- $_main: ; (lines=1, args=0, vars=0, tmps=0) diff --git a/ext/opcache/tests/opt/sccp_001.phpt b/ext/opcache/tests/opt/sccp_001.phpt index 1f67f985e342..d7cb8c700ac1 100644 --- a/ext/opcache/tests/opt/sccp_001.phpt +++ b/ext/opcache/tests/opt/sccp_001.phpt @@ -11,10 +11,10 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_002.phpt b/ext/opcache/tests/opt/sccp_002.phpt index fd2b373d7332..ff00281a0320 100644 --- a/ext/opcache/tests/opt/sccp_002.phpt +++ b/ext/opcache/tests/opt/sccp_002.phpt @@ -11,15 +11,15 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_003.phpt b/ext/opcache/tests/opt/sccp_003.phpt index 50ed9eb759c2..a0ac2e023647 100644 --- a/ext/opcache/tests/opt/sccp_003.phpt +++ b/ext/opcache/tests/opt/sccp_003.phpt @@ -11,15 +11,15 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_004.phpt b/ext/opcache/tests/opt/sccp_004.phpt index 495499f8843e..659e3488c174 100644 --- a/ext/opcache/tests/opt/sccp_004.phpt +++ b/ext/opcache/tests/opt/sccp_004.phpt @@ -11,18 +11,18 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_005.phpt b/ext/opcache/tests/opt/sccp_005.phpt index 1ff0d4e4ae7f..4fb86eacc0c0 100644 --- a/ext/opcache/tests/opt/sccp_005.phpt +++ b/ext/opcache/tests/opt/sccp_005.phpt @@ -11,8 +11,8 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_006.phpt b/ext/opcache/tests/opt/sccp_006.phpt index 60fa5f2f01c9..bc24ebbfb244 100644 --- a/ext/opcache/tests/opt/sccp_006.phpt +++ b/ext/opcache/tests/opt/sccp_006.phpt @@ -11,8 +11,8 @@ opcache.preload= --FILE-- 1,"a"=>2,"a"=>$x]; - echo $a["a"]; + $a = ["a"=>1,"a"=>2,"a"=>$x]; + echo $a["a"]; } ?> --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_007.phpt b/ext/opcache/tests/opt/sccp_007.phpt index c502a5c6beec..44ff01e64054 100644 --- a/ext/opcache/tests/opt/sccp_007.phpt +++ b/ext/opcache/tests/opt/sccp_007.phpt @@ -11,12 +11,12 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_008.phpt b/ext/opcache/tests/opt/sccp_008.phpt index d652964a6684..a5ba8a7d2277 100644 --- a/ext/opcache/tests/opt/sccp_008.phpt +++ b/ext/opcache/tests/opt/sccp_008.phpt @@ -11,12 +11,12 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_009.phpt b/ext/opcache/tests/opt/sccp_009.phpt index 47612cdb2982..601586fd647f 100644 --- a/ext/opcache/tests/opt/sccp_009.phpt +++ b/ext/opcache/tests/opt/sccp_009.phpt @@ -11,9 +11,9 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_010.phpt b/ext/opcache/tests/opt/sccp_010.phpt index a2e9945c7f64..8943b179e3f6 100644 --- a/ext/opcache/tests/opt/sccp_010.phpt +++ b/ext/opcache/tests/opt/sccp_010.phpt @@ -13,14 +13,14 @@ opcache.preload= function foo() { $o = new stdClass(); $o->foo = 0; - $i = 1; - $c = $i < 2; - if ($c) { - $k = 2 * $i; - $o->foo = $i; - echo $o->foo; - } - echo $o->foo; + $i = 1; + $c = $i < 2; + if ($c) { + $k = 2 * $i; + $o->foo = $i; + echo $o->foo; + } + echo $o->foo; } ?> --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_011.phpt b/ext/opcache/tests/opt/sccp_011.phpt index adb2c0a3638b..4bd90b18e6d8 100644 --- a/ext/opcache/tests/opt/sccp_011.phpt +++ b/ext/opcache/tests/opt/sccp_011.phpt @@ -11,15 +11,15 @@ opcache.preload= --FILE-- foo = 0; - $o->bar = 1; - } else { - $o->foo = 0; - $o->bar = 2; - } - echo $o->foo; + $o = new stdClass; + if ($x) { + $o->foo = 0; + $o->bar = 1; + } else { + $o->foo = 0; + $o->bar = 2; + } + echo $o->foo; } ?> --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_012.phpt b/ext/opcache/tests/opt/sccp_012.phpt index 0e3b872e0ca2..1ad1ed3b4ce6 100644 --- a/ext/opcache/tests/opt/sccp_012.phpt +++ b/ext/opcache/tests/opt/sccp_012.phpt @@ -13,16 +13,16 @@ opcache.preload= function foo() { $o = new stdClass(); $o->foo = 0; - $i = 1; - $c = $i < 2; - if ($c) { - $k = 2 * $i; - $o->foo = $i; - echo $o->foo; - } - $o->foo += 2; - $o->foo++; - echo $o->foo; + $i = 1; + $c = $i < 2; + if ($c) { + $k = 2 * $i; + $o->foo = $i; + echo $o->foo; + } + $o->foo += 2; + $o->foo++; + echo $o->foo; } ?> --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_013.phpt b/ext/opcache/tests/opt/sccp_013.phpt index 18b57a4185b3..1ed9c7703b88 100644 --- a/ext/opcache/tests/opt/sccp_013.phpt +++ b/ext/opcache/tests/opt/sccp_013.phpt @@ -9,11 +9,11 @@ opcache.optimization_level=-1 --FILE-- a = 1; - foreach ($entity_information as $info) { - $entity_types->a = 0; - } - var_dump((bool)($entity_types->a)); + $entity_types = new StdClass(); + $entity_types->a = 1; + foreach ($entity_information as $info) { + $entity_types->a = 0; + } + var_dump((bool)($entity_types->a)); } loadEntities(array("first", "second")); diff --git a/ext/opcache/tests/opt/sccp_015.phpt b/ext/opcache/tests/opt/sccp_015.phpt index b31f4edc150f..d11bd6c9e064 100644 --- a/ext/opcache/tests/opt/sccp_015.phpt +++ b/ext/opcache/tests/opt/sccp_015.phpt @@ -9,14 +9,14 @@ opcache.optimization_level=-1 --FILE-- b = 0; - foreach ($entity_information as $ex) { - var_dump((bool)$entity_types->b); - foreach ($entity_information as $info) { - $entity_types->b = 1; - } - } + $entity_types = new StdClass(); + $entity_types->b = 0; + foreach ($entity_information as $ex) { + var_dump((bool)$entity_types->b); + foreach ($entity_information as $info) { + $entity_types->b = 1; + } + } } loadEntities(array("first", "second")); diff --git a/ext/opcache/tests/opt/sccp_017.phpt b/ext/opcache/tests/opt/sccp_017.phpt index 6e05163b7c31..e72d892bdc5d 100644 --- a/ext/opcache/tests/opt/sccp_017.phpt +++ b/ext/opcache/tests/opt/sccp_017.phpt @@ -11,11 +11,11 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_018.phpt b/ext/opcache/tests/opt/sccp_018.phpt index dd1407dcec7a..e7a78ef50d66 100644 --- a/ext/opcache/tests/opt/sccp_018.phpt +++ b/ext/opcache/tests/opt/sccp_018.phpt @@ -10,12 +10,12 @@ opcache.optimization_level=-1 --FILE-- x = 5; - $b->x = 42; - echo $a->x; - echo "\n"; + $a = new stdClass; + $b = $a; + $a->x = 5; + $b->x = 42; + echo $a->x; + echo "\n"; } foo(); ?> diff --git a/ext/opcache/tests/opt/sccp_019.phpt b/ext/opcache/tests/opt/sccp_019.phpt index 1f7cba7fadea..3ed2d6bd81e6 100644 --- a/ext/opcache/tests/opt/sccp_019.phpt +++ b/ext/opcache/tests/opt/sccp_019.phpt @@ -11,10 +11,10 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_020.phpt b/ext/opcache/tests/opt/sccp_020.phpt index b3aa82bff506..be972f4fdf52 100644 --- a/ext/opcache/tests/opt/sccp_020.phpt +++ b/ext/opcache/tests/opt/sccp_020.phpt @@ -10,11 +10,11 @@ opcache.optimization_level=-1 --FILE-- x = 5; - $b->x = 42; - echo $a->x; - echo "\n"; + $b = $a = new stdClass; + $a->x = 5; + $b->x = 42; + echo $a->x; + echo "\n"; } foo(); ?> diff --git a/ext/opcache/tests/opt/sccp_021.phpt b/ext/opcache/tests/opt/sccp_021.phpt index 327cbc9a913d..1eb8de4516ae 100644 --- a/ext/opcache/tests/opt/sccp_021.phpt +++ b/ext/opcache/tests/opt/sccp_021.phpt @@ -10,19 +10,19 @@ opcache.optimization_level=-1 --FILE-- okey diff --git a/ext/opcache/tests/opt/sccp_022.phpt b/ext/opcache/tests/opt/sccp_022.phpt index 6a6bfbfec95a..000b1ab8b3a6 100644 --- a/ext/opcache/tests/opt/sccp_022.phpt +++ b/ext/opcache/tests/opt/sccp_022.phpt @@ -11,11 +11,11 @@ opcache.preload= --FILE-- foo = 5; - echo $a[1]; + $a[0] = $x; + $a[1] = 5; + echo $a[1]; + $a->foo = 5; + echo $a[1]; } ?> --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_023.phpt b/ext/opcache/tests/opt/sccp_023.phpt index d327d6279e3f..efa7d6b0134d 100644 --- a/ext/opcache/tests/opt/sccp_023.phpt +++ b/ext/opcache/tests/opt/sccp_023.phpt @@ -10,13 +10,13 @@ opcache.opt_debug_level=0 --FILE-- [ - 'allowed_values' => $allowed_values, - ], - ]; + $settings = [ + 'list_string' => [ + 'allowed_values' => $allowed_values, + ], + ]; - return $settings[$field_type]; + return $settings[$field_type]; } var_dump(a("list_string", ["xxx"])); diff --git a/ext/opcache/tests/opt/sccp_024.phpt b/ext/opcache/tests/opt/sccp_024.phpt index e6e2e311ef17..bd9a2fed67f8 100644 --- a/ext/opcache/tests/opt/sccp_024.phpt +++ b/ext/opcache/tests/opt/sccp_024.phpt @@ -11,14 +11,14 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_025.phpt b/ext/opcache/tests/opt/sccp_025.phpt index 8f46dab830bc..f78e8822d764 100644 --- a/ext/opcache/tests/opt/sccp_025.phpt +++ b/ext/opcache/tests/opt/sccp_025.phpt @@ -11,31 +11,31 @@ opcache.opt_debug_level=0 array( - 'id' => 1, - ), - 6 => array( - 'viewtopic' => strval("phpBB/viewtopic.$phpEx"), + $expected_data_sets = array( + 1 => array( + 'id' => 1, + ), + 6 => array( + 'viewtopic' => strval("phpBB/viewtopic.$phpEx"), - ), - ); + ), + ); - $test_cases = array( - array( - 'expected' => array(6), - ), - ); + $test_cases = array( + array( + 'expected' => array(6), + ), + ); - foreach ($test_cases as $case => $case_data) - { - foreach ($case_data['expected'] as $data_set => $expected) - { - $test_cases[$case]['expected'][$data_set] = $expected_data_sets[$expected]; - } - } + foreach ($test_cases as $case => $case_data) + { + foreach ($case_data['expected'] as $data_set => $expected) + { + $test_cases[$case]['expected'][$data_set] = $expected_data_sets[$expected]; + } + } - return $test_cases; + return $test_cases; } var_dump(test("xxx")); ?> diff --git a/ext/opcache/tests/opt/sccp_026.phpt b/ext/opcache/tests/opt/sccp_026.phpt index 132c9ddef3bd..6f02a57a5a1e 100644 --- a/ext/opcache/tests/opt/sccp_026.phpt +++ b/ext/opcache/tests/opt/sccp_026.phpt @@ -15,7 +15,7 @@ function test($var) { return; } - var_dump($username); + var_dump($username); } ?> --EXPECTF-- diff --git a/ext/opcache/tests/opt/sccp_027.phpt b/ext/opcache/tests/opt/sccp_027.phpt index 38189592b019..5c13111d1c92 100644 --- a/ext/opcache/tests/opt/sccp_027.phpt +++ b/ext/opcache/tests/opt/sccp_027.phpt @@ -10,15 +10,15 @@ opcache.preload= --FILE-- arr =& $a; - if (isset($a[0])) { - return 1; - } else { - return 2; - } - } + protected $arr; + public function init($a) { + $this->arr =& $a; + if (isset($a[0])) { + return 1; + } else { + return 2; + } + } } $x = new Foo(); var_dump($x->init([1])); diff --git a/ext/opcache/tests/opt/sccp_029.phpt b/ext/opcache/tests/opt/sccp_029.phpt index 3a1647771106..99459f74af5b 100644 --- a/ext/opcache/tests/opt/sccp_029.phpt +++ b/ext/opcache/tests/opt/sccp_029.phpt @@ -10,7 +10,7 @@ opcache.preload= --FILE-- --EXPECTF-- diff --git a/ext/opcache/tests/optimize_func_calls.phpt b/ext/opcache/tests/optimize_func_calls.phpt index eb1a6b38b450..3e2a8dd8f462 100644 --- a/ext/opcache/tests/optimize_func_calls.phpt +++ b/ext/opcache/tests/optimize_func_calls.phpt @@ -10,14 +10,14 @@ opcache.optimization_level=-1 getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } ?> OK diff --git a/ext/opcache/tests/phi_remove_001.phpt b/ext/opcache/tests/phi_remove_001.phpt index 3a76a9da5c65..d8c1a64eec8a 100644 --- a/ext/opcache/tests/phi_remove_001.phpt +++ b/ext/opcache/tests/phi_remove_001.phpt @@ -9,58 +9,58 @@ opcache.optimization_level=-1 --FILE-- 4) { - $WhereWeWere = mftell(); - $next4 = test(4); - if ($next4[0] == "\xFF") { - if (!isset($MPEGaudioHeaderDecodeCache[$next4])) { - $MPEGaudioHeaderDecodeCache[$next4] = MPEGaudioHeaderDecode($next4); - } - if (!isset($MPEGaudioHeaderValidCache[$next4])) { - $MPEGaudioHeaderValidCache[$next4] = MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false); - } - if ($MPEGaudioHeaderValidCache[$next4]) { - getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]); - getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]); - getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]); - getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]); - getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]); - if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) { - foreach ($Distribution as $key1 => $value1) { - foreach ($value1 as $key2 => $value2) { - $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned); - } - } - break; - } - continue; - } - } - unset($next4); - } + if ($MPEGaudioHeaderLengthCache[$head4] > 4) { + $WhereWeWere = mftell(); + $next4 = test(4); + if ($next4[0] == "\xFF") { + if (!isset($MPEGaudioHeaderDecodeCache[$next4])) { + $MPEGaudioHeaderDecodeCache[$next4] = MPEGaudioHeaderDecode($next4); + } + if (!isset($MPEGaudioHeaderValidCache[$next4])) { + $MPEGaudioHeaderValidCache[$next4] = MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false); + } + if ($MPEGaudioHeaderValidCache[$next4]) { + getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]); + getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]); + getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]); + getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]); + getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]); + if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) { + foreach ($Distribution as $key1 => $value1) { + foreach ($value1 as $key2 => $value2) { + $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned); + } + } + break; + } + continue; + } + } + unset($next4); + } - } - } - return true; + } + } + return true; } ?> okey diff --git a/ext/opcache/tests/phi_remove_002.phpt b/ext/opcache/tests/phi_remove_002.phpt index 3b0c429d501b..7e8b64bdf314 100644 --- a/ext/opcache/tests/phi_remove_002.phpt +++ b/ext/opcache/tests/phi_remove_002.phpt @@ -9,13 +9,13 @@ opcache.optimization_level=-1 --FILE-- login != $blogname )) ) { - test(); - } + if (! is_object( $user ) || ( is_object($user) && ( $user->login != $blogname )) ) { + test(); + } - $result = array('user' => $user); + $result = array('user' => $user); - return true; + return true; } ?> okey diff --git a/ext/opcache/tests/php_cli_server.inc b/ext/opcache/tests/php_cli_server.inc index e32cf9f97f3d..8d15b81c790b 100644 --- a/ext/opcache/tests/php_cli_server.inc +++ b/ext/opcache/tests/php_cli_server.inc @@ -4,64 +4,64 @@ define ("PHP_CLI_SERVER_PORT", 8964); define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT); function php_cli_server_start($ini = "") { - $php_executable = getenv('TEST_PHP_EXECUTABLE'); - $doc_root = __DIR__; + $php_executable = getenv('TEST_PHP_EXECUTABLE'); + $doc_root = __DIR__; - $ini_array = preg_split('/\s+/', trim($ini)); - $ini_array = array_map(function($arg) { - return trim($arg, '\'"'); - }, $ini_array); - $cmd = [$php_executable, '-t', $doc_root, '-n', ...$ini_array, '-S', PHP_CLI_SERVER_ADDRESS]; - $descriptorspec = array( - 0 => STDIN, - 1 => STDOUT, - 2 => array("null"), - ); - $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root, null, array("suppress_errors" => true)); + $ini_array = preg_split('/\s+/', trim($ini)); + $ini_array = array_map(function($arg) { + return trim($arg, '\'"'); + }, $ini_array); + $cmd = [$php_executable, '-t', $doc_root, '-n', ...$ini_array, '-S', PHP_CLI_SERVER_ADDRESS]; + $descriptorspec = array( + 0 => STDIN, + 1 => STDOUT, + 2 => array("null"), + ); + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root, null, array("suppress_errors" => true)); - // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' - // it might not be listening yet...need to wait until fsockopen() call returns - $error = "Unable to connect to server\n"; - for ($i=0; $i < 60; $i++) { - usleep(50000); // 50ms per try - $status = proc_get_status($handle); - $fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT); - // Failure, the server is no longer running - if (!($status && $status['running'])) { - $error = "Server is not running\n"; - break; - } - // Success, Connected to servers - if ($fp) { - $error = ''; - break; - } - } + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $error = "Unable to connect to server\n"; + for ($i=0; $i < 60; $i++) { + usleep(50000); // 50ms per try + $status = proc_get_status($handle); + $fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT); + // Failure, the server is no longer running + if (!($status && $status['running'])) { + $error = "Server is not running\n"; + break; + } + // Success, Connected to servers + if ($fp) { + $error = ''; + break; + } + } - if ($fp) { - fclose($fp); - } + if ($fp) { + fclose($fp); + } - if ($error) { - echo $error; - proc_terminate($handle); - exit(1); - } + if ($error) { + echo $error; + proc_terminate($handle); + exit(1); + } - register_shutdown_function( - function($handle) { - proc_terminate($handle); - /* Wait for server to shutdown */ - for ($i = 0; $i < 60; $i++) { - $status = proc_get_status($handle); - if (!($status && $status['running'])) { - break; - } - usleep(50000); - } - }, - $handle - ); + register_shutdown_function( + function($handle) { + proc_terminate($handle); + /* Wait for server to shutdown */ + for ($i = 0; $i < 60; $i++) { + $status = proc_get_status($handle); + if (!($status && $status['running'])) { + break; + } + usleep(50000); + } + }, + $handle + ); } ?> diff --git a/ext/opcache/tests/preload.inc b/ext/opcache/tests/preload.inc index 10de9390d033..52bb60e3484e 100644 --- a/ext/opcache/tests/preload.inc +++ b/ext/opcache/tests/preload.inc @@ -3,39 +3,39 @@ function f1() { } if (isset($rt)) { - function f2() { - } + function f2() { + } } interface a { - function foo(); - function bar(); + function foo(); + function bar(); } interface b { - function foo(); + function foo(); } abstract class c { - function bar() { } + function bar() { } } class x extends c implements a, b { - function foo() { } + function foo() { } } trait T1 { - static function foo() { - var_dump(__METHOD__); - } + static function foo() { + var_dump(__METHOD__); + } } trait T2 { - use T1; - static function bar() { - var_dump(__METHOD__); - } + use T1; + static function bar() { + var_dump(__METHOD__); + } } class Y { - use T2; + use T2; } class Z { @@ -50,9 +50,9 @@ function get_anon() { } if (!isset($rt)) { - eval("class Foo {}"); + eval("class Foo {}"); - class Bar extends Foo {} + class Bar extends Foo {} - eval("function f3() {} "); + eval("function f3() {} "); } diff --git a/ext/opcache/tests/preload_bug78014.inc b/ext/opcache/tests/preload_bug78014.inc index 84cc1d90c89d..9c469a72b6b1 100644 --- a/ext/opcache/tests/preload_bug78014.inc +++ b/ext/opcache/tests/preload_bug78014.inc @@ -1,2 +1,2 @@ - $value) { - switch ($key) { - case 'Trapped': - if ($value == null) { - $docInfo->$key = 1; - } - case 'CreationDate': - case 'ModDate': - $docInfo->$key = 2; - break; - } - } + foreach ($properties as $key => $value) { + switch ($key) { + case 'Trapped': + if ($value == null) { + $docInfo->$key = 1; + } + case 'CreationDate': + case 'ModDate': + $docInfo->$key = 2; + break; + } + } } ?> OK diff --git a/ext/opcache/tests/ssa_bug_011.phpt b/ext/opcache/tests/ssa_bug_011.phpt index c25e9c46abf6..253bdc78d5b9 100644 --- a/ext/opcache/tests/ssa_bug_011.phpt +++ b/ext/opcache/tests/ssa_bug_011.phpt @@ -5,11 +5,11 @@ Wrong assertion --FILE-- OK diff --git a/ext/openssl/tests/bug28382.phpt b/ext/openssl/tests/bug28382.phpt index f64e77dbd2a9..3d8cb528ba1d 100644 --- a/ext/openssl/tests/bug28382.phpt +++ b/ext/openssl/tests/bug28382.phpt @@ -10,9 +10,9 @@ $cert = file_get_contents(__DIR__ . "/bug28382cert.txt"); $ext = openssl_x509_parse($cert); var_dump($ext['extensions']); /* openssl 1.0 prepends the string "Full Name:" to the crlDistributionPoints array key. - For now, as this is the one difference only between 0.9.x and 1.x, it's handled with - placeholders to not to duplicate the test. When more diffs come, a duplication would - be probably a better solution. + For now, as this is the one difference only between 0.9.x and 1.x, it's handled with + placeholders to not to duplicate the test. When more diffs come, a duplication would + be probably a better solution. */ ?> --EXPECTF-- diff --git a/ext/openssl/tests/bug55646.phpt b/ext/openssl/tests/bug55646.phpt index a7e4152779ce..9de53590082f 100644 --- a/ext/openssl/tests/bug55646.phpt +++ b/ext/openssl/tests/bug55646.phpt @@ -36,7 +36,7 @@ $csr_res = openssl_csr_new( if (!$csr_res) { while ($e = openssl_error_string()) { $err = $e; - } + } die("Failed; last error: $err"); } openssl_csr_export($csr_res, $csr); diff --git a/ext/openssl/tests/bug60632.phpt b/ext/openssl/tests/bug60632.phpt index eb51276fa5bd..5993229a0040 100644 --- a/ext/openssl/tests/bug60632.phpt +++ b/ext/openssl/tests/bug60632.phpt @@ -8,11 +8,11 @@ if (!extension_loaded("openssl")) die("skip openssl not loaded"); 'sha256', - 'private_key_bits' => 1024, - 'private_key_type' => OPENSSL_KEYTYPE_RSA, - 'encrypt_key' => false, - 'config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf', + 'digest_alg' => 'sha256', + 'private_key_bits' => 1024, + 'private_key_type' => OPENSSL_KEYTYPE_RSA, + 'encrypt_key' => false, + 'config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf', )); $details = openssl_pkey_get_details($pkey); $test_pubkey = $details['key']; diff --git a/ext/openssl/tests/openssl_csr_get_public_key_basic.phpt b/ext/openssl/tests/openssl_csr_get_public_key_basic.phpt index 866eeae1690a..185e46539e3f 100644 --- a/ext/openssl/tests/openssl_csr_get_public_key_basic.phpt +++ b/ext/openssl/tests/openssl_csr_get_public_key_basic.phpt @@ -13,7 +13,7 @@ $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' . '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab'; $dh_details = array('p' => $phex, 'g' => '2'); $dh = openssl_pkey_new(array( - 'dh'=> array('p' => hex2bin($phex), 'g' => '2')) + 'dh'=> array('p' => hex2bin($phex), 'g' => '2')) ); $dn = array( diff --git a/ext/openssl/tests/openssl_csr_get_subject_basic.phpt b/ext/openssl/tests/openssl_csr_get_subject_basic.phpt index 87ab824f3590..8ebc51cc5063 100644 --- a/ext/openssl/tests/openssl_csr_get_subject_basic.phpt +++ b/ext/openssl/tests/openssl_csr_get_subject_basic.phpt @@ -13,7 +13,7 @@ $phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' . '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab'; $dh_details = array('p' => $phex, 'g' => '2'); $dh = openssl_pkey_new(array( - 'dh'=> array('p' => hex2bin($phex), 'g' => '2')) + 'dh'=> array('p' => hex2bin($phex), 'g' => '2')) ); $dn = array( diff --git a/ext/openssl/tests/openssl_decrypt_ccm.phpt b/ext/openssl/tests/openssl_decrypt_ccm.phpt index a5f01b87cea8..87b6d4b26465 100644 --- a/ext/openssl/tests/openssl_decrypt_ccm.phpt +++ b/ext/openssl/tests/openssl_decrypt_ccm.phpt @@ -22,13 +22,13 @@ foreach ($tests as $idx => $test) { // no IV var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, - NULL, $test['tag'], $test['aad'])); + NULL, $test['tag'], $test['aad'])); // failed because no AAD var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, - $test['iv'], $test['tag'])); + $test['iv'], $test['tag'])); // failed because wrong tag var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, - $test['iv'], str_repeat('x', 10), $test['aad'])); + $test['iv'], str_repeat('x', 10), $test['aad'])); ?> --EXPECTF-- diff --git a/ext/openssl/tests/openssl_decrypt_gcm.phpt b/ext/openssl/tests/openssl_decrypt_gcm.phpt index f03c4d2468d6..5c243a8fad34 100644 --- a/ext/openssl/tests/openssl_decrypt_gcm.phpt +++ b/ext/openssl/tests/openssl_decrypt_gcm.phpt @@ -22,13 +22,13 @@ foreach ($tests as $idx => $test) { // no IV var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, - NULL, $test['tag'], $test['aad'])); + NULL, $test['tag'], $test['aad'])); // failed because no AAD var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, - $test['iv'], $test['tag'])); + $test['iv'], $test['tag'])); // failed because wrong tag var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, - $test['iv'], str_repeat('x', 16), $test['aad'])); + $test['iv'], str_repeat('x', 16), $test['aad'])); ?> --EXPECTF-- diff --git a/ext/openssl/tests/openssl_error_string_basic.phpt b/ext/openssl/tests/openssl_error_string_basic.phpt index 3e3bbd03af7c..12875392f40a 100644 --- a/ext/openssl/tests/openssl_error_string_basic.phpt +++ b/ext/openssl/tests/openssl_error_string_basic.phpt @@ -9,15 +9,15 @@ function expect_openssl_errors($name, $expected_error_codes) { $expected_errors = array_fill_keys($expected_error_codes, false); $all_errors = array(); while (($error_string = openssl_error_string()) !== false) { - if (preg_match(",.+:([0-9A-F]+):.+,", $error_string, $m) > 0) { + if (preg_match(",.+:([0-9A-F]+):.+,", $error_string, $m) > 0) { $error_code = $m[1]; if (isset($expected_errors[$error_code])) { $expected_errors[$error_code] = true; } - $all_errors[$error_code] = $error_string; + $all_errors[$error_code] = $error_string; } else { - $all_errors[] = $error_string; - } + $all_errors[] = $error_string; + } } $fail = false; @@ -31,12 +31,12 @@ function expect_openssl_errors($name, $expected_error_codes) { if (!$fail) { echo "$name: ok\n"; } else { - echo "$name: uncaught errors\n"; - foreach ($all_errors as $code => $str) { - if (!isset($expected_errors[$code]) || !$expected_errors[$code]) { - echo "\t", $code, ": ", $str, "\n"; - } - } + echo "$name: uncaught errors\n"; + foreach ($all_errors as $code => $str) { + if (!isset($expected_errors[$code]) || !$expected_errors[$code]) { + echo "\t", $code, ": ", $str, "\n"; + } + } } } @@ -78,7 +78,7 @@ var_dump($enc_error); var_dump(openssl_error_string()); // internally OpenSSL ERR won't save more than 15 (16 - 1) errors so lets test it for ($i = 0; $i < 20; $i++) { - openssl_encrypt($data, $method, $enc_key); + openssl_encrypt($data, $method, $enc_key); } $error_queue_size = 0; while (($enc_error_new = openssl_error_string()) !== false) { diff --git a/ext/openssl/tests/openssl_pkcs7_verify_basic.phpt b/ext/openssl/tests/openssl_pkcs7_verify_basic.phpt index 699253f78954..63b181e58844 100644 --- a/ext/openssl/tests/openssl_pkcs7_verify_basic.phpt +++ b/ext/openssl/tests/openssl_pkcs7_verify_basic.phpt @@ -6,12 +6,12 @@ openssl_pkcs7_verify() tests --CLEAN-- diff --git a/ext/openssl/tests/openssl_pkey_new_basic.phpt b/ext/openssl/tests/openssl_pkey_new_basic.phpt index 41e67b2a0473..b2c37f6a87c0 100644 --- a/ext/openssl/tests/openssl_pkey_new_basic.phpt +++ b/ext/openssl/tests/openssl_pkey_new_basic.phpt @@ -5,7 +5,7 @@ openssl_pkey_new() basic usage tests --FILE-- array()); $dsa = array("dsa" => array()); diff --git a/ext/openssl/tests/sni_server_key_cert.phpt b/ext/openssl/tests/sni_server_key_cert.phpt index 58cf3d741df7..77a9d39f44d7 100644 --- a/ext/openssl/tests/sni_server_key_cert.phpt +++ b/ext/openssl/tests/sni_server_key_cert.phpt @@ -8,31 +8,31 @@ if (!function_exists("proc_open")) die("skip no proc_open"); --FILE-- [ - 'local_cert' => __DIR__ . '/domain1.pem', - 'SNI_server_certs' => [ - "cs.php.net" => [ - 'local_cert' => __DIR__ . "/sni_server_cs_cert.pem", - 'local_pk' => __DIR__ . "/sni_server_cs_key.pem" - ], - "uk.php.net" => [ - 'local_cert' => __DIR__ . "/sni_server_uk_cert.pem", - 'local_pk' => __DIR__ . "/sni_server_uk_key.pem" - ], - "us.php.net" => [ - 'local_cert' => __DIR__ . "/sni_server_us_cert.pem", - 'local_pk' => __DIR__ . "/sni_server_us_key.pem" - ], - ] - ]]); + $flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN; + $ctx = stream_context_create(['ssl' => [ + 'local_cert' => __DIR__ . '/domain1.pem', + 'SNI_server_certs' => [ + "cs.php.net" => [ + 'local_cert' => __DIR__ . "/sni_server_cs_cert.pem", + 'local_pk' => __DIR__ . "/sni_server_cs_key.pem" + ], + "uk.php.net" => [ + 'local_cert' => __DIR__ . "/sni_server_uk_cert.pem", + 'local_pk' => __DIR__ . "/sni_server_uk_key.pem" + ], + "us.php.net" => [ + 'local_cert' => __DIR__ . "/sni_server_us_cert.pem", + 'local_pk' => __DIR__ . "/sni_server_us_key.pem" + ], + ] + ]]); - $server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx); - phpt_notify(); + $server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx); + phpt_notify(); - for ($i=0; $i < 3; $i++) { - @stream_socket_accept($server, 3); - } + for ($i=0; $i < 3; $i++) { + @stream_socket_accept($server, 3); + } CODE; $clientCode = <<<'CODE' diff --git a/ext/openssl/tests/stream_security_level.phpt b/ext/openssl/tests/stream_security_level.phpt index b47ab97adc5d..ebb21c5d1aa4 100644 --- a/ext/openssl/tests/stream_security_level.phpt +++ b/ext/openssl/tests/stream_security_level.phpt @@ -18,33 +18,33 @@ $certFile = __DIR__ . DIRECTORY_SEPARATOR . 'stream_security_level.pem.tmp'; $cacertFile = __DIR__ . DIRECTORY_SEPARATOR . 'stream_security_level-ca.pem.tmp'; $serverCode = <<<'CODE' - $serverUri = "ssl://127.0.0.1:64322"; - $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; - $serverCtx = stream_context_create(['ssl' => [ - 'local_cert' => '%s' - ]]); + $serverUri = "ssl://127.0.0.1:64322"; + $serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN; + $serverCtx = stream_context_create(['ssl' => [ + 'local_cert' => '%s' + ]]); - $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); - phpt_notify(); + $server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx); + phpt_notify(); - @stream_socket_accept($server, 1); + @stream_socket_accept($server, 1); CODE; $serverCode = sprintf($serverCode, $certFile); $clientCode = <<<'CODE' - $serverUri = "ssl://127.0.0.1:64322"; - $clientFlags = STREAM_CLIENT_CONNECT; - $clientCtx = stream_context_create(['ssl' => [ - 'security_level' => %d, - 'verify_peer' => true, - 'cafile' => '%s', - 'verify_peer_name' => false - ]]); + $serverUri = "ssl://127.0.0.1:64322"; + $clientFlags = STREAM_CLIENT_CONNECT; + $clientCtx = stream_context_create(['ssl' => [ + 'security_level' => %d, + 'verify_peer' => true, + 'cafile' => '%s', + 'verify_peer_name' => false + ]]); - phpt_wait(); - $client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); + phpt_wait(); + $client = stream_socket_client($serverUri, $errno, $errstr, 1, $clientFlags, $clientCtx); - var_dump($client); + var_dump($client); CODE; $clientCode = sprintf($clientCode, $securityLevel, $cacertFile); diff --git a/ext/pcntl/tests/001.phpt b/ext/pcntl/tests/001.phpt index fe96d50f04ba..cdfdb0733f9e 100644 --- a/ext/pcntl/tests/001.phpt +++ b/ext/pcntl/tests/001.phpt @@ -11,60 +11,60 @@ Test pcntl wait functionality --FILE-- diff --git a/ext/pcntl/tests/pcntl_exec_2.phpt b/ext/pcntl/tests/pcntl_exec_2.phpt index 72274ede5fc0..18a3a6bc241c 100644 --- a/ext/pcntl/tests/pcntl_exec_2.phpt +++ b/ext/pcntl/tests/pcntl_exec_2.phpt @@ -10,14 +10,14 @@ if (!getenv("TEST_PHP_EXECUTABLE") || !is_executable(getenv("TEST_PHP_EXECUTABLE --FILE-- "1", - "FOO" => "BAR", - 1 => "long") + "PCNTL_EXEC_TEST_IS_CHILD" => "1", + "FOO" => "BAR", + 1 => "long") ); echo "nok\n"; diff --git a/ext/pcntl/tests/pcntl_fork_basic.phpt b/ext/pcntl/tests/pcntl_fork_basic.phpt index 59931df85096..3509e14a7fa2 100644 --- a/ext/pcntl/tests/pcntl_fork_basic.phpt +++ b/ext/pcntl/tests/pcntl_fork_basic.phpt @@ -15,10 +15,10 @@ echo "*** Test by calling method or function with its expected arguments, first $pid = pcntl_fork(); if ($pid > 0) { - pcntl_wait($status); - var_dump($pid); + pcntl_wait($status); + var_dump($pid); } else { - var_dump($pid); + var_dump($pid); } ?> --EXPECTF-- diff --git a/ext/pcntl/tests/pcntl_signal.phpt b/ext/pcntl/tests/pcntl_signal.phpt index 432b57e62ee6..cd55d9ad9673 100644 --- a/ext/pcntl/tests/pcntl_signal.phpt +++ b/ext/pcntl/tests/pcntl_signal.phpt @@ -6,13 +6,13 @@ pcntl_signal() --FILE-- --EXPECTF-- diff --git a/ext/pcntl/tests/pcntl_wait_rusage1.phpt b/ext/pcntl/tests/pcntl_wait_rusage1.phpt index b23195f91416..106c7088b893 100644 --- a/ext/pcntl/tests/pcntl_wait_rusage1.phpt +++ b/ext/pcntl/tests/pcntl_wait_rusage1.phpt @@ -7,34 +7,34 @@ pcntl_wait() and rusage --EXPECTF-- diff --git a/ext/pcntl/tests/pcntl_waitpid_rusage1.phpt b/ext/pcntl/tests/pcntl_waitpid_rusage1.phpt index 393dd59b9c30..d9776676a198 100644 --- a/ext/pcntl/tests/pcntl_waitpid_rusage1.phpt +++ b/ext/pcntl/tests/pcntl_waitpid_rusage1.phpt @@ -7,34 +7,34 @@ pcntl_waitpid() and rusage --EXPECTF-- diff --git a/ext/pcre/tests/001.phpt b/ext/pcre/tests/001.phpt index 313f7fdc679f..482ba1b73218 100644 --- a/ext/pcre/tests/001.phpt +++ b/ext/pcre/tests/001.phpt @@ -4,14 +4,14 @@ abusing preg_match() - (?P(\d{2})?\d\d) - - (?P(?:\d\d|[a-zA-Z]{2,3})) - - (?P[0-3]?\d)) - ~x', $s, $m)); + var_dump(preg_match('~ + (?P + (?P(\d{2})?\d\d) - + (?P(?:\d\d|[a-zA-Z]{2,3})) - + (?P[0-3]?\d)) + ~x', $s, $m)); - var_dump($m); + var_dump($m); } ?> diff --git a/ext/pcre/tests/003.phpt b/ext/pcre/tests/003.phpt index e697c375c6d5..b5fce131944a 100644 --- a/ext/pcre/tests/003.phpt +++ b/ext/pcre/tests/003.phpt @@ -4,15 +4,15 @@ abusing preg_match_all() - (?P(\d{2})?\d\d) - - (?P(?:\d\d|[a-zA-Z]{2,3})) - - (?P[0-3]?\d)) - ~x', - '2006-05-13 e outra data: "12-Aug-37"', $m, $flag)); + var_dump(preg_match_all('~ + (?P + (?P(\d{2})?\d\d) - + (?P(?:\d\d|[a-zA-Z]{2,3})) - + (?P[0-3]?\d)) + ~x', + '2006-05-13 e outra data: "12-Aug-37"', $m, $flag)); - var_dump($m); + var_dump($m); } ?> --EXPECT-- diff --git a/ext/pcre/tests/005.phpt b/ext/pcre/tests/005.phpt index 5eff83eba6b3..f988da054ae7 100644 --- a/ext/pcre/tests/005.phpt +++ b/ext/pcre/tests/005.phpt @@ -63,12 +63,12 @@ ext/ming/ming.o(.text+0x851): In function `zif_ming_setSWFCompression': /p2/var/php_gcov/PHP_5_2/ext/ming/ming.c:154: undefined reference to `Ming_setSWFCompression' "; - // Regular expression to select the error and warning information - // tuned for gcc 3.4, 4.0 and 4.1 - $gcc_regex = '/^((.+)(\(\.text\+0x[[:xdigit:]]+\))?: In function [`\'](\w+)\':\s+)?'. - '((?(1)(?(3)[^:\n]+|\2)|[^:\n]+)):(\d+): (?:(error|warning):\s+)?(.+)'. - str_repeat('(?:\s+\5:(\d+): (?:(error|warning):\s+)?(.+))?', 99). // capture up to 100 errors - '/mS'; + // Regular expression to select the error and warning information + // tuned for gcc 3.4, 4.0 and 4.1 + $gcc_regex = '/^((.+)(\(\.text\+0x[[:xdigit:]]+\))?: In function [`\'](\w+)\':\s+)?'. + '((?(1)(?(3)[^:\n]+|\2)|[^:\n]+)):(\d+): (?:(error|warning):\s+)?(.+)'. + str_repeat('(?:\s+\5:(\d+): (?:(error|warning):\s+)?(.+))?', 99). // capture up to 100 errors + '/mS'; var_dump(preg_match_all($gcc_regex, $sampledata, $m, PREG_SET_ORDER)); diff --git a/ext/pcre/tests/007.phpt b/ext/pcre/tests/007.phpt index 776bec27b2c7..bc213ad0e09e 100644 --- a/ext/pcre/tests/007.phpt +++ b/ext/pcre/tests/007.phpt @@ -10,10 +10,10 @@ if (@preg_match('/./u', '') === false) { --EXPECT-- array(7) { diff --git a/ext/pcre/tests/bug21732.phpt b/ext/pcre/tests/bug21732.phpt index 629e015a0613..a88d36c94c75 100644 --- a/ext/pcre/tests/bug21732.phpt +++ b/ext/pcre/tests/bug21732.phpt @@ -3,10 +3,10 @@ Bug #21732 (preg_replace() segfaults with invalid parameters) --FILE-- --EXPECT-- int(1) diff --git a/ext/pcre/tests/bug27103.phpt b/ext/pcre/tests/bug27103.phpt index 0264228aee4d..0b706010a04f 100644 --- a/ext/pcre/tests/bug27103.phpt +++ b/ext/pcre/tests/bug27103.phpt @@ -10,9 +10,9 @@ if (@preg_match('/./u', '') === false) { blub)|', 'callback', 'bla blub blah')); diff --git a/ext/pcre/tests/bug44191.phpt b/ext/pcre/tests/bug44191.phpt index 73fc29cd90f7..7d0b535dc661 100644 --- a/ext/pcre/tests/bug44191.phpt +++ b/ext/pcre/tests/bug44191.phpt @@ -8,7 +8,7 @@ $array = range(1, 10); preg_grep('/asdf/', $array); foreach ($array as $k => $v) { - print $k; + print $k; } ?> diff --git a/ext/pcre/tests/bug47662.phpt b/ext/pcre/tests/bug47662.phpt index abf65e6ca9fa..84b237864a8a 100644 --- a/ext/pcre/tests/bug47662.phpt +++ b/ext/pcre/tests/bug47662.phpt @@ -5,7 +5,7 @@ Bug #47662 (support more than 127 named subpatterns) $regex = '@'; for($bar=0; $bar<129; $bar++) { - $regex .= '((?P))'; + $regex .= '((?P))'; } $regex .= 'fo+bar@'; diff --git a/ext/pcre/tests/bug73392.phpt b/ext/pcre/tests/bug73392.phpt index 90606c9e05c0..704cc3d3515b 100644 --- a/ext/pcre/tests/bug73392.phpt +++ b/ext/pcre/tests/bug73392.phpt @@ -3,22 +3,22 @@ Bug #73392 (A use-after-free in zend allocator management) --FILE-- 'b', "/b/" => function () { return "c"; }, "/c/" => new Rep, "reporting" => array("Foo", "rep"), "a1" => array("Foo", "rep"), - ), 'a')); + array( + "/a/" => 'b', "/b/" => function () { return "c"; }, "/c/" => new Rep, "reporting" => array("Foo", "rep"), "a1" => array("Foo", "rep"), + ), 'a')); ?> --EXPECTF-- Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric or backslash in %sbug73392.php on line %d diff --git a/ext/pcre/tests/bug73483.phpt b/ext/pcre/tests/bug73483.phpt index fd107025271f..cbf4a2bdafc2 100644 --- a/ext/pcre/tests/bug73483.phpt +++ b/ext/pcre/tests/bug73483.phpt @@ -8,7 +8,7 @@ var_dump(preg_replace_callback($regex, function (array $matches) use($regex) { setlocale(LC_ALL, "en_US"); $ret = preg_replace($regex, "okey", $matches[0]); setlocale(LC_ALL, "C"); - return $ret; + return $ret; }, "dummy")); ?> --EXPECT-- diff --git a/ext/pcre/tests/bug77193.phpt b/ext/pcre/tests/bug77193.phpt index e143841e8321..4fdb603b8591 100644 --- a/ext/pcre/tests/bug77193.phpt +++ b/ext/pcre/tests/bug77193.phpt @@ -12,12 +12,12 @@ $text = '{CCM:CID_2}'; echo '1'; $mt = array(); preg_replace_callback( - '/([0-9]+)/i', - function ($matches) { - echo $matches[1]; - filter_var('http', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^http$/i']]); - }, - $text + '/([0-9]+)/i', + function ($matches) { + echo $matches[1]; + filter_var('http', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^http$/i']]); + }, + $text ); echo '3', "\n"; ?> diff --git a/ext/pcre/tests/cache_limit.phpt b/ext/pcre/tests/cache_limit.phpt index d6f3510e9d3f..d15b7675e476 100644 --- a/ext/pcre/tests/cache_limit.phpt +++ b/ext/pcre/tests/cache_limit.phpt @@ -12,10 +12,10 @@ $re = ''; $str = str_repeat('x', PREG_CACHE_SIZE); for ($i=0; $i < PREG_CACHE_SIZE; ++$i) { - $re .= '.'; - if (!preg_match("/$re/", $str)) { - die('non match. error'); - } + $re .= '.'; + if (!preg_match("/$re/", $str)) { + die('non match. error'); + } } var_dump(preg_match('/./', $str)); // this one was already deleted from the cache diff --git a/ext/pcre/tests/marks.phpt b/ext/pcre/tests/marks.phpt index 2a410834c61b..e718e7809356 100644 --- a/ext/pcre/tests/marks.phpt +++ b/ext/pcre/tests/marks.phpt @@ -4,7 +4,7 @@ Test support for PCRE marks --EXPECT-- diff --git a/ext/pcre/tests/preg_replace_callback2.phpt b/ext/pcre/tests/preg_replace_callback2.phpt index 6dab1a0cf20f..42c613726f39 100644 --- a/ext/pcre/tests/preg_replace_callback2.phpt +++ b/ext/pcre/tests/preg_replace_callback2.phpt @@ -4,7 +4,7 @@ preg_replace_callback() 2 'aksfjk', 12 => 'aa bb'))); diff --git a/ext/pcre/tests/preg_replace_callback_array.phpt b/ext/pcre/tests/preg_replace_callback_array.phpt index 01973eaa3298..ffefa2cc2634 100644 --- a/ext/pcre/tests/preg_replace_callback_array.phpt +++ b/ext/pcre/tests/preg_replace_callback_array.phpt @@ -4,41 +4,41 @@ preg_replace_callback_array() basic functions 'b', - "/b/" => function () { return "c"; }, - "/c/" => new Rep, - '/d/' => array("Foo", "rep")), 'a')); + array( + "/a/" => 'b', + "/b/" => function () { return "c"; }, + "/c/" => new Rep, + '/d/' => array("Foo", "rep")), 'a')); var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - "/c/" => new Rep, - "/b/" => function () { return "ok"; }, - '/d/' => array("Foo", "rep")), 'a')); + array( + "/a/" => 'b', + "/c/" => new Rep, + "/b/" => function () { return "ok"; }, + '/d/' => array("Foo", "rep")), 'a')); var_dump(preg_replace_callback_array( - array( - '/d/' => array("Foo", "rep"), - "/c/" => new Rep, - "/a/" => 'b', - "/b/" => function($a) { return "ok"; }), 'a', -1, $count)); + array( + '/d/' => array("Foo", "rep"), + "/c/" => new Rep, + "/a/" => 'b', + "/b/" => function($a) { return "ok"; }), 'a', -1, $count)); var_dump($count); ?> diff --git a/ext/pcre/tests/preg_replace_callback_array2.phpt b/ext/pcre/tests/preg_replace_callback_array2.phpt index 03d7a60eee83..f333d06dcb4e 100644 --- a/ext/pcre/tests/preg_replace_callback_array2.phpt +++ b/ext/pcre/tests/preg_replace_callback_array2.phpt @@ -8,16 +8,16 @@ $b = ""; var_dump(preg_replace_callback_array(array("xx" => "s"), $a, -1, $b)); var_dump($b); function f() { - static $count = 1; - throw new Exception($count); + static $count = 1; + throw new Exception($count); } var_dump(preg_replace_callback_array(array('/\w' => 'f'), 'z')); try { - var_dump(preg_replace_callback_array(array('/\w/' => 'f', '/.*/' => 'f'), 'z')); + var_dump(preg_replace_callback_array(array('/\w/' => 'f', '/.*/' => 'f'), 'z')); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } echo "Done\n"; diff --git a/ext/pcre/tests/preg_replace_edit_basic.phpt b/ext/pcre/tests/preg_replace_edit_basic.phpt index b272f379bee0..d5a251392abb 100644 --- a/ext/pcre/tests/preg_replace_edit_basic.phpt +++ b/ext/pcre/tests/preg_replace_edit_basic.phpt @@ -16,7 +16,7 @@ var_dump(preg_replace('<- This is a string$>', var_dump(preg_replace('<[0-35-9]>', '4', $string, //finds any number that's not 4 and replaces it with a 4 - '5', $count)); //limits to 5 replacements returns 444444789 + '5', $count)); //limits to 5 replacements returns 444444789 var_dump($count); //counts the number of replacements made (5) diff --git a/ext/pcre/tests/skip_001.inc b/ext/pcre/tests/skip_001.inc index 35434ece5b56..13035969b419 100644 --- a/ext/pcre/tests/skip_001.inc +++ b/ext/pcre/tests/skip_001.inc @@ -1,5 +1,5 @@ getAttribute(PDO::ATTR_DRIVER_NAME); $is_oci = $driver == 'oci'; if ($is_oci) { - $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val BLOB)'); + $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val BLOB)'); } else { - $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(256))'); + $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(256))'); } $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -29,13 +29,13 @@ fwrite($fp, "I am the LOB data"); rewind($fp); if ($is_oci) { - /* oracle is a bit different; you need to initiate a transaction otherwise - * the empty blob will be committed implicitly when the statement is - * executed */ - $db->beginTransaction(); - $insert = $db->prepare("insert into test (id, val) values (1, EMPTY_BLOB()) RETURNING val INTO :blob"); + /* oracle is a bit different; you need to initiate a transaction otherwise + * the empty blob will be committed implicitly when the statement is + * executed */ + $db->beginTransaction(); + $insert = $db->prepare("insert into test (id, val) values (1, EMPTY_BLOB()) RETURNING val INTO :blob"); } else { - $insert = $db->prepare("insert into test (id, val) values (1, :blob)"); + $insert = $db->prepare("insert into test (id, val) values (1, :blob)"); } $insert->bindValue(':blob', $fp, PDO::PARAM_LOB); $insert->execute(); diff --git a/ext/pdo/tests/bug_34687.phpt b/ext/pdo/tests/bug_34687.phpt index f25da54893a3..c260ddb27103 100644 --- a/ext/pdo/tests/bug_34687.phpt +++ b/ext/pdo/tests/bug_34687.phpt @@ -20,10 +20,10 @@ $x = $db->query("UPDATE non_existent_pdo_test_table set foo = 'bar'"); var_dump($x); $code = $db->errorCode(); if ($code !== '00000' && strlen($code)) { - echo "OK: $code\n"; + echo "OK: $code\n"; } else { - echo "ERR: $code\n"; - print_r($db->errorInfo()); + echo "ERR: $code\n"; + print_r($db->errorInfo()); } ?> diff --git a/ext/pdo/tests/bug_35671.phpt b/ext/pdo/tests/bug_35671.phpt index fae84652f857..c5e4bbb609d5 100644 --- a/ext/pdo/tests/bug_35671.phpt +++ b/ext/pdo/tests/bug_35671.phpt @@ -20,9 +20,9 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $insert = $db->prepare("insert into test (field1, field2, field3) values (:value1, :value2, :value3)"); $parm = array( - ":value1" => 15, - ":value2" => 20, - ":value3" => 25 + ":value1" => 15, + ":value2" => 20, + ":value3" => 25 ); $insert->execute($parm); diff --git a/ext/pdo/tests/bug_42917.phpt b/ext/pdo/tests/bug_42917.phpt index 814086a56a17..073e9c0126ec 100644 --- a/ext/pdo/tests/bug_42917.phpt +++ b/ext/pdo/tests/bug_42917.phpt @@ -17,7 +17,7 @@ $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."')"); + $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); } $res = $db->query("SELECT a,b FROM test"); diff --git a/ext/pdo/tests/bug_43130.phpt b/ext/pdo/tests/bug_43130.phpt index 4fea1a78ae97..bf65bf0513f8 100644 --- a/ext/pdo/tests/bug_43130.phpt +++ b/ext/pdo/tests/bug_43130.phpt @@ -20,12 +20,12 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); $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."')"); + $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); } $stmt = $db->prepare("SELECT a FROM test WHERE b=:id-value"); diff --git a/ext/pdo/tests/bug_43139.phpt b/ext/pdo/tests/bug_43139.phpt index 066eb2ed18f5..3b456a2cccbb 100644 --- a/ext/pdo/tests/bug_43139.phpt +++ b/ext/pdo/tests/bug_43139.phpt @@ -19,9 +19,9 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $from = ''; if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') { - $from = 'from dual'; + $from = 'from dual'; } else if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'firebird') { - $from = 'FROM RDB$DATABASE'; + $from = 'FROM RDB$DATABASE'; } var_dump($db->query("select 0 as abc, 1 as xyz, 2 as def $from")->fetchAll(PDO::FETCH_GROUP)); diff --git a/ext/pdo/tests/bug_44159.phpt b/ext/pdo/tests/bug_44159.phpt index 26b0e33b606c..bd7aca0e93f6 100644 --- a/ext/pdo/tests/bug_44159.phpt +++ b/ext/pdo/tests/bug_44159.phpt @@ -16,9 +16,9 @@ $pdo = new PDO("sqlite:".__DIR__."/foo.db"); $attrs = array(PDO::ATTR_STATEMENT_CLASS, PDO::ATTR_STRINGIFY_FETCHES, PDO::NULL_TO_STRING); foreach ($attrs as $attr) { - var_dump($pdo->setAttribute($attr, NULL)); - var_dump($pdo->setAttribute($attr, 1)); - var_dump($pdo->setAttribute($attr, 'nonsense')); + var_dump($pdo->setAttribute($attr, NULL)); + var_dump($pdo->setAttribute($attr, 1)); + var_dump($pdo->setAttribute($attr, 'nonsense')); } @unlink(__DIR__."/foo.db"); diff --git a/ext/pdo/tests/bug_44409.phpt b/ext/pdo/tests/bug_44409.phpt index f32eb879bda3..a378301f4179 100644 --- a/ext/pdo/tests/bug_44409.phpt +++ b/ext/pdo/tests/bug_44409.phpt @@ -19,20 +19,20 @@ $db->exec("INSERT INTO test (dat) VALUES ('Data from DB')"); class bug44409 implements Serializable { - public function __construct() - { - printf("Method called: %s()\n", __METHOD__); - } - - public function serialize() - { - return "any data from serizalize()"; - } - - public function unserialize($dat) - { - printf("Method called: %s(%s)\n", __METHOD__, var_export($dat, true)); - } + public function __construct() + { + printf("Method called: %s()\n", __METHOD__); + } + + public function serialize() + { + return "any data from serizalize()"; + } + + public function unserialize($dat) + { + printf("Method called: %s(%s)\n", __METHOD__, var_export($dat, true)); + } } $stmt = $db->query("SELECT * FROM test"); diff --git a/ext/pdo/tests/bug_44861.phpt b/ext/pdo/tests/bug_44861.phpt index ec2d779fb555..6ca5b175636b 100644 --- a/ext/pdo/tests/bug_44861.phpt +++ b/ext/pdo/tests/bug_44861.phpt @@ -27,11 +27,11 @@ $db = PDOTest::factory(); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') { - $from = 'FROM DUAL'; - $ob = '1'; + $from = 'FROM DUAL'; + $ob = '1'; } else { - $from = ''; - $ob = 'r'; + $from = ''; + $ob = 'r'; } $query = "SELECT 'row1' AS r $from UNION SELECT 'row2' $from UNION SELECT 'row3' $from UNION SELECT 'row4' $from ORDER BY $ob"; diff --git a/ext/pdo/tests/bug_47769.phpt b/ext/pdo/tests/bug_47769.phpt index c0ac8350ce55..1c4395cc4bf1 100644 --- a/ext/pdo/tests/bug_47769.phpt +++ b/ext/pdo/tests/bug_47769.phpt @@ -10,18 +10,18 @@ if (!extension_loaded("pdo_sqlite")) class test extends PDO { - protected function isProtected() { - echo "this is a protected method.\n"; - } - private function isPrivate() { - echo "this is a private method.\n"; - } + protected function isProtected() { + echo "this is a protected method.\n"; + } + private function isPrivate() { + echo "this is a private method.\n"; + } public function quote($str, $paramtype = NULL) { - $this->isProtected(); - $this->isPrivate(); - print $str ."\n"; - } + $this->isProtected(); + $this->isPrivate(); + print $str ."\n"; + } } $test = new test('sqlite::memory:'); diff --git a/ext/pdo/tests/bug_60665.phpt b/ext/pdo/tests/bug_60665.phpt index fef212ae95d5..efc43e4b501e 100644 --- a/ext/pdo/tests/bug_60665.phpt +++ b/ext/pdo/tests/bug_60665.phpt @@ -14,9 +14,9 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) { - case 'oci': $from = 'from dual'; break; - case 'firebird': $from = 'from rdb$database'; break; - default: $from = ''; break; + case 'oci': $from = 'from dual'; break; + case 'firebird': $from = 'from rdb$database'; break; + default: $from = ''; break; } $statement = $db->prepare("SELECT NULL AS null_value, 0 AS zero, 1 AS one $from"); $statement->execute(); diff --git a/ext/pdo/tests/bug_61292.phpt b/ext/pdo/tests/bug_61292.phpt index f82619d20e1c..07501d594f94 100644 --- a/ext/pdo/tests/bug_61292.phpt +++ b/ext/pdo/tests/bug_61292.phpt @@ -15,25 +15,25 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; class Database_SQL extends PDO { - function __construct() - { + function __construct() + { $dsn = getenv('PDOTEST_DSN'); $user = getenv('PDOTEST_USER'); $pass = getenv('PDOTEST_PASS'); if ($user === false) $user = NULL; if ($pass === false) $pass = NULL; - $options = array(PDO::ATTR_PERSISTENT => TRUE); + $options = array(PDO::ATTR_PERSISTENT => TRUE); - parent::__construct($dsn, $user, $pass, $options); - } + parent::__construct($dsn, $user, $pass, $options); + } - var $bar = array(); + var $bar = array(); - public function foo() - { - var_dump($this->bar); - } + public function foo() + { + var_dump($this->bar); + } } (new Database_SQL)->foo(); diff --git a/ext/pdo/tests/bug_65946.phpt b/ext/pdo/tests/bug_65946.phpt index db7671de993c..7c8f8c93cba7 100644 --- a/ext/pdo/tests/bug_65946.phpt +++ b/ext/pdo/tests/bug_65946.phpt @@ -17,22 +17,22 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $db->exec('CREATE TABLE test(id int)'); $db->exec('INSERT INTO test VALUES(1)'); switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) { - case 'dblib': - $sql = 'SELECT TOP :limit * FROM test'; - break; - case 'odbc': - $sql = 'SELECT TOP (:limit) * FROM test'; - break; - case 'firebird': - $sql = 'SELECT FIRST :limit * FROM test'; - break; - case 'oci': - //$sql = 'SELECT * FROM test FETCH FIRST :limit ROWS ONLY'; // Oracle 12c syntax - $sql = "select id from (select a.*, rownum rnum from (SELECT * FROM test) a where rownum <= :limit)"; - break; - default: - $sql = 'SELECT * FROM test LIMIT :limit'; - break; + case 'dblib': + $sql = 'SELECT TOP :limit * FROM test'; + break; + case 'odbc': + $sql = 'SELECT TOP (:limit) * FROM test'; + break; + case 'firebird': + $sql = 'SELECT FIRST :limit * FROM test'; + break; + case 'oci': + //$sql = 'SELECT * FROM test FETCH FIRST :limit ROWS ONLY'; // Oracle 12c syntax + $sql = "select id from (select a.*, rownum rnum from (SELECT * FROM test) a where rownum <= :limit)"; + break; + default: + $sql = 'SELECT * FROM test LIMIT :limit'; + break; } $stmt = $db->prepare($sql); $stmt->bindValue('limit', 1, PDO::PARAM_INT); diff --git a/ext/pdo/tests/bug_71447.phpt b/ext/pdo/tests/bug_71447.phpt index 64bdc199fec2..1db3ccf151e2 100644 --- a/ext/pdo/tests/bug_71447.phpt +++ b/ext/pdo/tests/bug_71447.phpt @@ -22,9 +22,9 @@ $db->exec('INSERT INTO test VALUES(1)'); // Comment without quotes or placeholders $stmt = $db->prepare(" - SELECT -- That's all folks! - '\"abc\":8000' - FROM test + SELECT -- That's all folks! + '\"abc\":8000' + FROM test "); $stmt->execute(); @@ -32,9 +32,9 @@ var_dump($stmt->fetchColumn()); // Comment and placeholder within a string $stmt = $db->prepare(" - SELECT - '\"abc\":8001 -- Wat?' - FROM test + SELECT + '\"abc\":8001 -- Wat?' + FROM test "); $stmt->execute(); @@ -42,9 +42,9 @@ var_dump($stmt->fetchColumn()); // Comment with single quote $stmt = $db->prepare(" - SELECT -- That's all folks! - '\"abc\":8002' - FROM test + SELECT -- That's all folks! + '\"abc\":8002' + FROM test "); $stmt->execute(); @@ -52,9 +52,9 @@ var_dump($stmt->fetchColumn()); // C-Style comment with single quote $stmt = $db->prepare(" - SELECT /* That's all folks! */ - '\"abc\":8003' - FROM test + SELECT /* That's all folks! */ + '\"abc\":8003' + FROM test "); $stmt->execute(); @@ -62,9 +62,9 @@ var_dump($stmt->fetchColumn()); // Comment with double quote $stmt = $db->prepare(" - SELECT -- Is it only \"single quotes? - '\"abc\":8004' - FROM test + SELECT -- Is it only \"single quotes? + '\"abc\":8004' + FROM test "); $stmt->execute(); @@ -72,10 +72,10 @@ var_dump($stmt->fetchColumn()); // Comment with ? placeholder $stmt = $db->prepare(" - SELECT -- What about question marks here? - * - FROM test - WHERE id = ? + SELECT -- What about question marks here? + * + FROM test + WHERE id = ? "); $stmt->execute([1]); @@ -83,10 +83,10 @@ var_dump($stmt->fetchColumn()); // Comment with named placeholder $stmt = $db->prepare(" - SELECT -- What about placeholders :bar - * - FROM test - WHERE id = :id + SELECT -- What about placeholders :bar + * + FROM test + WHERE id = :id "); $stmt->execute(['id' => 1]); diff --git a/ext/pdo/tests/bug_71885.phpt b/ext/pdo/tests/bug_71885.phpt index 25ddbdd90f86..8eb097f5d944 100644 --- a/ext/pdo/tests/bug_71885.phpt +++ b/ext/pdo/tests/bug_71885.phpt @@ -22,27 +22,27 @@ $db->exec("CREATE TABLE test (a int)"); $sql = "SELECT * FROM test WHERE a ?? 1"; try { - $db->exec($sql); + $db->exec($sql); } catch (PDOException $e) { - var_dump(strpos($e->getMessage(), "?") !== false); + var_dump(strpos($e->getMessage(), "?") !== false); } try { - $stmt = $db->prepare($sql); - $stmt->execute(); + $stmt = $db->prepare($sql); + $stmt->execute(); } catch (PDOException $e) { - var_dump(strpos($e->getMessage(), "?") !== false); + var_dump(strpos($e->getMessage(), "?") !== false); } if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); } try { - $stmt = $db->prepare($sql); - $stmt->execute(); + $stmt = $db->prepare($sql); + $stmt->execute(); } catch (PDOException $e) { - var_dump(strpos($e->getMessage(), "?") !== false); + var_dump(strpos($e->getMessage(), "?") !== false); } ?> diff --git a/ext/pdo/tests/pdo.inc b/ext/pdo/tests/pdo.inc index 8089236bbcdc..214764fc4736 100644 --- a/ext/pdo/tests/pdo.inc +++ b/ext/pdo/tests/pdo.inc @@ -2,9 +2,9 @@ function set_sql($name, $query) { - if (empty($GLOBALS['SQL'][$name])) - { - $GLOBALS['SQL'][$name] = $query; - } + if (empty($GLOBALS['SQL'][$name])) + { + $GLOBALS['SQL'][$name] = $query; + } } ?> diff --git a/ext/pdo/tests/pdo_005.phpt b/ext/pdo/tests/pdo_005.phpt index 6e89aad744c2..25eab7782fc6 100644 --- a/ext/pdo/tests/pdo_005.phpt +++ b/ext/pdo/tests/pdo_005.phpt @@ -23,20 +23,20 @@ $stmt = $db->prepare('SELECT id, val, val2 from test'); class TestBase { - public $id; - protected $val; - private $val2; + public $id; + protected $val; + private $val2; } class TestDerived extends TestBase { - protected $row; + protected $row; - public function __construct(&$row) - { - echo __METHOD__ . "($row,{$this->id})\n"; - $this->row = $row++; - } + public function __construct(&$row) + { + echo __METHOD__ . "($row,{$this->id})\n"; + $this->row = $row++; + } } $stmt->execute(); diff --git a/ext/pdo/tests/pdo_009.phpt b/ext/pdo/tests/pdo_009.phpt index bc63aa66fda6..7f332db7428d 100644 --- a/ext/pdo/tests/pdo_009.phpt +++ b/ext/pdo/tests/pdo_009.phpt @@ -28,26 +28,26 @@ $stmt = $db->prepare('SELECT classtypes.name, test.id AS id, test.val AS val FRO class Test1 { - public function __construct() - { - echo __METHOD__ . "()\n"; - } + public function __construct() + { + echo __METHOD__ . "()\n"; + } } class Test2 { - public function __construct() - { - echo __METHOD__ . "()\n"; - } + public function __construct() + { + echo __METHOD__ . "()\n"; + } } class Test3 { - public function __construct() - { - echo __METHOD__ . "()\n"; - } + public function __construct() + { + echo __METHOD__ . "()\n"; + } } $stmt->execute(); diff --git a/ext/pdo/tests/pdo_010.phpt b/ext/pdo/tests/pdo_010.phpt index f5b6bafbb941..7cc4ff15f708 100644 --- a/ext/pdo/tests/pdo_010.phpt +++ b/ext/pdo/tests/pdo_010.phpt @@ -28,26 +28,26 @@ $stmt = $db->prepare('SELECT classtypes.name, test.grp AS grp, test.id AS id, te class Test1 { - public function __construct() - { - echo __METHOD__ . "()\n"; - } + public function __construct() + { + echo __METHOD__ . "()\n"; + } } class Test2 { - public function __construct() - { - echo __METHOD__ . "()\n"; - } + public function __construct() + { + echo __METHOD__ . "()\n"; + } } class Test3 { - public function __construct() - { - echo __METHOD__ . "()\n"; - } + public function __construct() + { + echo __METHOD__ . "()\n"; + } } diff --git a/ext/pdo/tests/pdo_011.phpt b/ext/pdo/tests/pdo_011.phpt index e014ff9c9bad..7985d4406ac6 100644 --- a/ext/pdo/tests/pdo_011.phpt +++ b/ext/pdo/tests/pdo_011.phpt @@ -22,16 +22,16 @@ $db->exec('INSERT INTO test VALUES(4, \'D\', \'Group2\')'); class DerivedStatement extends PDOStatement { - private function __construct($name, $db) - { - $this->name = $name; - echo __METHOD__ . "($name)\n"; - } + private function __construct($name, $db) + { + $this->name = $name; + echo __METHOD__ . "($name)\n"; + } - function reTrieve($id, $val) { - echo __METHOD__ . "($id,$val)\n"; - return array($id=>$val); - } + function reTrieve($id, $val) { + echo __METHOD__ . "($id,$val)\n"; + return array($id=>$val); + } } $select1 = $db->prepare('SELECT grp, id FROM test'); @@ -40,24 +40,24 @@ $derived = $db->prepare('SELECT id, val FROM test', array(PDO::ATTR_STATEMENT_CL class Test1 { - public function __construct($id, $val) - { - echo __METHOD__ . "($id,$val)\n"; - $this->id = $id; - $this->val = $val; - } + public function __construct($id, $val) + { + echo __METHOD__ . "($id,$val)\n"; + $this->id = $id; + $this->val = $val; + } - static public function factory($id, $val) - { - echo __METHOD__ . "($id,$val)\n"; - return new self($id, $val); - } + static public function factory($id, $val) + { + echo __METHOD__ . "($id,$val)\n"; + return new self($id, $val); + } } function test($id,$val='N/A') { - echo __METHOD__ . "($id,$val)\n"; - return array($id=>$val); + echo __METHOD__ . "($id,$val)\n"; + return array($id=>$val); } $f = new Test1(0,0); diff --git a/ext/pdo/tests/pdo_012.phpt b/ext/pdo/tests/pdo_012.phpt index 0570f446cf24..1acad839de44 100644 --- a/ext/pdo/tests/pdo_012.phpt +++ b/ext/pdo/tests/pdo_012.phpt @@ -25,10 +25,10 @@ var_dump($stmt->fetchAll()); class Test { - function __construct($name = 'N/A') - { - echo __METHOD__ . "($name)\n"; - } + function __construct($name = 'N/A') + { + echo __METHOD__ . "($name)\n"; + } } unset($stmt); diff --git a/ext/pdo/tests/pdo_013.phpt b/ext/pdo/tests/pdo_013.phpt index ab4073805107..133fa40f19c1 100644 --- a/ext/pdo/tests/pdo_013.phpt +++ b/ext/pdo/tests/pdo_013.phpt @@ -26,22 +26,22 @@ $stmt->execute(); $stmt->setFetchMode(PDO::FETCH_NUM); foreach ($stmt as $data) { - var_dump($data); + var_dump($data); } class Test { - function __construct($name = 'N/A') - { - echo __METHOD__ . "($name)\n"; - } + function __construct($name = 'N/A') + { + echo __METHOD__ . "($name)\n"; + } } unset($stmt); foreach ($db->query($SELECT, PDO::FETCH_CLASS, 'Test') as $data) { - var_dump($data); + var_dump($data); } unset($stmt); @@ -50,7 +50,7 @@ $stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW')); foreach($stmt as $data) { - var_dump($data); + var_dump($data); } ?> --EXPECTF-- diff --git a/ext/pdo/tests/pdo_014.phpt b/ext/pdo/tests/pdo_014.phpt index 5c7774f2cd9a..ef47fd89d09f 100644 --- a/ext/pdo/tests/pdo_014.phpt +++ b/ext/pdo/tests/pdo_014.phpt @@ -21,10 +21,10 @@ $SELECT = 'SELECT val, grp FROM test'; class Test { - function __construct($name = 'N/A') - { - echo __METHOD__ . "($name)\n"; - } + function __construct($name = 'N/A') + { + echo __METHOD__ . "($name)\n"; + } } $stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW')); @@ -35,7 +35,7 @@ $it = new IteratorIterator($stmt); /* check if we can convert that thing */ foreach($it as $data) { - var_dump($data); + var_dump($data); } $it->next(); /* must be allowed */ @@ -44,26 +44,26 @@ var_dump($it->valid()); /* must return false */ class PDOStatementAggregate extends PDOStatement implements IteratorAggregate { - private function __construct() - { - echo __METHOD__ . "\n"; - $this->setFetchMode(PDO::FETCH_NUM); - /* default fetch mode is BOTH, so we see if the ctor can overwrite that */ - } + private function __construct() + { + echo __METHOD__ . "\n"; + $this->setFetchMode(PDO::FETCH_NUM); + /* default fetch mode is BOTH, so we see if the ctor can overwrite that */ + } - function getIterator() - { - echo __METHOD__ . "\n"; - $this->execute(); - return new IteratorIterator($this, 'PDOStatement'); - } + function getIterator() + { + echo __METHOD__ . "\n"; + $this->execute(); + return new IteratorIterator($this, 'PDOStatement'); + } } $stmt = $db->prepare($SELECT, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementAggregate'))); foreach($stmt as $data) { - var_dump($data); + var_dump($data); } ?> diff --git a/ext/pdo/tests/pdo_016.phpt b/ext/pdo/tests/pdo_016.phpt index 6879faa5b90f..69a70a1a4b14 100644 --- a/ext/pdo/tests/pdo_016.phpt +++ b/ext/pdo/tests/pdo_016.phpt @@ -16,7 +16,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } $db->exec('CREATE TABLE test(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); @@ -42,7 +42,7 @@ $stmt2->bindColumn('txt', $txt); $stmt2->execute(); while($stmt2->fetch(PDO::FETCH_BOUND)) { - var_dump(array($idx=>$txt)); + var_dump(array($idx=>$txt)); } echo "===ALONE===\n"; @@ -55,26 +55,26 @@ $stmt4->bindParam(':txt', $txt); /* using same name */ foreach($cont as $idx => $txt) { - var_dump(array($idx=>$txt)); - var_dump($stmt3->execute()); - - if ($idx == 0) { - /* portability-wise, you may only bindColumn()s - * after execute() has been called at least once */ - $stmt3->bindColumn('txt', $col1); - } - var_dump($stmt3->fetch(PDO::FETCH_BOUND)); - $stmt3->closeCursor(); - - var_dump($stmt4->execute()); - if ($idx == 0) { - /* portability-wise, you may only bindColumn()s - * after execute() has been called at least once */ - $stmt4->bindColumn('idx', $col2); - } - var_dump($stmt4->fetch(PDO::FETCH_BOUND)); - $stmt4->closeCursor(); - var_dump(array($col2=>$col1)); + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt3->bindColumn('txt', $col1); + } + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + + var_dump($stmt4->execute()); + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt4->bindColumn('idx', $col2); + } + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump(array($col2=>$col1)); } echo "===REBIND/SAME===\n"; @@ -83,15 +83,15 @@ $stmt4->bindColumn('idx', $col1); foreach($cont as $idx => $txt) { - var_dump(array($idx=>$txt)); - var_dump($stmt3->execute()); - var_dump($stmt3->fetch(PDO::FETCH_BOUND)); - $stmt3->closeCursor(); - var_dump($col1); - var_dump($stmt4->execute()); - var_dump($stmt4->fetch(PDO::FETCH_BOUND)); - $stmt4->closeCursor(); - var_dump($col1); + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + var_dump($col1); + var_dump($stmt4->execute()); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump($col1); } echo "===REBIND/CONFLICT===\n"; @@ -102,7 +102,7 @@ $stmt2->execute(); while($stmt2->fetch(PDO::FETCH_BOUND)) { - var_dump($col1); + var_dump($col1); } diff --git a/ext/pdo/tests/pdo_016a.phpt b/ext/pdo/tests/pdo_016a.phpt index 9f07516f8e9e..5f64d462d602 100644 --- a/ext/pdo/tests/pdo_016a.phpt +++ b/ext/pdo/tests/pdo_016a.phpt @@ -16,7 +16,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } $db->exec('CREATE TABLE test(idx int NOT NULL PRIMARY KEY, txt VARCHAR(20))'); @@ -42,7 +42,7 @@ $stmt2->bindColumn('txt', $txt); $stmt2->execute(); while($stmt2->fetch(PDO::FETCH_BOUND)) { - var_dump(array($idx=>$txt)); + var_dump(array($idx=>$txt)); } echo "===ALONE===\n"; @@ -55,26 +55,26 @@ $stmt4->bindParam('txt', $txt); /* using same name */ foreach($cont as $idx => $txt) { - var_dump(array($idx=>$txt)); - var_dump($stmt3->execute()); - - if ($idx == 0) { - /* portability-wise, you may only bindColumn()s - * after execute() has been called at least once */ - $stmt3->bindColumn('txt', $col1); - } - var_dump($stmt3->fetch(PDO::FETCH_BOUND)); - $stmt3->closeCursor(); - - var_dump($stmt4->execute()); - if ($idx == 0) { - /* portability-wise, you may only bindColumn()s - * after execute() has been called at least once */ - $stmt4->bindColumn('idx', $col2); - } - var_dump($stmt4->fetch(PDO::FETCH_BOUND)); - $stmt4->closeCursor(); - var_dump(array($col2=>$col1)); + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt3->bindColumn('txt', $col1); + } + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + + var_dump($stmt4->execute()); + if ($idx == 0) { + /* portability-wise, you may only bindColumn()s + * after execute() has been called at least once */ + $stmt4->bindColumn('idx', $col2); + } + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump(array($col2=>$col1)); } echo "===REBIND/SAME===\n"; @@ -83,15 +83,15 @@ $stmt4->bindColumn('idx', $col1); foreach($cont as $idx => $txt) { - var_dump(array($idx=>$txt)); - var_dump($stmt3->execute()); - var_dump($stmt3->fetch(PDO::FETCH_BOUND)); - $stmt3->closeCursor(); - var_dump($col1); - var_dump($stmt4->execute()); - var_dump($stmt4->fetch(PDO::FETCH_BOUND)); - $stmt4->closeCursor(); - var_dump($col1); + var_dump(array($idx=>$txt)); + var_dump($stmt3->execute()); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); + $stmt3->closeCursor(); + var_dump($col1); + var_dump($stmt4->execute()); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); + $stmt4->closeCursor(); + var_dump($col1); } echo "===REBIND/CONFLICT===\n"; @@ -102,7 +102,7 @@ $stmt2->execute(); while($stmt2->fetch(PDO::FETCH_BOUND)) { - var_dump($col1); + var_dump($col1); } diff --git a/ext/pdo/tests/pdo_017.phpt b/ext/pdo/tests/pdo_017.phpt index 32018da6e1a3..f06ebbdc435f 100644 --- a/ext/pdo/tests/pdo_017.phpt +++ b/ext/pdo/tests/pdo_017.phpt @@ -29,10 +29,10 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc'); - $suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db); + require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc'); + $suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db); } else { - $suf = ''; + $suf = ''; } $db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))'.$suf); @@ -43,8 +43,8 @@ $delete = $db->prepare('DELETE FROM test'); function countRows($action) { global $db; - $select = $db->prepare('SELECT COUNT(*) FROM test'); - $select->execute(); + $select = $db->prepare('SELECT COUNT(*) FROM test'); + $select->execute(); $res = $select->fetchColumn(); return "Counted $res rows after $action.\n"; } diff --git a/ext/pdo/tests/pdo_018.phpt b/ext/pdo/tests/pdo_018.phpt index b99cb80968ad..d35e078b32de 100644 --- a/ext/pdo/tests/pdo_018.phpt +++ b/ext/pdo/tests/pdo_018.phpt @@ -16,50 +16,50 @@ $db = PDOTest::factory(); class TestBase implements Serializable { - public $BasePub = 'Public'; - protected $BasePro = 'Protected'; - private $BasePri = 'Private'; + public $BasePub = 'Public'; + protected $BasePro = 'Protected'; + private $BasePri = 'Private'; - function serialize() - { - $serialized = array(); - foreach($this as $prop => $val) { - $serialized[$prop] = $val; - } - $serialized = serialize($serialized); - echo __METHOD__ . "() = '$serialized'\n"; - return $serialized; - } + function serialize() + { + $serialized = array(); + foreach($this as $prop => $val) { + $serialized[$prop] = $val; + } + $serialized = serialize($serialized); + echo __METHOD__ . "() = '$serialized'\n"; + return $serialized; + } - function unserialize($serialized) - { - echo __METHOD__ . "($serialized)\n"; - foreach(unserialize($serialized) as $prop => $val) { - $this->$prop = '#'.$val; - } - return true; - } + function unserialize($serialized) + { + echo __METHOD__ . "($serialized)\n"; + foreach(unserialize($serialized) as $prop => $val) { + $this->$prop = '#'.$val; + } + return true; + } } class TestDerived extends TestBase { - public $BasePub = 'DerivedPublic'; - protected $BasePro = 'DerivdeProtected'; - public $DerivedPub = 'Public'; - protected $DerivedPro = 'Protected'; - private $DerivedPri = 'Private'; + public $BasePub = 'DerivedPublic'; + protected $BasePro = 'DerivdeProtected'; + public $DerivedPub = 'Public'; + protected $DerivedPro = 'Protected'; + private $DerivedPri = 'Private'; - function serialize() - { - echo __METHOD__ . "()\n"; - return TestBase::serialize(); - } + function serialize() + { + echo __METHOD__ . "()\n"; + return TestBase::serialize(); + } - function unserialize($serialized) - { - echo __METHOD__ . "()\n"; - return TestBase::unserialize($serialized); - } + function unserialize($serialized) + { + echo __METHOD__ . "()\n"; + return TestBase::unserialize($serialized); + } } class TestLeaf extends TestDerived @@ -101,12 +101,12 @@ $ctypes = array(); foreach($objs as $obj) { - $cname = get_class($obj); - $ctype = NULL; /* set default for non stored class name */ - $stmt->execute(); - $stmt->bindColumn('id', $ctype); - $stmt->fetch(PDO::FETCH_BOUND); - $ctypes[$cname] = $ctype; + $cname = get_class($obj); + $ctype = NULL; /* set default for non stored class name */ + $stmt->execute(); + $stmt->bindColumn('id', $ctype); + $stmt->fetch(PDO::FETCH_BOUND); + $ctypes[$cname] = $ctype; } echo "===TYPES===\n"; @@ -122,16 +122,16 @@ $stmt->bindParam(':val', $val); foreach($objs as $idx => $obj) { - $ctype = $ctypes[get_class($obj)]; - if (method_exists($obj, 'serialize')) - { - $val = $obj->serialize(); - } - else - { - $val = ''; - } - $stmt->execute(); + $ctype = $ctypes[get_class($obj)]; + if (method_exists($obj, 'serialize')) + { + $val = $obj->serialize(); + } + else + { + $val = ''; + } + $stmt->execute(); } unset($stmt); @@ -140,31 +140,31 @@ echo "===DATA===\n"; $res = $db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN); switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) { - case 'dblib': - // map whitespace (from early TDS versions) to empty string so the test doesn't diff - if ($res[0] === ' ') { - $res[0] = ''; - } - break; + case 'dblib': + // map whitespace (from early TDS versions) to empty string so the test doesn't diff + if ($res[0] === ' ') { + $res[0] = ''; + } + break; - case 'oci': - // map NULL to empty string so the test doesn't diff - if ($res[0] === null) { - $res[0] = ''; - } - break; + case 'oci': + // map NULL to empty string so the test doesn't diff + if ($res[0] === null) { + $res[0] = ''; + } + break; } var_dump($res); echo "===FAILURE===\n"; try { - $db->query('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id')->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE, 'TestLeaf', array()); + $db->query('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id')->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE, 'TestLeaf', array()); } catch (PDOException $e) { - echo 'Exception:'; - echo $e->getMessage()."\n"; + echo 'Exception:'; + echo $e->getMessage()."\n"; } echo "===COUNT===\n"; diff --git a/ext/pdo/tests/pdo_019.phpt b/ext/pdo/tests/pdo_019.phpt index 68c5311b41c0..f37b9b13a58d 100644 --- a/ext/pdo/tests/pdo_019.phpt +++ b/ext/pdo/tests/pdo_019.phpt @@ -36,7 +36,7 @@ $stmt->bindColumn('txt', $txt); $stmt->execute(); while($stmt->fetch(PDO::FETCH_BOUND)) { - var_dump(array($idx=>$txt)); + var_dump(array($idx=>$txt)); } ?> diff --git a/ext/pdo/tests/pdo_020.phpt b/ext/pdo/tests/pdo_020.phpt index 32f53d840ed0..4586cc202d0f 100644 --- a/ext/pdo/tests/pdo_020.phpt +++ b/ext/pdo/tests/pdo_020.phpt @@ -21,10 +21,10 @@ $db->exec("INSERT INTO test VALUES(3, 'C', 'C')"); foreach (array('SELECT id, val FROM test', 'SELECT id, val, val2 FROM test', 'SELECT COUNT(*) FROM test') as $sql) { - $stmt = $db->query($sql); - $res = $stmt->columnCount(); + $stmt = $db->query($sql); + $res = $stmt->columnCount(); echo "Counted $res columns after $sql.\n"; - $stmt = null; + $stmt = null; } ?> diff --git a/ext/pdo/tests/pdo_021.phpt b/ext/pdo/tests/pdo_021.phpt index 10b8029c20b2..b627c453bff5 100644 --- a/ext/pdo/tests/pdo_021.phpt +++ b/ext/pdo/tests/pdo_021.phpt @@ -15,7 +15,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } $db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))'); diff --git a/ext/pdo/tests/pdo_023.phpt b/ext/pdo/tests/pdo_023.phpt index e021e67881fe..61c614ba52b0 100644 --- a/ext/pdo/tests/pdo_023.phpt +++ b/ext/pdo/tests/pdo_023.phpt @@ -19,14 +19,14 @@ class PDOStatementX extends PDOStatement protected function __construct() { - $this->test2 = 2; - $this->test2 = 22; - echo __METHOD__ . "()\n"; + $this->test2 = 2; + $this->test2 = 22; + echo __METHOD__ . "()\n"; } function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } } @@ -36,23 +36,23 @@ class PDODatabaseX extends PDO function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } function test() { - $this->test2 = 2; + $this->test2 = 2; var_dump($this->test1); var_dump($this->test2); - $this->test2 = 22; + $this->test2 = 22; } function query($sql) { - echo __METHOD__ . "()\n"; - $stmt = parent::prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx'))); - $stmt->execute(); - return $stmt; + echo __METHOD__ . "()\n"; + $stmt = parent::prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx'))); + $stmt->execute(); + return $stmt; } } diff --git a/ext/pdo/tests/pdo_024.phpt b/ext/pdo/tests/pdo_024.phpt index 042322871f4c..6f8063cc80cb 100644 --- a/ext/pdo/tests/pdo_024.phpt +++ b/ext/pdo/tests/pdo_024.phpt @@ -15,14 +15,14 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) { - case 'dblib': - // environment settings can influence how the table is created if specifics are missing - // https://msdn.microsoft.com/en-us/library/ms174979.aspx#Nullability Rules Within a Table Definition - $sql = 'create table test (id int, name varchar(10) null)'; - break; - default: - $sql = 'create table test (id int, name varchar(10))'; - break; + case 'dblib': + // environment settings can influence how the table is created if specifics are missing + // https://msdn.microsoft.com/en-us/library/ms174979.aspx#Nullability Rules Within a Table Definition + $sql = 'create table test (id int, name varchar(10) null)'; + break; + default: + $sql = 'create table test (id int, name varchar(10))'; + break; } $db->exec($sql); @@ -31,9 +31,9 @@ $name = NULL; $before_bind = $name; $stmt->bindParam(':name', $name, PDO::PARAM_NULL); if ($name !== $before_bind) { - echo "bind: fail\n"; + echo "bind: fail\n"; } else { - echo "bind: success\n"; + echo "bind: success\n"; } var_dump($stmt->execute()); var_dump($db->query('select name from test where id=0')->fetchColumn()); diff --git a/ext/pdo/tests/pdo_025.phpt b/ext/pdo/tests/pdo_025.phpt index 43cc542a0020..7bbd9b92f295 100644 --- a/ext/pdo/tests/pdo_025.phpt +++ b/ext/pdo/tests/pdo_025.phpt @@ -33,7 +33,7 @@ foreach ($data as $row) { } class Test { - public $id, $val, $val2; + public $id, $val, $val2; } $stmt = $db->prepare('SELECT * FROM test'); @@ -41,21 +41,21 @@ $stmt->setFetchMode(PDO::FETCH_INTO, new Test); $stmt->execute(); foreach($stmt as $obj) { - var_dump($obj); + var_dump($obj); } echo "===FAIL===\n"; class Fail { - protected $id; - public $val, $val2; + protected $id; + public $val, $val2; } $stmt->setFetchMode(PDO::FETCH_INTO, new Fail); $stmt->execute(); foreach($stmt as $obj) { - var_dump($obj); + var_dump($obj); } ?> diff --git a/ext/pdo/tests/pdo_026.phpt b/ext/pdo/tests/pdo_026.phpt index 8f72aff6e1c3..4bb1890b361a 100644 --- a/ext/pdo/tests/pdo_026.phpt +++ b/ext/pdo/tests/pdo_026.phpt @@ -25,13 +25,13 @@ class PDOStatementX extends PDOStatement protected function __construct($dbh) { - $this->dbh = $dbh; - echo __METHOD__ . "()\n"; + $this->dbh = $dbh; + echo __METHOD__ . "()\n"; } function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } } @@ -39,16 +39,16 @@ class PDODatabase extends PDO { function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } function query($sql) { - echo __METHOD__ . "()\n"; - $stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); - $stmt->setFetchMode(PDO::FETCH_ASSOC); - $stmt->execute(); - return $stmt; + echo __METHOD__ . "()\n"; + $stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); + $stmt->setFetchMode(PDO::FETCH_ASSOC); + $stmt->execute(); + return $stmt; } } @@ -70,7 +70,7 @@ var_dump(get_class($stmt)); var_dump(get_class($stmt->dbh)); foreach($stmt as $obj) { - var_dump($obj); + var_dump($obj); } echo "===DONE===\n"; diff --git a/ext/pdo/tests/pdo_027.phpt b/ext/pdo/tests/pdo_027.phpt index e10ab0aa7584..79151d0b6dde 100644 --- a/ext/pdo/tests/pdo_027.phpt +++ b/ext/pdo/tests/pdo_027.phpt @@ -19,7 +19,7 @@ $db->exec("INSERT INTO test (id,name) VALUES(1,'test1')"); $db->exec("INSERT INTO test (id,name) VALUES(2,'test2')"); foreach ($db->query("SELECT * FROM test", PDO::FETCH_LAZY) as $v) { - echo "lazy: " . $v->id.$v->name."\n"; + echo "lazy: " . $v->id.$v->name."\n"; } echo "End\n"; ?> diff --git a/ext/pdo/tests/pdo_028.phpt b/ext/pdo/tests/pdo_028.phpt index 726c28b2b8f4..427a22343cb9 100644 --- a/ext/pdo/tests/pdo_028.phpt +++ b/ext/pdo/tests/pdo_028.phpt @@ -20,7 +20,7 @@ $stmt = $db->prepare('INSERT INTO test values (1, ?, ?, ?)'); $data = array("one", "two", "three"); foreach ($data as $i => $v) { - $stmt->bindValue($i+1, $v); + $stmt->bindValue($i+1, $v); } $stmt->execute(); diff --git a/ext/pdo/tests/pdo_029.phpt b/ext/pdo/tests/pdo_029.phpt index 8204de236acd..10ab36912886 100644 --- a/ext/pdo/tests/pdo_029.phpt +++ b/ext/pdo/tests/pdo_029.phpt @@ -25,19 +25,19 @@ class PDOStatementX extends PDOStatement protected function __construct($dbh) { - $this->dbh = $dbh; - echo __METHOD__ . "()\n"; + $this->dbh = $dbh; + echo __METHOD__ . "()\n"; } function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } function execute($params = array()) { - echo __METHOD__ . "()\n"; - parent::execute(); + echo __METHOD__ . "()\n"; + parent::execute(); } } @@ -45,16 +45,16 @@ class PDODatabase extends PDO { function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } function query($sql) { - echo __METHOD__ . "()\n"; - $stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); - $stmt->setFetchMode(PDO::FETCH_ASSOC); - $stmt->execute(); - return $stmt; + echo __METHOD__ . "()\n"; + $stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); + $stmt->setFetchMode(PDO::FETCH_ASSOC); + $stmt->execute(); + return $stmt; } } @@ -80,7 +80,7 @@ var_dump(get_class($stmt->dbh)); echo "===FOREACH===\n"; foreach($stmt as $obj) { - var_dump($obj); + var_dump($obj); } echo "===DONE===\n"; diff --git a/ext/pdo/tests/pdo_030.phpt b/ext/pdo/tests/pdo_030.phpt index bc697d710816..2d054e0dd67c 100644 --- a/ext/pdo/tests/pdo_030.phpt +++ b/ext/pdo/tests/pdo_030.phpt @@ -25,20 +25,20 @@ class PDOStatementX extends PDOStatement protected function __construct($dbh) { - $this->dbh = $dbh; - $this->setFetchMode(PDO::FETCH_ASSOC); - echo __METHOD__ . "()\n"; + $this->dbh = $dbh; + $this->setFetchMode(PDO::FETCH_ASSOC); + echo __METHOD__ . "()\n"; } function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } function execute($params = array()) { - echo __METHOD__ . "()\n"; - parent::execute(); + echo __METHOD__ . "()\n"; + parent::execute(); } } @@ -46,13 +46,13 @@ class PDODatabase extends PDO { function __destruct() { - echo __METHOD__ . "()\n"; + echo __METHOD__ . "()\n"; } function query($sql) { - echo __METHOD__ . "()\n"; - return parent::query($sql); + echo __METHOD__ . "()\n"; + return parent::query($sql); } } @@ -81,7 +81,7 @@ var_dump(get_class($stmt->dbh)); echo "===FOREACH===\n"; foreach($stmt as $obj) { - var_dump($obj); + var_dump($obj); } echo "===DONE===\n"; diff --git a/ext/pdo/tests/pdo_031.phpt b/ext/pdo/tests/pdo_031.phpt index 689f7624ce84..bf1d0e06caa5 100644 --- a/ext/pdo/tests/pdo_031.phpt +++ b/ext/pdo/tests/pdo_031.phpt @@ -36,7 +36,7 @@ $stmt = $db->query('SELECT * FROM test'); foreach(new RecursiveTreeIterator(new RecursiveArrayIterator($stmt->fetchAll(PDO::FETCH_ASSOC)), RecursiveTreeIterator::BYPASS_KEY) as $c=>$v) { - echo "$v [$c]\n"; + echo "$v [$c]\n"; } echo "===DONE===\n"; diff --git a/ext/pdo/tests/pdo_034.phpt b/ext/pdo/tests/pdo_034.phpt index 4f66356729fd..3a504b6dea93 100644 --- a/ext/pdo/tests/pdo_034.phpt +++ b/ext/pdo/tests/pdo_034.phpt @@ -17,7 +17,7 @@ $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."')"); + $db->exec("INSERT INTO test (a,b,c) VALUES('test".$i."','".$i."','".$i."')"); } var_dump($db->query("SELECT a,b FROM test")->fetch(PDO::FETCH_KEY_PAIR)); diff --git a/ext/pdo/tests/pdo_dsn_containing_credentials.phpt b/ext/pdo/tests/pdo_dsn_containing_credentials.phpt index dca3ba1709e8..94859e53601c 100644 --- a/ext/pdo/tests/pdo_dsn_containing_credentials.phpt +++ b/ext/pdo/tests/pdo_dsn_containing_credentials.phpt @@ -15,36 +15,36 @@ PDOTest::skip(); ?> --FILE-- --EXPECTF-- using credentials in dsn: done diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc index 443c8dd8222e..2238123d40a0 100644 --- a/ext/pdo/tests/pdo_test.inc +++ b/ext/pdo/tests/pdo_test.inc @@ -2,83 +2,83 @@ # PDO test framework utilities if (getenv('PDOTEST_DSN') === false) { - $common = ''; - $append = false; - foreach(file(dirname($_SERVER['PHP_SELF']).'/common.phpt') as $line) { - if ($append) { - $common .= $line; - } elseif (trim($line) == '--REDIRECTTEST--') { - $append = true; - } - } - $conf = eval($common); - foreach($conf['ENV'] as $n=>$v) putenv("$n=$v"); + $common = ''; + $append = false; + foreach(file(dirname($_SERVER['PHP_SELF']).'/common.phpt') as $line) { + if ($append) { + $common .= $line; + } elseif (trim($line) == '--REDIRECTTEST--') { + $append = true; + } + } + $conf = eval($common); + foreach($conf['ENV'] as $n=>$v) putenv("$n=$v"); } class PDOTest { - // create an instance of the PDO driver, based on - // the current environment - static function factory($classname = 'PDO', $drop_test_tables = true) { - $dsn = getenv('PDOTEST_DSN'); - $user = getenv('PDOTEST_USER'); - $pass = getenv('PDOTEST_PASS'); - $attr = getenv('PDOTEST_ATTR'); - if (is_string($attr) && strlen($attr)) { - $attr = unserialize($attr); - } else { - $attr = null; - } + // create an instance of the PDO driver, based on + // the current environment + static function factory($classname = 'PDO', $drop_test_tables = true) { + $dsn = getenv('PDOTEST_DSN'); + $user = getenv('PDOTEST_USER'); + $pass = getenv('PDOTEST_PASS'); + $attr = getenv('PDOTEST_ATTR'); + if (is_string($attr) && strlen($attr)) { + $attr = unserialize($attr); + } else { + $attr = null; + } - if ($user === false) $user = NULL; - if ($pass === false) $pass = NULL; + if ($user === false) $user = NULL; + if ($pass === false) $pass = NULL; - $db = new $classname($dsn, $user, $pass, $attr); + $db = new $classname($dsn, $user, $pass, $attr); - if (!$db) { - die("Could not create PDO object (DSN=$dsn, user=$user)\n"); - } + if (!$db) { + die("Could not create PDO object (DSN=$dsn, user=$user)\n"); + } - // clean up any crufty test tables we might have left behind - // on a previous run - static $test_tables = array( - 'test', - 'test2', - 'classtypes' - ); - if ($drop_test_tables) { - foreach ($test_tables as $table) { - $db->exec("DROP TABLE $table"); - } - } + // clean up any crufty test tables we might have left behind + // on a previous run + static $test_tables = array( + 'test', + 'test2', + 'classtypes' + ); + if ($drop_test_tables) { + foreach ($test_tables as $table) { + $db->exec("DROP TABLE $table"); + } + } - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - return $db; - } + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + return $db; + } - static function skip() { - try { - $db = PDOTest::factory(); - } catch (PDOException $e) { - die("skip " . $e->getMessage()); - } - } + static function skip() { + try { + $db = PDOTest::factory(); + } catch (PDOException $e) { + die("skip " . $e->getMessage()); + } + } - static function test_factory($file) { - $config = self::get_config($file); - foreach ($config['ENV'] as $k => $v) { - putenv("$k=$v"); - } - return self::factory(); - } + static function test_factory($file) { + $config = self::get_config($file); + foreach ($config['ENV'] as $k => $v) { + putenv("$k=$v"); + } + return self::factory(); + } - static function get_config($file) { - $data = file_get_contents($file); - $data = preg_replace('/^.*--REDIRECTTEST--/s', '', $data); - $config = eval($data); + static function get_config($file) { + $data = file_get_contents($file); + $data = preg_replace('/^.*--REDIRECTTEST--/s', '', $data); + $config = eval($data); - return $config; - } + return $config; + } } ?> diff --git a/ext/pdo/tests/pecl_bug_5217.phpt b/ext/pdo/tests/pecl_bug_5217.phpt index 458092d25f4b..6e97ca48c684 100644 --- a/ext/pdo/tests/pecl_bug_5217.phpt +++ b/ext/pdo/tests/pecl_bug_5217.phpt @@ -14,12 +14,12 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); try { - $ser = serialize($db); - debug_zval_dump($ser); - $db = unserialize($ser); - $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); + $ser = serialize($db); + debug_zval_dump($ser); + $db = unserialize($ser); + $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(10))'); } catch (Exception $e) { - echo "Safely caught " . $e->getMessage() . "\n"; + echo "Safely caught " . $e->getMessage() . "\n"; } echo "PHP Didn't crash!\n"; diff --git a/ext/pdo/tests/pecl_bug_5772.phpt b/ext/pdo/tests/pecl_bug_5772.phpt index 5363d80ceefc..28cae695b7ba 100644 --- a/ext/pdo/tests/pecl_bug_5772.phpt +++ b/ext/pdo/tests/pecl_bug_5772.phpt @@ -18,11 +18,11 @@ $db->exec("CREATE TABLE test (id int NOT NULL, PRIMARY KEY (id))"); $db->exec("INSERT INTO test (id) VALUES (1)"); function heLLO($row) { - return $row; + return $row; } foreach ($db->query("SELECT * FROM test")->fetchAll(PDO::FETCH_FUNC, 'heLLO') as $row) { - var_dump($row); + var_dump($row); } --EXPECT-- string(1) "1" diff --git a/ext/pdo_dblib/tests/bug_50755.phpt b/ext/pdo_dblib/tests/bug_50755.phpt index 33b776c145a0..17ce3a1214d2 100644 --- a/ext/pdo_dblib/tests/bug_50755.phpt +++ b/ext/pdo_dblib/tests/bug_50755.phpt @@ -18,7 +18,7 @@ cross join information_schema.columns ic3"); $x = $stmt->execute(); $n = 0; while (($r = $stmt->fetch())) { - $n++; + $n++; } $stmt = null; diff --git a/ext/pdo_dblib/tests/config.inc b/ext/pdo_dblib/tests/config.inc index 2723090f0884..165f1d9330ac 100644 --- a/ext/pdo_dblib/tests/config.inc +++ b/ext/pdo_dblib/tests/config.inc @@ -3,50 +3,50 @@ // bug #72969 reflects a bug with FreeTDS, not with pdo_dblib // this function will version detect so the relevant tests can XFAILIF function driver_supports_batch_statements_without_select($db) { - $version = $db->getAttribute(PDO::DBLIB_ATTR_VERSION); + $version = $db->getAttribute(PDO::DBLIB_ATTR_VERSION); - // assume driver doesn't have this bug if not using FreeTDS - if (!strstartswith($version, 'freetds ')) { - return true; - } + // assume driver doesn't have this bug if not using FreeTDS + if (!strstartswith($version, 'freetds ')) { + return true; + } - // hasn't made it to numbered release yet - if (!strstartswith($version, 'freetds v1.1.dev.')) { - return false; - } + // hasn't made it to numbered release yet + if (!strstartswith($version, 'freetds v1.1.dev.')) { + return false; + } - // fc820490336c50d5c175d2a15327383256add4c9 was committed on the 5th - return intval(substr($version, -8)) >= 20161206; + // fc820490336c50d5c175d2a15327383256add4c9 was committed on the 5th + return intval(substr($version, -8)) >= 20161206; } function strstartswith($haystack, $needle) { - return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; + return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; } if (false !== getenv('PDO_DBLIB_TEST_DSN')) { - $dsn = getenv('PDO_DBLIB_TEST_DSN'); + $dsn = getenv('PDO_DBLIB_TEST_DSN'); } else { - $dsn = 'dblib:host=localhost;dbname=test'; + $dsn = 'dblib:host=localhost;dbname=test'; } if (false !== getenv('PDO_DBLIB_TEST_USER')) { - $user = getenv('PDO_DBLIB_TEST_USER'); + $user = getenv('PDO_DBLIB_TEST_USER'); } else { - $user = 'php'; + $user = 'php'; } if (false !== getenv('PDO_DBLIB_TEST_PASS')) { - $pass = getenv('PDO_DBLIB_TEST_PASS'); + $pass = getenv('PDO_DBLIB_TEST_PASS'); } else { - $pass = 'password'; + $pass = 'password'; } try { - $db = new PDO($dsn, $user, $pass); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + $db = new PDO($dsn, $user, $pass); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); } catch (PDOException $e) { - die('skip ' . $e->getMessage()); + die('skip ' . $e->getMessage()); } ?> diff --git a/ext/pdo_dblib/tests/timeout.phpt b/ext/pdo_dblib/tests/timeout.phpt index c0485c6d5134..2ef20fd4fc17 100644 --- a/ext/pdo_dblib/tests/timeout.phpt +++ b/ext/pdo_dblib/tests/timeout.phpt @@ -15,7 +15,7 @@ $sql = 'WAITFOR DELAY \'00:00:02\''; // querying without a timeout will succeed $stmt = $db->prepare($sql); if ($stmt->execute()) { - echo "OK\n"; + echo "OK\n"; } // regular timeout attribute, set after instance created, will affect query timeout, causing this query to fail @@ -23,12 +23,12 @@ $db = new PDO($dsn, $user, $pass); $db->setAttribute(PDO::ATTR_TIMEOUT, 1); $stmt = $db->prepare($sql); if (!$stmt->execute()) { - echo "OK\n"; + echo "OK\n"; - // expect some kind of error code - if ($stmt->errorCode() != '00000') { - echo "OK\n"; - } + // expect some kind of error code + if ($stmt->errorCode() != '00000') { + echo "OK\n"; + } } // pdo_dblib-specific timeout attribute, set after instance created, will control query timeout, causing this query to fail @@ -36,36 +36,36 @@ $db = new PDO($dsn, $user, $pass); $db->setAttribute(PDO::DBLIB_ATTR_QUERY_TIMEOUT, 1); $stmt = $db->prepare($sql); if (!$stmt->execute()) { - echo "OK\n"; + echo "OK\n"; - // expect some kind of error code - if ($stmt->errorCode() != '00000') { - echo "OK\n"; - } + // expect some kind of error code + if ($stmt->errorCode() != '00000') { + echo "OK\n"; + } } // regular timeout attribute will affect query timeout, causing this query to fail $db = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 1]); $stmt = $db->prepare($sql); if (!$stmt->execute()) { - echo "OK\n"; + echo "OK\n"; - // expect some kind of error code - if ($stmt->errorCode() != '00000') { - echo "OK\n"; - } + // expect some kind of error code + if ($stmt->errorCode() != '00000') { + echo "OK\n"; + } } // pdo_dblib-specific timeout attribute will control query timeout, causing this query to fail $db = new PDO($dsn, $user, $pass, [PDO::DBLIB_ATTR_QUERY_TIMEOUT => 1]); $stmt = $db->prepare($sql); if (!$stmt->execute()) { - echo "OK\n"; + echo "OK\n"; - // expect some kind of error code - if ($stmt->errorCode() != '00000') { - echo "OK\n"; - } + // expect some kind of error code + if ($stmt->errorCode() != '00000') { + echo "OK\n"; + } } ?> diff --git a/ext/pdo_dblib/tests/types.phpt b/ext/pdo_dblib/tests/types.phpt index a4d4fd39f78e..fa336d9fb449 100644 --- a/ext/pdo_dblib/tests/types.phpt +++ b/ext/pdo_dblib/tests/types.phpt @@ -10,31 +10,31 @@ require __DIR__ . '/config.inc'; require __DIR__ . '/config.inc'; function get_expected_float_string() { - global $db; + global $db; - switch ($db->getAttribute(PDO::DBLIB_ATTR_TDS_VERSION)) { - case '5.0': - case '6.0': - case '7.0': - case '7.1': - case '7.2': - case '8.0': - return '10.500'; - default: - return '10.5'; - } + switch ($db->getAttribute(PDO::DBLIB_ATTR_TDS_VERSION)) { + case '5.0': + case '6.0': + case '7.0': + case '7.1': + case '7.2': + case '8.0': + return '10.500'; + default: + return '10.5'; + } } $sql = " - SELECT - 'foo' AS [char], - CAST('2030-01-01 23:59:59' AS DATETIME) AS [datetime], - CAST(0 AS BIT) AS [false], - 10.500 AS [float], - 1000 AS [int], - CAST(10.500 AS MONEY) AS [money], - CAST('1950-01-18 23:00:00' AS SMALLDATETIME) as [smalldatetime], - CAST(1 AS BIT) AS [true] + SELECT + 'foo' AS [char], + CAST('2030-01-01 23:59:59' AS DATETIME) AS [datetime], + CAST(0 AS BIT) AS [false], + 10.500 AS [float], + 1000 AS [int], + CAST(10.500 AS MONEY) AS [money], + CAST('1950-01-18 23:00:00' AS SMALLDATETIME) as [smalldatetime], + CAST(1 AS BIT) AS [true] "; $stmt = $db->query($sql); diff --git a/ext/pdo_firebird/tests/bug_48877.phpt b/ext/pdo_firebird/tests/bug_48877.phpt index d685d0ac80cf..85da7d42856a 100644 --- a/ext/pdo_firebird/tests/bug_48877.phpt +++ b/ext/pdo_firebird/tests/bug_48877.phpt @@ -8,7 +8,7 @@ PDO_Firebird: bug 48877 The "bindValue" and "bindParam" do not work for PDO Fire require("testdb.inc"); $value = '2'; - + @$dbh->exec('DROP TABLE testz'); $dbh->exec('CREATE TABLE testz (A integer)'); $dbh->exec("INSERT INTO testz VALUES ('1')"); diff --git a/ext/pdo_firebird/tests/bug_73087.phpt b/ext/pdo_firebird/tests/bug_73087.phpt index b676293e445d..cd3d90137ee9 100644 --- a/ext/pdo_firebird/tests/bug_73087.phpt +++ b/ext/pdo_firebird/tests/bug_73087.phpt @@ -10,13 +10,13 @@ require 'testdb.inc'; $dbh->exec('create table atable (id integer not null, content blob sub_type 1 segment size 80)'); $S = $dbh->prepare('insert into atable (id, content) values (:id, :content)'); for ($I = 1; $I < 10; $I++) { - $Params = [ - 'id' => $I, - 'content' => base64_encode(random_bytes(10)) - ]; - foreach ($Params as $Param => $Value) - $S->bindValue($Param, $Value); - $S->execute(); + $Params = [ + 'id' => $I, + 'content' => base64_encode(random_bytes(10)) + ]; + foreach ($Params as $Param => $Value) + $S->bindValue($Param, $Value); + $S->execute(); } unset($S); unset($dbh); diff --git a/ext/pdo_firebird/tests/bug_76488.phpt b/ext/pdo_firebird/tests/bug_76488.phpt index ffcca7efd346..27b899086daa 100644 --- a/ext/pdo_firebird/tests/bug_76488.phpt +++ b/ext/pdo_firebird/tests/bug_76488.phpt @@ -14,15 +14,15 @@ with recursive r(n) as ( ) select n, cast(lpad(\'A\', 8000, \'A\') as BLOB sub_type TEXT) as SRC -from r +from r '; for ($i = 0; $i < 10; $i++) { $sth = $dbh->prepare($sql); $sth->execute(); $rows = $sth->fetchAll(); - unset($rows); - unset($sth); + unset($rows); + unset($sth); } unset($dbh); echo "OK"; diff --git a/ext/pdo_firebird/tests/bug_77863.phpt b/ext/pdo_firebird/tests/bug_77863.phpt index a133de5ba8d3..e0d829311868 100644 --- a/ext/pdo_firebird/tests/bug_77863.phpt +++ b/ext/pdo_firebird/tests/bug_77863.phpt @@ -107,8 +107,8 @@ try { echo "OK\n"; } catch(Exception $e) { - echo $e->getMessage() . '
'; - echo $e->getTraceAsString(); + echo $e->getMessage() . '
'; + echo $e->getTraceAsString(); } ?> --EXPECT-- diff --git a/ext/pdo_firebird/tests/connect.phpt b/ext/pdo_firebird/tests/connect.phpt index 20f0ce7013fe..116e9910669e 100644 --- a/ext/pdo_firebird/tests/connect.phpt +++ b/ext/pdo_firebird/tests/connect.phpt @@ -4,10 +4,10 @@ PDO_Firebird: connect/disconnect --FILE-- --EXPECT-- diff --git a/ext/pdo_firebird/tests/ddl.phpt b/ext/pdo_firebird/tests/ddl.phpt index b89c70456a48..ea2c15cd116c 100644 --- a/ext/pdo_firebird/tests/ddl.phpt +++ b/ext/pdo_firebird/tests/ddl.phpt @@ -5,32 +5,32 @@ PDO_Firebird: DDL/transactions --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - @$dbh->exec('DROP TABLE ddl'); - @$dbh->exec('DROP GENERATOR gen_ddl_id'); - @$dbh->exec('DROP TRIGGER ddl_bi'); + @$dbh->exec('DROP TABLE ddl'); + @$dbh->exec('DROP GENERATOR gen_ddl_id'); + @$dbh->exec('DROP TRIGGER ddl_bi'); - $dbh->exec("CREATE TABLE ddl (id INT NOT NULL PRIMARY KEY, text BLOB SUB_TYPE 1)"); - $dbh->exec("CREATE GENERATOR gen_ddl_id"); - $dbh->exec("CREATE TRIGGER ddl_bi FOR ddl BEFORE INSERT AS - BEGIN IF (NEW.id IS NULL) THEN NEW.id=GEN_ID(gen_ddl_id,1); END"); + $dbh->exec("CREATE TABLE ddl (id INT NOT NULL PRIMARY KEY, text BLOB SUB_TYPE 1)"); + $dbh->exec("CREATE GENERATOR gen_ddl_id"); + $dbh->exec("CREATE TRIGGER ddl_bi FOR ddl BEFORE INSERT AS + BEGIN IF (NEW.id IS NULL) THEN NEW.id=GEN_ID(gen_ddl_id,1); END"); - $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT,0); + $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT,0); - $dbh->beginTransaction(); - var_dump($dbh->exec("INSERT INTO ddl (text) VALUES ('bla')")); - var_dump($dbh->exec("UPDATE ddl SET text='blabla'")); - $dbh->rollback(); + $dbh->beginTransaction(); + var_dump($dbh->exec("INSERT INTO ddl (text) VALUES ('bla')")); + var_dump($dbh->exec("UPDATE ddl SET text='blabla'")); + $dbh->rollback(); - $dbh->beginTransaction(); - var_dump($dbh->exec("DELETE FROM ddl")); - $dbh->commit(); + $dbh->beginTransaction(); + var_dump($dbh->exec("DELETE FROM ddl")); + $dbh->commit(); - unset($dbh); - echo "done\n"; + unset($dbh); + echo "done\n"; ?> --EXPECT-- diff --git a/ext/pdo_firebird/tests/dialect_1.phpt b/ext/pdo_firebird/tests/dialect_1.phpt index 829025c16229..c0f2ff017d36 100644 --- a/ext/pdo_firebird/tests/dialect_1.phpt +++ b/ext/pdo_firebird/tests/dialect_1.phpt @@ -8,44 +8,44 @@ if (strpos(getenv('PDO_FIREBIRD_TEST_DSN'), 'dialect=1')===false) { ?> --FILE-- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - $dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); + $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + $dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); - $sql = - 'SELECT - 1 as N, - 2.0 as F, - cast(0.76 as numeric(15, 2)) as K, - cast(\'2019-06-12\' as date) as DT - FROM RDB$DATABASE'; - $query = $dbh->prepare($sql); - $query->execute(); - $row = $query->fetch(\PDO::FETCH_OBJ); - var_dump($row->N); - var_dump($row->F); - var_dump($row->K); - var_dump($row->DT); + $sql = + 'SELECT + 1 as N, + 2.0 as F, + cast(0.76 as numeric(15, 2)) as K, + cast(\'2019-06-12\' as date) as DT + FROM RDB$DATABASE'; + $query = $dbh->prepare($sql); + $query->execute(); + $row = $query->fetch(\PDO::FETCH_OBJ); + var_dump($row->N); + var_dump($row->F); + var_dump($row->K); + var_dump($row->DT); - unset($query); + unset($query); - $dbh->exec('RECREATE TABLE test_d1(K numeric(15, 2), DT date)'); - $sql='INSERT INTO test_d1(K, DT) values(?, ?)'; - $query = $dbh->prepare($sql); - $query->execute([0.76, '2019-06-12']); - unset($query); + $dbh->exec('RECREATE TABLE test_d1(K numeric(15, 2), DT date)'); + $sql='INSERT INTO test_d1(K, DT) values(?, ?)'; + $query = $dbh->prepare($sql); + $query->execute([0.76, '2019-06-12']); + unset($query); - $sql='SELECT * FROM test_d1'; - $query = $dbh->prepare($sql); - $query->execute(); - $row = $query->fetch(\PDO::FETCH_OBJ); - var_dump($row->K); - var_dump($row->DT); + $sql='SELECT * FROM test_d1'; + $query = $dbh->prepare($sql); + $query->execute(); + $row = $query->fetch(\PDO::FETCH_OBJ); + var_dump($row->K); + var_dump($row->DT); - unset($query); - unset($dbh); - echo "done\n"; + unset($query); + unset($dbh); + echo "done\n"; ?> --EXPECT-- diff --git a/ext/pdo_firebird/tests/execute.phpt b/ext/pdo_firebird/tests/execute.phpt index 0f1721f559dd..56ed10b0d0fe 100644 --- a/ext/pdo_firebird/tests/execute.phpt +++ b/ext/pdo_firebird/tests/execute.phpt @@ -4,41 +4,41 @@ PDO_Firebird: prepare/execute/binding --FILE-- getAttribute(PDO::ATTR_CONNECTION_STATUS)); + var_dump($dbh->getAttribute(PDO::ATTR_CONNECTION_STATUS)); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - $dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); + $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + $dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S'); - @$dbh->exec('DROP TABLE ddl'); - $dbh->exec("CREATE TABLE ddl (id SMALLINT NOT NULL PRIMARY KEY, text VARCHAR(32), - datetime TIMESTAMP DEFAULT '2000-02-12' NOT NULL)"); - $dbh->exec("INSERT INTO ddl (id,text) VALUES (1,'bla')"); + @$dbh->exec('DROP TABLE ddl'); + $dbh->exec("CREATE TABLE ddl (id SMALLINT NOT NULL PRIMARY KEY, text VARCHAR(32), + datetime TIMESTAMP DEFAULT '2000-02-12' NOT NULL)"); + $dbh->exec("INSERT INTO ddl (id,text) VALUES (1,'bla')"); - $s = $dbh->prepare("SELECT * FROM ddl WHERE id=? FOR UPDATE"); + $s = $dbh->prepare("SELECT * FROM ddl WHERE id=? FOR UPDATE"); - $id = 0; - $s->bindParam(1,$id); - $var = null; - $s->bindColumn("TEXT",$var); - $id = 1; - $s->execute(); - $s->setAttribute(PDO::ATTR_CURSOR_NAME, "c"); + $id = 0; + $s->bindParam(1,$id); + $var = null; + $s->bindColumn("TEXT",$var); + $id = 1; + $s->execute(); + $s->setAttribute(PDO::ATTR_CURSOR_NAME, "c"); - var_dump($id); + var_dump($id); - var_dump($s->fetch()); + var_dump($s->fetch()); - var_dump($var); + var_dump($var); - var_dump($dbh->exec("UPDATE ddl SET id=2 WHERE CURRENT OF c")); + var_dump($dbh->exec("UPDATE ddl SET id=2 WHERE CURRENT OF c")); - var_dump($s->fetch()); + var_dump($s->fetch()); - unset($s); - unset($dbh); - echo "done\n"; + unset($s); + unset($dbh); + echo "done\n"; ?> --EXPECT-- diff --git a/ext/pdo_firebird/tests/testdb.inc b/ext/pdo_firebird/tests/testdb.inc index d345d090bb32..23008fa0d99d 100644 --- a/ext/pdo_firebird/tests/testdb.inc +++ b/ext/pdo_firebird/tests/testdb.inc @@ -1,7 +1,7 @@ diff --git a/ext/pdo_mysql/tests/bug41125.phpt b/ext/pdo_mysql/tests/bug41125.phpt index 2212bb621d44..63ff7df2f33a 100644 --- a/ext/pdo_mysql/tests/bug41125.phpt +++ b/ext/pdo_mysql/tests/bug41125.phpt @@ -24,19 +24,19 @@ print implode(' - ', $stmt->errorinfo()) ."\n"; print "-------------------------------------------------------\n"; $queries = array( - "SELECT 1 FROM DUAL WHERE 1 = '?\'\''", - "SELECT 'a\\'0' FROM DUAL WHERE 1 = ?", - "SELECT 'a', 'b\'' FROM DUAL WHERE '''' LIKE '\\'' AND ?", - "SELECT 'foo?bar', '', '''' FROM DUAL WHERE ?" + "SELECT 1 FROM DUAL WHERE 1 = '?\'\''", + "SELECT 'a\\'0' FROM DUAL WHERE 1 = ?", + "SELECT 'a', 'b\'' FROM DUAL WHERE '''' LIKE '\\'' AND ?", + "SELECT 'foo?bar', '', '''' FROM DUAL WHERE ?" ); foreach ($queries as $k => $query) { - $stmt = $db->prepare($query); - $stmt->execute(array(1)); - printf("[%d] Query: [[%s]]\n", $k + 1, $query); - print implode(' - ', (($r = @$stmt->fetch(PDO::FETCH_NUM)) ? $r : array())) ."\n"; - print implode(' - ', $stmt->errorinfo()) ."\n"; - print "--------\n"; + $stmt = $db->prepare($query); + $stmt->execute(array(1)); + printf("[%d] Query: [[%s]]\n", $k + 1, $query); + print implode(' - ', (($r = @$stmt->fetch(PDO::FETCH_NUM)) ? $r : array())) ."\n"; + print implode(' - ', $stmt->errorinfo()) ."\n"; + print "--------\n"; } $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); @@ -53,33 +53,33 @@ print implode(' - ', $stmt->errorinfo()) ."\n"; print "-------------------------------------------------------\n"; $queries = array( - "SELECT 1, 'foo' FROM DUAL WHERE 1 = :id AND '\\0' IS NULL AND 2 <> :id", - "SELECT 1 FROM DUAL WHERE 1 = :id AND '' AND 2 <> :id", - "SELECT 1 FROM DUAL WHERE 1 = :id AND '\'\'' = '''' AND 2 <> :id", - "SELECT 1 FROM DUAL WHERE 1 = :id AND '\'' = '''' AND 2 <> :id", - "SELECT 'a', 'b\'' FROM DUAL WHERE '''' LIKE '\\'' AND 1", - "SELECT 'a''', '\'b\'' FROM DUAL WHERE '''' LIKE '\\'' AND 1", - "SELECT UPPER(:id) FROM DUAL WHERE '1'", - "SELECT 1 FROM DUAL WHERE '\''", - "SELECT 1 FROM DUAL WHERE :id AND '\\0' OR :id", - "SELECT 1 FROM DUAL WHERE 'a\\f\\n\\0' AND 1 >= :id", - "SELECT 1 FROM DUAL WHERE '\'' = ''''", - "SELECT '\\n' '1 FROM DUAL WHERE '''' and :id'", - "SELECT 1 'FROM DUAL WHERE :id AND '''' = '''' OR 1 = 1 AND ':id", + "SELECT 1, 'foo' FROM DUAL WHERE 1 = :id AND '\\0' IS NULL AND 2 <> :id", + "SELECT 1 FROM DUAL WHERE 1 = :id AND '' AND 2 <> :id", + "SELECT 1 FROM DUAL WHERE 1 = :id AND '\'\'' = '''' AND 2 <> :id", + "SELECT 1 FROM DUAL WHERE 1 = :id AND '\'' = '''' AND 2 <> :id", + "SELECT 'a', 'b\'' FROM DUAL WHERE '''' LIKE '\\'' AND 1", + "SELECT 'a''', '\'b\'' FROM DUAL WHERE '''' LIKE '\\'' AND 1", + "SELECT UPPER(:id) FROM DUAL WHERE '1'", + "SELECT 1 FROM DUAL WHERE '\''", + "SELECT 1 FROM DUAL WHERE :id AND '\\0' OR :id", + "SELECT 1 FROM DUAL WHERE 'a\\f\\n\\0' AND 1 >= :id", + "SELECT 1 FROM DUAL WHERE '\'' = ''''", + "SELECT '\\n' '1 FROM DUAL WHERE '''' and :id'", + "SELECT 1 'FROM DUAL WHERE :id AND '''' = '''' OR 1 = 1 AND ':id", ); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); $id = 1; foreach ($queries as $k => $query) { - $stmt = $db->prepare($query); - $stmt->bindParam(':id', $id); - $stmt->execute(); - - printf("[%d] Query: [[%s]]\n", $k + 1, $query); - print implode(' - ', (($r = @$stmt->fetch(PDO::FETCH_NUM)) ? $r : array())) ."\n"; - print implode(' - ', $stmt->errorinfo()) ."\n"; - print "--------\n"; + $stmt = $db->prepare($query); + $stmt->bindParam(':id', $id); + $stmt->execute(); + + printf("[%d] Query: [[%s]]\n", $k + 1, $query); + print implode(' - ', (($r = @$stmt->fetch(PDO::FETCH_NUM)) ? $r : array())) ."\n"; + print implode(' - ', $stmt->errorinfo()) ."\n"; + print "--------\n"; } ?> diff --git a/ext/pdo_mysql/tests/bug44327.phpt b/ext/pdo_mysql/tests/bug44327.phpt index f457c97aeb77..5adc8209e799 100644 --- a/ext/pdo_mysql/tests/bug44327.phpt +++ b/ext/pdo_mysql/tests/bug44327.phpt @@ -9,35 +9,35 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- prepare("SELECT 1 AS \"one\""); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_LAZY); - var_dump($row); - var_dump($row->{0}); - var_dump($row->one); - var_dump($row->queryString); + $stmt = $db->prepare("SELECT 1 AS \"one\""); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_LAZY); + var_dump($row); + var_dump($row->{0}); + var_dump($row->one); + var_dump($row->queryString); - print "----------------------------------\n"; + print "----------------------------------\n"; - @$db->exec("DROP TABLE test"); - $db->exec("CREATE TABLE test (id INT)"); - $db->exec("INSERT INTO test(id) VALUES (1)"); - $stmt = $db->prepare("SELECT id FROM test"); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_LAZY); - var_dump($row); - var_dump($row->queryString); - @$db->exec("DROP TABLE test"); + @$db->exec("DROP TABLE test"); + $db->exec("CREATE TABLE test (id INT)"); + $db->exec("INSERT INTO test(id) VALUES (1)"); + $stmt = $db->prepare("SELECT id FROM test"); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_LAZY); + var_dump($row); + var_dump($row->queryString); + @$db->exec("DROP TABLE test"); - print "----------------------------------\n"; + print "----------------------------------\n"; - $stmt = $db->prepare('foo'); - @$stmt->execute(); - $row = $stmt->fetch(); - var_dump($row->queryString); + $stmt = $db->prepare('foo'); + @$stmt->execute(); + $row = $stmt->fetch(); + var_dump($row->queryString); ?> --EXPECTF-- diff --git a/ext/pdo_mysql/tests/bug46292.phpt b/ext/pdo_mysql/tests/bug46292.phpt index fd2ef759e59a..dec4a9f5502f 100644 --- a/ext/pdo_mysql/tests/bug46292.phpt +++ b/ext/pdo_mysql/tests/bug46292.phpt @@ -9,45 +9,45 @@ MySQLPDOTest::skip(); --FILE-- setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - $pdoDb->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $pdoDb->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $pdoDb->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $pdoDb->query('DROP TABLE IF EXISTS testz'); + $pdoDb->query('DROP TABLE IF EXISTS testz'); - $pdoDb->query('CREATE TABLE testz (name VARCHAR(20) NOT NULL, value INT)'); + $pdoDb->query('CREATE TABLE testz (name VARCHAR(20) NOT NULL, value INT)'); - $pdoDb->query("INSERT INTO testz VALUES ('myclass', 1), ('myclass2', 2), ('myclass', NULL), ('myclass3', NULL)"); + $pdoDb->query("INSERT INTO testz VALUES ('myclass', 1), ('myclass2', 2), ('myclass', NULL), ('myclass3', NULL)"); - $stmt = $pdoDb->prepare("SELECT * FROM testz"); + $stmt = $pdoDb->prepare("SELECT * FROM testz"); - var_dump($stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_GROUP)); - $stmt->execute(); + var_dump($stmt->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_GROUP)); + $stmt->execute(); - var_dump($stmt->fetch()); - var_dump($stmt->fetch()); - var_dump($stmt->fetchAll()); + var_dump($stmt->fetch()); + var_dump($stmt->fetch()); + var_dump($stmt->fetchAll()); ?> --CLEAN-- prepare($query); + global $pdodb; + $stmt = $pdodb->prepare($query); - if (!$stmt->execute(array("foo"))) { - var_dump($stmt->errorInfo()); - } else{ - var_dump($stmt->fetch(PDO::FETCH_ASSOC)); - } + if (!$stmt->execute(array("foo"))) { + var_dump($stmt->errorInfo()); + } else{ + var_dump($stmt->fetch(PDO::FETCH_ASSOC)); + } } testQuery("/* ' */ select ? as f1 /* ' */"); diff --git a/ext/pdo_mysql/tests/bug63176.phpt b/ext/pdo_mysql/tests/bug63176.phpt index ed462c0c5384..2a75f4738476 100644 --- a/ext/pdo_mysql/tests/bug63176.phpt +++ b/ext/pdo_mysql/tests/bug63176.phpt @@ -10,24 +10,24 @@ MySQLPDOTest::skip(); db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true)); - } else { - $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true)); - } - $this->db->query('SELECT 1')->fetchAll(); - } + public function __construct($h) { + var_dump($h); + if ($h) { + $this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true)); + } else { + $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true)); + } + $this->db->query('SELECT 1')->fetchAll(); + } } $a = new ModelA(true); diff --git a/ext/pdo_mysql/tests/bug68371.phpt b/ext/pdo_mysql/tests/bug68371.phpt index f5046f0375e4..17eee8c2f413 100644 --- a/ext/pdo_mysql/tests/bug68371.phpt +++ b/ext/pdo_mysql/tests/bug68371.phpt @@ -14,54 +14,54 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $attrs = array( // Extensive test: default value and set+get values - PDO::ATTR_EMULATE_PREPARES => array(null, 1, 0), - PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, 0, 1), - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, 0, 1), + PDO::ATTR_EMULATE_PREPARES => array(null, 1, 0), + PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, 0, 1), + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, 0, 1), // Just test the default - PDO::ATTR_AUTOCOMMIT => array(null), - PDO::ATTR_PREFETCH => array(null), - PDO::ATTR_TIMEOUT => array(null), - PDO::ATTR_ERRMODE => array(null), - PDO::ATTR_SERVER_VERSION => array(null), - PDO::ATTR_CLIENT_VERSION => array(null), - PDO::ATTR_SERVER_INFO => array(null), - PDO::ATTR_CONNECTION_STATUS => array(null), - PDO::ATTR_CASE => array(null), - PDO::ATTR_CURSOR_NAME => array(null), - PDO::ATTR_CURSOR => array(null), - PDO::ATTR_ORACLE_NULLS => array(null), - PDO::ATTR_PERSISTENT => array(null), - PDO::ATTR_STATEMENT_CLASS => array(null), - PDO::ATTR_FETCH_TABLE_NAMES => array(null), - PDO::ATTR_FETCH_CATALOG_NAMES => array(null), - PDO::ATTR_DRIVER_NAME => array(null), - PDO::ATTR_STRINGIFY_FETCHES => array(null), - PDO::ATTR_MAX_COLUMN_LEN => array(null), - PDO::ATTR_DEFAULT_FETCH_MODE => array(null), + PDO::ATTR_AUTOCOMMIT => array(null), + PDO::ATTR_PREFETCH => array(null), + PDO::ATTR_TIMEOUT => array(null), + PDO::ATTR_ERRMODE => array(null), + PDO::ATTR_SERVER_VERSION => array(null), + PDO::ATTR_CLIENT_VERSION => array(null), + PDO::ATTR_SERVER_INFO => array(null), + PDO::ATTR_CONNECTION_STATUS => array(null), + PDO::ATTR_CASE => array(null), + PDO::ATTR_CURSOR_NAME => array(null), + PDO::ATTR_CURSOR => array(null), + PDO::ATTR_ORACLE_NULLS => array(null), + PDO::ATTR_PERSISTENT => array(null), + PDO::ATTR_STATEMENT_CLASS => array(null), + PDO::ATTR_FETCH_TABLE_NAMES => array(null), + PDO::ATTR_FETCH_CATALOG_NAMES => array(null), + PDO::ATTR_DRIVER_NAME => array(null), + PDO::ATTR_STRINGIFY_FETCHES => array(null), + PDO::ATTR_MAX_COLUMN_LEN => array(null), + PDO::ATTR_DEFAULT_FETCH_MODE => array(null), ); foreach ($attrs as $a => $vals) { - foreach ($vals as $v) { - try { - if (!isset($v)) { - var_dump($pdo->getAttribute($a)); - } else { - $pdo->setAttribute($a, $v); - if ($pdo->getAttribute($a) === $v) { - echo "OK\n"; - } else { - throw new \Exception('KO'); - } - } - } catch (\Exception $e) { - if ($e->getCode() == 'IM001') { - echo "ERR\n"; - } else { - echo "ERR {$e->getMessage()}\n"; - } - } - } + foreach ($vals as $v) { + try { + if (!isset($v)) { + var_dump($pdo->getAttribute($a)); + } else { + $pdo->setAttribute($a, $v); + if ($pdo->getAttribute($a) === $v) { + echo "OK\n"; + } else { + throw new \Exception('KO'); + } + } + } catch (\Exception $e) { + if ($e->getCode() == 'IM001') { + echo "ERR\n"; + } else { + echo "ERR {$e->getMessage()}\n"; + } + } + } } ?> diff --git a/ext/pdo_mysql/tests/bug70389.phpt b/ext/pdo_mysql/tests/bug70389.phpt index 09f439804ed7..f2be259543b2 100644 --- a/ext/pdo_mysql/tests/bug70389.phpt +++ b/ext/pdo_mysql/tests/bug70389.phpt @@ -10,9 +10,9 @@ MySQLPDOTest::skip(); true, - PDO::MYSQL_ATTR_LOCAL_INFILE => true, - PDO::ATTR_PERSISTENT => true, + PDO::MYSQL_ATTR_FOUND_ROWS => true, + PDO::MYSQL_ATTR_LOCAL_INFILE => true, + PDO::ATTR_PERSISTENT => true, ]; $std = new StdClass(); diff --git a/ext/pdo_mysql/tests/bug70862.phpt b/ext/pdo_mysql/tests/bug70862.phpt index d54d19f17b05..fee79cbebb9f 100644 --- a/ext/pdo_mysql/tests/bug70862.phpt +++ b/ext/pdo_mysql/tests/bug70862.phpt @@ -8,32 +8,32 @@ MySQLPDOTest::skip(); ?> --FILE-- exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label BLOB)')); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label BLOB)')); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - class HelloWrapper { - public function stream_open() { return true; } - public function stream_eof() { return true; } - public function stream_read() { return NULL; } - public function stream_stat() { return array(); } - } - stream_wrapper_register("hello", "HelloWrapper"); + class HelloWrapper { + public function stream_open() { return true; } + public function stream_eof() { return true; } + public function stream_read() { return NULL; } + public function stream_stat() { return array(); } + } + stream_wrapper_register("hello", "HelloWrapper"); - $f = fopen("hello://there", "r"); + $f = fopen("hello://there", "r"); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, :para)'); - $stmt->bindParam(":para", $f, PDO::PARAM_LOB); - $stmt->execute(); + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, :para)'); + $stmt->bindParam(":para", $f, PDO::PARAM_LOB); + $stmt->execute(); - var_dump($f); + var_dump($f); - print "done!"; + print "done!"; ?> --CLEAN-- query("INSERT INTO $tbl (`bit`) VALUES (0b01100)"); $ret = $pdo->query("SELECT * FROM $tbl")->fetchAll(); foreach ($ret as $i) { - var_dump($i["bit"]); + var_dump($i["bit"]); } ?> diff --git a/ext/pdo_mysql/tests/bug_33689.phpt b/ext/pdo_mysql/tests/bug_33689.phpt index 0755112f5f7f..84b8f5b914be 100644 --- a/ext/pdo_mysql/tests/bug_33689.phpt +++ b/ext/pdo_mysql/tests/bug_33689.phpt @@ -18,7 +18,7 @@ $db->exec('INSERT INTO test VALUES(1)'); var_dump($db->query('SELECT * from test')); foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } $stmt = $db->prepare('SELECT * from test'); @@ -28,9 +28,9 @@ $tmp = $stmt->getColumnMeta(0); // libmysql and mysqlnd will show the pdo_type entry at a different position in the hash if (!isset($tmp['pdo_type']) || (isset($tmp['pdo_type']) && $tmp['pdo_type'] != 2)) - printf("Expecting pdo_type = 2 got %s\n", $tmp['pdo_type']); + printf("Expecting pdo_type = 2 got %s\n", $tmp['pdo_type']); else - unset($tmp['pdo_type']); + unset($tmp['pdo_type']); print_r($tmp); ?> diff --git a/ext/pdo_mysql/tests/bug_38546.phpt b/ext/pdo_mysql/tests/bug_38546.phpt index 0d7b44d1dc7a..238bccb035ed 100644 --- a/ext/pdo_mysql/tests/bug_38546.phpt +++ b/ext/pdo_mysql/tests/bug_38546.phpt @@ -21,20 +21,20 @@ $db->exec("SET sql_mode='STRICT_TRANS_TABLES'"); $db->exec("DROP TABLE IF EXISTS test"); $query = "CREATE TABLE test( - uid MEDIUMINT UNSIGNED NOT NULL, + uid MEDIUMINT UNSIGNED NOT NULL, some_bool_1 BOOL NOT NULL, some_bool_2 BOOL NOT NULL, some_int TINYINT NOT NULL - )"; + )"; $db->exec($query); $st = $db->prepare("INSERT INTO test (uid, some_bool_1, some_bool_2, some_int) VALUES (?, ?, ?, ?)"); $values = [ - 'uid' => 6, - 'some_bool_1' => false, - 'some_bool_2' => true, - 'some_int' => -23 + 'uid' => 6, + 'some_bool_1' => false, + 'some_bool_2' => true, + 'some_int' => -23 ]; $st->bindParam(1, $values['uid'], PDO::PARAM_INT); $st->bindParam(2, $values['some_bool_1'], PDO::PARAM_BOOL); @@ -50,16 +50,16 @@ if ($result === false) { } foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } $st = $db->prepare("UPDATE test SET some_bool_1=?, some_bool_2=?, some_int=? WHERE uid=?"); $values = [ - 'uid' => 6, - 'some_bool_1' => (bool) 1, - 'some_bool_2' => (bool) 0, - 'some_int' => 1, + 'uid' => 6, + 'some_bool_1' => (bool) 1, + 'some_bool_2' => (bool) 0, + 'some_int' => 1, ]; $st->bindParam(1, $values['some_bool_1'], PDO::PARAM_BOOL); @@ -76,16 +76,16 @@ if ($result === false) { } foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } $st = $db->prepare("UPDATE test SET some_bool_1=?, some_bool_2=?, some_int=? WHERE uid=?"); $values = [ - 'uid' => 6, - 'some_bool_1' => (bool) 0, - 'some_bool_2' => (bool) 1, - 'some_int' => 2, + 'uid' => 6, + 'some_bool_1' => (bool) 0, + 'some_bool_2' => (bool) 1, + 'some_int' => 2, ]; $st->bindParam(1, $values['some_bool_1'], PDO::PARAM_BOOL); @@ -102,17 +102,17 @@ if ($result === false) { } foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } // String true and false should fail $st = $db->prepare("UPDATE test SET some_bool_1=?, some_bool_2=?, some_int=? WHERE uid=?"); $values = [ - 'uid' => 6, - 'some_bool_1' => 'true', - 'some_bool_2' => 'false', - 'some_int' => 3, + 'uid' => 6, + 'some_bool_1' => 'true', + 'some_bool_2' => 'false', + 'some_int' => 3, ]; $st->bindParam(1, $values['some_bool_1'], PDO::PARAM_BOOL); @@ -129,17 +129,17 @@ if ($result === false) { } foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } // Null should not be treated as false $st = $db->prepare("UPDATE test SET some_bool_1=?, some_bool_2=?, some_int=? WHERE uid=?"); $values = [ - 'uid' => 6, - 'some_bool_1' => true, - 'some_bool_2' => null, - 'some_int' => 4, + 'uid' => 6, + 'some_bool_1' => true, + 'some_bool_2' => null, + 'some_int' => 4, ]; $st->bindParam(1, $values['some_bool_1'], PDO::PARAM_BOOL); @@ -156,17 +156,17 @@ if ($result === false) { } foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } // Integers converted correctly $st = $db->prepare("UPDATE test SET some_bool_1=?, some_bool_2=?, some_int=? WHERE uid=?"); $values = [ - 'uid' => 6, - 'some_bool_1' => 256, - 'some_bool_2' => 0, - 'some_int' => 5, + 'uid' => 6, + 'some_bool_1' => 256, + 'some_bool_2' => 0, + 'some_int' => 5, ]; $st->bindParam(1, $values['some_bool_1'], PDO::PARAM_BOOL); @@ -183,7 +183,7 @@ if ($result === false) { } foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } ?> diff --git a/ext/pdo_mysql/tests/bug_39858.phpt b/ext/pdo_mysql/tests/bug_39858.phpt index db8afa99b812..9328c0f20d22 100644 --- a/ext/pdo_mysql/tests/bug_39858.phpt +++ b/ext/pdo_mysql/tests/bug_39858.phpt @@ -28,29 +28,29 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); function bug_39858($db) { - $db->exec("DROP PROCEDURE IF EXISTS p"); - $db->exec(" - CREATE PROCEDURE p() - NOT DETERMINISTIC - CONTAINS SQL - SQL SECURITY DEFINER - COMMENT '' - BEGIN - SELECT 2 * 2; - END;"); + $db->exec("DROP PROCEDURE IF EXISTS p"); + $db->exec(" + CREATE PROCEDURE p() + NOT DETERMINISTIC + CONTAINS SQL + SQL SECURITY DEFINER + COMMENT '' + BEGIN + SELECT 2 * 2; + END;"); - $stmt = $db->prepare("CALL p()"); - $stmt->execute(); - do { - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } while ($stmt->nextRowset()); + $stmt = $db->prepare("CALL p()"); + $stmt->execute(); + do { + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + } while ($stmt->nextRowset()); - $stmt = $db->prepare("CALL p()"); - $stmt->execute(); - do { - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } while ($stmt->nextRowset()); - $stmt->closeCursor(); + $stmt = $db->prepare("CALL p()"); + $stmt->execute(); + do { + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + } while ($stmt->nextRowset()); + $stmt->closeCursor(); } diff --git a/ext/pdo_mysql/tests/bug_41125.phpt b/ext/pdo_mysql/tests/bug_41125.phpt index e341ed409cec..c86cad2b5106 100644 --- a/ext/pdo_mysql/tests/bug_41125.phpt +++ b/ext/pdo_mysql/tests/bug_41125.phpt @@ -33,7 +33,7 @@ $sql = "CREATE TABLE IF NOT EXISTS test(id INT); INSERT INTO test(id) VALUES (1) // Compare MySQL C-API documentation $stmt = $db->query($sql); do { - var_dump($stmt->fetchAll()); + var_dump($stmt->fetchAll()); } while ($stmt->nextRowset()); print "done!"; diff --git a/ext/pdo_mysql/tests/bug_41997.phpt b/ext/pdo_mysql/tests/bug_41997.phpt index e3b52944be0d..def3d4406dc2 100644 --- a/ext/pdo_mysql/tests/bug_41997.phpt +++ b/ext/pdo_mysql/tests/bug_41997.phpt @@ -29,7 +29,7 @@ $db->exec('CREATE PROCEDURE p() BEGIN SELECT 1 AS "one"; END'); $stmt = $db->query("CALL p()"); do { - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } while ($stmt->nextRowset()); var_dump($stmt->errorInfo()); diff --git a/ext/pdo_mysql/tests/bug_42499.phpt b/ext/pdo_mysql/tests/bug_42499.phpt index 244101a7ae8d..4ad38eeca28c 100644 --- a/ext/pdo_mysql/tests/bug_42499.phpt +++ b/ext/pdo_mysql/tests/bug_42499.phpt @@ -26,16 +26,16 @@ $db = MySQLPDOTest::factory(); function bug_42499($db) { - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec("CREATE TABLE test(id CHAR(1)); INSERT INTO test(id) VALUES ('a')"); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec("CREATE TABLE test(id CHAR(1)); INSERT INTO test(id) VALUES ('a')"); - $stmt = $db->query('SELECT id AS _id FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query('SELECT id AS _id FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // You must not use exec() to run statements that create a result set! - $db->exec('SELECT id FROM test'); - // This will bail at you because you have not fetched the SELECT results: this is not a bug! - $db->exec("INSERT INTO test(id) VALUES ('b')"); + // You must not use exec() to run statements that create a result set! + $db->exec('SELECT id FROM test'); + // This will bail at you because you have not fetched the SELECT results: this is not a bug! + $db->exec("INSERT INTO test(id) VALUES ('b')"); } diff --git a/ext/pdo_mysql/tests/bug_44454.phpt b/ext/pdo_mysql/tests/bug_44454.phpt index d21cf3a4e2ca..e95904dda115 100644 --- a/ext/pdo_mysql/tests/bug_44454.phpt +++ b/ext/pdo_mysql/tests/bug_44454.phpt @@ -15,43 +15,43 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); function bug_44454($db) { - try { + try { - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(a INT, b INT, UNIQUE KEY idx_ab (a, b))'); - $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(a INT, b INT, UNIQUE KEY idx_ab (a, b))'); + $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); - $stmt = $db->query('SELECT a, b FROM test'); - printf("... SELECT has returned %d row...\n", $stmt->rowCount()); - while ($row = $stmt->fetch()) { - try { - printf("... INSERT should fail...\n"); - $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); - } catch (Exception $e) { - printf("... STMT - %s\n", var_export($stmt->errorCode(), true)); - printf("... PDO - %s\n", var_export($db->errorInfo(), true)); - } - } + $stmt = $db->query('SELECT a, b FROM test'); + printf("... SELECT has returned %d row...\n", $stmt->rowCount()); + while ($row = $stmt->fetch()) { + try { + printf("... INSERT should fail...\n"); + $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); + } catch (Exception $e) { + printf("... STMT - %s\n", var_export($stmt->errorCode(), true)); + printf("... PDO - %s\n", var_export($db->errorInfo(), true)); + } + } - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(a INT, b INT, UNIQUE KEY idx_ab (a, b))'); - $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(a INT, b INT, UNIQUE KEY idx_ab (a, b))'); + $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); - } catch (Exception $e) { - printf("... While error %s\n", $e->getMessage()); ; - } + } catch (Exception $e) { + printf("... While error %s\n", $e->getMessage()); ; + } - $stmt = $db->query('SELECT a, b FROM test'); - printf("... SELECT has returned %d row...\n", $stmt->rowCount()); - foreach ($stmt as $row) { - try { - printf("... INSERT should fail...\n"); - $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); - } catch (Exception $e) { - printf("... STMT - %s\n", var_export($stmt->errorCode(), true)); - printf("... PDO - %s\n", var_export($db->errorInfo(), true)); - } - } + $stmt = $db->query('SELECT a, b FROM test'); + printf("... SELECT has returned %d row...\n", $stmt->rowCount()); + foreach ($stmt as $row) { + try { + printf("... INSERT should fail...\n"); + $db->exec('INSERT INTO test(a, b) VALUES (1, 1)'); + } catch (Exception $e) { + printf("... STMT - %s\n", var_export($stmt->errorCode(), true)); + printf("... PDO - %s\n", var_export($db->errorInfo(), true)); + } + } } diff --git a/ext/pdo_mysql/tests/bug_44707.phpt b/ext/pdo_mysql/tests/bug_44707.phpt index 60f4ccdfaef8..6bd711443197 100644 --- a/ext/pdo_mysql/tests/bug_44707.phpt +++ b/ext/pdo_mysql/tests/bug_44707.phpt @@ -28,32 +28,32 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); function bug_44707($db) { - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(id INT, mybool TINYINT)'); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(id INT, mybool TINYINT)'); - $id = 1; - $mybool = false; - var_dump($mybool); + $id = 1; + $mybool = false; + var_dump($mybool); - $stmt = $db->prepare('INSERT INTO test(id, mybool) VALUES (?, ?)'); - $stmt->bindParam(1, $id); - $stmt->bindParam(2, $mybool, PDO::PARAM_BOOL); - var_dump($mybool); + $stmt = $db->prepare('INSERT INTO test(id, mybool) VALUES (?, ?)'); + $stmt->bindParam(1, $id); + $stmt->bindParam(2, $mybool, PDO::PARAM_BOOL); + var_dump($mybool); - $stmt->execute(); - var_dump($mybool); + $stmt->execute(); + var_dump($mybool); - $stmt = $db->query('SELECT * FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query('SELECT * FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->prepare('INSERT INTO test(id, mybool) VALUES (?, ?)'); - $stmt->bindParam(1, $id); - // INT and integer work well together - $stmt->bindParam(2, $mybool, PDO::PARAM_INT); - $stmt->execute(); + $stmt = $db->prepare('INSERT INTO test(id, mybool) VALUES (?, ?)'); + $stmt->bindParam(1, $id); + // INT and integer work well together + $stmt->bindParam(2, $mybool, PDO::PARAM_INT); + $stmt->execute(); - $stmt = $db->query('SELECT * FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query('SELECT * FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } diff --git a/ext/pdo_mysql/tests/bug_45120.phpt b/ext/pdo_mysql/tests/bug_45120.phpt index bc2ea76629fd..b281a6a3546b 100644 --- a/ext/pdo_mysql/tests/bug_45120.phpt +++ b/ext/pdo_mysql/tests/bug_45120.phpt @@ -15,20 +15,20 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); function bug_45120($db) { - $stmt = $db->prepare("SELECT 1 AS 'one'"); - if (true !== $stmt->execute()) - printf("[001] Execute has failed: %s\n", var_export($stmt->errorInfo(), true)); + $stmt = $db->prepare("SELECT 1 AS 'one'"); + if (true !== $stmt->execute()) + printf("[001] Execute has failed: %s\n", var_export($stmt->errorInfo(), true)); - $res = $stmt->fetch(PDO::FETCH_ASSOC); - if ($res['one'] != 1) - printf("[002] Wrong results: %s\n", var_export($res, true)); + $res = $stmt->fetch(PDO::FETCH_ASSOC); + if ($res['one'] != 1) + printf("[002] Wrong results: %s\n", var_export($res, true)); - if (true !== $stmt->execute()) - printf("[003] Execute has failed: %s\n", var_export($stmt->errorInfo(), true)); + if (true !== $stmt->execute()) + printf("[003] Execute has failed: %s\n", var_export($stmt->errorInfo(), true)); - $res = $stmt->fetch(PDO::FETCH_ASSOC); - if ($res['one'] != 1) - printf("[004] Wrong results: %s\n", var_export($res, true)); + $res = $stmt->fetch(PDO::FETCH_ASSOC); + if ($res['one'] != 1) + printf("[004] Wrong results: %s\n", var_export($res, true)); } diff --git a/ext/pdo_mysql/tests/bug_61207.phpt b/ext/pdo_mysql/tests/bug_61207.phpt index 346c1687e7bb..b8a6a21f09ab 100644 --- a/ext/pdo_mysql/tests/bug_61207.phpt +++ b/ext/pdo_mysql/tests/bug_61207.phpt @@ -26,9 +26,9 @@ $handle1->execute(); $i = 1; print("Handle 1:\n"); do { - print('Rowset ' . $i++ . "\n"); - if ($handle1->columnCount() > 0) - print("Results detected\n"); + print('Rowset ' . $i++ . "\n"); + if ($handle1->columnCount() > 0) + print("Results detected\n"); } while($handle1->nextRowset()); $handle2 = $db->prepare('select * from test where id = ?; @@ -42,9 +42,9 @@ $handle2->execute(); $i = 1; print("Handle 2:\n"); do { - print('Rowset ' . $i++ . "\n"); - if ($handle2->columnCount() > 0) - print("Results detected\n"); + print('Rowset ' . $i++ . "\n"); + if ($handle2->columnCount() > 0) + print("Results detected\n"); } while($handle2->nextRowset()); $handle3 = $db->prepare('update test set id = 2 where id = ?; @@ -58,9 +58,9 @@ $handle3->execute(); $i = 1; print("Handle 3:\n"); do { - print('Rowset ' . $i++ . "\n"); - if ($handle3->columnCount() > 0) - print("Results detected\n"); + print('Rowset ' . $i++ . "\n"); + if ($handle3->columnCount() > 0) + print("Results detected\n"); } while($handle3->nextRowset()); $handle4 = $db->prepare('insert into test(id) values(3); @@ -75,9 +75,9 @@ $handle4->execute(); $i = 1; print("Handle 4:\n"); do { - print('Rowset ' . $i++ . "\n"); - if ($handle1->columnCount() > 0) - print("Results detected\n"); + print('Rowset ' . $i++ . "\n"); + if ($handle1->columnCount() > 0) + print("Results detected\n"); } while($handle1->nextRowset()); $db->query("DROP TABLE test"); diff --git a/ext/pdo_mysql/tests/bug_61411.phpt b/ext/pdo_mysql/tests/bug_61411.phpt index f12804ab5f09..920dc4e06718 100644 --- a/ext/pdo_mysql/tests/bug_61411.phpt +++ b/ext/pdo_mysql/tests/bug_61411.phpt @@ -24,9 +24,9 @@ require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); $attr = getenv('PDOTEST_ATTR'); if (!$attr) { - $attr = array(); + $attr = array(); } else { - $attr = unserialize($attr); + $attr = unserialize($attr); } $attr[PDO::ATTR_PERSISTENT] = true; $attr[PDO::ATTR_EMULATE_PREPARES] = false; @@ -38,7 +38,7 @@ $stmt = $db->prepare("SELECT 1"); $stmt->execute(); foreach ($stmt as $line) { - var_dump($line); + var_dump($line); } print "done!"; diff --git a/ext/pdo_mysql/tests/bug_pecl_12925.phpt b/ext/pdo_mysql/tests/bug_pecl_12925.phpt index 361ef719d097..2075d145814f 100644 --- a/ext/pdo_mysql/tests/bug_pecl_12925.phpt +++ b/ext/pdo_mysql/tests/bug_pecl_12925.phpt @@ -15,17 +15,17 @@ $db = MySQLPDOTest::factory(); function bug_pecl_1295($db) { - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(id CHAR(1))'); - $db->exec("INSERT INTO test(id) VALUES ('a')"); - $stmt = $db->prepare("UPDATE test SET id = 'b'"); - $stmt->execute(); - $stmt = $db->prepare("UPDATE test SET id = 'c'"); - $stmt->execute(); - $stmt = $db->prepare('SELECT id FROM test'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt->closeCursor(); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(id CHAR(1))'); + $db->exec("INSERT INTO test(id) VALUES ('a')"); + $stmt = $db->prepare("UPDATE test SET id = 'b'"); + $stmt->execute(); + $stmt = $db->prepare("UPDATE test SET id = 'c'"); + $stmt->execute(); + $stmt = $db->prepare('SELECT id FROM test'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt->closeCursor(); } diff --git a/ext/pdo_mysql/tests/bug_pecl_7976.phpt b/ext/pdo_mysql/tests/bug_pecl_7976.phpt index 9eb50abd4373..00446edc470b 100644 --- a/ext/pdo_mysql/tests/bug_pecl_7976.phpt +++ b/ext/pdo_mysql/tests/bug_pecl_7976.phpt @@ -25,16 +25,16 @@ $db = MySQLPDOTest::factory(); function bug_pecl_7976($db) { - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN SELECT "1" AS _one; END;'); + $db->exec('DROP PROCEDURE IF EXISTS p'); + $db->exec('CREATE PROCEDURE p() BEGIN SELECT "1" AS _one; END;'); - $stmt = $db->query('CALL p()'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt->closeCursor(); + $stmt = $db->query('CALL p()'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt->closeCursor(); - $stmt = $db->query('CALL p()'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt->closeCursor(); + $stmt = $db->query('CALL p()'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt->closeCursor(); } diff --git a/ext/pdo_mysql/tests/config.inc b/ext/pdo_mysql/tests/config.inc index f5ea020b784d..d0a67ccd1667 100644 --- a/ext/pdo_mysql/tests/config.inc +++ b/ext/pdo_mysql/tests/config.inc @@ -2,21 +2,21 @@ /* Overrule global settings, if need be */ if (false !== getenv('PDO_MYSQL_TEST_DSN')) { - # user set them from their shell - $config['ENV']['PDOTEST_DSN'] = getenv('PDO_MYSQL_TEST_DSN'); - $config['ENV']['PDOTEST_USER'] = getenv('PDO_MYSQL_TEST_USER'); - $config['ENV']['PDOTEST_PASS'] = getenv('PDO_MYSQL_TEST_PASS'); - if (false !== getenv('PDO_MYSQL_TEST_ATTR')) { - $config['ENV']['PDOTEST_ATTR'] = getenv('PDO_MYSQL_TEST_ATTR'); - } + # user set them from their shell + $config['ENV']['PDOTEST_DSN'] = getenv('PDO_MYSQL_TEST_DSN'); + $config['ENV']['PDOTEST_USER'] = getenv('PDO_MYSQL_TEST_USER'); + $config['ENV']['PDOTEST_PASS'] = getenv('PDO_MYSQL_TEST_PASS'); + if (false !== getenv('PDO_MYSQL_TEST_ATTR')) { + $config['ENV']['PDOTEST_ATTR'] = getenv('PDO_MYSQL_TEST_ATTR'); + } } else { - $config['ENV']['PDOTEST_DSN'] = 'mysql:host=localhost;dbname=test'; - $config['ENV']['PDOTEST_USER'] = 'root'; - $config['ENV']['PDOTEST_PASS'] = ''; + $config['ENV']['PDOTEST_DSN'] = 'mysql:host=localhost;dbname=test'; + $config['ENV']['PDOTEST_USER'] = 'root'; + $config['ENV']['PDOTEST_PASS'] = ''; } foreach ($config['ENV'] as $k => $v) { - putenv("$k=$v"); + putenv("$k=$v"); } /* MySQL specific settings */ @@ -31,22 +31,22 @@ define('PDO_MYSQL_TEST_PASS', (false !== getenv('PDO_MYSQL_TEST_PASS')) ? getenv define('PDO_MYSQL_TEST_CHARSET', (false !== getenv('PDO_MYSQL_TEST_CHARSET')) ? getenv('PDO_MYSQL_TEST_CHARSET') : NULL); if (!function_exists('sys_get_temp_dir')) { - function sys_get_temp_dir() { + function sys_get_temp_dir() { - if (!empty($_ENV['TMP'])) - return realpath( $_ENV['TMP'] ); - if (!empty($_ENV['TMPDIR'])) - return realpath( $_ENV['TMPDIR'] ); - if (!empty($_ENV['TEMP'])) - return realpath( $_ENV['TEMP'] ); + if (!empty($_ENV['TMP'])) + return realpath( $_ENV['TMP'] ); + if (!empty($_ENV['TMPDIR'])) + return realpath( $_ENV['TMPDIR'] ); + if (!empty($_ENV['TEMP'])) + return realpath( $_ENV['TEMP'] ); - $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); - if ($temp_file) { - $temp_dir = realpath(dirname($temp_file)); - unlink($temp_file); - return $temp_dir; - } - return FALSE; - } + $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); + if ($temp_file) { + $temp_dir = realpath(dirname($temp_file)); + unlink($temp_file); + return $temp_dir; + } + return FALSE; + } } ?> diff --git a/ext/pdo_mysql/tests/mysql_pdo_test.inc b/ext/pdo_mysql/tests/mysql_pdo_test.inc index 65ad7b2d17c2..880f8dbf758f 100644 --- a/ext/pdo_mysql/tests/mysql_pdo_test.inc +++ b/ext/pdo_mysql/tests/mysql_pdo_test.inc @@ -4,174 +4,174 @@ require_once(dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'); class MySQLPDOTest extends PDOTest { - static function factory($classname = 'PDO', $drop_test_tables = false, $myattr = null, $mydsn = null) { - - $dsn = self::getDSN($mydsn); - $user = PDO_MYSQL_TEST_USER; - $pass = PDO_MYSQL_TEST_PASS; - $attr = getenv('PDOTEST_ATTR'); - - if (is_string($attr) && strlen($attr)) { - $attr = unserialize($attr); - } else { - $attr = null; - } - if ($user === false) - $user = NULL; - if ($pass === false) - $pass = NULL; - - $db = new $classname($dsn, $user, $pass, $attr); - if (!$db) { - die("Could not create PDO object (DSN=$dsn, user=$user)\n"); - } - - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); - - return $db; - } - - static function createTestTable($db, $engine = null) { - if (!$engine) - $engine = PDO_MYSQL_TEST_ENGINE; - - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine); - $db->exec("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')"); - } - - static function getTableEngine() { - return PDO_MYSQL_TEST_ENGINE; - } - - - static function getDSN($new_options = null, $addition = '') { - if (!$new_options) - return PDO_MYSQL_TEST_DSN . $addition; - - $old_options = array(); - $dsn = substr(PDO_MYSQL_TEST_DSN, - strpos(PDO_MYSQL_TEST_DSN, ':') + 1, - strlen(PDO_MYSQL_TEST_DSN)); - - // no real parser - any exotic setting can fool us - $parts = explode(';', $dsn); - foreach ($parts as $k => $v) { - $tmp = explode('=', $v); - if (count($tmp) == 2) - $old_options[$tmp[0]] = $tmp[1]; - } - - $options = $old_options; - foreach ($new_options as $k => $v) - $options[$k] = $v; - - $dsn = 'mysql:'; - foreach ($options as $k => $v) - $dsn .= sprintf('%s=%s;', $k, $v); - - if ($addition) - $dsn .= $addition; - else - $dsn = substr($dsn, 0, strlen($dsn) -1); - - return $dsn; - } - - static function getClientVersion($db) { - return self::extractVersion($db->getAttribute(PDO::ATTR_CLIENT_VERSION)); - } - - static function getServerVersion($db) { - return self::extractVersion($db->getAttribute(PDO::ATTR_SERVER_VERSION)); - } - - static function extractVersion($version_string) { - /* - TODO: - We're a bit in trouble: PDO_MYSQL returns version strings. - That's wrong according to the manual. According to the manual - integers should be returned. However, this code needs to work - with stinky PDO_MYSQL and hopefully better PDO_MYSQLND. - */ - - // already an int value? - if (is_int($version_string)) - return $version_string; - - // string but int value? - $tmp = (int)$version_string; - if (((string)$tmp) === $version_string) - return $tmp; - - // stinky string which we need to parse - $parts = explode('.', $version_string); - if (count($parts) < 3) - return -1; - - $version = (int)$parts[0] * 10000; - $version+= (int)$parts[1] * 100; - $version+= (int)$parts[2]; - - return $version; - } - - static function getTempDir() { - - if (!function_exists('sys_get_temp_dir')) { - - if (!empty($_ENV['TMP'])) - return realpath( $_ENV['TMP'] ); - if (!empty($_ENV['TMPDIR'])) - return realpath( $_ENV['TMPDIR'] ); - if (!empty($_ENV['TEMP'])) - return realpath( $_ENV['TEMP'] ); - - $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); - if ($temp_file) { - $temp_dir = realpath(dirname($temp_file)); - unlink($temp_file); - return $temp_dir; - } - return FALSE; - } else { - return sys_get_temp_dir(); - } - - } - - static function detect_transactional_mysql_engine($db) { - foreach ($db->query("show variables like 'have%'") as $row) { - if (!empty($row) && $row[1] == 'YES' && ($row[0] == 'have_innodb' || $row[0] == 'have_bdb')) { - return str_replace("have_", "", $row[0]); - } - } - /* MySQL 5.6.1+ */ - foreach ($db->query("SHOW ENGINES") as $row) { - if (isset($row['engine']) && isset($row['support'])) { - if ('InnoDB' == $row['engine'] && ('YES' == $row['support'] || 'DEFAULT' == $row['support'])) - return 'innodb'; - } - } - return false; - } - - static function isPDOMySQLnd() { - ob_start(); - phpinfo(); - $tmp = ob_get_contents(); - ob_end_clean(); - return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) && - preg_match('/Client API version.*mysqlnd/', $tmp)); - } - - static function dropTestTable($db = NULL) { - if (is_null($db)) - $db = self::factory(); - - $db->exec('DROP TABLE IF EXISTS test'); - } + static function factory($classname = 'PDO', $drop_test_tables = false, $myattr = null, $mydsn = null) { + + $dsn = self::getDSN($mydsn); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + $attr = getenv('PDOTEST_ATTR'); + + if (is_string($attr) && strlen($attr)) { + $attr = unserialize($attr); + } else { + $attr = null; + } + if ($user === false) + $user = NULL; + if ($pass === false) + $pass = NULL; + + $db = new $classname($dsn, $user, $pass, $attr); + if (!$db) { + die("Could not create PDO object (DSN=$dsn, user=$user)\n"); + } + + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); + + return $db; + } + + static function createTestTable($db, $engine = null) { + if (!$engine) + $engine = PDO_MYSQL_TEST_ENGINE; + + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine); + $db->exec("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')"); + } + + static function getTableEngine() { + return PDO_MYSQL_TEST_ENGINE; + } + + + static function getDSN($new_options = null, $addition = '') { + if (!$new_options) + return PDO_MYSQL_TEST_DSN . $addition; + + $old_options = array(); + $dsn = substr(PDO_MYSQL_TEST_DSN, + strpos(PDO_MYSQL_TEST_DSN, ':') + 1, + strlen(PDO_MYSQL_TEST_DSN)); + + // no real parser - any exotic setting can fool us + $parts = explode(';', $dsn); + foreach ($parts as $k => $v) { + $tmp = explode('=', $v); + if (count($tmp) == 2) + $old_options[$tmp[0]] = $tmp[1]; + } + + $options = $old_options; + foreach ($new_options as $k => $v) + $options[$k] = $v; + + $dsn = 'mysql:'; + foreach ($options as $k => $v) + $dsn .= sprintf('%s=%s;', $k, $v); + + if ($addition) + $dsn .= $addition; + else + $dsn = substr($dsn, 0, strlen($dsn) -1); + + return $dsn; + } + + static function getClientVersion($db) { + return self::extractVersion($db->getAttribute(PDO::ATTR_CLIENT_VERSION)); + } + + static function getServerVersion($db) { + return self::extractVersion($db->getAttribute(PDO::ATTR_SERVER_VERSION)); + } + + static function extractVersion($version_string) { + /* + TODO: + We're a bit in trouble: PDO_MYSQL returns version strings. + That's wrong according to the manual. According to the manual + integers should be returned. However, this code needs to work + with stinky PDO_MYSQL and hopefully better PDO_MYSQLND. + */ + + // already an int value? + if (is_int($version_string)) + return $version_string; + + // string but int value? + $tmp = (int)$version_string; + if (((string)$tmp) === $version_string) + return $tmp; + + // stinky string which we need to parse + $parts = explode('.', $version_string); + if (count($parts) < 3) + return -1; + + $version = (int)$parts[0] * 10000; + $version+= (int)$parts[1] * 100; + $version+= (int)$parts[2]; + + return $version; + } + + static function getTempDir() { + + if (!function_exists('sys_get_temp_dir')) { + + if (!empty($_ENV['TMP'])) + return realpath( $_ENV['TMP'] ); + if (!empty($_ENV['TMPDIR'])) + return realpath( $_ENV['TMPDIR'] ); + if (!empty($_ENV['TEMP'])) + return realpath( $_ENV['TEMP'] ); + + $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); + if ($temp_file) { + $temp_dir = realpath(dirname($temp_file)); + unlink($temp_file); + return $temp_dir; + } + return FALSE; + } else { + return sys_get_temp_dir(); + } + + } + + static function detect_transactional_mysql_engine($db) { + foreach ($db->query("show variables like 'have%'") as $row) { + if (!empty($row) && $row[1] == 'YES' && ($row[0] == 'have_innodb' || $row[0] == 'have_bdb')) { + return str_replace("have_", "", $row[0]); + } + } + /* MySQL 5.6.1+ */ + foreach ($db->query("SHOW ENGINES") as $row) { + if (isset($row['engine']) && isset($row['support'])) { + if ('InnoDB' == $row['engine'] && ('YES' == $row['support'] || 'DEFAULT' == $row['support'])) + return 'innodb'; + } + } + return false; + } + + static function isPDOMySQLnd() { + ob_start(); + phpinfo(); + $tmp = ob_get_contents(); + ob_end_clean(); + return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) && + preg_match('/Client API version.*mysqlnd/', $tmp)); + } + + static function dropTestTable($db = NULL) { + if (is_null($db)) + $db = self::factory(); + + $db->exec('DROP TABLE IF EXISTS test'); + } } ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt index b849f274bef3..2231f8b44936 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct.phpt @@ -8,289 +8,289 @@ MySQLPDOTest::skip(); ?> --FILE-- getMessage(), - (isset($db) && is_object($db)) ? $db->errorCode() : 'n/a', - (isset($db) && is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } - - return ''; - } - - try { - - try { - if (NULL !== ($db = @new PDO())) - printf("[001] Too few parameters\n"); - } catch (TypeError $ex) { - } - - print tryandcatch(2, '$db = new PDO(chr(0));'); - print tryandcatch(3, '$db = new PDO("a" . chr(0) . "b");'); - print tryandcatch(4, '$db = new PDO("MYSQL");'); - print tryandcatch(5, '$db = new PDO("mysql");'); - print tryandcatch(6, '$db = new PDO("mysql ");'); - print tryandcatch(7, '$db = new PDO("fantasyandfriends :");'); - - $dsn = PDO_MYSQL_TEST_DSN; - // MySQL Server might accept anonymous connections, don't - // print anything - tryandcatch(8, '$db = new PDO("' . $dsn . '");'); - - $user = 'dontcreatesuchauser'; - $pass = 'withthispassword'; - print tryandcatch(9, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); - - // should fail - $dsn = 'mysql:'; - // don't print the message since it can be different - tryandcatch(10, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); - - $dsn = PDO_MYSQL_TEST_DSN; - $user = PDO_MYSQL_TEST_USER; - $pass = PDO_MYSQL_TEST_PASS; - // should work... - $db = new PDO($dsn, $user, $pass); - - // Reaction on host not specified differs for different configs, so no printing - $dsn = 'mysql:invalid=foo'; - tryandcatch(11, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); - - $dsn = 'mysql:' . str_repeat('howmuch=canpdoeat;', 1000); - tryandcatch(12, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); - - $dsn = 'mysql:' . str_repeat('abcdefghij', 1024 * 10) . '=somevalue'; - tryandcatch(13, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); - - if (PDO_MYSQL_TEST_HOST) { - $host = PDO_MYSQL_TEST_HOST; - $invalid_host = $host . 'invalid'; - - // last host specification should be the one used - $dsn = MySQLPDOTest::getDSN(array('host' => $host), 'host=' . $invalid_host); - try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { - $tmp = $e->getMessage(); - if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002')) - printf("[014] Cannot find proper error codes: %s\n", $tmp); - } - - $dsn = MySQLPDOTest::getDSN(array('host' => $invalid_host), 'host=' . $host); - try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { - printf("[015] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - - $invalid_host = '-' . chr(0); - - $dsn = MySQLPDOTest::getDSN(array('host' => $invalid_host)); - try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { - $tmp = $e->getMessage(); - if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002')) - printf("[016] Cannot find proper error codes: %s\n", $tmp); - } - - // parsing should not get confused by chr(0) - $dsn = MySQLPDOTest::getDSN(array('host' => $invalid_host), 'host=' . $host); - try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { - printf("[017] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - - } - - // what about long values for a valid option ... - // hostnames > 1024 chars break on some NIS-enabled FreeBSD... - $dsn = MySQLPDOTest::getDSN(array('host' => str_repeat('0123456789', 100))); - try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { - $tmp = $e->getMessage(); - if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002')) - printf("[018] Cannot find proper error codes: %s\n", $tmp); - } - - if (PDO_MYSQL_TEST_PORT && (PDO_MYSQL_TEST_SOCKET == '')) { - // Playing with the port makes only sense if no socket gets used - - $port = PDO_MYSQL_TEST_PORT; - // let's hope we don't hit a MySQL running on that port... - $invalid_port = $port * 2; - - $dsn = MySQLPDOTest::getDSN(array('port' => $port), 'port=' . $invalid_port); - try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { - $tmp = $e->getMessage(); - if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005')) - printf("[019] Cannot find proper error codes: %s\n", $tmp); - } - - $dsn = MySQLPDOTest::getDSN(array('port' => $invalid_port), 'port=' . $port); - try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { - printf("[020] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - - $invalid_port = 'abc'; - $dsn = MySQLPDOTest::getDSN(array('port' => $port), 'port=' . $invalid_port); - try { - $db = @new PDO($dsn, $user, $pass); - // atoi('abc') = 0, 0 -> fallback to default 3306 -> may or may not fail! - } catch (PDOException $e) { - } - - } - - if (PDO_MYSQL_TEST_DB) { - $db = PDO_MYSQL_TEST_DB; - $invalid_db = 'letshopeitdoesnotexist'; - - $dsn = MySQLPDOTest::getDSN(array('dbname' => $db), 'dbname=' . $invalid_db); - try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { - $tmp = $e->getMessage(); - if (!stristr($tmp, '42000') && !stristr($tmp, '1049')) - printf("[022] Cannot find proper error codes: %s\n", $tmp); - } - - $dsn = MySQLPDOTest::getDSN(array('dbname' => $invalid_db), 'dbname=' . $db); - try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { - printf("[023] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - - } - - if (PDO_MYSQL_TEST_SOCKET && (stristr(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_SOCKET) !== false)) { - $socket = PDO_MYSQL_TEST_SOCKET; - $invalid_socket = '/lets/hope/it/does/not/exist'; - - $dsn = MySQLPDOTest::getDSN(array('unix_socket' => $socket), 'unix_socket=' . $invalid_socket); - try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { - $tmp = $e->getMessage(); - if (!stristr($tmp, 'HY000') && !stristr($tmp, '2002')) - printf("[024] Cannot find proper error codes: %s\n", $tmp); - } - - $dsn = MySQLPDOTest::getDSN(array('unix_socket' => $invalid_socket), 'unix_socket=' . $socket); - try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { - printf("[025] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - - } - - $have_charset_support = false; - $dsn = MySQLPDOTest::getDSN(); - try { - $db = new PDO($dsn, $user, $pass); - $stmt = $db->query('SELECT VERSION() as _version'); - $version = $stmt->fetch(PDO::FETCH_ASSOC); - - $tmp = explode('.', $version['_version']); - if ((count($tmp) == 3) && - (($tmp[0] >= 4 && $tmp[1] >= 1) || ($tmp[0] >= 5))) { - // MySQL Server 4.1 - charset support available - $have_charset_support = true; - } - - } catch (PDOException $e) { - printf("[026] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - - if (PDO_MYSQL_TEST_CHARSET) { - $charset = PDO_MYSQL_TEST_CHARSET; - $invalid_charset = 'invalid'; - - if ($have_charset_support) { - $dsn = MySQLPDOTest::getDSN(); - $db = new PDO($dsn, $user, $pass); - $stmt = $db->query(sprintf('SHOW CHARACTER SET LIKE "%s"', $charset)); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $have_charset = (empty($tmp)) ? false : true; - - if ($have_charset) { - $dsn = MySQLPDOTest::getDSN(array('charset' => $charset), 'charset=' . $invalid_charset); - try { - $db = @new PDO($dsn, $user, $pass); - /* NOTE: MySQL does a fallback to the charset suggested during the handshake - no error - no bug! */ - } catch (PDOException $e) { - $tmp = $e->getMessage(); - /* TODO: add proper codes */ - if (!stristr($tmp, 'sqlstatecode') || !stristr($tmp, 'mysqlinternalerrcode')) - printf("[027] TODO - Cannot find proper error codes: %s\n", $tmp); - } - - $dsn = MySQLPDOTest::getDSN(array('charset' => $invalid_charset), 'charset=' . $charset); - try { - $db = @new PDO($dsn, $user, $pass); - /* Strictly speaking we should test more: character_set_client, character_set_results, and character_set_connection */ - $stmt = $db->query('SELECT @@character_set_connection AS _charset'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - if ($tmp['_charset'] != $charset) - printf("[028] Character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", - $tmp['_charset'], $charset); - } catch (PDOException $e) { - printf("[029] DSN=%s, %s\n", $dsn, $e->getMessage()); - } - } else { - printf("[030] You're trying to run the tests with charset '%s' which seems not supported by the server!", $charset); - } - - } - - } - - if ($have_charset_support) { - // In case the PDO_MYSQL_TEST_CHARSET interferes with any defaults - // we do another test to verify that the charset has been set. - $dsn = MySQLPDOTest::getDSN(); - $db = new PDO($dsn, $user, $pass); - $stmt = $db->query('SHOW CHARACTER SET LIKE "latin1"'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $have_latin1 =(empty($tmp)) ? false : true; - $stmt = $db->query('SHOW CHARACTER SET LIKE "latin2"'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $have_latin2 =(empty($tmp)) ? false : true; - - if ($have_latin1 && $have_latin2) { - // very likely we do have both of them... - try { - $dsn = MySQLPDOTest::getDSN(array('charset' => 'latin1')); - $db = new PDO($dsn, $user, $pass); - $stmt = $db->query('SELECT @@character_set_connection AS _charset'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - if ($tmp['_charset'] != 'latin1') - printf("[031] DSN = %s, Character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", - $dsn, $tmp['_charset'], 'latin1'); - - } catch (PDOException $e) { - printf("[032] %s\n", $e->getMessage()); - } - - try { - $dsn = MySQLPDOTest::getDSN(array('charset' => 'latin2')); - $db = new PDO($dsn, $user, $pass); - $stmt = $db->query('SELECT @@character_set_connection AS _charset'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - if ($tmp['_charset'] != 'latin2') - printf("[033] DSN = %s, character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", - $dsn, $tmp['_charset'], 'latin2'); - - } catch (PDOException $e) { - printf("[034] %s\n", $e->getMessage()); - } - - } - } - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + function tryandcatch($offset, $code) { + + try { + eval($code); + assert(sprintf("[%03d] Should have failed\n", $offset) != ''); + } catch (PDOException $e) { + return sprintf("[%03d] %s, [%s] %s\n", + $offset, + $e->getMessage(), + (isset($db) && is_object($db)) ? $db->errorCode() : 'n/a', + (isset($db) && is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } + + return ''; + } + + try { + + try { + if (NULL !== ($db = @new PDO())) + printf("[001] Too few parameters\n"); + } catch (TypeError $ex) { + } + + print tryandcatch(2, '$db = new PDO(chr(0));'); + print tryandcatch(3, '$db = new PDO("a" . chr(0) . "b");'); + print tryandcatch(4, '$db = new PDO("MYSQL");'); + print tryandcatch(5, '$db = new PDO("mysql");'); + print tryandcatch(6, '$db = new PDO("mysql ");'); + print tryandcatch(7, '$db = new PDO("fantasyandfriends :");'); + + $dsn = PDO_MYSQL_TEST_DSN; + // MySQL Server might accept anonymous connections, don't + // print anything + tryandcatch(8, '$db = new PDO("' . $dsn . '");'); + + $user = 'dontcreatesuchauser'; + $pass = 'withthispassword'; + print tryandcatch(9, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); + + // should fail + $dsn = 'mysql:'; + // don't print the message since it can be different + tryandcatch(10, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); + + $dsn = PDO_MYSQL_TEST_DSN; + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + // should work... + $db = new PDO($dsn, $user, $pass); + + // Reaction on host not specified differs for different configs, so no printing + $dsn = 'mysql:invalid=foo'; + tryandcatch(11, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); + + $dsn = 'mysql:' . str_repeat('howmuch=canpdoeat;', 1000); + tryandcatch(12, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); + + $dsn = 'mysql:' . str_repeat('abcdefghij', 1024 * 10) . '=somevalue'; + tryandcatch(13, '$db = new PDO("' . $dsn . '", "' . $user . '", "' . $pass . '");'); + + if (PDO_MYSQL_TEST_HOST) { + $host = PDO_MYSQL_TEST_HOST; + $invalid_host = $host . 'invalid'; + + // last host specification should be the one used + $dsn = MySQLPDOTest::getDSN(array('host' => $host), 'host=' . $invalid_host); + try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { + $tmp = $e->getMessage(); + if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002')) + printf("[014] Cannot find proper error codes: %s\n", $tmp); + } + + $dsn = MySQLPDOTest::getDSN(array('host' => $invalid_host), 'host=' . $host); + try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { + printf("[015] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + + $invalid_host = '-' . chr(0); + + $dsn = MySQLPDOTest::getDSN(array('host' => $invalid_host)); + try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { + $tmp = $e->getMessage(); + if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002')) + printf("[016] Cannot find proper error codes: %s\n", $tmp); + } + + // parsing should not get confused by chr(0) + $dsn = MySQLPDOTest::getDSN(array('host' => $invalid_host), 'host=' . $host); + try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { + printf("[017] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + + } + + // what about long values for a valid option ... + // hostnames > 1024 chars break on some NIS-enabled FreeBSD... + $dsn = MySQLPDOTest::getDSN(array('host' => str_repeat('0123456789', 100))); + try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { + $tmp = $e->getMessage(); + if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005') && !stristr($tmp, '2002')) + printf("[018] Cannot find proper error codes: %s\n", $tmp); + } + + if (PDO_MYSQL_TEST_PORT && (PDO_MYSQL_TEST_SOCKET == '')) { + // Playing with the port makes only sense if no socket gets used + + $port = PDO_MYSQL_TEST_PORT; + // let's hope we don't hit a MySQL running on that port... + $invalid_port = $port * 2; + + $dsn = MySQLPDOTest::getDSN(array('port' => $port), 'port=' . $invalid_port); + try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { + $tmp = $e->getMessage(); + if (!stristr($tmp, 'HY000') && !stristr($tmp, '2005')) + printf("[019] Cannot find proper error codes: %s\n", $tmp); + } + + $dsn = MySQLPDOTest::getDSN(array('port' => $invalid_port), 'port=' . $port); + try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { + printf("[020] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + + $invalid_port = 'abc'; + $dsn = MySQLPDOTest::getDSN(array('port' => $port), 'port=' . $invalid_port); + try { + $db = @new PDO($dsn, $user, $pass); + // atoi('abc') = 0, 0 -> fallback to default 3306 -> may or may not fail! + } catch (PDOException $e) { + } + + } + + if (PDO_MYSQL_TEST_DB) { + $db = PDO_MYSQL_TEST_DB; + $invalid_db = 'letshopeitdoesnotexist'; + + $dsn = MySQLPDOTest::getDSN(array('dbname' => $db), 'dbname=' . $invalid_db); + try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { + $tmp = $e->getMessage(); + if (!stristr($tmp, '42000') && !stristr($tmp, '1049')) + printf("[022] Cannot find proper error codes: %s\n", $tmp); + } + + $dsn = MySQLPDOTest::getDSN(array('dbname' => $invalid_db), 'dbname=' . $db); + try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { + printf("[023] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + + } + + if (PDO_MYSQL_TEST_SOCKET && (stristr(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_SOCKET) !== false)) { + $socket = PDO_MYSQL_TEST_SOCKET; + $invalid_socket = '/lets/hope/it/does/not/exist'; + + $dsn = MySQLPDOTest::getDSN(array('unix_socket' => $socket), 'unix_socket=' . $invalid_socket); + try { $db = @new PDO($dsn, $user, $pass); assert(false); printf("%s\n", $dsn); } catch (PDOException $e) { + $tmp = $e->getMessage(); + if (!stristr($tmp, 'HY000') && !stristr($tmp, '2002')) + printf("[024] Cannot find proper error codes: %s\n", $tmp); + } + + $dsn = MySQLPDOTest::getDSN(array('unix_socket' => $invalid_socket), 'unix_socket=' . $socket); + try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) { + printf("[025] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + + } + + $have_charset_support = false; + $dsn = MySQLPDOTest::getDSN(); + try { + $db = new PDO($dsn, $user, $pass); + $stmt = $db->query('SELECT VERSION() as _version'); + $version = $stmt->fetch(PDO::FETCH_ASSOC); + + $tmp = explode('.', $version['_version']); + if ((count($tmp) == 3) && + (($tmp[0] >= 4 && $tmp[1] >= 1) || ($tmp[0] >= 5))) { + // MySQL Server 4.1 - charset support available + $have_charset_support = true; + } + + } catch (PDOException $e) { + printf("[026] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + + if (PDO_MYSQL_TEST_CHARSET) { + $charset = PDO_MYSQL_TEST_CHARSET; + $invalid_charset = 'invalid'; + + if ($have_charset_support) { + $dsn = MySQLPDOTest::getDSN(); + $db = new PDO($dsn, $user, $pass); + $stmt = $db->query(sprintf('SHOW CHARACTER SET LIKE "%s"', $charset)); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $have_charset = (empty($tmp)) ? false : true; + + if ($have_charset) { + $dsn = MySQLPDOTest::getDSN(array('charset' => $charset), 'charset=' . $invalid_charset); + try { + $db = @new PDO($dsn, $user, $pass); + /* NOTE: MySQL does a fallback to the charset suggested during the handshake - no error - no bug! */ + } catch (PDOException $e) { + $tmp = $e->getMessage(); + /* TODO: add proper codes */ + if (!stristr($tmp, 'sqlstatecode') || !stristr($tmp, 'mysqlinternalerrcode')) + printf("[027] TODO - Cannot find proper error codes: %s\n", $tmp); + } + + $dsn = MySQLPDOTest::getDSN(array('charset' => $invalid_charset), 'charset=' . $charset); + try { + $db = @new PDO($dsn, $user, $pass); + /* Strictly speaking we should test more: character_set_client, character_set_results, and character_set_connection */ + $stmt = $db->query('SELECT @@character_set_connection AS _charset'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + if ($tmp['_charset'] != $charset) + printf("[028] Character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", + $tmp['_charset'], $charset); + } catch (PDOException $e) { + printf("[029] DSN=%s, %s\n", $dsn, $e->getMessage()); + } + } else { + printf("[030] You're trying to run the tests with charset '%s' which seems not supported by the server!", $charset); + } + + } + + } + + if ($have_charset_support) { + // In case the PDO_MYSQL_TEST_CHARSET interferes with any defaults + // we do another test to verify that the charset has been set. + $dsn = MySQLPDOTest::getDSN(); + $db = new PDO($dsn, $user, $pass); + $stmt = $db->query('SHOW CHARACTER SET LIKE "latin1"'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $have_latin1 =(empty($tmp)) ? false : true; + $stmt = $db->query('SHOW CHARACTER SET LIKE "latin2"'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $have_latin2 =(empty($tmp)) ? false : true; + + if ($have_latin1 && $have_latin2) { + // very likely we do have both of them... + try { + $dsn = MySQLPDOTest::getDSN(array('charset' => 'latin1')); + $db = new PDO($dsn, $user, $pass); + $stmt = $db->query('SELECT @@character_set_connection AS _charset'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + if ($tmp['_charset'] != 'latin1') + printf("[031] DSN = %s, Character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", + $dsn, $tmp['_charset'], 'latin1'); + + } catch (PDOException $e) { + printf("[032] %s\n", $e->getMessage()); + } + + try { + $dsn = MySQLPDOTest::getDSN(array('charset' => 'latin2')); + $db = new PDO($dsn, $user, $pass); + $stmt = $db->query('SELECT @@character_set_connection AS _charset'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + if ($tmp['_charset'] != 'latin2') + printf("[033] DSN = %s, character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", + $dsn, $tmp['_charset'], 'latin2'); + + } catch (PDOException $e) { + printf("[034] %s\n", $e->getMessage()); + } + + } + } + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + (is_object($db)) ? $db->errorCode() : 'n/a', + (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } + + print "done!"; ?> --EXPECTF-- [002] invalid data source name, [n/a] n/a diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt index a03ad7f3246d..985179b84c54 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_ini.phpt @@ -13,43 +13,43 @@ if (getenv('PDO_MYSQL_TEST_DSN') !== "mysql:dbname=phptest;unix_socket=/tmp/mysq pdo.dsn.mysql="mysql:dbname=phptest;socket=/tmp/mysql.sock" --FILE-- $dsn) - if ('pdo.dsn.mysql' == $name) { - printf("pdo.dsn.mysql=%s\n", $dsn); - $found = true; - break; - } - - if (!$found) { - $dsn = ini_get('pdo.dsn.mysql'); - $found = ($dsn !== false); - } - - if (!$found) - printf("pdo.dsn.mysql cannot be accessed through ini_get_all()/ini_get()\n"); - - if (MySQLPDOTest::getDSN() == $dsn) { - // we are lucky, we can run the test - try { - - $user = PDO_MYSQL_TEST_USER; - $pass = PDO_MYSQL_TEST_PASS; - $db = new PDO('mysql', $user, $pass); - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } - - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + $found = false; + $values = ini_get_all(); + foreach ($values as $name => $dsn) + if ('pdo.dsn.mysql' == $name) { + printf("pdo.dsn.mysql=%s\n", $dsn); + $found = true; + break; + } + + if (!$found) { + $dsn = ini_get('pdo.dsn.mysql'); + $found = ($dsn !== false); + } + + if (!$found) + printf("pdo.dsn.mysql cannot be accessed through ini_get_all()/ini_get()\n"); + + if (MySQLPDOTest::getDSN() == $dsn) { + // we are lucky, we can run the test + try { + + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + $db = new PDO('mysql', $user, $pass); + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + (is_object($db)) ? $db->errorCode() : 'n/a', + (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } + + } + + print "done!"; ?> --EXPECT-- pdo.dsn.mysql cannot be accessed through ini_get_all()/ini_get() diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt index b7a52127c52b..ac5f7f6911f3 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt @@ -8,160 +8,160 @@ MySQLPDOTest::skip(); ?> --FILE-- $value)); - if (!is_object($db) || ($value !== ($tmp = @$db->getAttribute($option)))) - printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n", - $offset, - $value, gettype($value), - $tmp, gettype($tmp), - $option_desc); - } catch (PDOException $e) { - printf("[%03d] %s\n", $offset, $e->getMessage()); - } - - } - - try { - - $dsn = MySQLPDOTest::getDSN(); - $user = PDO_MYSQL_TEST_USER; - $pass = PDO_MYSQL_TEST_PASS; - - $valid_options = array( - /* pdo_dbh.c */ - PDO::ATTR_PERSISTENT => 'PDO::ATTR_PERSISTENT', - PDO::ATTR_AUTOCOMMIT => 'PDO::ATTR_AUTOCOMMIT', - /* mysql_driver.c */ - /* TODO Possible bug PDO::ATTR_TIMEOUT != MYSQLI_OPT_CONNECT_TIMEOUT*/ - PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT', - PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', - - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY', - PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE', - PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY', - - PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND', - PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', - ); - - $defaults = array( - PDO::ATTR_PERSISTENT => false, - PDO::ATTR_AUTOCOMMIT => 1, - /* TODO - why is this a valid option if getAttribute() does not support it?! */ - PDO::ATTR_TIMEOUT => false, - PDO::ATTR_EMULATE_PREPARES => 1, - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 1, - /* TODO getAttribute() does not handle it */ - PDO::MYSQL_ATTR_LOCAL_INFILE => false, - /* TODO getAttribute() does not handle it */ - PDO::MYSQL_ATTR_DIRECT_QUERY => 1, - PDO::MYSQL_ATTR_INIT_COMMAND => '', - ); - - try { - if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type'))) - printf("[001] Expecting NULL got %s/%s\n", gettype($db), $db); - } catch (TypeError $e) { - } - - if (!is_object($db = new PDO($dsn, $user, $pass, array()))) - printf("[002] Expecting object got %s/%s¸\n", gettype($db), $db); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + function set_option_and_check($offset, $option, $value, $option_desc) { + + $dsn = MySQLPDOTest::getDSN(); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + + try { + $db = new PDO($dsn, $user, $pass, array($option => $value)); + if (!is_object($db) || ($value !== ($tmp = @$db->getAttribute($option)))) + printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n", + $offset, + $value, gettype($value), + $tmp, gettype($tmp), + $option_desc); + } catch (PDOException $e) { + printf("[%03d] %s\n", $offset, $e->getMessage()); + } + + } + + try { + + $dsn = MySQLPDOTest::getDSN(); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + + $valid_options = array( + /* pdo_dbh.c */ + PDO::ATTR_PERSISTENT => 'PDO::ATTR_PERSISTENT', + PDO::ATTR_AUTOCOMMIT => 'PDO::ATTR_AUTOCOMMIT', + /* mysql_driver.c */ + /* TODO Possible bug PDO::ATTR_TIMEOUT != MYSQLI_OPT_CONNECT_TIMEOUT*/ + PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT', + PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', + + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY', + PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE', + PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY', + + PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND', + PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES', + ); + + $defaults = array( + PDO::ATTR_PERSISTENT => false, + PDO::ATTR_AUTOCOMMIT => 1, + /* TODO - why is this a valid option if getAttribute() does not support it?! */ + PDO::ATTR_TIMEOUT => false, + PDO::ATTR_EMULATE_PREPARES => 1, + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 1, + /* TODO getAttribute() does not handle it */ + PDO::MYSQL_ATTR_LOCAL_INFILE => false, + /* TODO getAttribute() does not handle it */ + PDO::MYSQL_ATTR_DIRECT_QUERY => 1, + PDO::MYSQL_ATTR_INIT_COMMAND => '', + ); + + try { + if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type'))) + printf("[001] Expecting NULL got %s/%s\n", gettype($db), $db); + } catch (TypeError $e) { + } + + if (!is_object($db = new PDO($dsn, $user, $pass, array()))) + printf("[002] Expecting object got %s/%s¸\n", gettype($db), $db); $invalid = 999; - if (is_object($db = new PDO($dsn, $user, $pass, array($invalid => true)))) - printf("[003] [TODO][CHANGEREQUEST] Please, lets not ignore invalid options and bail out!\n"); - - $db = new PDO($dsn, $user, $pass); - foreach ($valid_options as $option => $name) { - /* TODO getAttribute() is pretty poor in supporting the options, suppress errors */ - $tmp = @$db->getAttribute($option); - if ($tmp !== $defaults[$option]) - printf("[003a] Expecting default value for '%s' of '%s'/%s, getAttribute() reports setting '%s'/%s\n", - $name, $defaults[$option], gettype($defaults[$option]), - $tmp, gettype($tmp)); - } - - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_AUTOCOMMIT => true)); - if (!is_object($db) || !$db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[004] Autocommit should be on\n"); - - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_AUTOCOMMIT => false)); - if (!is_object($db) || $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[005] Autocommit should be off\n"); - - /* TODO: no way to check ATTR_TIMEOUT settings */ - if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => 10)))) - printf("[006] ATTR_TIMEOUT should be accepted\n"); - - if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => PHP_INT_MAX)))) - printf("[007] ATTR_TIMEOUT should be accepted\n"); - - if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => -PHP_INT_MAX)))) - printf("[008] ATTR_TIMEOUT should be accepted\n"); - - /* TODO: Its ugly that PDO::ATTR_EMULATE_PREPARES == PDO::MYSQL_ATTR_DIRECT_QUERY */ - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true)); - if (!is_object($db)) - printf("[009] ATTR_EMULATE_PREPARES should be accepted and on\n"); - if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) - printf("[010] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be on\n"); - if (!$db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[011] As PDO::MYSQL_ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES - and PDO::ATTR_EMULATE_PREPARES overrules the other, PDO::MYSQL_ATTR_DIRECT_QUERY should be on\n"); - - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false)); - if (!is_object($db)) - printf("[012] ATTR_EMULATE_PREPARES should be accepted and on\n"); - if ($db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) - printf("[013] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be off\n"); - if ($db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[014] As PDO::MYSQL_ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES - and PDO::ATTR_EMULATE_PREPARES overrules the other, PDO::MYSQL_ATTR_DIRECT_QUERY should be off\n"); - - // PDO::ATTR_EMULATE_PREPARES overrules PDO::MYSQL_ATTR_DIRECT_QUERY - // TODO: is it clever that a generic setting overrules a specific setting? - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true, PDO::MYSQL_ATTR_DIRECT_QUERY => false)); - if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) - printf("[015] PDO::ATTR_EMULATE_PREPARES should be on\n"); - if (!$db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[016] PDO::MYSQL_ATTR_DIRECT_QUERY should be on\n"); - - $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_DIRECT_QUERY => true)); - if ($db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) - printf("[017] PDO::ATTR_EMULATE_PREPARES should be off\n"); - if ($db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[018] PDO::MYSQL_ATTR_DIRECT_QUERY should be off\n"); - - set_option_and_check(19, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1, 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY'); - set_option_and_check(20, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0, 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY'); - - set_option_and_check(21, PDO::MYSQL_ATTR_LOCAL_INFILE, true, 'PDO::MYSQL_ATTR_LOCAL_INFILE'); - set_option_and_check(22, PDO::MYSQL_ATTR_LOCAL_INFILE, false, 'PDO::MYSQL_ATTR_LOCAL_INFILE'); - - set_option_and_check(23, PDO::MYSQL_ATTR_INIT_COMMAND, 'SET @a=1', 'PDO::MYSQL_ATTR_INIT_COMMAND'); - set_option_and_check(24, PDO::MYSQL_ATTR_INIT_COMMAND, '', 'PDO::MYSQL_ATTR_INIT_COMMAND'); - set_option_and_check(25, PDO::MYSQL_ATTR_INIT_COMMAND, 'INSERT INTO nonexistent(invalid) VALUES (1)', 'PDO::MYSQL_ATTR_INIT_COMMAND'); - - set_option_and_check(33, PDO::MYSQL_ATTR_DIRECT_QUERY, 1, 'PDO::MYSQL_ATTR_DIRECT_QUERY'); - set_option_and_check(34, PDO::MYSQL_ATTR_DIRECT_QUERY, 0, 'PDO::MYSQL_ATTR_DIRECT_QUERY'); - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } - - print "done!"; + if (is_object($db = new PDO($dsn, $user, $pass, array($invalid => true)))) + printf("[003] [TODO][CHANGEREQUEST] Please, lets not ignore invalid options and bail out!\n"); + + $db = new PDO($dsn, $user, $pass); + foreach ($valid_options as $option => $name) { + /* TODO getAttribute() is pretty poor in supporting the options, suppress errors */ + $tmp = @$db->getAttribute($option); + if ($tmp !== $defaults[$option]) + printf("[003a] Expecting default value for '%s' of '%s'/%s, getAttribute() reports setting '%s'/%s\n", + $name, $defaults[$option], gettype($defaults[$option]), + $tmp, gettype($tmp)); + } + + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_AUTOCOMMIT => true)); + if (!is_object($db) || !$db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[004] Autocommit should be on\n"); + + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_AUTOCOMMIT => false)); + if (!is_object($db) || $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[005] Autocommit should be off\n"); + + /* TODO: no way to check ATTR_TIMEOUT settings */ + if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => 10)))) + printf("[006] ATTR_TIMEOUT should be accepted\n"); + + if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => PHP_INT_MAX)))) + printf("[007] ATTR_TIMEOUT should be accepted\n"); + + if (!is_object($db = new PDO($dsn, $user, $pass, array(PDO::ATTR_TIMEOUT => -PHP_INT_MAX)))) + printf("[008] ATTR_TIMEOUT should be accepted\n"); + + /* TODO: Its ugly that PDO::ATTR_EMULATE_PREPARES == PDO::MYSQL_ATTR_DIRECT_QUERY */ + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true)); + if (!is_object($db)) + printf("[009] ATTR_EMULATE_PREPARES should be accepted and on\n"); + if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) + printf("[010] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be on\n"); + if (!$db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[011] As PDO::MYSQL_ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES + and PDO::ATTR_EMULATE_PREPARES overrules the other, PDO::MYSQL_ATTR_DIRECT_QUERY should be on\n"); + + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false)); + if (!is_object($db)) + printf("[012] ATTR_EMULATE_PREPARES should be accepted and on\n"); + if ($db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) + printf("[013] [TODO][CHANGEREQUEST] ATTR_EMULATE_PREPARES should be off\n"); + if ($db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[014] As PDO::MYSQL_ATTR_DIRECT_QUERY == PDO::ATTR_EMULATE_PREPARES + and PDO::ATTR_EMULATE_PREPARES overrules the other, PDO::MYSQL_ATTR_DIRECT_QUERY should be off\n"); + + // PDO::ATTR_EMULATE_PREPARES overrules PDO::MYSQL_ATTR_DIRECT_QUERY + // TODO: is it clever that a generic setting overrules a specific setting? + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => true, PDO::MYSQL_ATTR_DIRECT_QUERY => false)); + if (!$db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) + printf("[015] PDO::ATTR_EMULATE_PREPARES should be on\n"); + if (!$db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[016] PDO::MYSQL_ATTR_DIRECT_QUERY should be on\n"); + + $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_DIRECT_QUERY => true)); + if ($db->getAttribute(PDO::ATTR_EMULATE_PREPARES)) + printf("[017] PDO::ATTR_EMULATE_PREPARES should be off\n"); + if ($db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[018] PDO::MYSQL_ATTR_DIRECT_QUERY should be off\n"); + + set_option_and_check(19, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1, 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY'); + set_option_and_check(20, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0, 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY'); + + set_option_and_check(21, PDO::MYSQL_ATTR_LOCAL_INFILE, true, 'PDO::MYSQL_ATTR_LOCAL_INFILE'); + set_option_and_check(22, PDO::MYSQL_ATTR_LOCAL_INFILE, false, 'PDO::MYSQL_ATTR_LOCAL_INFILE'); + + set_option_and_check(23, PDO::MYSQL_ATTR_INIT_COMMAND, 'SET @a=1', 'PDO::MYSQL_ATTR_INIT_COMMAND'); + set_option_and_check(24, PDO::MYSQL_ATTR_INIT_COMMAND, '', 'PDO::MYSQL_ATTR_INIT_COMMAND'); + set_option_and_check(25, PDO::MYSQL_ATTR_INIT_COMMAND, 'INSERT INTO nonexistent(invalid) VALUES (1)', 'PDO::MYSQL_ATTR_INIT_COMMAND'); + + set_option_and_check(33, PDO::MYSQL_ATTR_DIRECT_QUERY, 1, 'PDO::MYSQL_ATTR_DIRECT_QUERY'); + set_option_and_check(34, PDO::MYSQL_ATTR_DIRECT_QUERY, 0, 'PDO::MYSQL_ATTR_DIRECT_QUERY'); + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + (is_object($db)) ? $db->errorCode() : 'n/a', + (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } + + print "done!"; ?> --EXPECTF-- [003] [TODO][CHANGEREQUEST] Please, lets not ignore invalid options and bail out! diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt index 3d7e1d4396e0..99754c905830 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options_libmysql.phpt @@ -10,72 +10,72 @@ if (MySQLPDOTest::isPDOMySQLnd()) ?> --FILE-- $value)); - if (!is_object($db) || (!$ignore_diff && ($value !== ($tmp = @$db->getAttribute($option))))) - printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n", - $offset, - $value, gettype($value), - $tmp, gettype($tmp), - $option_desc); - } catch (PDOException $e) { - printf("[%03d] %s\n", $offset, $e->getMessage()); - } + try { + $db = new PDO($dsn, $user, $pass, array($option => $value)); + if (!is_object($db) || (!$ignore_diff && ($value !== ($tmp = @$db->getAttribute($option))))) + printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n", + $offset, + $value, gettype($value), + $tmp, gettype($tmp), + $option_desc); + } catch (PDOException $e) { + printf("[%03d] %s\n", $offset, $e->getMessage()); + } - } + } - try { + try { - $dsn = MySQLPDOTest::getDSN(); - $user = PDO_MYSQL_TEST_USER; - $pass = PDO_MYSQL_TEST_PASS; + $dsn = MySQLPDOTest::getDSN(); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; - $valid_options = array(); - $valid_options[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'; - $valid_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'PDO::MYSQL_ATTR_INIT_COMMAND'; - $valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'; - $valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_GROUP] = 'PDO::MYSQL_ATTR_READ_DEFAULT_GROUP'; + $valid_options = array(); + $valid_options[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'; + $valid_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'PDO::MYSQL_ATTR_INIT_COMMAND'; + $valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'; + $valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_GROUP] = 'PDO::MYSQL_ATTR_READ_DEFAULT_GROUP'; - $defaults[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 1048576; - /* TODO getAttribute() does not handle it */ - $defaults[PDO::MYSQL_ATTR_INIT_COMMAND] = ''; - $defaults[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = false; - $defaults[PDO::MYSQL_ATTR_READ_DEFAULT_GROUP] = false; + $defaults[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 1048576; + /* TODO getAttribute() does not handle it */ + $defaults[PDO::MYSQL_ATTR_INIT_COMMAND] = ''; + $defaults[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = false; + $defaults[PDO::MYSQL_ATTR_READ_DEFAULT_GROUP] = false; - $db = new PDO($dsn, $user, $pass); - foreach ($valid_options as $option => $name) { - /* TODO getAttribute() is pretty poor in supporting the options, suppress errors */ - $tmp = @$db->getAttribute($option); - if ($tmp !== $defaults[$option]) - printf("[001] Expecting default value for '%s' of '%s'/%s, getAttribute() reports setting '%s'/%s\n", - $name, $defaults[$option], gettype($defaults[$option]), - $tmp, gettype($tmp)); - } + $db = new PDO($dsn, $user, $pass); + foreach ($valid_options as $option => $name) { + /* TODO getAttribute() is pretty poor in supporting the options, suppress errors */ + $tmp = @$db->getAttribute($option); + if ($tmp !== $defaults[$option]) + printf("[001] Expecting default value for '%s' of '%s'/%s, getAttribute() reports setting '%s'/%s\n", + $name, $defaults[$option], gettype($defaults[$option]), + $tmp, gettype($tmp)); + } - set_option_and_check(26, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, true, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'); - set_option_and_check(27, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, false, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'); + set_option_and_check(26, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, true, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'); + set_option_and_check(27, PDO::MYSQL_ATTR_READ_DEFAULT_FILE, false, 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE'); - set_option_and_check(30, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, -1, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE', true); - set_option_and_check(31, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, PHP_INT_MAX, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'); - set_option_and_check(32, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'); + set_option_and_check(30, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, -1, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE', true); + set_option_and_check(31, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, PHP_INT_MAX, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'); + set_option_and_check(32, PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1, 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE'); - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + (is_object($db)) ? $db->errorCode() : 'n/a', + (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } - print "done!"; + print "done!"; ?> --EXPECT-- [001] Expecting default value for 'PDO::MYSQL_ATTR_INIT_COMMAND' of ''/string, getAttribute() reports setting ''/boolean diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt index 7418033768a0..8d51961c9d4c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt @@ -8,68 +8,68 @@ MySQLPDOTest::skip(); ?> --FILE-- getMessage()); - } - unlink($file); - } + if ($fp = @fopen($file, 'w')) { + // ok, great we can create a file with a DSN in it + fwrite($fp, $dsn); + fclose($fp); + clearstatcache(); + assert(file_exists($file)); + try { + $db = new PDO($uri, $user, $pass); + } catch (PDOException $e) { + printf("[002] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), %s\n", + $uri, $dsn, + $file, filesize($file), file_get_contents($file), + $e->getMessage()); + } + unlink($file); + } - if ($fp = @fopen($file, 'w')) { - fwrite($fp, sprintf('mysql:dbname=letshopeinvalid;%s%s', - chr(0), $dsn)); - fclose($fp); - clearstatcache(); - assert(file_exists($file)); - try { - $db = new PDO($uri, $user, $pass); - } catch (PDOException $e) { - $expected = array( - "SQLSTATE[HY000] [1049] Unknown database 'letshopeinvalid'", - "SQLSTATE[HY000] [2002] No such file or directory" - ); - printf("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), chr(0) test, %s\n", - $uri, $dsn, - $file, filesize($file), file_get_contents($file), - (in_array($e->getMessage(), $expected) ? 'EXPECTED ERROR' : $e->getMessage())); - } - unlink($file); - } + if ($fp = @fopen($file, 'w')) { + fwrite($fp, sprintf('mysql:dbname=letshopeinvalid;%s%s', + chr(0), $dsn)); + fclose($fp); + clearstatcache(); + assert(file_exists($file)); + try { + $db = new PDO($uri, $user, $pass); + } catch (PDOException $e) { + $expected = array( + "SQLSTATE[HY000] [1049] Unknown database 'letshopeinvalid'", + "SQLSTATE[HY000] [2002] No such file or directory" + ); + printf("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), chr(0) test, %s\n", + $uri, $dsn, + $file, filesize($file), file_get_contents($file), + (in_array($e->getMessage(), $expected) ? 'EXPECTED ERROR' : $e->getMessage())); + } + unlink($file); + } - } + } - /* TODO: safe mode */ + /* TODO: safe mode */ - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + (is_object($db)) ? $db->errorCode() : 'n/a', + (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } - print "done!"; + print "done!"; ?> --EXPECTF-- [003] URI=uri:file://%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=letshopeinvalid%s'), chr(0) test, EXPECTED ERROR diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt index 361750260b34..0dd8663d08fa 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt @@ -9,85 +9,85 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- getAttribute(PDO::ATTR_AUTOCOMMIT))) - printf("[001] Expecting int/1 got %s\n", var_export($tmp, true)); + // autocommit should be on by default + if (1 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) + printf("[001] Expecting int/1 got %s\n", var_export($tmp, true)); - // lets see if the server agrees to that - $row = $db->query('SELECT @@autocommit AS _autocommit')->fetch(PDO::FETCH_ASSOC); - if (!$row['_autocommit']) - printf("[002] Server autocommit mode should be on, got '%s'\n", var_export($row['_autocommit'])); + // lets see if the server agrees to that + $row = $db->query('SELECT @@autocommit AS _autocommit')->fetch(PDO::FETCH_ASSOC); + if (!$row['_autocommit']) + printf("[002] Server autocommit mode should be on, got '%s'\n", var_export($row['_autocommit'])); - // on -> off - if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0)) - printf("[003] Cannot turn off autocommit\n"); + // on -> off + if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0)) + printf("[003] Cannot turn off autocommit\n"); - $row = $db->query('SELECT @@autocommit AS _autocommit')->fetch(PDO::FETCH_ASSOC); - if ($row['_autocommit']) - printf("[004] Server autocommit mode should be off, got '%s'\n", var_export($row['_autocommit'])); + $row = $db->query('SELECT @@autocommit AS _autocommit')->fetch(PDO::FETCH_ASSOC); + if ($row['_autocommit']) + printf("[004] Server autocommit mode should be off, got '%s'\n", var_export($row['_autocommit'])); - // PDO thinks autocommit is off, but its manually turned on... - if (!$db->query('SET autocommit = 1')) - printf("[005] Cannot turn on server autocommit mode, %s\n", var_export($db->errorInfo(), true)); + // PDO thinks autocommit is off, but its manually turned on... + if (!$db->query('SET autocommit = 1')) + printf("[005] Cannot turn on server autocommit mode, %s\n", var_export($db->errorInfo(), true)); - if (0 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) - printf("[006] Expecting int/0 got %s\n", var_export($tmp, true)); + if (0 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) + printf("[006] Expecting int/0 got %s\n", var_export($tmp, true)); - // off -> on - if (!$db->query('SET autocommit = 0')) - printf("[007] Cannot turn off server autocommit mode, %s\n", var_export($db->errorInfo(), true)); + // off -> on + if (!$db->query('SET autocommit = 0')) + printf("[007] Cannot turn off server autocommit mode, %s\n", var_export($db->errorInfo(), true)); - if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1)) - printf("[008] Cannot turn on autocommit\n"); + if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1)) + printf("[008] Cannot turn on autocommit\n"); - $row = $db->query('SELECT @@autocommit AS _autocommit')->fetch(PDO::FETCH_ASSOC); - if (!$row['_autocommit']) - printf("[009] Server autocommit mode should be on, got '%s'\n", var_export($row['_autocommit'])); + $row = $db->query('SELECT @@autocommit AS _autocommit')->fetch(PDO::FETCH_ASSOC); + if (!$row['_autocommit']) + printf("[009] Server autocommit mode should be on, got '%s'\n", var_export($row['_autocommit'])); - if (1 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) - printf("[010] Expecting int/1 got %s\n", var_export($tmp, true)); + if (1 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) + printf("[010] Expecting int/1 got %s\n", var_export($tmp, true)); - if (MySQLPDOTest::detect_transactional_mysql_engine($db)) { - // nice, we have a transactional engine to play with + if (MySQLPDOTest::detect_transactional_mysql_engine($db)) { + // nice, we have a transactional engine to play with - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - $num = $row['_num']; + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $num = $row['_num']; - $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); - $num++; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[011] Insert has failed, test will fail\n"); + $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); + $num++; + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[011] Insert has failed, test will fail\n"); - // autocommit is on, no rollback possible - $db->query('ROLLBACK'); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[012] ROLLBACK should not have undone anything\n"); + // autocommit is on, no rollback possible + $db->query('ROLLBACK'); + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[012] ROLLBACK should not have undone anything\n"); - if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0)) - printf("[013] Cannot turn off autocommit\n"); + if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0)) + printf("[013] Cannot turn off autocommit\n"); - $db->query('DELETE FROM test WHERE id = 100'); - $db->query('ROLLBACK'); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[014] ROLLBACK should have undone the DELETE\n"); + $db->query('DELETE FROM test WHERE id = 100'); + $db->query('ROLLBACK'); + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[014] ROLLBACK should have undone the DELETE\n"); - $db->query('DELETE FROM test WHERE id = 100'); - $db->query('COMMIT'); - $num--; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[015] DELETE should have been committed\n"); + $db->query('DELETE FROM test WHERE id = 100'); + $db->query('COMMIT'); + $num--; + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[015] DELETE should have been committed\n"); - } + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- getAttribute(PDO::ATTR_CASE); - $known = array( - PDO::CASE_LOWER => 'PDO::CASE_LOWER', - PDO::CASE_UPPER => 'PDO::CASE_UPPER', - PDO::CASE_NATURAL => 'PDO::CASE_NATURAL' - ); - if (!isset($known[$default])) - printf("[001] getAttribute(PDO::ATTR_CASE) returns unknown value '%s'\n", - var_export($default, true)); - else - var_dump($known[$default]); + $default = $db->getAttribute(PDO::ATTR_CASE); + $known = array( + PDO::CASE_LOWER => 'PDO::CASE_LOWER', + PDO::CASE_UPPER => 'PDO::CASE_UPPER', + PDO::CASE_NATURAL => 'PDO::CASE_NATURAL' + ); + if (!isset($known[$default])) + printf("[001] getAttribute(PDO::ATTR_CASE) returns unknown value '%s'\n", + var_export($default, true)); + else + var_dump($known[$default]); - // lets see what the default is... - if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM test ORDER BY id ASC LIMIT 2"))) - printf("[002] %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + // lets see what the default is... + if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM test ORDER BY id ASC LIMIT 2"))) + printf("[002] %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); + var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); - if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER)) - printf("[003] Cannot set PDO::ATTR_CASE = PDO::CASE_LOWER, %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER)) + printf("[003] Cannot set PDO::ATTR_CASE = PDO::CASE_LOWER, %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_LOWER) - printf("[004] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", - var_export($tmp, true)); + if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_LOWER) + printf("[004] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", + var_export($tmp, true)); - if (true === $db->exec('ALTER TABLE test ADD MiXeD CHAR(1)')) - printf("[005] Cannot add column %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (true === $db->exec('ALTER TABLE test ADD MiXeD CHAR(1)')) + printf("[005] Cannot add column %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (false === $db->exec('ALTER TABLE test ADD MYUPPER CHAR(1)')) - printf("[006] Cannot add column %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (false === $db->exec('ALTER TABLE test ADD MYUPPER CHAR(1)')) + printf("[006] Cannot add column %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2"))) - printf("[007] %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2"))) + printf("[007] %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); + var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); - if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER)) - printf("[008] Cannot set PDO::ATTR_CASE = PDO::CASE_UPPER %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER)) + printf("[008] Cannot set PDO::ATTR_CASE = PDO::CASE_UPPER %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_UPPER) - printf("[009] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", - var_export($tmp, true)); + if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_UPPER) + printf("[009] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", + var_export($tmp, true)); - if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM test ORDER BY id ASC LIMIT 1"))) - printf("[010] %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM test ORDER BY id ASC LIMIT 1"))) + printf("[010] %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); + var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); - if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL)) - printf("[011] Cannot set PDO::ATTR_CASE = PDO::CASE_NATURAL %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL)) + printf("[011] Cannot set PDO::ATTR_CASE = PDO::CASE_NATURAL %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_NATURAL) - printf("[012] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", - var_export($tmp, true)); + if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_NATURAL) + printf("[012] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n", + var_export($tmp, true)); - if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM test ORDER BY id ASC LIMIT 1"))) - printf("[013] %s - %s\n", - var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); + if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM test ORDER BY id ASC LIMIT 1"))) + printf("[013] %s - %s\n", + var_export($db->errorInfo(), true), var_export($db->errorCode(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); + var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- errorCode()) || ('00000' == $db->errorCode())); + assert(('' == $db->errorCode()) || ('00000' == $db->errorCode())); - $version = $db->getAttribute(PDO::ATTR_CLIENT_VERSION); + $version = $db->getAttribute(PDO::ATTR_CLIENT_VERSION); - // No more constraints - mysqlnd and libmysql return different strings at least - // with mysqli. Return type check is already performed in the generic test. - // According to the manual we should get an int but as of today we do get a string... - if ('' == $version) - printf("[001] Client version must not be empty\n"); + // No more constraints - mysqlnd and libmysql return different strings at least + // with mysqli. Return type check is already performed in the generic test. + // According to the manual we should get an int but as of today we do get a string... + if ('' == $version) + printf("[001] Client version must not be empty\n"); - // Read-only - if (false !== $db->setAttribute(PDO::ATTR_CLIENT_VERSION, '1.0')) - printf("[002] Wonderful, I can change the client version!\n"); + // Read-only + if (false !== $db->setAttribute(PDO::ATTR_CLIENT_VERSION, '1.0')) + printf("[002] Wonderful, I can change the client version!\n"); - $new_version = $db->getAttribute(PDO::ATTR_CLIENT_VERSION); - if ($new_version !== $version) - printf("[003] Did we change it from '%s' to '%s'?\n", $version, $new_version); + $new_version = $db->getAttribute(PDO::ATTR_CLIENT_VERSION); + if ($new_version !== $version) + printf("[003] Did we change it from '%s' to '%s'?\n", $version, $new_version); - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt index 8abb16a1c792..07a1de5b652f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_connection_status.phpt @@ -9,24 +9,24 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- getAttribute(PDO::ATTR_CONNECTION_STATUS); + $status = $db->getAttribute(PDO::ATTR_CONNECTION_STATUS); if (!is_string($status)) printf("[002] Expecting string, got '%s'\n", var_export($status, true)); - if ('' == $status) - printf("[003] Connection status string must not be empty\n"); + if ('' == $status) + printf("[003] Connection status string must not be empty\n"); - if (false !== $db->setAttribute(PDO::ATTR_CONNECTION_STATUS, 'my own connection status')) - printf("[004] Changing read only attribute\n"); + if (false !== $db->setAttribute(PDO::ATTR_CONNECTION_STATUS, 'my own connection status')) + printf("[004] Changing read only attribute\n"); - $status2 = $db->getAttribute(PDO::ATTR_CONNECTION_STATUS); - if ($status !== $status2) - printf("[005] Connection status should not have changed\n"); + $status2 = $db->getAttribute(PDO::ATTR_CONNECTION_STATUS); + if ($status !== $status2) + printf("[005] Connection status should not have changed\n"); - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt index 65ab531ffd2b..e105a0eac1df 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_driver_name.phpt @@ -9,22 +9,22 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- errorCode()) || ('00000' == $db->errorCode())); + assert(('' == $db->errorCode()) || ('00000' == $db->errorCode())); - $name = $db->getAttribute(PDO::ATTR_DRIVER_NAME); - var_dump($name); + $name = $db->getAttribute(PDO::ATTR_DRIVER_NAME); + var_dump($name); - if (false !== $db->setAttribute(PDO::ATTR_DRIVER_NAME, 'mydriver')) - printf("[001] Wonderful, I can create new PDO drivers!\n"); + if (false !== $db->setAttribute(PDO::ATTR_DRIVER_NAME, 'mydriver')) + printf("[001] Wonderful, I can create new PDO drivers!\n"); - $new_name = $db->getAttribute(PDO::ATTR_DRIVER_NAME); - if ($name != $new_name) - printf("[002] Did we change it from '%s' to '%s'?\n", $name, $new_name); + $new_name = $db->getAttribute(PDO::ATTR_DRIVER_NAME); + if ($name != $new_name) + printf("[002] Did we change it from '%s' to '%s'?\n", $name, $new_name); - print "done!"; + print "done!"; ?> --EXPECT-- string(5) "mysql" diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt index f0dc29b8d483..13c331633c4f 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_errmode.phpt @@ -11,153 +11,153 @@ $db = MySQLPDOTest::factory(); error_reporting=E_ALL --FILE-- setAttribute(PDO::ATTR_ERRMODE, $tmp)) - printf("[001] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...\n"); - - $tmp = new stdClass(); - $ret = @$db->setAttribute(PDO::ATTR_ERRMODE, $tmp); - if (false != $ret) - printf("[002] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...%s\n", - var_export($ret, true)); - - $ret = @$db->setAttribute(PDO::ATTR_ERRMODE, 'pdo'); - if (false != $ret) - printf("[003] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...%s\n", - var_export($ret, true)); - - if (false != @$db->setAttribute(PDO::ATTR_ERRMODE, $invalid)) - printf("[004] Invalid ERRMODE should be rejected\n"); - - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); - // no message for any PDO call but... - $db->query('THIS IS NOT VALID SQL'); - // ... still messages for everything else - $code = $db->errorCode(); - $info = $db->errorInfo(); - - if ($code != '42000') - printf("[005] Expecting SQL code 42000 got '%s'\n", $code); - if ($code !== $info[0]) - printf("[006] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", - $code, $info[0]); - if ('' == $info[1]) - printf("[007] Driver specific error code not set\n"); - if ('' == $info[2]) - printf("[008] Driver specific error message not set\n"); - - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - $db->query('THIS IS NOT VALID SQL'); - - $code = $db->errorCode(); - $info = $db->errorInfo(); - - if ($code != '42000') - printf("[009] Expecting SQL code 42000 got '%s'\n", $code); - if ($code !== $info[0]) - printf("[010] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", - $code, $info[0]); - if ('' == $info[1]) - printf("[011] Driver specific error code not set\n"); - if ('' == $info[2]) - printf("[012] Driver specific error message not set\n"); - - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - try { - $line = __LINE__ + 1; - $db->query('THIS IS NOT VALID SQL'); - } catch (PDOException $e) { - - $code = $db->errorCode(); - $info = $db->errorInfo(); - - if ($code != '42000') - printf("[013] Expecting SQL code 42000 got '%s'\n", $code); - if ($code !== $info[0]) - printf("[014] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", - $code, $info[0]); - if ('' == $info[1]) - printf("[015] Driver specific error code not set\n"); - if ('' == $info[2]) - printf("[016] Driver specific error message not set\n"); - - if ($e->getCode() !== $code) - printf("[017] Exception code '%s' differs from errorCode '%s'\n", - $e->getCode(), $code); - - $msg = $e->getMessage(); - foreach ($info as $k => $v) { - if (false === stristr($msg, (string)$v)) { - printf("[018] Cannot find all parts of the error info ('%s') in the exception message '%s'\n", - $v, $msg); - } - } - - if ($e->getLine() !== $line) - printf("[019] Exception has been thrown in line %d, exception object reports line %d\n", - $line, $e->getLine()); - - if ($e->getFile() !== __FILE__) - printf("[020] Exception has been thrown in file '%s', exception object reports file '%s'\n", - __FILE__, $e->getFile()); - - } - - function my_handler($e) { - global $db, $line; - - $code = $db->errorCode(); - $info = $db->errorInfo(); - - if ($code != '42000') - printf("[021] Expecting SQL code 42000 got '%s'\n", $code); - if ($code !== $info[0]) - printf("[022] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", - $code, $info[0]); - if ('' == $info[1]) - printf("[023] Driver specific error code not set\n"); - if ('' == $info[2]) - printf("[024] Driver specific error message not set\n"); - - if ($e->getCode() !== $code) - printf("[025] Exception code '%s' differs from errorCode '%s'\n", - $e->getCode(), $code); - - $msg = $e->getMessage(); - foreach ($info as $k => $v) { - if (false === stristr($msg, (string)$v)) { - printf("[026] Cannot find all parts of the error info ('%s') in the exception message '%s'\n", - $v, $msg); - } - } - - if ($e->getLine() !== $line) - printf("[027] Exception has been thrown in line %d, exception object reports line %d\n", - $line, $e->getLine()); - - if ($e->getFile() !== __FILE__) - printf("[028] Exception has been thrown in file '%s', exception object reports file '%s'\n", - __FILE__, $e->getFile()); - - if (get_class($e) != 'PDOException') - printf("[029] Expecting PDO exception got exception of type '%s'\n", get_class($e)); - - print "\nend of execution"; - } - set_exception_handler('my_handler'); - $line = __LINE__ + 1; - $db->query('THIS IS NOT VALID SQL'); - - print "done!\n"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + $valid = array(PDO::ERRMODE_SILENT, PDO::ERRMODE_WARNING, PDO::ERRMODE_EXCEPTION); + do { + $invalid = mt_rand(-1000, 1000); + } while (in_array($invalid, $valid)); + + + $tmp = array(); + if (false != @$db->setAttribute(PDO::ATTR_ERRMODE, $tmp)) + printf("[001] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...\n"); + + $tmp = new stdClass(); + $ret = @$db->setAttribute(PDO::ATTR_ERRMODE, $tmp); + if (false != $ret) + printf("[002] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...%s\n", + var_export($ret, true)); + + $ret = @$db->setAttribute(PDO::ATTR_ERRMODE, 'pdo'); + if (false != $ret) + printf("[003] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...%s\n", + var_export($ret, true)); + + if (false != @$db->setAttribute(PDO::ATTR_ERRMODE, $invalid)) + printf("[004] Invalid ERRMODE should be rejected\n"); + + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); + // no message for any PDO call but... + $db->query('THIS IS NOT VALID SQL'); + // ... still messages for everything else + $code = $db->errorCode(); + $info = $db->errorInfo(); + + if ($code != '42000') + printf("[005] Expecting SQL code 42000 got '%s'\n", $code); + if ($code !== $info[0]) + printf("[006] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", + $code, $info[0]); + if ('' == $info[1]) + printf("[007] Driver specific error code not set\n"); + if ('' == $info[2]) + printf("[008] Driver specific error message not set\n"); + + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + $db->query('THIS IS NOT VALID SQL'); + + $code = $db->errorCode(); + $info = $db->errorInfo(); + + if ($code != '42000') + printf("[009] Expecting SQL code 42000 got '%s'\n", $code); + if ($code !== $info[0]) + printf("[010] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", + $code, $info[0]); + if ('' == $info[1]) + printf("[011] Driver specific error code not set\n"); + if ('' == $info[2]) + printf("[012] Driver specific error message not set\n"); + + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + try { + $line = __LINE__ + 1; + $db->query('THIS IS NOT VALID SQL'); + } catch (PDOException $e) { + + $code = $db->errorCode(); + $info = $db->errorInfo(); + + if ($code != '42000') + printf("[013] Expecting SQL code 42000 got '%s'\n", $code); + if ($code !== $info[0]) + printf("[014] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", + $code, $info[0]); + if ('' == $info[1]) + printf("[015] Driver specific error code not set\n"); + if ('' == $info[2]) + printf("[016] Driver specific error message not set\n"); + + if ($e->getCode() !== $code) + printf("[017] Exception code '%s' differs from errorCode '%s'\n", + $e->getCode(), $code); + + $msg = $e->getMessage(); + foreach ($info as $k => $v) { + if (false === stristr($msg, (string)$v)) { + printf("[018] Cannot find all parts of the error info ('%s') in the exception message '%s'\n", + $v, $msg); + } + } + + if ($e->getLine() !== $line) + printf("[019] Exception has been thrown in line %d, exception object reports line %d\n", + $line, $e->getLine()); + + if ($e->getFile() !== __FILE__) + printf("[020] Exception has been thrown in file '%s', exception object reports file '%s'\n", + __FILE__, $e->getFile()); + + } + + function my_handler($e) { + global $db, $line; + + $code = $db->errorCode(); + $info = $db->errorInfo(); + + if ($code != '42000') + printf("[021] Expecting SQL code 42000 got '%s'\n", $code); + if ($code !== $info[0]) + printf("[022] Code and info should be identical, got errorCode() = %s, errorInfo()[0] = %s\n", + $code, $info[0]); + if ('' == $info[1]) + printf("[023] Driver specific error code not set\n"); + if ('' == $info[2]) + printf("[024] Driver specific error message not set\n"); + + if ($e->getCode() !== $code) + printf("[025] Exception code '%s' differs from errorCode '%s'\n", + $e->getCode(), $code); + + $msg = $e->getMessage(); + foreach ($info as $k => $v) { + if (false === stristr($msg, (string)$v)) { + printf("[026] Cannot find all parts of the error info ('%s') in the exception message '%s'\n", + $v, $msg); + } + } + + if ($e->getLine() !== $line) + printf("[027] Exception has been thrown in line %d, exception object reports line %d\n", + $line, $e->getLine()); + + if ($e->getFile() !== __FILE__) + printf("[028] Exception has been thrown in file '%s', exception object reports file '%s'\n", + __FILE__, $e->getFile()); + + if (get_class($e) != 'PDOException') + printf("[029] Expecting PDO exception got exception of type '%s'\n", get_class($e)); + + print "\nend of execution"; + } + set_exception_handler('my_handler'); + $line = __LINE__ + 1; + $db->query('THIS IS NOT VALID SQL'); + + print "done!\n"; --EXPECTF-- [003] Maybe PDO could indicate that this is not a proper way of setting the ERRMODE...true diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt index a19e680de10b..eabc4db82951 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_fetch_table_names.phpt @@ -8,21 +8,21 @@ MySQLPDOTest::skip(); ?> --FILE-- setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 1); - $stmt = $db->query('SELECT label FROM test LIMIT 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt->closeCursor(); + $db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 1); + $stmt = $db->query('SELECT label FROM test LIMIT 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt->closeCursor(); - $db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 0); - $stmt = $db->query('SELECT label FROM test LIMIT 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt->closeCursor(); + $db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 0); + $stmt = $db->query('SELECT label FROM test LIMIT 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt->closeCursor(); - print "done!"; + print "done!"; ?> --EXPECT-- array(1) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt index cd3b40d6d12f..c979075fd7fc 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt @@ -11,29 +11,29 @@ $db = MySQLPDOTest::factory(); error_reporting=E_ALL --FILE-- exec(sprintf('DROP TABLE IF EXISTS %s', $table)); + $table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX))); + $db = new PDO($dsn, $user, $pass); + $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); - $create = sprintf('CREATE TABLE %s(id INT)', $table); - var_dump($create); - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create)); + $create = sprintf('CREATE TABLE %s(id INT)', $table); + var_dump($create); + $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create)); - $info = $db->errorInfo(); - var_dump($info[0]); + $info = $db->errorInfo(); + var_dump($info[0]); - $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table)); - $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table)); + $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); - print "done!"; + $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); + print "done!"; ?> --EXPECTF-- string(58) "CREATE TABLE test_%s(id INT)" diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt index c988b2b3cb6b..1337c1ac95df 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_max_buffer_size.phpt @@ -10,58 +10,58 @@ if (MySQLPDOTest::isPDOMySQLnd()) ?> --FILE-- $buffer_size, - /* buffer is only relevant with native PS */ - PDO::MYSQL_ATTR_DIRECT_QUERY => 0, - PDO::ATTR_EMULATE_PREPARES => 0, - )); + /* unsigned overflow possible ? */ + $db = new PDO($dsn, $user, $pass, + array( + PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => $buffer_size, + /* buffer is only relevant with native PS */ + PDO::MYSQL_ATTR_DIRECT_QUERY => 0, + PDO::ATTR_EMULATE_PREPARES => 0, + )); - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, val LONGBLOB) ENGINE = %s', PDO_MYSQL_TEST_ENGINE)); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, val LONGBLOB) ENGINE = %s', PDO_MYSQL_TEST_ENGINE)); - // 10 * (10 * 1024) = 10 * (10 * 1k) = 100k - $db->exec('INSERT INTO test(id, val) VALUES (1, REPEAT("01234567890", 10240))'); + // 10 * (10 * 1024) = 10 * (10 * 1k) = 100k + $db->exec('INSERT INTO test(id, val) VALUES (1, REPEAT("01234567890", 10240))'); - $stmt = $db->prepare('SELECT id, val FROM test'); - $stmt->execute(); + $stmt = $db->prepare('SELECT id, val FROM test'); + $stmt->execute(); - $id = $val = NULL; - $stmt->bindColumn(1, $id); - $stmt->bindColumn(2, $val); - while ($row = $stmt->fetch(PDO::FETCH_BOUND)) { - printf("[%03d] id = %d, val = %s... (length: %d)\n", - $offset, $id, substr($val, 0, 10), strlen($val)); - } - $db->exec('DROP TABLE IF EXISTS test'); + $id = $val = NULL; + $stmt->bindColumn(1, $id); + $stmt->bindColumn(2, $val); + while ($row = $stmt->fetch(PDO::FETCH_BOUND)) { + printf("[%03d] id = %d, val = %s... (length: %d)\n", + $offset, $id, substr($val, 0, 10), strlen($val)); + } + $db->exec('DROP TABLE IF EXISTS test'); - } catch (PDOException $e) { - printf("[%03d] %s, [%s] %s\n", - $offset, - $e->getMessage(), - (is_object($db)) ? $db->errorCode() : 'n/a', - (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); - } - } + } catch (PDOException $e) { + printf("[%03d] %s, [%s] %s\n", + $offset, + $e->getMessage(), + (is_object($db)) ? $db->errorCode() : 'n/a', + (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); + } + } - try_buffer_size(1, -1); - try_buffer_size(2, 1000); - try_buffer_size(3, NULL); - try_buffer_size(4, 2000); + try_buffer_size(1, -1); + try_buffer_size(2, 1000); + try_buffer_size(3, NULL); + try_buffer_size(4, 2000); - print "done!"; + print "done!"; ?> --CLEAN-- exec(sprintf('DROP TABLE IF EXISTS %s', $table)); - $create = sprintf('CREATE TABLE %s(id INT)', $table); - $db->exec($create); - $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table)); - $stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (2)', $table, $table)); - $stmt->closeCursor(); - $info = $db->errorInfo(); - var_dump($info[0]); - $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX))); + $db = new PDO($dsn, $user, $pass); + $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); + $create = sprintf('CREATE TABLE %s(id INT)', $table); + $db->exec($create); + $db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table)); + $stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (2)', $table, $table)); + $stmt->closeCursor(); + $info = $db->errorInfo(); + var_dump($info[0]); + $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // A single query with a trailing delimiter. - $stmt = $db->query('SELECT 1 AS value;'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query('SELECT 1 AS value;'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // New connection, does not allow multiple statements. - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => false)); - $stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (3)', $table, $table)); - var_dump($stmt); - $info = $db->errorInfo(); - var_dump($info[0]); + // New connection, does not allow multiple statements. + $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => false)); + $stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (3)', $table, $table)); + var_dump($stmt); + $info = $db->errorInfo(); + var_dump($info[0]); - $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query(sprintf('SELECT id FROM %s', $table)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); // A single query with a trailing delimiter. $stmt = $db->query('SELECT 1 AS value;'); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); - print "done!"; + $db->exec(sprintf('DROP TABLE IF EXISTS %s', $table)); + print "done!"; ?> --EXPECT-- string(5) "00000" diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt index 44503c1053f4..694a0394415c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt @@ -8,78 +8,78 @@ MySQLPDOTest::skip(); ?> --FILE-- setAttribute(PDO::ATTR_ORACLE_NULLS, $tmp)) - printf("[001] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n"); + $tmp = array(); + if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, $tmp)) + printf("[001] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n"); - $tmp = new stdClass(); - if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, $tmp)); - printf("[002] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n"); + $tmp = new stdClass(); + if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, $tmp)); + printf("[002] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n"); - if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 'pdo')) - printf("[003] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n"); + if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 'pdo')) + printf("[003] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n"); - $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1); - $stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e"); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1); + $stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e"); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 0); - $stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e"); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 0); + $stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e"); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1); - $stmt = $db->query('SELECT VERSION() as _version'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - if ((int)substr($row['_version'], 0, 1) >= 5) - $have_procedures = true; - else - $have_procedures = false; + $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1); + $stmt = $db->query('SELECT VERSION() as _version'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if ((int)substr($row['_version'], 0, 1) >= 5) + $have_procedures = true; + else + $have_procedures = false; - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - if ($have_procedures && (false !== $db->exec('DROP PROCEDURE IF EXISTS p')) && - (false !== $db->exec("CREATE PROCEDURE p() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) { - // requires MySQL 5+ - $stmt = $db->prepare('CALL p()'); - $stmt->execute(); - $expected = array( - array( - "z" => NULL, - "a" => NULL, - "b" => " ", - "c" => NULL, - "d" => " d", - "e" => " e", - ), - ); - do { - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if ($tmp != $expected) { - printf("[004] Expecting %s got %s\n", - var_export($expected, true), var_export($tmp, true)); - } - } while ($stmt->nextRowset()); + if ($have_procedures && (false !== $db->exec('DROP PROCEDURE IF EXISTS p')) && + (false !== $db->exec("CREATE PROCEDURE p() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) { + // requires MySQL 5+ + $stmt = $db->prepare('CALL p()'); + $stmt->execute(); + $expected = array( + array( + "z" => NULL, + "a" => NULL, + "b" => " ", + "c" => NULL, + "d" => " d", + "e" => " e", + ), + ); + do { + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if ($tmp != $expected) { + printf("[004] Expecting %s got %s\n", + var_export($expected, true), var_export($tmp, true)); + } + } while ($stmt->nextRowset()); - $stmt->execute(); - do { - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if ($tmp != $expected) { - printf("[005] Expecting %s got %s\n", - var_export($expected, true), var_export($tmp, true)); - } - } while ($stmt->nextRowset()); + $stmt->execute(); + do { + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if ($tmp != $expected) { + printf("[005] Expecting %s got %s\n", + var_export($expected, true), var_export($tmp, true)); + } + } while ($stmt->nextRowset()); - } + } - if ($have_procedures) - @$db->exec('DROP PROCEDURE IF EXISTS p'); + if ($have_procedures) + @$db->exec('DROP PROCEDURE IF EXISTS p'); - print "done!"; + print "done!"; ?> --EXPECTF-- [002] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt index f1ca4be1dec5..155f3514fa7c 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_prefetch.phpt @@ -9,11 +9,11 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- getAttribute(PDO::ATTR_PREFETCH)); - var_dump($db->setAttribute(PDO::ATTR_PREFETCH, true)); - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + var_dump($db->getAttribute(PDO::ATTR_PREFETCH)); + var_dump($db->setAttribute(PDO::ATTR_PREFETCH, true)); + print "done!"; --EXPECTF-- Warning: PDO::getAttribute(): SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute in %s on line %d bool(false) diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt index 4a142eee3807..d1b6e1e02b33 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt @@ -9,43 +9,43 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- errorCode()) || ('00000' == $db->errorCode())); - - $info = $db->getAttribute(PDO::ATTR_SERVER_INFO); - if ('' == $info) - printf("[001] Server info must not be empty\n"); - - // Read-only? - if (false !== $db->setAttribute(PDO::ATTR_SERVER_INFO, 'new uptime: 0s')) - printf("[002] Wonderful, I can change the client version!\n"); - - $new_info = $db->getAttribute(PDO::ATTR_SERVER_INFO); - if (soundex($new_info) != soundex($info)) - printf("[003] Did we change it from '%s' to '%s'?\n", $info, $info); - - // lets hope we always run this in the same second as we did run the server info request... - if (!$stmt = $db->query("SHOW STATUS LIKE '%uptime%'")) - printf("[004] Cannot run SHOW STATUS, [%s]\n", $db->errorCode()); - else { - if (!$row = $stmt->fetch(PDO::FETCH_NUM)) - printf("[005] Unable to fetch uptime, [%s]\n", $db->errorCode()); - else - $uptime = $row[1]; - $stmt->closeCursor(); - } - - if (!preg_match('/Uptime/i', $info)) - printf("[006] Can't find uptime in server info '%s'\n", $info); - - if (isset($uptime)) { - if (!preg_match('/Uptime: (\d+)/i', $info, $matches) || $uptime - $matches[1] > 1) { - printf("[007] SHOW STATUS and server info have reported a different uptime, please check. Server info: '%s', SHOW STATUS: '%s'\n", $info, $uptime); - } - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + assert(('' == $db->errorCode()) || ('00000' == $db->errorCode())); + + $info = $db->getAttribute(PDO::ATTR_SERVER_INFO); + if ('' == $info) + printf("[001] Server info must not be empty\n"); + + // Read-only? + if (false !== $db->setAttribute(PDO::ATTR_SERVER_INFO, 'new uptime: 0s')) + printf("[002] Wonderful, I can change the client version!\n"); + + $new_info = $db->getAttribute(PDO::ATTR_SERVER_INFO); + if (soundex($new_info) != soundex($info)) + printf("[003] Did we change it from '%s' to '%s'?\n", $info, $info); + + // lets hope we always run this in the same second as we did run the server info request... + if (!$stmt = $db->query("SHOW STATUS LIKE '%uptime%'")) + printf("[004] Cannot run SHOW STATUS, [%s]\n", $db->errorCode()); + else { + if (!$row = $stmt->fetch(PDO::FETCH_NUM)) + printf("[005] Unable to fetch uptime, [%s]\n", $db->errorCode()); + else + $uptime = $row[1]; + $stmt->closeCursor(); + } + + if (!preg_match('/Uptime/i', $info)) + printf("[006] Can't find uptime in server info '%s'\n", $info); + + if (isset($uptime)) { + if (!preg_match('/Uptime: (\d+)/i', $info, $matches) || $uptime - $matches[1] > 1) { + printf("[007] SHOW STATUS and server info have reported a different uptime, please check. Server info: '%s', SHOW STATUS: '%s'\n", $info, $uptime); + } + } + + print "done!"; --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt index a635c3771aba..62a2fae8b029 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_server_version.phpt @@ -9,57 +9,57 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- errorCode()) || ('00000' == $db->errorCode())); + assert(('' == $db->errorCode()) || ('00000' == $db->errorCode())); - $version = $db->getAttribute(PDO::ATTR_SERVER_VERSION); - if ('' == $version) - printf("[001] Server version must not be empty\n"); + $version = $db->getAttribute(PDO::ATTR_SERVER_VERSION); + if ('' == $version) + printf("[001] Server version must not be empty\n"); - // Ideally the server version would be an integer - as documented but BC break! - // If its a version string it should be of the format \d+\.\d+\.\d+.* + // Ideally the server version would be an integer - as documented but BC break! + // If its a version string it should be of the format \d+\.\d+\.\d+.* - if (is_string($version)) { - // Its not an int like documented but a string - maybe for BC reasons... - if (!preg_match('/(\d+)\.(\d+)\.(\d+)(.*)/', $version, $matches)) - printf("[002] Client version string seems wrong, got '%s'\n", $version); - else { - // Difficult to define any meaningful constraints - // A possible better check would be calling mysqli_get_server_version() and - // comparing what we get. However, mysqli_get_server_version() needs a mysqli handle - // for which in turn one needs to parse the PDO test environment variables - // for connection parameter... - if ($matches[1] < 3) - printf("[003] Strange major version: '%s'. Should be more than 3\n", $matches[1]); - if ($matches[2] < 0) - printf("[004] Minor version should be at least 0, got '%s'\n", $matches[2]); - if ($matches[3] < 0) - printf("[005] Sub version should be at least 0, got '%s'\n", $matches[2]); - } - } else if (is_int($version)) { - // Lets accept also int if it follows the rules from the original MYSQL C API - $major = floor($version / 10000); - $minor = floor(($version - ($main * 10000)) / 100); - $sub = $version - ($main * 10000) - ($minor * 100); - if ($major < 3) - printf("[006] Strange major version: '%s'. Should be more than 3\n", $major); - if ($minor < 0) - printf("[007] Minor version should be at least 0, got '%s'\n", $minor); - if ($sub < 0) - printf("[008] Sub version should be at least 0, got '%s'\n", $sub); - } + if (is_string($version)) { + // Its not an int like documented but a string - maybe for BC reasons... + if (!preg_match('/(\d+)\.(\d+)\.(\d+)(.*)/', $version, $matches)) + printf("[002] Client version string seems wrong, got '%s'\n", $version); + else { + // Difficult to define any meaningful constraints + // A possible better check would be calling mysqli_get_server_version() and + // comparing what we get. However, mysqli_get_server_version() needs a mysqli handle + // for which in turn one needs to parse the PDO test environment variables + // for connection parameter... + if ($matches[1] < 3) + printf("[003] Strange major version: '%s'. Should be more than 3\n", $matches[1]); + if ($matches[2] < 0) + printf("[004] Minor version should be at least 0, got '%s'\n", $matches[2]); + if ($matches[3] < 0) + printf("[005] Sub version should be at least 0, got '%s'\n", $matches[2]); + } + } else if (is_int($version)) { + // Lets accept also int if it follows the rules from the original MYSQL C API + $major = floor($version / 10000); + $minor = floor(($version - ($main * 10000)) / 100); + $sub = $version - ($main * 10000) - ($minor * 100); + if ($major < 3) + printf("[006] Strange major version: '%s'. Should be more than 3\n", $major); + if ($minor < 0) + printf("[007] Minor version should be at least 0, got '%s'\n", $minor); + if ($sub < 0) + printf("[008] Sub version should be at least 0, got '%s'\n", $sub); + } - // Read-only? - if (false !== $db->setAttribute(PDO::ATTR_CLIENT_VERSION, '1.0')) - printf("[009] Wonderful, I can change the client version!\n"); + // Read-only? + if (false !== $db->setAttribute(PDO::ATTR_CLIENT_VERSION, '1.0')) + printf("[009] Wonderful, I can change the client version!\n"); - $new_version = $db->getAttribute(PDO::ATTR_SERVER_VERSION); - if ($new_version !== $version) - printf("[010] Did we change it from '%s' to '%s'?\n", $version, $new_version); + $new_version = $db->getAttribute(PDO::ATTR_SERVER_VERSION); + if ($new_version !== $version) + printf("[010] Did we change it from '%s' to '%s'?\n", $version, $new_version); - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt index 237f03af3836..e8bdd164346b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt @@ -9,100 +9,100 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- getAttribute(PDO::ATTR_STATEMENT_CLASS); - var_dump($default); - - if (false !== ($tmp = @$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, 'foo'))) - printf("[002] Expecting boolean/false got %s\n", var_export($tmp, true)); - - if (false !== ($tmp = @$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('classname')))) - printf("[003] Expecting boolean/false got %s\n", var_export($tmp, true)); - - // unknown class - if (false !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('classname', array())))) - printf("[004] Expecting boolean/false got %s\n", var_export($tmp, true)); - - // class not derived from PDOStatement - class myclass { - function __construct() { - printf("myclass\n"); - } - } - if (false !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('myclass', array())))) - printf("[005] Expecting boolean/false got %s\n", var_export($tmp, true)); - - // public constructor not allowed - class mystatement extends PDOStatement { - public function __construct() { - printf("mystatement\n"); - } - } - - if (false !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement', array())))) - printf("[006] Expecting boolean/false got %s\n", var_export($tmp, true)); - - // ... but a public destructor is allowed - class mystatement2 extends PDOStatement { - public function __destruct() { - printf("mystatement\n"); - } - } - - if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement2', array())))) - printf("[007] Expecting boolean/true got %s\n", var_export($tmp, true)); - - // private constructor - class mystatement3 extends PDOStatement { - private function __construct($msg) { - printf("mystatement3\n"); - var_dump($msg); - } - } - if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement3', array('param1'))))) - printf("[008] Expecting boolean/true got %s\n", var_export($tmp, true)); - - // private constructor - class mystatement4 extends PDOStatement { - private function __construct($msg) { - printf("%s\n", get_class($this)); - var_dump($msg); - } - } - if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement4', array('param1'))))) - printf("[008] Expecting boolean/true got %s\n", var_export($tmp, true)); - - var_dump($db->getAttribute(PDO::ATTR_STATEMENT_CLASS)); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); - - class mystatement5 extends mystatement4 { - public function fetchAll($fetch_style = 1, $column_index = 1, $ctor_args = array()) { - return "no data :)"; - } - } - - if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement5', array('mystatement5'))))) - printf("[009] Expecting boolean/true got %s\n", var_export($tmp, true)); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); - var_dump($stmt->fetchAll()); - - if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement')))) - printf("[010] Expecting boolean/true got %s\n", var_export($tmp, true)); - - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1'); - var_dump($stmt->fetchAll()); - - // Yes, this is a fatal error and I want it to fail. - abstract class mystatement6 extends mystatement5 { - } - if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement6', array('mystatement6'))))) - printf("[011] Expecting boolean/true got %s\n", var_export($tmp, true)); - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1'); - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + + $default = $db->getAttribute(PDO::ATTR_STATEMENT_CLASS); + var_dump($default); + + if (false !== ($tmp = @$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, 'foo'))) + printf("[002] Expecting boolean/false got %s\n", var_export($tmp, true)); + + if (false !== ($tmp = @$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('classname')))) + printf("[003] Expecting boolean/false got %s\n", var_export($tmp, true)); + + // unknown class + if (false !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('classname', array())))) + printf("[004] Expecting boolean/false got %s\n", var_export($tmp, true)); + + // class not derived from PDOStatement + class myclass { + function __construct() { + printf("myclass\n"); + } + } + if (false !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('myclass', array())))) + printf("[005] Expecting boolean/false got %s\n", var_export($tmp, true)); + + // public constructor not allowed + class mystatement extends PDOStatement { + public function __construct() { + printf("mystatement\n"); + } + } + + if (false !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement', array())))) + printf("[006] Expecting boolean/false got %s\n", var_export($tmp, true)); + + // ... but a public destructor is allowed + class mystatement2 extends PDOStatement { + public function __destruct() { + printf("mystatement\n"); + } + } + + if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement2', array())))) + printf("[007] Expecting boolean/true got %s\n", var_export($tmp, true)); + + // private constructor + class mystatement3 extends PDOStatement { + private function __construct($msg) { + printf("mystatement3\n"); + var_dump($msg); + } + } + if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement3', array('param1'))))) + printf("[008] Expecting boolean/true got %s\n", var_export($tmp, true)); + + // private constructor + class mystatement4 extends PDOStatement { + private function __construct($msg) { + printf("%s\n", get_class($this)); + var_dump($msg); + } + } + if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement4', array('param1'))))) + printf("[008] Expecting boolean/true got %s\n", var_export($tmp, true)); + + var_dump($db->getAttribute(PDO::ATTR_STATEMENT_CLASS)); + $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + + class mystatement5 extends mystatement4 { + public function fetchAll($fetch_style = 1, $column_index = 1, $ctor_args = array()) { + return "no data :)"; + } + } + + if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement5', array('mystatement5'))))) + printf("[009] Expecting boolean/true got %s\n", var_export($tmp, true)); + $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + var_dump($stmt->fetchAll()); + + if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement')))) + printf("[010] Expecting boolean/true got %s\n", var_export($tmp, true)); + + $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1'); + var_dump($stmt->fetchAll()); + + // Yes, this is a fatal error and I want it to fail. + abstract class mystatement6 extends mystatement5 { + } + if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement6', array('mystatement6'))))) + printf("[011] Expecting boolean/true got %s\n", var_export($tmp, true)); + $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1'); + + print "done!"; ?> --EXPECTF-- array(1) { diff --git a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt index f2653f4b6b92..2fc60f9fc2f6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt @@ -11,175 +11,175 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) ?> --FILE-- getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[001] Autocommit should be on by default\n"); + if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[001] Autocommit should be on by default\n"); - if (false == $db->beginTransaction()) - printf("[002] Cannot start a transaction, [%s] [%s]\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + if (false == $db->beginTransaction()) + printf("[002] Cannot start a transaction, [%s] [%s]\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[003] Autocommit should be on by default, beginTransaction() shall not impact it\n"); + if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[003] Autocommit should be on by default, beginTransaction() shall not impact it\n"); - if (0 == $db->exec('DELETE FROM test')) - printf("[004] No rows deleted, can't be true.\n"); + if (0 == $db->exec('DELETE FROM test')) + printf("[004] No rows deleted, can't be true.\n"); - /* This is the PDO way to close a connection */ - $db = null; - $db = MySQLPDOTest::factory(); + /* This is the PDO way to close a connection */ + $db = null; + $db = MySQLPDOTest::factory(); - /* Autocommit was off - by definition. Commit was not issued. DELETE should have been rolled back. */ - if (!($stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC'))) - printf("[005] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + /* Autocommit was off - by definition. Commit was not issued. DELETE should have been rolled back. */ + if (!($stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC'))) + printf("[005] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - var_dump($row); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + var_dump($row); - if (!$db->beginTransaction()) - printf("[006] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->beginTransaction()) + printf("[006] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id']))) - printf("[007] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id']))) + printf("[007] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (!$db->commit()) - printf("[008] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->commit()) + printf("[008] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[009] Autocommit should be on after commit()\n"); + if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[009] Autocommit should be on after commit()\n"); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) - printf("[010] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + printf("[010] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - var_dump($stmt->fetch(PDO::FETCH_ASSOC)); + var_dump($stmt->fetch(PDO::FETCH_ASSOC)); - if (!$db->beginTransaction()) - printf("[011] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->beginTransaction()) + printf("[011] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $db->exec(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z')", $row['id'])); + $db->exec(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z')", $row['id'])); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) - printf("[012] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + printf("[012] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $new_row1 = $stmt->fetch(PDO::FETCH_ASSOC); - var_dump($new_row1); + $new_row1 = $stmt->fetch(PDO::FETCH_ASSOC); + var_dump($new_row1); - if (!$db->commit()) - printf("[013] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->commit()) + printf("[013] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) - printf("[014] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + printf("[014] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $new_row2 = $stmt->fetch(PDO::FETCH_ASSOC); - if ($new_row1 != $new_row2) { - printf("[015] Results must not differ!\n"); - var_dump($new_row1); - var_dump($new_row2); - } + $new_row2 = $stmt->fetch(PDO::FETCH_ASSOC); + if ($new_row1 != $new_row2) { + printf("[015] Results must not differ!\n"); + var_dump($new_row1); + var_dump($new_row2); + } - if (!$db->beginTransaction()) - printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->beginTransaction()) + printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id']))) - printf("[017] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id']))) + printf("[017] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (!$db->rollback()) - printf("[018] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->rollback()) + printf("[018] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[019] Autocommit should be on after rollback\n"); + if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[019] Autocommit should be on after rollback\n"); - if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) - printf("[020] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id'])))) + printf("[020] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $new_row2 = $stmt->fetch(PDO::FETCH_ASSOC); - if ($new_row1 != $new_row2) { - printf("[021] Results must not differ!\n"); - var_dump($new_row1); - var_dump($new_row2); - } + $new_row2 = $stmt->fetch(PDO::FETCH_ASSOC); + if ($new_row1 != $new_row2) { + printf("[021] Results must not differ!\n"); + var_dump($new_row1); + var_dump($new_row2); + } - // now, lets check the server variables - if (!($stmt = $db->query('SELECT @@autocommit as auto_commit'))) - printf("[022] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + // now, lets check the server variables + if (!($stmt = $db->query('SELECT @@autocommit as auto_commit'))) + printf("[022] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - if ($tmp['auto_commit'] != 1) - printf("[023] MySQL Server should indicate autocommit mode, expecting 1, got '%s', [%d] %s\n", - $tmp['auto_commit'], $stmt->errorCode(), $stmt->errorInfo()); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + if ($tmp['auto_commit'] != 1) + printf("[023] MySQL Server should indicate autocommit mode, expecting 1, got '%s', [%d] %s\n", + $tmp['auto_commit'], $stmt->errorCode(), $stmt->errorInfo()); - if (!$db->beginTransaction()) - printf("[024] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->beginTransaction()) + printf("[024] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (!($stmt = $db->query('SELECT @@autocommit as auto_commit'))) - printf("[025] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!($stmt = $db->query('SELECT @@autocommit as auto_commit'))) + printf("[025] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - if ($tmp['auto_commit'] != 0) - printf("[026] Autocommit mode of the MySQL Server should be off, got '%s', [%d] %s\n", - $tmp['auto_commit'], $stmt->errorCode(), trim(implode(' ', $stmt->errorInfo()))); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + if ($tmp['auto_commit'] != 0) + printf("[026] Autocommit mode of the MySQL Server should be off, got '%s', [%d] %s\n", + $tmp['auto_commit'], $stmt->errorCode(), trim(implode(' ', $stmt->errorInfo()))); - $db->commit(); - // Now we should be back to autocommit - we've issues a commit - if ($tmp['auto_commit'] != 1) - printf("[027] MySQL Server should indicate autocommit mode, expecting 1, got '%s', [%d] %s\n", - $tmp['auto_commit'], $stmt->errorCode(), $stmt->errorInfo()); + $db->commit(); + // Now we should be back to autocommit - we've issues a commit + if ($tmp['auto_commit'] != 1) + printf("[027] MySQL Server should indicate autocommit mode, expecting 1, got '%s', [%d] %s\n", + $tmp['auto_commit'], $stmt->errorCode(), $stmt->errorInfo()); - // Turn off autocommit using a server variable - $db->exec('SET @@autocommit = 0'); - if (1 === $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[028] I'm confused, how can autocommit be on? Didn't I say I want to manually control transactions?\n"); + // Turn off autocommit using a server variable + $db->exec('SET @@autocommit = 0'); + if (1 === $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[028] I'm confused, how can autocommit be on? Didn't I say I want to manually control transactions?\n"); - if (!$db->beginTransaction()) - printf("[029] Cannot start a transaction, [%d] %s\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->beginTransaction()) + printf("[029] Cannot start a transaction, [%d] %s\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - try { - if (false !== $db->beginTransaction()) { - printf("[030] No false and no exception - that's wrong.\n"); - } - } catch (PDOException $e) { - assert($e->getMessage() != ''); - } + try { + if (false !== $db->beginTransaction()) { + printf("[030] No false and no exception - that's wrong.\n"); + } + } catch (PDOException $e) { + assert($e->getMessage() != ''); + } - // TODO: What about an engine that does not support transactions? - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, 'MyISAM'); + // TODO: What about an engine that does not support transactions? + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, 'MyISAM'); - if (false == $db->beginTransaction()) - printf("[031] Cannot start a transaction, [%s] [%s]\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + if (false == $db->beginTransaction()) + printf("[031] Cannot start a transaction, [%s] [%s]\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) - printf("[032] Autocommit should be on my default, beginTransaction() should not change that\n"); + if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT)) + printf("[032] Autocommit should be on my default, beginTransaction() should not change that\n"); - if (0 == $db->exec('DELETE FROM test')) - printf("[033] No rows deleted, can't be true.\n"); + if (0 == $db->exec('DELETE FROM test')) + printf("[033] No rows deleted, can't be true.\n"); - if (!$db->commit()) - printf("[034] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + if (!$db->commit()) + printf("[034] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - if (false == $db->beginTransaction()) - printf("[035] Cannot start a transaction, [%s] [%s]\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + if (false == $db->beginTransaction()) + printf("[035] Cannot start a transaction, [%s] [%s]\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - if (0 == $db->exec("INSERT INTO test(id, label) VALUES (1, 'a')")) - printf("[036] Cannot insert data, [%s] [%s]\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + if (0 == $db->exec("INSERT INTO test(id, label) VALUES (1, 'a')")) + printf("[036] Cannot insert data, [%s] [%s]\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - // Should cause a Server warning but no error - if (!$db->rollback()) - printf("[037] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + // Should cause a Server warning but no error + if (!$db->rollback()) + printf("[037] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - var_dump($db->errorCode()); + var_dump($db->errorCode()); - if (1 != $db->exec('DELETE FROM test')) - printf("[038] No rows deleted, can't be true.\n"); + if (1 != $db->exec('DELETE FROM test')) + printf("[038] No rows deleted, can't be true.\n"); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - @$db->exec($sql); - if ($db->errorCode() != 0) { - // not all MySQL Server versions and/or engines might support the type - return true; - } + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); + @$db->exec($sql); + if ($db->errorCode() != 0) { + // not all MySQL Server versions and/or engines might support the type + return true; + } - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); - $stmt->bindValue(1, $offset); - $stmt->bindValue(2, $value); - if (!$stmt->execute()) { - printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true)); - return false; - } - $stmt = $db->query('SELECT id, label FROM test'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - var_dump($row); - var_dump($value); + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); + $stmt->bindValue(1, $offset); + $stmt->bindValue(2, $value); + if (!$stmt->execute()) { + printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true)); + return false; + } + $stmt = $db->query('SELECT id, label FROM test'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + var_dump($row); + var_dump($value); - return true; - } + return true; + } - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - test_type($db, 20, 'BIT(8)', 1); + test_type($db, 20, 'BIT(8)', 1); - echo "done!\n"; + echo "done!\n"; ?> --CLEAN-- --FILE-- true, - 'MYSQL_ATTR_LOCAL_INFILE' => true, - 'MYSQL_ATTR_DIRECT_QUERY' => true, - 'MYSQL_ATTR_FOUND_ROWS' => true, - 'MYSQL_ATTR_IGNORE_SPACE' => true, - 'MYSQL_ATTR_INIT_COMMAND' => true, - "MYSQL_ATTR_SSL_KEY" => true, - "MYSQL_ATTR_SSL_CERT" => true, - "MYSQL_ATTR_SSL_CA" => true, - "MYSQL_ATTR_SSL_CAPATH" => true, - "MYSQL_ATTR_SSL_CIPHER" => true, - "MYSQL_ATTR_COMPRESS" => true, - "MYSQL_ATTR_MULTI_STATEMENTS" => true, - "MYSQL_ATTR_SSL_VERIFY_SERVER_CERT" => true, - ); + $expected = array( + 'MYSQL_ATTR_USE_BUFFERED_QUERY' => true, + 'MYSQL_ATTR_LOCAL_INFILE' => true, + 'MYSQL_ATTR_DIRECT_QUERY' => true, + 'MYSQL_ATTR_FOUND_ROWS' => true, + 'MYSQL_ATTR_IGNORE_SPACE' => true, + 'MYSQL_ATTR_INIT_COMMAND' => true, + "MYSQL_ATTR_SSL_KEY" => true, + "MYSQL_ATTR_SSL_CERT" => true, + "MYSQL_ATTR_SSL_CA" => true, + "MYSQL_ATTR_SSL_CAPATH" => true, + "MYSQL_ATTR_SSL_CIPHER" => true, + "MYSQL_ATTR_COMPRESS" => true, + "MYSQL_ATTR_MULTI_STATEMENTS" => true, + "MYSQL_ATTR_SSL_VERIFY_SERVER_CERT" => true, + ); - if (!MySQLPDOTest::isPDOMySQLnd()) { - $expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] = true; - $expected['MYSQL_ATTR_READ_DEFAULT_FILE'] = true; - $expected['MYSQL_ATTR_READ_DEFAULT_GROUP'] = true; - } + if (!MySQLPDOTest::isPDOMySQLnd()) { + $expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] = true; + $expected['MYSQL_ATTR_READ_DEFAULT_FILE'] = true; + $expected['MYSQL_ATTR_READ_DEFAULT_GROUP'] = true; + } - if (extension_loaded('mysqlnd')) { - $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; - } else if (extension_loaded('mysqli')) { - if (mysqli_get_client_version() > 50605) { - $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; - } - } else if (MySQLPDOTest::getClientVersion(MySQLPDOTest::factory()) > 50605) { - /* XXX the MySQL client library version isn't exposed with any - constants, the single possibility is to use the PDO::getAttribute(). - This however will fail with no connection. */ - $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; - } + if (extension_loaded('mysqlnd')) { + $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; + } else if (extension_loaded('mysqli')) { + if (mysqli_get_client_version() > 50605) { + $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; + } + } else if (MySQLPDOTest::getClientVersion(MySQLPDOTest::factory()) > 50605) { + /* XXX the MySQL client library version isn't exposed with any + constants, the single possibility is to use the PDO::getAttribute(). + This however will fail with no connection. */ + $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true; + } - /* - TODO + /* + TODO - MYSQLI_OPT_CONNECT_TIMEOUT != PDO::ATTR_TIMEOUT (integer) + MYSQLI_OPT_CONNECT_TIMEOUT != PDO::ATTR_TIMEOUT (integer) Sets the timeout value in seconds for communications with the database. - ^ Potential BUG, PDO::ATTR_TIMEOUT is used in pdo_mysql_handle_factory + ^ Potential BUG, PDO::ATTR_TIMEOUT is used in pdo_mysql_handle_factory - MYSQLI_SET_CHARSET_NAME -> DSN/charset= - ^ Undocumented and pitfall for ext/mysqli users + MYSQLI_SET_CHARSET_NAME -> DSN/charset= + ^ Undocumented and pitfall for ext/mysqli users - Assorted mysqlnd settings missing - */ - $ref = new ReflectionClass('PDO'); - $constants = $ref->getConstants(); - $values = array(); + Assorted mysqlnd settings missing + */ + $ref = new ReflectionClass('PDO'); + $constants = $ref->getConstants(); + $values = array(); - foreach ($constants as $name => $value) - if (substr($name, 0, 11) == 'MYSQL_ATTR_') { - if (!isset($values[$value])) - $values[$value] = array($name); - else - $values[$value][] = $name; + foreach ($constants as $name => $value) + if (substr($name, 0, 11) == 'MYSQL_ATTR_') { + if (!isset($values[$value])) + $values[$value] = array($name); + else + $values[$value][] = $name; - if (isset($expected[$name])) { - unset($expected[$name]); - unset($constants[$name]); - } + if (isset($expected[$name])) { + unset($expected[$name]); + unset($constants[$name]); + } - } else { - unset($constants[$name]); - } + } else { + unset($constants[$name]); + } - if (!empty($constants)) { - printf("[001] Dumping list of unexpected constants\n"); - var_dump($constants); - } + if (!empty($constants)) { + printf("[001] Dumping list of unexpected constants\n"); + var_dump($constants); + } - if (!empty($expected)) { - printf("[002] Dumping list of missing constants\n"); - var_dump($expected); - } + if (!empty($expected)) { + printf("[002] Dumping list of missing constants\n"); + var_dump($expected); + } - if (!empty($values)) { - foreach ($values as $value => $constants) { - if (count($constants) > 1) { - printf("[003] Several constants share the same value '%s'\n", $value); - var_dump($constants); - } - } - } + if (!empty($values)) { + foreach ($values as $value => $constants) { + if (count($constants) > 1) { + printf("[003] Several constants share the same value '%s'\n", $value); + var_dump($constants); + } + } + } - print "done!"; + print "done!"; --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt index 6141ff611b58..9dec5700b6dd 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt @@ -11,74 +11,74 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) ?> --FILE-- beginTransaction())) { - printf("[001] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - } + try { + if (true !== ($tmp = $db->beginTransaction())) { + printf("[001] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + } - // DDL will issue an implicit commit - $db->exec(sprintf('DROP TABLE IF EXISTS test_commit')); - $db->exec(sprintf('CREATE TABLE test_commit(id INT) ENGINE=%s', MySQLPDOTest::detect_transactional_mysql_engine($db))); - if (true !== ($tmp = $db->commit())) { - printf("[002] No commit allowed? [%s] %s\n", - $db->errorCode(), implode(' ', $db->errorInfo())); - } + // DDL will issue an implicit commit + $db->exec(sprintf('DROP TABLE IF EXISTS test_commit')); + $db->exec(sprintf('CREATE TABLE test_commit(id INT) ENGINE=%s', MySQLPDOTest::detect_transactional_mysql_engine($db))); + if (true !== ($tmp = $db->commit())) { + printf("[002] No commit allowed? [%s] %s\n", + $db->errorCode(), implode(' ', $db->errorInfo())); + } - // pdo_transaction_transitions should check this as well... - // ... just to be sure the most basic stuff really works we check it again... - if (1 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) - printf("[003] According to the manual we should be back to autocommit mode, got %s/%s\n", - gettype($tmp), var_export($tmp, true)); + // pdo_transaction_transitions should check this as well... + // ... just to be sure the most basic stuff really works we check it again... + if (1 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT))) + printf("[003] According to the manual we should be back to autocommit mode, got %s/%s\n", + gettype($tmp), var_export($tmp, true)); - if (true !== ($tmp = $db->beginTransaction())) - printf("[004] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $db->beginTransaction())) + printf("[004] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')"); + $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')"); - if (true !== ($tmp = $db->commit())) - printf("[005] No commit allowed? [%s] %s\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + if (true !== ($tmp = $db->commit())) + printf("[005] No commit allowed? [%s] %s\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - // a weak test without unicode etc. - lets leave that to dedicated tests - $stmt = $db->query('SELECT id, label FROM test WHERE id = 100'); - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) { - printf("[006] Record data is strange, dumping rows\n"); - var_dump($rows); - } + // a weak test without unicode etc. - lets leave that to dedicated tests + $stmt = $db->query('SELECT id, label FROM test WHERE id = 100'); + $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) { + printf("[006] Record data is strange, dumping rows\n"); + var_dump($rows); + } - // Ok, lets check MyISAM resp. any other non-transactional engine - // pdo_mysql_begin_transaction has more on this, quick check only - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, 'MyISAM'); + // Ok, lets check MyISAM resp. any other non-transactional engine + // pdo_mysql_begin_transaction has more on this, quick check only + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, 'MyISAM'); - if (true !== ($tmp = $db->beginTransaction())) - printf("[007] Expecting true, got %s/%s\n", gettype($tmp), $tmp); + if (true !== ($tmp = $db->beginTransaction())) + printf("[007] Expecting true, got %s/%s\n", gettype($tmp), $tmp); - $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')"); - if (true !== ($tmp = $db->commit())) - printf("[008] No commit allowed? [%s] %s\n", - $db->errorCode(), implode(' ', $db->errorInfo())); + $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')"); + if (true !== ($tmp = $db->commit())) + printf("[008] No commit allowed? [%s] %s\n", + $db->errorCode(), implode(' ', $db->errorInfo())); - // a weak test without unicode etc. - lets leave that to dedicated tests - $stmt = $db->query('SELECT id, label FROM test WHERE id = 100'); - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) { - printf("[009] Record data is strange, dumping rows\n"); - var_dump($rows); - } + // a weak test without unicode etc. - lets leave that to dedicated tests + $stmt = $db->query('SELECT id, label FROM test WHERE id = 100'); + $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) { + printf("[009] Record data is strange, dumping rows\n"); + var_dump($rows); + } - } catch (PDOException $e) { - printf("[002] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[002] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; --CLEAN-- --FILE-- query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value; + /* Connect to mysql to determine the current charset so we can diffinate it */ + $link = MySQLPDOTest::factory(); + $charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value; - /* Make sure that we don't attempt to set the current character set to make this case useful */ - $new_charset = ($charset == 'latin1' ? 'ascii' : 'latin1'); + /* Make sure that we don't attempt to set the current character set to make this case useful */ + $new_charset = ($charset == 'latin1' ? 'ascii' : 'latin1'); - /* Done with the original connection, create a second link to test the character set being defined */ - unset($link); + /* Done with the original connection, create a second link to test the character set being defined */ + unset($link); - $link = MySQLPDOTest::factory('PDO', false, null, Array('charset' => $new_charset)); - $conn_charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value; + $link = MySQLPDOTest::factory('PDO', false, null, Array('charset' => $new_charset)); + $conn_charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value; - if ($charset !== $conn_charset) { - echo "done!\n"; - } else { - echo "failed!\n"; - } + if ($charset !== $conn_charset) { + echo "done!\n"; + } else { + echo "failed!\n"; + } ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt b/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt index 5bf6c10448ab..c2b07100c0c6 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_errorcode.phpt @@ -9,73 +9,73 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- errorCode(); - if (($code != $expected) && (($expected != '00000') && ($code != ''))) { - printf("[%03d] Expecting error code '%s' got code '%s'\n", - $offset, $expected, $code); - } + $code = $obj->errorCode(); + if (($code != $expected) && (($expected != '00000') && ($code != ''))) { + printf("[%03d] Expecting error code '%s' got code '%s'\n", + $offset, $expected, $code); + } - } + } - try { + try { - /* - If you create a PDOStatement object through PDO->prepare() - or PDO->query() and invoke an error on the statement handle, - PDO->errorCode() will not reflect that error. You must call - PDOStatement->errorCode() to return the error code for an - operation performed on a particular statement handle. - */ - $code = $db->errorCode(); - check_error(2, $db); + /* + If you create a PDOStatement object through PDO->prepare() + or PDO->query() and invoke an error on the statement handle, + PDO->errorCode() will not reflect that error. You must call + PDOStatement->errorCode() to return the error code for an + operation performed on a particular statement handle. + */ + $code = $db->errorCode(); + check_error(2, $db); - $stmt = $db->query('SELECT id, label FROM test'); - $stmt2 = &$stmt; - check_error(3, $db); - check_error(4, $stmt); + $stmt = $db->query('SELECT id, label FROM test'); + $stmt2 = &$stmt; + check_error(3, $db); + check_error(4, $stmt); - $db->exec('DROP TABLE IF EXISTS test'); - @$stmt->execute(); - check_error(4, $db); - check_error(5, $stmt, '42S02'); - check_error(6, $stmt2, '42S02'); + $db->exec('DROP TABLE IF EXISTS test'); + @$stmt->execute(); + check_error(4, $db); + check_error(5, $stmt, '42S02'); + check_error(6, $stmt2, '42S02'); - $db->exec('DROP TABLE IF EXISTS unknown'); - @$stmt = $db->query('SELECT id, label FROM unknown'); - check_error(7, $db, '42S02'); + $db->exec('DROP TABLE IF EXISTS unknown'); + @$stmt = $db->query('SELECT id, label FROM unknown'); + check_error(7, $db, '42S02'); - MySQLPDOTest::createTestTable($db); - $stmt = $db->query('SELECT id, label FROM test'); - check_error(8, $db); - check_error(9, $stmt); + MySQLPDOTest::createTestTable($db); + $stmt = $db->query('SELECT id, label FROM test'); + check_error(8, $db); + check_error(9, $stmt); - $db2 = &$db; - @$db->query('SELECT id, label FROM unknown'); - check_error(10, $db, '42S02'); - check_error(11, $db2, '42S02'); - check_error(12, $stmt); - check_error(13, $stmt2); + $db2 = &$db; + @$db->query('SELECT id, label FROM unknown'); + check_error(10, $db, '42S02'); + check_error(11, $db2, '42S02'); + check_error(12, $stmt); + check_error(13, $stmt2); - // lets hope this is an invalid attribute code - $invalid_attr = -1 * PHP_INT_MAX + 3; - $tmp = @$db->getAttribute($invalid_attr); - check_error(14, $db, 'IM001'); - check_error(15, $db2, 'IM001'); - check_error(16, $stmt); - check_error(17, $stmt2); + // lets hope this is an invalid attribute code + $invalid_attr = -1 * PHP_INT_MAX + 3; + $tmp = @$db->getAttribute($invalid_attr); + check_error(14, $db, 'IM001'); + check_error(15, $db2, 'IM001'); + check_error(16, $stmt); + check_error(17, $stmt2); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- errorInfo(); - $code = $info[0]; - - if (($code != $expected) && (($expected != '00000') && ($code != ''))) { - printf("[%03d] Expecting error code '%s' got code '%s'\n", - $offset, $expected, $code); - } - - if ($expected != '00000') { - if (!isset($info[1]) || $info[1] == '') - printf("[%03d] Driver-specific error code not set\n", $offset); - if (!isset($info[2]) || $info[2] == '') - printf("[%03d] Driver-specific error message.not set\n", $offset); - } - - } - - function pdo_mysql_errorinfo($db, $offset) { - - try { - - /* - If you create a PDOStatement object through PDO->prepare() - or PDO->query() and invoke an error on the statement handle, - PDO->errorCode() will not reflect that error. You must call - PDOStatement->errorCode() to return the error code for an - operation performed on a particular statement handle. - */ - $code = $db->errorCode(); - check_error($offset + 2, $db); - - $stmt = $db->query('SELECT id, label FROM test'); - $stmt2 = &$stmt; - check_error($offset + 3, $db); - check_error($offset + 4, $stmt); - - $db->exec('DROP TABLE IF EXISTS test'); - @$stmt->execute(); - check_error($offset + 5, $db); - check_error($offset + 6, $stmt, '42S02'); - check_error($offset + 7, $stmt2, '42S02'); - - @$stmt = $db->query('SELECT id, label FROM unknown'); - check_error($offset + 8, $db, '42S02'); - - MySQLPDOTest::createTestTable($db); - $stmt = $db->query('SELECT id, label FROM test'); - check_error($offset + 9, $db); - check_error($offset + 10, $stmt); - - $db2 = &$db; - $db->exec('DROP TABLE IF EXISTS unknown'); - @$db->query('SELECT id, label FROM unknown'); - check_error($offset + 11, $db, '42S02'); - check_error($offset + 12, $db2, '42S02'); - check_error($offset + 13, $stmt); - check_error($offset + 14, $stmt2); - - // lets hope this is an invalid attribute code - $invalid_attr = -1 * PHP_INT_MAX + 3; - $tmp = @$db->getAttribute($invalid_attr); - check_error($offset + 15, $db, 'IM001'); - check_error($offset + 16, $db2, 'IM001'); - check_error($offset + 17, $stmt); - check_error($offset + 18, $stmt2); - - } catch (PDOException $e) { - printf("[%03d] %s [%s] %s\n", - $offset + 19, $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - } - - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - printf("Emulated Prepared Statements...\n"); - pdo_mysql_errorinfo($db, 0); - - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - printf("Native Prepared Statements...\n"); - pdo_mysql_errorinfo($db, 20); - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + + function check_error($offset, &$obj, $expected = '00000') { + $info = $obj->errorInfo(); + $code = $info[0]; + + if (($code != $expected) && (($expected != '00000') && ($code != ''))) { + printf("[%03d] Expecting error code '%s' got code '%s'\n", + $offset, $expected, $code); + } + + if ($expected != '00000') { + if (!isset($info[1]) || $info[1] == '') + printf("[%03d] Driver-specific error code not set\n", $offset); + if (!isset($info[2]) || $info[2] == '') + printf("[%03d] Driver-specific error message.not set\n", $offset); + } + + } + + function pdo_mysql_errorinfo($db, $offset) { + + try { + + /* + If you create a PDOStatement object through PDO->prepare() + or PDO->query() and invoke an error on the statement handle, + PDO->errorCode() will not reflect that error. You must call + PDOStatement->errorCode() to return the error code for an + operation performed on a particular statement handle. + */ + $code = $db->errorCode(); + check_error($offset + 2, $db); + + $stmt = $db->query('SELECT id, label FROM test'); + $stmt2 = &$stmt; + check_error($offset + 3, $db); + check_error($offset + 4, $stmt); + + $db->exec('DROP TABLE IF EXISTS test'); + @$stmt->execute(); + check_error($offset + 5, $db); + check_error($offset + 6, $stmt, '42S02'); + check_error($offset + 7, $stmt2, '42S02'); + + @$stmt = $db->query('SELECT id, label FROM unknown'); + check_error($offset + 8, $db, '42S02'); + + MySQLPDOTest::createTestTable($db); + $stmt = $db->query('SELECT id, label FROM test'); + check_error($offset + 9, $db); + check_error($offset + 10, $stmt); + + $db2 = &$db; + $db->exec('DROP TABLE IF EXISTS unknown'); + @$db->query('SELECT id, label FROM unknown'); + check_error($offset + 11, $db, '42S02'); + check_error($offset + 12, $db2, '42S02'); + check_error($offset + 13, $stmt); + check_error($offset + 14, $stmt2); + + // lets hope this is an invalid attribute code + $invalid_attr = -1 * PHP_INT_MAX + 3; + $tmp = @$db->getAttribute($invalid_attr); + check_error($offset + 15, $db, 'IM001'); + check_error($offset + 16, $db2, 'IM001'); + check_error($offset + 17, $stmt); + check_error($offset + 18, $stmt2); + + } catch (PDOException $e) { + printf("[%03d] %s [%s] %s\n", + $offset + 19, $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + } + + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + printf("Emulated Prepared Statements...\n"); + pdo_mysql_errorinfo($db, 0); + + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + printf("Native Prepared Statements...\n"); + pdo_mysql_errorinfo($db, 20); + + print "done!"; ?> --CLEAN-- --FILE-- exec($sql); - if (!is_null($exp) && ($ret !== $exp)) { - printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", - $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - } catch (PDOException $e) { - printf("[%03d] '%s' has failed, [%s] %s\n", - $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - return true; - } - - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - - /* affected rows related */ - try { - - exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); - exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); - exec_and_count(4, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1); - exec_and_count(5, $db, "INSERT INTO test(id, col1) VALUES (2, 'b'), (3, 'c')", 2); - exec_and_count(6, $db, "UPDATE test SET id = 4 WHERE id = 3", 1); - exec_and_count(7, $db, "INSERT INTO test(id, col1) VALUES (1, 'd') ON DUPLICATE KEY UPDATE id = 3", 2); - exec_and_count(8, $db, "UPDATE test SET id = 5 WHERE id = 5", 0); - exec_and_count(9, $db, "INSERT INTO test(id, col1) VALUES (5, 'e') ON DUPLICATE KEY UPDATE id = 6", 1); - exec_and_count(10, $db, "REPLACE INTO test(id, col1) VALUES (5, 'f')", 2); - exec_and_count(11, $db, "REPLACE INTO test(id, col1) VALUES (6, 'g')", 1); - exec_and_count(12, $db, 'DELETE FROM test WHERE id > 2', 4); - exec_and_count(13, $db, 'DROP TABLE test', 0); - exec_and_count(14, $db, 'SET @myvar = 1', 0); - - exec_and_count(15, $db, 'THIS IS NOT VALID SQL, I HOPE', false); - printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); - - exec_and_count(36, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); - exec_and_count(37, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1); - // Results may vary. Typically you will get 1. But the MySQL 5.1 manual states: Truncation operations do not return the number of deleted rows. - // Don't rely on any return value! - exec_and_count(38, $db, 'TRUNCATE TABLE test', NULL); - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } - - - /* CREATE, DROP, CALL SP and SF */ - if (MySQLPDOTest::getServerVersion($db) > 50000) { - // let's try to play with stored procedures - try { - $ignore_exception = true; - exec_and_count(18, $db, 'DROP PROCEDURE IF EXISTS p', 0); - exec_and_count(19, $db, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(255)) BEGIN SELECT VERSION() INTO ver_param; END;', 0); - // we got this far without problems. If there's an issue from now on, its a failure - $ignore_exception = false; - exec_and_count(20, $db, 'CALL p(@version)', 1); - $stmt = $db->query('SELECT @version AS p_version'); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (count($tmp) > 1 || !isset($tmp[0]['p_version'])) { - printf("[022] Data seems wrong, dumping\n"); - var_dump($tmp); - } else { - $p_version = $tmp[0]['p_version']; - } - - $stmt = $db->query('SELECT VERSION() AS _version'); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (count($tmp) > 1 || !isset($tmp[0]['_version'])) { - printf("[023] Data seems wrong, dumping\n"); - var_dump($tmp); - } else { - if ($p_version !== $tmp[0]['_version']) { - printf("[024] Found different version strings, SP returned '%s'/%s, SELECT returned '%s'/%s\n", - $p_version, gettype($p_version), - $tmp[0]['_version'], gettype($tmp[0]['_version'])); - } - } - exec_and_count(25, $db, 'DROP PROCEDURE IF EXISTS p', 0); - - } catch (PDOException $e) { - // ignore it, we might not have sufficient permissions - if (!$ignore_exception) - printf("[021] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } - - // stored function - try { - $ignore_exception = true; - exec_and_count(27, $db, 'DROP FUNCTION IF EXISTS f', 0); - exec_and_count(28, $db, 'CREATE FUNCTION f( ver_param VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC RETURN ver_param;', 0); - // we got this far without problems. If there's an issue from now on, its a failure - $ignore_exception = false; - $stmt = $db->query('SELECT f(VERSION()) AS f_version'); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (count($tmp) > 1 || !isset($tmp[0]['f_version'])) { - printf("[029] Data seems wrong, dumping\n"); - var_dump($tmp); - } else { - $f_version = $tmp[0]['f_version']; - } - $stmt = $db->query('SELECT VERSION() AS _version'); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (count($tmp) > 1 || !isset($tmp[0]['_version'])) { - printf("[030] Data seems wrong, dumping\n"); - var_dump($tmp); - } else { - if ($f_version !== $tmp[0]['_version']) { - printf("[031] Found different version strings, SF returned '%s'/%s, SELECT returned '%s'/%s\n", - $f_version, gettype($f_version), - $tmp[0]['_version'], gettype($tmp[0]['_version'])); - } - } - exec_and_count(32, $db, 'DROP FUNCTION IF EXISTS f', 0); - - } catch (PDOException $e) { - // ignore it, we might not have sufficient permissions - if (!$ignore_exception) - printf("[026] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } - } - - // multi query - try { - - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $exp = 0; - - $tmp = @$db->exec(sprintf('DROP TABLE IF EXISTS test; CREATE TABLE test(id INT) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - if ($exp !== $tmp) - printf("[034] Expecting %s/%s got %s/%s, [%s] %s\n", - $exp, gettype($exp), - $tmp, gettype($tmp), - $db->errorCode(), var_export($db->errorInfo(), true)); - - // this is interesting: if we get sort of affected rows, what will happen now? - $tmp = @$db->exec('INSERT INTO test(id) VALUES (1); INSERT INTO test(id) VALUES (2)'); - printf("[035] With emulated PS it works but makes no sense given that exec() returns sort of affected rows...\n"); - - - } catch (PDOException $e) { - printf("[033] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - - print "done!"; + function exec_and_count($offset, &$db, $sql, $exp = NULL) { + + try { + + $ret = $db->exec($sql); + if (!is_null($exp) && ($ret !== $exp)) { + printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", + $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + } catch (PDOException $e) { + printf("[%03d] '%s' has failed, [%s] %s\n", + $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + return true; + } + + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + + /* affected rows related */ + try { + + exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); + exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); + exec_and_count(4, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1); + exec_and_count(5, $db, "INSERT INTO test(id, col1) VALUES (2, 'b'), (3, 'c')", 2); + exec_and_count(6, $db, "UPDATE test SET id = 4 WHERE id = 3", 1); + exec_and_count(7, $db, "INSERT INTO test(id, col1) VALUES (1, 'd') ON DUPLICATE KEY UPDATE id = 3", 2); + exec_and_count(8, $db, "UPDATE test SET id = 5 WHERE id = 5", 0); + exec_and_count(9, $db, "INSERT INTO test(id, col1) VALUES (5, 'e') ON DUPLICATE KEY UPDATE id = 6", 1); + exec_and_count(10, $db, "REPLACE INTO test(id, col1) VALUES (5, 'f')", 2); + exec_and_count(11, $db, "REPLACE INTO test(id, col1) VALUES (6, 'g')", 1); + exec_and_count(12, $db, 'DELETE FROM test WHERE id > 2', 4); + exec_and_count(13, $db, 'DROP TABLE test', 0); + exec_and_count(14, $db, 'SET @myvar = 1', 0); + + exec_and_count(15, $db, 'THIS IS NOT VALID SQL, I HOPE', false); + printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo())); + + exec_and_count(36, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); + exec_and_count(37, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1); + // Results may vary. Typically you will get 1. But the MySQL 5.1 manual states: Truncation operations do not return the number of deleted rows. + // Don't rely on any return value! + exec_and_count(38, $db, 'TRUNCATE TABLE test', NULL); + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } + + + /* CREATE, DROP, CALL SP and SF */ + if (MySQLPDOTest::getServerVersion($db) > 50000) { + // let's try to play with stored procedures + try { + $ignore_exception = true; + exec_and_count(18, $db, 'DROP PROCEDURE IF EXISTS p', 0); + exec_and_count(19, $db, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(255)) BEGIN SELECT VERSION() INTO ver_param; END;', 0); + // we got this far without problems. If there's an issue from now on, its a failure + $ignore_exception = false; + exec_and_count(20, $db, 'CALL p(@version)', 1); + $stmt = $db->query('SELECT @version AS p_version'); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (count($tmp) > 1 || !isset($tmp[0]['p_version'])) { + printf("[022] Data seems wrong, dumping\n"); + var_dump($tmp); + } else { + $p_version = $tmp[0]['p_version']; + } + + $stmt = $db->query('SELECT VERSION() AS _version'); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (count($tmp) > 1 || !isset($tmp[0]['_version'])) { + printf("[023] Data seems wrong, dumping\n"); + var_dump($tmp); + } else { + if ($p_version !== $tmp[0]['_version']) { + printf("[024] Found different version strings, SP returned '%s'/%s, SELECT returned '%s'/%s\n", + $p_version, gettype($p_version), + $tmp[0]['_version'], gettype($tmp[0]['_version'])); + } + } + exec_and_count(25, $db, 'DROP PROCEDURE IF EXISTS p', 0); + + } catch (PDOException $e) { + // ignore it, we might not have sufficient permissions + if (!$ignore_exception) + printf("[021] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } + + // stored function + try { + $ignore_exception = true; + exec_and_count(27, $db, 'DROP FUNCTION IF EXISTS f', 0); + exec_and_count(28, $db, 'CREATE FUNCTION f( ver_param VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC RETURN ver_param;', 0); + // we got this far without problems. If there's an issue from now on, its a failure + $ignore_exception = false; + $stmt = $db->query('SELECT f(VERSION()) AS f_version'); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (count($tmp) > 1 || !isset($tmp[0]['f_version'])) { + printf("[029] Data seems wrong, dumping\n"); + var_dump($tmp); + } else { + $f_version = $tmp[0]['f_version']; + } + $stmt = $db->query('SELECT VERSION() AS _version'); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (count($tmp) > 1 || !isset($tmp[0]['_version'])) { + printf("[030] Data seems wrong, dumping\n"); + var_dump($tmp); + } else { + if ($f_version !== $tmp[0]['_version']) { + printf("[031] Found different version strings, SF returned '%s'/%s, SELECT returned '%s'/%s\n", + $f_version, gettype($f_version), + $tmp[0]['_version'], gettype($tmp[0]['_version'])); + } + } + exec_and_count(32, $db, 'DROP FUNCTION IF EXISTS f', 0); + + } catch (PDOException $e) { + // ignore it, we might not have sufficient permissions + if (!$ignore_exception) + printf("[026] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } + } + + // multi query + try { + + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + $exp = 0; + + $tmp = @$db->exec(sprintf('DROP TABLE IF EXISTS test; CREATE TABLE test(id INT) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + if ($exp !== $tmp) + printf("[034] Expecting %s/%s got %s/%s, [%s] %s\n", + $exp, gettype($exp), + $tmp, gettype($tmp), + $db->errorCode(), var_export($db->errorInfo(), true)); + + // this is interesting: if we get sort of affected rows, what will happen now? + $tmp = @$db->exec('INSERT INTO test(id) VALUES (1); INSERT INTO test(id) VALUES (2)'); + printf("[035] With emulated PS it works but makes no sense given that exec() returns sort of affected rows...\n"); + + + } catch (PDOException $e) { + printf("[033] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + + print "done!"; ?> --CLEAN-- --FILE-- exec($sql); - else - $ret = $db->exec($sql); + if ($suppress_warning) + $ret = @$db->exec($sql); + else + $ret = $db->exec($sql); - if ($ret !== $exp) { - printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", - $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } + if ($ret !== $exp) { + printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", + $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } - } catch (PDOException $e) { - printf("[%03d] '%s' has failed, [%s] %s\n", - $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } + } catch (PDOException $e) { + printf("[%03d] '%s' has failed, [%s] %s\n", + $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } - return true; - } + return true; + } - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - /* affected rows related */ - try { + /* affected rows related */ + try { - @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl'); - @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2'); - if (1 === @$db->exec('CREATE DATABASE pdo_exec_ddl')) { - // yippie - we can create databases etc. - exec_and_count(3, $db, 'ALTER DATABASE pdo_exec_ddl CHARACTER SET latin1', 1); - } + @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl'); + @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2'); + if (1 === @$db->exec('CREATE DATABASE pdo_exec_ddl')) { + // yippie - we can create databases etc. + exec_and_count(3, $db, 'ALTER DATABASE pdo_exec_ddl CHARACTER SET latin1', 1); + } - exec_and_count(4, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl', 0); - exec_and_count(5, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl2', 0); - if (0 === $db->exec('CREATE TABLE pdo_exec_ddl(id INT, col1 CHAR(2))')) { - exec_and_count(5, $db, 'CREATE INDEX idx1 ON pdo_exec_ddl(id)', 0); - exec_and_count(6, $db, 'DROP INDEX idx1 ON pdo_exec_ddl', 0); - exec_and_count(7, $db, 'ALTER TABLE pdo_exec_ddl DROP id', 0); - exec_and_count(8, $db, 'ALTER TABLE pdo_exec_ddl ADD id INT', 0); - exec_and_count(9, $db, 'ALTER TABLE pdo_exec_ddl ALTER id SET DEFAULT 1', 0); - exec_and_count(10, $db, 'RENAME TABLE pdo_exec_ddl TO pdo_exec_ddl2', 0); - } + exec_and_count(4, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl', 0); + exec_and_count(5, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl2', 0); + if (0 === $db->exec('CREATE TABLE pdo_exec_ddl(id INT, col1 CHAR(2))')) { + exec_and_count(5, $db, 'CREATE INDEX idx1 ON pdo_exec_ddl(id)', 0); + exec_and_count(6, $db, 'DROP INDEX idx1 ON pdo_exec_ddl', 0); + exec_and_count(7, $db, 'ALTER TABLE pdo_exec_ddl DROP id', 0); + exec_and_count(8, $db, 'ALTER TABLE pdo_exec_ddl ADD id INT', 0); + exec_and_count(9, $db, 'ALTER TABLE pdo_exec_ddl ALTER id SET DEFAULT 1', 0); + exec_and_count(10, $db, 'RENAME TABLE pdo_exec_ddl TO pdo_exec_ddl2', 0); + } - /* - 11.1.2. ALTER LOGFILE GROUP Syntax - 11.1.3. ALTER SERVER Syntax - 11.1.5. ALTER TABLESPACE Syntax - 11.1.8. CREATE LOGFILE GROUP Syntax - 11.1.9. CREATE SERVER Syntax - 11.1.11. CREATE TABLESPACE Syntax - 11.1.14. DROP LOGFILE GROUP Syntax - 11.1.15. DROP SERVER Syntax - 11.1.17. DROP TABLESPACE Syntax - */ + /* + 11.1.2. ALTER LOGFILE GROUP Syntax + 11.1.3. ALTER SERVER Syntax + 11.1.5. ALTER TABLESPACE Syntax + 11.1.8. CREATE LOGFILE GROUP Syntax + 11.1.9. CREATE SERVER Syntax + 11.1.11. CREATE TABLESPACE Syntax + 11.1.14. DROP LOGFILE GROUP Syntax + 11.1.15. DROP SERVER Syntax + 11.1.17. DROP TABLESPACE Syntax + */ - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; --CLEAN-- fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { ?> --FILE-- exec($sql); - if ($ret !== $exp) { - printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", - $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - } catch (PDOException $e) { - - if (42000 == $db->errorCode()) { - // Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND) - // Load data infile not allowed - return false; - } - - printf("[%03d] '%s' has failed, [%s] %s\n", - $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - return true; - } - - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); - putenv('PDOTEST_ATTR='.serialize([PDO::MYSQL_ATTR_LOCAL_INFILE=>true])); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - - /* affected rows related */ - try { - - exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); - exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); - - $stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'"); - if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { - $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; - } else { - $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; - } - - $fp = fopen($filename, "w"); - fwrite($fp, "1;foo\n"); - fwrite($fp, "2;bar"); - fclose($fp); - - $sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename)); - - if (exec_and_count(4, $db, $sql, 2)) { - - $stmt = $db->query('SELECT id, col1 FROM test ORDER BY id ASC'); - $expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar")); - $ret = $stmt->fetchAll(PDO::FETCH_ASSOC); - foreach ($expected as $offset => $exp) { - foreach ($exp as $key => $value) { - if ($ret[$offset][$key] != $value) { - printf("Results seem wrong, check manually\n"); - var_dump($ret); - var_dump($expected); - break 2; - } - } - } - } - - unlink($filename); - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + function exec_and_count($offset, &$db, $sql, $exp) { + + try { + + $ret = $db->exec($sql); + if ($ret !== $exp) { + printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", + $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + } catch (PDOException $e) { + + if (42000 == $db->errorCode()) { + // Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND) + // Load data infile not allowed + return false; + } + + printf("[%03d] '%s' has failed, [%s] %s\n", + $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + return true; + } + + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + putenv('PDOTEST_ATTR='.serialize([PDO::MYSQL_ATTR_LOCAL_INFILE=>true])); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + + /* affected rows related */ + try { + + exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); + exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); + + $stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'"); + if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { + $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; + } else { + $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; + } + + $fp = fopen($filename, "w"); + fwrite($fp, "1;foo\n"); + fwrite($fp, "2;bar"); + fclose($fp); + + $sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename)); + + if (exec_and_count(4, $db, $sql, 2)) { + + $stmt = $db->query('SELECT id, col1 FROM test ORDER BY id ASC'); + $expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar")); + $ret = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($expected as $offset => $exp) { + foreach ($exp as $key => $value) { + if ($ret[$offset][$key] != $value) { + printf("Results seem wrong, check manually\n"); + var_dump($ret); + var_dump($expected); + break 2; + } + } + } + } + + unlink($filename); + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- exec($sql); - if ($ret !== $exp) { - printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", - $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } + $ret = $db->exec($sql); + if ($ret !== $exp) { + printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", + $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } - } catch (PDOException $e) { - printf("[%03d] '%s' has failed, [%s] %s\n", - $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } + } catch (PDOException $e) { + printf("[%03d] '%s' has failed, [%s] %s\n", + $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } - return true; - } + return true; + } - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - /* affected rows related */ - try { + /* affected rows related */ + try { - exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); - exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); - exec_and_count(4, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1); - // question is: will the result set be cleaned up, will it be possible to run more queries on the line? - // buffered or unbuffered does not matter! - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - exec_and_count(5, $db, 'SELECT id FROM test', 0); - exec_and_count(6, $db, "INSERT INTO test(id, col1) VALUES (2, 'b')", 1); + exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); + exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); + exec_and_count(4, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1); + // question is: will the result set be cleaned up, will it be possible to run more queries on the line? + // buffered or unbuffered does not matter! + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + exec_and_count(5, $db, 'SELECT id FROM test', 0); + exec_and_count(6, $db, "INSERT INTO test(id, col1) VALUES (2, 'b')", 1); - } catch (PDOException $e) { - printf("[001] %s, [%s] %s\n", - $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s, [%s] %s\n", + $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query('SELECT 1'); - $num = $stmt->fetch(PDO::FETCH_NUM); + try { + $stmt = $db->query('SELECT 1'); + $num = $stmt->fetch(PDO::FETCH_NUM); - $stmt = $db->query('SELECT 1'); - $assoc = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt = $db->query('SELECT 1'); + $assoc = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt = $db->query('SELECT 1'); - $both = $stmt->fetch(PDO::FETCH_BOTH); + $stmt = $db->query('SELECT 1'); + $both = $stmt->fetch(PDO::FETCH_BOTH); - $computed_both = array_merge($num, $assoc); - if ($computed_both != $both) { - printf("[%03d] Suspicious FETCH_BOTH result, dumping\n", $offset); - var_dump($computed_both); - var_dump($both); - } + $computed_both = array_merge($num, $assoc); + if ($computed_both != $both) { + printf("[%03d] Suspicious FETCH_BOTH result, dumping\n", $offset); + var_dump($computed_both); + var_dump($both); + } - if (!is_null($expect) && ($expect != $both)) { - printf("[%03d] Expected differs from returned data, dumping\n", $offset); - var_dump($expect); - var_dump($both); - } + if (!is_null($expect) && ($expect != $both)) { + printf("[%03d] Expected differs from returned data, dumping\n", $offset); + var_dump($expect); + var_dump($both); + } - } catch (PDOException $e) { + } catch (PDOException $e) { - printf("[%03d] %s, [%s] %s\n", - $offset, - $e->getMessage(), $db->errroCode(), implode(' ', $db->errorInfo())); + printf("[%03d] %s, [%s] %s\n", + $offset, + $e->getMessage(), $db->errroCode(), implode(' ', $db->errorInfo())); - } + } - } + } - try { + try { - fetch(2, $db, 'SELECT 1', array(0 => '1', '1' => '1')); + fetch(2, $db, 'SELECT 1', array(0 => '1', '1' => '1')); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt index 51310faa9e28..386dfb1e1eb4 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_get_attribute.phpt @@ -11,60 +11,60 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db)) ?> --FILE-- setAttribute($attribute, $value)) { - printf("[%03d] Cannot set attribute '%s' to value '%s'\n", - $offset, $attribute, var_export($tmp, true)); - return false; - } - - if (gettype($value) != $value_type) { - printf("[%03d] Call to PDO::setAttribute(int attribute, mixed value) has changed the type of value from %s to %s, test will not work properly\n", - $offset, $value_type, gettype($value)); - return false; - } - - $tmp = $db->getAttribute($attribute); - if ($tmp !== $value) { - printf("[%03d] Attribute '%s' was set to '%s'/%s but getAttribute() reports '%s'/%s\n", - $offset, $attribute, var_export($value, true), gettype($value), var_export($tmp, true), gettype($tmp)); - return false; - } - - } catch (PDOException $e) { - printf("[%03d] %s, [%s] %s\n", - $offset, $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - return true; - } - - set_and_get(1, $db, PDO::ATTR_AUTOCOMMIT, 1); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + + function set_and_get($offset, $db, $attribute, $value) { + + $value_type = gettype($value); + try { + + if (!$db->setAttribute($attribute, $value)) { + printf("[%03d] Cannot set attribute '%s' to value '%s'\n", + $offset, $attribute, var_export($tmp, true)); + return false; + } + + if (gettype($value) != $value_type) { + printf("[%03d] Call to PDO::setAttribute(int attribute, mixed value) has changed the type of value from %s to %s, test will not work properly\n", + $offset, $value_type, gettype($value)); + return false; + } + + $tmp = $db->getAttribute($attribute); + if ($tmp !== $value) { + printf("[%03d] Attribute '%s' was set to '%s'/%s but getAttribute() reports '%s'/%s\n", + $offset, $attribute, var_export($value, true), gettype($value), var_export($tmp, true), gettype($tmp)); + return false; + } + + } catch (PDOException $e) { + printf("[%03d] %s, [%s] %s\n", + $offset, $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + return true; + } + + set_and_get(1, $db, PDO::ATTR_AUTOCOMMIT, 1); /* - set_and_get(2, $db, PDO::ATTR_AUTOCOMMIT, 0); - set_and_get(3, $db, PDO::ATTR_AUTOCOMMIT, -1); - $obj = new stdClass(); - set_and_get(4, $db, PDO::ATTR_AUTOCOMMIT, $obj); + set_and_get(2, $db, PDO::ATTR_AUTOCOMMIT, 0); + set_and_get(3, $db, PDO::ATTR_AUTOCOMMIT, -1); + $obj = new stdClass(); + set_and_get(4, $db, PDO::ATTR_AUTOCOMMIT, $obj); - set_and_get(5, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, 1); - set_and_get(6, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, 0); - set_and_get(7, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, -1); - $tmp = array(); - set_and_get(8, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, $tmp); + set_and_get(5, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, 1); + set_and_get(6, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, 0); + set_and_get(7, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, -1); + $tmp = array(); + set_and_get(8, $db, PDO::MYSQL_ATTR_LOCAL_INFILE, $tmp); - set_and_get(9, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, ''); - set_and_get(10, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, 'SOME SQL'); - set_and_get(11, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, -1); + set_and_get(9, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, ''); + set_and_get(10, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, 'SOME SQL'); + set_and_get(11, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, -1); */ /* @@ -87,7 +87,7 @@ PDO::ATTR_CONNECTION_STATUS PDO::ATTR_SERVER_INFO */ - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- true, - 'prepare' => true, - 'beginTransaction' => true, - 'commit' => true, - 'rollBack' => true, - 'setAttribute' => true, - 'exec' => true, - 'query' => true, - 'lastInsertId' => true, - 'errorCode' => true, - 'errorInfo' => true, - 'getAttribute' => true, - 'quote' => true, - 'inTransaction' => true, - 'getAvailableDrivers' => true, - ); - $classname = get_class($db); + $expected = array( + '__construct' => true, + 'prepare' => true, + 'beginTransaction' => true, + 'commit' => true, + 'rollBack' => true, + 'setAttribute' => true, + 'exec' => true, + 'query' => true, + 'lastInsertId' => true, + 'errorCode' => true, + 'errorInfo' => true, + 'getAttribute' => true, + 'quote' => true, + 'inTransaction' => true, + 'getAvailableDrivers' => true, + ); + $classname = get_class($db); - $methods = get_class_methods($classname); - foreach ($methods as $k => $method) { - if (isset($expected[$method])) { - unset($expected[$method]); - unset($methods[$k]); - } - if ($method == $classname) { - unset($expected['__construct']); - unset($methods[$k]); - } - } - if (!empty($expected)) { - printf("Dumping missing class methods\n"); - var_dump($expected); - } - if (!empty($methods)) { - printf("Found more methods than expected, dumping list\n"); - var_dump($methods); - } + $methods = get_class_methods($classname); + foreach ($methods as $k => $method) { + if (isset($expected[$method])) { + unset($expected[$method]); + unset($methods[$k]); + } + if ($method == $classname) { + unset($expected['__construct']); + unset($methods[$k]); + } + } + if (!empty($expected)) { + printf("Dumping missing class methods\n"); + var_dump($expected); + } + if (!empty($methods)) { + printf("Found more methods than expected, dumping list\n"); + var_dump($methods); + } - print "done!"; + print "done!"; --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt index d9dec0bcd3ef..b63ecb2c52e1 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt @@ -9,106 +9,106 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- lastInsertId())) - printf("[001] No query has been run, lastInsertId() should return '0'/string got '%s'/%s\n", - var_export($tmp, true), gettype($tmp)); - - if ('0' !== ($tmp = $db->lastInsertId('sequence_name'))) - printf("[002] MySQL does not support sequences, expecting '0'/string got '%s'/%s\n", - var_export($tmp, true), gettype($tmp)); - - $db->exec('DROP TABLE IF EXISTS test'); - if ('0' !== ($tmp = $db->lastInsertId())) - printf("[003] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - $db->exec(sprintf('CREATE TABLE test(id INT, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - if ('0' !== ($tmp = $db->lastInsertId())) - printf("[004] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - $stmt = $db->query('SELECT id FROM test LIMIT 1'); - if ('0' !== ($tmp = $db->lastInsertId())) - printf("[005] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - // no auto increment column - $db->exec("INSERT INTO test(id, col1) VALUES (100, 'a')"); - if ('0' !== ($tmp = $db->lastInsertId())) - printf("[006] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - $db->exec('ALTER TABLE test MODIFY id INT AUTO_INCREMENT PRIMARY KEY'); - if ('0' !== ($tmp = $db->lastInsertId())) - printf("[006] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - // duplicate key - @$db->exec("INSERT INTO test(id, col1) VALUES (100, 'a')"); - if ('0' !== ($tmp = $db->lastInsertId())) - printf("[007] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - $db->exec("INSERT INTO test(id, col1) VALUES (101, 'b')"); - if ('101' !== ($tmp = $db->lastInsertId())) - printf("[008] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); - - $db->exec('ALTER TABLE test MODIFY col1 CHAR(10) UNIQUE'); - // replace = delete + insert -> new auto increment value - $db->exec("REPLACE INTO test(col1) VALUES ('b')"); - $next_id = (int)$db->lastInsertId(); - - if ($next_id <= 101) - printf("[009] Expecting at least 102, got %d\n",$next_id); - - $stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $last_id = $row['_last_id']; - if ($next_id != $last_id) { - printf("[010] LAST_INSERT_ID() = %d and lastInserId() = %d differ\n", - $last_id, $next_id); - } - - $db->exec("INSERT INTO test(col1) VALUES ('c'), ('d'), ('e')"); - $next_id = (int)$db->lastInsertId(); - if ($next_id <= $last_id) - printf("[011] Expecting at least %d, got %d\n", $last_id + 1, $next_id); - - // warnings are unhandy, lets go for exceptions for a second - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - try { - $ignore_exception = true; - $db->exec('LOCK TABLE test WRITE'); - $ignore_exception = false; - - if (MySQLPDOTest::getServerVersion($db) >= 50000) { - $stmt = $db->query('SELECT @@auto_increment_increment AS inc'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $inc = $row['inc']; - } else { - $inc = 1; - } - - $stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $last_id = $row['_last_id']; - - $db->exec("INSERT INTO test(col1) VALUES ('z')"); - $next_id = (int)$db->lastInsertId(); - if ($next_id < ($last_id + $inc)) - printf("[012] Expecting at least %d, got %d\n", $last_id + $inc, $next_id); - - } catch (PDOException $e) { - if (!$ignore_exception) - printf("[014] %s, [%s} %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - @$db->exec('UNLOCK TABLE test'); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + try { + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[001] No query has been run, lastInsertId() should return '0'/string got '%s'/%s\n", + var_export($tmp, true), gettype($tmp)); + + if ('0' !== ($tmp = $db->lastInsertId('sequence_name'))) + printf("[002] MySQL does not support sequences, expecting '0'/string got '%s'/%s\n", + var_export($tmp, true), gettype($tmp)); + + $db->exec('DROP TABLE IF EXISTS test'); + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[003] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + $db->exec(sprintf('CREATE TABLE test(id INT, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[004] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + $stmt = $db->query('SELECT id FROM test LIMIT 1'); + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[005] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + // no auto increment column + $db->exec("INSERT INTO test(id, col1) VALUES (100, 'a')"); + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[006] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + $db->exec('ALTER TABLE test MODIFY id INT AUTO_INCREMENT PRIMARY KEY'); + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[006] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + // duplicate key + @$db->exec("INSERT INTO test(id, col1) VALUES (100, 'a')"); + if ('0' !== ($tmp = $db->lastInsertId())) + printf("[007] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + $db->exec("INSERT INTO test(id, col1) VALUES (101, 'b')"); + if ('101' !== ($tmp = $db->lastInsertId())) + printf("[008] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp)); + + $db->exec('ALTER TABLE test MODIFY col1 CHAR(10) UNIQUE'); + // replace = delete + insert -> new auto increment value + $db->exec("REPLACE INTO test(col1) VALUES ('b')"); + $next_id = (int)$db->lastInsertId(); + + if ($next_id <= 101) + printf("[009] Expecting at least 102, got %d\n",$next_id); + + $stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $last_id = $row['_last_id']; + if ($next_id != $last_id) { + printf("[010] LAST_INSERT_ID() = %d and lastInserId() = %d differ\n", + $last_id, $next_id); + } + + $db->exec("INSERT INTO test(col1) VALUES ('c'), ('d'), ('e')"); + $next_id = (int)$db->lastInsertId(); + if ($next_id <= $last_id) + printf("[011] Expecting at least %d, got %d\n", $last_id + 1, $next_id); + + // warnings are unhandy, lets go for exceptions for a second + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + try { + $ignore_exception = true; + $db->exec('LOCK TABLE test WRITE'); + $ignore_exception = false; + + if (MySQLPDOTest::getServerVersion($db) >= 50000) { + $stmt = $db->query('SELECT @@auto_increment_increment AS inc'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $inc = $row['inc']; + } else { + $inc = 1; + } + + $stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $last_id = $row['_last_id']; + + $db->exec("INSERT INTO test(col1) VALUES ('z')"); + $next_id = (int)$db->lastInsertId(); + if ($next_id < ($last_id + $inc)) + printf("[012] Expecting at least %d, got %d\n", $last_id + $inc, $next_id); + + } catch (PDOException $e) { + if (!$ignore_exception) + printf("[014] %s, [%s} %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); + @$db->exec('UNLOCK TABLE test'); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($db); - function test_proc($db) { + function test_proc($db) { - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN SELECT id FROM test ORDER BY id ASC LIMIT 3; SELECT id, label FROM test WHERE id < 4 ORDER BY id DESC LIMIT 3; END;'); - $stmt = $db->query('CALL p()'); - do { - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } while ($stmt->nextRowSet()); - var_dump($stmt->nextRowSet()); + $db->exec('DROP PROCEDURE IF EXISTS p'); + $db->exec('CREATE PROCEDURE p() BEGIN SELECT id FROM test ORDER BY id ASC LIMIT 3; SELECT id, label FROM test WHERE id < 4 ORDER BY id DESC LIMIT 3; END;'); + $stmt = $db->query('CALL p()'); + do { + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + } while ($stmt->nextRowSet()); + var_dump($stmt->nextRowSet()); - } + } - try { + try { - // Using native PS for proc, since emulated fails. - printf("Native PS...\n"); - foreach (array(false, true) as $multi) { - $value = $multi ? 'true' : 'false'; - echo "\nTesting with PDO::MYSQL_ATTR_MULTI_STATEMENTS set to {$value}\n"; - $dsn = MySQLPDOTest::getDSN(); - $user = PDO_MYSQL_TEST_USER; - $pass = PDO_MYSQL_TEST_PASS; - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => $multi)); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - test_proc($db); + // Using native PS for proc, since emulated fails. + printf("Native PS...\n"); + foreach (array(false, true) as $multi) { + $value = $multi ? 'true' : 'false'; + echo "\nTesting with PDO::MYSQL_ATTR_MULTI_STATEMENTS set to {$value}\n"; + $dsn = MySQLPDOTest::getDSN(); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => $multi)); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + test_proc($db); - $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => $multi)); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + $db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => $multi)); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - test_proc($db); + test_proc($db); - // Switch back to emulated prepares to verify multi statement attribute. - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - // This will fail when $multi is false. - $stmt = $db->query("SELECT * FROM test; INSERT INTO test (id, label) VALUES (99, 'x')"); - if ($stmt !== false) { - $stmt->closeCursor(); - } - $info = $db->errorInfo(); - var_dump($info[0]); - } - @$db->exec('DROP PROCEDURE IF EXISTS p'); + // Switch back to emulated prepares to verify multi statement attribute. + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + // This will fail when $multi is false. + $stmt = $db->query("SELECT * FROM test; INSERT INTO test (id, label) VALUES (99, 'x')"); + if ($stmt !== false) { + $stmt->closeCursor(); + } + $info = $db->errorInfo(); + var_dump($info[0]); + } + @$db->exec('DROP PROCEDURE IF EXISTS p'); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- execute(); var_dump($db->query('SELECT * from test')); foreach ($db->query('SELECT * from test') as $row) { - print_r($row); + print_r($row); } ?> diff --git a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt index 3656e71a0c74..4d95c73cdc7b 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_pconnect.phpt @@ -8,92 +8,92 @@ MySQLPDOTest::skip(); ?> --FILE-- true)); - $db2 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); - $db1->exec('SET @pdo_persistent_connection=1'); - $stmt = $db2->query('SELECT @pdo_persistent_connection as _pers'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - if ($tmp['_pers'] !== '1') - printf("[001] Both handles should use the same connection."); - - $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $con1 = $tmp['_con1']; - - $stmt = $db2->query('SELECT CONNECTION_ID() as _con2'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $con2 = $tmp['_con2']; - - if ($con1 !== $con2) - printf("[002] Both handles should report the same MySQL thread ID"); - - $db1 = NULL; /* should be equal to closing to my understanding */ - $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); - $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $con1 = $tmp['_con1']; - - if ($con1 !== $con2) - printf("[003] Both handles should report the same MySQL thread ID"); - - $affected = $db1->exec(sprintf('KILL %d', $con1)); - // Server needs some think-time sometimes - sleep(1); - if ('00000' == $db1->errorCode()) { - // looks like KILL has worked ? Or not... TODO: why no warning with libmysql?! - @$db1->exec("SET @pdo_persistent_connection=2"); - // but now I want to see some error... - if ('HY000' != $db1->errorCode()) - printf("[004] Wrong error code %s\n", $db1->errorCode()); - - $tmp = implode(' ', $db1->errorInfo()); - if (!strstr($tmp, '2006')) - printf("[005] Wrong error info %s\n", $tmp); - } - - $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => false)); - $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $con1 = $tmp['_con1']; - - @$db2 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); - $stmt = $db2->query('SELECT CONNECTION_ID() as _con2'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - $con2 = $tmp['_con2']; - - if ($con1 == $con2) - printf("[006] Looks like the persistent and the non persistent connection are using the same link?!\n"); - - // lets go crazy and create a few pconnections... - $connections = array(); - for ($i = 0; $i <= 20; $i++) { - $connections[$i] = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); - } - do { - $i = mt_rand(0, 20); - if (isset($connections[$i])) - unset($connections[$i]); - } while (!empty($connections)); - - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s [%s] %s\n", - $e->getMessage(), - (is_object($db1)) ? $db1->errorCode() : 'n/a', - (is_object($db1)) ? implode(' ', $db1->errorInfo()) : 'n/a', - (is_object($db2)) ? $db2->errorCode() : 'n/a', - (is_object($db2)) ? implode(' ', $db2->errorInfo()) : 'n/a'); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + try { + + $dsn = MySQLPDOTest::getDSN(); + $user = PDO_MYSQL_TEST_USER; + $pass = PDO_MYSQL_TEST_PASS; + + $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + $db2 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + $db1->exec('SET @pdo_persistent_connection=1'); + $stmt = $db2->query('SELECT @pdo_persistent_connection as _pers'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + if ($tmp['_pers'] !== '1') + printf("[001] Both handles should use the same connection."); + + $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $con1 = $tmp['_con1']; + + $stmt = $db2->query('SELECT CONNECTION_ID() as _con2'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $con2 = $tmp['_con2']; + + if ($con1 !== $con2) + printf("[002] Both handles should report the same MySQL thread ID"); + + $db1 = NULL; /* should be equal to closing to my understanding */ + $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $con1 = $tmp['_con1']; + + if ($con1 !== $con2) + printf("[003] Both handles should report the same MySQL thread ID"); + + $affected = $db1->exec(sprintf('KILL %d', $con1)); + // Server needs some think-time sometimes + sleep(1); + if ('00000' == $db1->errorCode()) { + // looks like KILL has worked ? Or not... TODO: why no warning with libmysql?! + @$db1->exec("SET @pdo_persistent_connection=2"); + // but now I want to see some error... + if ('HY000' != $db1->errorCode()) + printf("[004] Wrong error code %s\n", $db1->errorCode()); + + $tmp = implode(' ', $db1->errorInfo()); + if (!strstr($tmp, '2006')) + printf("[005] Wrong error info %s\n", $tmp); + } + + $db1 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => false)); + $stmt = $db1->query('SELECT CONNECTION_ID() as _con1'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $con1 = $tmp['_con1']; + + @$db2 = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + $stmt = $db2->query('SELECT CONNECTION_ID() as _con2'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + $con2 = $tmp['_con2']; + + if ($con1 == $con2) + printf("[006] Looks like the persistent and the non persistent connection are using the same link?!\n"); + + // lets go crazy and create a few pconnections... + $connections = array(); + for ($i = 0; $i <= 20; $i++) { + $connections[$i] = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true)); + } + do { + $i = mt_rand(0, 20); + if (isset($connections[$i])) + unset($connections[$i]); + } while (!empty($connections)); + + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s [%s] %s\n", + $e->getMessage(), + (is_object($db1)) ? $db1->errorCode() : 'n/a', + (is_object($db1)) ? implode(' ', $db1->errorInfo()) : 'n/a', + (is_object($db2)) ? $db2->errorCode() : 'n/a', + (is_object($db2)) ? implode(' ', $db2->errorInfo()) : 'n/a'); + } + + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt index a230b3c19f18..e44f1d2a5269 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt @@ -9,22 +9,22 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- 6.0.3-alpha */ - $reg = 'Client API version.*' . preg_quote($db->getAttribute(PDO::ATTR_CLIENT_VERSION), '/'); + /* PDO Driver for MySQL, client library version => 6.0.3-alpha */ + $reg = 'Client API version.*' . preg_quote($db->getAttribute(PDO::ATTR_CLIENT_VERSION), '/'); - if (!preg_match("/$reg/", $tmp)) { - printf("[001] Cannot find MySQL PDO driver line in phpinfo() output\n"); - } + if (!preg_match("/$reg/", $tmp)) { + printf("[001] Cannot find MySQL PDO driver line in phpinfo() output\n"); + } - print "done!"; + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt index 8db812ee19ae..6fe2ff20ba61 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt @@ -9,314 +9,314 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- prepare($query); - else - $stmt = $db->prepare($query); - - if (is_array($error_info) && isset($error_info['prepare'])) { - $tmp = $db->errorInfo(); - - if (isset($error_info['prepare']['sqlstate']) && - ($error_info['prepare']['sqlstate'] !== $tmp[0])) { - printf("[%03d] prepare() - expecting SQLSTATE '%s' got '%s'\n", - $offset, $error_info['prepare']['sqlstate'], $tmp[0]); - return false; - } - - if (isset($error_info['prepare']['mysql']) && - ($error_info['prepare']['mysql'] !== $tmp[1])) { - printf("[%03d] prepare() - expecting MySQL Code '%s' got '%s'\n", - $offset, $error_info['prepare']['mysql'], $tmp[0]); - return false; - } - - return false; - } - - if (is_null($input_params)) - $input_params = array(); - - if (is_array($error_info) && isset($error_info['execute'])) - $ret = @$stmt->execute($input_params); - else - $ret = $stmt->execute($input_params); - - if (!is_bool($ret)) - printf("[%03d] PDO::execute() should return a boolean value, got %s/%s\n", - var_export($ret, true), $ret); - - if (is_array($error_info) && isset($error_info['execute'])) { - $tmp = $stmt->errorInfo(); - - if (isset($error_info['execute']['sqlstate']) && - ($error_info['execute']['sqlstate'] !== $tmp[0])) { - printf("[%03d] execute() - expecting SQLSTATE '%s' got '%s'\n", - $offset, $error_info['execute']['sqlstate'], $tmp[0]); - return false; - } - - if (isset($error_info['execute']['mysql']) && - ($error_info['execute']['mysql'] !== $tmp[1])) { - printf("[%03d] execute() - expecting MySQL Code '%s' got '%s'\n", - $offset, $error_info['execute']['mysql'], $tmp[0]); - return false; - } - - return false; - } - - } catch (PDOException $e) { - printf("[%03d] %s, [%s} %s\n", - $offset, $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - return $stmt; - } - - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); - - // TODO - that's PDO - you can prepare empty statements! - prepex(3, $db, '', - array(), array('execute' => array('sqlstate' => '42000'))); - - // lets be fair and do the most simple SELECT first - $stmt = prepex(4, $db, 'SELECT 1 as "one"'); - var_dump($stmt->fetch(PDO::FETCH_ASSOC)); - - prepex(5, $db, 'DROP TABLE IF EXISTS test'); - prepex(6, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - prepex(7, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')"); - $stmt = prepex(8, $db, 'SELECT label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - prepex(9, $db, 'DELETE FROM test'); - prepex(10, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')", - array(':placeholder' => 'first row')); - $stmt = prepex(11, $db, 'SELECT label FROM test'); - - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - prepex(12, $db, 'DELETE FROM test'); - prepex(13, $db, 'INSERT INTO test(id, label) VALUES(1, :placeholder)', - array(':placeholder' => 'first row')); - prepex(14, $db, 'INSERT INTO test(id, label) VALUES(2, :placeholder)', - array(':placeholder' => 'second row')); - $stmt = prepex(15, $db, 'SELECT label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // Is PDO fun? - prepex(16, $db, 'SELECT label FROM test WHERE :placeholder > 1', - array(':placeholder' => 'id')); - prepex(17, $db, 'SELECT :placeholder FROM test WHERE id > 1', - array(':placeholder' => 'id')); - prepex(18, $db, 'SELECT :placeholder FROM test WHERE :placeholder > :placeholder', - array(':placeholder' => 'test')); - - for ($num_params = 2; $num_params < 100; $num_params++) { - $params = array(':placeholder' => 'a'); - for ($i = 1; $i < $num_params; $i++) { - $params[str_repeat('a', $i)] = 'some data'; - } - prepex(19, $db, 'SELECT id, label FROM test WHERE label > :placeholder', - $params, array('execute' => array('sqlstate' => 'HY093'))); - } - - prepex(20, $db, 'DELETE FROM test'); - prepex(21, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder), (2, :placeholder)', - array(':placeholder' => 'row')); - $stmt = prepex(22, $db, 'SELECT id, label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - $stmt = prepex(23, $db, 'SELECT id, label FROM test WHERE :placeholder IS NOT NULL', - array(':placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[024] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); - - $stmt = prepex(25, $db, 'SELECT id, label FROM test WHERE :placeholder IS NULL', - array(':placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[026] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); - - prepex(27, $db, 'DROP TABLE IF EXISTS test'); - prepex(28, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); - if (is_object(prepex(29, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)'))) { - prepex(30, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder)', - array(':placeholder' => 'MySQL is the best database in the world!')); - prepex(31, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder)', - array(':placeholder' => 'If I have the freedom to choose, I would always go again for the MySQL Server')); - $stmt = prepex(32, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)', - array(':placeholder' => 'mysql')); - /* - Lets ignore this - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[033] Expecting two rows, got %d rows\n", $tmp); - */ - } - prepex(34, $db, 'DELETE FROM test'); - prepex(35, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder), (2, :placeholder)', - array(':placeholder' => 'row')); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + function prepex($offset, &$db, $query, $input_params = null, $error_info = null) { + + try { + + if (is_array($error_info) && isset($error_info['prepare'])) + $stmt = @$db->prepare($query); + else + $stmt = $db->prepare($query); + + if (is_array($error_info) && isset($error_info['prepare'])) { + $tmp = $db->errorInfo(); + + if (isset($error_info['prepare']['sqlstate']) && + ($error_info['prepare']['sqlstate'] !== $tmp[0])) { + printf("[%03d] prepare() - expecting SQLSTATE '%s' got '%s'\n", + $offset, $error_info['prepare']['sqlstate'], $tmp[0]); + return false; + } + + if (isset($error_info['prepare']['mysql']) && + ($error_info['prepare']['mysql'] !== $tmp[1])) { + printf("[%03d] prepare() - expecting MySQL Code '%s' got '%s'\n", + $offset, $error_info['prepare']['mysql'], $tmp[0]); + return false; + } + + return false; + } + + if (is_null($input_params)) + $input_params = array(); + + if (is_array($error_info) && isset($error_info['execute'])) + $ret = @$stmt->execute($input_params); + else + $ret = $stmt->execute($input_params); + + if (!is_bool($ret)) + printf("[%03d] PDO::execute() should return a boolean value, got %s/%s\n", + var_export($ret, true), $ret); + + if (is_array($error_info) && isset($error_info['execute'])) { + $tmp = $stmt->errorInfo(); + + if (isset($error_info['execute']['sqlstate']) && + ($error_info['execute']['sqlstate'] !== $tmp[0])) { + printf("[%03d] execute() - expecting SQLSTATE '%s' got '%s'\n", + $offset, $error_info['execute']['sqlstate'], $tmp[0]); + return false; + } + + if (isset($error_info['execute']['mysql']) && + ($error_info['execute']['mysql'] !== $tmp[1])) { + printf("[%03d] execute() - expecting MySQL Code '%s' got '%s'\n", + $offset, $error_info['execute']['mysql'], $tmp[0]); + return false; + } + + return false; + } + + } catch (PDOException $e) { + printf("[%03d] %s, [%s} %s\n", + $offset, $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + return $stmt; + } + + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); + + // TODO - that's PDO - you can prepare empty statements! + prepex(3, $db, '', + array(), array('execute' => array('sqlstate' => '42000'))); + + // lets be fair and do the most simple SELECT first + $stmt = prepex(4, $db, 'SELECT 1 as "one"'); + var_dump($stmt->fetch(PDO::FETCH_ASSOC)); + + prepex(5, $db, 'DROP TABLE IF EXISTS test'); + prepex(6, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + prepex(7, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')"); + $stmt = prepex(8, $db, 'SELECT label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + prepex(9, $db, 'DELETE FROM test'); + prepex(10, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')", + array(':placeholder' => 'first row')); + $stmt = prepex(11, $db, 'SELECT label FROM test'); + + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + prepex(12, $db, 'DELETE FROM test'); + prepex(13, $db, 'INSERT INTO test(id, label) VALUES(1, :placeholder)', + array(':placeholder' => 'first row')); + prepex(14, $db, 'INSERT INTO test(id, label) VALUES(2, :placeholder)', + array(':placeholder' => 'second row')); + $stmt = prepex(15, $db, 'SELECT label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // Is PDO fun? + prepex(16, $db, 'SELECT label FROM test WHERE :placeholder > 1', + array(':placeholder' => 'id')); + prepex(17, $db, 'SELECT :placeholder FROM test WHERE id > 1', + array(':placeholder' => 'id')); + prepex(18, $db, 'SELECT :placeholder FROM test WHERE :placeholder > :placeholder', + array(':placeholder' => 'test')); + + for ($num_params = 2; $num_params < 100; $num_params++) { + $params = array(':placeholder' => 'a'); + for ($i = 1; $i < $num_params; $i++) { + $params[str_repeat('a', $i)] = 'some data'; + } + prepex(19, $db, 'SELECT id, label FROM test WHERE label > :placeholder', + $params, array('execute' => array('sqlstate' => 'HY093'))); + } + + prepex(20, $db, 'DELETE FROM test'); + prepex(21, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder), (2, :placeholder)', + array(':placeholder' => 'row')); + $stmt = prepex(22, $db, 'SELECT id, label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + $stmt = prepex(23, $db, 'SELECT id, label FROM test WHERE :placeholder IS NOT NULL', + array(':placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[024] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); + + $stmt = prepex(25, $db, 'SELECT id, label FROM test WHERE :placeholder IS NULL', + array(':placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[026] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); + + prepex(27, $db, 'DROP TABLE IF EXISTS test'); + prepex(28, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); + if (is_object(prepex(29, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)'))) { + prepex(30, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder)', + array(':placeholder' => 'MySQL is the best database in the world!')); + prepex(31, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder)', + array(':placeholder' => 'If I have the freedom to choose, I would always go again for the MySQL Server')); + $stmt = prepex(32, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)', + array(':placeholder' => 'mysql')); + /* + Lets ignore this + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[033] Expecting two rows, got %d rows\n", $tmp); + */ + } + prepex(34, $db, 'DELETE FROM test'); + prepex(35, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder), (2, :placeholder)', + array(':placeholder' => 'row')); /* - $stmt = prepex(36, $db, 'SELECT id, label FROM "test WHERE MATCH label AGAINST (:placeholder)', - array(':placeholder' => 'row'), - array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); + $stmt = prepex(36, $db, 'SELECT id, label FROM "test WHERE MATCH label AGAINST (:placeholder)', + array(':placeholder' => 'row'), + array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); */ - $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', - array(':placeholder' => 'row'), - array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); - - $stmt = prepex(38, $db, 'SELECT id, label AS "label" FROM test WHERE label = :placeholder', - array(':placeholder' => 'row')); - - $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = :placeholder)", - $db->quote('%ro%')); - $stmt = prepex(39, $db, $sql, array('placeholder' => -1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[040] Expecting zero rows, got %d rows\n", $tmp); - - - $sql = sprintf("SELECT id, label FROM test WHERE (id = :placeholder) OR (label LIKE %s)", - $db->quote('%ro%')); - $stmt = prepex(41, $db, $sql, array('placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[042] Expecting two rows, got %d rows\n", $tmp); - - $sql = "SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = :placeholder)"; - $stmt = prepex(43, $db, $sql, array('placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) - printf("[044] Expecting onw row, got %d rows\n", $tmp); - - // and now, the same with anonymous placeholders... - prepex(45, $db, 'DROP TABLE IF EXISTS test'); - prepex(46, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - prepex(47, $db, "INSERT INTO test(id, label) VALUES(1, '?')"); - $stmt = prepex(48, $db, 'SELECT label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - prepex(49, $db, 'DELETE FROM test'); - prepex(50, $db, "INSERT INTO test(id, label) VALUES(1, '?')", - array('first row')); - $stmt = prepex(51, $db, 'SELECT label FROM test'); - - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - prepex(52, $db, 'DELETE FROM test'); - prepex(53, $db, 'INSERT INTO test(id, label) VALUES(1, ?)', - array('first row')); - prepex(54, $db, 'INSERT INTO test(id, label) VALUES(2, ?)', - array('second row')); - $stmt = prepex(55, $db, 'SELECT label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // Is PDO fun? - prepex(56, $db, 'SELECT label FROM test WHERE ? > 1', - array('id')); - prepex(57, $db, 'SELECT ? FROM test WHERE id > 1', - array('id')); - prepex(58, $db, 'SELECT ? FROM test WHERE ? > ?', - array('test'), array('execute' => array('sqlstate' => 'HY093'))); - - prepex(59, $db, 'SELECT ? FROM test WHERE ? > ?', - array('id', 'label', 'value')); - - for ($num_params = 2; $num_params < 100; $num_params++) { - $params = array('a'); - for ($i = 1; $i < $num_params; $i++) { - $params[] = 'some data'; - } - prepex(60, $db, 'SELECT id, label FROM test WHERE label > ?', - $params, array('execute' => array('sqlstate' => 'HY093'))); - } - - prepex(61, $db, 'DELETE FROM test'); - prepex(62, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', - array('row', 'row')); - $stmt = prepex(63, $db, 'SELECT id, label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - $stmt = prepex(64, $db, 'SELECT id, label FROM test WHERE ? IS NOT NULL', - array(1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[065] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); - - $stmt = prepex(66, $db, 'SELECT id, label FROM test WHERE ? IS NULL', - array(1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[067] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); - - prepex(68, $db, 'DROP TABLE IF EXISTS test'); - prepex(69, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); - if (is_object(prepex(70, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)'))) { - prepex(71, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', - array('MySQL is the best database in the world!')); - prepex(72, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', - array('If I have the freedom to choose, I would always go again for the MySQL Server')); - $stmt = prepex(73, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (?)', - array('mysql')); - /* - Lets ignore that - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[074] Expecting two rows, got %d rows\n", $tmp); - */ - } - - prepex(74, $db, 'DELETE FROM test'); - prepex(75, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', - array('row', 'row')); - - $stmt = prepex(76, $db, 'SELECT id, label FROM "test WHERE MATCH label AGAINST (?)', - array('row'), - array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); - - /* - TODO enable after fix - $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', - array(':placeholder' => 'row'), - array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); - */ - - $stmt = prepex(78, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', - array('row')); - - $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", - $db->quote('%ro%')); - $stmt = prepex(79, $db, $sql, array(-1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[080] Expecting zero rows, got %d rows\n", $tmp); - - - $sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", - $db->quote('%ro%')); - $stmt = prepex(81, $db, $sql, array(1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[082] Expecting two rows, got %d rows\n", $tmp); - - $sql = "SELECT id, label FROM test WHERE id = ? AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; - $stmt = prepex(83, $db, $sql, array(1, 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) - printf("[084] Expecting one row, got %d rows\n", $tmp); - - $sql = "SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; - $stmt = prepex(85, $db, $sql, array(1, 1), array('execute' => array('sqlstate' => 'HY093'))); - if (is_object($stmt) && count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[086] Expecting no rows, got %d rows\n", $tmp); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', + array(':placeholder' => 'row'), + array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); + + $stmt = prepex(38, $db, 'SELECT id, label AS "label" FROM test WHERE label = :placeholder', + array(':placeholder' => 'row')); + + $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = :placeholder)", + $db->quote('%ro%')); + $stmt = prepex(39, $db, $sql, array('placeholder' => -1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[040] Expecting zero rows, got %d rows\n", $tmp); + + + $sql = sprintf("SELECT id, label FROM test WHERE (id = :placeholder) OR (label LIKE %s)", + $db->quote('%ro%')); + $stmt = prepex(41, $db, $sql, array('placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[042] Expecting two rows, got %d rows\n", $tmp); + + $sql = "SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = :placeholder)"; + $stmt = prepex(43, $db, $sql, array('placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) + printf("[044] Expecting onw row, got %d rows\n", $tmp); + + // and now, the same with anonymous placeholders... + prepex(45, $db, 'DROP TABLE IF EXISTS test'); + prepex(46, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + prepex(47, $db, "INSERT INTO test(id, label) VALUES(1, '?')"); + $stmt = prepex(48, $db, 'SELECT label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + prepex(49, $db, 'DELETE FROM test'); + prepex(50, $db, "INSERT INTO test(id, label) VALUES(1, '?')", + array('first row')); + $stmt = prepex(51, $db, 'SELECT label FROM test'); + + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + prepex(52, $db, 'DELETE FROM test'); + prepex(53, $db, 'INSERT INTO test(id, label) VALUES(1, ?)', + array('first row')); + prepex(54, $db, 'INSERT INTO test(id, label) VALUES(2, ?)', + array('second row')); + $stmt = prepex(55, $db, 'SELECT label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // Is PDO fun? + prepex(56, $db, 'SELECT label FROM test WHERE ? > 1', + array('id')); + prepex(57, $db, 'SELECT ? FROM test WHERE id > 1', + array('id')); + prepex(58, $db, 'SELECT ? FROM test WHERE ? > ?', + array('test'), array('execute' => array('sqlstate' => 'HY093'))); + + prepex(59, $db, 'SELECT ? FROM test WHERE ? > ?', + array('id', 'label', 'value')); + + for ($num_params = 2; $num_params < 100; $num_params++) { + $params = array('a'); + for ($i = 1; $i < $num_params; $i++) { + $params[] = 'some data'; + } + prepex(60, $db, 'SELECT id, label FROM test WHERE label > ?', + $params, array('execute' => array('sqlstate' => 'HY093'))); + } + + prepex(61, $db, 'DELETE FROM test'); + prepex(62, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', + array('row', 'row')); + $stmt = prepex(63, $db, 'SELECT id, label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + $stmt = prepex(64, $db, 'SELECT id, label FROM test WHERE ? IS NOT NULL', + array(1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[065] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); + + $stmt = prepex(66, $db, 'SELECT id, label FROM test WHERE ? IS NULL', + array(1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[067] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); + + prepex(68, $db, 'DROP TABLE IF EXISTS test'); + prepex(69, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); + if (is_object(prepex(70, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)'))) { + prepex(71, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', + array('MySQL is the best database in the world!')); + prepex(72, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', + array('If I have the freedom to choose, I would always go again for the MySQL Server')); + $stmt = prepex(73, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (?)', + array('mysql')); + /* + Lets ignore that + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[074] Expecting two rows, got %d rows\n", $tmp); + */ + } + + prepex(74, $db, 'DELETE FROM test'); + prepex(75, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', + array('row', 'row')); + + $stmt = prepex(76, $db, 'SELECT id, label FROM "test WHERE MATCH label AGAINST (?)', + array('row'), + array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); + + /* + TODO enable after fix + $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', + array(':placeholder' => 'row'), + array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); + */ + + $stmt = prepex(78, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', + array('row')); + + $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", + $db->quote('%ro%')); + $stmt = prepex(79, $db, $sql, array(-1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[080] Expecting zero rows, got %d rows\n", $tmp); + + + $sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", + $db->quote('%ro%')); + $stmt = prepex(81, $db, $sql, array(1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[082] Expecting two rows, got %d rows\n", $tmp); + + $sql = "SELECT id, label FROM test WHERE id = ? AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; + $stmt = prepex(83, $db, $sql, array(1, 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) + printf("[084] Expecting one row, got %d rows\n", $tmp); + + $sql = "SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; + $stmt = prepex(85, $db, $sql, array(1, 1), array('execute' => array('sqlstate' => 'HY093'))); + if (is_object($stmt) && count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[086] Expecting no rows, got %d rows\n", $tmp); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to switch to emulated prepared statements, test will fail\n"); - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - $stmt = $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')"); - // you can bind as many values as you want no matter if they can be replaced or not - $stmt->execute(array('first row')); - if ('00000' !== $stmt->errorCode()) - printf("[003] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + $stmt = $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')"); + // you can bind as many values as you want no matter if they can be replaced or not + $stmt->execute(array('first row')); + if ('00000' !== $stmt->errorCode()) + printf("[003] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - $stmt = $db->prepare('SELECT id, label FROM test'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // now the same with native PS - printf("now the same with native PS\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to switch off emulated prepared statements, test will fail\n"); + // now the same with native PS + printf("now the same with native PS\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to switch off emulated prepared statements, test will fail\n"); - $db->exec('DELETE FROM test'); - $stmt = $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')"); - // you can bind as many values as you want no matter if they can be replaced or not - $stmt->execute(array('first row')); - if ('00000' !== $stmt->errorCode()) - printf("[005] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + $db->exec('DELETE FROM test'); + $stmt = $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')"); + // you can bind as many values as you want no matter if they can be replaced or not + $stmt->execute(array('first row')); + if ('00000' !== $stmt->errorCode()) + printf("[005] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - $stmt = $db->prepare('SELECT id, label FROM test'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to switch off emulated prepared statements, test will fail\n"); + try { + // native PS + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to switch off emulated prepared statements, test will fail\n"); - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); - // So, what will happen? More placeholder but values and - // placeholders in interesting places... - $stmt = $db->prepare('SELECT ? FROM test WHERE ? > ?'); - $stmt->execute(array('test')); - if ('00000' !== $stmt->errorCode()) { - printf("[003] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - } - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + // So, what will happen? More placeholder but values and + // placeholders in interesting places... + $stmt = $db->prepare('SELECT ? FROM test WHERE ? > ?'); + $stmt->execute(array('test')); + if ('00000' !== $stmt->errorCode()) { + printf("[003] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + } + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // now the same with emulated PS - printf("now the same with emulated PS\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to switch on emulated prepared statements, test will fail\n"); + // now the same with emulated PS + printf("now the same with emulated PS\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to switch on emulated prepared statements, test will fail\n"); - $stmt = $db->prepare('SELECT ? FROM test WHERE ? > ?'); - $stmt->execute(array('test')); - if ('00000' !== $stmt->errorCode()) - printf("[005] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT ? FROM test WHERE ? > ?'); + $stmt->execute(array('test')); + if ('00000' !== $stmt->errorCode()) + printf("[005] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { ?> --FILE-- exec($sql); - if ($ret !== $exp) { - printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", - $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - } catch (PDOException $e) { - - if (42000 == $db->errorCode()) { - // Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND) - // Load data infile not allowed - return false; - } - - printf("[%03d] '%s' has failed, [%s] %s\n", - $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - return true; - } - - require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); - $db = MySQLPDOTest::factory(); - // Run with native PS. - // The test is about checking the fallback to emulation - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); - - /* affected rows related */ - try { - - exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); - exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); - - $stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'"); - if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { - $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; - } else { - $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; - } - - $fp = fopen($filename, "w"); - fwrite($fp, "1;foo\n"); - fwrite($fp, "2;bar"); - fclose($fp); - - // This should fail, the PS protocol should not support it. - // mysqlnd will give 2014 as a follow-up of the fallback logic - // libmysql will give a little more precise 2030 error code - // However, you get an error and the big question is what happens to the line - $stmt = $db->prepare(sprintf("LOAD DATA INFILE %s INTO TABLE test FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename))); - if (!$stmt->execute()) { - printf("[004] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - } - - // Check the line - $stmt = $db->query("SELECT 1 as 'one'"); - if ($stmt->errorCode() != '0000') { - printf("[005] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - } else { - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (!isset($rows[0]['one']) || $rows[0]['one'] != 1) - printf("[006] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - } - - unlink($filename); - - } catch (PDOException $e) { - printf("[001] %s, [%s] %s (%s)\n", - $e->getMessage(), - $db->errorCode(), - implode(' ', $db->errorInfo()), - (isset($stmt)) ? implode(' ', $stmt->errorInfo()) : 'N/A'); - } - - print "done!"; + function exec_and_count($offset, &$db, $sql, $exp) { + + try { + + $ret = $db->exec($sql); + if ($ret !== $exp) { + printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", + $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + } catch (PDOException $e) { + + if (42000 == $db->errorCode()) { + // Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND) + // Load data infile not allowed + return false; + } + + printf("[%03d] '%s' has failed, [%s] %s\n", + $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + return true; + } + + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + // Run with native PS. + // The test is about checking the fallback to emulation + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); + + /* affected rows related */ + try { + + exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0); + exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0); + + $stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'"); + if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) { + $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; + } else { + $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv"; + } + + $fp = fopen($filename, "w"); + fwrite($fp, "1;foo\n"); + fwrite($fp, "2;bar"); + fclose($fp); + + // This should fail, the PS protocol should not support it. + // mysqlnd will give 2014 as a follow-up of the fallback logic + // libmysql will give a little more precise 2030 error code + // However, you get an error and the big question is what happens to the line + $stmt = $db->prepare(sprintf("LOAD DATA INFILE %s INTO TABLE test FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename))); + if (!$stmt->execute()) { + printf("[004] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + } + + // Check the line + $stmt = $db->query("SELECT 1 as 'one'"); + if ($stmt->errorCode() != '0000') { + printf("[005] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + } else { + $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!isset($rows[0]['one']) || $rows[0]['one'] != 1) + printf("[006] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + } + + unlink($filename); + + } catch (PDOException $e) { + printf("[001] %s, [%s] %s (%s)\n", + $e->getMessage(), + $db->errorCode(), + implode(' ', $db->errorInfo()), + (isset($stmt)) ? implode(' ', $stmt->errorInfo()) : 'N/A'); + } + + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); - $db->exec('CREATE FULLTEXT INDEX idx1 ON test(label)'); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); + $db->exec('CREATE FULLTEXT INDEX idx1 ON test(label)'); - $stmt = $db->prepare('SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)'); - $stmt->execute(array(':placeholder' => 'row')); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)'); + $stmt->execute(array(':placeholder' => 'row')); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->prepare('SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)'); - $stmt->execute(array('placeholder' => 'row')); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)'); + $stmt->execute(array('placeholder' => 'row')); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->prepare('SELECT id, label FROM test WHERE MATCH label AGAINST (?)'); - $stmt->execute(array('row')); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test WHERE MATCH label AGAINST (?)'); + $stmt->execute(array('row')); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } catch (PDOException $e) { + } catch (PDOException $e) { - printf("[001] %s, [%s} %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + printf("[001] %s, [%s} %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- prepare($query); - else - $stmt = $db->prepare($query); + if ($suppress_warning || (is_array($error_info) && isset($error_info['prepare']))) + $stmt = @$db->prepare($query); + else + $stmt = $db->prepare($query); - if (is_array($error_info) && isset($error_info['prepare'])) { - $tmp = $db->errorInfo(); + if (is_array($error_info) && isset($error_info['prepare'])) { + $tmp = $db->errorInfo(); - if (isset($error_info['prepare']['sqlstate']) && - ($error_info['prepare']['sqlstate'] !== $tmp[0])) { - printf("[%03d] prepare() - expecting SQLSTATE '%s' got '%s'\n", - $offset, $error_info['prepare']['sqlstate'], $tmp[0]); - return false; - } + if (isset($error_info['prepare']['sqlstate']) && + ($error_info['prepare']['sqlstate'] !== $tmp[0])) { + printf("[%03d] prepare() - expecting SQLSTATE '%s' got '%s'\n", + $offset, $error_info['prepare']['sqlstate'], $tmp[0]); + return false; + } - if (isset($error_info['prepare']['mysql']) && - ($error_info['prepare']['mysql'] !== $tmp[1])) { - printf("[%03d] prepare() - expecting MySQL Code '%s' got '%s'\n", - $offset, $error_info['prepare']['mysql'], $tmp[0]); - return false; - } + if (isset($error_info['prepare']['mysql']) && + ($error_info['prepare']['mysql'] !== $tmp[1])) { + printf("[%03d] prepare() - expecting MySQL Code '%s' got '%s'\n", + $offset, $error_info['prepare']['mysql'], $tmp[0]); + return false; + } - return false; - } + return false; + } - if (!is_object($stmt)) - return false; + if (!is_object($stmt)) + return false; - if (is_null($input_params)) - $input_params = array(); + if (is_null($input_params)) + $input_params = array(); // 5.0.18, 5.1.14 @ 15 // printf("[%03d]\n", $offset); - if ($suppress_warning || (is_array($error_info) && isset($error_info['execute']))) - $ret = @$stmt->execute($input_params); - else - $ret = $stmt->execute($input_params); - - if (!is_bool($ret)) - printf("[%03d] PDO::execute() should return a boolean value, got %s/%s\n", - var_export($ret, true), $ret); - - $tmp = $stmt->errorInfo(); - if (isset($tmp[1]) && ($tmp[1] == 2030)) { - // Trying to hack around MySQL Server version dependent features - // 2030 This command is not supported in the prepared statement protocol yet - return false; - } - - if (is_array($error_info) && isset($error_info['execute'])) { - - if (isset($error_info['execute']['sqlstate']) && - ($error_info['execute']['sqlstate'] !== $tmp[0])) { - printf("[%03d] execute() - expecting SQLSTATE '%s' got '%s'\n", - $offset, $error_info['execute']['sqlstate'], $tmp[0]); - return false; - } - - if (isset($error_info['execute']['mysql']) && - ($error_info['execute']['mysql'] !== $tmp[1])) { - printf("[%03d] execute() - expecting MySQL Code '%s' got '%s'\n", - $offset, $error_info['execute']['mysql'], $tmp[0]); - return false; - } - - return false; - - } - - } catch (PDOException $e) { - printf("[%03d] %s, [%s} %s\n", - $offset, $e->getMessage(), - $db->errorCode(), implode(' ', $db->errorInfo())); - return false; - } - - return $stmt; - } - - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); - - // TODO - that's PDO - you can prepare empty statements! - prepex(3, $db, '', - array(), array('prepare' => array('sqlstate' => '42000'))); - - // lets be fair and do the most simple SELECT first - $stmt = prepex(4, $db, 'SELECT 1 as "one"'); - if (MySQLPDOTest::isPDOMySQLnd()) - // native types - int - $expected = array('one' => 1); - else - // always strings, like STRINGIFY flag - $expected = array('one' => '1'); - - $row = $stmt->fetch(PDO::FETCH_ASSOC); - if ($row !== $expected) { - printf("[004a] Expecting %s got %s\n", var_export($expected, true), var_export($row, true)); - } - - prepex(5, $db, 'DROP TABLE IF EXISTS test'); - prepex(6, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - prepex(7, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')"); - $stmt = prepex(8, $db, 'SELECT label FROM test ORDER BY id ASC'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - prepex(9, $db, 'DELETE FROM test'); - prepex(10, $db, 'INSERT INTO test(id, label) VALUES(1, :placeholder)', - array(':placeholder' => 'first row')); - prepex(11, $db, 'INSERT INTO test(id, label) VALUES(2, :placeholder)', - array(':placeholder' => 'second row')); - $stmt = prepex(12, $db, 'SELECT label FROM test ORDER BY id ASC'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // Is PDO fun? - $stmt = prepex(13, $db, 'SELECT label FROM test WHERE :placeholder > 1', - array(':placeholder' => 'id')); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - for ($num_params = 2; $num_params < 100; $num_params++) { - $params = array(':placeholder' => 'a'); - for ($i = 1; $i < $num_params; $i++) { - $params[str_repeat('a', $i)] = 'some data'; - } - prepex(16, $db, 'SELECT id, label FROM test WHERE label > :placeholder', - $params, array('execute' => array('sqlstate' => 'HY093'))); - } - - $stmt = prepex(16, $db, 'SELECT id, label FROM test WHERE :placeholder IS NOT NULL', - array(':placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[017] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); - - $stmt = prepex(18, $db, 'SELECT id, label FROM test WHERE :placeholder IS NULL', - array(':placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[019] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); - - prepex(20, $db, 'DROP TABLE IF EXISTS test'); - prepex(21, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); - // Not every MySQL Server version supports this - if (is_object(prepex(22, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)', null, null, true))) { - prepex(23, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder)', - array(':placeholder' => 'MySQL is the best database in the world!')); - prepex(24, $db, 'INSERT INTO test(id, label) VALUES (2, :placeholder)', - array(':placeholder' => 'If I have the freedom to choose, I would always go again for the MySQL Server')); - $stmt = prepex(25, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)', - array(':placeholder' => 'mysql'), null, true); - if (is_object($stmt)) { - /* - Lets ignore this - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[033] Expecting two rows, got %d rows\n", $tmp); - */ - $stmt = prepex(26, $db, 'SELECT id, label FROM test ORDER BY id ASC'); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[027] Expecting two rows, got %d rows\n", $tmp); - - if ($tmp[0]['label'] !== 'MySQL is the best database in the world!') { - printf("[028] INSERT seems to have failed, dumping data, check manually\n"); - var_dump($tmp); - } - } - } - - $db->exec('DELETE FROM test'); - $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); - $db->exec("INSERT INTO test(id, label) VALUES (2, 'row2')"); - - $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = :placeholder)", - $db->quote('%ro%')); - $stmt = prepex(29, $db, $sql, array('placeholder' => -1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[030] Expecting zero rows, got %d rows\n", $tmp); - - $sql = sprintf("SELECT id, label FROM test WHERE (id = :placeholder) OR (label LIKE %s)", - $db->quote('%go%')); - $stmt = prepex(31, $db, $sql, array('placeholder' => 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) - printf("[032] Expecting one row, got %d rows\n", $tmp); - - // and now, the same with anonymous placeholders... - prepex(33, $db, 'DROP TABLE IF EXISTS test'); - prepex(34, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - prepex(35, $db, "INSERT INTO test(id, label) VALUES(1, '?')"); - $stmt = prepex(36, $db, 'SELECT label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - prepex(37, $db, 'DELETE FROM test'); - prepex(38, $db, 'INSERT INTO test(id, label) VALUES(1, ?)', - array('first row')); - prepex(39, $db, 'INSERT INTO test(id, label) VALUES(2, ?)', - array('second row')); - $stmt = prepex(40, $db, 'SELECT label FROM test'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // Is PDO fun? - prepex(40, $db, 'SELECT label FROM test WHERE ? > 1', - array('id')); - prepex(41, $db, 'SELECT ? FROM test WHERE id > 1', - array('id')); - prepex(42, $db, 'SELECT ? FROM test WHERE ? > ?', - array('id', 'label', 'value')); - - for ($num_params = 2; $num_params < 100; $num_params++) { - $params = array('a'); - for ($i = 1; $i < $num_params; $i++) { - $params[] = 'some data'; - } - prepex(43, $db, 'SELECT id, label FROM test WHERE label > ?', - $params, array('execute' => array('sqlstate' => 'HY093'))); - } - - prepex(44, $db, 'DELETE FROM test'); - prepex(45, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', - array('row', 'row')); - $stmt = prepex(46, $db, 'SELECT id, label FROM test ORDER BY id'); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - $exp = array( - 0 => array( - "id" => "1", - "label" => "row" - ), - 1 => array( - "id" => "2", - "label" => "row" - ), - ); - - if (MySQLPDOTest::isPDOMySQLnd()) { - // mysqlnd returns native types - $exp[0]['id'] = 1; - $exp[1]['id'] = 2; - } - if ($tmp !== $exp) { - printf("[064] Results seem wrong. Please check dumps manually.\n"); - var_dump($exp); - var_dump($tmp); - } - - $stmt = prepex(47, $db, 'SELECT id, label FROM test WHERE ? IS NOT NULL', - array(1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[048] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); - - $stmt = prepex(49, $db, 'SELECT id, label FROM test WHERE ? IS NULL', - array(1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[050] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); - - prepex(51, $db, 'DROP TABLE IF EXISTS test'); - prepex(52, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); - if (is_object(prepex(53, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)', null, null, true))) { - prepex(54, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', - array('MySQL is the best database in the world!')); - prepex(55, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', - array('If I have the freedom to choose, I would always go again for the MySQL Server')); - $stmt = prepex(56, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (?)', - array('mysql'), null, true); - /* - Lets ignore that - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[074] Expecting two rows, got %d rows\n", $tmp); - */ - } - - prepex(57, $db, 'DELETE FROM test'); - prepex(58, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', - array('row1', 'row2')); - - /* - TODO enable after fix - $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', - array(':placeholder' => 'row'), - array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); - */ - - $stmt = prepex(59, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', - array('row1')); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - $exp = array( - 0 => array("id" => "1", "label" => "row1") - ); - - if (MySQLPDOTest::isPDOMySQLnd()) { - // mysqlnd returns native types - $exp[0]['id'] = 1; - } - if ($tmp !== $exp) { - printf("[065] Results seem wrong. Please check dumps manually.\n"); - var_dump($exp); - var_dump($tmp); - } - - $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", - $db->quote('%ro%')); - $stmt = prepex(60, $db, $sql, array(-1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) - printf("[061] Expecting zero rows, got %d rows\n", $tmp); - - $sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", - $db->quote('%ro%')); - $stmt = prepex(61, $db, $sql, array(1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) - printf("[062] Expecting two rows, got %d rows\n", $tmp); - - $sql = "SELECT id, label FROM test WHERE id = ? AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; - $stmt = prepex(63, $db, $sql, array(1, 1)); - if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) - printf("[064] Expecting one row, got %d rows\n", $tmp); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + if ($suppress_warning || (is_array($error_info) && isset($error_info['execute']))) + $ret = @$stmt->execute($input_params); + else + $ret = $stmt->execute($input_params); + + if (!is_bool($ret)) + printf("[%03d] PDO::execute() should return a boolean value, got %s/%s\n", + var_export($ret, true), $ret); + + $tmp = $stmt->errorInfo(); + if (isset($tmp[1]) && ($tmp[1] == 2030)) { + // Trying to hack around MySQL Server version dependent features + // 2030 This command is not supported in the prepared statement protocol yet + return false; + } + + if (is_array($error_info) && isset($error_info['execute'])) { + + if (isset($error_info['execute']['sqlstate']) && + ($error_info['execute']['sqlstate'] !== $tmp[0])) { + printf("[%03d] execute() - expecting SQLSTATE '%s' got '%s'\n", + $offset, $error_info['execute']['sqlstate'], $tmp[0]); + return false; + } + + if (isset($error_info['execute']['mysql']) && + ($error_info['execute']['mysql'] !== $tmp[1])) { + printf("[%03d] execute() - expecting MySQL Code '%s' got '%s'\n", + $offset, $error_info['execute']['mysql'], $tmp[0]); + return false; + } + + return false; + + } + + } catch (PDOException $e) { + printf("[%03d] %s, [%s} %s\n", + $offset, $e->getMessage(), + $db->errorCode(), implode(' ', $db->errorInfo())); + return false; + } + + return $stmt; + } + + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); + + // TODO - that's PDO - you can prepare empty statements! + prepex(3, $db, '', + array(), array('prepare' => array('sqlstate' => '42000'))); + + // lets be fair and do the most simple SELECT first + $stmt = prepex(4, $db, 'SELECT 1 as "one"'); + if (MySQLPDOTest::isPDOMySQLnd()) + // native types - int + $expected = array('one' => 1); + else + // always strings, like STRINGIFY flag + $expected = array('one' => '1'); + + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if ($row !== $expected) { + printf("[004a] Expecting %s got %s\n", var_export($expected, true), var_export($row, true)); + } + + prepex(5, $db, 'DROP TABLE IF EXISTS test'); + prepex(6, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + prepex(7, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')"); + $stmt = prepex(8, $db, 'SELECT label FROM test ORDER BY id ASC'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + prepex(9, $db, 'DELETE FROM test'); + prepex(10, $db, 'INSERT INTO test(id, label) VALUES(1, :placeholder)', + array(':placeholder' => 'first row')); + prepex(11, $db, 'INSERT INTO test(id, label) VALUES(2, :placeholder)', + array(':placeholder' => 'second row')); + $stmt = prepex(12, $db, 'SELECT label FROM test ORDER BY id ASC'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // Is PDO fun? + $stmt = prepex(13, $db, 'SELECT label FROM test WHERE :placeholder > 1', + array(':placeholder' => 'id')); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + for ($num_params = 2; $num_params < 100; $num_params++) { + $params = array(':placeholder' => 'a'); + for ($i = 1; $i < $num_params; $i++) { + $params[str_repeat('a', $i)] = 'some data'; + } + prepex(16, $db, 'SELECT id, label FROM test WHERE label > :placeholder', + $params, array('execute' => array('sqlstate' => 'HY093'))); + } + + $stmt = prepex(16, $db, 'SELECT id, label FROM test WHERE :placeholder IS NOT NULL', + array(':placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[017] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); + + $stmt = prepex(18, $db, 'SELECT id, label FROM test WHERE :placeholder IS NULL', + array(':placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[019] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); + + prepex(20, $db, 'DROP TABLE IF EXISTS test'); + prepex(21, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); + // Not every MySQL Server version supports this + if (is_object(prepex(22, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)', null, null, true))) { + prepex(23, $db, 'INSERT INTO test(id, label) VALUES (1, :placeholder)', + array(':placeholder' => 'MySQL is the best database in the world!')); + prepex(24, $db, 'INSERT INTO test(id, label) VALUES (2, :placeholder)', + array(':placeholder' => 'If I have the freedom to choose, I would always go again for the MySQL Server')); + $stmt = prepex(25, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (:placeholder)', + array(':placeholder' => 'mysql'), null, true); + if (is_object($stmt)) { + /* + Lets ignore this + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[033] Expecting two rows, got %d rows\n", $tmp); + */ + $stmt = prepex(26, $db, 'SELECT id, label FROM test ORDER BY id ASC'); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[027] Expecting two rows, got %d rows\n", $tmp); + + if ($tmp[0]['label'] !== 'MySQL is the best database in the world!') { + printf("[028] INSERT seems to have failed, dumping data, check manually\n"); + var_dump($tmp); + } + } + } + + $db->exec('DELETE FROM test'); + $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); + $db->exec("INSERT INTO test(id, label) VALUES (2, 'row2')"); + + $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = :placeholder)", + $db->quote('%ro%')); + $stmt = prepex(29, $db, $sql, array('placeholder' => -1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[030] Expecting zero rows, got %d rows\n", $tmp); + + $sql = sprintf("SELECT id, label FROM test WHERE (id = :placeholder) OR (label LIKE %s)", + $db->quote('%go%')); + $stmt = prepex(31, $db, $sql, array('placeholder' => 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) + printf("[032] Expecting one row, got %d rows\n", $tmp); + + // and now, the same with anonymous placeholders... + prepex(33, $db, 'DROP TABLE IF EXISTS test'); + prepex(34, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + prepex(35, $db, "INSERT INTO test(id, label) VALUES(1, '?')"); + $stmt = prepex(36, $db, 'SELECT label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + prepex(37, $db, 'DELETE FROM test'); + prepex(38, $db, 'INSERT INTO test(id, label) VALUES(1, ?)', + array('first row')); + prepex(39, $db, 'INSERT INTO test(id, label) VALUES(2, ?)', + array('second row')); + $stmt = prepex(40, $db, 'SELECT label FROM test'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // Is PDO fun? + prepex(40, $db, 'SELECT label FROM test WHERE ? > 1', + array('id')); + prepex(41, $db, 'SELECT ? FROM test WHERE id > 1', + array('id')); + prepex(42, $db, 'SELECT ? FROM test WHERE ? > ?', + array('id', 'label', 'value')); + + for ($num_params = 2; $num_params < 100; $num_params++) { + $params = array('a'); + for ($i = 1; $i < $num_params; $i++) { + $params[] = 'some data'; + } + prepex(43, $db, 'SELECT id, label FROM test WHERE label > ?', + $params, array('execute' => array('sqlstate' => 'HY093'))); + } + + prepex(44, $db, 'DELETE FROM test'); + prepex(45, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', + array('row', 'row')); + $stmt = prepex(46, $db, 'SELECT id, label FROM test ORDER BY id'); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + $exp = array( + 0 => array( + "id" => "1", + "label" => "row" + ), + 1 => array( + "id" => "2", + "label" => "row" + ), + ); + + if (MySQLPDOTest::isPDOMySQLnd()) { + // mysqlnd returns native types + $exp[0]['id'] = 1; + $exp[1]['id'] = 2; + } + if ($tmp !== $exp) { + printf("[064] Results seem wrong. Please check dumps manually.\n"); + var_dump($exp); + var_dump($tmp); + } + + $stmt = prepex(47, $db, 'SELECT id, label FROM test WHERE ? IS NOT NULL', + array(1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[048] '1' IS NOT NULL evaluates to true, expecting two rows, got %d rows\n", $tmp); + + $stmt = prepex(49, $db, 'SELECT id, label FROM test WHERE ? IS NULL', + array(1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[050] '1' IS NOT NULL evaluates to true, expecting zero rows, got %d rows\n", $tmp); + + prepex(51, $db, 'DROP TABLE IF EXISTS test'); + prepex(52, $db, 'CREATE TABLE test(id INT, label CHAR(255)) ENGINE=MyISAM'); + if (is_object(prepex(53, $db, 'CREATE FULLTEXT INDEX idx1 ON test(label)', null, null, true))) { + prepex(54, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', + array('MySQL is the best database in the world!')); + prepex(55, $db, 'INSERT INTO test(id, label) VALUES (1, ?)', + array('If I have the freedom to choose, I would always go again for the MySQL Server')); + $stmt = prepex(56, $db, 'SELECT id, label FROM test WHERE MATCH label AGAINST (?)', + array('mysql'), null, true); + /* + Lets ignore that + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[074] Expecting two rows, got %d rows\n", $tmp); + */ + } + + prepex(57, $db, 'DELETE FROM test'); + prepex(58, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', + array('row1', 'row2')); + + /* + TODO enable after fix + $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', + array(':placeholder' => 'row'), + array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); + */ + + $stmt = prepex(59, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', + array('row1')); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + $exp = array( + 0 => array("id" => "1", "label" => "row1") + ); + + if (MySQLPDOTest::isPDOMySQLnd()) { + // mysqlnd returns native types + $exp[0]['id'] = 1; + } + if ($tmp !== $exp) { + printf("[065] Results seem wrong. Please check dumps manually.\n"); + var_dump($exp); + var_dump($tmp); + } + + $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", + $db->quote('%ro%')); + $stmt = prepex(60, $db, $sql, array(-1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 0) + printf("[061] Expecting zero rows, got %d rows\n", $tmp); + + $sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", + $db->quote('%ro%')); + $stmt = prepex(61, $db, $sql, array(1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2) + printf("[062] Expecting two rows, got %d rows\n", $tmp); + + $sql = "SELECT id, label FROM test WHERE id = ? AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; + $stmt = prepex(63, $db, $sql, array(1, 1)); + if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 1) + printf("[064] Expecting one row, got %d rows\n", $tmp); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - // We need to run the emulated version first. Native version will cause a fatal error - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); + // We need to run the emulated version first. Native version will cause a fatal error + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); - // INSERT a single row - $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); + // INSERT a single row + $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); - $stmt = $db->prepare('SELECT unknown_column FROM test WHERE id > :placeholder ORDER BY id ASC'); - $stmt->execute(array(':placeholder' => 0)); - if ('00000' !== $stmt->errorCode()) - printf("[003] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + $stmt = $db->prepare('SELECT unknown_column FROM test WHERE id > :placeholder ORDER BY id ASC'); + $stmt->execute(array(':placeholder' => 0)); + if ('00000' !== $stmt->errorCode()) + printf("[003] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > :placeholder ORDER BY id ASC'); - $stmt->execute(array(':placeholder' => 0)); - if ('00000' !== $stmt->errorCode()) - printf("[004] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > :placeholder ORDER BY id ASC'); + $stmt->execute(array(':placeholder' => 0)); + if ('00000' !== $stmt->errorCode()) + printf("[004] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // Native PS - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[005] Unable to turn off emulated prepared statements\n"); + // Native PS + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[005] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT unknown_column FROM test WHERE id > :placeholder ORDER BY id ASC'); - $stmt->execute(array(':placeholder' => 0)); - if ('00000' !== $stmt->errorCode()) - printf("[006] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + $stmt = $db->prepare('SELECT unknown_column FROM test WHERE id > :placeholder ORDER BY id ASC'); + $stmt->execute(array(':placeholder' => 0)); + if ('00000' !== $stmt->errorCode()) + printf("[006] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > :placeholder ORDER BY id ASC'); - $stmt->execute(array(':placeholder' => 0)); - if ('00000' !== $stmt->errorCode()) - printf("[007] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > :placeholder ORDER BY id ASC'); + $stmt->execute(array(':placeholder' => 0)); + if ('00000' !== $stmt->errorCode()) + printf("[007] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare("SELECT :param FROM test ORDER BY id ASC LIMIT 1"); - $stmt->execute(array(':param' => 'id')); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare("SELECT :param FROM test ORDER BY id ASC LIMIT 1"); + $stmt->execute(array(':param' => 'id')); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $db->prepare('SELECT :placeholder FROM test WHERE :placeholder > :placeholder'); - $stmt->execute(array(':placeholder' => 'test')); + $db->prepare('SELECT :placeholder FROM test WHERE :placeholder > :placeholder'); + $stmt->execute(array(':placeholder' => 'test')); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label1 CHAR(255), label2 CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); - printf("Native...\n"); - - // INSERT a single row - $stmt = $db->prepare('INSERT INTO test(id, label1, label2) VALUES (1, :placeholder, :placeholder)'); - - $stmt->execute(array(':placeholder' => 'row1')); - if ('00000' !== $stmt->errorCode()) - printf("[003] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - - // Ok, what has happened: anything inserted into the DB? - $stmt = $db->prepare('SELECT id, label1, label2 FROM test WHERE id = 1'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // Now the same with emulated PS. - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn on emulated prepared statements\n"); - printf("Emulated...\n"); - - $stmt = $db->prepare('INSERT INTO test(id, label1, label2) VALUES(2, :placeholder, :placeholder)'); - // No replacement shall be made - $stmt->execute(array(':placeholder' => 'row2')); - if ('00000' !== $stmt->errorCode()) - printf("[005] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - - // Now, what do we have in the DB? - $stmt = $db->prepare('SELECT id, label1, label2 FROM test WHERE id = 2'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // - // Another variation of the theme - // - - $db->exec('DELETE FROM test'); - $db->exec("INSERT INTO test (id, label1, label2) VALUES (1, 'row1', 'row2')"); - $sql = "SELECT id, label1 FROM test WHERE id = :placeholder AND label1 = (SELECT label1 AS 'SELECT' FROM test WHERE id = :placeholder)"; - - // emulated... - $stmt = $db->prepare($sql); - $stmt->execute(array(':placeholder' => 1)); - if ('00000' !== $stmt->errorCode()) - printf("[006] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - // native... - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[007] Unable to turn off emulated prepared statements\n"); - printf("Native...\n"); - - $stmt = $db->prepare($sql); - $stmt->execute(array(':placeholder' => 1)); - if ('00000' !== $stmt->errorCode()) - printf("[008] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + try { + + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label1 CHAR(255), label2 CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); + printf("Native...\n"); + + // INSERT a single row + $stmt = $db->prepare('INSERT INTO test(id, label1, label2) VALUES (1, :placeholder, :placeholder)'); + + $stmt->execute(array(':placeholder' => 'row1')); + if ('00000' !== $stmt->errorCode()) + printf("[003] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + + // Ok, what has happened: anything inserted into the DB? + $stmt = $db->prepare('SELECT id, label1, label2 FROM test WHERE id = 1'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // Now the same with emulated PS. + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn on emulated prepared statements\n"); + printf("Emulated...\n"); + + $stmt = $db->prepare('INSERT INTO test(id, label1, label2) VALUES(2, :placeholder, :placeholder)'); + // No replacement shall be made + $stmt->execute(array(':placeholder' => 'row2')); + if ('00000' !== $stmt->errorCode()) + printf("[005] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + + // Now, what do we have in the DB? + $stmt = $db->prepare('SELECT id, label1, label2 FROM test WHERE id = 2'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // + // Another variation of the theme + // + + $db->exec('DELETE FROM test'); + $db->exec("INSERT INTO test (id, label1, label2) VALUES (1, 'row1', 'row2')"); + $sql = "SELECT id, label1 FROM test WHERE id = :placeholder AND label1 = (SELECT label1 AS 'SELECT' FROM test WHERE id = :placeholder)"; + + // emulated... + $stmt = $db->prepare($sql); + $stmt->execute(array(':placeholder' => 1)); + if ('00000' !== $stmt->errorCode()) + printf("[006] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + // native... + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[007] Unable to turn off emulated prepared statements\n"); + printf("Native...\n"); + + $stmt = $db->prepare($sql); + $stmt->execute(array(':placeholder' => 1)); + if ('00000' !== $stmt->errorCode()) + printf("[008] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); - $stmt = $db->query('DELETE FROM test'); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, ?), (2, ?)'); - $stmt->execute(array('a', 'b')); - $stmt = $db->prepare("SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"); - $stmt->execute(array(1, 1)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query('DELETE FROM test'); + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, ?), (2, ?)'); + $stmt->execute(array('a', 'b')); + $stmt = $db->prepare("SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"); + $stmt->execute(array(1, 1)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); - // INSERT a single row - $stmt = $db->prepare("INSERT INTO test(id, label) VALUES (100, ':placeholder')"); + // INSERT a single row + $stmt = $db->prepare("INSERT INTO test(id, label) VALUES (100, ':placeholder')"); - // Yes, there is no placeholder to bind to and named placeholder - // do not work with MySQL native PS, but lets see what happens! - // The ':placeholder' is a string constant in the INSERT statement. - // I would expect to get an error message, but this is not what happens. - $stmt->execute(array(':placeholder' => 'row1')); - if ('00000' !== $stmt->errorCode()) - printf("[003] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + // Yes, there is no placeholder to bind to and named placeholder + // do not work with MySQL native PS, but lets see what happens! + // The ':placeholder' is a string constant in the INSERT statement. + // I would expect to get an error message, but this is not what happens. + $stmt->execute(array(':placeholder' => 'row1')); + if ('00000' !== $stmt->errorCode()) + printf("[003] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - // Ok, what has happened: anything inserted into the DB? - $stmt = $db->prepare('SELECT id, label FROM test'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + // Ok, what has happened: anything inserted into the DB? + $stmt = $db->prepare('SELECT id, label FROM test'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // Now the same with emulated PS. - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn on emulated prepared statements\n"); + // Now the same with emulated PS. + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn on emulated prepared statements\n"); - // Note that the "named placeholder" is enclosed by double quotes. - $stmt = $db->prepare("INSERT INTO test(id, label) VALUES(101, ':placeholder')"); - // No replacement shall be made - $stmt->execute(array(':placeholder' => 'row1')); - // Again, I'd like to see an error message - if ('00000' !== $stmt->errorCode()) - printf("[005] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + // Note that the "named placeholder" is enclosed by double quotes. + $stmt = $db->prepare("INSERT INTO test(id, label) VALUES(101, ':placeholder')"); + // No replacement shall be made + $stmt->execute(array(':placeholder' => 'row1')); + // Again, I'd like to see an error message + if ('00000' !== $stmt->errorCode()) + printf("[005] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - // Now, what do we have in the DB? - $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + // Now, what do we have in the DB? + $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to switch on emulated prepared statements, test will fail\n"); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to switch on emulated prepared statements, test will fail\n"); - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); - $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE)); + $db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')"); - $stmt = $db->prepare('SELECT ?, id, label FROM test WHERE ? = ? ORDER BY id ASC'); - $stmt->execute(array('id', 'label', 'label')); - if ('00000' !== $stmt->errorCode()) - printf("[003] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->prepare('SELECT ?, id, label FROM test WHERE ? = ? ORDER BY id ASC'); + $stmt->execute(array('id', 'label', 'label')); + if ('00000' !== $stmt->errorCode()) + printf("[003] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - // now the same with native PS - printf("now the same with native PS\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to switch off emulated prepared statements, test will fail\n"); + // now the same with native PS + printf("now the same with native PS\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to switch off emulated prepared statements, test will fail\n"); - $stmt = $db->prepare('SELECT ?, id, label FROM test WHERE ? = ? ORDER BY id ASC'); - $stmt->execute(array('id', 'label', 'label')); - if ('00000' !== $stmt->errorCode()) - printf("[005] Execute has failed, %s %s\n", - var_export($stmt->errorCode(), true), - var_export($stmt->errorInfo(), true)); + $stmt = $db->prepare('SELECT ?, id, label FROM test WHERE ? = ? ORDER BY id ASC'); + $stmt->execute(array('id', 'label', 'label')); + if ('00000' !== $stmt->errorCode()) + printf("[005] Execute has failed, %s %s\n", + var_export($stmt->errorCode(), true), + var_export($stmt->errorInfo(), true)); - $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (!MySQLPDOTest::isPDOMySQLnd()) { - if (isset($tmp[0]['id'])) { - // libmysql should return a string here whereas mysqlnd returns a native int - if (gettype($tmp[0]['id']) == 'string') - // convert to int for the test output... - settype($tmp[0]['id'], 'integer'); - } - } - var_dump($tmp); + $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!MySQLPDOTest::isPDOMySQLnd()) { + if (isset($tmp[0]['id'])) { + // libmysql should return a string here whereas mysqlnd returns a native int + if (gettype($tmp[0]['id']) == 'string') + // convert to int for the test output... + settype($tmp[0]['id'], 'integer'); + } + } + var_dump($tmp); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- beginTransaction(); + $db->beginTransaction(); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - $num = $row['_num']; + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + $num = $row['_num']; - $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); - $num++; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[001] INSERT has failed, test will fail\n"); + $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); + $num++; + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[001] INSERT has failed, test will fail\n"); - $db->rollBack(); - $num--; - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[002] ROLLBACK has failed\n"); + $db->rollBack(); + $num--; + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[002] ROLLBACK has failed\n"); - $db->beginTransaction(); - $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); - $db->query('DROP TABLE IF EXISTS test2'); - $db->query('CREATE TABLE test2(id INT)'); - $num++; - $db->rollBack(); - $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != $num) - printf("[002] ROLLBACK should have no effect because of the implicit COMMIT - triggered by DROP/CREATE TABLE\n"); + $db->beginTransaction(); + $db->query("INSERT INTO test(id, label) VALUES (100, 'z')"); + $db->query('DROP TABLE IF EXISTS test2'); + $db->query('CREATE TABLE test2(id INT)'); + $num++; + $db->rollBack(); + $row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != $num) + printf("[002] ROLLBACK should have no effect because of the implicit COMMIT + triggered by DROP/CREATE TABLE\n"); - $db->query('DROP TABLE IF EXISTS test2'); - $db->query('CREATE TABLE test2(id INT) ENGINE=MyISAM'); - $db->beginTransaction(); - $db->query('INSERT INTO test2(id) VALUES (1)'); - $db->rollBack(); - $row = $db->query('SELECT COUNT(*) AS _num FROM test2')->fetch(PDO::FETCH_ASSOC); - if ($row['_num'] != 1) - printf("[003] ROLLBACK should have no effect\n"); + $db->query('DROP TABLE IF EXISTS test2'); + $db->query('CREATE TABLE test2(id INT) ENGINE=MyISAM'); + $db->beginTransaction(); + $db->query('INSERT INTO test2(id) VALUES (1)'); + $db->rollBack(); + $row = $db->query('SELECT COUNT(*) AS _num FROM test2')->fetch(PDO::FETCH_ASSOC); + if ($row['_num'] != 1) + printf("[003] ROLLBACK should have no effect\n"); - $db->query('DROP TABLE IF EXISTS test2'); + $db->query('DROP TABLE IF EXISTS test2'); - $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); - $db->beginTransaction(); - $db->query('DELETE FROM test'); - $db->rollBack(); - var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); + $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); + $db->beginTransaction(); + $db->query('DELETE FROM test'); + $db->rollBack(); + var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); - $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); - $db->beginTransaction(); - $db->query('DELETE FROM test'); - $db->rollBack(); - var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); + $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); + $db->beginTransaction(); + $db->query('DELETE FROM test'); + $db->rollBack(); + var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); - $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); - $db->beginTransaction(); - $db->query('DELETE FROM test'); - $db->commit(); - var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); + $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 1); + $db->beginTransaction(); + $db->query('DELETE FROM test'); + $db->commit(); + var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); - $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); - $db->beginTransaction(); - $db->query('DELETE FROM test'); - $db->commit(); - var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); + $db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0); + $db->beginTransaction(); + $db->query('DELETE FROM test'); + $db->commit(); + var_dump($db->getAttribute(PDO::ATTR_AUTOCOMMIT)); - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); - $stmt->execute(); - $id = $label = null; + $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + $stmt->execute(); + $id = $label = null; - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[003] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[003] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[004] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[004] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - $data = array(); - while ($stmt->fetch(PDO::FETCH_BOUND)) { - printf("id = %s (%s) / label = %s (%s)\n", - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - $data[] = array('id' => $id, 'label' => $label); - } + $data = array(); + while ($stmt->fetch(PDO::FETCH_BOUND)) { + printf("id = %s (%s) / label = %s (%s)\n", + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + $data[] = array('id' => $id, 'label' => $label); + } - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); - $index = 0; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - if ($row['id'] != $data[$index]['id']) { - printf("[005] Fetch bound and fetch assoc differ - column 'id', bound: %s/%s, assoc: %s/%s\n", - var_export($data[$index]['id'], true), gettype($data[$index]['id']), - var_export($row['id'], true), gettype($row['id'])); - } - if ($row['label'] != $data[$index]['label']) { - printf("[006] Fetch bound and fetch assoc differ - column 'label', bound: %s/%s, assoc: %s/%s\n", - var_export($data[$index]['label'], true), gettype($data[$index]['label']), - var_export($row['label'], true), gettype($row['label'])); - } - $index++; - } + $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2'); + $index = 0; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if ($row['id'] != $data[$index]['id']) { + printf("[005] Fetch bound and fetch assoc differ - column 'id', bound: %s/%s, assoc: %s/%s\n", + var_export($data[$index]['id'], true), gettype($data[$index]['id']), + var_export($row['id'], true), gettype($row['id'])); + } + if ($row['label'] != $data[$index]['label']) { + printf("[006] Fetch bound and fetch assoc differ - column 'label', bound: %s/%s, assoc: %s/%s\n", + var_export($data[$index]['label'], true), gettype($data[$index]['label']), + var_export($row['label'], true), gettype($row['label'])); + } + $index++; + } - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[007] Unable to turn off emulated prepared statements\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[007] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id ASC LIMIT 2, 2'); - $stmt->execute(); - $id = $label = null; + $stmt = $db->prepare('SELECT id, label FROM test ORDER BY id ASC LIMIT 2, 2'); + $stmt->execute(); + $id = $label = null; - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[008] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[008] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[009] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[009] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - $data = array(); - while ($stmt->fetch(PDO::FETCH_BOUND)) { - printf("id = %s (%s) / label = %s (%s)\n", - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - $data[] = array('id' => $id, 'label' => $label); - } + $data = array(); + while ($stmt->fetch(PDO::FETCH_BOUND)) { + printf("id = %s (%s) / label = %s (%s)\n", + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + $data[] = array('id' => $id, 'label' => $label); + } - $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2, 2'); - $index = 0; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - if ($row['id'] != $data[$index]['id']) { - printf("[010] Fetch bound and fetch assoc differ - column 'id', bound: %s/%s, assoc: %s/%s\n", - var_export($data[$index]['id'], true), gettype($data[$index]['id']), - var_export($row['id'], true), gettype($row['id'])); - } - if ($row['label'] != $data[$index]['label']) { - printf("[011] Fetch bound and fetch assoc differ - column 'label', bound: %s/%s, assoc: %s/%s\n", - var_export($data[$index]['label'], true), gettype($data[$index]['label']), - var_export($row['label'], true), gettype($row['label'])); - } - $index++; - } + $stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2, 2'); + $index = 0; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + if ($row['id'] != $data[$index]['id']) { + printf("[010] Fetch bound and fetch assoc differ - column 'id', bound: %s/%s, assoc: %s/%s\n", + var_export($data[$index]['id'], true), gettype($data[$index]['id']), + var_export($row['id'], true), gettype($row['id'])); + } + if ($row['label'] != $data[$index]['label']) { + printf("[011] Fetch bound and fetch assoc differ - column 'label', bound: %s/%s, assoc: %s/%s\n", + var_export($data[$index]['label'], true), gettype($data[$index]['label']), + var_export($row['label'], true), gettype($row['label'])); + } + $index++; + } - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); - - MySQLPDOTest::createTestTable($db); - - function pdo_mysql_stmt_bindparam($db, $offset) { - - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindParam(1, $in)) - printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[%03d + 2] Cannot bind integer column, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Same again...\n"); - $stmt->execute(); - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - // NULL values - printf("NULL...\n"); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (100, ?)'); - $label = null; - if (!$stmt->bindParam(1, $label)) - printf("[%03d + 4] Cannot bind parameter, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->execute()) - printf("[%03d + 5] Cannot execute statement, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - /* NOTE: you cannot use PDO::query() with unbuffered, native PS - see extra test */ - $stmt = $db->prepare('SELECT id, NULL AS _label FROM test WHERE label IS NULL'); - $stmt->execute(); - - $id = $label = 'bogus'; - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[%03d + 6] Cannot bind NULL column, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - } - - try { - printf("Emulated PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); - - printf("Buffered...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - pdo_mysql_stmt_bindparam($db, 3); - - printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - pdo_mysql_stmt_bindparam($db, 4); - - printf("Native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn off emulated prepared statements\n"); - - printf("Buffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - pdo_mysql_stmt_bindparam($db, 5); - - printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - pdo_mysql_stmt_bindparam($db, 6); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + + MySQLPDOTest::createTestTable($db); + + function pdo_mysql_stmt_bindparam($db, $offset) { + + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindParam(1, $in)) + printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[%03d + 2] Cannot bind integer column, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Same again...\n"); + $stmt->execute(); + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + // NULL values + printf("NULL...\n"); + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (100, ?)'); + $label = null; + if (!$stmt->bindParam(1, $label)) + printf("[%03d + 4] Cannot bind parameter, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->execute()) + printf("[%03d + 5] Cannot execute statement, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + /* NOTE: you cannot use PDO::query() with unbuffered, native PS - see extra test */ + $stmt = $db->prepare('SELECT id, NULL AS _label FROM test WHERE label IS NULL'); + $stmt->execute(); + + $id = $label = 'bogus'; + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[%03d + 6] Cannot bind NULL column, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + } + + try { + printf("Emulated PS...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); + + printf("Buffered...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + pdo_mysql_stmt_bindparam($db, 3); + + printf("Unbuffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + pdo_mysql_stmt_bindparam($db, 4); + + printf("Native PS...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn off emulated prepared statements\n"); + + printf("Buffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + pdo_mysql_stmt_bindparam($db, 5); + + printf("Unbuffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + pdo_mysql_stmt_bindparam($db, 6); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - else - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - - $db->exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - if ((!$stmt = @$db->prepare($sql)) || (!@$stmt->execute())) - // Server might not support column type - skip it - return true; - - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, ?)'); - if (!$stmt->bindParam(1, $value)) { - printf("[%03d/%s + 1] %s\n", $offset, ($native) ? 'native' : 'emulated', - var_export($stmt->errorInfo(), true)); - return false; - } - if (!$stmt->execute()) { - printf("[%03d/%s + 2] %s\n", $offset, ($native) ? 'native' : 'emulated', - var_export($stmt->errorInfo(), true)); - return false; - } - - $stmt = $db->query('SELECT id, label FROM test'); - $id = $label = null; - if (!$stmt->bindColumn(1, $id)) { - printf("[%03d/%s + 3] %s\n", $offset, ($native) ? 'native' : 'emulated', - var_export($stmt->errorInfo(), true)); - return false; - } - if (!$stmt->bindColumn(2, $label)) { - printf("[%03d/%s + 4] %s\n", $offset, ($native) ? 'native' : 'emulated', - var_export($stmt->errorInfo(), true)); - return false; - } - - if (!$stmt->fetch(PDO::FETCH_BOUND)) { - printf("[%03d/%s + 5] %s\n", $offset, ($native) ? 'native' : 'emulated', - var_export($stmt->errorInfo(), true)); - return false; - } - $stmt->closeCursor(); - - if ($label != $value) { - printf("[%03d/%s + 6] Got %s expecting %s - please check manually\n", - $offset, ($native) ? 'native' : 'emulated', - var_export($label, true), var_export($value, true)); - // fall through - } - - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - if (empty($row)) { - printf("[%03d/%s + 7] %s\n", $offset, ($native) ? 'native' : 'emulated', - var_export($stmt->errorInfo(), true)); - return false; - } - - if ($row['label'] != $value) { - printf("[%03d/%s + 8] Got %s expecting %s - please check manually\n", - $offset, ($native) ? 'native' : 'emulated', - var_export($row['label'], true), var_export($value, true)); - return false; - } - - if ($row['label'] != $label) { - printf("[%03d/%s + 9] Got %s from FETCH_ASSOC and %s from FETCH_BOUND- please check manually\n", - $offset, ($native) ? 'native' : 'emulated', - var_export($row['label'], true), var_export($value, true)); - return false; - } - - $db->exec('DROP TABLE IF EXISTS test'); - return true; - } - - function pdo_mysql_stmt_bindparam_types($db, $offset, $sql_type, $value) { - - pdo_mysql_stmt_bindparam_types_do($db, $offset, true, $sql_type, $value); - pdo_mysql_stmt_bindparam_types_do($db, $offset, false, $sql_type, $value); - - } - - try { - - // pdo_mysql_stmt_bindparam_types($db, 2, 'BIT(8)', 1); - pdo_mysql_stmt_bindparam_types($db, 3, 'TINYINT', -127); - pdo_mysql_stmt_bindparam_types($db, 4, 'TINYINT UNSIGNED', 255); - pdo_mysql_stmt_bindparam_types($db, 5, 'BOOLEAN', 1); - pdo_mysql_stmt_bindparam_types($db, 6, 'SMALLINT', -32768); - pdo_mysql_stmt_bindparam_types($db, 7, 'SMALLINT UNSIGNED', 65535); - pdo_mysql_stmt_bindparam_types($db, 8, 'MEDIUMINT', -8388608); - pdo_mysql_stmt_bindparam_types($db, 9, 'MEDIUMINT UNSIGNED', 16777215); - pdo_mysql_stmt_bindparam_types($db, 10, 'INT', -2147483648); - pdo_mysql_stmt_bindparam_types($db, 11, 'INT UNSIGNED', 4294967295); - pdo_mysql_stmt_bindparam_types($db, 12, 'BIGINT', -1000); - pdo_mysql_stmt_bindparam_types($db, 13, 'BIGINT UNSIGNED', 1000); - pdo_mysql_stmt_bindparam_types($db, 14, 'REAL', -1000); - pdo_mysql_stmt_bindparam_types($db, 15, 'REAL UNSIGNED', 1000); - pdo_mysql_stmt_bindparam_types($db, 16, 'REAL ZEROFILL', '0000000000000000000000'); - pdo_mysql_stmt_bindparam_types($db, 17, 'REAL UNSIGNED ZEROFILL', '0000000000000000000010'); - pdo_mysql_stmt_bindparam_types($db, 18, 'DOUBLE', -1000); - pdo_mysql_stmt_bindparam_types($db, 19, 'DOUBLE UNSIGNED', 1000); - pdo_mysql_stmt_bindparam_types($db, 20, 'DOUBLE ZEROFILL', '000000000000'); - pdo_mysql_stmt_bindparam_types($db, 21, 'DOUBLE ZEROFILL UNSIGNED', '000000001000'); - pdo_mysql_stmt_bindparam_types($db, 22, 'FLOAT', -1000); - pdo_mysql_stmt_bindparam_types($db, 23, 'FLOAT UNSIGNED', 1000); - pdo_mysql_stmt_bindparam_types($db, 24, 'FLOAT ZEROFILL', '000000000000'); - pdo_mysql_stmt_bindparam_types($db, 25, 'FLOAT ZEROFILL UNSIGNED', '000000001000'); - pdo_mysql_stmt_bindparam_types($db, 26, 'DECIMAL', -1000); - pdo_mysql_stmt_bindparam_types($db, 27, 'DECIMAL UNSIGNED', 1000); - pdo_mysql_stmt_bindparam_types($db, 28, 'DECIMAL ZEROFILL', '000000000000'); - pdo_mysql_stmt_bindparam_types($db, 29, 'DECIMAL ZEROFILL UNSIGNED', '000000001000'); - pdo_mysql_stmt_bindparam_types($db, 30, 'NUMERIC', -1000); - pdo_mysql_stmt_bindparam_types($db, 31, 'NUMERIC UNSIGNED', 1000); - pdo_mysql_stmt_bindparam_types($db, 32, 'NUMERIC ZEROFILL', '000000000000'); - pdo_mysql_stmt_bindparam_types($db, 33, 'NUMERIC ZEROFILL UNSIGNED', '000000001000'); - pdo_mysql_stmt_bindparam_types($db, 34, 'DATE', '2008-04-23'); - pdo_mysql_stmt_bindparam_types($db, 35, 'TIME', '16:43:12'); - pdo_mysql_stmt_bindparam_types($db, 36, 'TIMESTAMP', '2008-04-23 16:44:53'); - pdo_mysql_stmt_bindparam_types($db, 37, 'DATETIME', '2008-04-23 16:44:53'); - pdo_mysql_stmt_bindparam_types($db, 38, 'YEAR', '2008'); - pdo_mysql_stmt_bindparam_types($db, 39, 'CHAR(1)', 'a'); - pdo_mysql_stmt_bindparam_types($db, 40, 'CHAR(255)', 'abc'); - pdo_mysql_stmt_bindparam_types($db, 41, 'VARCHAR(255)', str_repeat('a', 255)); - pdo_mysql_stmt_bindparam_types($db, 42, 'BINARY(255)', str_repeat('a', 255)); - pdo_mysql_stmt_bindparam_types($db, 43, 'VARBINARY(255)', str_repeat('a', 255)); - pdo_mysql_stmt_bindparam_types($db, 44, 'TINYBLOB', str_repeat('a', 255)); - pdo_mysql_stmt_bindparam_types($db, 45, 'BLOB', str_repeat('b', 300)); - pdo_mysql_stmt_bindparam_types($db, 46, 'MEDIUMBLOB', str_repeat('b', 300)); - pdo_mysql_stmt_bindparam_types($db, 47, 'LONGBLOB', str_repeat('b', 300)); - pdo_mysql_stmt_bindparam_types($db, 48, 'TINYTEXT', str_repeat('c', 255)); - pdo_mysql_stmt_bindparam_types($db, 49, 'TINYTEXT BINARY', str_repeat('c', 255)); - pdo_mysql_stmt_bindparam_types($db, 50, 'TEXT', str_repeat('d', 300)); - pdo_mysql_stmt_bindparam_types($db, 51, 'TEXT BINARY', str_repeat('d', 300)); - pdo_mysql_stmt_bindparam_types($db, 52, 'MEDIUMTEXT', str_repeat('d', 300)); - pdo_mysql_stmt_bindparam_types($db, 53, 'MEDIUMTEXT BINARY', str_repeat('d', 300)); - pdo_mysql_stmt_bindparam_types($db, 54, 'LONGTEXT', str_repeat('d', 300)); - pdo_mysql_stmt_bindparam_types($db, 55, 'LONGTEXT BINARY', str_repeat('d', 300)); - pdo_mysql_stmt_bindparam_types($db, 56, "ENUM('yes', 'no') DEFAULT 'yes'", "no"); - pdo_mysql_stmt_bindparam_types($db, 57, "SET('yes', 'no') DEFAULT 'yes'", "no"); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + + function pdo_mysql_stmt_bindparam_types_do($db, $offset, $native, $sql_type, $value) { + + if ($native) + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + else + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); + if ((!$stmt = @$db->prepare($sql)) || (!@$stmt->execute())) + // Server might not support column type - skip it + return true; + + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, ?)'); + if (!$stmt->bindParam(1, $value)) { + printf("[%03d/%s + 1] %s\n", $offset, ($native) ? 'native' : 'emulated', + var_export($stmt->errorInfo(), true)); + return false; + } + if (!$stmt->execute()) { + printf("[%03d/%s + 2] %s\n", $offset, ($native) ? 'native' : 'emulated', + var_export($stmt->errorInfo(), true)); + return false; + } + + $stmt = $db->query('SELECT id, label FROM test'); + $id = $label = null; + if (!$stmt->bindColumn(1, $id)) { + printf("[%03d/%s + 3] %s\n", $offset, ($native) ? 'native' : 'emulated', + var_export($stmt->errorInfo(), true)); + return false; + } + if (!$stmt->bindColumn(2, $label)) { + printf("[%03d/%s + 4] %s\n", $offset, ($native) ? 'native' : 'emulated', + var_export($stmt->errorInfo(), true)); + return false; + } + + if (!$stmt->fetch(PDO::FETCH_BOUND)) { + printf("[%03d/%s + 5] %s\n", $offset, ($native) ? 'native' : 'emulated', + var_export($stmt->errorInfo(), true)); + return false; + } + $stmt->closeCursor(); + + if ($label != $value) { + printf("[%03d/%s + 6] Got %s expecting %s - please check manually\n", + $offset, ($native) ? 'native' : 'emulated', + var_export($label, true), var_export($value, true)); + // fall through + } + + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (empty($row)) { + printf("[%03d/%s + 7] %s\n", $offset, ($native) ? 'native' : 'emulated', + var_export($stmt->errorInfo(), true)); + return false; + } + + if ($row['label'] != $value) { + printf("[%03d/%s + 8] Got %s expecting %s - please check manually\n", + $offset, ($native) ? 'native' : 'emulated', + var_export($row['label'], true), var_export($value, true)); + return false; + } + + if ($row['label'] != $label) { + printf("[%03d/%s + 9] Got %s from FETCH_ASSOC and %s from FETCH_BOUND- please check manually\n", + $offset, ($native) ? 'native' : 'emulated', + var_export($row['label'], true), var_export($value, true)); + return false; + } + + $db->exec('DROP TABLE IF EXISTS test'); + return true; + } + + function pdo_mysql_stmt_bindparam_types($db, $offset, $sql_type, $value) { + + pdo_mysql_stmt_bindparam_types_do($db, $offset, true, $sql_type, $value); + pdo_mysql_stmt_bindparam_types_do($db, $offset, false, $sql_type, $value); + + } + + try { + + // pdo_mysql_stmt_bindparam_types($db, 2, 'BIT(8)', 1); + pdo_mysql_stmt_bindparam_types($db, 3, 'TINYINT', -127); + pdo_mysql_stmt_bindparam_types($db, 4, 'TINYINT UNSIGNED', 255); + pdo_mysql_stmt_bindparam_types($db, 5, 'BOOLEAN', 1); + pdo_mysql_stmt_bindparam_types($db, 6, 'SMALLINT', -32768); + pdo_mysql_stmt_bindparam_types($db, 7, 'SMALLINT UNSIGNED', 65535); + pdo_mysql_stmt_bindparam_types($db, 8, 'MEDIUMINT', -8388608); + pdo_mysql_stmt_bindparam_types($db, 9, 'MEDIUMINT UNSIGNED', 16777215); + pdo_mysql_stmt_bindparam_types($db, 10, 'INT', -2147483648); + pdo_mysql_stmt_bindparam_types($db, 11, 'INT UNSIGNED', 4294967295); + pdo_mysql_stmt_bindparam_types($db, 12, 'BIGINT', -1000); + pdo_mysql_stmt_bindparam_types($db, 13, 'BIGINT UNSIGNED', 1000); + pdo_mysql_stmt_bindparam_types($db, 14, 'REAL', -1000); + pdo_mysql_stmt_bindparam_types($db, 15, 'REAL UNSIGNED', 1000); + pdo_mysql_stmt_bindparam_types($db, 16, 'REAL ZEROFILL', '0000000000000000000000'); + pdo_mysql_stmt_bindparam_types($db, 17, 'REAL UNSIGNED ZEROFILL', '0000000000000000000010'); + pdo_mysql_stmt_bindparam_types($db, 18, 'DOUBLE', -1000); + pdo_mysql_stmt_bindparam_types($db, 19, 'DOUBLE UNSIGNED', 1000); + pdo_mysql_stmt_bindparam_types($db, 20, 'DOUBLE ZEROFILL', '000000000000'); + pdo_mysql_stmt_bindparam_types($db, 21, 'DOUBLE ZEROFILL UNSIGNED', '000000001000'); + pdo_mysql_stmt_bindparam_types($db, 22, 'FLOAT', -1000); + pdo_mysql_stmt_bindparam_types($db, 23, 'FLOAT UNSIGNED', 1000); + pdo_mysql_stmt_bindparam_types($db, 24, 'FLOAT ZEROFILL', '000000000000'); + pdo_mysql_stmt_bindparam_types($db, 25, 'FLOAT ZEROFILL UNSIGNED', '000000001000'); + pdo_mysql_stmt_bindparam_types($db, 26, 'DECIMAL', -1000); + pdo_mysql_stmt_bindparam_types($db, 27, 'DECIMAL UNSIGNED', 1000); + pdo_mysql_stmt_bindparam_types($db, 28, 'DECIMAL ZEROFILL', '000000000000'); + pdo_mysql_stmt_bindparam_types($db, 29, 'DECIMAL ZEROFILL UNSIGNED', '000000001000'); + pdo_mysql_stmt_bindparam_types($db, 30, 'NUMERIC', -1000); + pdo_mysql_stmt_bindparam_types($db, 31, 'NUMERIC UNSIGNED', 1000); + pdo_mysql_stmt_bindparam_types($db, 32, 'NUMERIC ZEROFILL', '000000000000'); + pdo_mysql_stmt_bindparam_types($db, 33, 'NUMERIC ZEROFILL UNSIGNED', '000000001000'); + pdo_mysql_stmt_bindparam_types($db, 34, 'DATE', '2008-04-23'); + pdo_mysql_stmt_bindparam_types($db, 35, 'TIME', '16:43:12'); + pdo_mysql_stmt_bindparam_types($db, 36, 'TIMESTAMP', '2008-04-23 16:44:53'); + pdo_mysql_stmt_bindparam_types($db, 37, 'DATETIME', '2008-04-23 16:44:53'); + pdo_mysql_stmt_bindparam_types($db, 38, 'YEAR', '2008'); + pdo_mysql_stmt_bindparam_types($db, 39, 'CHAR(1)', 'a'); + pdo_mysql_stmt_bindparam_types($db, 40, 'CHAR(255)', 'abc'); + pdo_mysql_stmt_bindparam_types($db, 41, 'VARCHAR(255)', str_repeat('a', 255)); + pdo_mysql_stmt_bindparam_types($db, 42, 'BINARY(255)', str_repeat('a', 255)); + pdo_mysql_stmt_bindparam_types($db, 43, 'VARBINARY(255)', str_repeat('a', 255)); + pdo_mysql_stmt_bindparam_types($db, 44, 'TINYBLOB', str_repeat('a', 255)); + pdo_mysql_stmt_bindparam_types($db, 45, 'BLOB', str_repeat('b', 300)); + pdo_mysql_stmt_bindparam_types($db, 46, 'MEDIUMBLOB', str_repeat('b', 300)); + pdo_mysql_stmt_bindparam_types($db, 47, 'LONGBLOB', str_repeat('b', 300)); + pdo_mysql_stmt_bindparam_types($db, 48, 'TINYTEXT', str_repeat('c', 255)); + pdo_mysql_stmt_bindparam_types($db, 49, 'TINYTEXT BINARY', str_repeat('c', 255)); + pdo_mysql_stmt_bindparam_types($db, 50, 'TEXT', str_repeat('d', 300)); + pdo_mysql_stmt_bindparam_types($db, 51, 'TEXT BINARY', str_repeat('d', 300)); + pdo_mysql_stmt_bindparam_types($db, 52, 'MEDIUMTEXT', str_repeat('d', 300)); + pdo_mysql_stmt_bindparam_types($db, 53, 'MEDIUMTEXT BINARY', str_repeat('d', 300)); + pdo_mysql_stmt_bindparam_types($db, 54, 'LONGTEXT', str_repeat('d', 300)); + pdo_mysql_stmt_bindparam_types($db, 55, 'LONGTEXT BINARY', str_repeat('d', 300)); + pdo_mysql_stmt_bindparam_types($db, 56, "ENUM('yes', 'no') DEFAULT 'yes'", "no"); + pdo_mysql_stmt_bindparam_types($db, 57, "SET('yes', 'no') DEFAULT 'yes'", "no"); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); - - printf("Binding variable...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindValue(1, $in)) - printf("[003] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[004] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[005] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Binding value and not variable...\n"); - if (!$stmt->bindValue(1, 0)) - printf("[006] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[007] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[008] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Binding variable which references another variable...\n"); - $in = 0; - $in_ref = &$in; - if (!$stmt->bindValue(1, $in_ref)) - printf("[009] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[010] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[011] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - - printf("Binding a variable and a value...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindValue(1, $in)) - printf("[012] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindValue(2, 2)) - printf("[013] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[014] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[015] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Binding a variable to two placeholders and changing the variable value in between the binds...\n"); - // variable value change shall have no impact - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindValue(1, $in)) - printf("[016] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $in = 2; - if (!$stmt->bindValue(2, $in)) - printf("[017] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[018] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[019] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - printf("Testing emulated PS...\n"); - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); - - printf("Binding variable...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindValue(1, $in)) - printf("[003] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[004] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[005] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Binding value and not variable...\n"); - if (!$stmt->bindValue(1, 0)) - printf("[006] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[007] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[008] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Binding variable which references another variable...\n"); - $in = 0; - $in_ref = &$in; - if (!$stmt->bindValue(1, $in_ref)) - printf("[009] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[010] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[011] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - - printf("Binding a variable and a value...\n"); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindValue(1, $in)) - printf("[012] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindValue(2, 2)) - printf("[013] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[014] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[015] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - printf("Binding a variable to two placeholders and changing the variable value in between the binds...\n"); - // variable value change shall have no impact - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindValue(1, $in)) - printf("[016] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $in = 2; - if (!$stmt->bindValue(2, $in)) - printf("[017] Cannot bind value, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[018] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[019] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + + printf("Testing native PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); + + printf("Binding variable...\n"); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindValue(1, $in)) + printf("[003] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[004] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[005] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Binding value and not variable...\n"); + if (!$stmt->bindValue(1, 0)) + printf("[006] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[007] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[008] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Binding variable which references another variable...\n"); + $in = 0; + $in_ref = &$in; + if (!$stmt->bindValue(1, $in_ref)) + printf("[009] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[010] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[011] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + + printf("Binding a variable and a value...\n"); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindValue(1, $in)) + printf("[012] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindValue(2, 2)) + printf("[013] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[014] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[015] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Binding a variable to two placeholders and changing the variable value in between the binds...\n"); + // variable value change shall have no impact + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindValue(1, $in)) + printf("[016] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $in = 2; + if (!$stmt->bindValue(2, $in)) + printf("[017] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[018] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[019] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + printf("Testing emulated PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); + + printf("Binding variable...\n"); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindValue(1, $in)) + printf("[003] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[004] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[005] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Binding value and not variable...\n"); + if (!$stmt->bindValue(1, 0)) + printf("[006] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[007] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[008] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Binding variable which references another variable...\n"); + $in = 0; + $in_ref = &$in; + if (!$stmt->bindValue(1, $in_ref)) + printf("[009] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[010] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[011] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + + printf("Binding a variable and a value...\n"); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindValue(1, $in)) + printf("[012] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindValue(2, 2)) + printf("[013] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[014] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[015] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + printf("Binding a variable to two placeholders and changing the variable value in between the binds...\n"); + // variable value change shall have no impact + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? AND id <= ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindValue(1, $in)) + printf("[016] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $in = 2; + if (!$stmt->bindValue(2, $in)) + printf("[017] Cannot bind value, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[018] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[019] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label BLOB) ENGINE=%s', PDO_MYSQL_TEST_ENGINE); - $db->exec($sql); - - if (!$stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)')) { - printf("[%03d + 4] %s\n", $offset, var_export($db->errorInfo(), true)); - return false; - } - - $fp = fopen($file, 'r'); - if (!$fp) { - printf("[%03d + 5] Cannot create test file '%s'\n", $offset, $file); - return false; - } - - - $id = 1; - $stmt->bindParam(1, $id); - if (true !== ($tmp = $stmt->bindParam(2, $fp, PDO::PARAM_LOB))) { - printf("[%03d + 6] Expecting true, got %s. %s\n", - $offset, - var_export($tmp, true), - var_export($db->errorInfo(), true)); - return false; - } - - if (true !== $stmt->execute()) { - printf("[%03d + 7] Failed to INSERT data, %s\n", $offset, var_export($stmt->errorInfo(), true)); - return false; - } - - $stmt2 = $db->query('SELECT id, label FROM test WHERE id = 1'); - $row = $stmt2->fetch(PDO::FETCH_ASSOC); - if ($row['label'] != $blob) { - printf("[%03d + 8] INSERT and/or SELECT has failed, dumping data.\n", $offset); - var_dump($row); - var_dump($blob); - return false; - } - - // Lets test the chr(0) handling in case the streaming has failed: - // is the bug about chr(0) or the streaming... - $db->exec('DELETE FROM test'); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); - $stmt->bindParam(1, $id); - $stmt->bindParam(2, $blob); - if (true !== $stmt->execute()) - printf("[%03d + 9] %s\n", $offset, var_export($stmt->errorInfo(), true)); - - $stmt2 = $db->query('SELECT id, label FROM test WHERE id = 1'); - $row = $stmt2->fetch(PDO::FETCH_ASSOC); - if ($row['label'] != $blob) { - printf("[%03d + 10] INSERT and/or SELECT has failed, dumping data.\n", $offset); - var_dump($row); - var_dump($blob); - return false; - } - - return true; - } - - $db = MySQLPDOTest::factory(); - $blob = 'I am a mighty BLOB!' . chr(0) . "I am a binary thingie!"; - $tmp = MySQLPDOTest::getTempDir(); - $file = $tmp . DIRECTORY_SEPARATOR . 'pdoblob.tst'; - - try { - - printf("Emulated PS...\n"); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - blob_from_stream(10, $db, $file, $blob); - - printf("Native PS...\n"); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - blob_from_stream(30, $db, $file, $blob); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + function blob_from_stream($offset, $db, $file, $blob) { + + @unlink($file); + clearstatcache(); + if (file_exists($file)) { + printf("[%03d + 1] Cannot remove old test file\n", $offset); + return false; + } + + $fp = fopen($file, 'w'); + if (!$fp || !fwrite($fp, $blob)) { + printf("[%03d + 2] Cannot create test file '%s'\n", $offset, $file); + return false; + } + + fclose($fp); + clearstatcache(); + if (!file_exists($file)) { + printf("[%03d + 3] Failed to create test file '%s'\n", $offset, $file); + return false; + } + + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label BLOB) ENGINE=%s', PDO_MYSQL_TEST_ENGINE); + $db->exec($sql); + + if (!$stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)')) { + printf("[%03d + 4] %s\n", $offset, var_export($db->errorInfo(), true)); + return false; + } + + $fp = fopen($file, 'r'); + if (!$fp) { + printf("[%03d + 5] Cannot create test file '%s'\n", $offset, $file); + return false; + } + + + $id = 1; + $stmt->bindParam(1, $id); + if (true !== ($tmp = $stmt->bindParam(2, $fp, PDO::PARAM_LOB))) { + printf("[%03d + 6] Expecting true, got %s. %s\n", + $offset, + var_export($tmp, true), + var_export($db->errorInfo(), true)); + return false; + } + + if (true !== $stmt->execute()) { + printf("[%03d + 7] Failed to INSERT data, %s\n", $offset, var_export($stmt->errorInfo(), true)); + return false; + } + + $stmt2 = $db->query('SELECT id, label FROM test WHERE id = 1'); + $row = $stmt2->fetch(PDO::FETCH_ASSOC); + if ($row['label'] != $blob) { + printf("[%03d + 8] INSERT and/or SELECT has failed, dumping data.\n", $offset); + var_dump($row); + var_dump($blob); + return false; + } + + // Lets test the chr(0) handling in case the streaming has failed: + // is the bug about chr(0) or the streaming... + $db->exec('DELETE FROM test'); + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); + $stmt->bindParam(1, $id); + $stmt->bindParam(2, $blob); + if (true !== $stmt->execute()) + printf("[%03d + 9] %s\n", $offset, var_export($stmt->errorInfo(), true)); + + $stmt2 = $db->query('SELECT id, label FROM test WHERE id = 1'); + $row = $stmt2->fetch(PDO::FETCH_ASSOC); + if ($row['label'] != $blob) { + printf("[%03d + 10] INSERT and/or SELECT has failed, dumping data.\n", $offset); + var_dump($row); + var_dump($blob); + return false; + } + + return true; + } + + $db = MySQLPDOTest::factory(); + $blob = 'I am a mighty BLOB!' . chr(0) . "I am a binary thingie!"; + $tmp = MySQLPDOTest::getTempDir(); + $file = $tmp . DIRECTORY_SEPARATOR . 'pdoblob.tst'; + + try { + + printf("Emulated PS...\n"); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + blob_from_stream(10, $db, $file, $blob); + + printf("Native PS...\n"); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + blob_from_stream(30, $db, $file, $blob); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- 255, - 'TINYTEXT' => 255, - 'BLOB' => 32767, - 'TEXT' => 32767, - 'MEDIUMBLOB' => 100000, - 'MEDIUMTEXT' => 100000, - 'LONGBLOB' => 100000, - 'LONGTEXT' => 100000, - ); + $blobs = array( + 'TINYBLOB' => 255, + 'TINYTEXT' => 255, + 'BLOB' => 32767, + 'TEXT' => 32767, + 'MEDIUMBLOB' => 100000, + 'MEDIUMTEXT' => 100000, + 'LONGBLOB' => 100000, + 'LONGTEXT' => 100000, + ); - function test_blob($db, $offset, $sql_type, $test_len) { + function test_blob($db, $offset, $sql_type, $test_len) { - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, PDO_MYSQL_TEST_ENGINE)); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, PDO_MYSQL_TEST_ENGINE)); - $value = str_repeat('a', $test_len); - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); - $stmt->bindValue(1, 1); - $stmt->bindValue(2, $value); - if (!$stmt->execute()) { - printf("[%03d + 1] %d %s\n", - $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - return false; - } + $value = str_repeat('a', $test_len); + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); + $stmt->bindValue(1, 1); + $stmt->bindValue(2, $value); + if (!$stmt->execute()) { + printf("[%03d + 1] %d %s\n", + $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + return false; + } - $stmt = $db->query('SELECT id, label FROM test'); - $id = $label = NULL; - $stmt->bindColumn(1, $id, PDO::PARAM_INT); - $stmt->bindColumn(2, $label, PDO::PARAM_LOB); + $stmt = $db->query('SELECT id, label FROM test'); + $id = $label = NULL; + $stmt->bindColumn(1, $id, PDO::PARAM_INT); + $stmt->bindColumn(2, $label, PDO::PARAM_LOB); - if (!$stmt->fetch(PDO::FETCH_BOUND)) { - printf("[%03d + 2] %d %s\n", - $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - return false; - } + if (!$stmt->fetch(PDO::FETCH_BOUND)) { + printf("[%03d + 2] %d %s\n", + $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + return false; + } - if ($label !== $value) { - printf("[%03d + 3] Returned value seems to be wrong (%d vs. %d characters). Check manually\n", - $offset, strlen($label), strlen($value)); - return false; - } + if ($label !== $value) { + printf("[%03d + 3] Returned value seems to be wrong (%d vs. %d characters). Check manually\n", + $offset, strlen($label), strlen($value)); + return false; + } - if (1 != $id) { - printf("[%03d + 3] Returned id column value seems wrong, expecting 1 got %s.\n", - $offset, var_export($id, true)); - return false; - } + if (1 != $id) { + printf("[%03d + 3] Returned id column value seems wrong, expecting 1 got %s.\n", + $offset, var_export($id, true)); + return false; + } - $stmt = $db->query('SELECT id, label FROM test'); - $ret = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt = $db->query('SELECT id, label FROM test'); + $ret = $stmt->fetch(PDO::FETCH_ASSOC); - if ($ret['label'] !== $value) { - printf("[%03d + 3] Returned value seems to be wrong (%d vs. %d characters). Check manually\n", - $offset, strlen($ret['label']), strlen($value)); - return false; - } + if ($ret['label'] !== $value) { + printf("[%03d + 3] Returned value seems to be wrong (%d vs. %d characters). Check manually\n", + $offset, strlen($ret['label']), strlen($value)); + return false; + } - if (1 != $ret['id']) { - printf("[%03d + 3] Returned id column value seems wrong, expecting 1 got %s.\n", - $offset, var_export($ret['id'], true)); - return false; - } + if (1 != $ret['id']) { + printf("[%03d + 3] Returned id column value seems wrong, expecting 1 got %s.\n", + $offset, var_export($ret['id'], true)); + return false; + } - return true; - } + return true; + } - $offset = 0; - foreach ($blobs as $sql_type => $test_len) { - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - test_blob($db, ++$offset, $sql_type, $test_len); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - test_blob($db, ++$offset, $sql_type, $test_len); - } + $offset = 0; + foreach ($blobs as $sql_type => $test_len) { + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + test_blob($db, ++$offset, $sql_type, $test_len); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + test_blob($db, ++$offset, $sql_type, $test_len); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - // query() shall fail! - $stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - $stmt1->closeCursor(); - - // This is proper usage of closeCursor(). It shall prevent any further error messages. - if (MySQLPDOTest::isPDOMySQLnd()) { - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - } else { - // see pdo_mysql_stmt_unbuffered_2050.phpt for an explanation - unset($stmt1); - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - } - // fetch only the first rows and let closeCursor() clean up - $row1 = $stmt1->fetch(PDO::FETCH_ASSOC); - $stmt1->closeCursor(); - - $stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?'); - $stmt2->bindValue(1, "z"); - - $stmt2->bindValue(2, $row1['id']); - $stmt2->execute(); - $stmt2->closeCursor(); - - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - // check if changing the fetch mode from unbuffered to buffered will - // cause any harm to a statement created prior to the change - $stmt1->execute(); - $row2 = $stmt1->fetch(PDO::FETCH_ASSOC); - $stmt1->closeCursor(); - if (!isset($row2['label']) || ('z' !== $row2['label'])) - printf("Expecting array(id => 1, label => z) got %s\n", var_export($row2, true)); - unset($stmt1); - - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - // should work - $stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - $stmt1->closeCursor(); - - $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); - // fetch only the first rows and let closeCursor() clean up - $row3 = $stmt1->fetch(PDO::FETCH_ASSOC); - $stmt1->closeCursor(); - assert($row3 == $row2); - - $stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?'); - $stmt2->bindValue(1, "a"); - $stmt2->bindValue(2, $row1['id']); - $stmt2->execute(); - $stmt2->closeCursor(); - - $stmt1->execute(); - $row4 = $stmt1->fetch(PDO::FETCH_ASSOC); - $stmt1->closeCursor(); - assert($row4 == $row1); - - $offset = 0; - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindParam(1, $in)) - printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - $stmt->execute(); - $id = $label = null; - - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[%03d + 2] Cannot bind integer column, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); - - $stmt->closeCursor(); - $stmt->execute(); - - } - - - try { - - printf("Testing emulated PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); - - printf("Buffered...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - MySQLPDOTest::createTestTable($db); - pdo_mysql_stmt_closecursor($db); - - printf("Unbuffered...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - MySQLPDOTest::createTestTable($db); - pdo_mysql_stmt_closecursor($db); - - printf("Testing native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); - - printf("Buffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - pdo_mysql_stmt_closecursor($db); - - printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - pdo_mysql_stmt_closecursor($db); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + /* TODO the results look wrong, why do we get 2014 with buffered AND unbuffered queries */ + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + function pdo_mysql_stmt_closecursor($db) { + + // This one should fail. I let it fail to prove that closeCursor() makes a difference. + // If no error messages gets printed do not know if proper usage of closeCursor() makes any + // difference or not. That's why we need to cause an error here. + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + // query() shall fail! + $stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1->closeCursor(); + + // This is proper usage of closeCursor(). It shall prevent any further error messages. + if (MySQLPDOTest::isPDOMySQLnd()) { + $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + } else { + // see pdo_mysql_stmt_unbuffered_2050.phpt for an explanation + unset($stmt1); + $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + } + // fetch only the first rows and let closeCursor() clean up + $row1 = $stmt1->fetch(PDO::FETCH_ASSOC); + $stmt1->closeCursor(); + + $stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?'); + $stmt2->bindValue(1, "z"); + + $stmt2->bindValue(2, $row1['id']); + $stmt2->execute(); + $stmt2->closeCursor(); + + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + // check if changing the fetch mode from unbuffered to buffered will + // cause any harm to a statement created prior to the change + $stmt1->execute(); + $row2 = $stmt1->fetch(PDO::FETCH_ASSOC); + $stmt1->closeCursor(); + if (!isset($row2['label']) || ('z' !== $row2['label'])) + printf("Expecting array(id => 1, label => z) got %s\n", var_export($row2, true)); + unset($stmt1); + + $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + // should work + $stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + $stmt1->closeCursor(); + + $stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC'); + // fetch only the first rows and let closeCursor() clean up + $row3 = $stmt1->fetch(PDO::FETCH_ASSOC); + $stmt1->closeCursor(); + assert($row3 == $row2); + + $stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?'); + $stmt2->bindValue(1, "a"); + $stmt2->bindValue(2, $row1['id']); + $stmt2->execute(); + $stmt2->closeCursor(); + + $stmt1->execute(); + $row4 = $stmt1->fetch(PDO::FETCH_ASSOC); + $stmt1->closeCursor(); + assert($row4 == $row1); + + $offset = 0; + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindParam(1, $in)) + printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + $stmt->execute(); + $id = $label = null; + + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[%03d + 2] Cannot bind integer column, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); + + $stmt->closeCursor(); + $stmt->execute(); + + } + + + try { + + printf("Testing emulated PS...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); + + printf("Buffered...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + MySQLPDOTest::createTestTable($db); + pdo_mysql_stmt_closecursor($db); + + printf("Unbuffered...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + MySQLPDOTest::createTestTable($db); + pdo_mysql_stmt_closecursor($db); + + printf("Testing native PS...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); + + printf("Buffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + pdo_mysql_stmt_closecursor($db); + + printf("Unbuffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + pdo_mysql_stmt_closecursor($db); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + MySQLPDOTest::createTestTable($db); - $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); - $in = 0; - if (!$stmt->bindParam(1, $in)) - printf("[003] Cannot bind parameter, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2'); + $in = 0; + if (!$stmt->bindParam(1, $in)) + printf("[003] Cannot bind parameter, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - $stmt->execute(); - $id = $label = null; + $stmt->execute(); + $id = $label = null; - if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) - printf("[004] Cannot bind integer column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) + printf("[004] Cannot bind integer column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) - printf("[005] Cannot bind string column, %s %s\n", - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) + printf("[005] Cannot bind string column, %s %s\n", + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); - $stmt->closeCursor(); - $stmt->execute(); - while ($stmt->fetch(PDO::FETCH_BOUND)) - printf("in = %d -> id = %s (%s) / label = %s (%s)\n", - $in, - var_export($id, true), gettype($id), - var_export($label, true), gettype($label)); + $stmt->closeCursor(); + $stmt->execute(); + while ($stmt->fetch(PDO::FETCH_BOUND)) + printf("in = %d -> id = %s (%s) / label = %s (%s)\n", + $in, + var_export($id, true), gettype($id), + var_export($label, true), gettype($label)); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - $db->exec('DROP TABLE IF EXISTS test'); - print "done!"; + $db->exec('DROP TABLE IF EXISTS test'); + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); + // Internal data structures should be the same in both cases. + printf("Testing emulated PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare("SELECT id, label, '?' as foo FROM test"); - $stmt->execute(); - var_dump($stmt->columnCount()); + $stmt = $db->prepare("SELECT id, label, '?' as foo FROM test"); + $stmt->execute(); + var_dump($stmt->columnCount()); - $stmt = $db->query('SELECT * FROM test'); - var_dump($stmt->columnCount()); + $stmt = $db->query('SELECT * FROM test'); + var_dump($stmt->columnCount()); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - printf("Testing native PS...\n"); - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn off emulated prepared statements\n"); + printf("Testing native PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare("SELECT id, label, '?' as foo, 'TODO - Stored Procedure' as bar FROM test"); - $stmt->execute(); - var_dump($stmt->columnCount()); + $stmt = $db->prepare("SELECT id, label, '?' as foo, 'TODO - Stored Procedure' as bar FROM test"); + $stmt->execute(); + var_dump($stmt->columnCount()); - $stmt = $db->query('SELECT * FROM test'); - var_dump($stmt->columnCount()); + $stmt = $db->query('SELECT * FROM test'); + var_dump($stmt->columnCount()); - } catch (PDOException $e) { - printf("[003] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[003] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS ihopeitdoesnotexist'); + $db->exec('DROP TABLE IF EXISTS ihopeitdoesnotexist'); - printf("Testing emulated PS...\n"); - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); + printf("Testing emulated PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); - $stmt->execute(); - var_dump($stmt->errorCode()); + $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + $stmt->execute(); + var_dump($stmt->errorCode()); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - printf("Testing native PS...\n"); - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn off emulated prepared statements\n"); + printf("Testing native PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); - $stmt->execute(); - var_dump($stmt->errorCode()); + $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + $stmt->execute(); + var_dump($stmt->errorCode()); - } catch (PDOException $e) { - printf("[003] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[003] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --EXPECTF-- Testing emulated PS... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt index e9dbeab3a61f..b876628e257d 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt @@ -9,55 +9,55 @@ $db = MySQLPDOTest::factory(); ?> --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); + printf("Testing emulated PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); - var_dump($stmt->errorInfo()); - $stmt->execute(); - var_dump($stmt->errorInfo()); + $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + var_dump($stmt->errorInfo()); + $stmt->execute(); + var_dump($stmt->errorInfo()); - MySQLPDOTest::createTestTable($db); - $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); - $db->exec('DROP TABLE test'); - var_dump($stmt->execute()); - var_dump($stmt->errorInfo()); - var_dump($db->errorInfo()); + MySQLPDOTest::createTestTable($db); + $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); + $db->exec('DROP TABLE test'); + var_dump($stmt->execute()); + var_dump($stmt->errorInfo()); + var_dump($db->errorInfo()); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); + } - printf("Testing native PS...\n"); - try { - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn off emulated prepared statements\n"); + printf("Testing native PS...\n"); + try { + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn off emulated prepared statements\n"); - $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); - var_dump($stmt); + $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); + var_dump($stmt); - MySQLPDOTest::createTestTable($db); - $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); - var_dump($stmt->errorInfo()); - $db->exec('DROP TABLE test'); - $stmt->execute(); - var_dump($stmt->errorInfo()); - var_dump($db->errorInfo()); + MySQLPDOTest::createTestTable($db); + $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); + var_dump($stmt->errorInfo()); + $db->exec('DROP TABLE test'); + $stmt->execute(); + var_dump($stmt->errorInfo()); + var_dump($db->errorInfo()); - } catch (PDOException $e) { - printf("[003] %s [%s] %s\n", - $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); - } - print "done!"; + } catch (PDOException $e) { + printf("[003] %s [%s] %s\n", + $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); + } + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); - if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn on emulated prepared statements\n"); - - if (!is_object($stmt = $db->query('DESCRIBE test id'))) - printf("[003] Emulated PS, DESCRIBE failed, %s\n", var_export($db->errorInfo(), true)); - - $describe = array(); - $valid = false; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $describe[] = $row; - foreach ($row as $column => $value) - if (isset($row['field']) && ($row['field'] == 'id')) - $valid = true; - } - if (empty($describe)) - printf("[004] Emulated PS, DESCRIBE returned no results\n"); - else if (!$valid) - printf("[005] Emulated PS, DESCRIBE, returned data seems wrong, dumping %s\n", - var_export($describe, true)); - - if (!is_object($stmt = $db->query('SHOW ENGINES'))) - printf("[006] Emulated PS, SHOW failed, %s\n", var_export($db->errorInfo(), true)); - - $show = array(); - $valid = false; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $show[] = $row; - foreach ($row as $column => $value) - // MyISAM engine should be part of _every_ MySQL today - if ($value == 'MyISAM') - $valid = true; - } - if (empty($show)) - printf("[007] Emulated PS, SHOW returned no results\n"); - else if (!$valid) - printf("[008] Emulated PS, SHOW data seems wrong, dumping %s\n", - var_export($show, true)); - - if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM test"))) - printf("[009] Emulated PS, EXPLAIN returned no results\n"); - - $explain = array(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) - $explain[] = $row; - - if (empty($explain)) - printf("[010] Emulated PS, EXPLAIN returned no results\n"); - - // And now native PS - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[011] Unable to turn off emulated prepared statements\n"); - - $native_support = 'no'; - if ($db->exec("PREPARE mystmt FROM 'DESCRIBE test id'")) { - $native_support = 'yes'; - $db->exec('DEALLOCATE PREPARE mystmt'); - } - - if (!is_object($stmt = $db->query('DESCRIBE test id'))) - printf("[012] Native PS (native support: %s), DESCRIBE failed, %s\n", - $native_support, - var_export($db->errorInfo(), true)); - - $describe_native = array(); - $valid = false; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $describe_native[] = $row; - foreach ($row as $column => $value) - if (isset($row['field']) && ($row['field'] == 'id')) - $valid = true; - } - if (empty($describe_native)) - printf("[013] Native PS (native support: %s), DESCRIBE returned no results\n", - $native_support); - else if (!$valid) - printf("[014] Native PS (native support: %s), DESCRIBE, returned data seems wrong, dumping %s\n", - $native_support, - var_export($describe_native, true)); - - if ($describe != $describe_native) - printf("[015] Emulated and native PS (native support: %s) results of DESCRIBE differ: %s vs. %s\n", - $native_support, - var_export($describe, true), - var_export($describe_native, true)); - - - $native_support = 'no'; - if ($db->exec("PREPARE mystmt FROM 'SHOW ENGINES'")) { - $native_support = 'yes'; - $db->exec('DEALLOCATE PREPARE mystmt'); - } - - if (!is_object($stmt = $db->query('SHOW ENGINES'))) - printf("[016] Native PS (native support: %s), SHOW failed, %s\n", - $native_support, - var_export($db->errorInfo(), true)); - - $show_native = array(); - $valid = false; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $show_native[] = $row; - foreach ($row as $column => $value) - // MyISAM engine should be part of _every_ MySQL today - if ($value == 'MyISAM') - $valid = true; - } - if (empty($show_native)) - printf("[017] Native PS (native support: %s), SHOW returned no results\n", - $native_support); - else if (!$valid) - printf("[018] Native PS (native support: %s), SHOW data seems wrong, dumping %s\n", - var_export($show_native, true)); - - if ($show != $show_native) - printf("Native PS (native support: %s) and emulated PS returned different data for SHOW: %s vs. %s\n", - $native_support, - var_export($show, true), - var_export($show_native, true)); - - $native_support = 'no'; - if ($db->exec("PREPARE mystmt FROM 'EXPLAIN SELECT id FROM test'")) { - $native_support = 'yes'; - $db->exec('DEALLOCATE PREPARE mystmt'); - } - - if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM test"))) - printf("[012] Native PS (native support: %s), EXPLAIN failed, %s\n", - $native_support, - var_export($db->errorInfo(), true)); - - $explain_native = array(); - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) - $explain_native[] = $row; - - if (empty($explain_native)) - printf("[013] Native PS (native support: %s), EXPLAIN returned no results\n", - $native_support); - - if ($explain != $explain_native) - printf("Native PS (native support: %s) and emulated PS returned different data for EXPLAIN: %s vs. %s\n", - $native_support, - var_export($explain, true), - var_export($explain_native, true)); - - $stmt->execute(); - $explain_native = $stmt->fetchAll(PDO::FETCH_ASSOC); - if ($explain != $explain_native) - printf("Native PS (native support: %s) and emulated PS returned different data for EXPLAIN: %s vs. %s\n", - $native_support, - var_export($explain, true), - var_export($explain_native, true)); - - $stmt->execute(); - $stmt->execute(); - // libmysql needs this - otherwise we get a 2015 error - if (!MYSQLPDOTest::isPDOMySQLnd()) - $stmt->fetchAll(PDO::FETCH_ASSOC); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!\n"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + + try { + + // Emulated PS first + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); + if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn on emulated prepared statements\n"); + + if (!is_object($stmt = $db->query('DESCRIBE test id'))) + printf("[003] Emulated PS, DESCRIBE failed, %s\n", var_export($db->errorInfo(), true)); + + $describe = array(); + $valid = false; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $describe[] = $row; + foreach ($row as $column => $value) + if (isset($row['field']) && ($row['field'] == 'id')) + $valid = true; + } + if (empty($describe)) + printf("[004] Emulated PS, DESCRIBE returned no results\n"); + else if (!$valid) + printf("[005] Emulated PS, DESCRIBE, returned data seems wrong, dumping %s\n", + var_export($describe, true)); + + if (!is_object($stmt = $db->query('SHOW ENGINES'))) + printf("[006] Emulated PS, SHOW failed, %s\n", var_export($db->errorInfo(), true)); + + $show = array(); + $valid = false; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $show[] = $row; + foreach ($row as $column => $value) + // MyISAM engine should be part of _every_ MySQL today + if ($value == 'MyISAM') + $valid = true; + } + if (empty($show)) + printf("[007] Emulated PS, SHOW returned no results\n"); + else if (!$valid) + printf("[008] Emulated PS, SHOW data seems wrong, dumping %s\n", + var_export($show, true)); + + if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM test"))) + printf("[009] Emulated PS, EXPLAIN returned no results\n"); + + $explain = array(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) + $explain[] = $row; + + if (empty($explain)) + printf("[010] Emulated PS, EXPLAIN returned no results\n"); + + // And now native PS + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[011] Unable to turn off emulated prepared statements\n"); + + $native_support = 'no'; + if ($db->exec("PREPARE mystmt FROM 'DESCRIBE test id'")) { + $native_support = 'yes'; + $db->exec('DEALLOCATE PREPARE mystmt'); + } + + if (!is_object($stmt = $db->query('DESCRIBE test id'))) + printf("[012] Native PS (native support: %s), DESCRIBE failed, %s\n", + $native_support, + var_export($db->errorInfo(), true)); + + $describe_native = array(); + $valid = false; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $describe_native[] = $row; + foreach ($row as $column => $value) + if (isset($row['field']) && ($row['field'] == 'id')) + $valid = true; + } + if (empty($describe_native)) + printf("[013] Native PS (native support: %s), DESCRIBE returned no results\n", + $native_support); + else if (!$valid) + printf("[014] Native PS (native support: %s), DESCRIBE, returned data seems wrong, dumping %s\n", + $native_support, + var_export($describe_native, true)); + + if ($describe != $describe_native) + printf("[015] Emulated and native PS (native support: %s) results of DESCRIBE differ: %s vs. %s\n", + $native_support, + var_export($describe, true), + var_export($describe_native, true)); + + + $native_support = 'no'; + if ($db->exec("PREPARE mystmt FROM 'SHOW ENGINES'")) { + $native_support = 'yes'; + $db->exec('DEALLOCATE PREPARE mystmt'); + } + + if (!is_object($stmt = $db->query('SHOW ENGINES'))) + printf("[016] Native PS (native support: %s), SHOW failed, %s\n", + $native_support, + var_export($db->errorInfo(), true)); + + $show_native = array(); + $valid = false; + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $show_native[] = $row; + foreach ($row as $column => $value) + // MyISAM engine should be part of _every_ MySQL today + if ($value == 'MyISAM') + $valid = true; + } + if (empty($show_native)) + printf("[017] Native PS (native support: %s), SHOW returned no results\n", + $native_support); + else if (!$valid) + printf("[018] Native PS (native support: %s), SHOW data seems wrong, dumping %s\n", + var_export($show_native, true)); + + if ($show != $show_native) + printf("Native PS (native support: %s) and emulated PS returned different data for SHOW: %s vs. %s\n", + $native_support, + var_export($show, true), + var_export($show_native, true)); + + $native_support = 'no'; + if ($db->exec("PREPARE mystmt FROM 'EXPLAIN SELECT id FROM test'")) { + $native_support = 'yes'; + $db->exec('DEALLOCATE PREPARE mystmt'); + } + + if (!is_object($stmt = $db->query("EXPLAIN SELECT id FROM test"))) + printf("[012] Native PS (native support: %s), EXPLAIN failed, %s\n", + $native_support, + var_export($db->errorInfo(), true)); + + $explain_native = array(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) + $explain_native[] = $row; + + if (empty($explain_native)) + printf("[013] Native PS (native support: %s), EXPLAIN returned no results\n", + $native_support); + + if ($explain != $explain_native) + printf("Native PS (native support: %s) and emulated PS returned different data for EXPLAIN: %s vs. %s\n", + $native_support, + var_export($explain, true), + var_export($explain_native, true)); + + $stmt->execute(); + $explain_native = $stmt->fetchAll(PDO::FETCH_ASSOC); + if ($explain != $explain_native) + printf("Native PS (native support: %s) and emulated PS returned different data for EXPLAIN: %s vs. %s\n", + $native_support, + var_export($explain, true), + var_export($explain_native, true)); + + $stmt->execute(); + $stmt->execute(); + // libmysql needs this - otherwise we get a 2015 error + if (!MYSQLPDOTest::isPDOMySQLnd()) + $stmt->fetchAll(PDO::FETCH_ASSOC); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!\n"; ?> --CLEAN-- --FILE-- {$prop} = $value; - } - - public function __get($prop) { - printf("%s(%s)\n", __METHOD__, $prop); - return NULL; - } - - // Singleton - public static function singleton($caller) { - printf("%s(%s)\n", __METHOD__, $caller); - - if (!self::$instance) { - $c = __CLASS__; - self::$instance = new $c($caller); - } - return self::$instance; - } - - // Serializable - public function serialize() { - printf("%s()\n", __METHOD__); - return 'Data from serialize'; - } - - public function unserialize($data) { - printf("%s(%s)\n", __METHOD__, var_export($data, true)); - } - - } - - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[002] Unable to turn off emulated prepared statements\n"); - - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(id INT, myobj BLOB) ENGINE=%s', - MySQLPDOTest::getTableEngine())); - - printf("Creating an object, serializing it and writing it to DB...\n"); - $id = 1; - $obj = myclass::singleton('Creating object'); - $myobj = serialize($obj); - $stmt = $db->prepare('INSERT INTO test(id, myobj) VALUES (?, ?)'); - $stmt->bindValue(1, $id); - $stmt->bindValue(2, $myobj); - $stmt->execute(); - - printf("\nUnserializing the previously serialized object...\n"); - var_dump(unserialize($myobj)); - - printf("\nUsing PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE to fetch the object from DB and unserialize it...\n"); - $stmt = $db->prepare('SELECT myobj FROM test'); - $stmt->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass', array('PDO shall not call __construct()')); - $stmt->execute(); - var_dump($stmt->fetch()); - - printf("\nUsing PDO::FETCH_CLASS to fetch the object from DB and unserialize it...\n"); - $stmt = $db->prepare('SELECT myobj FROM test'); - $stmt->setFetchMode(PDO::FETCH_CLASS, 'myclass', array('PDO shall call __construct()')); - $stmt->execute(); - var_dump($stmt->fetch()); - - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + try { + + class myclass implements Serializable { + + private static $instance = null; + protected $myprotected = 'a protected property'; + + // Good old magic stuff + private function __construct($caller = NULL) { + printf("%s(%s)\n", __METHOD__, $caller); + } + + + public function __destruct() { + // printf("%s()\n", __METHOD__); + } + + public function __sleep() { + printf("%s()\n", __METHOD__); + } + + public function __wakeup() { + printf("%s()\n", __METHOD__); + } + + public function __call($method, $params) { + printf("%s(%s, %s)\n", __METHOD__, $method, var_export($params, true)); + } + + public function __set($prop, $value) { + printf("%s(%s, %s)\n", __METHOD__, $prop, var_export($value, true)); + $this->{$prop} = $value; + } + + public function __get($prop) { + printf("%s(%s)\n", __METHOD__, $prop); + return NULL; + } + + // Singleton + public static function singleton($caller) { + printf("%s(%s)\n", __METHOD__, $caller); + + if (!self::$instance) { + $c = __CLASS__; + self::$instance = new $c($caller); + } + return self::$instance; + } + + // Serializable + public function serialize() { + printf("%s()\n", __METHOD__); + return 'Data from serialize'; + } + + public function unserialize($data) { + printf("%s(%s)\n", __METHOD__, var_export($data, true)); + } + + } + + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[002] Unable to turn off emulated prepared statements\n"); + + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(id INT, myobj BLOB) ENGINE=%s', + MySQLPDOTest::getTableEngine())); + + printf("Creating an object, serializing it and writing it to DB...\n"); + $id = 1; + $obj = myclass::singleton('Creating object'); + $myobj = serialize($obj); + $stmt = $db->prepare('INSERT INTO test(id, myobj) VALUES (?, ?)'); + $stmt->bindValue(1, $id); + $stmt->bindValue(2, $myobj); + $stmt->execute(); + + printf("\nUnserializing the previously serialized object...\n"); + var_dump(unserialize($myobj)); + + printf("\nUsing PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE to fetch the object from DB and unserialize it...\n"); + $stmt = $db->prepare('SELECT myobj FROM test'); + $stmt->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass', array('PDO shall not call __construct()')); + $stmt->execute(); + var_dump($stmt->fetch()); + + printf("\nUsing PDO::FETCH_CLASS to fetch the object from DB and unserialize it...\n"); + $stmt = $db->prepare('SELECT myobj FROM test'); + $stmt->setFetchMode(PDO::FETCH_CLASS, 'myclass', array('PDO shall call __construct()')); + $stmt->execute(); + var_dump($stmt->fetch()); + + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!\n"; + print "done!\n"; ?> --CLEAN-- --FILE-- {$prop} = $value; - } + public function __set($prop, $value) { + printf("%s(%s, %s)\n", __METHOD__, var_export($prop, true), var_export($value, true)); + $this->{$prop} = $value; + } - public function serialize() { - printf("%s()\n", __METHOD__); - return 'Value from serialize()'; - } + public function serialize() { + printf("%s()\n", __METHOD__); + return 'Value from serialize()'; + } - public function unserialize($data) { - printf("%s(%s)\n", __METHOD__, var_export($data, true)); - } + public function unserialize($data) { + printf("%s(%s)\n", __METHOD__, var_export($data, true)); + } - } + } - printf("Lets see what the Serializeable interface makes our object behave like...\n"); - $obj = new myclass('Called by script'); - $tmp = unserialize(serialize($obj)); - var_dump($tmp); + printf("Lets see what the Serializeable interface makes our object behave like...\n"); + $obj = new myclass('Called by script'); + $tmp = unserialize(serialize($obj)); + var_dump($tmp); - printf("\nAnd now magic PDO using fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE)...\n"); - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec(sprintf('CREATE TABLE test(myobj BLOB) ENGINE=%s', MySQLPDOTest::getTableEngine())); - $db->exec("INSERT INTO test(myobj) VALUES ('Data fetched from DB to be given to unserialize()')"); + printf("\nAnd now magic PDO using fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE)...\n"); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec(sprintf('CREATE TABLE test(myobj BLOB) ENGINE=%s', MySQLPDOTest::getTableEngine())); + $db->exec("INSERT INTO test(myobj) VALUES ('Data fetched from DB to be given to unserialize()')"); - $stmt = $db->prepare('SELECT myobj FROM test'); - $stmt->execute(); - $rows = $stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass', array('Called by PDO')); - var_dump($rows[0]); + $stmt = $db->prepare('SELECT myobj FROM test'); + $stmt->execute(); + $rows = $stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass', array('Called by PDO')); + var_dump($rows[0]); - $stmt->execute(); - $rows = $stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass'); - var_dump($rows[0]); + $stmt->execute(); + $rows = $stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass'); + var_dump($rows[0]); - printf("\nAnd now PDO using setFetchMode(PDO::FETCH:CLASS|PDO::FETCH_SERIALIZE) + fetch()...\n"); - $stmt = $db->prepare('SELECT myobj FROM test'); - $stmt->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass', array('Called by PDO')); - $stmt->execute(); - var_dump($stmt->fetch()); + printf("\nAnd now PDO using setFetchMode(PDO::FETCH:CLASS|PDO::FETCH_SERIALIZE) + fetch()...\n"); + $stmt = $db->prepare('SELECT myobj FROM test'); + $stmt->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE, 'myclass', array('Called by PDO')); + $stmt->execute(); + var_dump($stmt->fetch()); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - $db->exec('DROP TABLE IF EXISTS test'); - print "done!\n"; + $db->exec('DROP TABLE IF EXISTS test'); + print "done!\n"; ?> --EXPECTF-- Lets see what the Serializeable interface makes our object behave like... diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt index ae14c056f34e..976068235833 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt @@ -25,52 +25,52 @@ MySQLPDOTest::createTestTable($db); try { - $query = "SELECT id, '', NULL, \"\" FROM test ORDER BY id ASC LIMIT 3"; - $stmt = $db->prepare($query); + $query = "SELECT id, '', NULL, \"\" FROM test ORDER BY id ASC LIMIT 3"; + $stmt = $db->prepare($query); - class myclass { + class myclass { - private $set_calls = 0; - protected static $static_set_calls = 0; + private $set_calls = 0; + protected static $static_set_calls = 0; - // NOTE: PDO does not care about protected - protected $grp; + // NOTE: PDO does not care about protected + protected $grp; - // NOTE: PDO does not care about private and calls __construct() after __set() - private function __construct($param1, $param2) { - printf("myclass::__construct(%s, %s): %d / %d\n", - $param1, $param2, - self::$static_set_calls, $this->set_calls); - } + // NOTE: PDO does not care about private and calls __construct() after __set() + private function __construct($param1, $param2) { + printf("myclass::__construct(%s, %s): %d / %d\n", + $param1, $param2, + self::$static_set_calls, $this->set_calls); + } - // NOTE: PDO will call __set() prior to calling __construct() - public function __set($prop, $value) { - $this->not_a_magic_one(); - printf("myclass::__set(%s, -%s-) %d\n", - $prop, var_export($value, true), $this->set_calls, self::$static_set_calls); - if ("" != $prop) - $this->{$prop} = $value; - } + // NOTE: PDO will call __set() prior to calling __construct() + public function __set($prop, $value) { + $this->not_a_magic_one(); + printf("myclass::__set(%s, -%s-) %d\n", + $prop, var_export($value, true), $this->set_calls, self::$static_set_calls); + if ("" != $prop) + $this->{$prop} = $value; + } - // NOTE: PDO can call regular methods prior to calling __construct() - public function not_a_magic_one() { - $this->set_calls++; - self::$static_set_calls++; - } + // NOTE: PDO can call regular methods prior to calling __construct() + public function not_a_magic_one() { + $this->set_calls++; + self::$static_set_calls++; + } - } - $stmt->execute(); - $rowno = 0; - $rows[] = array(); - while (is_object($rows[] = $stmt->fetchObject('myclass', array($rowno++, $rowno)))) - ; + } + $stmt->execute(); + $rowno = 0; + $rows[] = array(); + while (is_object($rows[] = $stmt->fetchObject('myclass', array($rowno++, $rowno)))) + ; - var_dump($rows[$rowno - 1]); + var_dump($rows[$rowno - 1]); } catch (PDOException $e) { - // we should never get here, we use warnings, but never trust a system... - printf("[001] %s, [%s} %s\n", - $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); + // we should never get here, we use warnings, but never trust a system... + printf("[001] %s, [%s} %s\n", + $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); } print "done!"; diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt index 5ac683ea482e..3526b35c2461 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt @@ -22,277 +22,277 @@ MySQLPDOTest::createTestTable($db); try { - $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); - - // execute() has not been called yet - // NOTE: no warning - if (false !== ($tmp = $stmt->getColumnMeta(0))) - printf("[002] Expecting false got %s\n", var_export($tmp, true)); - - $stmt->execute(); - - // invalid offset - if (false !== ($tmp = @$stmt->getColumnMeta(-1))) - printf("[004] Expecting false got %s\n", var_export($tmp, true)); - - $emulated = $stmt->getColumnMeta(0); - - printf("Testing native PS...\n"); - $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[007] Unable to turn off emulated prepared statements\n"); - - $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); - $stmt->execute(); - $native = $stmt->getColumnMeta(0); - if (count($native) == 0) { - printf("[008] Meta data seems wrong, %s / %s\n", - var_export($native, true), var_export($emulated, true)); - } - - // invalid offset - if (false !== ($tmp = $stmt->getColumnMeta(1))) - printf("[009] Expecting false because of invalid offset got %s\n", var_export($tmp, true)); - - - function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) { - - $db->exec('DROP TABLE IF EXISTS test'); - - $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - if (!($stmt = @$db->prepare($sql)) || (!@$stmt->execute())) { - // Some engines and/or MySQL server versions might not support the data type - return true; - } - - if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) { - printf("[%03d] + 1] Insert failed, %d - %s\n", $offset, - $db->errorCode(), var_export($db->errorInfo(), true)); - return false; - } - - $stmt = $db->prepare('SELECT id, label FROM test'); - $stmt->execute(); - $meta = $stmt->getColumnMeta(1); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - - if (empty($meta)) { - printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - return false; - } - - $elements = array('flags', 'table', 'name', 'len', 'precision', 'pdo_type'); - foreach ($elements as $k => $element) - if (!isset($meta[$element])) { - printf("[%03d + 3] Element %s missing, %s\n", $offset, - $element, var_export($meta, true)); - return false; - } - - if (($meta['table'] != 'test') || ($meta['name'] != 'label')) { - printf("[%03d + 4] Table or field name is wrong, %s\n", $offset, - var_export($meta, true)); - return false; - } - - if (!is_null($native_type)) { - if (!isset($meta['native_type'])) { - printf("[%03d + 5] Element native_type missing, %s\n", $offset, - var_export($meta, true)); - return false; - } - - if (!is_array($native_type)) - $native_type = array($native_type); - - $found = false; - foreach ($native_type as $k => $type) { - if ($meta['native_type'] == $type) { - $found = true; - break; - } - } - - if (!$found) { - printf("[%03d + 6] Expecting native type %s, %s\n", $offset, - var_export($native_type, true), var_export($meta, true)); - return false; - } - } - - if (!is_null($pdo_type) && ($meta['pdo_type'] != $pdo_type)) { - printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, - $pdo_type, var_export($meta, true), var_export($meta['native_type'])); - return false; - } - - return true; - } - - $stmt = $db->prepare('SELECT @@sql_mode AS _mode'); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $real_as_float = (false === stristr($row['_mode'], "REAL_AS_FLOAT")) ? false : true; - - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); - $is_mysqlnd = MySQLPDOTest::isPDOMySQLnd(); - test_meta($db, 20, 'BIT(8)', 1, 'BIT', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - test_meta($db, 30, 'TINYINT', -127, 'TINY', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - test_meta($db, 40, 'TINYINT UNSIGNED', 255, 'TINY', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - test_meta($db, 50, 'BOOLEAN', 1, NULL, ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - - test_meta($db, 60, 'SMALLINT', -32768, 'SHORT', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - test_meta($db, 70, 'SMALLINT UNSIGNED', 65535, 'SHORT', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - - test_meta($db, 80, 'MEDIUMINT', -8388608, 'INT24', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - test_meta($db, 90, 'MEDIUMINT UNSIGNED', 16777215, 'INT24', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - - test_meta($db, 100, 'INT', -2147483648, 'LONG', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - test_meta($db, 110, 'INT UNSIGNED', 4294967295, 'LONG', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - - test_meta($db, 120, 'BIGINT', '-9223372036854775808', 'LONGLONG', ($is_mysqlnd) ? ((PHP_INT_SIZE == 4) ? PDO::PARAM_STR : PDO::PARAM_INT) : PDO::PARAM_STR); - test_meta($db, 130, 'BIGINT UNSIGNED', '18446744073709551615', 'LONGLONG', ($is_mysqlnd) ? ((PHP_INT_SIZE == 4) ? PDO::PARAM_STR : PDO::PARAM_INT) : PDO::PARAM_STR); - - test_meta($db, 130, 'REAL', -1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); - test_meta($db, 140, 'REAL UNSIGNED', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); - test_meta($db, 150, 'REAL ZEROFILL', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); - test_meta($db, 160, 'REAL UNSIGNED ZEROFILL', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); - - test_meta($db, 170, 'DOUBLE', -1.01, 'DOUBLE', PDO::PARAM_STR); - test_meta($db, 180, 'DOUBLE UNSIGNED', 1.01, 'DOUBLE', PDO::PARAM_STR); - test_meta($db, 190, 'DOUBLE ZEROFILL', 1.01, 'DOUBLE', PDO::PARAM_STR); - test_meta($db, 200, 'DOUBLE UNSIGNED ZEROFILL', 1.01, 'DOUBLE', PDO::PARAM_STR); - - test_meta($db, 210, 'FLOAT', -1.01, 'FLOAT', PDO::PARAM_STR); - test_meta($db, 220, 'FLOAT UNSIGNED', 1.01, 'FLOAT', PDO::PARAM_STR); - test_meta($db, 230, 'FLOAT ZEROFILL', 1.01, 'FLOAT', PDO::PARAM_STR); - test_meta($db, 240, 'FLOAT UNSIGNED ZEROFILL', 1.01, 'FLOAT', PDO::PARAM_STR); - - test_meta($db, 250, 'DECIMAL', -1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - test_meta($db, 260, 'DECIMAL UNSIGNED', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - test_meta($db, 270, 'DECIMAL ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - test_meta($db, 280, 'DECIMAL UNSIGNED ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - - test_meta($db, 290, 'NUMERIC', -1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - test_meta($db, 300, 'NUMERIC UNSIGNED', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - test_meta($db, 310, 'NUMERIC ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - test_meta($db, 320, 'NUMERIC UNSIGNED ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); - - test_meta($db, 330, 'DATE', '2008-04-23', array('DATE', 'NEWDATE'), PDO::PARAM_STR); - test_meta($db, 340, 'TIME', '14:37:00', 'TIME', PDO::PARAM_STR); - test_meta($db, 350, 'TIMESTAMP', '2008-03-23 14:38:00', 'TIMESTAMP', PDO::PARAM_STR); - test_meta($db, 360, 'DATETIME', '2008-03-23 14:38:00', 'DATETIME', PDO::PARAM_STR); - test_meta($db, 370, 'YEAR', '2008', 'YEAR', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); - - test_meta($db, 380, 'CHAR(1)', 'a', 'STRING', PDO::PARAM_STR); - test_meta($db, 390, 'CHAR(10)', '0123456789', 'STRING', PDO::PARAM_STR); - test_meta($db, 400, 'CHAR(255)', str_repeat('z', 255), 'STRING', PDO::PARAM_STR); - test_meta($db, 410, 'VARCHAR(1)', 'a', 'VAR_STRING', PDO::PARAM_STR); - test_meta($db, 420, 'VARCHAR(10)', '0123456789', 'VAR_STRING', PDO::PARAM_STR); - test_meta($db, 430, 'VARCHAR(255)', str_repeat('z', 255), 'VAR_STRING', PDO::PARAM_STR); - - test_meta($db, 440, 'BINARY(1)', str_repeat('a', 1), 'STRING', PDO::PARAM_STR); - test_meta($db, 450, 'BINARY(255)', str_repeat('b', 255), 'STRING', PDO::PARAM_STR); - test_meta($db, 460, 'VARBINARY(1)', str_repeat('a', 1), 'VAR_STRING', PDO::PARAM_STR); - test_meta($db, 470, 'VARBINARY(255)', str_repeat('b', 255), 'VAR_STRING', PDO::PARAM_STR); - - test_meta($db, 480, 'TINYBLOB', str_repeat('b', 255), 'BLOB', PDO::PARAM_STR); - test_meta($db, 490, 'BLOB', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - test_meta($db, 500, 'MEDIUMBLOB', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - test_meta($db, 510, 'LONGBLOB', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - - test_meta($db, 520, 'TINYTEXT', str_repeat('b', 255), 'BLOB', PDO::PARAM_STR); - test_meta($db, 530, 'TINYTEXT BINARY', str_repeat('b', 255), 'BLOB', PDO::PARAM_STR); - - test_meta($db, 560, 'TEXT', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - test_meta($db, 570, 'TEXT BINARY', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - - test_meta($db, 580, 'MEDIUMTEXT', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - test_meta($db, 590, 'MEDIUMTEXT BINARY', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - - test_meta($db, 600, 'LONGTEXT', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - test_meta($db, 610, 'LONGTEXT BINARY', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); - - test_meta($db, 620, "ENUM('yes', 'no') DEFAULT 'yes'", 'no', NULL, PDO::PARAM_STR); - test_meta($db, 630, "SET('yes', 'no') DEFAULT 'yes'", 'no', NULL, PDO::PARAM_STR); + $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); + + // execute() has not been called yet + // NOTE: no warning + if (false !== ($tmp = $stmt->getColumnMeta(0))) + printf("[002] Expecting false got %s\n", var_export($tmp, true)); + + $stmt->execute(); + + // invalid offset + if (false !== ($tmp = @$stmt->getColumnMeta(-1))) + printf("[004] Expecting false got %s\n", var_export($tmp, true)); + + $emulated = $stmt->getColumnMeta(0); + + printf("Testing native PS...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[007] Unable to turn off emulated prepared statements\n"); + + $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); + $stmt->execute(); + $native = $stmt->getColumnMeta(0); + if (count($native) == 0) { + printf("[008] Meta data seems wrong, %s / %s\n", + var_export($native, true), var_export($emulated, true)); + } + + // invalid offset + if (false !== ($tmp = $stmt->getColumnMeta(1))) + printf("[009] Expecting false because of invalid offset got %s\n", var_export($tmp, true)); + + + function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) { + + $db->exec('DROP TABLE IF EXISTS test'); + + $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); + if (!($stmt = @$db->prepare($sql)) || (!@$stmt->execute())) { + // Some engines and/or MySQL server versions might not support the data type + return true; + } + + if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) { + printf("[%03d] + 1] Insert failed, %d - %s\n", $offset, + $db->errorCode(), var_export($db->errorInfo(), true)); + return false; + } + + $stmt = $db->prepare('SELECT id, label FROM test'); + $stmt->execute(); + $meta = $stmt->getColumnMeta(1); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + + if (empty($meta)) { + printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + return false; + } + + $elements = array('flags', 'table', 'name', 'len', 'precision', 'pdo_type'); + foreach ($elements as $k => $element) + if (!isset($meta[$element])) { + printf("[%03d + 3] Element %s missing, %s\n", $offset, + $element, var_export($meta, true)); + return false; + } + + if (($meta['table'] != 'test') || ($meta['name'] != 'label')) { + printf("[%03d + 4] Table or field name is wrong, %s\n", $offset, + var_export($meta, true)); + return false; + } + + if (!is_null($native_type)) { + if (!isset($meta['native_type'])) { + printf("[%03d + 5] Element native_type missing, %s\n", $offset, + var_export($meta, true)); + return false; + } + + if (!is_array($native_type)) + $native_type = array($native_type); + + $found = false; + foreach ($native_type as $k => $type) { + if ($meta['native_type'] == $type) { + $found = true; + break; + } + } + + if (!$found) { + printf("[%03d + 6] Expecting native type %s, %s\n", $offset, + var_export($native_type, true), var_export($meta, true)); + return false; + } + } + + if (!is_null($pdo_type) && ($meta['pdo_type'] != $pdo_type)) { + printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, + $pdo_type, var_export($meta, true), var_export($meta['native_type'])); + return false; + } + + return true; + } + + $stmt = $db->prepare('SELECT @@sql_mode AS _mode'); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $real_as_float = (false === stristr($row['_mode'], "REAL_AS_FLOAT")) ? false : true; + + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + $is_mysqlnd = MySQLPDOTest::isPDOMySQLnd(); + test_meta($db, 20, 'BIT(8)', 1, 'BIT', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + test_meta($db, 30, 'TINYINT', -127, 'TINY', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + test_meta($db, 40, 'TINYINT UNSIGNED', 255, 'TINY', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + test_meta($db, 50, 'BOOLEAN', 1, NULL, ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + + test_meta($db, 60, 'SMALLINT', -32768, 'SHORT', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + test_meta($db, 70, 'SMALLINT UNSIGNED', 65535, 'SHORT', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + + test_meta($db, 80, 'MEDIUMINT', -8388608, 'INT24', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + test_meta($db, 90, 'MEDIUMINT UNSIGNED', 16777215, 'INT24', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + + test_meta($db, 100, 'INT', -2147483648, 'LONG', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + test_meta($db, 110, 'INT UNSIGNED', 4294967295, 'LONG', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + + test_meta($db, 120, 'BIGINT', '-9223372036854775808', 'LONGLONG', ($is_mysqlnd) ? ((PHP_INT_SIZE == 4) ? PDO::PARAM_STR : PDO::PARAM_INT) : PDO::PARAM_STR); + test_meta($db, 130, 'BIGINT UNSIGNED', '18446744073709551615', 'LONGLONG', ($is_mysqlnd) ? ((PHP_INT_SIZE == 4) ? PDO::PARAM_STR : PDO::PARAM_INT) : PDO::PARAM_STR); + + test_meta($db, 130, 'REAL', -1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); + test_meta($db, 140, 'REAL UNSIGNED', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); + test_meta($db, 150, 'REAL ZEROFILL', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); + test_meta($db, 160, 'REAL UNSIGNED ZEROFILL', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR); + + test_meta($db, 170, 'DOUBLE', -1.01, 'DOUBLE', PDO::PARAM_STR); + test_meta($db, 180, 'DOUBLE UNSIGNED', 1.01, 'DOUBLE', PDO::PARAM_STR); + test_meta($db, 190, 'DOUBLE ZEROFILL', 1.01, 'DOUBLE', PDO::PARAM_STR); + test_meta($db, 200, 'DOUBLE UNSIGNED ZEROFILL', 1.01, 'DOUBLE', PDO::PARAM_STR); + + test_meta($db, 210, 'FLOAT', -1.01, 'FLOAT', PDO::PARAM_STR); + test_meta($db, 220, 'FLOAT UNSIGNED', 1.01, 'FLOAT', PDO::PARAM_STR); + test_meta($db, 230, 'FLOAT ZEROFILL', 1.01, 'FLOAT', PDO::PARAM_STR); + test_meta($db, 240, 'FLOAT UNSIGNED ZEROFILL', 1.01, 'FLOAT', PDO::PARAM_STR); + + test_meta($db, 250, 'DECIMAL', -1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + test_meta($db, 260, 'DECIMAL UNSIGNED', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + test_meta($db, 270, 'DECIMAL ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + test_meta($db, 280, 'DECIMAL UNSIGNED ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + + test_meta($db, 290, 'NUMERIC', -1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + test_meta($db, 300, 'NUMERIC UNSIGNED', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + test_meta($db, 310, 'NUMERIC ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + test_meta($db, 320, 'NUMERIC UNSIGNED ZEROFILL', 1.01, array('DECIMAL', 'NEWDECIMAL'), PDO::PARAM_STR); + + test_meta($db, 330, 'DATE', '2008-04-23', array('DATE', 'NEWDATE'), PDO::PARAM_STR); + test_meta($db, 340, 'TIME', '14:37:00', 'TIME', PDO::PARAM_STR); + test_meta($db, 350, 'TIMESTAMP', '2008-03-23 14:38:00', 'TIMESTAMP', PDO::PARAM_STR); + test_meta($db, 360, 'DATETIME', '2008-03-23 14:38:00', 'DATETIME', PDO::PARAM_STR); + test_meta($db, 370, 'YEAR', '2008', 'YEAR', ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR); + + test_meta($db, 380, 'CHAR(1)', 'a', 'STRING', PDO::PARAM_STR); + test_meta($db, 390, 'CHAR(10)', '0123456789', 'STRING', PDO::PARAM_STR); + test_meta($db, 400, 'CHAR(255)', str_repeat('z', 255), 'STRING', PDO::PARAM_STR); + test_meta($db, 410, 'VARCHAR(1)', 'a', 'VAR_STRING', PDO::PARAM_STR); + test_meta($db, 420, 'VARCHAR(10)', '0123456789', 'VAR_STRING', PDO::PARAM_STR); + test_meta($db, 430, 'VARCHAR(255)', str_repeat('z', 255), 'VAR_STRING', PDO::PARAM_STR); + + test_meta($db, 440, 'BINARY(1)', str_repeat('a', 1), 'STRING', PDO::PARAM_STR); + test_meta($db, 450, 'BINARY(255)', str_repeat('b', 255), 'STRING', PDO::PARAM_STR); + test_meta($db, 460, 'VARBINARY(1)', str_repeat('a', 1), 'VAR_STRING', PDO::PARAM_STR); + test_meta($db, 470, 'VARBINARY(255)', str_repeat('b', 255), 'VAR_STRING', PDO::PARAM_STR); + + test_meta($db, 480, 'TINYBLOB', str_repeat('b', 255), 'BLOB', PDO::PARAM_STR); + test_meta($db, 490, 'BLOB', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + test_meta($db, 500, 'MEDIUMBLOB', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + test_meta($db, 510, 'LONGBLOB', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + + test_meta($db, 520, 'TINYTEXT', str_repeat('b', 255), 'BLOB', PDO::PARAM_STR); + test_meta($db, 530, 'TINYTEXT BINARY', str_repeat('b', 255), 'BLOB', PDO::PARAM_STR); + + test_meta($db, 560, 'TEXT', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + test_meta($db, 570, 'TEXT BINARY', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + + test_meta($db, 580, 'MEDIUMTEXT', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + test_meta($db, 590, 'MEDIUMTEXT BINARY', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + + test_meta($db, 600, 'LONGTEXT', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + test_meta($db, 610, 'LONGTEXT BINARY', str_repeat('b', 256), 'BLOB', PDO::PARAM_STR); + + test_meta($db, 620, "ENUM('yes', 'no') DEFAULT 'yes'", 'no', NULL, PDO::PARAM_STR); + test_meta($db, 630, "SET('yes', 'no') DEFAULT 'yes'", 'no', NULL, PDO::PARAM_STR); /* | spatial_type */ - // unique key - $db->exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label INT UNIQUE) ENGINE = %s', MySQLPDOTest::getTableEngine()); - if (($stmt = @$db->prepare($sql)) && @$stmt->execute()) { - $db->exec('INSERT INTO test(id, label) VALUES (1, 2)'); - $stmt = $db->query('SELECT id, label FROM test'); - $meta = $stmt->getColumnMeta(1); - if (!isset($meta['flags'])) { - printf("[1000] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'unique_key') - $found = true; - } - if (!$found) - printf("[1001] Flags seem wrong %s\n", var_export($meta, true)); - } - } - - // primary key - $db->exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT PRIMARY KEY NOT NULL AUTO_INCREMENT) ENGINE = %s', MySQLPDOTest::getTableEngine()); - if (($stmt = @$db->prepare($sql)) && @$stmt->execute()) { - $db->exec('INSERT INTO test(id) VALUES (1)'); - $stmt = $db->query('SELECT id FROM test'); - $meta = $stmt->getColumnMeta(0); - if (!isset($meta['flags'])) { - printf("[1002] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'primary_key') - $found = true; - } - if (!$found) - printf("[1003] Flags seem wrong %s\n", var_export($meta, true)); - } - } - - // multiple key - $db->exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label1 INT, label2 INT, INDEX idx1(label1, label2)) ENGINE = %s', MySQLPDOTest::getTableEngine()); - if (($stmt = @$db->prepare($sql)) && @$stmt->execute()) { - $db->exec('INSERT INTO test(id, label1, label2) VALUES (1, 2, 3)'); - $stmt = $db->query('SELECT id, label1, label2 FROM test'); - $meta = $stmt->getColumnMeta(1); - if (!isset($meta['flags'])) { - printf("[1004] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'multiple_key') - $found = true; - } - if (!$found) - printf("[1005] Flags seem wrong %s\n", var_export($meta, true)); - } - } - - $stmt = $db->query('SELECT NULL AS col1'); - $meta = $stmt->getColumnMeta(0); - if ('NULL' !== $meta['native_type']) - printf("[1006] Expecting NULL got %s\n", $meta['native_type']); + // unique key + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label INT UNIQUE) ENGINE = %s', MySQLPDOTest::getTableEngine()); + if (($stmt = @$db->prepare($sql)) && @$stmt->execute()) { + $db->exec('INSERT INTO test(id, label) VALUES (1, 2)'); + $stmt = $db->query('SELECT id, label FROM test'); + $meta = $stmt->getColumnMeta(1); + if (!isset($meta['flags'])) { + printf("[1000] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'unique_key') + $found = true; + } + if (!$found) + printf("[1001] Flags seem wrong %s\n", var_export($meta, true)); + } + } + + // primary key + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT PRIMARY KEY NOT NULL AUTO_INCREMENT) ENGINE = %s', MySQLPDOTest::getTableEngine()); + if (($stmt = @$db->prepare($sql)) && @$stmt->execute()) { + $db->exec('INSERT INTO test(id) VALUES (1)'); + $stmt = $db->query('SELECT id FROM test'); + $meta = $stmt->getColumnMeta(0); + if (!isset($meta['flags'])) { + printf("[1002] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'primary_key') + $found = true; + } + if (!$found) + printf("[1003] Flags seem wrong %s\n", var_export($meta, true)); + } + } + + // multiple key + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label1 INT, label2 INT, INDEX idx1(label1, label2)) ENGINE = %s', MySQLPDOTest::getTableEngine()); + if (($stmt = @$db->prepare($sql)) && @$stmt->execute()) { + $db->exec('INSERT INTO test(id, label1, label2) VALUES (1, 2, 3)'); + $stmt = $db->query('SELECT id, label1, label2 FROM test'); + $meta = $stmt->getColumnMeta(1); + if (!isset($meta['flags'])) { + printf("[1004] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'multiple_key') + $found = true; + } + if (!$found) + printf("[1005] Flags seem wrong %s\n", var_export($meta, true)); + } + } + + $stmt = $db->query('SELECT NULL AS col1'); + $meta = $stmt->getColumnMeta(0); + if ('NULL' !== $meta['native_type']) + printf("[1006] Expecting NULL got %s\n", $meta['native_type']); } catch (PDOException $e) { - // we should never get here, we use warnings, but never trust a system... - printf("[001] %s, [%s} %s\n", - $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); + // we should never get here, we use warnings, but never trust a system... + printf("[001] %s, [%s} %s\n", + $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); } $db->exec('DROP TABLE IF EXISTS test'); diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt index 9e36714d549f..7f4904d23bd9 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt @@ -8,48 +8,48 @@ MySQLPDOTest::skip(); ?> --FILE-- query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1'); - var_dump($stmt->errorInfo()); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - var_dump($stmt->errorInfo()); + $stmt = $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1'); + var_dump($stmt->errorInfo()); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + var_dump($stmt->errorInfo()); - } + } - function mysql_stmt_multiquery_proper_usage($db) { + function mysql_stmt_multiquery_proper_usage($db) { - $stmt = $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1'); - do { - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } while ($stmt->nextRowset()); + $stmt = $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1'); + do { + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + } while ($stmt->nextRowset()); - } + } - try { + try { - printf("Emulated Prepared Statements...\n"); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - mysql_stmt_multiquery_wrong_usage($db); - mysql_stmt_multiquery_proper_usage($db); + printf("Emulated Prepared Statements...\n"); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + mysql_stmt_multiquery_wrong_usage($db); + mysql_stmt_multiquery_proper_usage($db); - printf("Native Prepared Statements...\n"); - $db = MySQLPDOTest::factory(); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - mysql_stmt_multiquery_wrong_usage($db); - mysql_stmt_multiquery_proper_usage($db); + printf("Native Prepared Statements...\n"); + $db = MySQLPDOTest::factory(); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + mysql_stmt_multiquery_wrong_usage($db); + mysql_stmt_multiquery_proper_usage($db); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - MySQLPDOTest::createTestTable($db); + MySQLPDOTest::createTestTable($db); - $stmt = $db->query('SELECT id FROM test'); - if (false !== ($tmp = $stmt->nextRowSet())) - printf("[002] Expecting false got %s\n", var_export($tmp, true)); + $stmt = $db->query('SELECT id FROM test'); + if (false !== ($tmp = $stmt->nextRowSet())) + printf("[002] Expecting false got %s\n", var_export($tmp, true)); - // TODO: should give a warning, but its PDO, let's ignore the missing warning for now - if (false !== ($tmp = $stmt->nextRowSet(1))) - printf("[003] Expecting false got %s\n", var_export($tmp, true)); + // TODO: should give a warning, but its PDO, let's ignore the missing warning for now + if (false !== ($tmp = $stmt->nextRowSet(1))) + printf("[003] Expecting false got %s\n", var_export($tmp, true)); - function test_proc1($db) { + function test_proc1($db) { - $stmt = $db->query('SELECT @VERSION as _version'); - $tmp = $stmt->fetch(PDO::FETCH_ASSOC); - assert($tmp['_version'] === NULL); - while ($stmt->fetch()) ; + $stmt = $db->query('SELECT @VERSION as _version'); + $tmp = $stmt->fetch(PDO::FETCH_ASSOC); + assert($tmp['_version'] === NULL); + while ($stmt->fetch()) ; - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;'); - $db->exec('CALL p(@VERSION)'); - $stmt = $db->query('SELECT @VERSION as _version'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - var_dump($stmt->nextRowSet()); + $db->exec('DROP PROCEDURE IF EXISTS p'); + $db->exec('CREATE PROCEDURE p(OUT ver_param VARCHAR(25)) BEGIN SELECT VERSION() INTO ver_param; END;'); + $db->exec('CALL p(@VERSION)'); + $stmt = $db->query('SELECT @VERSION as _version'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + var_dump($stmt->nextRowSet()); - } + } - function test_proc2($db) { + function test_proc2($db) { - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN SELECT id FROM test ORDER BY id ASC LIMIT 3; SELECT id, label FROM test WHERE id < 4 ORDER BY id DESC LIMIT 3; END;'); - $stmt = $db->query('CALL p()'); - do { - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - } while ($stmt->nextRowSet()); - var_dump($stmt->nextRowSet()); + $db->exec('DROP PROCEDURE IF EXISTS p'); + $db->exec('CREATE PROCEDURE p() BEGIN SELECT id FROM test ORDER BY id ASC LIMIT 3; SELECT id, label FROM test WHERE id < 4 ORDER BY id DESC LIMIT 3; END;'); + $stmt = $db->query('CALL p()'); + do { + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + } while ($stmt->nextRowSet()); + var_dump($stmt->nextRowSet()); - } + } - try { + try { - // Emulated PS - printf("Emulated PS...\n"); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + // Emulated PS + printf("Emulated PS...\n"); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); - test_proc1($db); - test_proc2($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + test_proc1($db); + test_proc2($db); - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); - test_proc1($db); - test_proc2($db); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); + test_proc1($db); + test_proc2($db); - // Native PS - printf("Native PS...\n"); - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - test_proc1($db); - test_proc2($db); + // Native PS + printf("Native PS...\n"); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + test_proc1($db); + test_proc2($db); - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 0); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - test_proc1($db); - test_proc2($db); + test_proc1($db); + test_proc2($db); - @$db->exec('DROP PROCEDURE IF EXISTS p'); + @$db->exec('DROP PROCEDURE IF EXISTS p'); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- query('SELECT id FROM test WHERE 1 = 0')->rowCount())) - printf("[002] Expecting 0 got %s", var_export($tmp, true)); + if (0 !== ($tmp = $db->query('SELECT id FROM test WHERE 1 = 0')->rowCount())) + printf("[002] Expecting 0 got %s", var_export($tmp, true)); - if (1 !== ($tmp = $db->query('SELECT id FROM test WHERE id = 1')->rowCount())) - printf("[003] Expecting 1 got %s", var_export($tmp, true)); + if (1 !== ($tmp = $db->query('SELECT id FROM test WHERE id = 1')->rowCount())) + printf("[003] Expecting 1 got %s", var_export($tmp, true)); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - print "done!"; + print "done!"; ?> --CLEAN-- --FILE-- setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); - if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) - printf("[004] Unable to turn off emulated prepared statements\n"); - - printf("Buffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - printf("Unbuffered...\n"); - MySQLPDOTest::createTestTable($db); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - /* - NOTE - this will cause an error and it OK - When using unbuffered prepared statements MySQL expects you to - fetch all data from the row before sending new data to the server. - PDO::query() will prepare and execute a statement in one step. - After the execution of PDO::query(), MySQL expects you to fetch - the results from the line before sending new commands. However, - PHP/PDO will send a CLOSE message as part of the PDO::query() call. - - The following happens: - - $stmt = PDO::query() - mysql_stmt_prepare() - mysql_stmt_execute() - - $stmt->fetchAll() - mysql_stmt_fetch() - - And now the right side of the expression will be executed first: - $stmt = PDO::query() - PDO::query() - mysql_stmt_prepare - mysql_stmt_execute - - PHP continues at the left side of the expression: - - $stmt = PDO::query() - - What happens is that $stmt gets overwritten. The reference counter of the - zval representing the current value of $stmt. PDO gets a callback that - it has to free the resources associated with the zval representing the - current value of stmt: - mysql_stmt_close - ---> ERROR - ---> execute() has been send on the line, you are supposed to fetch - ---> you must not try to send a CLOSE after execute() - ---> Error: 2050 (CR_FETCH_CANCELED) - ---> Message: Row retrieval was canceled by mysql_stmt_close() call - ---> MySQL does its best to recover the line and cancels the retrieval - - PHP proceeds and assigns the new statement object/zval obtained from - PDO to $stmt. - - Solutions: - - use mysqlnd - - use prepare() + execute() instead of query() - - as there is no explicit close() in PDO, try unset($stmt) before the new assignment - - fix PDO::query() [not the driver, fix PDO itself] - */ - - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - $stmt = $db->prepare('SELECT id, label FROM test WHERE id = 1'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - $stmt = $db->prepare('SELECT id, label FROM test WHERE id = 1'); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - unset($stmt); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - unset($stmt); - $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + try { + + printf("Native PS...\n"); + $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); + if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) + printf("[004] Unable to turn off emulated prepared statements\n"); + + printf("Buffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + printf("Unbuffered...\n"); + MySQLPDOTest::createTestTable($db); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + /* + NOTE - this will cause an error and it OK + When using unbuffered prepared statements MySQL expects you to + fetch all data from the row before sending new data to the server. + PDO::query() will prepare and execute a statement in one step. + After the execution of PDO::query(), MySQL expects you to fetch + the results from the line before sending new commands. However, + PHP/PDO will send a CLOSE message as part of the PDO::query() call. + + The following happens: + + $stmt = PDO::query() + mysql_stmt_prepare() + mysql_stmt_execute() + + $stmt->fetchAll() + mysql_stmt_fetch() + + And now the right side of the expression will be executed first: + $stmt = PDO::query() + PDO::query() + mysql_stmt_prepare + mysql_stmt_execute + + PHP continues at the left side of the expression: + + $stmt = PDO::query() + + What happens is that $stmt gets overwritten. The reference counter of the + zval representing the current value of $stmt. PDO gets a callback that + it has to free the resources associated with the zval representing the + current value of stmt: + mysql_stmt_close + ---> ERROR + ---> execute() has been send on the line, you are supposed to fetch + ---> you must not try to send a CLOSE after execute() + ---> Error: 2050 (CR_FETCH_CANCELED) + ---> Message: Row retrieval was canceled by mysql_stmt_close() call + ---> MySQL does its best to recover the line and cancels the retrieval + + PHP proceeds and assigns the new statement object/zval obtained from + PDO to $stmt. + + Solutions: + - use mysqlnd + - use prepare() + execute() instead of query() + - as there is no explicit close() in PDO, try unset($stmt) before the new assignment + - fix PDO::query() [not the driver, fix PDO itself] + */ + + $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + $stmt = $db->prepare('SELECT id, label FROM test WHERE id = 1'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + $stmt = $db->prepare('SELECT id, label FROM test WHERE id = 1'); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + unset($stmt); + $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + unset($stmt); + $stmt = $db->query('SELECT id, label FROM test WHERE id = 1'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --CLEAN-- --FILE-- fetch(PDO::FETCH_ASSOC); - } while ($stmt->nextRowSet()); - - if (!isset($row['one']) || ($row['one'] != 1)) { - printf("[%03d + 1] Expecting array('one' => 1), got %s\n", $offset, var_export($row, true)); - return false; - } - - if (($columns == 2) && - (!isset($row['two']) || ($row['two'] != 2))) { - printf("[%03d + 2] Expecting array('one' => 1, 'two' => 2), got %s\n", $offset, var_export($row, true)); - return false; - } else if (($columns == 1) && isset($row['two'])) { - printf("[%03d + 3] Expecting one array element got two\n", $offset); - return false; - } - - return true; - } - - try { - - // What will happen if a PS returns a different number of result set column upon each execution? - // Lets try with a SP accepting parameters... - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p(IN cols INT) BEGIN IF cols < 2 THEN SELECT cols AS "one"; ELSE SELECT 1 AS "one", cols AS "two"; END IF; END;'); - - // Emulates PS first - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $stmt = $db->prepare('CALL p(?)'); - - $columns = null; - $stmt->bindParam(1, $columns); - for ($i = 0; $i < 5; $i++) { - $columns = ($i % 2) + 1; - $stmt->execute(); - check_result($i, $stmt, $columns); - } - - if (MySQLPDOTest::isPDOMySQLnd()) { - // Native PS - // Libmysql cannot handle such a stored procedure. You will see leaks with libmysql - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); - $stmt = $db->prepare('CALL p(?)'); - $stmt->bindParam(1, $columns); - for ($i = 5; $i < 10; $i++) { - $columns = ($i % 2) + 1; - $stmt->execute(); - check_result($i, $stmt, $columns); - } - } - - // And now without parameters... - this gives a different control flow inside PDO - $db->exec('DROP PROCEDURE IF EXISTS p'); - $db->exec('CREATE PROCEDURE p() BEGIN DECLARE cols INT; SELECT @numcols INTO cols; IF cols < 2 THEN SET @numcols = 2; SELECT cols AS "one"; ELSE SET @numcols = 1; SELECT 1 AS "one", cols AS "two"; END IF; END;'); - - // Emulates PS first - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); - $db->exec('SET @numcols = 1'); - $stmt = $db->prepare('CALL p()'); - $stmt->execute(); - check_result(11, $stmt, 1); - $stmt->execute(); - check_result(12, $stmt, 2); - $db->exec('SET @numcols = 1'); - $stmt->execute(); - check_result(13, $stmt, 1); - - if (MySQLPDOTest::isPDOMySQLnd()) { - // Native PS - // Libmysql cannot handle such a stored procedure. You will see leaks with libmysql - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); - $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); - $db->exec('SET @numcols = 1'); - $stmt = $db->prepare('CALL p()'); - $stmt->execute(); - check_result(14, $stmt, 1); - $stmt->execute(); - check_result(15, $stmt, 2); - $db->exec('SET @numcols = 1'); - $stmt->execute(); - check_result(16, $stmt, 1); - } - - } catch (PDOException $e) { - printf("[99] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } - - print "done!"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + $db = MySQLPDOTest::factory(); + + function check_result($offset, $stmt, $columns) { + + do { + $row = $stmt->fetch(PDO::FETCH_ASSOC); + } while ($stmt->nextRowSet()); + + if (!isset($row['one']) || ($row['one'] != 1)) { + printf("[%03d + 1] Expecting array('one' => 1), got %s\n", $offset, var_export($row, true)); + return false; + } + + if (($columns == 2) && + (!isset($row['two']) || ($row['two'] != 2))) { + printf("[%03d + 2] Expecting array('one' => 1, 'two' => 2), got %s\n", $offset, var_export($row, true)); + return false; + } else if (($columns == 1) && isset($row['two'])) { + printf("[%03d + 3] Expecting one array element got two\n", $offset); + return false; + } + + return true; + } + + try { + + // What will happen if a PS returns a different number of result set column upon each execution? + // Lets try with a SP accepting parameters... + $db->exec('DROP PROCEDURE IF EXISTS p'); + $db->exec('CREATE PROCEDURE p(IN cols INT) BEGIN IF cols < 2 THEN SELECT cols AS "one"; ELSE SELECT 1 AS "one", cols AS "two"; END IF; END;'); + + // Emulates PS first + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + $stmt = $db->prepare('CALL p(?)'); + + $columns = null; + $stmt->bindParam(1, $columns); + for ($i = 0; $i < 5; $i++) { + $columns = ($i % 2) + 1; + $stmt->execute(); + check_result($i, $stmt, $columns); + } + + if (MySQLPDOTest::isPDOMySQLnd()) { + // Native PS + // Libmysql cannot handle such a stored procedure. You will see leaks with libmysql + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $stmt = $db->prepare('CALL p(?)'); + $stmt->bindParam(1, $columns); + for ($i = 5; $i < 10; $i++) { + $columns = ($i % 2) + 1; + $stmt->execute(); + check_result($i, $stmt, $columns); + } + } + + // And now without parameters... - this gives a different control flow inside PDO + $db->exec('DROP PROCEDURE IF EXISTS p'); + $db->exec('CREATE PROCEDURE p() BEGIN DECLARE cols INT; SELECT @numcols INTO cols; IF cols < 2 THEN SET @numcols = 2; SELECT cols AS "one"; ELSE SET @numcols = 1; SELECT 1 AS "one", cols AS "two"; END IF; END;'); + + // Emulates PS first + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); + $db->exec('SET @numcols = 1'); + $stmt = $db->prepare('CALL p()'); + $stmt->execute(); + check_result(11, $stmt, 1); + $stmt->execute(); + check_result(12, $stmt, 2); + $db->exec('SET @numcols = 1'); + $stmt->execute(); + check_result(13, $stmt, 1); + + if (MySQLPDOTest::isPDOMySQLnd()) { + // Native PS + // Libmysql cannot handle such a stored procedure. You will see leaks with libmysql + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); + $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); + $db->exec('SET @numcols = 1'); + $stmt = $db->prepare('CALL p()'); + $stmt->execute(); + check_result(14, $stmt, 1); + $stmt->execute(); + check_result(15, $stmt, 2); + $db->exec('SET @numcols = 1'); + $stmt->execute(); + check_result(16, $stmt, 1); + } + + } catch (PDOException $e) { + printf("[99] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } + + print "done!"; ?> --EXPECT-- done! diff --git a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt index 83158b348411..f98271d792bc 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt @@ -8,65 +8,65 @@ MySQLPDOTest::skip(); ?> --FILE-- protocol(); - return call_user_func_array(array($this, 'parent::__construct'), func_get_args()); - } + public function __construct() { + $this->protocol(); + return call_user_func_array(array($this, 'parent::__construct'), func_get_args()); + } - public function exec($statement) { - $this->protocol(); - return parent::exec($statement); - } + public function exec($statement) { + $this->protocol(); + return parent::exec($statement); + } - public function query($statement) { - $this->protocol(); - return call_user_func_array(array($this, 'parent::query'), func_get_args()); - } + public function query($statement) { + $this->protocol(); + return call_user_func_array(array($this, 'parent::query'), func_get_args()); + } - public function __call($method, $args) { - print "__call(".var_export($method,true).", ".var_export($args, true).")\n"; - // $this->protocol(); - } + public function __call($method, $args) { + print "__call(".var_export($method,true).", ".var_export($args, true).")\n"; + // $this->protocol(); + } - private function protocol() { - $stack = debug_backtrace(); - if (!isset($stack[1])) - return; + private function protocol() { + $stack = debug_backtrace(); + if (!isset($stack[1])) + return; - printf("%s(", $stack[1]['function']); - $args = ''; - foreach ($stack[1]['args'] as $k => $v) - $args .= sprintf("%s, ", var_export($v, true)); - if ($args != '') - printf("%s", substr($args, 0, -2)); - printf(")\n"); - } + printf("%s(", $stack[1]['function']); + $args = ''; + foreach ($stack[1]['args'] as $k => $v) + $args .= sprintf("%s, ", var_export($v, true)); + if ($args != '') + printf("%s", substr($args, 0, -2)); + printf(")\n"); + } - } + } - $db = new MyPDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS); - $db->exec('DROP TABLE IF EXISTS test'); - $db->exec('CREATE TABLE test(id INT)'); - $db->exec('INSERT INTO test(id) VALUES (1), (2)'); - $stmt = $db->query('SELECT * FROM test ORDER BY id ASC'); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); - var_dump($stmt->fetch()); - $db->intercept_call(); + $db = new MyPDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS); + $db->exec('DROP TABLE IF EXISTS test'); + $db->exec('CREATE TABLE test(id INT)'); + $db->exec('INSERT INTO test(id) VALUES (1), (2)'); + $stmt = $db->query('SELECT * FROM test ORDER BY id ASC'); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + var_dump($stmt->fetch()); + $db->intercept_call(); - } catch (PDOException $e) { - printf("[001] %s [%s] %s\n", - $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); - } + } catch (PDOException $e) { + printf("[001] %s [%s] %s\n", + $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); + } - $db->exec('DROP TABLE IF EXISTS test'); - print "done!\n"; + $db->exec('DROP TABLE IF EXISTS test'); + print "done!\n"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - @$db->exec($sql); - if ($db->errorCode() != 0) { - // not all MySQL Server versions and/or engines might support the type - return true; - } - - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); - $stmt->bindValue(1, $offset); - $stmt->bindValue(2, $value); - if (!$stmt->execute()) { - printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true)); - return false; - } - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); - $stmt = $db->query('SELECT id, label FROM test'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - - if (!isset($row['id']) || !isset($row['label'])) { - printf("[%03d + 2] Fetched result seems wrong, dumping result: %s\n", $offset, var_export($row, true)); - return false; - } - - if ($row['id'] != $offset) { - printf("[%03d + 3] Expecting %s got %s\n", $offset, $row['id']); - return false; - } - - if (!is_null($pattern)) { - if (!preg_match($pattern, $row['label'])) { - printf("[%03d + 5] Value seems wrong, accepting pattern %s got %s, check manually\n", - $offset, $pattern, var_export($row['label'], true)); - return false; - } - - } else { - - $exp = $value; - if (!is_null($ret_value)) { - // we expect a different return value than our input value - // typically the difference is only the type - $exp = $ret_value; - } - if ($row['label'] !== $exp && !is_null($alternative_type) && gettype($row['label']) != $alternative_type) { - printf("[%03d + 4] %s - input = %s/%s, output = %s/%s (alternative type: %s)\n", $offset, - $sql_type, var_export($exp, true), gettype($exp), - var_export($row['label'], true), gettype($row['label']), - $alternative_type); - return false; - } - - } - - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $stmt = $db->query('SELECT id, label FROM test'); - $row_string = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - if (is_null($pattern) && ($row['label'] != $row_string['label'])) { - printf("%s - STRINGIGY = %s, NATIVE = %s\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true)); - return false; - } else if (!is_null($pattern) && !preg_match($pattern, $row_string['label'])) { - printf("%s - STRINGIGY = %s, NATIVE = %s, pattern '%s'\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true), $pattern); - return false; - } - - - return true; - } - - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + function test_type(&$db, $offset, $sql_type, $value, $ret_value = NULL, $pattern = NULL, $alternative_type = NULL) { + + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); + @$db->exec($sql); + if ($db->errorCode() != 0) { + // not all MySQL Server versions and/or engines might support the type + return true; + } + + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); + $stmt->bindValue(1, $offset); + $stmt->bindValue(2, $value); + if (!$stmt->execute()) { + printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true)); + return false; + } + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + $stmt = $db->query('SELECT id, label FROM test'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + if (!isset($row['id']) || !isset($row['label'])) { + printf("[%03d + 2] Fetched result seems wrong, dumping result: %s\n", $offset, var_export($row, true)); + return false; + } + + if ($row['id'] != $offset) { + printf("[%03d + 3] Expecting %s got %s\n", $offset, $row['id']); + return false; + } + + if (!is_null($pattern)) { + if (!preg_match($pattern, $row['label'])) { + printf("[%03d + 5] Value seems wrong, accepting pattern %s got %s, check manually\n", + $offset, $pattern, var_export($row['label'], true)); + return false; + } + + } else { + + $exp = $value; + if (!is_null($ret_value)) { + // we expect a different return value than our input value + // typically the difference is only the type + $exp = $ret_value; + } + if ($row['label'] !== $exp && !is_null($alternative_type) && gettype($row['label']) != $alternative_type) { + printf("[%03d + 4] %s - input = %s/%s, output = %s/%s (alternative type: %s)\n", $offset, + $sql_type, var_export($exp, true), gettype($exp), + var_export($row['label'], true), gettype($row['label']), + $alternative_type); + return false; + } + + } + + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $stmt = $db->query('SELECT id, label FROM test'); + $row_string = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + if (is_null($pattern) && ($row['label'] != $row_string['label'])) { + printf("%s - STRINGIGY = %s, NATIVE = %s\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true)); + return false; + } else if (!is_null($pattern) && !preg_match($pattern, $row_string['label'])) { + printf("%s - STRINGIGY = %s, NATIVE = %s, pattern '%s'\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true), $pattern); + return false; + } + + + return true; + } + + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); /* - test_type($db, 20, 'BIT(8)', 1); + test_type($db, 20, 'BIT(8)', 1); */ - $is_mysqlnd = MySQLPDOTest::isPDOMySQLnd(); + $is_mysqlnd = MySQLPDOTest::isPDOMySQLnd(); - test_type($db, 30, 'TINYINT', -127, ($is_mysqlnd) ? -127: '-127'); - test_type($db, 40, 'TINYINT UNSIGNED', 255, ($is_mysqlnd) ? 255 : '255'); - test_type($db, 50, 'BOOLEAN', 1, ($is_mysqlnd) ? 1 : '1'); + test_type($db, 30, 'TINYINT', -127, ($is_mysqlnd) ? -127: '-127'); + test_type($db, 40, 'TINYINT UNSIGNED', 255, ($is_mysqlnd) ? 255 : '255'); + test_type($db, 50, 'BOOLEAN', 1, ($is_mysqlnd) ? 1 : '1'); - test_type($db, 60, 'SMALLINT', -32768, ($is_mysqlnd) ? -32768 : '-32768'); - test_type($db, 70, 'SMALLINT UNSIGNED', 65535, ($is_mysqlnd) ? 65535 : '65535'); + test_type($db, 60, 'SMALLINT', -32768, ($is_mysqlnd) ? -32768 : '-32768'); + test_type($db, 70, 'SMALLINT UNSIGNED', 65535, ($is_mysqlnd) ? 65535 : '65535'); - test_type($db, 80, 'MEDIUMINT', -8388608, ($is_mysqlnd) ? -8388608 : '-8388608'); - test_type($db, 90, 'MEDIUMINT UNSIGNED', 16777215, ($is_mysqlnd) ? 16777215 : '16777215'); + test_type($db, 80, 'MEDIUMINT', -8388608, ($is_mysqlnd) ? -8388608 : '-8388608'); + 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', - NULL, ($is_mysqlnd) ? 'integer' : NULL); + test_type($db, 100, 'INT', -2147483648, + ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (double)-2147483648) : '-2147483648', + 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'); - // no chance to return int with the current PDO version - we are forced to return strings - test_type($db, 120, 'BIGINT', 1, ($is_mysqlnd) ? 1 : '1'); - // to avoid trouble with numeric ranges, lets pass the numbers as a string - test_type($db, 130, 'BIGINT', '-9223372036854775808', NULL, '/^\-9[\.]*22/'); - test_type($db, 140, 'BIGINT UNSIGNED', '18446744073709551615', NULL, '/^1[\.]*844/'); + // no chance to return int with the current PDO version - we are forced to return strings + test_type($db, 120, 'BIGINT', 1, ($is_mysqlnd) ? 1 : '1'); + // to avoid trouble with numeric ranges, lets pass the numbers as a string + test_type($db, 130, 'BIGINT', '-9223372036854775808', NULL, '/^\-9[\.]*22/'); + test_type($db, 140, 'BIGINT UNSIGNED', '18446744073709551615', NULL, '/^1[\.]*844/'); - test_type($db, 150, 'REAL', -1.01, ($is_mysqlnd) ? -1.01 : '-1.01'); - test_type($db, 160, 'REAL UNSIGNED', 1.01, ($is_mysqlnd) ? 1.01 : '1.01'); + test_type($db, 150, 'REAL', -1.01, ($is_mysqlnd) ? -1.01 : '-1.01'); + test_type($db, 160, 'REAL UNSIGNED', 1.01, ($is_mysqlnd) ? 1.01 : '1.01'); - test_type($db, 170, 'DOUBLE', -1.01, ($is_mysqlnd) ? -1.01 : '-1.01'); - test_type($db, 180, 'DOUBLE UNSIGNED', 1.01, ($is_mysqlnd) ? 1.01 : '1.01'); + test_type($db, 170, 'DOUBLE', -1.01, ($is_mysqlnd) ? -1.01 : '-1.01'); + test_type($db, 180, 'DOUBLE UNSIGNED', 1.01, ($is_mysqlnd) ? 1.01 : '1.01'); - test_type($db, 210, 'FLOAT', -1.01, NULL, '/^\-1.0\d+/'); - test_type($db, 220, 'FLOAT UNSIGNED', 1.01, NULL, '/^1.0\d+/'); + test_type($db, 210, 'FLOAT', -1.01, NULL, '/^\-1.0\d+/'); + test_type($db, 220, 'FLOAT UNSIGNED', 1.01, NULL, '/^1.0\d+/'); - test_type($db, 250, 'DECIMAL', -1.01, '-1'); - test_type($db, 260, 'DECIMAL UNSIGNED', 1.01, '1'); + test_type($db, 250, 'DECIMAL', -1.01, '-1'); + test_type($db, 260, 'DECIMAL UNSIGNED', 1.01, '1'); - test_type($db, 290, 'NUMERIC', -1.01, '-1'); - test_type($db, 300, 'NUMERIC UNSIGNED', 1.01, '1'); + test_type($db, 290, 'NUMERIC', -1.01, '-1'); + test_type($db, 300, 'NUMERIC UNSIGNED', 1.01, '1'); - test_type($db, 330, 'DATE', '2008-04-23'); - test_type($db, 340, 'TIME', '14:37:00'); - test_type($db, 350, 'TIMESTAMP', '2008-05-06 21:09:00'); - test_type($db, 360, 'DATETIME', '2008-03-23 14:38:00'); - test_type($db, 370, 'YEAR', 2008, ($is_mysqlnd) ? 2008 : '2008'); + test_type($db, 330, 'DATE', '2008-04-23'); + test_type($db, 340, 'TIME', '14:37:00'); + test_type($db, 350, 'TIMESTAMP', '2008-05-06 21:09:00'); + test_type($db, 360, 'DATETIME', '2008-03-23 14:38:00'); + test_type($db, 370, 'YEAR', 2008, ($is_mysqlnd) ? 2008 : '2008'); - test_type($db, 380, 'CHAR(1)', 'a'); - test_type($db, 390, 'CHAR(10)', '0123456789'); - test_type($db, 400, 'CHAR(255)', str_repeat('z', 255)); - test_type($db, 410, 'VARCHAR(1)', 'a'); - test_type($db, 420, 'VARCHAR(10)', '0123456789'); - test_type($db, 430, 'VARCHAR(255)', str_repeat('z', 255)); + test_type($db, 380, 'CHAR(1)', 'a'); + test_type($db, 390, 'CHAR(10)', '0123456789'); + test_type($db, 400, 'CHAR(255)', str_repeat('z', 255)); + test_type($db, 410, 'VARCHAR(1)', 'a'); + test_type($db, 420, 'VARCHAR(10)', '0123456789'); + test_type($db, 430, 'VARCHAR(255)', str_repeat('z', 255)); - test_type($db, 440, 'BINARY(1)', str_repeat('a', 1)); - test_type($db, 450, 'BINARY(255)', str_repeat('b', 255)); - test_type($db, 460, 'VARBINARY(1)', str_repeat('a', 1)); - test_type($db, 470, 'VARBINARY(255)', str_repeat('b', 255)); + test_type($db, 440, 'BINARY(1)', str_repeat('a', 1)); + test_type($db, 450, 'BINARY(255)', str_repeat('b', 255)); + test_type($db, 460, 'VARBINARY(1)', str_repeat('a', 1)); + test_type($db, 470, 'VARBINARY(255)', str_repeat('b', 255)); - test_type($db, 480, 'TINYBLOB', str_repeat('b', 255)); - test_type($db, 490, 'BLOB', str_repeat('b', 256)); - test_type($db, 500, 'MEDIUMBLOB', str_repeat('b', 256)); - test_type($db, 510, 'LONGBLOB', str_repeat('b', 256)); + test_type($db, 480, 'TINYBLOB', str_repeat('b', 255)); + test_type($db, 490, 'BLOB', str_repeat('b', 256)); + test_type($db, 500, 'MEDIUMBLOB', str_repeat('b', 256)); + test_type($db, 510, 'LONGBLOB', str_repeat('b', 256)); - test_type($db, 520, 'TINYTEXT', str_repeat('b', 255)); - test_type($db, 530, 'TINYTEXT BINARY', str_repeat('b', 255)); + test_type($db, 520, 'TINYTEXT', str_repeat('b', 255)); + test_type($db, 530, 'TINYTEXT BINARY', str_repeat('b', 255)); - test_type($db, 560, 'TEXT', str_repeat('b', 256)); - test_type($db, 570, 'TEXT BINARY', str_repeat('b', 256)); + test_type($db, 560, 'TEXT', str_repeat('b', 256)); + test_type($db, 570, 'TEXT BINARY', str_repeat('b', 256)); - test_type($db, 580, 'MEDIUMTEXT', str_repeat('b', 256)); - test_type($db, 590, 'MEDIUMTEXT BINARY', str_repeat('b', 256)); + test_type($db, 580, 'MEDIUMTEXT', str_repeat('b', 256)); + test_type($db, 590, 'MEDIUMTEXT BINARY', str_repeat('b', 256)); - test_type($db, 600, 'LONGTEXT', str_repeat('b', 256)); - test_type($db, 610, 'LONGTEXT BINARY', str_repeat('b', 256)); + test_type($db, 600, 'LONGTEXT', str_repeat('b', 256)); + test_type($db, 610, 'LONGTEXT BINARY', str_repeat('b', 256)); - test_type($db, 620, "ENUM('yes', 'no') DEFAULT 'yes'", 'no'); - test_type($db, 630, "SET('yes', 'no') DEFAULT 'yes'", 'no'); + test_type($db, 620, "ENUM('yes', 'no') DEFAULT 'yes'", 'no'); + test_type($db, 630, "SET('yes', 'no') DEFAULT 'yes'", 'no'); - test_type($db, 640, 'DECIMAL(3,2)', -1.01, '-1.01'); + test_type($db, 640, 'DECIMAL(3,2)', -1.01, '-1.01'); - echo "done!\n"; + echo "done!\n"; ?> --CLEAN-- --FILE-- exec('DROP TABLE IF EXISTS test'); - $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); - @$db->exec($sql); - if ($db->errorCode() != 0) { - // not all MySQL Server versions and/or engines might support the type - return true; - } - - $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); - $stmt->bindValue(1, $offset); - $stmt->bindValue(2, $value); - try { - if (!$stmt->execute()) { - printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true)); - return false; - } - } catch (PDOException $e) { - // This might be a SQL warning on signed values inserted in unsigned columns - // Zerofill implies unsigned but the test plays with signed = negative values as well! - return true; - } - - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); - $stmt = $db->query('SELECT id, label FROM test'); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - if (!isset($row['id']) || !isset($row['label'])) { - printf("[%03d + 2] Fetched result seems wrong, dumping result: %s\n", $offset, var_export($row, true)); - return false; - } - - if ($row['id'] != $offset) { - printf("[%03d + 3] Expecting %s got %s\n", $offset, $row['id']); - return false; - } - - if (!is_null($pattern)) { - - if (!preg_match($pattern, $row['label'])) { - printf("[%03d + 5] Value seems wrong, accepting pattern %s got %s, check manually\n", - $offset, $pattern, var_export($row['label'], true)); - return false; - } - - } else { - - $exp = $value; - if (!is_null($ret_value)) { - // we expect a different return value than our input value - // typically the difference is only the type - $exp = $ret_value; - } - - if ($row['label'] !== $exp) { - printf("[%03d + 4] %s - input = %s/%s, output = %s/%s\n", $offset, - $sql_type, var_export($exp, true), gettype($exp), - var_export($row['label'], true), gettype($row['label'])); - return false; - } - - } - - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); - $stmt = $db->query('SELECT id, label FROM test'); - $row_string = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - if ($row['label'] != $row_string['label']) { - printf("%s - STRINGIGY = %s, NATIVE = %s\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true)); - return false; - } - - return true; - } - - $db = MySQLPDOTest::factory(); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); - - $stmt = $db->prepare('SELECT @@sql_mode AS _mode'); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $real_as_float = (false === stristr($row['_mode'], "REAL_AS_FLOAT")) ? false : true; - - test_type($db, 100, 'REAL ZEROFILL', -1.01, NULL, '/^[0]*0$/'); - test_type($db, 110, 'REAL ZEROFILL', 1.01, NULL, ($real_as_float) ? '/^[0]*1\.0.*$/' : '/^[0]*1\.01$/'); - test_type($db, 120, 'REAL UNSIGNED ZEROFILL', 1.01, NULL, ($real_as_float) ? '/^[0]*1\..*$/' : '/^[0]*1\.01$/'); - - test_type($db, 130, 'DOUBLE ZEROFILL', -1.01, NULL, '/^[0]*0$/'); - test_type($db, 140, 'DOUBLE ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/'); - test_type($db, 150, 'DOUBLE UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/'); - - test_type($db, 160, 'FLOAT ZEROFILL', -1.01, NULL, '/^[0]*0$/'); - test_type($db, 170, 'FLOAT ZEROFILL', 1, NULL, '/^[0]*1$/'); - test_type($db, 180, 'FLOAT UNSIGNED ZEROFILL', -1, NULL, '/^[0]*0$/'); - - test_type($db, 190, 'DECIMAL ZEROFILL', -1.01, NULL, '/^[0]*0$/'); - test_type($db, 200, 'DECIMAL ZEROFILL', 1.01, NULL, '/^[0]*1$/'); - test_type($db, 210, 'DECIMAL UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1$/'); - - test_type($db, 220, 'NUMERIC ZEROFILL', -1, NULL, '/^[0]*0$/'); - test_type($db, 230, 'NUMERIC ZEROFILL', 1, NULL, '/^[0]*1$/'); - test_type($db, 240, 'NUMERIC UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1$/'); - - echo "done!\n"; + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + + function test_type(&$db, $offset, $sql_type, $value, $ret_value = NULL, $pattern = NULL) { + + $db->exec('DROP TABLE IF EXISTS test'); + $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine()); + @$db->exec($sql); + if ($db->errorCode() != 0) { + // not all MySQL Server versions and/or engines might support the type + return true; + } + + $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)'); + $stmt->bindValue(1, $offset); + $stmt->bindValue(2, $value); + try { + if (!$stmt->execute()) { + printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true)); + return false; + } + } catch (PDOException $e) { + // This might be a SQL warning on signed values inserted in unsigned columns + // Zerofill implies unsigned but the test plays with signed = negative values as well! + return true; + } + + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + $stmt = $db->query('SELECT id, label FROM test'); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + if (!isset($row['id']) || !isset($row['label'])) { + printf("[%03d + 2] Fetched result seems wrong, dumping result: %s\n", $offset, var_export($row, true)); + return false; + } + + if ($row['id'] != $offset) { + printf("[%03d + 3] Expecting %s got %s\n", $offset, $row['id']); + return false; + } + + if (!is_null($pattern)) { + + if (!preg_match($pattern, $row['label'])) { + printf("[%03d + 5] Value seems wrong, accepting pattern %s got %s, check manually\n", + $offset, $pattern, var_export($row['label'], true)); + return false; + } + + } else { + + $exp = $value; + if (!is_null($ret_value)) { + // we expect a different return value than our input value + // typically the difference is only the type + $exp = $ret_value; + } + + if ($row['label'] !== $exp) { + printf("[%03d + 4] %s - input = %s/%s, output = %s/%s\n", $offset, + $sql_type, var_export($exp, true), gettype($exp), + var_export($row['label'], true), gettype($row['label'])); + return false; + } + + } + + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + $stmt = $db->query('SELECT id, label FROM test'); + $row_string = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + if ($row['label'] != $row_string['label']) { + printf("%s - STRINGIGY = %s, NATIVE = %s\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true)); + return false; + } + + return true; + } + + $db = MySQLPDOTest::factory(); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + + $stmt = $db->prepare('SELECT @@sql_mode AS _mode'); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $real_as_float = (false === stristr($row['_mode'], "REAL_AS_FLOAT")) ? false : true; + + test_type($db, 100, 'REAL ZEROFILL', -1.01, NULL, '/^[0]*0$/'); + test_type($db, 110, 'REAL ZEROFILL', 1.01, NULL, ($real_as_float) ? '/^[0]*1\.0.*$/' : '/^[0]*1\.01$/'); + test_type($db, 120, 'REAL UNSIGNED ZEROFILL', 1.01, NULL, ($real_as_float) ? '/^[0]*1\..*$/' : '/^[0]*1\.01$/'); + + test_type($db, 130, 'DOUBLE ZEROFILL', -1.01, NULL, '/^[0]*0$/'); + test_type($db, 140, 'DOUBLE ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/'); + test_type($db, 150, 'DOUBLE UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/'); + + test_type($db, 160, 'FLOAT ZEROFILL', -1.01, NULL, '/^[0]*0$/'); + test_type($db, 170, 'FLOAT ZEROFILL', 1, NULL, '/^[0]*1$/'); + test_type($db, 180, 'FLOAT UNSIGNED ZEROFILL', -1, NULL, '/^[0]*0$/'); + + test_type($db, 190, 'DECIMAL ZEROFILL', -1.01, NULL, '/^[0]*0$/'); + test_type($db, 200, 'DECIMAL ZEROFILL', 1.01, NULL, '/^[0]*1$/'); + test_type($db, 210, 'DECIMAL UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1$/'); + + test_type($db, 220, 'NUMERIC ZEROFILL', -1, NULL, '/^[0]*0$/'); + test_type($db, 230, 'NUMERIC ZEROFILL', 1, NULL, '/^[0]*1$/'); + test_type($db, 240, 'NUMERIC UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1$/'); + + echo "done!\n"; ?> --CLEAN-- exec("CREATE TABLE test (bar INT NOT NULL, phase enum('please_select', 'I', 'II', 'IIa', 'IIb', 'III', 'IV'))"); foreach ($db->query('DESCRIBE test phase')->fetchAll(PDO::FETCH_ASSOC) as $row) { - print_r($row); + print_r($row); } ?> --CLEAN-- diff --git a/ext/pdo_mysql/tests/skipif.inc b/ext/pdo_mysql/tests/skipif.inc index e503f55b3ca6..65c7f34fc631 100644 --- a/ext/pdo_mysql/tests/skipif.inc +++ b/ext/pdo_mysql/tests/skipif.inc @@ -1,3 +1,3 @@ exec('DROP TABLE IF EXISTS test'); $db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine); diff --git a/ext/pdo_oci/tests/bug46274.phpt b/ext/pdo_oci/tests/bug46274.phpt index 91aa5c883fb4..388d29719961 100644 --- a/ext/pdo_oci/tests/bug46274.phpt +++ b/ext/pdo_oci/tests/bug46274.phpt @@ -16,7 +16,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - $db->exec("DROP TABLE test_one_blob"); + $db->exec("DROP TABLE test_one_blob"); } catch (Exception $e) { } diff --git a/ext/pdo_oci/tests/bug46274_2.phpt b/ext/pdo_oci/tests/bug46274_2.phpt index 434cdbc218ce..cf2618366e8e 100644 --- a/ext/pdo_oci/tests/bug46274_2.phpt +++ b/ext/pdo_oci/tests/bug46274_2.phpt @@ -16,7 +16,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); try { - $db->exec("DROP TABLE test_one_blob"); + $db->exec("DROP TABLE test_one_blob"); } catch (Exception $e) { } diff --git a/ext/pdo_oci/tests/bug57702.phpt b/ext/pdo_oci/tests/bug57702.phpt index ff64399a9a30..12f91226c657 100644 --- a/ext/pdo_oci/tests/bug57702.phpt +++ b/ext/pdo_oci/tests/bug57702.phpt @@ -25,20 +25,20 @@ $stmt->execute(); function do_insert($db, $id, $data1, $data2) { - $db->beginTransaction(); - $stmt = $db->prepare("insert into bug57702 (id, data1, data2) values (:id, empty_blob(), empty_blob()) returning data1, data2 into :blob1, :blob2"); - $stmt->bindParam(':id', $id); - $stmt->bindParam(':blob1', $blob1, PDO::PARAM_LOB); - $stmt->bindParam(':blob2', $blob2, PDO::PARAM_LOB); - $blob1 = null; - $blob2 = null; - $stmt->execute(); - - fwrite($blob1, $data1); - fclose($blob1); - fwrite($blob2, $data2); - fclose($blob2); - $db->commit(); + $db->beginTransaction(); + $stmt = $db->prepare("insert into bug57702 (id, data1, data2) values (:id, empty_blob(), empty_blob()) returning data1, data2 into :blob1, :blob2"); + $stmt->bindParam(':id', $id); + $stmt->bindParam(':blob1', $blob1, PDO::PARAM_LOB); + $stmt->bindParam(':blob2', $blob2, PDO::PARAM_LOB); + $blob1 = null; + $blob2 = null; + $stmt->execute(); + + fwrite($blob1, $data1); + fclose($blob1); + fwrite($blob2, $data2); + fclose($blob2); + $db->commit(); } do_insert($db, 1, "row 1 col 1", "row 1 col 2"); @@ -63,8 +63,8 @@ var_dump($row['data2']); echo "\nSecond Query\n"; foreach($db->query("select data1 as d1, data2 as d2 from bug57702 order by id") as $row) { - var_dump($row['d1']); - var_dump($row['d2']); + var_dump($row['d1']); + var_dump($row['d2']); } //////////////////// @@ -89,8 +89,8 @@ echo "\nFourth Query\n"; $a = array(); $i = 0; foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { - $a[$i][0] = $row['d4_1']; - $a[$i][1] = $row['d4_2']; + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; $i++; } @@ -112,8 +112,8 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Let's use streams $a = array(); $i = 0; foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { - $a[$i][0] = $row['d4_1']; - $a[$i][1] = $row['d4_2']; + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; $i++; } @@ -131,11 +131,11 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Let's use streams $a = array(); $i = 0; foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { - $a[$i][0] = $row['d4_1']; - $a[$i][1] = $row['d4_2']; - var_dump(stream_get_contents($a[$i][0])); - var_dump(stream_get_contents($a[$i][1])); - $i++; + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; + var_dump(stream_get_contents($a[$i][0])); + var_dump(stream_get_contents($a[$i][1])); + $i++; } // Cleanup diff --git a/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt b/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt index f208fd56d920..bfe4c59f87c8 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt @@ -22,28 +22,28 @@ echo "Test 1 Check beginTransaction insertion\n"; $dbh->beginTransaction(); try { - $dbh->exec("insert into pdo_ac_tab (col1) values ('data 1')"); - $dbh->exec("insert into pdo_ac_tab (col1) values ('data 2')"); - $dbh->commit(); + $dbh->exec("insert into pdo_ac_tab (col1) values ('data 1')"); + $dbh->exec("insert into pdo_ac_tab (col1) values ('data 2')"); + $dbh->commit(); } catch (PDOException $e) { - echo "Caught unexpected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; - $dbh->rollback(); + echo "Caught unexpected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; + $dbh->rollback(); } echo "Test 2 Cause an exception and test beginTransaction rollback\n"; $dbh->beginTransaction(); try { - $dbh->exec("insert into pdo_ac_tab (col1) values ('not committed #1')"); - $dbh->exec("insert into pdo_ac_tab (col1) values ('data that is too long to fit and will barf')"); - $dbh->commit(); + $dbh->exec("insert into pdo_ac_tab (col1) values ('not committed #1')"); + $dbh->exec("insert into pdo_ac_tab (col1) values ('data that is too long to fit and will barf')"); + $dbh->commit(); } catch (PDOException $e) { - echo "Caught expected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; - $dbh->rollback(); + echo "Caught expected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; + $dbh->rollback(); } echo "Test 3 Setting ATTR_AUTOCOMMIT to true will commit and end the transaction\n"; @@ -53,11 +53,11 @@ $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, true); print "PDO::ATTR_AUTOCOMMIT: "; var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT)); try { - $dbh->rollback(); + $dbh->rollback(); } catch (PDOException $e) { - echo "Caught expected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; + echo "Caught expected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; } echo "Test 4 Setting ATTR_AUTOCOMMIT to false will commit and end the transaction\n"; @@ -68,11 +68,11 @@ $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, false); print "PDO::ATTR_AUTOCOMMIT: "; var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT)); try { - $dbh->rollback(); + $dbh->rollback(); } catch (PDOException $e) { - echo "Caught expected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; + echo "Caught expected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; } echo "Test 5 Handle transactions ourselves\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_attr_case.phpt b/ext/pdo_oci/tests/pdo_oci_attr_case.phpt index 5ad89af6b1e4..09821cb74d8a 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_case.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_case.phpt @@ -13,22 +13,22 @@ require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); function do_query1($dbh) { - var_dump($dbh->getAttribute(PDO::ATTR_CASE)); - $s = $dbh->prepare("select dummy from dual"); - $s->execute(); - while ($r = $s->fetch(PDO::FETCH_ASSOC)) { - var_dump($r); - } + var_dump($dbh->getAttribute(PDO::ATTR_CASE)); + $s = $dbh->prepare("select dummy from dual"); + $s->execute(); + while ($r = $s->fetch(PDO::FETCH_ASSOC)) { + var_dump($r); + } } function do_query2($dbh, $mode) { - echo "Mode desired is $mode\n"; - $s = $dbh->prepare("select dummy from dual", array(PDO::ATTR_CASE, $mode)); - $s->execute(); - while ($r = $s->fetch(PDO::FETCH_ASSOC)) { - var_dump($r); - } + echo "Mode desired is $mode\n"; + $s = $dbh->prepare("select dummy from dual", array(PDO::ATTR_CASE, $mode)); + $s->execute(); + while ($r = $s->fetch(PDO::FETCH_ASSOC)) { + var_dump($r); + } } $dbh = PDOTest::factory(); diff --git a/ext/pdo_oci/tests/pdo_oci_attr_client.phpt b/ext/pdo_oci/tests/pdo_oci_attr_client.phpt index 3febab71eafa..fdb65cf15657 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_client.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_client.phpt @@ -19,19 +19,19 @@ var_dump($cv); $s = explode(".", $cv); if (count($s) > 1 && (($s[0] == 10 && $s[1] >= 2) || $s[0] >= 11)) { - if (count($s) != 5) { - echo "Wrong number of values in array\nVersion was: "; - var_dump($cv); - } else { - echo "Version OK, so far as can be portably checked\n"; - } + if (count($s) != 5) { + echo "Wrong number of values in array\nVersion was: "; + var_dump($cv); + } else { + echo "Version OK, so far as can be portably checked\n"; + } } else { - if (count($s) != 2) { - echo "Wrong number of values in array\nVersion was: "; - var_dump($cv); - } else { - echo "Version OK, so far as can be portably checked\n"; - } + if (count($s) != 2) { + echo "Wrong number of values in array\nVersion was: "; + var_dump($cv); + } else { + echo "Version OK, so far as can be portably checked\n"; + } } echo "Done\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt b/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt index 2a38341b273b..cb8edba5433e 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt @@ -13,13 +13,13 @@ require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); function do_query($dbh) { - var_dump($dbh->getAttribute(PDO::ATTR_ORACLE_NULLS)); - $s = $dbh->prepare("select '' as myempty, null as mynull from dual"); - $s->execute(); - while ($r = $s->fetch()) { - var_dump($r[0]); - var_dump($r[1]); - } + var_dump($dbh->getAttribute(PDO::ATTR_ORACLE_NULLS)); + $s = $dbh->prepare("select '' as myempty, null as mynull from dual"); + $s->execute(); + while ($r = $s->fetch()) { + var_dump($r[0]); + var_dump($r[1]); + } } $dbh = PDOTest::factory(); diff --git a/ext/pdo_oci/tests/pdo_oci_attr_server.phpt b/ext/pdo_oci/tests/pdo_oci_attr_server.phpt index 566bd0749d66..e17401ddacb1 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_server.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_server.phpt @@ -22,10 +22,10 @@ echo "ATTR_SERVER_INFO\n"; $si = $dbh->getAttribute(PDO::ATTR_SERVER_INFO); $pos = strpos($si, "Oracle"); if ($pos === 0) { - echo "Found 'Oracle' at position $pos as expected\n"; + echo "Found 'Oracle' at position $pos as expected\n"; } else { - echo "Unexpected result. Server info was:\n"; - var_dump($si); + echo "Unexpected result. Server info was:\n"; + var_dump($si); } echo "Done\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_class_constants.phpt b/ext/pdo_oci/tests/pdo_oci_class_constants.phpt index 0946b3f89b79..f66c8252453b 100644 --- a/ext/pdo_oci/tests/pdo_oci_class_constants.phpt +++ b/ext/pdo_oci/tests/pdo_oci_class_constants.phpt @@ -12,11 +12,11 @@ PDOTest::skip(); require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); $expected = [ - 'OCI_ATTR_CLIENT_INFO' => true, - 'OCI_ATTR_ACTION' => true, - 'OCI_ATTR_CLIENT_IDENTIFIER' => true, - 'OCI_ATTR_MODULE' => true, - 'OCI_ATTR_CALL_TIMEOUT' => true, + 'OCI_ATTR_CLIENT_INFO' => true, + 'OCI_ATTR_ACTION' => true, + 'OCI_ATTR_CLIENT_IDENTIFIER' => true, + 'OCI_ATTR_MODULE' => true, + 'OCI_ATTR_CALL_TIMEOUT' => true, ]; $ref = new ReflectionClass('PDO'); @@ -24,40 +24,40 @@ $constants = $ref->getConstants(); $values = []; foreach ($constants as $name => $value) { - if (substr($name, 0, 8) == 'OCI_ATTR') { - if (!isset($values[$value])) { - $values[$value] = [$name]; + if (substr($name, 0, 8) == 'OCI_ATTR') { + if (!isset($values[$value])) { + $values[$value] = [$name]; } else { - $values[$value][] = $name; + $values[$value][] = $name; } - if (isset($expected[$name])) { - unset($expected[$name]); - unset($constants[$name]); - } + if (isset($expected[$name])) { + unset($expected[$name]); + unset($constants[$name]); + } - } else { - unset($constants[$name]); - } + } else { + unset($constants[$name]); + } } if (!empty($constants)) { - printf("[001] Dumping list of unexpected constants\n"); - var_dump($constants); + printf("[001] Dumping list of unexpected constants\n"); + var_dump($constants); } if (!empty($expected)) { - printf("[002] Dumping list of missing constants\n"); - var_dump($expected); + printf("[002] Dumping list of missing constants\n"); + var_dump($expected); } if (!empty($values)) { - foreach ($values as $value => $constants) { - if (count($constants) > 1) { - printf("[003] Several constants share the same value '%s'\n", $value); - var_dump($constants); - } - } + foreach ($values as $value => $constants) { + if (count($constants) > 1) { + printf("[003] Several constants share the same value '%s'\n", $value); + var_dump($constants); + } + } } print "done!"; diff --git a/ext/pdo_oci/tests/pdo_oci_fread_1.phpt b/ext/pdo_oci/tests/pdo_oci_fread_1.phpt index 0fa06c9ce4d1..85a0ca19ed22 100644 --- a/ext/pdo_oci/tests/pdo_oci_fread_1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_fread_1.phpt @@ -19,7 +19,7 @@ $dbh->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Initialization $stmtarray = array( "begin execute immediate 'drop table pdo_oci_fread_tab'; exception when others then null; end;", - "create table pdo_oci_fread_tab (id number, data clob)", + "create table pdo_oci_fread_tab (id number, data clob)", "declare lob1 clob := 'abc' || lpad('j',4020,'j') || 'xyz'; begin @@ -28,7 +28,7 @@ $stmtarray = array( ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } echo "Test 1\n"; @@ -47,11 +47,11 @@ fclose($sh); // Clean up $stmtarray = array( - "drop table pdo_oci_fread_tab" + "drop table pdo_oci_fread_tab" ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } ?> diff --git a/ext/pdo_oci/tests/pdo_oci_quote1.phpt b/ext/pdo_oci/tests/pdo_oci_quote1.phpt index b71ff17e803d..415917829f33 100644 --- a/ext/pdo_oci/tests/pdo_oci_quote1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_quote1.phpt @@ -21,17 +21,17 @@ $stmt = $db->prepare('select * from poq_tab'); $a = array(null, "", "a", "ab", "abc", "ab'cd", "a\b\n", "'", "''", "a'", "'z", "a''b", '"'); foreach ($a as $u) { - $q = $db->quote($u); - echo "Unquoted : "; - var_dump($u); - echo "Quoted : "; - var_dump($q); + $q = $db->quote($u); + echo "Unquoted : "; + var_dump($u); + echo "Quoted : "; + var_dump($q); - $db->exec("delete from poq_tab"); + $db->exec("delete from poq_tab"); - $db->query("insert into poq_tab (t) values($q)"); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $db->query("insert into poq_tab (t) values($q)"); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } echo "Done\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt b/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt index 1b152c50395b..4f3a19c8bed8 100644 --- a/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt +++ b/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt @@ -13,116 +13,116 @@ echo "Preparations before the test\n"; require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); try { - $db = PDOTest::factory(); - $db->exec(<<exec(<<exec("CREATE TABLE test(id INT)"); - - $db->beginTransaction(); - - $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); - - echo "Test 1. calling function with invalid parameters\n"; - - // execute() has not been called yet - // NOTE: no warning - if (false !== ($tmp = $stmt->getColumnMeta(0))) - printf("[002] Expecting false got %s\n", var_export($tmp, true)); - - $stmt->execute(); - // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 0 given in - if (false !== ($tmp = @$stmt->getColumnMeta())) - printf("[003] Expecting false got %s\n", var_export($tmp, true)); - - // invalid offset - if (false !== ($tmp = @$stmt->getColumnMeta(-1))) - printf("[004] Expecting false got %s\n", var_export($tmp, true)); - - // Warning: PDOStatement::getColumnMeta() expects parameter 1 to be int, array given in - if (false !== ($tmp = @$stmt->getColumnMeta(array()))) - printf("[005] Expecting false got %s\n", var_export($tmp, true)); - - // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 2 given in - if (false !== ($tmp = @$stmt->getColumnMeta(1, 1))) - printf("[006] Expecting false got %s\n", var_export($tmp, true)); - - // invalid offset - if (false !== ($tmp = $stmt->getColumnMeta(1))) - printf("[007] Expecting false because of invalid offset got %s\n", var_export($tmp, true)); - - echo "Test 2. testing return values\n"; - echo "Test 2.1 testing array returned\n"; - - $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); - $stmt->execute(); - $native = $stmt->getColumnMeta(0); - if (count($native) == 0) { - printf("[008] Meta data seems wrong, %s / %s\n", - var_export($native, true), var_export($emulated, true)); - } - - - function test_return($meta, $offset, $native_type, $pdo_type){ - if (empty($meta)) { - printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - return false; - } - $elements = array('flags', 'scale', 'name', 'len', 'precision', 'pdo_type'); - foreach ($elements as $k => $element) - if (!isset($meta[$element])) { - printf("[%03d + 3] Element %s missing, %s\n", $offset, - $element, var_export($meta, true)); - return false; - } - - if (!is_null($native_type)) { - if (!isset($meta['native_type'])) { - printf("[%03d + 4] Element native_type missing, %s\n", $offset, - var_export($meta, true)); - return false; - } - - if (!is_array($native_type)) - $native_type = array($native_type); - - $found = false; - foreach ($native_type as $k => $type) { - if ($meta['native_type'] == $type) { - $found = true; - break; - } - } - - if (!$found) { - printf("[%03d + 5] Expecting native type %s, %s\n", $offset, - var_export($native_type, true), var_export($meta, true)); - return false; - } - } - - if (!is_null($pdo_type) && ($meta['pdo_type'] != $pdo_type)) { - printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, - $pdo_type, var_export($meta, true), var_export($meta['native_type'])); - return false; - } - - return true; - } - - - function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) { - - $db->exec(<<exec("CREATE TABLE test(id INT)"); + + $db->beginTransaction(); + + $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); + + echo "Test 1. calling function with invalid parameters\n"; + + // execute() has not been called yet + // NOTE: no warning + if (false !== ($tmp = $stmt->getColumnMeta(0))) + printf("[002] Expecting false got %s\n", var_export($tmp, true)); + + $stmt->execute(); + // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 0 given in + if (false !== ($tmp = @$stmt->getColumnMeta())) + printf("[003] Expecting false got %s\n", var_export($tmp, true)); + + // invalid offset + if (false !== ($tmp = @$stmt->getColumnMeta(-1))) + printf("[004] Expecting false got %s\n", var_export($tmp, true)); + + // Warning: PDOStatement::getColumnMeta() expects parameter 1 to be int, array given in + if (false !== ($tmp = @$stmt->getColumnMeta(array()))) + printf("[005] Expecting false got %s\n", var_export($tmp, true)); + + // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 2 given in + if (false !== ($tmp = @$stmt->getColumnMeta(1, 1))) + printf("[006] Expecting false got %s\n", var_export($tmp, true)); + + // invalid offset + if (false !== ($tmp = $stmt->getColumnMeta(1))) + printf("[007] Expecting false because of invalid offset got %s\n", var_export($tmp, true)); + + echo "Test 2. testing return values\n"; + echo "Test 2.1 testing array returned\n"; + + $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); + $stmt->execute(); + $native = $stmt->getColumnMeta(0); + if (count($native) == 0) { + printf("[008] Meta data seems wrong, %s / %s\n", + var_export($native, true), var_export($emulated, true)); + } + + + function test_return($meta, $offset, $native_type, $pdo_type){ + if (empty($meta)) { + printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + return false; + } + $elements = array('flags', 'scale', 'name', 'len', 'precision', 'pdo_type'); + foreach ($elements as $k => $element) + if (!isset($meta[$element])) { + printf("[%03d + 3] Element %s missing, %s\n", $offset, + $element, var_export($meta, true)); + return false; + } + + if (!is_null($native_type)) { + if (!isset($meta['native_type'])) { + printf("[%03d + 4] Element native_type missing, %s\n", $offset, + var_export($meta, true)); + return false; + } + + if (!is_array($native_type)) + $native_type = array($native_type); + + $found = false; + foreach ($native_type as $k => $type) { + if ($meta['native_type'] == $type) { + $found = true; + break; + } + } + + if (!$found) { + printf("[%03d + 5] Expecting native type %s, %s\n", $offset, + var_export($native_type, true), var_export($meta, true)); + return false; + } + } + + if (!is_null($pdo_type) && ($meta['pdo_type'] != $pdo_type)) { + printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, + $pdo_type, var_export($meta, true), var_export($meta['native_type'])); + return false; + } + + return true; + } + + + function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) { + + $db->exec(<<prepare($sql); - $stmt->execute(); - - if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) { - printf("[%03d] + 1] Insert failed, %d - %s\n", $offset, - $db->errorCode(), var_export($db->errorInfo(), true)); - return false; - } - - $stmt = $db->prepare('SELECT id, label FROM test'); - $stmt->execute(); - $meta = $stmt->getColumnMeta(1); - return test_return($meta, $offset, $native_type, $pdo_type); - } - - echo "Test 2.2 testing numeric columns\n"; - - test_meta($db, 20, 'NUMBER' , 0 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 30, 'NUMBER' , 256 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 40, 'INT' , 256 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 50, 'INTEGER' , 256 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 60, 'NUMBER' , 256.01 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 70, 'NUMBER' , -8388608 , 'NUMBER', PDO::PARAM_STR); - - test_meta($db, 80, 'NUMBER' , 2147483648 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 90, 'NUMBER' , 4294967295 , 'NUMBER', PDO::PARAM_STR); - - test_meta($db, 100, 'DEC' , 1.01 , 'NUMBER' , PDO::PARAM_STR); - test_meta($db, 110, 'DECIMAL' , 1.01 , 'NUMBER' , PDO::PARAM_STR); - test_meta($db, 120, 'FLOAT' , 1.01 , 'FLOAT' , PDO::PARAM_STR); - test_meta($db, 130, 'DOUBLE PRECISION', 1.01 , 'FLOAT' , PDO::PARAM_STR); - test_meta($db, 140, 'BINARY_FLOAT' , 1.01 , 'BINARY_FLOAT' , PDO::PARAM_STR); - test_meta($db, 150, 'BINARY_DOUBLE' , 1.01 , 'BINARY_DOUBLE', PDO::PARAM_STR); - - echo "Test 2.3 testing temporal columns\n"; - - $db->exec("alter session set nls_date_format='YYYY-MM-DD'"); - test_meta($db, 160, 'DATE' , '2008-04-23' , 'DATE', PDO::PARAM_STR); - - echo "Test 2.4 testing string columns\n"; - - test_meta($db, 170, 'CHAR(1)' , 'a' , 'CHAR' , PDO::PARAM_STR); - test_meta($db, 180, 'CHAR(10)' , '0123456789' , 'CHAR' , PDO::PARAM_STR); - test_meta($db, 190, 'CHAR(255)' , str_repeat('z', 255) , 'CHAR' , PDO::PARAM_STR); - test_meta($db, 200, 'VARCHAR(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 210, 'VARCHAR(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 220, 'VARCHAR(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 230, 'VARCHAR2(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 240, 'VARCHAR2(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 250, 'VARCHAR2(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); - - test_meta($db, 260, 'NCHAR(1)' , 'a' , 'NCHAR' , PDO::PARAM_STR); - test_meta($db, 270, 'NCHAR(10)' , '0123456789' , 'NCHAR' , PDO::PARAM_STR); - test_meta($db, 280, 'NCHAR(255)' , str_repeat('z', 255) , 'NCHAR' , PDO::PARAM_STR); - test_meta($db, 290, 'NVARCHAR2(1)' , 'a' , 'NVARCHAR2', PDO::PARAM_STR); - test_meta($db, 300, 'NVARCHAR2(10)' , '0123456789' , 'NVARCHAR2', PDO::PARAM_STR); - test_meta($db, 310, 'NVARCHAR2(255)', str_repeat('z', 255) , 'NVARCHAR2', PDO::PARAM_STR); - - echo "Test 2.5 testing lobs columns\n"; - - test_meta($db, 320, 'CLOB' , str_repeat('b', 255) , 'CLOB' , PDO::PARAM_LOB); - test_meta($db, 330, 'BLOB' , str_repeat('b', 256) , 'BLOB' , PDO::PARAM_LOB); - test_meta($db, 340, 'NCLOB' , str_repeat('b', 255) , 'NCLOB' , PDO::PARAM_LOB); - - test_meta($db, 350, 'LONG' , str_repeat('b', 256) , 'LONG' , PDO::PARAM_STR); - test_meta($db, 360, 'LONG RAW' , str_repeat('b', 256) , 'LONG RAW', PDO::PARAM_STR); - test_meta($db, 370, 'RAW(256)' , str_repeat('b', 256) , 'RAW' , PDO::PARAM_STR); - - - $db->exec(<<prepare($sql); + $stmt->execute(); + + if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) { + printf("[%03d] + 1] Insert failed, %d - %s\n", $offset, + $db->errorCode(), var_export($db->errorInfo(), true)); + return false; + } + + $stmt = $db->prepare('SELECT id, label FROM test'); + $stmt->execute(); + $meta = $stmt->getColumnMeta(1); + return test_return($meta, $offset, $native_type, $pdo_type); + } + + echo "Test 2.2 testing numeric columns\n"; + + test_meta($db, 20, 'NUMBER' , 0 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 30, 'NUMBER' , 256 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 40, 'INT' , 256 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 50, 'INTEGER' , 256 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 60, 'NUMBER' , 256.01 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 70, 'NUMBER' , -8388608 , 'NUMBER', PDO::PARAM_STR); + + test_meta($db, 80, 'NUMBER' , 2147483648 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 90, 'NUMBER' , 4294967295 , 'NUMBER', PDO::PARAM_STR); + + test_meta($db, 100, 'DEC' , 1.01 , 'NUMBER' , PDO::PARAM_STR); + test_meta($db, 110, 'DECIMAL' , 1.01 , 'NUMBER' , PDO::PARAM_STR); + test_meta($db, 120, 'FLOAT' , 1.01 , 'FLOAT' , PDO::PARAM_STR); + test_meta($db, 130, 'DOUBLE PRECISION', 1.01 , 'FLOAT' , PDO::PARAM_STR); + test_meta($db, 140, 'BINARY_FLOAT' , 1.01 , 'BINARY_FLOAT' , PDO::PARAM_STR); + test_meta($db, 150, 'BINARY_DOUBLE' , 1.01 , 'BINARY_DOUBLE', PDO::PARAM_STR); + + echo "Test 2.3 testing temporal columns\n"; + + $db->exec("alter session set nls_date_format='YYYY-MM-DD'"); + test_meta($db, 160, 'DATE' , '2008-04-23' , 'DATE', PDO::PARAM_STR); + + echo "Test 2.4 testing string columns\n"; + + test_meta($db, 170, 'CHAR(1)' , 'a' , 'CHAR' , PDO::PARAM_STR); + test_meta($db, 180, 'CHAR(10)' , '0123456789' , 'CHAR' , PDO::PARAM_STR); + test_meta($db, 190, 'CHAR(255)' , str_repeat('z', 255) , 'CHAR' , PDO::PARAM_STR); + test_meta($db, 200, 'VARCHAR(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 210, 'VARCHAR(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 220, 'VARCHAR(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 230, 'VARCHAR2(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 240, 'VARCHAR2(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 250, 'VARCHAR2(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); + + test_meta($db, 260, 'NCHAR(1)' , 'a' , 'NCHAR' , PDO::PARAM_STR); + test_meta($db, 270, 'NCHAR(10)' , '0123456789' , 'NCHAR' , PDO::PARAM_STR); + test_meta($db, 280, 'NCHAR(255)' , str_repeat('z', 255) , 'NCHAR' , PDO::PARAM_STR); + test_meta($db, 290, 'NVARCHAR2(1)' , 'a' , 'NVARCHAR2', PDO::PARAM_STR); + test_meta($db, 300, 'NVARCHAR2(10)' , '0123456789' , 'NVARCHAR2', PDO::PARAM_STR); + test_meta($db, 310, 'NVARCHAR2(255)', str_repeat('z', 255) , 'NVARCHAR2', PDO::PARAM_STR); + + echo "Test 2.5 testing lobs columns\n"; + + test_meta($db, 320, 'CLOB' , str_repeat('b', 255) , 'CLOB' , PDO::PARAM_LOB); + test_meta($db, 330, 'BLOB' , str_repeat('b', 256) , 'BLOB' , PDO::PARAM_LOB); + test_meta($db, 340, 'NCLOB' , str_repeat('b', 255) , 'NCLOB' , PDO::PARAM_LOB); + + test_meta($db, 350, 'LONG' , str_repeat('b', 256) , 'LONG' , PDO::PARAM_STR); + test_meta($db, 360, 'LONG RAW' , str_repeat('b', 256) , 'LONG RAW', PDO::PARAM_STR); + test_meta($db, 370, 'RAW(256)' , str_repeat('b', 256) , 'RAW' , PDO::PARAM_STR); + + + $db->exec(<<query('SELECT count(*) FROM dual'); - $meta = $stmt->getColumnMeta(0); - test_return($meta, 380, 'NUMBER', PDO::PARAM_STR); - $stmt = $db->query("SELECT TO_DATE('2008-04-23') FROM dual"); - $meta = $stmt->getColumnMeta(0); - test_return($meta, 390, 'DATE', PDO::PARAM_STR); - $stmt = $db->query("SELECT TO_CHAR(542) FROM dual"); - $meta = $stmt->getColumnMeta(0); - test_return($meta, 400, 'VARCHAR2', PDO::PARAM_STR); - - - echo "Test 2.7 testing flags returned\n"; - - $sql = sprintf('CREATE TABLE test(id INT NOT NULL, label INT NULL)'); - $stmt = $db->prepare($sql); - $stmt->execute(); - $db->exec('INSERT INTO test(id, label) VALUES (1, 1)'); - $stmt = $db->query('SELECT id, label FROM test'); - $meta = $stmt->getColumnMeta(0); - // verify the flags array contains a not_null flag and not nullable flags - if (!isset($meta['flags'])) { - printf("[1001] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'not_null') - $found = true; - if ($flag == 'nullable') - printf("[1003] Flags seem wrong %s\n", var_export($meta, true)); - } - if (!$found) - printf("[1002] Flags seem wrong %s\n", var_export($meta, true)); - } - $meta = $stmt->getColumnMeta(1); - // verify the flags array contains a nullable flag and not not_null flags - if (!isset($meta['flags'])) { - printf("[1003] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'not_null') - printf("[1004] Flags seem wrong %s\n", var_export($meta, true)); - if ($flag == 'nullable') - $found = true; - } - if (!$found) - printf("[1005] Flags seem wrong %s\n", var_export($meta, true)); - } + echo "Test 2.6 testing function return\n"; + + $stmt = $db->query('SELECT count(*) FROM dual'); + $meta = $stmt->getColumnMeta(0); + test_return($meta, 380, 'NUMBER', PDO::PARAM_STR); + $stmt = $db->query("SELECT TO_DATE('2008-04-23') FROM dual"); + $meta = $stmt->getColumnMeta(0); + test_return($meta, 390, 'DATE', PDO::PARAM_STR); + $stmt = $db->query("SELECT TO_CHAR(542) FROM dual"); + $meta = $stmt->getColumnMeta(0); + test_return($meta, 400, 'VARCHAR2', PDO::PARAM_STR); + + + echo "Test 2.7 testing flags returned\n"; + + $sql = sprintf('CREATE TABLE test(id INT NOT NULL, label INT NULL)'); + $stmt = $db->prepare($sql); + $stmt->execute(); + $db->exec('INSERT INTO test(id, label) VALUES (1, 1)'); + $stmt = $db->query('SELECT id, label FROM test'); + $meta = $stmt->getColumnMeta(0); + // verify the flags array contains a not_null flag and not nullable flags + if (!isset($meta['flags'])) { + printf("[1001] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'not_null') + $found = true; + if ($flag == 'nullable') + printf("[1003] Flags seem wrong %s\n", var_export($meta, true)); + } + if (!$found) + printf("[1002] Flags seem wrong %s\n", var_export($meta, true)); + } + $meta = $stmt->getColumnMeta(1); + // verify the flags array contains a nullable flag and not not_null flags + if (!isset($meta['flags'])) { + printf("[1003] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'not_null') + printf("[1004] Flags seem wrong %s\n", var_export($meta, true)); + if ($flag == 'nullable') + $found = true; + } + if (!$found) + printf("[1005] Flags seem wrong %s\n", var_export($meta, true)); + } } catch (PDOException $e) { - // we should never get here, we use warnings, but never trust a system... - printf("[001] %s, [%s} %s\n", - $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); + // we should never get here, we use warnings, but never trust a system... + printf("[001] %s, [%s} %s\n", + $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); } $db->exec(<<setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); @$dbh->exec("drop table pdo_oci_stream_1_tab"); $stmtarray = array( - "create table pdo_oci_stream_1_tab (id number, data clob)", + "create table pdo_oci_stream_1_tab (id number, data clob)", ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } $dbh->exec(" @@ -76,11 +76,11 @@ echo 'Read '.stream_get_contents($r['data'], -1, 30000)."\n"; // jjjxyz // Clean up $stmtarray = array( - "drop table pdo_oci_stream_1_tab" + "drop table pdo_oci_stream_1_tab" ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } ?> diff --git a/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt b/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt index 7164f5ad6f2f..a50b4815c31d 100644 --- a/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt +++ b/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt @@ -26,16 +26,16 @@ $j = 9; $a_val = ord('a'); foreach($db->query("select data1 as d4_1, data2 as d4_2 from pdo_oci_stream_2 order by id") as $row) { $a = $row['d4_1']; - $a1 = $row['d4_2']; + $a1 = $row['d4_2']; $str1 = stream_get_contents($a); - $str2 = stream_get_contents($a1); + $str2 = stream_get_contents($a1); $str1len = strlen($str1); - $str2len = strlen($str2); + $str2len = strlen($str2); $b = ord($str1[0]); - $b1 = ord($str2[0]); + $b1 = ord($str2[0]); if (($b != ($a_val + $i)) && ($str1len != (4086 + $i)) && ($b1 != ($a_val + $j)) && ($str2len != (4086 + $j))) { @@ -56,8 +56,8 @@ foreach($db->query("select data1 as d4_1, data2 as d4_2 from pdo_oci_stream_2 or $i++; if ($i>9) $i = 0; - $j--; - if ($j<0) + $j--; + if ($j<0) $j = 9; } echo "Fetch operation done!\n"; diff --git a/ext/pdo_oci/tests/pecl_bug_6364.phpt b/ext/pdo_oci/tests/pecl_bug_6364.phpt index 054d58a0f8c4..affdc77649e4 100644 --- a/ext/pdo_oci/tests/pecl_bug_6364.phpt +++ b/ext/pdo_oci/tests/pecl_bug_6364.phpt @@ -32,7 +32,7 @@ var_dump($out_param1); var_dump($out_param2); foreach ($dbh->query("select * from bug_6364_t") as $row) { - var_dump($row); + var_dump($row); } print "Done\n"; diff --git a/ext/pdo_odbc/tests/long_columns.phpt b/ext/pdo_odbc/tests/long_columns.phpt index bb02dcf89f3b..5f369a50d459 100644 --- a/ext/pdo_odbc/tests/long_columns.phpt +++ b/ext/pdo_odbc/tests/long_columns.phpt @@ -46,11 +46,11 @@ $db = PDOTest::test_factory('ext/pdo_odbc/tests/common.phpt'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data CLOB)')) { - if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data longtext)')) { - if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data varchar(4000))')) { - die("BORK: don't know how to create a long column here:\n" . implode(", ", $db->errorInfo())); - } - } + if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data longtext)')) { + if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data varchar(4000))')) { + die("BORK: don't know how to create a long column here:\n" . implode(", ", $db->errorInfo())); + } + } } $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -61,32 +61,32 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sizes = array(32, 53, 64, 79, 128, 253, 254, 255, 256, 257, 258, 1022, 1023, 1024, 1025, 1026, 510, 511, 512, 513, 514, 1278, 1279, 1280, 1281, 1282, 2046, 2047, 2048, 2049, 2050, 1534, 1535, 1536, 1537, 1538, 3070, 3071, 3072, 3073, 3074, 3998, 3999, 4000); function alpha_repeat($len) { - // use the alphabet instead of 'i' characters to make sure the blocks don't overlap when they are reassembled - $out = ""; - while (strlen($out) < $len) { - $out .= "abcdefghijklmnopqrstuvwxyz"; - } - return substr($out, 0, $len); + // use the alphabet instead of 'i' characters to make sure the blocks don't overlap when they are reassembled + $out = ""; + while (strlen($out) < $len) { + $out .= "abcdefghijklmnopqrstuvwxyz"; + } + return substr($out, 0, $len); } // don't use Prepared Statements. that fails on MS SQL server (works with Access, MyODBC), which is a separate failure, feature/code-path from what // this test does - nice to be able to test using MS SQL server foreach ($sizes as $num) { - $text = alpha_repeat($num); - $db->exec("INSERT INTO TEST VALUES($num, '$text')"); + $text = alpha_repeat($num); + $db->exec("INSERT INTO TEST VALUES($num, '$text')"); } // verify data foreach ($db->query('SELECT id, data from TEST ORDER BY LEN(data) ASC') as $row) { - $expect = alpha_repeat($row[0]); - if (strcmp($expect, $row[1])) { - echo "Failed on size $row[id]:\n"; - printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); - echo ($expect) . "\n"; - echo ($row['data']) . "\n"; - } else { - echo "Passed on size $row[id]\n"; - } + $expect = alpha_repeat($row[0]); + if (strcmp($expect, $row[1])) { + echo "Failed on size $row[id]:\n"; + printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); + echo ($expect) . "\n"; + echo ($row['data']) . "\n"; + } else { + echo "Passed on size $row[id]\n"; + } } echo "Finished\n"; diff --git a/ext/pdo_odbc/tests/max_columns.phpt b/ext/pdo_odbc/tests/max_columns.phpt index ae68a09e91b9..b36eb5381fd2 100644 --- a/ext/pdo_odbc/tests/max_columns.phpt +++ b/ext/pdo_odbc/tests/max_columns.phpt @@ -11,11 +11,11 @@ $db = PDOTest::test_factory('ext/pdo_odbc/tests/common.phpt'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data varchar(max))')) { - if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data longtext)')) { - if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data CLOB)')) { - die("BORK: don't know how to create a long column here:\n" . implode(", ", $db->errorInfo())); - } - } + if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data longtext)')) { + if (false === $db->exec('CREATE TABLE TEST (id INT NOT NULL PRIMARY KEY, data CLOB)')) { + die("BORK: don't know how to create a long column here:\n" . implode(", ", $db->errorInfo())); + } + } } $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -25,19 +25,19 @@ $sizes = array(32, 64, 128, 253, 254, 255, 256, 257, 258, 512, 1024, 2048, 3998, $db->beginTransaction(); $insert = $db->prepare('INSERT INTO TEST VALUES (?, ?)'); foreach ($sizes as $num) { - $insert->execute(array($num, str_repeat('i', $num))); + $insert->execute(array($num, str_repeat('i', $num))); } $insert = null; $db->commit(); foreach ($db->query('SELECT id, data from TEST') as $row) { - $expect = str_repeat('i', $row[0]); - if (strcmp($expect, $row[1])) { - echo "Failed on size $row[id]:\n"; - printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); - echo bin2hex($expect) . "\n"; - echo bin2hex($row['data']) . "\n"; - } + $expect = str_repeat('i', $row[0]); + if (strcmp($expect, $row[1])) { + echo "Failed on size $row[id]:\n"; + printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); + echo bin2hex($expect) . "\n"; + echo bin2hex($row['data']) . "\n"; + } } echo "Finished\n"; diff --git a/ext/pdo_pgsql/tests/bug43925.phpt b/ext/pdo_pgsql/tests/bug43925.phpt index d90f36fbbc40..20b1156de536 100644 --- a/ext/pdo_pgsql/tests/bug43925.phpt +++ b/ext/pdo_pgsql/tests/bug43925.phpt @@ -29,13 +29,13 @@ $dbh->query('INSERT INTO nodes (id, root, lft, rgt) VALUES (3, 1, 4, 5);'); $stmt = $dbh->prepare(' - SELECT * - FROM nodes - WHERE (:rootId > 0 OR lft > :left OR rgt > :left) - AND (root = :rootId OR root = :left) - AND (1 > :left OR 1 < :left OR 1 = :left) - AND (:x > 0 OR :x < 10 OR :x > 100) - OR :y = 1 OR :left = 1 + SELECT * + FROM nodes + WHERE (:rootId > 0 OR lft > :left OR rgt > :left) + AND (root = :rootId OR root = :left) + AND (1 > :left OR 1 < :left OR 1 = :left) + AND (:x > 0 OR :x < 10 OR :x > 100) + OR :y = 1 OR :left = 1 '); $stmt->bindValue('left', 1, PDO::PARAM_INT); @@ -46,8 +46,8 @@ $stmt->bindValue('y', 50, PDO::PARAM_INT); $stmt->execute(); foreach ($stmt->fetchAll() as $row) { - print implode(' - ', $row); - print "\n"; + print implode(' - ', $row); + print "\n"; } $dbh->query('DROP TABLE nodes'); diff --git a/ext/pdo_pgsql/tests/bug46274.phpt b/ext/pdo_pgsql/tests/bug46274.phpt index 0ae6849b417b..9f3dbf0542f9 100644 --- a/ext/pdo_pgsql/tests/bug46274.phpt +++ b/ext/pdo_pgsql/tests/bug46274.phpt @@ -15,7 +15,7 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - @$db->query("SET bytea_output = 'escape'"); + @$db->query("SET bytea_output = 'escape'"); } catch (Exception $e) { } diff --git a/ext/pdo_pgsql/tests/bug48764.phpt b/ext/pdo_pgsql/tests/bug48764.phpt index 1f890267e56b..c1d6c6a74fb2 100644 --- a/ext/pdo_pgsql/tests/bug48764.phpt +++ b/ext/pdo_pgsql/tests/bug48764.phpt @@ -37,7 +37,7 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); bug($db); putenv('PDOTEST_ATTR='.serialize(array( - PDO::ATTR_EMULATE_PREPARES => 1, + PDO::ATTR_EMULATE_PREPARES => 1, ))); $db = PDOTest::factory('PDO', false); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -50,14 +50,14 @@ putenv('PDOTEST_ATTR'); function bug($db, $options = array()) { - try { - $stmt = $db->prepare("SELECT ?", $options); - $stmt->execute(array(1)); - echo "OK\n"; - } catch (PDOException $e) { - // Indetermined data type when using native prepared statements - echo $e->getCode()."\n"; - } + try { + $stmt = $db->prepare("SELECT ?", $options); + $stmt->execute(array(1)); + echo "OK\n"; + } catch (PDOException $e) { + // Indetermined data type when using native prepared statements + echo $e->getCode()."\n"; + } } --EXPECT-- Test 1 diff --git a/ext/pdo_pgsql/tests/bug66584.phpt b/ext/pdo_pgsql/tests/bug66584.phpt index 7c98046a30b5..4fc43d881719 100644 --- a/ext/pdo_pgsql/tests/bug66584.phpt +++ b/ext/pdo_pgsql/tests/bug66584.phpt @@ -21,24 +21,24 @@ $pdo->query("CREATE TABLE b66584 (a int)"); $pdo->query("INSERT INTO b66584 VALUES (165)"); for ($i = 1; $i >= 0; $i--) { - $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, (bool)$i); + $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, (bool)$i); - try { - run($pdo, [0 => 1, 2 => 165, 5 => 3]); - } catch (\Exception $e) { - var_dump($e->getMessage()); - } + try { + run($pdo, [0 => 1, 2 => 165, 5 => 3]); + } catch (\Exception $e) { + var_dump($e->getMessage()); + } - try { - run($pdo, json_decode('{"0":234,"1":165,"2":221,"3":207,"4":188,"5":216,"6":1150,"7":916,"8":967,"9":987,"10":951,"11":990,"12":959,"13":896,"14":947,"15":877,"16":1000,"17":1023,"18":904,"19":856,"20":860,"21":866,"22":930,"23":974,"24":1032,"25":1016,"26":1050,"27":1059,"28":1040,"29":1064,"30":1004,"31":214,"32":189,"33":166,"34":1002,"35":167,"36":191,"37":859,"38":204,"39":181,"40":1001,"42":208,"43":198,"44":177,"45":1003,"46":858,"47":190,"48":162,"49":210,"50":171,"51":197,"52":168,"53":194,"54":209,"55":200,"56":192,"57":180,"58":232,"59":222,"60":163,"61":196,"62":217,"64":176,"65":193,"66":172,"67":195,"68":170,"69":173,"70":233,"71":223,"72":218,"73":186,"74":175,"75":224,"76":205,"77":211,"78":235,"79":1101,"80":225,"81":236,"82":1102,"83":1164,"84":1083,"85":1005,"86":861,"87":1179,"88":960,"89":991,"90":1187,"91":880,"92":1149,"93":1033,"94":931,"95":1006,"96":862,"97":1151,"98":917,"99":881,"100":1148,"101":1065,"102":867,"103":952,"104":1152,"105":918,"106":961,"107":1180,"108":992,"109":1188,"110":932,"111":933,"112":968,"113":868,"114":882,"115":1147,"116":1017,"117":1131,"118":1174,"119":1178,"120":1186,"121":869,"122":1051,"123":934,"124":969,"125":975,"126":1066,"127":237,"128":953,"129":1024,"130":1146,"131":883,"132":1145,"133":884,"134":885,"135":1144,"136":886,"137":1143,"138":1025,"139":897,"140":898,"141":899,"142":1026,"143":1142,"144":887,"145":1141,"146":888,"147":889,"148":1140,"149":1189,"150":993,"151":1139,"152":890,"153":1138,"154":891,"155":900,"156":892,"157":1137,"158":1027,"159":901,"160":1136,"161":893,"162":870,"163":1052,"164":954,"165":1041,"166":1018,"167":1165,"168":1084,"169":962,"170":1181,"171":994,"172":1190,"173":1042,"174":935,"175":226,"176":871,"177":1191,"178":995,"179":977,"180":948,"181":1175,"182":1053,"183":955,"184":1182,"185":963,"186":1067,"187":919,"188":1153,"189":920,"190":1154,"191":1055,"192":1054,"193":1056,"194":863,"195":872,"196":1028,"197":921,"198":1155,"199":936,"200":970,"201":1019,"202":1166,"203":1085,"204":1135,"205":894,"206":1034,"207":905,"208":873,"209":937,"210":902,"211":1029,"212":1007,"213":864,"214":1043,"215":1057,"216":956,"217":957,"218":939,"219":1086,"220":1167,"221":1087,"222":1168,"223":1173,"224":1108,"225":978,"226":1044,"227":1183,"228":964,"229":965,"230":1184,"231":1045,"232":874,"233":940,"234":1046,"235":979,"236":903,"237":980,"238":1156,"239":922,"240":1035,"241":906,"242":971,"243":972,"244":878,"245":1134,"246":879,"247":1133,"248":907,"249":1036,"250":908,"251":1132,"252":895,"253":909,"254":1060,"255":981,"256":1068,"257":996,"258":1192,"259":941,"260":865,"261":1008,"262":910,"263":997,"264":1193,"265":982,"266":942,"267":1020,"268":983,"269":1061,"270":949,"271":1176,"272":875,"273":911,"274":1069,"275":1157,"276":923,"277":1158,"278":924,"279":988,"280":984,"281":925,"282":1159,"283":1062,"284":1047,"285":1194,"286":998,"287":1021,"288":1030,"289":1031,"290":1070,"291":1088,"292":1169,"293":958,"294":1195,"295":999,"296":966,"297":1185,"298":944,"299":945,"300":1022,"301":1103,"302":220,"303":1099,"304":1048,"305":927,"306":1161,"307":989,"308":973,"309":1071,"310":1074,"311":1072,"312":1073,"313":912,"314":1037,"315":913,"316":914,"317":1177,"318":950,"319":1049,"320":876,"321":985,"322":915,"323":1038,"324":946,"325":1089,"326":1170,"327":1090,"328":1171,"329":1091,"330":1172,"331":1063,"332":986,"333":928,"334":1162,"335":929,"336":1163,"337":976,"338":231,"339":201,"340":1098,"341":215}', true)); - } catch (\Exception $e) { - var_dump($e->getMessage()); - } + try { + run($pdo, json_decode('{"0":234,"1":165,"2":221,"3":207,"4":188,"5":216,"6":1150,"7":916,"8":967,"9":987,"10":951,"11":990,"12":959,"13":896,"14":947,"15":877,"16":1000,"17":1023,"18":904,"19":856,"20":860,"21":866,"22":930,"23":974,"24":1032,"25":1016,"26":1050,"27":1059,"28":1040,"29":1064,"30":1004,"31":214,"32":189,"33":166,"34":1002,"35":167,"36":191,"37":859,"38":204,"39":181,"40":1001,"42":208,"43":198,"44":177,"45":1003,"46":858,"47":190,"48":162,"49":210,"50":171,"51":197,"52":168,"53":194,"54":209,"55":200,"56":192,"57":180,"58":232,"59":222,"60":163,"61":196,"62":217,"64":176,"65":193,"66":172,"67":195,"68":170,"69":173,"70":233,"71":223,"72":218,"73":186,"74":175,"75":224,"76":205,"77":211,"78":235,"79":1101,"80":225,"81":236,"82":1102,"83":1164,"84":1083,"85":1005,"86":861,"87":1179,"88":960,"89":991,"90":1187,"91":880,"92":1149,"93":1033,"94":931,"95":1006,"96":862,"97":1151,"98":917,"99":881,"100":1148,"101":1065,"102":867,"103":952,"104":1152,"105":918,"106":961,"107":1180,"108":992,"109":1188,"110":932,"111":933,"112":968,"113":868,"114":882,"115":1147,"116":1017,"117":1131,"118":1174,"119":1178,"120":1186,"121":869,"122":1051,"123":934,"124":969,"125":975,"126":1066,"127":237,"128":953,"129":1024,"130":1146,"131":883,"132":1145,"133":884,"134":885,"135":1144,"136":886,"137":1143,"138":1025,"139":897,"140":898,"141":899,"142":1026,"143":1142,"144":887,"145":1141,"146":888,"147":889,"148":1140,"149":1189,"150":993,"151":1139,"152":890,"153":1138,"154":891,"155":900,"156":892,"157":1137,"158":1027,"159":901,"160":1136,"161":893,"162":870,"163":1052,"164":954,"165":1041,"166":1018,"167":1165,"168":1084,"169":962,"170":1181,"171":994,"172":1190,"173":1042,"174":935,"175":226,"176":871,"177":1191,"178":995,"179":977,"180":948,"181":1175,"182":1053,"183":955,"184":1182,"185":963,"186":1067,"187":919,"188":1153,"189":920,"190":1154,"191":1055,"192":1054,"193":1056,"194":863,"195":872,"196":1028,"197":921,"198":1155,"199":936,"200":970,"201":1019,"202":1166,"203":1085,"204":1135,"205":894,"206":1034,"207":905,"208":873,"209":937,"210":902,"211":1029,"212":1007,"213":864,"214":1043,"215":1057,"216":956,"217":957,"218":939,"219":1086,"220":1167,"221":1087,"222":1168,"223":1173,"224":1108,"225":978,"226":1044,"227":1183,"228":964,"229":965,"230":1184,"231":1045,"232":874,"233":940,"234":1046,"235":979,"236":903,"237":980,"238":1156,"239":922,"240":1035,"241":906,"242":971,"243":972,"244":878,"245":1134,"246":879,"247":1133,"248":907,"249":1036,"250":908,"251":1132,"252":895,"253":909,"254":1060,"255":981,"256":1068,"257":996,"258":1192,"259":941,"260":865,"261":1008,"262":910,"263":997,"264":1193,"265":982,"266":942,"267":1020,"268":983,"269":1061,"270":949,"271":1176,"272":875,"273":911,"274":1069,"275":1157,"276":923,"277":1158,"278":924,"279":988,"280":984,"281":925,"282":1159,"283":1062,"284":1047,"285":1194,"286":998,"287":1021,"288":1030,"289":1031,"290":1070,"291":1088,"292":1169,"293":958,"294":1195,"295":999,"296":966,"297":1185,"298":944,"299":945,"300":1022,"301":1103,"302":220,"303":1099,"304":1048,"305":927,"306":1161,"307":989,"308":973,"309":1071,"310":1074,"311":1072,"312":1073,"313":912,"314":1037,"315":913,"316":914,"317":1177,"318":950,"319":1049,"320":876,"321":985,"322":915,"323":1038,"324":946,"325":1089,"326":1170,"327":1090,"328":1171,"329":1091,"330":1172,"331":1063,"332":986,"333":928,"334":1162,"335":929,"336":1163,"337":976,"338":231,"339":201,"340":1098,"341":215}', true)); + } catch (\Exception $e) { + var_dump($e->getMessage()); + } } try { - $pdo->query("DROP TABLE b66584"); - $pdo->rollback(); + $pdo->query("DROP TABLE b66584"); + $pdo->rollback(); } catch (\Exception $e) { } @@ -48,11 +48,11 @@ function run($pdo, $data) $stmt = $pdo->prepare("SELECT COUNT(*) FROM b66584 WHERE a IN ({$bind})"); - var_dump(count($data)); + var_dump(count($data)); $stmt->execute($data); - var_dump($stmt->fetchColumn()); + var_dump($stmt->fetchColumn()); } ?> diff --git a/ext/pdo_pgsql/tests/bug67462.phpt b/ext/pdo_pgsql/tests/bug67462.phpt index 11a39a5f1272..197bbb32ed51 100644 --- a/ext/pdo_pgsql/tests/bug67462.phpt +++ b/ext/pdo_pgsql/tests/bug67462.phpt @@ -17,14 +17,14 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $pdo->beginTransaction(); try { - $pdo->query("CREATE TABLE b67462 (a int NOT NULL PRIMARY KEY DEFERRABLE INITIALLY DEFERRED)"); - $pdo->query("INSERT INTO b67462 VALUES (1), (1)"); + $pdo->query("CREATE TABLE b67462 (a int NOT NULL PRIMARY KEY DEFERRABLE INITIALLY DEFERRED)"); + $pdo->query("INSERT INTO b67462 VALUES (1), (1)"); - var_dump($pdo->inTransaction()); - $pdo->commit(); // This should fail! + var_dump($pdo->inTransaction()); + $pdo->commit(); // This should fail! } catch (\Exception $e) { - var_dump($pdo->inTransaction()); - var_dump($pdo->beginTransaction()); + var_dump($pdo->inTransaction()); + var_dump($pdo->beginTransaction()); } ?> diff --git a/ext/pdo_pgsql/tests/bug68371.phpt b/ext/pdo_pgsql/tests/bug68371.phpt index 24dc5f501f1d..8cbcc7179c95 100644 --- a/ext/pdo_pgsql/tests/bug68371.phpt +++ b/ext/pdo_pgsql/tests/bug68371.phpt @@ -16,53 +16,53 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $attrs = array( // Extensive test: default value and set+get values - PDO::ATTR_EMULATE_PREPARES => array(null, true, false), - PDO::PGSQL_ATTR_DISABLE_PREPARES => array(null, true, false), + PDO::ATTR_EMULATE_PREPARES => array(null, true, false), + PDO::PGSQL_ATTR_DISABLE_PREPARES => array(null, true, false), // Just test the default - PDO::ATTR_AUTOCOMMIT => array(null), - PDO::ATTR_PREFETCH => array(null), - PDO::ATTR_TIMEOUT => array(null), - PDO::ATTR_ERRMODE => array(null), - PDO::ATTR_SERVER_VERSION => array(null), - PDO::ATTR_CLIENT_VERSION => array(null), - PDO::ATTR_SERVER_INFO => array(null), - PDO::ATTR_CONNECTION_STATUS => array(null), - PDO::ATTR_CASE => array(null), - PDO::ATTR_CURSOR_NAME => array(null), - PDO::ATTR_CURSOR => array(null), - PDO::ATTR_ORACLE_NULLS => array(null), - PDO::ATTR_PERSISTENT => array(null), - PDO::ATTR_STATEMENT_CLASS => array(null), - PDO::ATTR_FETCH_TABLE_NAMES => array(null), - PDO::ATTR_FETCH_CATALOG_NAMES => array(null), - PDO::ATTR_DRIVER_NAME => array(null), - PDO::ATTR_STRINGIFY_FETCHES => array(null), - PDO::ATTR_MAX_COLUMN_LEN => array(null), - PDO::ATTR_DEFAULT_FETCH_MODE => array(null), + PDO::ATTR_AUTOCOMMIT => array(null), + PDO::ATTR_PREFETCH => array(null), + PDO::ATTR_TIMEOUT => array(null), + PDO::ATTR_ERRMODE => array(null), + PDO::ATTR_SERVER_VERSION => array(null), + PDO::ATTR_CLIENT_VERSION => array(null), + PDO::ATTR_SERVER_INFO => array(null), + PDO::ATTR_CONNECTION_STATUS => array(null), + PDO::ATTR_CASE => array(null), + PDO::ATTR_CURSOR_NAME => array(null), + PDO::ATTR_CURSOR => array(null), + PDO::ATTR_ORACLE_NULLS => array(null), + PDO::ATTR_PERSISTENT => array(null), + PDO::ATTR_STATEMENT_CLASS => array(null), + PDO::ATTR_FETCH_TABLE_NAMES => array(null), + PDO::ATTR_FETCH_CATALOG_NAMES => array(null), + PDO::ATTR_DRIVER_NAME => array(null), + PDO::ATTR_STRINGIFY_FETCHES => array(null), + PDO::ATTR_MAX_COLUMN_LEN => array(null), + PDO::ATTR_DEFAULT_FETCH_MODE => array(null), ); foreach ($attrs as $a => $vals) { - foreach ($vals as $v) { - try { - if (!isset($v)) { - var_dump($pdo->getAttribute($a)); - } else { - $pdo->setAttribute($a, $v); - if ($pdo->getAttribute($a) === $v) { - echo "OK\n"; - } else { - throw new \Exception('KO'); - } - } - } catch (\Exception $e) { - if ($e->getCode() == 'IM001') { - echo "ERR\n"; - } else { - echo "ERR {$e->getMessage()}\n"; - } - } - } + foreach ($vals as $v) { + try { + if (!isset($v)) { + var_dump($pdo->getAttribute($a)); + } else { + $pdo->setAttribute($a, $v); + if ($pdo->getAttribute($a) === $v) { + echo "OK\n"; + } else { + throw new \Exception('KO'); + } + } + } catch (\Exception $e) { + if ($e->getCode() == 'IM001') { + echo "ERR\n"; + } else { + echo "ERR {$e->getMessage()}\n"; + } + } + } } ?> diff --git a/ext/pdo_pgsql/tests/bug69344.phpt b/ext/pdo_pgsql/tests/bug69344.phpt index 14d45d0ddbee..f544518455f2 100644 --- a/ext/pdo_pgsql/tests/bug69344.phpt +++ b/ext/pdo_pgsql/tests/bug69344.phpt @@ -16,19 +16,19 @@ $pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $pdo->setAttribute (\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC); $test = function () use ($pdo) { - $arr = [ - 0 => "a", - 2 => "b", - ]; - - $stmt = $pdo->prepare("SELECT (?)::text AS a, (?)::text AS b"); - - try { - $stmt->execute($arr); - var_dump($stmt->fetch()); - } catch (\Exception $e) { - echo $e->getMessage()."\n"; - } + $arr = [ + 0 => "a", + 2 => "b", + ]; + + $stmt = $pdo->prepare("SELECT (?)::text AS a, (?)::text AS b"); + + try { + $stmt->execute($arr); + var_dump($stmt->fetch()); + } catch (\Exception $e) { + echo $e->getMessage()."\n"; + } }; $test(); diff --git a/ext/pdo_pgsql/tests/bug70313.phpt b/ext/pdo_pgsql/tests/bug70313.phpt index f734442f8cb2..07c7f68ab327 100644 --- a/ext/pdo_pgsql/tests/bug70313.phpt +++ b/ext/pdo_pgsql/tests/bug70313.phpt @@ -15,20 +15,20 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); try { - $stmt = $db->prepare(");"); + $stmt = $db->prepare(");"); - $stmt->execute([1]); + $stmt->execute([1]); } catch (PDOException $e) { - var_dump($e->getCode()); + var_dump($e->getCode()); } $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); try { - $stmt = $db->prepare(");"); + $stmt = $db->prepare(");"); - $stmt->execute([1]); + $stmt->execute([1]); } catch (PDOException $e) { - var_dump($e->getCode()); + var_dump($e->getCode()); } ?> diff --git a/ext/pdo_pgsql/tests/bug70861.phpt b/ext/pdo_pgsql/tests/bug70861.phpt index 2da08e6e039d..a7d1d1f9d6e5 100644 --- a/ext/pdo_pgsql/tests/bug70861.phpt +++ b/ext/pdo_pgsql/tests/bug70861.phpt @@ -15,7 +15,7 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - @$db->query("SET bytea_output = 'escape'"); + @$db->query("SET bytea_output = 'escape'"); } catch (Exception $e) { } @@ -23,10 +23,10 @@ $db->query('DROP TABLE IF EXISTS test_blob_crash CASCADE'); $db->query('CREATE TABLE test_blob_crash (id SERIAL NOT NULL, blob1 BYTEA)'); class HelloWrapper { - public function stream_open() { return true; } - public function stream_eof() { return true; } - public function stream_read() { return NULL; } - public function stream_stat() { return array(); } + public function stream_open() { return true; } + public function stream_eof() { return true; } + public function stream_read() { return NULL; } + public function stream_stat() { return array(); } } stream_wrapper_register("hello", "HelloWrapper"); diff --git a/ext/pdo_pgsql/tests/bug71885.phpt b/ext/pdo_pgsql/tests/bug71885.phpt index ea5b1882ffae..f47ffcb4441c 100644 --- a/ext/pdo_pgsql/tests/bug71885.phpt +++ b/ext/pdo_pgsql/tests/bug71885.phpt @@ -16,19 +16,19 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM); foreach ([false, true] as $emulate) { - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate); - try { - $stmt = $db->prepare('select ?- lseg \'((-1,0),(1,0))\''); - $stmt->execute(); - } catch (PDOException $e) { - var_dump('ERR'); - } + try { + $stmt = $db->prepare('select ?- lseg \'((-1,0),(1,0))\''); + $stmt->execute(); + } catch (PDOException $e) { + var_dump('ERR'); + } - $stmt = $db->prepare('select ??- lseg \'((-1,0),(1,0))\''); - $stmt->execute(); + $stmt = $db->prepare('select ??- lseg \'((-1,0),(1,0))\''); + $stmt->execute(); - var_dump($stmt->fetch()); + var_dump($stmt->fetch()); } ?> diff --git a/ext/pdo_pgsql/tests/bug71885_2.phpt b/ext/pdo_pgsql/tests/bug71885_2.phpt index f957a39610c6..452902ed3897 100644 --- a/ext/pdo_pgsql/tests/bug71885_2.phpt +++ b/ext/pdo_pgsql/tests/bug71885_2.phpt @@ -25,15 +25,15 @@ $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM); $jsonb = $db->quote(json_encode(['a' => 1])); foreach ([false, true] as $emulate) { - $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate); + $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate); - $stmt = $db->prepare("SELECT {$jsonb}::jsonb ?? ?"); - $stmt->execute(['b']); - var_dump($stmt->fetch()); + $stmt = $db->prepare("SELECT {$jsonb}::jsonb ?? ?"); + $stmt->execute(['b']); + var_dump($stmt->fetch()); - $stmt = $db->prepare("SELECT {$jsonb}::jsonb ???"); - $stmt->execute(['a']); - var_dump($stmt->fetch()); + $stmt = $db->prepare("SELECT {$jsonb}::jsonb ???"); + $stmt->execute(['a']); + var_dump($stmt->fetch()); } ?> diff --git a/ext/pdo_pgsql/tests/bug72294.phpt b/ext/pdo_pgsql/tests/bug72294.phpt index bd5124ff17d8..6940fa8d1f99 100644 --- a/ext/pdo_pgsql/tests/bug72294.phpt +++ b/ext/pdo_pgsql/tests/bug72294.phpt @@ -102,7 +102,7 @@ class PreparedStatementCache //return $pdo->prepare( $sql ); $this->cached_statements[$sql] = $pdo->prepare( $sql ); - return $this->cached_statements[$sql]; + return $this->cached_statements[$sql]; } } @@ -110,29 +110,29 @@ class DatabaseTest extends PHPUnit_Framework_TestCase { public function testIt() { - $pdo = PDOTest::test_factory(__DIR__ . '/common.phpt'); + $pdo = PDOTest::test_factory(__DIR__ . '/common.phpt'); - $prepared_statement_cache = new PreparedStatementCache( $pdo ); + $prepared_statement_cache = new PreparedStatementCache( $pdo ); - for( $i = 1; $i <= 300; ++$i ) { - $statement = $prepared_statement_cache->prepare( $pdo, <<prepare( $pdo, <<execute(); - } + } } public function test_construct() { - $pdo = PDOTest::test_factory(__DIR__ . '/common.phpt'); + $pdo = PDOTest::test_factory(__DIR__ . '/common.phpt'); - $pdo->exec( 'CREATE TEMPORARY TABLE temp_table ( test_column INT NOT NULL );' ); + $pdo->exec( 'CREATE TEMPORARY TABLE temp_table ( test_column INT NOT NULL );' ); - $this->cache = new PreparedStatementCache( $pdo ); + $this->cache = new PreparedStatementCache( $pdo ); - $statement = $this->cache->prepare( $pdo, 'SELECT * FROM temp_table WHERE test_column > 0' ); - $statement->execute(); + $statement = $this->cache->prepare( $pdo, 'SELECT * FROM temp_table WHERE test_column > 0' ); + $statement->execute(); } } diff --git a/ext/pdo_pgsql/tests/bug72570.phpt b/ext/pdo_pgsql/tests/bug72570.phpt index b479974484c1..1d5512f1f64f 100644 --- a/ext/pdo_pgsql/tests/bug72570.phpt +++ b/ext/pdo_pgsql/tests/bug72570.phpt @@ -18,9 +18,9 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $stmt = $db->prepare("SELECT 1"); try { - var_dump($stmt->execute([1])); + var_dump($stmt->execute([1])); } catch (PDOException $e) { - var_dump($e->getCode()); + var_dump($e->getCode()); } ?> diff --git a/ext/pdo_pgsql/tests/bug75402.phpt b/ext/pdo_pgsql/tests/bug75402.phpt index 9c7460b87199..52ae4df957ec 100644 --- a/ext/pdo_pgsql/tests/bug75402.phpt +++ b/ext/pdo_pgsql/tests/bug75402.phpt @@ -46,7 +46,7 @@ $db->query("INSERT INTO bug75402 (\"id\", \"group_id\", \"submitter\", \"operati -$sql = "SELECT +$sql = "SELECT ID as \"sID\", GROUP_ID as \"sGroupID\", SUBMITTER as \"sOwner\", @@ -56,19 +56,19 @@ $sql = "SELECT STATUS as \"sStatus\", PROGRESS as \"sProgress\", HIDDEN as \"bHidden\", - to_char(INSERT_DATETIME, 'IYYY.MM.DD HH24:MI:SS') as \"sDatetime\" - FROM bug75402 + to_char(INSERT_DATETIME, 'IYYY.MM.DD HH24:MI:SS') as \"sDatetime\" + FROM bug75402 ORDER BY INSERT_DATETIME DESC"; if ($db) { $stmt = $db->prepare($sql, - array( - // With the following options memory is not being - // deallocated - \PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL - // With the following option memory is de-allocated - // \PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY - ) + array( + // With the following options memory is not being + // deallocated + \PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL + // With the following option memory is de-allocated + // \PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY + ) ); $stmt->execute(); diff --git a/ext/pdo_pgsql/tests/bug_33876.phpt b/ext/pdo_pgsql/tests/bug_33876.phpt index dc213f6abb90..a425f6d9f6d6 100644 --- a/ext/pdo_pgsql/tests/bug_33876.phpt +++ b/ext/pdo_pgsql/tests/bug_33876.phpt @@ -23,70 +23,70 @@ $res = $db->prepare('SELECT foo from test where bar = ?'); # this is the portable approach to binding a bool $res->bindValue(1, false, PDO::PARAM_BOOL); if (!$res->execute()) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # this is the portable approach to binding a bool $res->bindValue(1, true, PDO::PARAM_BOOL); if (!$res->execute()) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # true gets cast to string (because the implied default is string) # true-as-string is 1, so this "works" if (!$res->execute(array(true))) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # Expected to fail; unless told otherwise, PDO assumes string inputs # false -> "" as string, which pgsql doesn't like if (!$res->execute(array(false))) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # And now using emulator prepares echo "EMUL\n"; $res = $db->prepare('SELECT foo from test where bar = ?', array( - PDO::ATTR_EMULATE_PREPARES => true)); + PDO::ATTR_EMULATE_PREPARES => true)); # this is the portable approach to binding a bool $res->bindValue(1, false, PDO::PARAM_BOOL); if (!$res->execute()) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # this is the portable approach to binding a bool $res->bindValue(1, true, PDO::PARAM_BOOL); if (!$res->execute()) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # true gets cast to string (because the implied default is string) # true-as-string is 1, so this "works" if (!$res->execute(array(true))) - print_r($res->errorInfo()); + print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # Expected to fail; unless told otherwise, PDO assumes string inputs # false -> "" as string, which pgsql doesn't like if (!$res->execute(array(false))) { - $err = $res->errorInfo(); - // Strip additional lines outputted by recent PgSQL versions - $err[2] = trim(current(explode("\n", $err[2]))); - print_r($err); + $err = $res->errorInfo(); + // Strip additional lines outputted by recent PgSQL versions + $err[2] = trim(current(explode("\n", $err[2]))); + print_r($err); } else { - print_r($res->fetchAll(PDO::FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); } --EXPECTF-- Array diff --git a/ext/pdo_pgsql/tests/config.inc b/ext/pdo_pgsql/tests/config.inc index 0fefe4664b8b..367671e42a04 100644 --- a/ext/pdo_pgsql/tests/config.inc +++ b/ext/pdo_pgsql/tests/config.inc @@ -1,16 +1,16 @@ $v) { - putenv("$k=$v"); + putenv("$k=$v"); } diff --git a/ext/pdo_pgsql/tests/copy_from.phpt b/ext/pdo_pgsql/tests/copy_from.phpt index 55a9df72aa4f..b57a8ea9aeb4 100644 --- a/ext/pdo_pgsql/tests/copy_from.phpt +++ b/ext/pdo_pgsql/tests/copy_from.phpt @@ -22,11 +22,11 @@ $tableRows = array(); $tableRowsWithDifferentNullValues = array(); for($i=0;$i<3;$i++) { - $firstParameter = $i; - $secondParameter = "test insert {$i}"; - $tableRows[] = "{$firstParameter}\t{$secondParameter}\t\\N"; - $tableRowsWithDifferentNullValues[] = "{$firstParameter};{$secondParameter};NULL"; - $tableRowsWithDifferentNullValuesAndSelectedFields[] = "{$firstParameter};NULL"; + $firstParameter = $i; + $secondParameter = "test insert {$i}"; + $tableRows[] = "{$firstParameter}\t{$secondParameter}\t\\N"; + $tableRowsWithDifferentNullValues[] = "{$firstParameter};{$secondParameter};NULL"; + $tableRowsWithDifferentNullValuesAndSelectedFields[] = "{$firstParameter};NULL"; } $filename = 'test_pgsqlCopyFromFile.csv'; $filenameWithDifferentNullValues = 'test_pgsqlCopyFromFileWithDifferentNullValues.csv'; @@ -42,7 +42,7 @@ var_dump($db->pgsqlCopyFromArray('test',$tableRows)); $stmt = $db->query("select * from test"); foreach($stmt as $r) { - var_dump($r); + var_dump($r); } $db->rollback(); @@ -51,7 +51,7 @@ $db->beginTransaction(); var_dump($db->pgsqlCopyFromArray('test',$tableRowsWithDifferentNullValues,";","NULL")); $stmt = $db->query("select * from test"); foreach($stmt as $r) { - var_dump($r); + var_dump($r); } $db->rollback(); @@ -60,16 +60,16 @@ $db->beginTransaction(); var_dump($db->pgsqlCopyFromArray('test',$tableRowsWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); $stmt = $db->query("select * from test"); foreach($stmt as $r) { - var_dump($r); + var_dump($r); } $db->rollback(); echo "Testing pgsqlCopyFromArray() with error\n"; $db->beginTransaction(); try { - var_dump($db->pgsqlCopyFromArray('test_error',$tableRowsWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); + var_dump($db->pgsqlCopyFromArray('test_error',$tableRowsWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); } catch (Exception $e) { - echo "Exception: {$e->getMessage()}\n"; + echo "Exception: {$e->getMessage()}\n"; } $db->rollback(); @@ -79,7 +79,7 @@ var_dump($db->pgsqlCopyFromFile('test',$filename)); $stmt = $db->query("select * from test"); foreach($stmt as $r) { - var_dump($r); + var_dump($r); } $db->rollback(); @@ -88,7 +88,7 @@ $db->beginTransaction(); var_dump($db->pgsqlCopyFromFile('test',$filenameWithDifferentNullValues,";","NULL")); $stmt = $db->query("select * from test"); foreach($stmt as $r) { - var_dump($r); + var_dump($r); } $db->rollback(); @@ -97,31 +97,31 @@ $db->beginTransaction(); var_dump($db->pgsqlCopyFromFile('test',$filenameWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); $stmt = $db->query("select * from test"); foreach($stmt as $r) { - var_dump($r); + var_dump($r); } $db->rollback(); echo "Testing pgsqlCopyFromFile() with error\n"; $db->beginTransaction(); try { - var_dump($db->pgsqlCopyFromFile('test_error',$filenameWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); + var_dump($db->pgsqlCopyFromFile('test_error',$filenameWithDifferentNullValuesAndSelectedFields,";","NULL",'a,c')); } catch (Exception $e) { - echo "Exception: {$e->getMessage()}\n"; + echo "Exception: {$e->getMessage()}\n"; } $db->rollback(); echo "Testing pgsqlCopyFromFile() with non existing file\n"; $db->beginTransaction(); try { - var_dump($db->pgsqlCopyFromFile('test',"nonexisting/foo.csv",";","NULL",'a,c')); + var_dump($db->pgsqlCopyFromFile('test',"nonexisting/foo.csv",";","NULL",'a,c')); } catch (Exception $e) { - echo "Exception: {$e->getMessage()}\n"; + echo "Exception: {$e->getMessage()}\n"; } $db->rollback(); // Clean up foreach (array($filename, $filenameWithDifferentNullValues, $filenameWithDifferentNullValuesAndSelectedFields) as $f) { - @unlink($f); + @unlink($f); } ?> --EXPECTF-- diff --git a/ext/pdo_pgsql/tests/copy_to.phpt b/ext/pdo_pgsql/tests/copy_to.phpt index 3df882c93cb6..edda1483db08 100644 --- a/ext/pdo_pgsql/tests/copy_to.phpt +++ b/ext/pdo_pgsql/tests/copy_to.phpt @@ -22,13 +22,13 @@ echo "Preparing test table for CopyTo tests\n"; $stmt = $db->prepare("INSERT INTO test (a, b, c) values (?, ?, ?)"); for($i=0;$i<3;$i++) { - $firstParameter = $i; - $secondParameter = "test insert {$i}"; - $thirdParameter = NULL; - $stmt->bindValue(1, $firstParameter); - $stmt->bindValue(2, $secondParameter); - $stmt->bindValue(3, $thirdParameter); - $stmt->execute(); + $firstParameter = $i; + $secondParameter = "test insert {$i}"; + $thirdParameter = NULL; + $stmt->bindValue(1, $firstParameter); + $stmt->bindValue(2, $secondParameter); + $stmt->bindValue(3, $thirdParameter); + $stmt->execute(); } $db->commit(); @@ -42,9 +42,9 @@ var_dump($db->pgsqlCopyToArray('test',";","NULL",'a,c')); echo "Testing pgsqlCopyToArray() with error\n"; try { - var_dump($db->pgsqlCopyToArray('test_error')); + var_dump($db->pgsqlCopyToArray('test_error')); } catch (Exception $e) { - echo "Exception: {$e->getMessage()}\n"; + echo "Exception: {$e->getMessage()}\n"; } echo "Testing pgsqlCopyToFile() with default parameters\n"; @@ -61,20 +61,20 @@ echo file_get_contents($filename); echo "Testing pgsqlCopyToFile() with error\n"; try { - var_dump($db->pgsqlCopyToFile('test_error',$filename)); + var_dump($db->pgsqlCopyToFile('test_error',$filename)); } catch (Exception $e) { - echo "Exception: {$e->getMessage()}\n"; + echo "Exception: {$e->getMessage()}\n"; } echo "Testing pgsqlCopyToFile() to unwritable file\n"; try { - var_dump($db->pgsqlCopyToFile('test', 'nonexistent/foo.csv')); + var_dump($db->pgsqlCopyToFile('test', 'nonexistent/foo.csv')); } catch (Exception $e) { - echo "Exception: {$e->getMessage()}\n"; + echo "Exception: {$e->getMessage()}\n"; } if(isset($filename)) { - @unlink($filename); + @unlink($filename); } ?> --EXPECTF-- diff --git a/ext/pdo_pgsql/tests/disable_prepares.phpt b/ext/pdo_pgsql/tests/disable_prepares.phpt index bbc6a62e876b..f224bffb1505 100644 --- a/ext/pdo_pgsql/tests/disable_prepares.phpt +++ b/ext/pdo_pgsql/tests/disable_prepares.phpt @@ -15,7 +15,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_COLUMN); $stmt = $db->prepare("SELECT statement FROM pg_prepared_statements", array( - PDO::ATTR_EMULATE_PREPARES => true)); + PDO::ATTR_EMULATE_PREPARES => true)); $stmt2 = $db->prepare("SELECT (?)::int2"); $stmt2->execute(array(1)); @@ -27,7 +27,7 @@ $stmt->execute(); $first = $stmt->fetchAll(); $stmt3 = $db->prepare("SELECT (?)::int4", array( - PDO::PGSQL_ATTR_DISABLE_PREPARES => true)); + PDO::PGSQL_ATTR_DISABLE_PREPARES => true)); $stmt3->execute(array(3)); var_dump($stmt3->fetch()); $stmt3->execute(array(4)); diff --git a/ext/pdo_pgsql/tests/is_in_transaction.phpt b/ext/pdo_pgsql/tests/is_in_transaction.phpt index f5e950a04710..cff798619bc5 100644 --- a/ext/pdo_pgsql/tests/is_in_transaction.phpt +++ b/ext/pdo_pgsql/tests/is_in_transaction.phpt @@ -39,19 +39,19 @@ $stmt->bindValue(1, "error"); $stmt->bindValue(2, "test insert"); $stmt->execute(); } catch (Exception $e) { - /* We catch the exception because the execute will give error and we must test the PDO::PGSQL_TRANSACTION_ERROR */ - echo "Test PDO::PGSQL_TRANSACTION_INERROR\n"; - var_dump($db->inTransaction()); - $db->rollBack(); + /* We catch the exception because the execute will give error and we must test the PDO::PGSQL_TRANSACTION_ERROR */ + echo "Test PDO::PGSQL_TRANSACTION_INERROR\n"; + var_dump($db->inTransaction()); + $db->rollBack(); } echo "Test PDO::PGSQL_TRANSACTION_IDLE\n"; var_dump($db->inTransaction()); } catch (Exception $e) { - /* catch exceptions so that we can show the relative error */ - echo "Exception! at line ", $e->getLine(), "\n"; - var_dump($e->getMessage()); + /* catch exceptions so that we can show the relative error */ + echo "Exception! at line ", $e->getLine(), "\n"; + var_dump($e->getMessage()); } ?> diff --git a/ext/pdo_pgsql/tests/large_objects.phpt b/ext/pdo_pgsql/tests/large_objects.phpt index 6215e49cb50c..d1f1f050481c 100644 --- a/ext/pdo_pgsql/tests/large_objects.phpt +++ b/ext/pdo_pgsql/tests/large_objects.phpt @@ -38,8 +38,8 @@ $stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB); $stmt->execute(); echo "Fetching:\n"; while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) { - var_dump($row['blobid']); - var_dump(stream_get_contents($lob)); + var_dump($row['blobid']); + var_dump(stream_get_contents($lob)); } echo "Fetched!\n"; @@ -49,8 +49,8 @@ $stmt->execute(); $stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB); echo "Fetching late bind:\n"; while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) { - var_dump($row['blobid']); - var_dump(is_int($row['bloboid'])); + var_dump($row['blobid']); + var_dump(is_int($row['bloboid'])); } echo "Fetched!\n"; @@ -60,16 +60,16 @@ $stmt->execute(); $stmt->bindColumn('bloboid', $lob, PDO::PARAM_LOB); echo "Fetching NO bind:\n"; while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) { - var_dump($row['blobid']); - var_dump(is_int($row['bloboid'])); + var_dump($row['blobid']); + var_dump(is_int($row['bloboid'])); } echo "Fetched!\n"; } catch (Exception $e) { - /* catch exceptions so that we can guarantee to clean - * up the LOB */ - echo "Exception! at line ", $e->getLine(), "\n"; - var_dump($e->getMessage()); + /* catch exceptions so that we can guarantee to clean + * up the LOB */ + echo "Exception! at line ", $e->getLine(), "\n"; + var_dump($e->getMessage()); } /* Now to remove the large object from the database, so it doesn't diff --git a/ext/pdo_sqlite/tests/bug35336.phpt b/ext/pdo_sqlite/tests/bug35336.phpt index 201429bc4ee2..52a425b62f0b 100644 --- a/ext/pdo_sqlite/tests/bug35336.phpt +++ b/ext/pdo_sqlite/tests/bug35336.phpt @@ -7,9 +7,9 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; --FILE-- true)); - } + function __construct($dsn) { + parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true)); + } } class Baz extends PDO { - function __construct($dsn) { - parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true)); - } + function __construct($dsn) { + parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true)); + } } class Bar extends Baz { - function quux() { - echo get_class($this), "\n"; - $foo = new Foo("sqlite::memory:"); - echo get_class($this), "\n"; - } + function quux() { + echo get_class($this), "\n"; + $foo = new Foo("sqlite::memory:"); + echo get_class($this), "\n"; + } } $bar = new Bar("sqlite::memory:"); diff --git a/ext/pdo_sqlite/tests/bug48773.phpt b/ext/pdo_sqlite/tests/bug48773.phpt index c9a2f64bef71..a5f43cdd923b 100644 --- a/ext/pdo_sqlite/tests/bug48773.phpt +++ b/ext/pdo_sqlite/tests/bug48773.phpt @@ -8,18 +8,18 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); - } + $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); + } } $db = new foo('sqlite::memory:', '', ''); diff --git a/ext/pdo_sqlite/tests/bug50728.phpt b/ext/pdo_sqlite/tests/bug50728.phpt index b00ea50cf016..98f8907f485e 100644 --- a/ext/pdo_sqlite/tests/bug50728.phpt +++ b/ext/pdo_sqlite/tests/bug50728.phpt @@ -7,9 +7,9 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; --FILE-- getCode()); + var_dump($e->getCode()); } ?> --EXPECT-- diff --git a/ext/pdo_sqlite/tests/bug52487.phpt b/ext/pdo_sqlite/tests/bug52487.phpt index ff586d2f6414..17a581296a21 100644 --- a/ext/pdo_sqlite/tests/bug52487.phpt +++ b/ext/pdo_sqlite/tests/bug52487.phpt @@ -11,7 +11,7 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt'); $stmt = $db->prepare("select 1 as attr"); for ($i = 0; $i < 10; $i++) { - $stmt->setFetchMode(PDO::FETCH_INTO, new stdClass); + $stmt->setFetchMode(PDO::FETCH_INTO, new stdClass); } print "ok\n"; diff --git a/ext/pdo_sqlite/tests/bug66033.phpt b/ext/pdo_sqlite/tests/bug66033.phpt index ebd519171a7d..c48ebe41ec48 100644 --- a/ext/pdo_sqlite/tests/bug66033.phpt +++ b/ext/pdo_sqlite/tests/bug66033.phpt @@ -7,26 +7,26 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; --FILE-- dbh = $dbh; - throw new Exception("Blah"); - } + public $dbh; + protected function __construct($dbh) { + $this->dbh = $dbh; + throw new Exception("Blah"); + } } $pdo = new PDO('sqlite::memory:', null, null); $pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement', - array($pdo))); + array($pdo))); $pdo->exec("CREATE TABLE IF NOT EXISTS messages ( - id INTEGER PRIMARY KEY, - title TEXT, - message TEXT, - time INTEGER)"); + id INTEGER PRIMARY KEY, + title TEXT, + message TEXT, + time INTEGER)"); try { - $pdoStatement = $pdo->query("select * from messages"); + $pdoStatement = $pdo->query("select * from messages"); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> --EXPECT-- diff --git a/ext/pdo_sqlite/tests/bug70862.phpt b/ext/pdo_sqlite/tests/bug70862.phpt index d66bb6262fba..f676d66387d8 100644 --- a/ext/pdo_sqlite/tests/bug70862.phpt +++ b/ext/pdo_sqlite/tests/bug70862.phpt @@ -14,10 +14,10 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); class HelloWrapper { - public function stream_open() { return true; } - public function stream_eof() { return true; } - public function stream_read() { return NULL; } - public function stream_stat() { return array(); } + public function stream_open() { return true; } + public function stream_eof() { return true; } + public function stream_read() { return NULL; } + public function stream_stat() { return array(); } } stream_wrapper_register("hello", "HelloWrapper"); diff --git a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt index c788b4ee90ec..525e29b953e1 100644 --- a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt +++ b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt @@ -34,27 +34,27 @@ $st = $db->query('SELECT * FROM testing'); var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo'))); class foo { - public function method($x) { - return "--- $x ---"; - } + public function method($x) { + return "--- $x ---"; + } } class bar extends foo { - public function __construct($db) { - $st = $db->query('SELECT * FROM testing'); - var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::method'))); - } - - static public function test($x, $y) { - return $x .'---'. $y; - } - - private function test2($x, $y) { - return $x; - } - - public function test3($x, $y) { - return $x .'==='. $y; - } + public function __construct($db) { + $st = $db->query('SELECT * FROM testing'); + var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::method'))); + } + + static public function test($x, $y) { + return $x .'---'. $y; + } + + private function test2($x, $y) { + return $x; + } + + public function test3($x, $y) { + return $x .'==='. $y; + } } new bar($db); diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt index c9157d1b054d..b21620bee714 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt @@ -16,7 +16,7 @@ $db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; } foreach ($db->query('SELECT testing(name) FROM foobar') as $row) { - var_dump($row); + var_dump($row); } $db->query('DROP TABLE foobar'); diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt index fcfc344896e3..0742d20e845a 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt @@ -18,7 +18,7 @@ $db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a, $result = $db->query('SELECT name FROM foobar ORDER BY name COLLATE MYCOLLATE'); foreach ($result as $row) { - echo $row['name'] . "\n"; + echo $row['name'] . "\n"; } $result = $db->query('SELECT name FROM foobar ORDER BY name'); diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt index 1e753f379930..45075e974860 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt @@ -17,7 +17,7 @@ $db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }); foreach ($db->query('SELECT testing(name) FROM foobar') as $row) { - var_dump($row); + var_dump($row); } $db->query('DROP TABLE foobar'); diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt index 5a329a1d971a..9cb6ecc02d85 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt @@ -20,7 +20,7 @@ $db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1, foreach ($db->query('SELECT testing(name) FROM foobar') as $row) { - var_dump($row); + var_dump($row); } $db->query('DROP TABLE foobar'); diff --git a/ext/pgsql/tests/01createdb.phpt b/ext/pgsql/tests/01createdb.phpt index 45062c3b4930..2abd051c8b65 100644 --- a/ext/pgsql/tests/01createdb.phpt +++ b/ext/pgsql/tests/01createdb.phpt @@ -11,22 +11,22 @@ include('config.inc'); $db = pg_connect($conn_str); if (!($q = @pg_query($db, "SELECT * FROM ".$table_name)) || !@pg_num_rows($q)) { - pg_query($db,$table_def); // Create table here - for ($i=0; $i < $num_test_record; $i++) { - pg_query($db,"INSERT INTO ".$table_name." VALUES ($i, 'ABC');"); - } + pg_query($db,$table_def); // Create table here + for ($i=0; $i < $num_test_record; $i++) { + pg_query($db,"INSERT INTO ".$table_name." VALUES ($i, 'ABC');"); + } } else { - echo pg_last_error()."\n"; + echo pg_last_error()."\n"; } $v = pg_version(); if (version_compare($v['server'], '9.2', '>=') && (!($q = @pg_query($db, "SELECT * FROM ".$table_name_92)) || !@pg_num_rows($q))) { - pg_query($db,$table_def_92); // Create table here + pg_query($db,$table_def_92); // Create table here } else { - echo pg_last_error()."\n"; + echo pg_last_error()."\n"; } // Create view here diff --git a/ext/pgsql/tests/02connection.phpt b/ext/pgsql/tests/02connection.phpt index 16a44e5dd910..9922bba98f3b 100644 --- a/ext/pgsql/tests/02connection.phpt +++ b/ext/pgsql/tests/02connection.phpt @@ -13,41 +13,41 @@ var_dump($db); if (pg_connection_status($db) != PGSQL_CONNECTION_OK) { - echo "pg_connection_status() error\n"; + echo "pg_connection_status() error\n"; } if (!pg_connection_reset($db)) { - echo "pg_connection_reset() error\n"; + echo "pg_connection_reset() error\n"; } if (pg_connection_busy($db)) { - echo "pg_connection_busy() error\n"; + echo "pg_connection_busy() error\n"; } if (function_exists('pg_transaction_status')) { - if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE) - { - echo "pg_transaction_status() error\n"; - } + if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE) + { + echo "pg_transaction_status() error\n"; + } } if (false === pg_host($db)) { - echo "pg_host() error\n"; + echo "pg_host() error\n"; } if (!pg_dbname($db)) { - echo "pg_dbname() error\n"; + echo "pg_dbname() error\n"; } if (!pg_port($db)) { - echo "pg_port() error\n"; + echo "pg_port() error\n"; } if (pg_tty($db)) { - echo "pg_tty() error\n"; + echo "pg_tty() error\n"; } if (pg_options($db)) { - echo "pg_options() error\n"; + echo "pg_options() error\n"; } pg_close($db); diff --git a/ext/pgsql/tests/03sync_query.phpt b/ext/pgsql/tests/03sync_query.phpt index eb8fae084d1e..1cd439bc204a 100644 --- a/ext/pgsql/tests/03sync_query.phpt +++ b/ext/pgsql/tests/03sync_query.phpt @@ -12,45 +12,45 @@ $db = pg_connect($conn_str); $result = pg_query($db, "SELECT * FROM ".$table_name.";"); if (!($rows = pg_num_rows($result))) { - echo "pg_num_row() error\n"; + echo "pg_num_row() error\n"; } for ($i=0; $i < $rows; $i++) { - pg_fetch_array($result, $i, PGSQL_NUM); + pg_fetch_array($result, $i, PGSQL_NUM); } for ($i=0; $i < $rows; $i++) { - pg_fetch_object($result); + pg_fetch_object($result); } for ($i=0; $i < $rows; $i++) { - pg_fetch_row($result, $i); + pg_fetch_row($result, $i); } for ($i=0; $i < $rows; $i++) { - pg_fetch_result($result, $i, 0); + pg_fetch_result($result, $i, 0); } pg_result_error($result); if (function_exists('pg_result_error_field')) { - pg_result_error_field($result, PGSQL_DIAG_SEVERITY); - pg_result_error_field($result, PGSQL_DIAG_SQLSTATE); - pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY); - pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL); - pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT); - pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION); - if (defined('PGSQL_DIAG_INTERNAL_POSITION')) - { - pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION); - } - if (defined('PGSQL_DIAG_INTERNAL_QUERY')) - { - pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY); - } - pg_result_error_field($result, PGSQL_DIAG_CONTEXT); - pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE); - pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE); - pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION); + pg_result_error_field($result, PGSQL_DIAG_SEVERITY); + pg_result_error_field($result, PGSQL_DIAG_SQLSTATE); + pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY); + pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL); + pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT); + pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION); + if (defined('PGSQL_DIAG_INTERNAL_POSITION')) + { + pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION); + } + if (defined('PGSQL_DIAG_INTERNAL_QUERY')) + { + pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY); + } + pg_result_error_field($result, PGSQL_DIAG_CONTEXT); + pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE); + pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE); + pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION); } pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";")); diff --git a/ext/pgsql/tests/04async_query.phpt b/ext/pgsql/tests/04async_query.phpt index fe67382026c7..34d383ed686b 100644 --- a/ext/pgsql/tests/04async_query.phpt +++ b/ext/pgsql/tests/04async_query.phpt @@ -10,35 +10,35 @@ include('config.inc'); $db = pg_connect($conn_str); if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) { - echo "pg_send_query() error\n"; + echo "pg_send_query() error\n"; } while(pg_connection_busy($db)); // busy wait: intended if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - echo "pg_connection_status() error\n"; + echo "pg_connection_status() error\n"; } if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } if (!($rows = pg_num_rows($result))) { - echo "pg_num_rows() error\n"; + echo "pg_num_rows() error\n"; } for ($i=0; $i < $rows; $i++) { - pg_fetch_array($result, $i, PGSQL_NUM); + pg_fetch_array($result, $i, PGSQL_NUM); } for ($i=0; $i < $rows; $i++) { - pg_fetch_object($result); + pg_fetch_object($result); } for ($i=0; $i < $rows; $i++) { - pg_fetch_row($result, $i); + pg_fetch_row($result, $i); } for ($i=0; $i < $rows; $i++) { - pg_fetch_result($result, $i, 0); + pg_fetch_result($result, $i, 0); } pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); @@ -52,7 +52,7 @@ pg_field_is_null($result, 0); if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');")) { - echo "pg_send_query() error\n"; + echo "pg_send_query() error\n"; } pg_last_oid($result); diff --git a/ext/pgsql/tests/05large_object.phpt b/ext/pgsql/tests/05large_object.phpt index e091d6072a6d..df47d074044a 100644 --- a/ext/pgsql/tests/05large_object.phpt +++ b/ext/pgsql/tests/05large_object.phpt @@ -63,7 +63,7 @@ pg_query($db, 'begin'); @unlink($path . 'php.gif.exported'); pg_lo_export($oid, $path . 'php.gif.exported', $db); if (!file_exists($path . 'php.gif.exported')) { - echo "Export failed\n"; + echo "Export failed\n"; } @unlink($path . 'php.gif.exported'); pg_query($db, 'commit'); diff --git a/ext/pgsql/tests/07optional.phpt b/ext/pgsql/tests/07optional.phpt index 9fa6f1633193..f633f8149823 100644 --- a/ext/pgsql/tests/07optional.phpt +++ b/ext/pgsql/tests/07optional.phpt @@ -14,9 +14,9 @@ $enc = pg_client_encoding($db); pg_set_client_encoding($db, $enc); if (function_exists('pg_set_error_verbosity')) { - pg_set_error_verbosity(PGSQL_ERRORS_TERSE); - pg_set_error_verbosity(PGSQL_ERRORS_DEFAULT); - pg_set_error_verbosity(PGSQL_ERRORS_VERBOSE); + pg_set_error_verbosity(PGSQL_ERRORS_TERSE); + pg_set_error_verbosity(PGSQL_ERRORS_DEFAULT); + pg_set_error_verbosity(PGSQL_ERRORS_VERBOSE); } echo "OK"; ?> diff --git a/ext/pgsql/tests/08escape.phpt b/ext/pgsql/tests/08escape.phpt index 6b0d1899d41a..6b510aef7337 100644 --- a/ext/pgsql/tests/08escape.phpt +++ b/ext/pgsql/tests/08escape.phpt @@ -14,13 +14,13 @@ $expect = "ABC\\\\ABC\\'"; $expect2 = "ABC\\\\ABC\\\\''"; //the way escape string differs from PostgreSQL 9.0 $after = pg_escape_string($before); if ($expect === $after || $expect2 === $after) { - echo "pg_escape_string() is Ok\n"; + echo "pg_escape_string() is Ok\n"; } else { - echo "pg_escape_string() is NOT Ok\n"; - var_dump($before); - var_dump($after); - var_dump($expect); + echo "pg_escape_string() is NOT Ok\n"; + var_dump($before); + var_dump($after); + var_dump($expect); } // pg_escape_bytea() test @@ -28,13 +28,13 @@ $before = "ABC\\ABC"; $expect = "ABC\\\\\\\\ABC"; $after = pg_escape_bytea($before); if ($expect === $after) { - echo "pg_escape_bytea() is Ok\n"; + echo "pg_escape_bytea() is Ok\n"; } else { - echo "pg_escape_byte() is NOT Ok\n"; - var_dump($before); - var_dump($after); - var_dump($expect); + echo "pg_escape_byte() is NOT Ok\n"; + var_dump($before); + var_dump($after); + var_dump($expect); } // Test using database @@ -49,23 +49,23 @@ pg_query($db, $sql); // Retrieve binary from DB for ($i = 0; $i < 2; $i++) { - $sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = 10000"; - $result = pg_query($db, $sql); - $row = pg_fetch_array($result, 0, PGSQL_ASSOC); + $sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = 10000"; + $result = pg_query($db, $sql); + $row = pg_fetch_array($result, 0, PGSQL_ASSOC); - if ($data === pg_unescape_bytea($row['bin'])) { - echo "pg_escape_bytea() actually works with database\n"; - break; - } - elseif (!$i) { - // Force bytea escaping and retry - @pg_query($db, "SET bytea_output = 'escape'"); - } - else { - $result = pg_query($db, $sql); - echo "pg_escape_bytea() is broken\n"; - break; - } + if ($data === pg_unescape_bytea($row['bin'])) { + echo "pg_escape_bytea() actually works with database\n"; + break; + } + elseif (!$i) { + // Force bytea escaping and retry + @pg_query($db, "SET bytea_output = 'escape'"); + } + else { + $result = pg_query($db, $sql); + echo "pg_escape_bytea() is broken\n"; + break; + } } // pg_escape_literal/pg_escape_identifier @@ -73,26 +73,26 @@ $before = "ABC\\ABC\'"; $expect = " E'ABC\\\\ABC\\\\'''"; $after = pg_escape_literal($before); if ($expect === $after) { - echo "pg_escape_literal() is Ok\n"; + echo "pg_escape_literal() is Ok\n"; } else { - echo "pg_escape_literal() is NOT Ok\n"; - var_dump($before); - var_dump($after); - var_dump($expect); + echo "pg_escape_literal() is NOT Ok\n"; + var_dump($before); + var_dump($after); + var_dump($expect); } $before = "ABC\\ABC\'"; $expect = "\"ABC\ABC\'\""; $after = pg_escape_identifier($before); if ($expect === $after) { - echo "pg_escape_identifier() is Ok\n"; + echo "pg_escape_identifier() is Ok\n"; } else { - echo "pg_escape_identifier() is NOT Ok\n"; - var_dump($before); - var_dump($after); - var_dump($expect); + echo "pg_escape_identifier() is NOT Ok\n"; + var_dump($before); + var_dump($after); + var_dump($expect); } ?> diff --git a/ext/pgsql/tests/10pg_convert_json_array.phpt b/ext/pgsql/tests/10pg_convert_json_array.phpt index 960cfd6c99f8..46aec3ffbc02 100644 --- a/ext/pgsql/tests/10pg_convert_json_array.phpt +++ b/ext/pgsql/tests/10pg_convert_json_array.phpt @@ -14,16 +14,16 @@ include 'config.inc'; $db = pg_connect($conn_str); $fields = array( - 'textary'=>'{"meeting", "lunch", "training", "presentation"}', - 'jsn'=>'{"f1":1,"f2":"foo"}', + 'textary'=>'{"meeting", "lunch", "training", "presentation"}', + 'jsn'=>'{"f1":1,"f2":"foo"}', ); $converted = pg_convert($db, $table_name_92, $fields); var_dump($converted); if (!pg_insert($db, $table_name_92, $fields)) { - echo "Error\n"; + echo "Error\n"; } else { - echo "OK\n"; + echo "OK\n"; } ?> diff --git a/ext/pgsql/tests/15pg_delete.phpt b/ext/pgsql/tests/15pg_delete.phpt index 3b9f7d803c0b..5afcf602537d 100644 --- a/ext/pgsql/tests/15pg_delete.phpt +++ b/ext/pgsql/tests/15pg_delete.phpt @@ -15,10 +15,10 @@ $ids = array('num'=>'1234'); echo pg_delete($db, $table_name, $ids, PGSQL_DML_STRING)."\n"; echo pg_delete($db, $table_name, $ids, PGSQL_DML_STRING|PGSQL_DML_ESCAPE)."\n"; if (!pg_delete($db, $table_name, $ids)) { - echo "Error\n"; + echo "Error\n"; } else { - echo "Ok\n"; + echo "Ok\n"; } ?> --EXPECT-- diff --git a/ext/pgsql/tests/18pg_escape_bytea_before.phpt b/ext/pgsql/tests/18pg_escape_bytea_before.phpt index ca2acd9ce766..8222eccde430 100644 --- a/ext/pgsql/tests/18pg_escape_bytea_before.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea_before.phpt @@ -20,10 +20,10 @@ $rows = pg_fetch_all($result); $unesc_image = pg_unescape_bytea($rows[0]['bin']); if ($unesc_image !== $image) { - echo "NG"; + echo "NG"; } else { - echo "OK"; + echo "OK"; } ?> --EXPECT-- diff --git a/ext/pgsql/tests/18pg_escape_bytea_esc.phpt b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt index 263adad40c3c..0420c7eb752f 100644 --- a/ext/pgsql/tests/18pg_escape_bytea_esc.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt @@ -20,10 +20,10 @@ $rows = pg_fetch_all($result); $unesc_image = pg_unescape_bytea($rows[0]['bin']); if ($unesc_image !== $image) { - echo "NG"; + echo "NG"; } else { - echo "OK"; + echo "OK"; } ?> --EXPECT-- diff --git a/ext/pgsql/tests/18pg_escape_bytea_hex.phpt b/ext/pgsql/tests/18pg_escape_bytea_hex.phpt index 5af7bbebeffe..af2f3cf4d43d 100644 --- a/ext/pgsql/tests/18pg_escape_bytea_hex.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea_hex.phpt @@ -23,10 +23,10 @@ $rows = pg_fetch_all($result); $unesc_image = pg_unescape_bytea($rows[0]['bin']); if ($unesc_image !== $image) { - echo "NG"; + echo "NG"; } else { - echo "OK"; + echo "OK"; } ?> --EXPECT-- diff --git a/ext/pgsql/tests/22pg_fetch_object.phpt b/ext/pgsql/tests/22pg_fetch_object.phpt index ebdf77568e89..9f9319bcfeff 100644 --- a/ext/pgsql/tests/22pg_fetch_object.phpt +++ b/ext/pgsql/tests/22pg_fetch_object.phpt @@ -9,9 +9,9 @@ error_reporting(E_ALL); include 'config.inc'; class test_class { - function __construct($arg1, $arg2) { - echo __METHOD__ . "($arg1,$arg2)\n"; - } + function __construct($arg1, $arg2) { + echo __METHOD__ . "($arg1,$arg2)\n"; + } } $db = pg_connect($conn_str); diff --git a/ext/pgsql/tests/23sync_query_params.phpt b/ext/pgsql/tests/23sync_query_params.phpt index a700ddca17b6..1406cec5bf0c 100644 --- a/ext/pgsql/tests/23sync_query_params.phpt +++ b/ext/pgsql/tests/23sync_query_params.phpt @@ -14,42 +14,42 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] >= 3) { - $result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)); - if (!($rows = pg_num_rows($result))) - { - echo "pg_num_row() error\n"; - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_array($result, $i, PGSQL_NUM); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_object($result); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_row($result, $i); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_result($result, $i, 0); - } + $result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)); + if (!($rows = pg_num_rows($result))) + { + echo "pg_num_row() error\n"; + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_array($result, $i, PGSQL_NUM); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_object($result); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_row($result, $i); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_result($result, $i, 0); + } - pg_result_error($result); - pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); - pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); - pg_field_name($result, 0); - pg_field_num($result, $field_name); - pg_field_size($result, 0); - pg_field_type($result, 0); - pg_field_prtlen($result, 0); - pg_field_is_null($result, 0); + pg_result_error($result); + pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); + pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); + pg_field_name($result, 0); + pg_field_num($result, $field_name); + pg_field_size($result, 0); + pg_field_type($result, 0); + pg_field_prtlen($result, 0); + pg_field_is_null($result, 0); - $result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")); - pg_last_oid($result); + $result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")); + pg_last_oid($result); - pg_free_result($result); + pg_free_result($result); } pg_close($db); diff --git a/ext/pgsql/tests/24sync_query_prepared.phpt b/ext/pgsql/tests/24sync_query_prepared.phpt index ca099eb43b8f..1ab7e095f4b9 100644 --- a/ext/pgsql/tests/24sync_query_prepared.phpt +++ b/ext/pgsql/tests/24sync_query_prepared.phpt @@ -14,48 +14,48 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] >= 3) { - $result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;"); - pg_result_error($result); - pg_free_result($result); - $result = pg_execute($db, "php_test", array(100)); - if (!($rows = pg_num_rows($result))) - { - echo "pg_num_row() error\n"; - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_array($result, $i, PGSQL_NUM); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_object($result); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_row($result, $i); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_result($result, $i, 0); - } + $result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;"); + pg_result_error($result); + pg_free_result($result); + $result = pg_execute($db, "php_test", array(100)); + if (!($rows = pg_num_rows($result))) + { + echo "pg_num_row() error\n"; + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_array($result, $i, PGSQL_NUM); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_object($result); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_row($result, $i); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_result($result, $i, 0); + } - pg_result_error($result); - pg_num_rows(pg_execute($db, "php_test", array(100))); - pg_num_fields(pg_execute($db, "php_test", array(100))); - pg_field_name($result, 0); - pg_field_num($result, $field_name); - pg_field_size($result, 0); - pg_field_type($result, 0); - pg_field_prtlen($result, 0); - pg_field_is_null($result, 0); + pg_result_error($result); + pg_num_rows(pg_execute($db, "php_test", array(100))); + pg_num_fields(pg_execute($db, "php_test", array(100))); + pg_field_name($result, 0); + pg_field_num($result, $field_name); + pg_field_size($result, 0); + pg_field_type($result, 0); + pg_field_prtlen($result, 0); + pg_field_is_null($result, 0); - $result = pg_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"); - pg_result_error($result); - pg_free_result($result); - $result = pg_execute($db, "php_test2", array(9999, "A'BC")); - pg_last_oid($result); + $result = pg_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"); + pg_result_error($result); + pg_free_result($result); + $result = pg_execute($db, "php_test2", array(9999, "A'BC")); + pg_last_oid($result); - pg_free_result($result); + pg_free_result($result); } pg_close($db); diff --git a/ext/pgsql/tests/25async_query_params.phpt b/ext/pgsql/tests/25async_query_params.phpt index ae1a1630efef..87b5e0dbb113 100644 --- a/ext/pgsql/tests/25async_query_params.phpt +++ b/ext/pgsql/tests/25async_query_params.phpt @@ -14,53 +14,53 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] >= 3) { - if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) { - echo "pg_send_query_params() error\n"; - } - while(pg_connection_busy($db)); // busy wait: intended - if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - echo "pg_connection_status() error\n"; - } - if (!($result = pg_get_result($db))) - { - echo "pg_get_result() error\n"; - } - if (!($rows = pg_num_rows($result))) { - echo "pg_num_rows() error\n"; - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_array($result, $i, PGSQL_NUM); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_object($result); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_row($result, $i); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_result($result, $i, 0); - } + if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) { + echo "pg_send_query_params() error\n"; + } + while(pg_connection_busy($db)); // busy wait: intended + if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { + echo "pg_connection_status() error\n"; + } + if (!($result = pg_get_result($db))) + { + echo "pg_get_result() error\n"; + } + if (!($rows = pg_num_rows($result))) { + echo "pg_num_rows() error\n"; + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_array($result, $i, PGSQL_NUM); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_object($result); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_row($result, $i); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_result($result, $i, 0); + } - pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); - pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); - pg_field_name($result, 0); - pg_field_num($result, $field_name); - pg_field_size($result, 0); - pg_field_type($result, 0); - pg_field_prtlen($result, 0); - pg_field_is_null($result, 0); + pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); + pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); + pg_field_name($result, 0); + pg_field_num($result, $field_name); + pg_field_size($result, 0); + pg_field_type($result, 0); + pg_field_prtlen($result, 0); + pg_field_is_null($result, 0); - if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"))) - { - echo "pg_send_query_params() error\n"; - } + if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"))) + { + echo "pg_send_query_params() error\n"; + } - pg_last_oid($result); - pg_free_result($result); + pg_last_oid($result); + pg_free_result($result); } pg_close($db); diff --git a/ext/pgsql/tests/26async_query_prepared.phpt b/ext/pgsql/tests/26async_query_prepared.phpt index 33ca7c7bfa34..6eacb4e3eeb7 100644 --- a/ext/pgsql/tests/26async_query_prepared.phpt +++ b/ext/pgsql/tests/26async_query_prepared.phpt @@ -14,89 +14,89 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] >= 3) { - if (!pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) { - echo "pg_send_prepare() error\n"; - } - while(pg_connection_busy($db)); // busy wait: intended - if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - echo "pg_connection_status() error\n"; - } - if (!($result = pg_get_result($db))) - { - echo "pg_get_result() error\n"; - } - pg_free_result($result); + if (!pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) { + echo "pg_send_prepare() error\n"; + } + while(pg_connection_busy($db)); // busy wait: intended + if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { + echo "pg_connection_status() error\n"; + } + if (!($result = pg_get_result($db))) + { + echo "pg_get_result() error\n"; + } + pg_free_result($result); - if (!pg_send_execute($db, 'php_test', array(100))) { - echo "pg_send_execute() error\n"; - } - while(pg_connection_busy($db)); // busy wait: intended - if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - echo "pg_connection_status() error\n"; - } - if (!($result = pg_get_result($db))) - { - echo "pg_get_result() error\n"; - } + if (!pg_send_execute($db, 'php_test', array(100))) { + echo "pg_send_execute() error\n"; + } + while(pg_connection_busy($db)); // busy wait: intended + if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { + echo "pg_connection_status() error\n"; + } + if (!($result = pg_get_result($db))) + { + echo "pg_get_result() error\n"; + } - if (!($rows = pg_num_rows($result))) { - echo "pg_num_rows() error\n"; - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_array($result, $i, PGSQL_NUM); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_object($result); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_row($result, $i); - } - for ($i=0; $i < $rows; $i++) - { - pg_fetch_result($result, $i, 0); - } + if (!($rows = pg_num_rows($result))) { + echo "pg_num_rows() error\n"; + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_array($result, $i, PGSQL_NUM); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_object($result); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_row($result, $i); + } + for ($i=0; $i < $rows; $i++) + { + pg_fetch_result($result, $i, 0); + } - pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); - pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); - pg_field_name($result, 0); - pg_field_num($result, $field_name); - pg_field_size($result, 0); - pg_field_type($result, 0); - pg_field_prtlen($result, 0); - pg_field_is_null($result, 0); + pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); + pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); + pg_field_name($result, 0); + pg_field_num($result, $field_name); + pg_field_size($result, 0); + pg_field_type($result, 0); + pg_field_prtlen($result, 0); + pg_field_is_null($result, 0); - if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);")) - { - echo "pg_send_prepare() error\n"; - } - while(pg_connection_busy($db)); // busy wait: intended - if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - echo "pg_connection_status() error\n"; - } - if (!($result = pg_get_result($db))) - { - echo "pg_get_result() error\n"; - } - pg_free_result($result); + if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);")) + { + echo "pg_send_prepare() error\n"; + } + while(pg_connection_busy($db)); // busy wait: intended + if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { + echo "pg_connection_status() error\n"; + } + if (!($result = pg_get_result($db))) + { + echo "pg_get_result() error\n"; + } + pg_free_result($result); - if (!pg_send_execute($db, "php_test2", array(9999, "A'BC"))) - { - echo "pg_send_execute() error\n"; - } - while(pg_connection_busy($db)); // busy wait: intended - if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - echo "pg_connection_status() error\n"; - } - if (!($result = pg_get_result($db))) - { - echo "pg_get_result() error\n"; - } + if (!pg_send_execute($db, "php_test2", array(9999, "A'BC"))) + { + echo "pg_send_execute() error\n"; + } + while(pg_connection_busy($db)); // busy wait: intended + if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { + echo "pg_connection_status() error\n"; + } + if (!($result = pg_get_result($db))) + { + echo "pg_get_result() error\n"; + } - pg_last_oid($result); - pg_free_result($result); + pg_last_oid($result); + pg_free_result($result); } pg_close($db); diff --git a/ext/pgsql/tests/29nb_async_connect.phpt b/ext/pgsql/tests/29nb_async_connect.phpt index a9b17ebc3a19..d98b34da4782 100644 --- a/ext/pgsql/tests/29nb_async_connect.phpt +++ b/ext/pgsql/tests/29nb_async_connect.phpt @@ -11,30 +11,30 @@ include('config.inc'); include('nonblocking.inc'); if (!$db = pg_connect($conn_str, PGSQL_CONNECT_ASYNC)) { - die("pg_connect() error"); + die("pg_connect() error"); } elseif (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { - die("pg_connect() error"); + die("pg_connect() error"); } elseif ($db_socket = pg_socket($db)) { - stream_set_blocking($db_socket, FALSE); + stream_set_blocking($db_socket, FALSE); } else { - die("pg_socket() error"); + die("pg_socket() error"); } while (TRUE) { - switch ($status = pg_connect_poll($db)) { - case PGSQL_POLLING_READING: - nb_is_readable($db_socket); - break; - case PGSQL_POLLING_WRITING: - nb_is_writable($db_socket); - break; - case PGSQL_POLLING_FAILED: - die("async connection failed"); - case PGSQL_POLLING_OK: - break 2; - default: - die("unknown poll status"); - } + switch ($status = pg_connect_poll($db)) { + case PGSQL_POLLING_READING: + nb_is_readable($db_socket); + break; + case PGSQL_POLLING_WRITING: + nb_is_writable($db_socket); + break; + case PGSQL_POLLING_FAILED: + die("async connection failed"); + case PGSQL_POLLING_OK: + break 2; + default: + die("unknown poll status"); + } } assert(pg_connection_status($db) === PGSQL_CONNECTION_OK); echo "OK"; diff --git a/ext/pgsql/tests/30nb_async_query_params.phpt b/ext/pgsql/tests/30nb_async_query_params.phpt index 1c8a1eed8f0a..612327a9c485 100644 --- a/ext/pgsql/tests/30nb_async_query_params.phpt +++ b/ext/pgsql/tests/30nb_async_query_params.phpt @@ -15,8 +15,8 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] < 3) { - echo "OK"; - exit(0); + echo "OK"; + exit(0); } $db_socket = pg_socket($db); @@ -24,30 +24,30 @@ stream_set_blocking($db_socket, false); $sent = pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)); if ($sent === FALSE) { - echo "pg_send_query_params() error\n"; + echo "pg_send_query_params() error\n"; } elseif ($sent === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } if (!($rows = pg_num_rows($result))) { - echo "pg_num_rows() error\n"; + echo "pg_num_rows() error\n"; } for ($i=0; $i < $rows; $i++) { - pg_fetch_array($result, $i, PGSQL_NUM); + pg_fetch_array($result, $i, PGSQL_NUM); } for ($i=0; $i < $rows; $i++) { - pg_fetch_object($result); + pg_fetch_object($result); } for ($i=0; $i < $rows; $i++) { - pg_fetch_row($result, $i); + pg_fetch_row($result, $i); } for ($i=0; $i < $rows; $i++) { - pg_fetch_result($result, $i, 0); + pg_fetch_result($result, $i, 0); } pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); @@ -62,9 +62,9 @@ pg_field_is_null($result, 0); $sent = pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")); if ($sent === FALSE) { - echo "pg_send_query_params() error\n"; + echo "pg_send_query_params() error\n"; } elseif ($sent === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } pg_last_oid($result); diff --git a/ext/pgsql/tests/31nb_async_query_prepared.phpt b/ext/pgsql/tests/31nb_async_query_prepared.phpt index f485e596f9fb..476f21bc519d 100644 --- a/ext/pgsql/tests/31nb_async_query_prepared.phpt +++ b/ext/pgsql/tests/31nb_async_query_prepared.phpt @@ -15,8 +15,8 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] < 3) { - echo "OK"; - exit(0); + echo "OK"; + exit(0); } $db_socket = pg_socket($db); @@ -24,45 +24,45 @@ stream_set_blocking($db_socket, false); $nb_send = pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;"); if ($nb_send === FALSE) { - echo "pg_send_prepare() error\n"; + echo "pg_send_prepare() error\n"; } elseif ($nb_send === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } pg_free_result($result); $nb_send = pg_send_execute($db, 'php_test', array(100)); if ($nb_send === FALSE) { - echo "pg_send_execute() error\n"; + echo "pg_send_execute() error\n"; } elseif ($nb_send === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } if (!($rows = pg_num_rows($result))) { - echo "pg_num_rows() error\n"; + echo "pg_num_rows() error\n"; } for ($i=0; $i < $rows; $i++) { - pg_fetch_array($result, $i, PGSQL_NUM); + pg_fetch_array($result, $i, PGSQL_NUM); } for ($i=0; $i < $rows; $i++) { - pg_fetch_object($result); + pg_fetch_object($result); } for ($i=0; $i < $rows; $i++) { - pg_fetch_row($result, $i); + pg_fetch_row($result, $i); } for ($i=0; $i < $rows; $i++) { - pg_fetch_result($result, $i, 0); + pg_fetch_result($result, $i, 0); } pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); @@ -76,29 +76,29 @@ pg_field_is_null($result, 0); $nb_send = pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"); if ($nb_send === FALSE) { - echo "pg_send_prepare() error\n"; + echo "pg_send_prepare() error\n"; } elseif ($nb_send === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } pg_free_result($result); $nb_send = pg_send_execute($db, "php_test2", array(9999, "A'BC")); if ($nb_send === FALSE) { - echo "pg_send_execute() error\n"; + echo "pg_send_execute() error\n"; } elseif ($nb_send === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } pg_last_oid($result); diff --git a/ext/pgsql/tests/32nb_async_query.phpt b/ext/pgsql/tests/32nb_async_query.phpt index 8ef1591db50f..a90f9799a3a7 100644 --- a/ext/pgsql/tests/32nb_async_query.phpt +++ b/ext/pgsql/tests/32nb_async_query.phpt @@ -15,8 +15,8 @@ $db = pg_connect($conn_str); $version = pg_version($db); if ($version['protocol'] < 3) { - echo "OK"; - exit(0); + echo "OK"; + exit(0); } $db_socket = pg_socket($db); @@ -24,31 +24,31 @@ stream_set_blocking($db_socket, false); $nb_send = pg_send_query($db, "SELECT * FROM ".$table_name.";"); if ($nb_send === FALSE) { - echo "pg_send_query() error\n"; + echo "pg_send_query() error\n"; } elseif ($nb_send === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } if (!($rows = pg_num_rows($result))) { - echo "pg_num_rows() error\n"; + echo "pg_num_rows() error\n"; } for ($i=0; $i < $rows; $i++) { - pg_fetch_array($result, $i, PGSQL_NUM); + pg_fetch_array($result, $i, PGSQL_NUM); } for ($i=0; $i < $rows; $i++) { - pg_fetch_object($result); + pg_fetch_object($result); } for ($i=0; $i < $rows; $i++) { - pg_fetch_row($result, $i); + pg_fetch_row($result, $i); } for ($i=0; $i < $rows; $i++) { - pg_fetch_result($result, $i, 0); + pg_fetch_result($result, $i, 0); } pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); @@ -62,15 +62,15 @@ pg_field_is_null($result, 0); $nb_send = pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"); if ($nb_send === FALSE) { - echo "pg_send_query() error\n"; + echo "pg_send_query() error\n"; } elseif ($nb_send === 0) { - nb_flush($db, $db_socket); + nb_flush($db, $db_socket); } nb_consume($db, $db_socket); if (!($result = pg_get_result($db))) { - echo "pg_get_result() error\n"; + echo "pg_get_result() error\n"; } pg_last_oid($result); diff --git a/ext/pgsql/tests/80_bug14383.phpt b/ext/pgsql/tests/80_bug14383.phpt index 1331f146ccf6..e9c609388816 100644 --- a/ext/pgsql/tests/80_bug14383.phpt +++ b/ext/pgsql/tests/80_bug14383.phpt @@ -11,7 +11,7 @@ require_once('config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ("Could not connect to the server"); + die ("Could not connect to the server"); } pg_close($dbh); diff --git a/ext/pgsql/tests/80_bug24499.phpt b/ext/pgsql/tests/80_bug24499.phpt index a9773bdafe08..1ba8accadea5 100644 --- a/ext/pgsql/tests/80_bug24499.phpt +++ b/ext/pgsql/tests/80_bug24499.phpt @@ -11,7 +11,7 @@ require_once('config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ("Could not connect to the server"); + die ("Could not connect to the server"); } @pg_query("DROP SEQUENCE id_id_seq"); @@ -19,24 +19,24 @@ if (!$dbh) { pg_query("CREATE TABLE id (id SERIAL, t INT)"); for ($i=0; $i<4; $i++) { - pg_query("INSERT INTO id (t) VALUES ($i)"); + pg_query("INSERT INTO id (t) VALUES ($i)"); } class Id { - public $id; + public $id; - public function getId() - { - global $dbh; + public function getId() + { + global $dbh; - $q = pg_query($dbh, "SELECT id FROM id"); - print_r(pg_fetch_array($q)); - print_r(pg_fetch_array($q)); - $id = pg_fetch_object($q); - var_dump($id); - return $id->id; - } + $q = pg_query($dbh, "SELECT id FROM id"); + print_r(pg_fetch_array($q)); + print_r(pg_fetch_array($q)); + $id = pg_fetch_object($q); + var_dump($id); + return $id->id; + } } $id = new Id(); diff --git a/ext/pgsql/tests/80_bug27597.phpt b/ext/pgsql/tests/80_bug27597.phpt index 5e28258570b2..92f0d81800fb 100644 --- a/ext/pgsql/tests/80_bug27597.phpt +++ b/ext/pgsql/tests/80_bug27597.phpt @@ -11,29 +11,29 @@ require_once(__DIR__ . '/config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ("Could not connect to the server"); + die ("Could not connect to the server"); } @pg_query("DROP TABLE id"); pg_query("CREATE TABLE id (id INT)"); for ($i=0; $i<4; $i++) { - pg_query("INSERT INTO id (id) VALUES ($i)"); + pg_query("INSERT INTO id (id) VALUES ($i)"); } function xi_fetch_array($res, $type = PGSQL_ASSOC) { - $a = pg_fetch_array($res, NULL, $type) ; - return $a ; + $a = pg_fetch_array($res, NULL, $type) ; + return $a ; } $res = pg_query("SELECT * FROM id"); $i = 0; // endless-loop protection while($row = xi_fetch_array($res)) { - print_r($row); - if ($i++ > 4) { - echo "ENDLESS-LOOP"; - exit(1); - } + print_r($row); + if ($i++ > 4) { + echo "ENDLESS-LOOP"; + exit(1); + } } pg_close($dbh); diff --git a/ext/pgsql/tests/80_bug32223.phpt b/ext/pgsql/tests/80_bug32223.phpt index 36dd3a803f47..08c8903dbf8b 100644 --- a/ext/pgsql/tests/80_bug32223.phpt +++ b/ext/pgsql/tests/80_bug32223.phpt @@ -25,7 +25,7 @@ require_once('lcmess.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ("Could not connect to the server"); + die ("Could not connect to the server"); } _set_lc_messages(); @@ -46,7 +46,7 @@ var_dump($row); pg_free_result($res); if ($row[0] == 'f') { - var_dump(pg_last_notice($dbh)); + var_dump(pg_last_notice($dbh)); } pg_close($dbh); diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt index 5d83024681a9..63908f3b7ada 100644 --- a/ext/pgsql/tests/80_bug36625.phpt +++ b/ext/pgsql/tests/80_bug36625.phpt @@ -11,7 +11,7 @@ require_once('config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ('Could not connect to the server'); + die ('Could not connect to the server'); } $tracefile = __DIR__ . '/trace.tmp'; @@ -27,9 +27,9 @@ pg_close($dbh); $found = 0; function search_trace_file($line) { - if (strpos($line, '"select 1"') !== false || strpos($line, "'select 1'") !== false) { - $GLOBALS['found']++; - } + if (strpos($line, '"select 1"') !== false || strpos($line, "'select 1'") !== false) { + $GLOBALS['found']++; + } } $trace = file($tracefile); diff --git a/ext/pgsql/tests/80_bug39971.phpt b/ext/pgsql/tests/80_bug39971.phpt index 14c7fbd547ba..4fd065adf7a9 100644 --- a/ext/pgsql/tests/80_bug39971.phpt +++ b/ext/pgsql/tests/80_bug39971.phpt @@ -11,7 +11,7 @@ require_once('config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ("Could not connect to the server"); + die ("Could not connect to the server"); } pg_query("CREATE TABLE php_test (id SERIAL, tm timestamp NOT NULL)"); diff --git a/ext/pgsql/tests/80_bug42783.phpt b/ext/pgsql/tests/80_bug42783.phpt index c375aa0d6655..49119891e0b7 100644 --- a/ext/pgsql/tests/80_bug42783.phpt +++ b/ext/pgsql/tests/80_bug42783.phpt @@ -11,7 +11,7 @@ require_once('config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { - die ("Could not connect to the server"); + die ("Could not connect to the server"); } pg_query("CREATE TABLE php_test (id SERIAL PRIMARY KEY, time TIMESTAMP NOT NULL DEFAULT now())"); diff --git a/ext/pgsql/tests/bug71998.phpt b/ext/pgsql/tests/bug71998.phpt index 01d295e3e8c7..116135ab51ef 100644 --- a/ext/pgsql/tests/bug71998.phpt +++ b/ext/pgsql/tests/bug71998.phpt @@ -14,61 +14,61 @@ $db = pg_connect($conn_str); pg_query("CREATE TABLE tmp_statistics (id integer NOT NULL, remote_addr inet);"); $ips = array( - /* IPv4*/ - "127.0.0.1", - "10.0.0.1", - "192.168.1.1", - "0.0.0.0", - "255.255.255.255", - "192.168.1.35/24", + /* IPv4*/ + "127.0.0.1", + "10.0.0.1", + "192.168.1.1", + "0.0.0.0", + "255.255.255.255", + "192.168.1.35/24", - /* IPv6 */ - "::1", - "::10.2.3.4", - "::ffff:10.4.3.2", - "1:2:3:4:5:6:7:8", - "::ffff:10.0.0.1", - "::ffff:1.2.3.4", - "::ffff:0.0.0.0", - "1:2:3:4:5:6:77:88", - "::ffff:255.255.255.255", - "fe08::7:8", - "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", - "::5:aef1:ffff/128", - "2001:4f8:3:ba::/112", + /* IPv6 */ + "::1", + "::10.2.3.4", + "::ffff:10.4.3.2", + "1:2:3:4:5:6:7:8", + "::ffff:10.0.0.1", + "::ffff:1.2.3.4", + "::ffff:0.0.0.0", + "1:2:3:4:5:6:77:88", + "::ffff:255.255.255.255", + "fe08::7:8", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + "::5:aef1:ffff/128", + "2001:4f8:3:ba::/112", ); $bad = array( - /* bad */ - "256.257.258.259", - "fe08::7:8interface", - "schnitzel", - "10002.3.4", - "1.2.3.4.5", - "256.0.0.0", - "260.0.0.0", + /* bad */ + "256.257.258.259", + "fe08::7:8interface", + "schnitzel", + "10002.3.4", + "1.2.3.4.5", + "256.0.0.0", + "260.0.0.0", ); $ips = array_merge($ips, $bad); $i = 0; $errors = 0; foreach ($ips as $ip) { - $data = array("id" => ++$i, "remote_addr" => $ip); - $r = @pg_insert($db, 'tmp_statistics', $data); + $data = array("id" => ++$i, "remote_addr" => $ip); + $r = @pg_insert($db, 'tmp_statistics', $data); - if (!$r && in_array($ip, $bad)) { - $errors++; - //echo pg_last_error($db); - } + if (!$r && in_array($ip, $bad)) { + $errors++; + //echo pg_last_error($db); + } - //pg_query($db, "INSERT INTO tmp_statistics (id, remote_addr) VALUES (2, '127.0.0.1')"); // OK, record inserted + //pg_query($db, "INSERT INTO tmp_statistics (id, remote_addr) VALUES (2, '127.0.0.1')"); // OK, record inserted } $r = pg_query($db, "SELECT * FROM tmp_statistics"); while (false != ($row = pg_fetch_row($r))) { - var_dump($row); + var_dump($row); } echo $errors, " errors caught\n"; diff --git a/ext/pgsql/tests/bug72028.phpt b/ext/pgsql/tests/bug72028.phpt index a16f8e72f742..7073ca7d03a6 100644 --- a/ext/pgsql/tests/bug72028.phpt +++ b/ext/pgsql/tests/bug72028.phpt @@ -29,7 +29,7 @@ $result = pg_query_params($conn, $sql, $params2); $r = pg_query("SELECT * FROM $table"); while (false !== ($i = pg_fetch_assoc($r))) { - var_dump($i); + var_dump($i); } pg_query("DROP TABLE $table"); diff --git a/ext/pgsql/tests/bug77047.phpt b/ext/pgsql/tests/bug77047.phpt index 2cbc4c3ddaf3..222a5398b63b 100644 --- a/ext/pgsql/tests/bug77047.phpt +++ b/ext/pgsql/tests/bug77047.phpt @@ -14,8 +14,8 @@ $db = pg_connect($conn_str); pg_query($db, "DROP TABLE IF EXISTS bug77047"); pg_query($db, "CREATE TABLE bug77047 ( - t TIME WITHOUT TIME ZONE - )"); + t TIME WITHOUT TIME ZONE + )"); pg_insert($db, "bug77047", array("t" => "13:31")); pg_insert($db, "bug77047", array("t" => "13:31:13")); @@ -26,7 +26,7 @@ pg_insert($db, "bug77047", array("t" => "")); $res = pg_query($db, "SELECT t FROM bug77047"); while (false !== ($row = pg_fetch_row($res))) { - var_dump(array_pop($row)); + var_dump(array_pop($row)); } ?> diff --git a/ext/pgsql/tests/lcmess.inc b/ext/pgsql/tests/lcmess.inc index 6e0ac25b11ec..32ab0e36f59a 100644 --- a/ext/pgsql/tests/lcmess.inc +++ b/ext/pgsql/tests/lcmess.inc @@ -2,20 +2,20 @@ function _skip_lc_messages($lc_messages = 'C') { - if (!_set_lc_messages($lc_messages)) { - die("skip Cannot set LC_MESSAGES to '{$lc_messages}'\n"); - } + if (!_set_lc_messages($lc_messages)) { + die("skip Cannot set LC_MESSAGES to '{$lc_messages}'\n"); + } } function _set_lc_messages($lc_messages = 'C') { - if (pg_result(pg_query("SHOW LC_MESSAGES"), 0, 0) != $lc_messages) { - if (!@pg_exec("SET LC_MESSAGES='{$lc_messages}'")) { - return false; - } - } + if (pg_result(pg_query("SHOW LC_MESSAGES"), 0, 0) != $lc_messages) { + if (!@pg_exec("SET LC_MESSAGES='{$lc_messages}'")) { + return false; + } + } - return true; + return true; } ?> diff --git a/ext/pgsql/tests/pg_insert_002.phpt b/ext/pgsql/tests/pg_insert_002.phpt index 0dcee55b8f71..bb84a00d0dd2 100644 --- a/ext/pgsql/tests/pg_insert_002.phpt +++ b/ext/pgsql/tests/pg_insert_002.phpt @@ -10,7 +10,7 @@ include('config.inc'); $conn = pg_connect($conn_str); foreach (array('', '.', '..') as $table) { - var_dump(pg_insert($conn, $table, array('id' => 1, 'id2' => 1))); + var_dump(pg_insert($conn, $table, array('id' => 1, 'id2' => 1))); } ?> Done diff --git a/ext/pgsql/tests/pg_update_001.phpt b/ext/pgsql/tests/pg_update_001.phpt index 85a86f3d231b..7ef66c26525a 100644 --- a/ext/pgsql/tests/pg_update_001.phpt +++ b/ext/pgsql/tests/pg_update_001.phpt @@ -26,7 +26,7 @@ var_dump(pg_update($conn, 'phptests.foo', array('id' => 100), array('id2' => 2), $rs = pg_query('SELECT * FROM foo UNION SELECT * FROM phptests.foo ORDER BY id'); while ($row = pg_fetch_assoc($rs)) { - var_dump($row); + var_dump($row); } pg_query('DROP TABLE foo'); diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc index e24847445c47..38c2888afa5f 100644 --- a/ext/pgsql/tests/skipif.inc +++ b/ext/pgsql/tests/skipif.inc @@ -19,27 +19,27 @@ if (!is_resource($conn)) { function skip_server_version($version, $op = '<') { - $pg = pg_parameter_status('server_version'); - if (version_compare($pg, $version, $op)) { - die("skip Server version {$pg} is {$op} {$version}\n"); - } - return $pg; + $pg = pg_parameter_status('server_version'); + if (version_compare($pg, $version, $op)) { + die("skip Server version {$pg} is {$op} {$version}\n"); + } + return $pg; } function skip_bytea_not_hex() { - $out = pg_escape_bytea("\xFF"); - if (strpos($out, '377') !== false) { - die("skip libpq or backend < 9.0\n"); - } + $out = pg_escape_bytea("\xFF"); + if (strpos($out, '377') !== false) { + die("skip libpq or backend < 9.0\n"); + } } function skip_bytea_not_escape() { - $out = pg_escape_bytea("\xFF"); - if (strpos($out, '377') === false) { - die("skip libpq or backend >= 9.0\n"); - } + $out = pg_escape_bytea("\xFF"); + if (strpos($out, '377') === false) { + die("skip libpq or backend >= 9.0\n"); + } } ?> diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc index 79bf5c8855c5..7527e1c4d9e7 100644 --- a/ext/phar/phar/clicommand.inc +++ b/ext/phar/phar/clicommand.inc @@ -16,336 +16,336 @@ */ abstract class CLICommand { - protected $argc; - protected $argv; - protected $cmds = array(); - protected $args = array(); - protected $typs = array(); - - function __construct($argc, array $argv) - { - $this->argc = $argc; - $this->argv = $argv; - $this->cmds = self::getCommands($this); - $this->typs = self::getArgTyps($this); - - if ($argc < 2) { - self::error("No command given, check ${argv[0]} help\n"); - } elseif (!isset($this->cmds[$argv[1]]['run'])) { - self::error("Unknown command '${argv[1]}', check ${argv[0]} help\n"); - } else { - $command = $argv[1]; - } - - if (isset($this->cmds[$command]['arg'])) { - $this->args = call_user_func(array($this, $this->cmds[$command]['arg'])); - $i = 1; - $missing = false; - while (++$i < $argc) { - if ($argv[$i][0] == '-') { - if (strlen($argv[$i]) == 2 && isset($this->args[$argv[$i][1]])) { - $arg = $argv[$i][1]; - if (++$i >= $argc) { - self::error("Missing argument to parameter '$arg' of command '$command', check ${argv[0]} help\n"); - } else { - $this->args[$arg]['val'] = $this->checkArgTyp($arg, $i, $argc, $argv); - } - } else { - self::error("Unknown parameter '${argv[$i]}' to command $command, check ${argv[0]} help\n"); - } - } else { - break; - } - } - - if (isset($this->args[''])) { - if ($i >= $argc) { - if (isset($this->args['']['require']) && $this->args['']['require']) { - self::error("Missing default trailing arguments to command $command, check ${argv[0]} help\n"); - } - } else { - $this->args['']['val'] = array(); - while($i < $argc) { - $this->args['']['val'][] = $argv[$i++]; - } - } - } else if ($i < $argc) { - self::error("Unexpected default arguments to command $command, check ${argv[0]} help\n"); - } - - foreach($this->args as $arg => $inf) { - if (strlen($arg) && !isset($inf['val']) && isset($inf['required']) && $inf['required']) { - $missing .= "Missing parameter '-$arg' to command $command, check ${argv[0]} help\n"; - } - } - - if (strlen($missing)) { - self::error($missing); - } - } - - call_user_func(array($this, $this->cmds[$command]['run']), $this->args); - } - - static function notice ($msg) - { - fprintf(STDERR, $msg); - } - - static function error ($msg, $exit_code = 1) - { - self::notice($msg); - exit($exit_code); - } - - function checkArgTyp($arg, $i, $argc, $argv) - { - $typ = $this->args[$arg]['typ']; - - if (isset($this->typs[$typ]['typ'])) { - return call_user_func(array($this, $this->typs[$typ]['typ']), $argv[$i], $this->args[$arg], $arg); - } else { - return $argv[$i]; - } - } - - static function getSubFuncs(CLICommand $cmdclass, $prefix, array $subs) - { - $a = array(); - $r = new ReflectionClass($cmdclass); - $l = strlen($prefix); - - foreach($r->getMethods() as $m) { - if (substr($m->name, 0, $l) == $prefix) { - foreach($subs as $sub) { - $what = substr($m->name, $l+strlen($sub)+1); - $func = $prefix . $sub . '_' . $what; - $what = str_replace('_', '-', $what); - if ($r->hasMethod($func)) { - if (!isset($a[$what])) { - $a[$what] = array(); - } - $a[$what][$sub] = /*$m->class . '::' .*/ $func; - } - } - } - } - return $a; - } - - static function getCommands(CLICommand $cmdclass) - { - return self::getSubFuncs($cmdclass, 'cli_cmd_', array('arg','inf','run')); - } - - static function getArgTyps(CLICommand $cmdclass) - { - return self::getSubFuncs($cmdclass, 'cli_arg_', array('typ')); - } - - static function cli_arg_typ_bool($arg, $cfg, $key) - { - return (bool)$arg; - } - - static function cli_arg_typ_int($arg, $cfg, $key) - { - if ((int)$arg != $arg) { - self::error("Argument to -$key must be an integer.\n"); - } - - return (int)$arg; - } - - static function cli_arg_typ_regex($arg, $cfg, $key) - { - if (strlen($arg)) { - if (strlen($arg) > 1 && $arg[0] == $arg[strlen($arg)-1] && strpos('/,', $arg) !== false) { - return $arg; - } else { - return '/' . $arg . '/'; - } - } else { - return NULL; - } - } - - static function cli_arg_typ_select($arg, $cfg, $key) - { - if (!in_array($arg, array_keys($cfg['select']))) { - self::error("Parameter value '$arg' not one of '" . join("', '", array_keys($cfg['select'])) . "'.\n"); - } - return $arg; - } - - static function cli_arg_typ_dir($arg, $cfg, $key) - { - $f = realpath($arg); - - if ($f===false || !file_exists($f) || !is_dir($f)) { - self::error("Requested path '$arg' does not exist.\n"); - } - return $f; - } - - static function cli_arg_typ_file($arg) - { - $f = new SplFileInfo($arg); - $f = $f->getRealPath(); - if ($f===false || !file_exists($f)) { - echo "Requested file '$arg' does not exist.\n"; - exit(1); - } - return $f; - } - - static function cli_arg_typ_filenew($arg, $cfg, $key) - { - $d = dirname($arg); - $f = realpath($d); - - if ($f === false) { - self::error("Path for file '$arg' does not exist.\n"); - } - return $f . '/' . basename($arg); - } - - static function cli_arg_typ_filecont($arg, $cfg, $key) - { - return file_get_contents(self::cli_arg_typ_file($arg, $cfg, $key)); - } - - function cli_get_SP2($l1, $arg_inf) - { - return str_repeat(' ', $l1 + 2 + 4 + 8); - } - - function cli_get_SP3($l1, $l2, $arg_inf) - { - return str_repeat(' ', $l1 + 2 + 4 + 8 + 2 + $l2 + 2); - } - - static function cli_cmd_inf_help() - { - return "This help or help for a selected command."; - } - - private function cli_wordwrap($what, $l, $sp) - { - $p = max(79 - $l, 40); // minimum length for paragraph - $b = substr($what, 0, $l); // strip out initial $l - $r = substr($what, $l); // remainder - $r = str_replace("\n", "\n".$sp, $r); // in remainder replace \n's - return $b . wordwrap($r, $p, "\n".$sp); - } - - private function cli_help_get_args($func, $l, $sp, $required) - { - $inf = ""; - foreach(call_user_func($func, $l, $sp) as $arg => $conf) { - if ((isset($conf['required']) && $conf['required']) != $required) { - continue; - } - - if (strlen($arg)) { - $arg = "-$arg "; - } else { - $arg = "... "; - } - - $sp2 = $this->cli_get_SP2($l, $inf); - $l2 = strlen($sp2); - $inf .= $this->cli_wordwrap($sp . $arg . $conf['inf'], $l2, $sp2) . "\n"; - - if (isset($conf['select']) && count($conf['select'])) { - $ls = 0; - foreach($conf['select'] as $opt => $what) { - $ls = max($ls, strlen($opt)); - } - $sp3 = $this->cli_get_SP3($l, $ls, $inf); - $l3 = strlen($sp3); - foreach($conf['select'] as $opt => $what) { - $inf .= $this->cli_wordwrap($sp2 . " " . sprintf("%-${ls}s ", $opt) . $what, $l3, $sp3) . "\n"; - } - } - } - if (strlen($inf)) { - if ($required) { - return $sp . "Required arguments:\n\n" . $inf; - } else { - return $sp . "Optional arguments:\n\n". $inf; - } - } - } - - function cli_cmd_arg_help() - { - return array('' => array('typ'=>'any','val'=>NULL,'inf'=>'Optional command to retrieve help for.')); - } - - function cli_cmd_run_help() - { - $argv = $this->argv; - $which = $this->args['']['val']; - if (isset($which)) { - if (count($which) != 1) { - self::error("More than one command given.\n"); - } - - $which = $which[0]; - if (!array_key_exists($which, $this->cmds)) { - if (strtolower($which) == 'commands') { - self::cli_cmd_run_help_list(); - exit(0); - } - self::error("Unknown command, cannot retrieve help.\n"); - } - - $l = strlen($which); - $cmds = array($which => $this->cmds[$which]); - } else { - echo "\n$argv[0] [options]\n\n"; - $l = 0; - ksort($this->cmds); - foreach($this->cmds as $name => $funcs) { - $l = max($l, strlen($name)); - } - $inf = "Commands:"; - $lst = ""; - $ind = strlen($inf) + 1; - foreach($this->cmds as $name => $funcs) { - $lst .= ' ' . $name; - } - echo $this->cli_wordwrap($inf.$lst, $ind, str_repeat(' ', $ind)) . "\n\n"; - $cmds = $this->cmds; - } - $sp = str_repeat(' ', $l + 2); - foreach($cmds as $name => $funcs) { - $inf = $name . substr($sp, strlen($name)); - if (isset($funcs['inf'])) { - $inf .= $this->cli_wordwrap(call_user_func(array($this, $funcs['inf'])), $l, $sp) . "\n"; - if (isset($funcs['arg'])) { - $inf .= "\n"; - $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, true); - $inf .= "\n"; - $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, false); - } - } - echo "$inf\n\n"; - } - exit(0); - } - - static function cli_cmd_inf_help_list() - { - return "Lists available commands."; - } - - function cli_cmd_run_help_list() - { - ksort($this->cmds); - echo join(' ', array_keys($this->cmds)) . "\n"; - } + protected $argc; + protected $argv; + protected $cmds = array(); + protected $args = array(); + protected $typs = array(); + + function __construct($argc, array $argv) + { + $this->argc = $argc; + $this->argv = $argv; + $this->cmds = self::getCommands($this); + $this->typs = self::getArgTyps($this); + + if ($argc < 2) { + self::error("No command given, check ${argv[0]} help\n"); + } elseif (!isset($this->cmds[$argv[1]]['run'])) { + self::error("Unknown command '${argv[1]}', check ${argv[0]} help\n"); + } else { + $command = $argv[1]; + } + + if (isset($this->cmds[$command]['arg'])) { + $this->args = call_user_func(array($this, $this->cmds[$command]['arg'])); + $i = 1; + $missing = false; + while (++$i < $argc) { + if ($argv[$i][0] == '-') { + if (strlen($argv[$i]) == 2 && isset($this->args[$argv[$i][1]])) { + $arg = $argv[$i][1]; + if (++$i >= $argc) { + self::error("Missing argument to parameter '$arg' of command '$command', check ${argv[0]} help\n"); + } else { + $this->args[$arg]['val'] = $this->checkArgTyp($arg, $i, $argc, $argv); + } + } else { + self::error("Unknown parameter '${argv[$i]}' to command $command, check ${argv[0]} help\n"); + } + } else { + break; + } + } + + if (isset($this->args[''])) { + if ($i >= $argc) { + if (isset($this->args['']['require']) && $this->args['']['require']) { + self::error("Missing default trailing arguments to command $command, check ${argv[0]} help\n"); + } + } else { + $this->args['']['val'] = array(); + while($i < $argc) { + $this->args['']['val'][] = $argv[$i++]; + } + } + } else if ($i < $argc) { + self::error("Unexpected default arguments to command $command, check ${argv[0]} help\n"); + } + + foreach($this->args as $arg => $inf) { + if (strlen($arg) && !isset($inf['val']) && isset($inf['required']) && $inf['required']) { + $missing .= "Missing parameter '-$arg' to command $command, check ${argv[0]} help\n"; + } + } + + if (strlen($missing)) { + self::error($missing); + } + } + + call_user_func(array($this, $this->cmds[$command]['run']), $this->args); + } + + static function notice ($msg) + { + fprintf(STDERR, $msg); + } + + static function error ($msg, $exit_code = 1) + { + self::notice($msg); + exit($exit_code); + } + + function checkArgTyp($arg, $i, $argc, $argv) + { + $typ = $this->args[$arg]['typ']; + + if (isset($this->typs[$typ]['typ'])) { + return call_user_func(array($this, $this->typs[$typ]['typ']), $argv[$i], $this->args[$arg], $arg); + } else { + return $argv[$i]; + } + } + + static function getSubFuncs(CLICommand $cmdclass, $prefix, array $subs) + { + $a = array(); + $r = new ReflectionClass($cmdclass); + $l = strlen($prefix); + + foreach($r->getMethods() as $m) { + if (substr($m->name, 0, $l) == $prefix) { + foreach($subs as $sub) { + $what = substr($m->name, $l+strlen($sub)+1); + $func = $prefix . $sub . '_' . $what; + $what = str_replace('_', '-', $what); + if ($r->hasMethod($func)) { + if (!isset($a[$what])) { + $a[$what] = array(); + } + $a[$what][$sub] = /*$m->class . '::' .*/ $func; + } + } + } + } + return $a; + } + + static function getCommands(CLICommand $cmdclass) + { + return self::getSubFuncs($cmdclass, 'cli_cmd_', array('arg','inf','run')); + } + + static function getArgTyps(CLICommand $cmdclass) + { + return self::getSubFuncs($cmdclass, 'cli_arg_', array('typ')); + } + + static function cli_arg_typ_bool($arg, $cfg, $key) + { + return (bool)$arg; + } + + static function cli_arg_typ_int($arg, $cfg, $key) + { + if ((int)$arg != $arg) { + self::error("Argument to -$key must be an integer.\n"); + } + + return (int)$arg; + } + + static function cli_arg_typ_regex($arg, $cfg, $key) + { + if (strlen($arg)) { + if (strlen($arg) > 1 && $arg[0] == $arg[strlen($arg)-1] && strpos('/,', $arg) !== false) { + return $arg; + } else { + return '/' . $arg . '/'; + } + } else { + return NULL; + } + } + + static function cli_arg_typ_select($arg, $cfg, $key) + { + if (!in_array($arg, array_keys($cfg['select']))) { + self::error("Parameter value '$arg' not one of '" . join("', '", array_keys($cfg['select'])) . "'.\n"); + } + return $arg; + } + + static function cli_arg_typ_dir($arg, $cfg, $key) + { + $f = realpath($arg); + + if ($f===false || !file_exists($f) || !is_dir($f)) { + self::error("Requested path '$arg' does not exist.\n"); + } + return $f; + } + + static function cli_arg_typ_file($arg) + { + $f = new SplFileInfo($arg); + $f = $f->getRealPath(); + if ($f===false || !file_exists($f)) { + echo "Requested file '$arg' does not exist.\n"; + exit(1); + } + return $f; + } + + static function cli_arg_typ_filenew($arg, $cfg, $key) + { + $d = dirname($arg); + $f = realpath($d); + + if ($f === false) { + self::error("Path for file '$arg' does not exist.\n"); + } + return $f . '/' . basename($arg); + } + + static function cli_arg_typ_filecont($arg, $cfg, $key) + { + return file_get_contents(self::cli_arg_typ_file($arg, $cfg, $key)); + } + + function cli_get_SP2($l1, $arg_inf) + { + return str_repeat(' ', $l1 + 2 + 4 + 8); + } + + function cli_get_SP3($l1, $l2, $arg_inf) + { + return str_repeat(' ', $l1 + 2 + 4 + 8 + 2 + $l2 + 2); + } + + static function cli_cmd_inf_help() + { + return "This help or help for a selected command."; + } + + private function cli_wordwrap($what, $l, $sp) + { + $p = max(79 - $l, 40); // minimum length for paragraph + $b = substr($what, 0, $l); // strip out initial $l + $r = substr($what, $l); // remainder + $r = str_replace("\n", "\n".$sp, $r); // in remainder replace \n's + return $b . wordwrap($r, $p, "\n".$sp); + } + + private function cli_help_get_args($func, $l, $sp, $required) + { + $inf = ""; + foreach(call_user_func($func, $l, $sp) as $arg => $conf) { + if ((isset($conf['required']) && $conf['required']) != $required) { + continue; + } + + if (strlen($arg)) { + $arg = "-$arg "; + } else { + $arg = "... "; + } + + $sp2 = $this->cli_get_SP2($l, $inf); + $l2 = strlen($sp2); + $inf .= $this->cli_wordwrap($sp . $arg . $conf['inf'], $l2, $sp2) . "\n"; + + if (isset($conf['select']) && count($conf['select'])) { + $ls = 0; + foreach($conf['select'] as $opt => $what) { + $ls = max($ls, strlen($opt)); + } + $sp3 = $this->cli_get_SP3($l, $ls, $inf); + $l3 = strlen($sp3); + foreach($conf['select'] as $opt => $what) { + $inf .= $this->cli_wordwrap($sp2 . " " . sprintf("%-${ls}s ", $opt) . $what, $l3, $sp3) . "\n"; + } + } + } + if (strlen($inf)) { + if ($required) { + return $sp . "Required arguments:\n\n" . $inf; + } else { + return $sp . "Optional arguments:\n\n". $inf; + } + } + } + + function cli_cmd_arg_help() + { + return array('' => array('typ'=>'any','val'=>NULL,'inf'=>'Optional command to retrieve help for.')); + } + + function cli_cmd_run_help() + { + $argv = $this->argv; + $which = $this->args['']['val']; + if (isset($which)) { + if (count($which) != 1) { + self::error("More than one command given.\n"); + } + + $which = $which[0]; + if (!array_key_exists($which, $this->cmds)) { + if (strtolower($which) == 'commands') { + self::cli_cmd_run_help_list(); + exit(0); + } + self::error("Unknown command, cannot retrieve help.\n"); + } + + $l = strlen($which); + $cmds = array($which => $this->cmds[$which]); + } else { + echo "\n$argv[0] [options]\n\n"; + $l = 0; + ksort($this->cmds); + foreach($this->cmds as $name => $funcs) { + $l = max($l, strlen($name)); + } + $inf = "Commands:"; + $lst = ""; + $ind = strlen($inf) + 1; + foreach($this->cmds as $name => $funcs) { + $lst .= ' ' . $name; + } + echo $this->cli_wordwrap($inf.$lst, $ind, str_repeat(' ', $ind)) . "\n\n"; + $cmds = $this->cmds; + } + $sp = str_repeat(' ', $l + 2); + foreach($cmds as $name => $funcs) { + $inf = $name . substr($sp, strlen($name)); + if (isset($funcs['inf'])) { + $inf .= $this->cli_wordwrap(call_user_func(array($this, $funcs['inf'])), $l, $sp) . "\n"; + if (isset($funcs['arg'])) { + $inf .= "\n"; + $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, true); + $inf .= "\n"; + $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, false); + } + } + echo "$inf\n\n"; + } + exit(0); + } + + static function cli_cmd_inf_help_list() + { + return "Lists available commands."; + } + + function cli_cmd_run_help_list() + { + ksort($this->cmds); + echo join(' ', array_keys($this->cmds)) . "\n"; + } } ?> diff --git a/ext/phar/phar/directorygraphiterator.inc b/ext/phar/phar/directorygraphiterator.inc index 34579678a778..e31f3e4e67c2 100644 --- a/ext/phar/phar/directorygraphiterator.inc +++ b/ext/phar/phar/directorygraphiterator.inc @@ -16,19 +16,19 @@ */ class DirectoryGraphIterator extends DirectoryTreeIterator { - function __construct($path) - { - RecursiveIteratorIterator::__construct( - new RecursiveCachingIterator( - new ParentIterator( - new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME - ) - ), - CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD - ), - parent::SELF_FIRST - ); - } + function __construct($path) + { + RecursiveIteratorIterator::__construct( + new RecursiveCachingIterator( + new ParentIterator( + new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME + ) + ), + CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD + ), + parent::SELF_FIRST + ); + } } ?> diff --git a/ext/phar/phar/directorytreeiterator.inc b/ext/phar/phar/directorytreeiterator.inc index 2c681632fb74..de6acea13d66 100644 --- a/ext/phar/phar/directorytreeiterator.inc +++ b/ext/phar/phar/directorytreeiterator.inc @@ -16,39 +16,39 @@ */ class DirectoryTreeIterator extends RecursiveIteratorIterator { - /** Construct from a path. - * @param $path directory to iterate - */ - function __construct($path) - { - parent::__construct( - new RecursiveCachingIterator( - new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME - ), - CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD - ), - parent::SELF_FIRST - ); - } + /** Construct from a path. + * @param $path directory to iterate + */ + function __construct($path) + { + parent::__construct( + new RecursiveCachingIterator( + new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME + ), + CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD + ), + parent::SELF_FIRST + ); + } - /** @return the current element prefixed with ASCII graphics - */ - function current() - { - $tree = ''; - for ($l=0; $l < $this->getDepth(); $l++) { - $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' '; - } - return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-') - . $this->getSubIterator($l)->__toString(); - } + /** @return the current element prefixed with ASCII graphics + */ + function current() + { + $tree = ''; + for ($l=0; $l < $this->getDepth(); $l++) { + $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' '; + } + return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-') + . $this->getSubIterator($l)->__toString(); + } - /** Aggregates the inner iterator - */ - function __call($func, $params) - { - return call_user_func_array(array($this->getSubIterator(), $func), $params); - } + /** Aggregates the inner iterator + */ + function __call($func, $params) + { + return call_user_func_array(array($this->getSubIterator(), $func), $params); + } } ?> diff --git a/ext/phar/phar/invertedregexiterator.inc b/ext/phar/phar/invertedregexiterator.inc index 8f82f41f2aac..ff7024e4ece2 100644 --- a/ext/phar/phar/invertedregexiterator.inc +++ b/ext/phar/phar/invertedregexiterator.inc @@ -16,12 +16,12 @@ */ class InvertedRegexIterator extends RegexIterator { - /** @return !RegexIterator::accept() - */ - function accept() - { - return !RegexIterator::accept(); - } + /** @return !RegexIterator::accept() + */ + function accept() + { + return !RegexIterator::accept(); + } } ?> diff --git a/ext/phar/phar/phar.inc b/ext/phar/phar/phar.inc index 129a0c43bf8a..9ca25e7f6f18 100644 --- a/ext/phar/phar/phar.inc +++ b/ext/phar/phar/phar.inc @@ -20,61 +20,61 @@ */ class Phar extends PHP_Archive implements RecursiveIterator { - function getSignature() - { - return false; - } + function getSignature() + { + return false; + } - function getAlias() - { - return false; - } + function getAlias() + { + return false; + } - function rewind() - { - } + function rewind() + { + } - function valid() - { - return false; - } + function valid() + { + return false; + } - function current() - { - } + function current() + { + } - function key() - { - } + function key() + { + } - function next() - { - } + function next() + { + } - function hasChildren() - { - return false; - } + function hasChildren() + { + return false; + } - function getChildren() - { - } + function getChildren() + { + } - function hasMetadata() - { - } + function hasMetadata() + { + } - function getMetadata() - { - } + function getMetadata() + { + } - function getStub() - { - } + function getStub() + { + } - function setStub() - { - } + function setStub() + { + } } ?> diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index 341e5f3465f7..1fb41dbb6a75 100644 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -24,1572 +24,1572 @@ */ class PharCommand extends CLICommand { - // {{{ public function cli_get_SP2 - public function cli_get_SP2($l1, $arg_inf) - { - return str_repeat(' ', $l1 + 2 + 4 + 9); - } - // }}} - // {{{ public function cli_get_SP3 - /** - * Cli Get SP3 - * - * @param string $l1 Eleven - * @param string $l2 Twelve - * @param string $arg_inf - * @return string The repeated string. - */ - function cli_get_SP3($l1, $l2, $arg_inf) - { - return str_repeat(' ', $l1 + 2 + 4 + 9 + 2 + $l2 + 2); - } - // }}} - // {{{ static function phar_args - /** - * Phar arguments - * - * This function contains all the phar commands - * - * @param string $which Which argument is chosen. - * @param string $phartype The type of phar, specific file to work on - * @return unknown - */ - static function phar_args($which, $phartype) - { - $phar_args = array( - 'a' => array( - 'typ' => 'alias', - 'val' => NULL, - 'inf' => ' Provide an alias name for the phar file.' - ), - 'b' => array( - 'typ' => 'any', - 'val' => NULL, - 'inf' => ' Hash-bang line to start the archive (e.g. #!/usr/bin/php). The hash ' - .' mark itself \'#!\' and the newline character are optional.' - ), - 'c' => array( - 'typ' => 'compalg', - 'val' => NULL, - 'inf' => ' Compression algorithm.', - 'select' => array( - '0' => 'No compression', - 'none' => 'No compression', - 'auto' => 'Automatically select compression algorithm' - ) - ), - 'e' => array( - 'typ' => 'entry', - 'val' => NULL, - 'inf' => ' Name of entry to work on (must include PHAR internal directory name if any).' - ), - 'f' => array( - 'typ' => $phartype, - 'val' => NULL, - 'inf' => ' Specifies the phar file to work on.' - ), - 'h' => array( - 'typ' => 'select', - 'val' => NULL, - 'inf' => ' Selects the hash algorithm.', - 'select' => array('md5' => 'MD5','sha1' => 'SHA1') - ), - 'i' => array( - 'typ' => 'regex', - 'val' => NULL, - 'inf' => ' Specifies a regular expression for input files.' - ), - 'k' => array( - 'typ' => 'any', - 'val' => NULL, - 'inf' => ' Subscription index to work on.', - ), - 'l' => array( - 'typ' => 'int', - 'val' => 0, - 'inf' => ' Number of preceding subdirectories to strip from file entries', - ), - 'm' => array( - 'typ' => 'any', - 'val' => NULL, - 'inf' => ' Meta data to store with entry (serialized php data).' - ), - 'p' => array( - 'typ' => 'loader', - 'val' => NULL, - 'inf' => ' Location of PHP_Archive class file (pear list-files PHP_Archive).' - .'You can use \'0\' or \'1\' to locate it automatically using the mentioned ' - .'pear command. When using \'0\' the command does not error out when the ' - .'class file cannot be located. This switch also adds some code around the ' - .'stub so that class PHP_Archive gets registered as phar:// stream wrapper ' - .'if necessary. And finally this switch will add the file phar.inc from ' - .'this package and load it to ensure class Phar is present.' - , - ), - 's' => array( - 'typ' => 'file', - 'val' => NULL, - 'inf' => ' Select the stub file.' - ), - 'x' => array( - 'typ' => 'regex', - 'val' => NULL, - 'inf' => ' Regular expression for input files to exclude.' - ), - 'y' => array( - 'typ' => 'privkey', - 'val' => NULL, - 'inf' => ' Private key for OpenSSL signing.', - ), - ); - - if (extension_loaded('zlib')) { - $phar_args['c']['select']['gz'] = 'GZip compression'; - $phar_args['c']['select']['gzip'] = 'GZip compression'; - } - - if (extension_loaded('bz2')) { - $phar_args['c']['select']['bz2'] = 'BZip2 compression'; - $phar_args['c']['select']['bzip2'] = 'BZip2 compression'; - } - - $hash_avail = Phar::getSupportedSignatures(); - $hash_optional = array('SHA-256' => 'SHA256', - 'SHA-512' => 'SHA512', - 'OpenSSL' => 'OpenSSL'); - if (!in_array('OpenSSL', $hash_avail)) { - unset($phar_args['y']); - } - - foreach($hash_optional as $key => $name) { - if (in_array($key, $hash_avail)) { - $phar_args['h']['select'][strtolower($name)] = $name; - } - } - - $args = array(); - - foreach($phar_args as $lkey => $cfg) { - $ukey = strtoupper($lkey); - $required = strpos($which, $ukey) !== false; - $optional = strpos($which, $lkey) !== false; - - if ($required || $optional) { - $args[$lkey] = $cfg; - $args[$lkey]['required'] = $required; - } - } - return $args; - } - // }}} - // {{{ static function strEndsWith - /** - * String Ends With - * - * Whether a string ends with another needle. - * - * @param string $haystack The haystack - * @param string $needle The needle. - * @return mixed false if doesn't end with anything, the string - * substr'ed if the string ends with the needle. - */ - static function strEndsWith($haystack, $needle) - { - return substr($haystack, -strlen($needle)) == $needle; - } - // }}} - // {{{ static function cli_arg_typ_loader - /** - * Argument type loader - * - * @param string $arg Either 'auto', 'optional' or an filename that - * contains class PHP_Archive - * @param string $cfg Configuration to pass to a new file - * @param string $key The key - * @return string $arg The argument. - */ - static function cli_arg_typ_loader($arg, $cfg, $key) - { - if (($arg == '0' || $arg == '1') && !file_exists($arg) && substr(PHP_OS, 0, 3) != 'WIN') { - $found = NULL; - $apiver = false; - $path = explode(PATH_SEPARATOR, $_ENV['PATH']); - $pear = false; - foreach ($path as $component) { - if (file_exists($component . DIRECTORY_SEPARATOR . 'pear') - && is_executable($component . DIRECTORY_SEPARATOR . 'pear')) { - $pear = true; - break; - } - } - if ($pear) { - $apiver = `pear -q info PHP_Archive 2>/dev/null|grep 'API Version'`; - $apiver = trim(substr($apiver, strlen('API Version'))); - } - if ($apiver) { - self::notice("PEAR package PHP_Archive: API Version: $apiver.\n"); - $files = explode("\n", `pear list-files PHP_Archive`); - $phpdir = `pear config-get php_dir 2>/dev/null`; - $phpdir = trim($phpdir); - self::notice("PEAR package PHP_Archive: $phpdir.\n"); - if (is_dir($phpdir)) { - foreach($files as $ent) { - $matches = NULL; - if (preg_match(",^php[ \t]+([^ \t].*[\\\\/]PHP[\\\\/]Archive\.php)$,", $ent, $matches)) { - $sub = $matches[1]; - if (strpos($sub, $phpdir) !== 0) { - $found = NULL; - break; - } - $found = $sub; - break; - } - } - } else { - self::notice("PEAR package PHP_Archive: corrupt or inaccessible base dir: $php_dir.\n"); - } - } - if (isset($found)) { - self::notice("PEAR package PHP_Archive: $found.\n"); - } else { - $msg = "PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.\n"; - if ($arg == '0') { - self::notice($msg); - } else { - self::error($msg); - } - } - $arg = $found; - } - return self::cli_arg_typ_file($arg); - } - // }}} - // {{{ static function cli_arg_typ_pharnew - /** - * Argument type new phar - * - * @param string $arg The new phar component. - * @param string $cfg Configuration to pass to a new file - * @param string $key The key - * @return string $arg The new argument file. - */ - static function cli_arg_typ_pharnew($arg, $cfg, $key) - { - $arg = self::cli_arg_typ_filenew($arg, $cfg, $key); - if (!Phar::isValidPharFilename($arg)) { - self::error("Phar files must have file extension '.phar', '.phar.php', '.phar.bz2' or '.phar.gz'.\n"); - } - return $arg; - } - // }}} - // {{{ static function cli_arg_typ_pharfile - /** - * Argument type existing Phar file - * - * Return filename of an existing Phar. - * - * @param string $arg The file in the phar to open. - * @param string $cfg The configuration information - * @param string $key The key information. - * @return string $pharfile The name of the loaded Phar file. - * @note The Phar will be loaded - */ - static function cli_arg_typ_pharfile($arg, $cfg, $key) - { - try { - $pharfile = self::cli_arg_typ_file($arg, $cfg, $key); - - if (!Phar::loadPhar($pharfile)) { - self::error("Unable to open phar '$arg'\n"); - } - - return $pharfile; - } catch(Exception $e) { - self::error("Exception while opening phar '$arg':\n" . $e->getMessage() . "\n"); - } - } - // }}} - // {{{ static function cli_arg_typ_pharurl - /** - * Argument type Phar url-like - * - * Check the argument as cli_arg_Typ_phar and return its name prefixed - * with phar:// - * - * Ex: - * - * $arg = 'pharchive.phar/file.php'; - * cli_arg_typ_pharurl($arg) - * - * - * @param string $arg The url-like phar archive to retrieve. - * @return string The phar file-archive. - */ - static function cli_arg_typ_pharurl($arg, $cfg, $key) - { - return 'phar://' . self::cli_arg_typ_pharfile($arg, $cfg, $key); - } - // }}} - // {{{ static function cli_arg_typ_phar - /** - * Cli argument type phar - * - * @param string $arg The phar archive to use. - * @return object new Phar of the passed argument. - */ - static function cli_arg_typ_phar($arg, $cfg, $key) - { - try { - return new Phar(self::cli_arg_typ_pharfile($arg, $cfg, $key)); - } catch(Exception $e) { - self::error("Exception while opening phar '$argv':\n" . $e->getMessage() . "\n"); - } - } - // }}} - // {{{ static function cli_arg_typ_entry - /** - * Argument type Entry name - * - * @param string $arg The argument (the entry) - * @return string $arg The entry itself. - */ - static function cli_arg_typ_entry($arg, $cfg, $key) - { - // no further check atm, maybe check for no '/' at beginning - return $arg; - } - // }}} - // {{{ static function cli_arg_typ_compalg - /** - * Argument type compression algorithm - * - * @param string $arg The phar selection - * @param string $cfg The config option. - * @param string $key The key information. - * @return string $arg The selected algorithm - */ - static function cli_arg_typ_compalg($arg, $cfg, $key) - { - $arg = self::cli_arg_typ_select($arg, $cfg, $key); - - switch($arg) { - case 'auto': - if (extension_loaded('zlib')) { - $arg = 'gz'; - } elseif (extension_loaded('bz2')) { - $arg = 'bz2'; - } else { - $arg = '0'; - } - break; - } - return $arg; - } - // }}} - // {{{ static function cli_arg_typ_privkey - /** - * Argument type private key (for OpenSSL signing) - * - * @param string $arg The phar selection - * @param string $cfg The config option. - * @param string $key The key information. - * @return string $arg The private key. - */ - static function cli_arg_typ_privkey($arg, $cfg, $key) - { - $arg = self::cli_arg_typ_filecont($arg, $cfg, $key); - - $hash_avail = Phar::getSupportedSignatures(); - if ($arg && !in_array('OpenSSL', $hash_avail)) - { - self::error("Cannot specify private key without OpenSSL support.\n"); - } - return $arg; - } - // }}} - // {{{ static function phar_check_hash - /** - * Check whether hash method is valid. - * - * @return Hash constant to be used. - */ - function phar_check_hash($hash, $privkey) - { - switch($hash) { - case 'md5': - return Phar::MD5; - case 'sha1': - return Phar::SHA1; - case 'sha256': - return Phar::SHA256; - case 'sha512': - return Phar::SHA512; - case 'openssl': - if (!$privkey) { - self::error("Cannot use OpenSSL signing without key.\n"); - } - return Phar::OPENSSL; - } - } - // }}} - // {{{ static function cli_cmd_inf_pack - /** - * Information pack - * - * @return string A description about packing files into a Phar archive. - */ - static function cli_cmd_inf_pack() - { - return "Pack files into a PHAR archive.\n" . - "When using -s , then the stub file is being " . - "excluded from the list of input files/dirs." . - "To create an archive that contains PEAR class PHP_Archive " . - "then point -p argument to PHP/Archive.php.\n"; - } - // }}} - // {{{ static function cli_cmd_arg_pack - /** - * Pack a new phar infos - * - * @return array $args The arguments for a new Phar archive. - */ - static function cli_cmd_arg_pack() - { - $args = self::phar_args('abcFhilpsxy', 'pharnew'); - - $args[''] = array( - 'typ' => 'any', - 'val' => NULL, - 'required' => 1, - 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', - ); - - return $args; - } - // }}} - // {{{ function phar_set_stub_begin - /** - * Set the stub - */ - public function phar_set_stub_begin(Phar $phar, $stub, $loader = NULL, $hashbang = NULL) - { - if (isset($stub)) { - $c = file_get_contents($stub); - - if (substr($c, 0, 2) == '#!') { - if (strpos($c, "\n") !== false) { - if (!isset($hashbang)) { - $hashbang = substr($c, 0, strpos($c, "\n") + 1); - } - $c = substr($c, strpos($c, "\n") + 1); - } else { - if (!isset($hashbang)) { - $hashbang = $c; - } - $c = NULL; - } - } - - if (isset($hashbang)) { - if (substr($hashbang, 0, 2) != '#!') { - $hashbang = '#!' . $hashbang; - } - if (substr($hashbang, -1) != "\n") { - $hashbang .= "\n"; - } - } else { - $hashbang = ""; - } - - if (isset($loader)) { - $s = ""; - if (is_file($loader)) { - $s .= file_get_contents($loader); - } - $s .= "'; - $s .= $c; - - $phar->setStub($hashbang . $s); - } else { - $phar->setStub($hashbang . $c); - } - return new SplFileInfo($stub); - } - return NULL; - } - // }}} - // {{{ function phar_set_stub_end - /** - * Set stub end - */ - public function phar_set_stub_end(Phar $phar, $stub, $loader = NULL) - { - if (isset($stub) && isset($loader)) { - if (substr(__FILE__, -15) == 'pharcommand.inc') { - self::phar_add_file($phar, 0, 'phar.inc', 'phar://'.__FILE__.'/phar.inc', NULL); - } else { - self::phar_add_file($phar, 0, 'phar.inc', dirname(__FILE__).'/phar/phar.inc', NULL); - } - } - } - // }}} - // {{{ function cli_cmd_run_pack - /** - * Pack a new Phar - * - * This function will try to pack a new Phar archive. - * - * @see Exit to make sure that we are done. - */ - public function cli_cmd_run_pack() - { - if (ini_get('phar.readonly')) { - self::error("Creating phar files is disabled by ini setting 'phar.readonly'.\n"); - } - - if (!Phar::canWrite()) { - self::error("Creating phar files is disabled, Phar::canWrite() returned false.\n"); - } - - $alias = $this->args['a']['val']; - $hashbang = $this->args['b']['val']; - $archive = $this->args['f']['val']; - $hash = $this->args['h']['val']; - $privkey = $this->args['y']['val'] ?? null; - $regex = $this->args['i']['val']; - $level = $this->args['l']['val']; - $loader = $this->args['p']['val']; - $stub = $this->args['s']['val']; - $invregex = $this->args['x']['val']; - $input = $this->args['']['val']; - - $hash = self::phar_check_hash($hash, $privkey); - - $phar = new Phar($archive, 0, $alias); - - $phar->startBuffering(); - - $stub = $this->phar_set_stub_begin($phar, $stub, $loader, $hashbang); - - if (!is_array($input)) { - $this->phar_add($phar, $level, $input, $regex, $invregex, $stub, NULL, isset($loader)); - } else { - foreach($input as $i) { - $this->phar_add($phar, $level, $i, $regex, $invregex, $stub, NULL, isset($loader)); - } - } - - $this->phar_set_stub_end($phar, $stub, $loader); - - switch($this->args['c']['val']) { - case 'gz': - case 'gzip': - $phar->compressFiles(Phar::GZ); - break; - case 'bz2': - case 'bzip2': - $phar->compressFiles(Phar::BZ2); - break; - default: - $phar->decompressFiles(); - break; - } - - if ($hash) { - $phar->setSignatureAlgorithm($hash, $privkey); - } - - $phar->stopBuffering(); - exit(0); - } - // }}} - // {{{ static function phar_add - /** - * Add files to a phar archive. - * - * This function will take a directory and iterate through - * it and get the files to insert into the Phar archive. - * - * @param Phar $phar The phar object. - * @param string $input The input directory - * @param string $regex The regex used in RegexIterator. - * @param string $invregex The InvertedRegexIterator expression. - * @param SplFileInfo $stub Stub file object - * @param mixed $compress Compression algorithm or NULL - * @param boolean $noloader Whether to prevent adding the loader - */ - static function phar_add(Phar $phar, $level, $input, $regex, $invregex, SplFileInfo $stub = NULL, $compress = NULL, $noloader = false) - { - if ($input && is_file($input) && !is_dir($input)) { - return self::phar_add_file($phar, $level, $input, $input, $compress); - } - $dir = new RecursiveDirectoryIterator($input); - $dir = new RecursiveIteratorIterator($dir); - - if (isset($regex)) { - $dir = new RegexIterator($dir, $regex); - } - - if (isset($invregex)) { - $dir = new InvertedRegexIterator($dir, $invregex); - } - - try { - foreach($dir as $file) { - if ((empty($stub) || $file->getRealPath() != $stub->getRealPath()) && !is_dir($file)) { - self::phar_add_file($phar, $level, $dir->getSubPathName(), $file, $compress, $noloader); - } - } - } catch(Exception $e) { - self::error("Unable to complete operation on file '$file'\n" . $e->getMessage() . "\n"); - } - } - // }}} - // {{{ static function phar_add_file - /** - * Add a phar file - * - * This function adds a file to a phar archive. - * - * @param Phar $phar The phar object - * @param string $level The level of the file. - * @param string $entry The entry point - * @param string $file The file to add to the archive - * @param string $compress The compression scheme for the file. - * @param boolean $noloader Whether to prevent adding the loader - */ - static function phar_add_file(Phar $phar, $level, $entry, $file, $compress, $noloader = false) - { - $entry = str_replace('//', '/', $entry); - while($level-- > 0 && ($p = strpos($entry, '/')) !== false) { - $entry = substr($entry, $p+1); - } - - if ($noloader && $entry == 'phar.inc') { - return; - } - - echo "$entry\n"; - - $phar[$entry] = file_get_contents($file); - switch($compress) { - case 'gz': - case 'gzip': - $phar[$entry]->compress(Phar::GZ); - break; - case 'bz2': - case 'bzip2': - $phar[$entry]->compress(Phar::BZ2); - break; - case '0': - $phar[$entry]->decompress(); - break; - default: - break; - } - } - // }}} - // {{{ public function phar_dir_echo - /** - * Echo directory - * - * @param string $pn - * @param unknown_type $f - */ - public function phar_dir_echo($pn, $f) - { - echo "$f\n"; - } - // }}} - // {{{ public function phar_dir_operation - /** - * Directory operations - * - * Phar directory operations. - * - * @param RecursiveIteratorIterator $dir The recursiveIteratorIterator object. - * @param string $func Function to call on the iterations - * @param array $args Function arguments. - */ - public function phar_dir_operation(RecursiveIteratorIterator $dir, $func, array $args = array()) - { - $regex = $this->args['i']['val']; - $invregex= $this->args['x']['val']; - - if (isset($regex)) { - $dir = new RegexIterator($dir, $regex); - } - - if (isset($invregex)) { - $dir = new InvertedRegexIterator($dir, $invregex); - } - - $any = false; - foreach($dir as $pn => $f) { - $any = true; - call_user_func($func, $pn, $f, $args); - } - return $any; - } - // {{{ static function cli_cmd_inf_list - /** - * Cli Command Info List - * - * @return string What inf does - */ - static function cli_cmd_inf_list() - { - return "List contents of a PHAR archive."; - } - // }}} - // {{{ static function cli_cmd_arg_list - /** - * Cli Command Argument List - * - * @return arguments list - */ - static function cli_cmd_arg_list() - { - return self::phar_args('Fix', 'pharurl'); - } - // }}} - // {{{ public function cli_cmd_run_list - /** - * Cli Command Run List - * - * @see $this->phar_dir_operation - */ - public function cli_cmd_run_list() - { - $this->phar_dir_operation( - new DirectoryTreeIterator( - $this->args['f']['val']), - array($this, 'phar_dir_echo') - ); - } - // }}} - // {{{ static function cli_command_inf_tree - /** - * Cli Command Inf Tree - * - * @return string The description of a directory tree for a Phar archive. - */ - static function cli_cmd_inf_tree() - { - return "Get a directory tree for a PHAR archive."; - } - // }}} - // {{{ static function cli_cmd_arg_tree - /** - * Cli Command Argument Tree - * - * @return string Arguments in URL format. - */ - static function cli_cmd_arg_tree() - { - return self::phar_args('Fix', 'pharurl'); - } - // }}} - // {{{ public function cli_cmd_run_tree - /** - * Cli Command Run Tree - * - * Set the phar_dir_operation with a directorygraphiterator. - * - * @see DirectoryGraphIterator - * @see $this->phar_dir_operation - * - */ - public function cli_cmd_run_tree() - { - $a = $this->phar_dir_operation( - new DirectoryGraphIterator( - $this->args['f']['val']), - array($this, 'phar_dir_echo') - ); - if (!$a) { - echo "|-\n"; - } - } - // }}} - // {{{ cli_cmd_inf_extract - /** - * Cli Command Inf Extract - * - * @return string The description of the command extra to a directory. - */ - static function cli_cmd_inf_extract() - { - return "Extract a PHAR package to a directory."; - } - // }}} - // {{{ static function cli_cmd_arg_extract - /** - * Cli Command Arguments Extract - * - * The arguments for the extract function. - * - * @return array The arguments for the extraction. - */ - static function cli_cmd_arg_extract() - { - $args = self::phar_args('Fix', 'phar'); - - $args[''] = array( - 'type' => 'dir', - 'val' => '.', - 'inf' => ' Directory to extract to (defaults to \'.\').', - ); - - return $args; - } - // }}} - // {{{ public function cli_cmd_run_extract - /** - * Run Extract - * - * Run the extraction of a phar Archive. - * - * @see $this->phar_dir_operation - */ - public function cli_cmd_run_extract() - { - $dir = $this->args['']['val']; - - if (is_array($dir)) { - if (count($dir) != 1) { - self::error("Only one target directory allowed.\n"); - } else { - $dir = $dir[0]; - } - } - - $phar = $this->args['f']['val']; - $base = $phar->getPathname(); - $bend = strpos($base, '.phar'); - $bend = strpos($base, '/', $bend); - $base = substr($base, 0, $bend + 1); - $blen = strlen($base); - - $this->phar_dir_operation( - new RecursiveIteratorIterator($phar), - array($this, 'phar_dir_extract'), - array($blen, $dir) - ); - } - // }}} - // {{{ public function phar_dir_extract - /** - * Extract to a directory - * - * This function will extract the content of a Phar - * to a directory and create new files and directories - * depending on the permissions on that folder. - * - * @param string $pn - * @param string $f The file name - * @param array $args The directory and Blen information - */ - public function phar_dir_extract($pn, $f, $args) - { - $blen = $args[0]; - $dir = $args[1]; - $sub = substr($pn, $blen); - $target = $dir . '/' . $sub; - - if (!file_exists(dirname($target))) { - @mkdir(dirname($target), 0777, true); - } - if (!file_exists(dirname($target))) { - self::error("Operation could not be completed\n"); - } - - echo "$sub"; - - if (!@copy($f, $target)) { - echo " ...error\n"; - } else { - echo " ...ok\n"; - } - } - // }}} - // {{{ static function cli_cmd_inf_delete - /** - * Delete an entry from a phar information. - * - * @return string The information - */ - static function cli_cmd_inf_delete() - { - return 'Delete entry from a PHAR archive'; - } - // }}} - // {{{ static function cli_cmd_arg_delete - /** - * The cli command argument for deleting. - * - * @return array information about the arguments to use. - */ - static function cli_cmd_arg_delete() - { - return self::phar_args('FE', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_delete - /** - * Deleting execution - * - * Execute the deleting of the file from the phar archive. - */ - public function cli_cmd_run_delete() - { - $phar = $this->args['f']['val']; - $entry = $this->args['e']['val']; - - $phar->startBuffering(); - unset($phar[$entry]); - $phar->stopBuffering(); - } - // }}} - // {{{ static function cli_cmd_inf_add - /** - * Client comment add file information - * - * @return string The description of the feature - */ - static function cli_cmd_inf_add() - { - return "Add entries to a PHAR package."; - } - // }}} - // {{{ static function cli_cmd_arg_add - /** - * Add a file arguments - */ - static function cli_cmd_arg_add() - { - $args = self::phar_args('acFilx', 'phar'); - $args[''] = array( - 'type' => 'any', - 'val' => NULL, - 'required' => 1, - 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', - ); - return $args; - } - // }}} - // {{{ public functio cli_cmd_run_add - /** - * Add a file - * - * Run the action of adding a file to - * a phar archive. - */ - public function cli_cmd_run_add() - { - $compress= $this->args['c']['val']; - $phar = $this->args['f']['val']; - $regex = $this->args['i']['val']; - $level = $this->args['l']['val']; - $invregex= $this->args['x']['val']; - $input = $this->args['']['val']; - - $phar->startBuffering(); - - if (!is_array($input)) { - $this->phar_add($phar, $level, $input, $regex, $invregex, NULL, $compress); - } else { - foreach($input as $i) { - $this->phar_add($phar, $level, $i, $regex, $invregex, NULL, $compress); - } - } - $phar->stopBuffering(); - exit(0); - } - // }}} - // {{{ public function cli_cmd_inf_stub_set - /** - * Set the stup of a phar file. - * - * @return string The stub set description. - */ - public function cli_cmd_inf_stub_set() - { - return "Set the stub of a PHAR file. " . - "If no input file is specified as stub then stdin is being used."; - } - // }}} - // {{{ public function cli_cmd_arg_stub_set - /** - * Set the argument stub - * - * @return string arguments for a stub - */ - public function cli_cmd_arg_stub_set() - { - $args = self::phar_args('bFps', 'phar'); - $args['s']['val'] = 'php://stdin'; - return $args; - } - // }}} - // {{{ public function cli_cmd_run_stub_set - /** - * Cli Command run stub set - * - * @see $phar->setStub() - */ - public function cli_cmd_run_stub_set() - { - $hashbang = $this->args['b']['val']; - $phar = $this->args['f']['val']; - $stub = $this->args['s']['val']; - $loader = $this->args['p']['val']; - - $this->phar_set_stub_begin($phar, $stub, $loader, $hashbang); - $this->phar_set_stub_end($phar, $stub, $loader); - } - // }}} - // {{{ public function cli_cmd_inf_stub_get - /** - * Get the command stub infos. - * - * @return string a description of the stub of a Phar file. - */ - public function cli_cmd_inf_stub_get() - { - return "Get the stub of a PHAR file. " . - "If no output file is specified as stub then stdout is being used."; - } - // }}} - // {{{ public function cli_cmd_arg_stub_get - /** - * Get the argument stub - * - * @return array $args The arguments passed to the stub. - */ - public function cli_cmd_arg_stub_get() - { - $args = self::phar_args('Fs', 'phar'); - $args['s']['val'] = 'php://stdin'; - return $args; - } - // }}} - // {{{ public function cli_cmd_run_stub_get - /** - * Cli Command Run Stub - * - * Get arguments and store them into a stub. - * - * @param arguments $args - * @see $this->args - */ - public function cli_cmd_run_stub_get($args) - { - $phar = $this->args['f']['val']; - $stub = $this->args['s']['val']; - - file_put_contents($stub, $phar->getStub()); - } - // }}} - // {{{ public function cli_cmd_inf_compress - /** - * Cli Command Inf Compress - * - * Cli Command compress information - * - * @return string A description of the command. - */ - public function cli_cmd_inf_compress() - { - return "Compress or uncompress all files or a selected entry."; - } - // }}} - // {{{ public function cli_cmd_arg_cmpress - /** - * Cli Command Arg Compress - * - * @return array The arguments for compress - */ - public function cli_cmd_arg_compress() - { - return self::phar_args('FCe', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_compress - /** - * Cli Command Run Compress - * - * @see $this->args - */ - public function cli_cmd_run_compress() - { - $phar = $this->args['f']['val']; - $entry = $this->args['e']['val']; - - switch($this->args['c']['val']) { - case 'gz': - case 'gzip': - if (isset($entry)) { - $phar[$entry]->compress(Phar::GZ); - } else { - $phar->compressFiles(Phar::GZ); - } - break; - case 'bz2': - case 'bzip2': - if (isset($entry)) { - $phar[$entry]->compress(Phar::BZ2); - } else { - $phar->compressFiles(Phar::BZ2); - } - break; - default: - if (isset($entry)) { - $phar[$entry]->decompress(); - } else { - $phar->decompressFiles(); - } - break; - } - } - // }}} - // {{{ public function cli_cmd_inf_sign - /** - * Cli Command Info Signature - * - * @return string A description of the signature arguments. - */ - public function cli_cmd_inf_sign() - { - return "Set signature hash algorithm."; - } - // }}} - // {{{ public function cli_cmd_arg_sign - /** - * Cli Command Argument Sign - * - * @return array Arguments for Signature - */ - public function cli_cmd_arg_sign() - { - return self::phar_args('FHy', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_sign - /** - * Cli Command Run Signature - * - * @see $phar->setSignaturealgorithm - */ - public function cli_cmd_run_sign() - { - $phar = $this->args['f']['val']; - $hash = $this->args['h']['val']; - $privkey = $this->args['y']['val']; - - $hash = self::phar_check_hash($hash, $privkey); - - $phar->setSignatureAlgorithm($hash, $privkey); - } - // }}} - // {{{ public function cli_cmd_inf_meta_set - /** - * Cli Command Inf Meta Set - * - * @return string A description - */ - public function cli_cmd_inf_meta_set() - { - return "Set meta data of a PHAR entry or a PHAR package using serialized input. " . - "If no input file is specified for meta data then stdin is being used." . - "You can also specify a particular index using -k. In that case the metadata is " . - "expected to be an array and the value of the given index is being set. If " . - "the metadata is not present or empty a new array will be created. If the " . - "metadata is present and a flat value then the return value is 1. Also using -k " . - "the input is been taken directly rather then being serialized."; - } - // }}} - // {{{ public function cli_cmd_arg_meta_set - /** - * Cli Command Argument Meta Set - * - * @return array The arguments for meta set - */ - public function cli_cmd_arg_meta_set() - { - return self::phar_args('FekM', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_met_set - /** - * Cli Command Run Metaset - * - * @see $phar->startBuffering - * @see $phar->setMetadata - * @see $phar->stopBuffering - */ - public function cli_cmd_run_meta_set() - { - $phar = $this->args['f']['val']; - $entry = $this->args['e']['val']; - $index = $this->args['k']['val']; - $meta = $this->args['m']['val']; - - $phar->startBuffering(); - - if (isset($index)) { - if (isset($entry)) { - if ($phar[$entry]->hasMetadata()) { - $old = $phar[$entry]->getMetadata(); - } else { - $old = array(); - } - } else { - if ($phar->hasMetadata()) { - $old = $phar->getMetadata(); - } else { - $old = array(); - } - } - - if (!is_array($old)) { - self::error('Metadata is a flat value while an index operation was issued.'); - } - - $old[$index] = $meta; - $meta = $old; - } else { - $meta = unserialize($meta); - } - - if (isset($entry)) { - $phar[$entry]->setMetadata($meta); - } else { - $phar->setMetadata($meta); - } - $phar->stopBuffering(); - } - // }}} - // {{{ public function cli_cmd_inf_met_get - /** - * Cli Command Inf Metaget - * - * @return string A description of the metaget arguments - */ - public function cli_cmd_inf_meta_get() - { - return "Get meta information of a PHAR entry or a PHAR package in serialized from. " . - "If no output file is specified for meta data then stdout is being used.\n" . - "You can also specify a particular index using -k. In that case the metadata is " . - "expected to be an array and the value of the given index is returned using echo " . - "rather than using serialize. If that index does not exist or no meta data is " . - "present then the return value is 1."; - } - // }}} - // {{{ public function cli_cmd_arg_meta_get - /** - * Cli Command arg metaget - * - * @return array The arguments for meta get. - */ - public function cli_cmd_arg_meta_get() - { - return self::phar_args('Fek', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_meta_get - /** - * Cli Command Run Metaget - * - * @see $this->args - * @see $phar[$x]->hasMetadata() - * @see $phar->getMetadata() - */ - public function cli_cmd_run_meta_get() - { - $phar = $this->args['f']['val']; - $entry = $this->args['e']['val']; - $index = $this->args['k']['val']; - - if (isset($entry)) { - if (!$phar[$entry]->hasMetadata()) { - echo "No Metadata\n"; - exit(1); - } - echo serialize($phar[$entry]->getMetadata()); - } else { - if (!$phar->hasMetadata()) { - echo "No Metadata\n"; - exit(1); - } - $meta = $phar->getMetadata(); - } - - if (isset($index)) { - if (isset($index)) { - if (isset($meta[$index])) { - echo $meta[$index]; - exit(0); - } else { - echo "No Metadata\n"; - exit(1); - } - } else { - echo serialize($meta); - } - } - } - // }}} - // {{{ public function cli_cmd_inf_meta_del - /** - * Cli Command Inf Metadel - * - * @return string A description of the metadel function - */ - public function cli_cmd_inf_meta_del() - { - return "Delete meta information of a PHAR entry or a PHAR package.\n" . - "If -k is given then the metadata is expected to be an array " . - "and the given index is being deleted.\n" . - "If something was deleted the return value is 0 otherwise it is 1."; - } - // }}} - // {{{ public function cli_cmd_arg_meta_del - /** - * CliC ommand Arg Metadelete - * - * @return array The arguments for metadel - */ - public function cli_cmd_arg_meta_del() - { - return self::phar_args('Fek', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_meta_del - /** - * Cli Command Run MetaDel - * - * @see $phar[$x]->delMetadata() - * @see $phar->delMetadata() - */ - public function cli_cmd_run_meta_del() - { - $phar = $this->args['f']['val']; - $entry = $this->args['e']['val']; - $index = $this->args['k']['val']; - - if (isset($entry)) { - if (isset($index)) { - if (!$phar[$entry]->hasMetadata()) { - exit(1); - } - $meta = $phar[$entry]->getMetadata(); - - // @todo add error message here. - if (!is_array($meta)) { - exit(1); - } - - unset($meta[$index]); - $phar[$entry]->setMetadata($meta); - } else { - exit($phar[$entry]->delMetadata() ? 0 : 1); - } - } else { - if (isset($index)) { - if (!$phar->hasMetadata()) { - exit(1); - } - - $meta = $phar->getMetadata(); - - // @todo Add error message - if (!is_array($meta)) { - exit(1); - } - - unset($meta[$index]); - $phar->setMetadata($meta); - } else { - exit($phar->delMetadata() ? 0 : 1); - } - } - } - // }}} - // {{{ public function cli_cmd_inf_info - /** - * CLi Command Inf Info - * - * @return string A description about the info commands. - */ - public function cli_cmd_inf_info() - { - return "Get information about a PHAR package.\n" . - "By using -k it is possible to return a single value."; - } - // }}} - // {{{ public function cli_cmd_arg_info - /** - * Cli Command Arg Infos - * - * @return array The arguments for info command. - */ - public function cli_cmd_arg_info() - { - return self::phar_args('Fk', 'phar'); - } - // }}} - // {{{ public function cli_cmd_run_info - /** - * Cli Command Run Info - * - * @param args $args - */ - public function cli_cmd_run_info() - { - $phar = $this->args['f']['val']; - $index = $this->args['k']['val']; - - $hash = $phar->getSignature(); - $infos = array(); - - if ($phar->getAlias()) { - $infos['Alias'] = $phar->getAlias(); - } - - if (!$hash) { - $infos['Hash-type'] = 'NONE'; - } else { - $infos['Hash-type'] = $hash['hash_type']; - $infos['Hash'] = $hash['hash']; - } - - $csize = 0; - $usize = 0; - $count = 0; - $ccount = 0; - $ucount = 0; - $mcount = 0; - $compalg = array('GZ'=>0, 'BZ2'=>0); - - foreach(new RecursiveIteratorIterator($phar) as $ent) { - $count++; - if ($ent->isCompressed()) { - $ccount++; - $csize += $ent->getCompressedSize(); - if ($ent->isCompressed(Phar::GZ)) { - $compalg['GZ']++; - } elseif ($ent->isCompressed(Phar::BZ2)) { - $compalg['BZ2']++; - } - } else { - $ucount++; - $csize += $ent->getSize(); - } - - $usize += $ent->getSize(); - - if ($ent->hasMetadata()) { - $mcount++; - } - } - - $infos['Entries'] = $count; - $infos['Uncompressed-files'] = $ucount; - $infos['Compressed-files'] = $ccount; - $infos['Compressed-gz'] = $compalg['GZ']; - $infos['Compressed-bz2'] = $compalg['BZ2']; - $infos['Uncompressed-size'] = $usize; - $infos['Compressed-size'] = $csize; - $infos['Compression-ratio'] = sprintf('%.3g%%', $usize ? ($csize * 100) / $usize : 100); - $infos['Metadata-global'] = $phar->hasMetadata() * 1; - $infos['Metadata-files'] = $mcount; - $infos['Stub-size'] = strlen($phar->getStub()); - - if (isset($index)) { - if (!isset($infos[$index])) { - self::error("Requested value does not exist.\n"); - } - - echo $infos[$index]; - exit(0); - } - - $l = 0; - foreach($infos as $which => $val) { - $l = max(strlen($which), $l); - } - - foreach($infos as $which => $val) { - echo $which . ':' . str_repeat(' ', $l + 1 - strlen($which)) . $val . "\n"; - } - } - // }}} - // {{{ public function cli_cmd_inf_version - /** - * CLi Command Inf Version - * - * @return string A description about the info commands. - */ - public function cli_cmd_inf_version() - { - return "Get information about the PHAR environment and the tool version."; - } - // }}} - // {{{ public function cli_cmd_arg_version - /** - * Cli Command Arg Version - * - * @return array The arguments for version command. - */ - public function cli_cmd_arg_version() - { - return self::phar_args('', NULL); - } - // }}} - // {{{ public function cli_cmd_run_info - /** - * Cli Command Run Info - * - * @param args $args - */ - public function cli_cmd_run_version() - { - $use_ext = extension_loaded('phar'); - $version = array( - 'PHP Version' => phpversion(), - 'phar.phar version' => '$Id$', - 'Phar EXT version' => $use_ext ? phpversion('phar') : 'Not available', - 'Phar API version' => Phar::apiVersion(), - 'Phar-based phar archives' => true, - 'Tar-based phar archives' => $use_ext, - 'ZIP-based phar archives' => $use_ext, - 'gzip compression' => extension_loaded('zlib'), - 'bzip2 compression' => extension_loaded('bz2'), - 'supported signatures' => $use_ext ? join(', ', Phar::getSupportedSignatures()) : '', - ); - $klen = 0; - foreach($version as $k => $v) - { - $klen = max($klen, strlen($k)); - } - ++$klen; - foreach($version as $k => $v) { - if (is_bool($v)) { - $v = $v ? 'enabled' : 'disabled'; - } - printf("%-${klen}s %s\n", $k.':', $v); - } - } - // }}} + // {{{ public function cli_get_SP2 + public function cli_get_SP2($l1, $arg_inf) + { + return str_repeat(' ', $l1 + 2 + 4 + 9); + } + // }}} + // {{{ public function cli_get_SP3 + /** + * Cli Get SP3 + * + * @param string $l1 Eleven + * @param string $l2 Twelve + * @param string $arg_inf + * @return string The repeated string. + */ + function cli_get_SP3($l1, $l2, $arg_inf) + { + return str_repeat(' ', $l1 + 2 + 4 + 9 + 2 + $l2 + 2); + } + // }}} + // {{{ static function phar_args + /** + * Phar arguments + * + * This function contains all the phar commands + * + * @param string $which Which argument is chosen. + * @param string $phartype The type of phar, specific file to work on + * @return unknown + */ + static function phar_args($which, $phartype) + { + $phar_args = array( + 'a' => array( + 'typ' => 'alias', + 'val' => NULL, + 'inf' => ' Provide an alias name for the phar file.' + ), + 'b' => array( + 'typ' => 'any', + 'val' => NULL, + 'inf' => ' Hash-bang line to start the archive (e.g. #!/usr/bin/php). The hash ' + .' mark itself \'#!\' and the newline character are optional.' + ), + 'c' => array( + 'typ' => 'compalg', + 'val' => NULL, + 'inf' => ' Compression algorithm.', + 'select' => array( + '0' => 'No compression', + 'none' => 'No compression', + 'auto' => 'Automatically select compression algorithm' + ) + ), + 'e' => array( + 'typ' => 'entry', + 'val' => NULL, + 'inf' => ' Name of entry to work on (must include PHAR internal directory name if any).' + ), + 'f' => array( + 'typ' => $phartype, + 'val' => NULL, + 'inf' => ' Specifies the phar file to work on.' + ), + 'h' => array( + 'typ' => 'select', + 'val' => NULL, + 'inf' => ' Selects the hash algorithm.', + 'select' => array('md5' => 'MD5','sha1' => 'SHA1') + ), + 'i' => array( + 'typ' => 'regex', + 'val' => NULL, + 'inf' => ' Specifies a regular expression for input files.' + ), + 'k' => array( + 'typ' => 'any', + 'val' => NULL, + 'inf' => ' Subscription index to work on.', + ), + 'l' => array( + 'typ' => 'int', + 'val' => 0, + 'inf' => ' Number of preceding subdirectories to strip from file entries', + ), + 'm' => array( + 'typ' => 'any', + 'val' => NULL, + 'inf' => ' Meta data to store with entry (serialized php data).' + ), + 'p' => array( + 'typ' => 'loader', + 'val' => NULL, + 'inf' => ' Location of PHP_Archive class file (pear list-files PHP_Archive).' + .'You can use \'0\' or \'1\' to locate it automatically using the mentioned ' + .'pear command. When using \'0\' the command does not error out when the ' + .'class file cannot be located. This switch also adds some code around the ' + .'stub so that class PHP_Archive gets registered as phar:// stream wrapper ' + .'if necessary. And finally this switch will add the file phar.inc from ' + .'this package and load it to ensure class Phar is present.' + , + ), + 's' => array( + 'typ' => 'file', + 'val' => NULL, + 'inf' => ' Select the stub file.' + ), + 'x' => array( + 'typ' => 'regex', + 'val' => NULL, + 'inf' => ' Regular expression for input files to exclude.' + ), + 'y' => array( + 'typ' => 'privkey', + 'val' => NULL, + 'inf' => ' Private key for OpenSSL signing.', + ), + ); + + if (extension_loaded('zlib')) { + $phar_args['c']['select']['gz'] = 'GZip compression'; + $phar_args['c']['select']['gzip'] = 'GZip compression'; + } + + if (extension_loaded('bz2')) { + $phar_args['c']['select']['bz2'] = 'BZip2 compression'; + $phar_args['c']['select']['bzip2'] = 'BZip2 compression'; + } + + $hash_avail = Phar::getSupportedSignatures(); + $hash_optional = array('SHA-256' => 'SHA256', + 'SHA-512' => 'SHA512', + 'OpenSSL' => 'OpenSSL'); + if (!in_array('OpenSSL', $hash_avail)) { + unset($phar_args['y']); + } + + foreach($hash_optional as $key => $name) { + if (in_array($key, $hash_avail)) { + $phar_args['h']['select'][strtolower($name)] = $name; + } + } + + $args = array(); + + foreach($phar_args as $lkey => $cfg) { + $ukey = strtoupper($lkey); + $required = strpos($which, $ukey) !== false; + $optional = strpos($which, $lkey) !== false; + + if ($required || $optional) { + $args[$lkey] = $cfg; + $args[$lkey]['required'] = $required; + } + } + return $args; + } + // }}} + // {{{ static function strEndsWith + /** + * String Ends With + * + * Whether a string ends with another needle. + * + * @param string $haystack The haystack + * @param string $needle The needle. + * @return mixed false if doesn't end with anything, the string + * substr'ed if the string ends with the needle. + */ + static function strEndsWith($haystack, $needle) + { + return substr($haystack, -strlen($needle)) == $needle; + } + // }}} + // {{{ static function cli_arg_typ_loader + /** + * Argument type loader + * + * @param string $arg Either 'auto', 'optional' or an filename that + * contains class PHP_Archive + * @param string $cfg Configuration to pass to a new file + * @param string $key The key + * @return string $arg The argument. + */ + static function cli_arg_typ_loader($arg, $cfg, $key) + { + if (($arg == '0' || $arg == '1') && !file_exists($arg) && substr(PHP_OS, 0, 3) != 'WIN') { + $found = NULL; + $apiver = false; + $path = explode(PATH_SEPARATOR, $_ENV['PATH']); + $pear = false; + foreach ($path as $component) { + if (file_exists($component . DIRECTORY_SEPARATOR . 'pear') + && is_executable($component . DIRECTORY_SEPARATOR . 'pear')) { + $pear = true; + break; + } + } + if ($pear) { + $apiver = `pear -q info PHP_Archive 2>/dev/null|grep 'API Version'`; + $apiver = trim(substr($apiver, strlen('API Version'))); + } + if ($apiver) { + self::notice("PEAR package PHP_Archive: API Version: $apiver.\n"); + $files = explode("\n", `pear list-files PHP_Archive`); + $phpdir = `pear config-get php_dir 2>/dev/null`; + $phpdir = trim($phpdir); + self::notice("PEAR package PHP_Archive: $phpdir.\n"); + if (is_dir($phpdir)) { + foreach($files as $ent) { + $matches = NULL; + if (preg_match(",^php[ \t]+([^ \t].*[\\\\/]PHP[\\\\/]Archive\.php)$,", $ent, $matches)) { + $sub = $matches[1]; + if (strpos($sub, $phpdir) !== 0) { + $found = NULL; + break; + } + $found = $sub; + break; + } + } + } else { + self::notice("PEAR package PHP_Archive: corrupt or inaccessible base dir: $php_dir.\n"); + } + } + if (isset($found)) { + self::notice("PEAR package PHP_Archive: $found.\n"); + } else { + $msg = "PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.\n"; + if ($arg == '0') { + self::notice($msg); + } else { + self::error($msg); + } + } + $arg = $found; + } + return self::cli_arg_typ_file($arg); + } + // }}} + // {{{ static function cli_arg_typ_pharnew + /** + * Argument type new phar + * + * @param string $arg The new phar component. + * @param string $cfg Configuration to pass to a new file + * @param string $key The key + * @return string $arg The new argument file. + */ + static function cli_arg_typ_pharnew($arg, $cfg, $key) + { + $arg = self::cli_arg_typ_filenew($arg, $cfg, $key); + if (!Phar::isValidPharFilename($arg)) { + self::error("Phar files must have file extension '.phar', '.phar.php', '.phar.bz2' or '.phar.gz'.\n"); + } + return $arg; + } + // }}} + // {{{ static function cli_arg_typ_pharfile + /** + * Argument type existing Phar file + * + * Return filename of an existing Phar. + * + * @param string $arg The file in the phar to open. + * @param string $cfg The configuration information + * @param string $key The key information. + * @return string $pharfile The name of the loaded Phar file. + * @note The Phar will be loaded + */ + static function cli_arg_typ_pharfile($arg, $cfg, $key) + { + try { + $pharfile = self::cli_arg_typ_file($arg, $cfg, $key); + + if (!Phar::loadPhar($pharfile)) { + self::error("Unable to open phar '$arg'\n"); + } + + return $pharfile; + } catch(Exception $e) { + self::error("Exception while opening phar '$arg':\n" . $e->getMessage() . "\n"); + } + } + // }}} + // {{{ static function cli_arg_typ_pharurl + /** + * Argument type Phar url-like + * + * Check the argument as cli_arg_Typ_phar and return its name prefixed + * with phar:// + * + * Ex: + * + * $arg = 'pharchive.phar/file.php'; + * cli_arg_typ_pharurl($arg) + * + * + * @param string $arg The url-like phar archive to retrieve. + * @return string The phar file-archive. + */ + static function cli_arg_typ_pharurl($arg, $cfg, $key) + { + return 'phar://' . self::cli_arg_typ_pharfile($arg, $cfg, $key); + } + // }}} + // {{{ static function cli_arg_typ_phar + /** + * Cli argument type phar + * + * @param string $arg The phar archive to use. + * @return object new Phar of the passed argument. + */ + static function cli_arg_typ_phar($arg, $cfg, $key) + { + try { + return new Phar(self::cli_arg_typ_pharfile($arg, $cfg, $key)); + } catch(Exception $e) { + self::error("Exception while opening phar '$argv':\n" . $e->getMessage() . "\n"); + } + } + // }}} + // {{{ static function cli_arg_typ_entry + /** + * Argument type Entry name + * + * @param string $arg The argument (the entry) + * @return string $arg The entry itself. + */ + static function cli_arg_typ_entry($arg, $cfg, $key) + { + // no further check atm, maybe check for no '/' at beginning + return $arg; + } + // }}} + // {{{ static function cli_arg_typ_compalg + /** + * Argument type compression algorithm + * + * @param string $arg The phar selection + * @param string $cfg The config option. + * @param string $key The key information. + * @return string $arg The selected algorithm + */ + static function cli_arg_typ_compalg($arg, $cfg, $key) + { + $arg = self::cli_arg_typ_select($arg, $cfg, $key); + + switch($arg) { + case 'auto': + if (extension_loaded('zlib')) { + $arg = 'gz'; + } elseif (extension_loaded('bz2')) { + $arg = 'bz2'; + } else { + $arg = '0'; + } + break; + } + return $arg; + } + // }}} + // {{{ static function cli_arg_typ_privkey + /** + * Argument type private key (for OpenSSL signing) + * + * @param string $arg The phar selection + * @param string $cfg The config option. + * @param string $key The key information. + * @return string $arg The private key. + */ + static function cli_arg_typ_privkey($arg, $cfg, $key) + { + $arg = self::cli_arg_typ_filecont($arg, $cfg, $key); + + $hash_avail = Phar::getSupportedSignatures(); + if ($arg && !in_array('OpenSSL', $hash_avail)) + { + self::error("Cannot specify private key without OpenSSL support.\n"); + } + return $arg; + } + // }}} + // {{{ static function phar_check_hash + /** + * Check whether hash method is valid. + * + * @return Hash constant to be used. + */ + function phar_check_hash($hash, $privkey) + { + switch($hash) { + case 'md5': + return Phar::MD5; + case 'sha1': + return Phar::SHA1; + case 'sha256': + return Phar::SHA256; + case 'sha512': + return Phar::SHA512; + case 'openssl': + if (!$privkey) { + self::error("Cannot use OpenSSL signing without key.\n"); + } + return Phar::OPENSSL; + } + } + // }}} + // {{{ static function cli_cmd_inf_pack + /** + * Information pack + * + * @return string A description about packing files into a Phar archive. + */ + static function cli_cmd_inf_pack() + { + return "Pack files into a PHAR archive.\n" . + "When using -s , then the stub file is being " . + "excluded from the list of input files/dirs." . + "To create an archive that contains PEAR class PHP_Archive " . + "then point -p argument to PHP/Archive.php.\n"; + } + // }}} + // {{{ static function cli_cmd_arg_pack + /** + * Pack a new phar infos + * + * @return array $args The arguments for a new Phar archive. + */ + static function cli_cmd_arg_pack() + { + $args = self::phar_args('abcFhilpsxy', 'pharnew'); + + $args[''] = array( + 'typ' => 'any', + 'val' => NULL, + 'required' => 1, + 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', + ); + + return $args; + } + // }}} + // {{{ function phar_set_stub_begin + /** + * Set the stub + */ + public function phar_set_stub_begin(Phar $phar, $stub, $loader = NULL, $hashbang = NULL) + { + if (isset($stub)) { + $c = file_get_contents($stub); + + if (substr($c, 0, 2) == '#!') { + if (strpos($c, "\n") !== false) { + if (!isset($hashbang)) { + $hashbang = substr($c, 0, strpos($c, "\n") + 1); + } + $c = substr($c, strpos($c, "\n") + 1); + } else { + if (!isset($hashbang)) { + $hashbang = $c; + } + $c = NULL; + } + } + + if (isset($hashbang)) { + if (substr($hashbang, 0, 2) != '#!') { + $hashbang = '#!' . $hashbang; + } + if (substr($hashbang, -1) != "\n") { + $hashbang .= "\n"; + } + } else { + $hashbang = ""; + } + + if (isset($loader)) { + $s = ""; + if (is_file($loader)) { + $s .= file_get_contents($loader); + } + $s .= "'; + $s .= $c; + + $phar->setStub($hashbang . $s); + } else { + $phar->setStub($hashbang . $c); + } + return new SplFileInfo($stub); + } + return NULL; + } + // }}} + // {{{ function phar_set_stub_end + /** + * Set stub end + */ + public function phar_set_stub_end(Phar $phar, $stub, $loader = NULL) + { + if (isset($stub) && isset($loader)) { + if (substr(__FILE__, -15) == 'pharcommand.inc') { + self::phar_add_file($phar, 0, 'phar.inc', 'phar://'.__FILE__.'/phar.inc', NULL); + } else { + self::phar_add_file($phar, 0, 'phar.inc', dirname(__FILE__).'/phar/phar.inc', NULL); + } + } + } + // }}} + // {{{ function cli_cmd_run_pack + /** + * Pack a new Phar + * + * This function will try to pack a new Phar archive. + * + * @see Exit to make sure that we are done. + */ + public function cli_cmd_run_pack() + { + if (ini_get('phar.readonly')) { + self::error("Creating phar files is disabled by ini setting 'phar.readonly'.\n"); + } + + if (!Phar::canWrite()) { + self::error("Creating phar files is disabled, Phar::canWrite() returned false.\n"); + } + + $alias = $this->args['a']['val']; + $hashbang = $this->args['b']['val']; + $archive = $this->args['f']['val']; + $hash = $this->args['h']['val']; + $privkey = $this->args['y']['val'] ?? null; + $regex = $this->args['i']['val']; + $level = $this->args['l']['val']; + $loader = $this->args['p']['val']; + $stub = $this->args['s']['val']; + $invregex = $this->args['x']['val']; + $input = $this->args['']['val']; + + $hash = self::phar_check_hash($hash, $privkey); + + $phar = new Phar($archive, 0, $alias); + + $phar->startBuffering(); + + $stub = $this->phar_set_stub_begin($phar, $stub, $loader, $hashbang); + + if (!is_array($input)) { + $this->phar_add($phar, $level, $input, $regex, $invregex, $stub, NULL, isset($loader)); + } else { + foreach($input as $i) { + $this->phar_add($phar, $level, $i, $regex, $invregex, $stub, NULL, isset($loader)); + } + } + + $this->phar_set_stub_end($phar, $stub, $loader); + + switch($this->args['c']['val']) { + case 'gz': + case 'gzip': + $phar->compressFiles(Phar::GZ); + break; + case 'bz2': + case 'bzip2': + $phar->compressFiles(Phar::BZ2); + break; + default: + $phar->decompressFiles(); + break; + } + + if ($hash) { + $phar->setSignatureAlgorithm($hash, $privkey); + } + + $phar->stopBuffering(); + exit(0); + } + // }}} + // {{{ static function phar_add + /** + * Add files to a phar archive. + * + * This function will take a directory and iterate through + * it and get the files to insert into the Phar archive. + * + * @param Phar $phar The phar object. + * @param string $input The input directory + * @param string $regex The regex used in RegexIterator. + * @param string $invregex The InvertedRegexIterator expression. + * @param SplFileInfo $stub Stub file object + * @param mixed $compress Compression algorithm or NULL + * @param boolean $noloader Whether to prevent adding the loader + */ + static function phar_add(Phar $phar, $level, $input, $regex, $invregex, SplFileInfo $stub = NULL, $compress = NULL, $noloader = false) + { + if ($input && is_file($input) && !is_dir($input)) { + return self::phar_add_file($phar, $level, $input, $input, $compress); + } + $dir = new RecursiveDirectoryIterator($input); + $dir = new RecursiveIteratorIterator($dir); + + if (isset($regex)) { + $dir = new RegexIterator($dir, $regex); + } + + if (isset($invregex)) { + $dir = new InvertedRegexIterator($dir, $invregex); + } + + try { + foreach($dir as $file) { + if ((empty($stub) || $file->getRealPath() != $stub->getRealPath()) && !is_dir($file)) { + self::phar_add_file($phar, $level, $dir->getSubPathName(), $file, $compress, $noloader); + } + } + } catch(Exception $e) { + self::error("Unable to complete operation on file '$file'\n" . $e->getMessage() . "\n"); + } + } + // }}} + // {{{ static function phar_add_file + /** + * Add a phar file + * + * This function adds a file to a phar archive. + * + * @param Phar $phar The phar object + * @param string $level The level of the file. + * @param string $entry The entry point + * @param string $file The file to add to the archive + * @param string $compress The compression scheme for the file. + * @param boolean $noloader Whether to prevent adding the loader + */ + static function phar_add_file(Phar $phar, $level, $entry, $file, $compress, $noloader = false) + { + $entry = str_replace('//', '/', $entry); + while($level-- > 0 && ($p = strpos($entry, '/')) !== false) { + $entry = substr($entry, $p+1); + } + + if ($noloader && $entry == 'phar.inc') { + return; + } + + echo "$entry\n"; + + $phar[$entry] = file_get_contents($file); + switch($compress) { + case 'gz': + case 'gzip': + $phar[$entry]->compress(Phar::GZ); + break; + case 'bz2': + case 'bzip2': + $phar[$entry]->compress(Phar::BZ2); + break; + case '0': + $phar[$entry]->decompress(); + break; + default: + break; + } + } + // }}} + // {{{ public function phar_dir_echo + /** + * Echo directory + * + * @param string $pn + * @param unknown_type $f + */ + public function phar_dir_echo($pn, $f) + { + echo "$f\n"; + } + // }}} + // {{{ public function phar_dir_operation + /** + * Directory operations + * + * Phar directory operations. + * + * @param RecursiveIteratorIterator $dir The recursiveIteratorIterator object. + * @param string $func Function to call on the iterations + * @param array $args Function arguments. + */ + public function phar_dir_operation(RecursiveIteratorIterator $dir, $func, array $args = array()) + { + $regex = $this->args['i']['val']; + $invregex= $this->args['x']['val']; + + if (isset($regex)) { + $dir = new RegexIterator($dir, $regex); + } + + if (isset($invregex)) { + $dir = new InvertedRegexIterator($dir, $invregex); + } + + $any = false; + foreach($dir as $pn => $f) { + $any = true; + call_user_func($func, $pn, $f, $args); + } + return $any; + } + // {{{ static function cli_cmd_inf_list + /** + * Cli Command Info List + * + * @return string What inf does + */ + static function cli_cmd_inf_list() + { + return "List contents of a PHAR archive."; + } + // }}} + // {{{ static function cli_cmd_arg_list + /** + * Cli Command Argument List + * + * @return arguments list + */ + static function cli_cmd_arg_list() + { + return self::phar_args('Fix', 'pharurl'); + } + // }}} + // {{{ public function cli_cmd_run_list + /** + * Cli Command Run List + * + * @see $this->phar_dir_operation + */ + public function cli_cmd_run_list() + { + $this->phar_dir_operation( + new DirectoryTreeIterator( + $this->args['f']['val']), + array($this, 'phar_dir_echo') + ); + } + // }}} + // {{{ static function cli_command_inf_tree + /** + * Cli Command Inf Tree + * + * @return string The description of a directory tree for a Phar archive. + */ + static function cli_cmd_inf_tree() + { + return "Get a directory tree for a PHAR archive."; + } + // }}} + // {{{ static function cli_cmd_arg_tree + /** + * Cli Command Argument Tree + * + * @return string Arguments in URL format. + */ + static function cli_cmd_arg_tree() + { + return self::phar_args('Fix', 'pharurl'); + } + // }}} + // {{{ public function cli_cmd_run_tree + /** + * Cli Command Run Tree + * + * Set the phar_dir_operation with a directorygraphiterator. + * + * @see DirectoryGraphIterator + * @see $this->phar_dir_operation + * + */ + public function cli_cmd_run_tree() + { + $a = $this->phar_dir_operation( + new DirectoryGraphIterator( + $this->args['f']['val']), + array($this, 'phar_dir_echo') + ); + if (!$a) { + echo "|-\n"; + } + } + // }}} + // {{{ cli_cmd_inf_extract + /** + * Cli Command Inf Extract + * + * @return string The description of the command extra to a directory. + */ + static function cli_cmd_inf_extract() + { + return "Extract a PHAR package to a directory."; + } + // }}} + // {{{ static function cli_cmd_arg_extract + /** + * Cli Command Arguments Extract + * + * The arguments for the extract function. + * + * @return array The arguments for the extraction. + */ + static function cli_cmd_arg_extract() + { + $args = self::phar_args('Fix', 'phar'); + + $args[''] = array( + 'type' => 'dir', + 'val' => '.', + 'inf' => ' Directory to extract to (defaults to \'.\').', + ); + + return $args; + } + // }}} + // {{{ public function cli_cmd_run_extract + /** + * Run Extract + * + * Run the extraction of a phar Archive. + * + * @see $this->phar_dir_operation + */ + public function cli_cmd_run_extract() + { + $dir = $this->args['']['val']; + + if (is_array($dir)) { + if (count($dir) != 1) { + self::error("Only one target directory allowed.\n"); + } else { + $dir = $dir[0]; + } + } + + $phar = $this->args['f']['val']; + $base = $phar->getPathname(); + $bend = strpos($base, '.phar'); + $bend = strpos($base, '/', $bend); + $base = substr($base, 0, $bend + 1); + $blen = strlen($base); + + $this->phar_dir_operation( + new RecursiveIteratorIterator($phar), + array($this, 'phar_dir_extract'), + array($blen, $dir) + ); + } + // }}} + // {{{ public function phar_dir_extract + /** + * Extract to a directory + * + * This function will extract the content of a Phar + * to a directory and create new files and directories + * depending on the permissions on that folder. + * + * @param string $pn + * @param string $f The file name + * @param array $args The directory and Blen information + */ + public function phar_dir_extract($pn, $f, $args) + { + $blen = $args[0]; + $dir = $args[1]; + $sub = substr($pn, $blen); + $target = $dir . '/' . $sub; + + if (!file_exists(dirname($target))) { + @mkdir(dirname($target), 0777, true); + } + if (!file_exists(dirname($target))) { + self::error("Operation could not be completed\n"); + } + + echo "$sub"; + + if (!@copy($f, $target)) { + echo " ...error\n"; + } else { + echo " ...ok\n"; + } + } + // }}} + // {{{ static function cli_cmd_inf_delete + /** + * Delete an entry from a phar information. + * + * @return string The information + */ + static function cli_cmd_inf_delete() + { + return 'Delete entry from a PHAR archive'; + } + // }}} + // {{{ static function cli_cmd_arg_delete + /** + * The cli command argument for deleting. + * + * @return array information about the arguments to use. + */ + static function cli_cmd_arg_delete() + { + return self::phar_args('FE', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_delete + /** + * Deleting execution + * + * Execute the deleting of the file from the phar archive. + */ + public function cli_cmd_run_delete() + { + $phar = $this->args['f']['val']; + $entry = $this->args['e']['val']; + + $phar->startBuffering(); + unset($phar[$entry]); + $phar->stopBuffering(); + } + // }}} + // {{{ static function cli_cmd_inf_add + /** + * Client comment add file information + * + * @return string The description of the feature + */ + static function cli_cmd_inf_add() + { + return "Add entries to a PHAR package."; + } + // }}} + // {{{ static function cli_cmd_arg_add + /** + * Add a file arguments + */ + static function cli_cmd_arg_add() + { + $args = self::phar_args('acFilx', 'phar'); + $args[''] = array( + 'type' => 'any', + 'val' => NULL, + 'required' => 1, + 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching the given regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.', + ); + return $args; + } + // }}} + // {{{ public functio cli_cmd_run_add + /** + * Add a file + * + * Run the action of adding a file to + * a phar archive. + */ + public function cli_cmd_run_add() + { + $compress= $this->args['c']['val']; + $phar = $this->args['f']['val']; + $regex = $this->args['i']['val']; + $level = $this->args['l']['val']; + $invregex= $this->args['x']['val']; + $input = $this->args['']['val']; + + $phar->startBuffering(); + + if (!is_array($input)) { + $this->phar_add($phar, $level, $input, $regex, $invregex, NULL, $compress); + } else { + foreach($input as $i) { + $this->phar_add($phar, $level, $i, $regex, $invregex, NULL, $compress); + } + } + $phar->stopBuffering(); + exit(0); + } + // }}} + // {{{ public function cli_cmd_inf_stub_set + /** + * Set the stup of a phar file. + * + * @return string The stub set description. + */ + public function cli_cmd_inf_stub_set() + { + return "Set the stub of a PHAR file. " . + "If no input file is specified as stub then stdin is being used."; + } + // }}} + // {{{ public function cli_cmd_arg_stub_set + /** + * Set the argument stub + * + * @return string arguments for a stub + */ + public function cli_cmd_arg_stub_set() + { + $args = self::phar_args('bFps', 'phar'); + $args['s']['val'] = 'php://stdin'; + return $args; + } + // }}} + // {{{ public function cli_cmd_run_stub_set + /** + * Cli Command run stub set + * + * @see $phar->setStub() + */ + public function cli_cmd_run_stub_set() + { + $hashbang = $this->args['b']['val']; + $phar = $this->args['f']['val']; + $stub = $this->args['s']['val']; + $loader = $this->args['p']['val']; + + $this->phar_set_stub_begin($phar, $stub, $loader, $hashbang); + $this->phar_set_stub_end($phar, $stub, $loader); + } + // }}} + // {{{ public function cli_cmd_inf_stub_get + /** + * Get the command stub infos. + * + * @return string a description of the stub of a Phar file. + */ + public function cli_cmd_inf_stub_get() + { + return "Get the stub of a PHAR file. " . + "If no output file is specified as stub then stdout is being used."; + } + // }}} + // {{{ public function cli_cmd_arg_stub_get + /** + * Get the argument stub + * + * @return array $args The arguments passed to the stub. + */ + public function cli_cmd_arg_stub_get() + { + $args = self::phar_args('Fs', 'phar'); + $args['s']['val'] = 'php://stdin'; + return $args; + } + // }}} + // {{{ public function cli_cmd_run_stub_get + /** + * Cli Command Run Stub + * + * Get arguments and store them into a stub. + * + * @param arguments $args + * @see $this->args + */ + public function cli_cmd_run_stub_get($args) + { + $phar = $this->args['f']['val']; + $stub = $this->args['s']['val']; + + file_put_contents($stub, $phar->getStub()); + } + // }}} + // {{{ public function cli_cmd_inf_compress + /** + * Cli Command Inf Compress + * + * Cli Command compress information + * + * @return string A description of the command. + */ + public function cli_cmd_inf_compress() + { + return "Compress or uncompress all files or a selected entry."; + } + // }}} + // {{{ public function cli_cmd_arg_cmpress + /** + * Cli Command Arg Compress + * + * @return array The arguments for compress + */ + public function cli_cmd_arg_compress() + { + return self::phar_args('FCe', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_compress + /** + * Cli Command Run Compress + * + * @see $this->args + */ + public function cli_cmd_run_compress() + { + $phar = $this->args['f']['val']; + $entry = $this->args['e']['val']; + + switch($this->args['c']['val']) { + case 'gz': + case 'gzip': + if (isset($entry)) { + $phar[$entry]->compress(Phar::GZ); + } else { + $phar->compressFiles(Phar::GZ); + } + break; + case 'bz2': + case 'bzip2': + if (isset($entry)) { + $phar[$entry]->compress(Phar::BZ2); + } else { + $phar->compressFiles(Phar::BZ2); + } + break; + default: + if (isset($entry)) { + $phar[$entry]->decompress(); + } else { + $phar->decompressFiles(); + } + break; + } + } + // }}} + // {{{ public function cli_cmd_inf_sign + /** + * Cli Command Info Signature + * + * @return string A description of the signature arguments. + */ + public function cli_cmd_inf_sign() + { + return "Set signature hash algorithm."; + } + // }}} + // {{{ public function cli_cmd_arg_sign + /** + * Cli Command Argument Sign + * + * @return array Arguments for Signature + */ + public function cli_cmd_arg_sign() + { + return self::phar_args('FHy', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_sign + /** + * Cli Command Run Signature + * + * @see $phar->setSignaturealgorithm + */ + public function cli_cmd_run_sign() + { + $phar = $this->args['f']['val']; + $hash = $this->args['h']['val']; + $privkey = $this->args['y']['val']; + + $hash = self::phar_check_hash($hash, $privkey); + + $phar->setSignatureAlgorithm($hash, $privkey); + } + // }}} + // {{{ public function cli_cmd_inf_meta_set + /** + * Cli Command Inf Meta Set + * + * @return string A description + */ + public function cli_cmd_inf_meta_set() + { + return "Set meta data of a PHAR entry or a PHAR package using serialized input. " . + "If no input file is specified for meta data then stdin is being used." . + "You can also specify a particular index using -k. In that case the metadata is " . + "expected to be an array and the value of the given index is being set. If " . + "the metadata is not present or empty a new array will be created. If the " . + "metadata is present and a flat value then the return value is 1. Also using -k " . + "the input is been taken directly rather then being serialized."; + } + // }}} + // {{{ public function cli_cmd_arg_meta_set + /** + * Cli Command Argument Meta Set + * + * @return array The arguments for meta set + */ + public function cli_cmd_arg_meta_set() + { + return self::phar_args('FekM', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_met_set + /** + * Cli Command Run Metaset + * + * @see $phar->startBuffering + * @see $phar->setMetadata + * @see $phar->stopBuffering + */ + public function cli_cmd_run_meta_set() + { + $phar = $this->args['f']['val']; + $entry = $this->args['e']['val']; + $index = $this->args['k']['val']; + $meta = $this->args['m']['val']; + + $phar->startBuffering(); + + if (isset($index)) { + if (isset($entry)) { + if ($phar[$entry]->hasMetadata()) { + $old = $phar[$entry]->getMetadata(); + } else { + $old = array(); + } + } else { + if ($phar->hasMetadata()) { + $old = $phar->getMetadata(); + } else { + $old = array(); + } + } + + if (!is_array($old)) { + self::error('Metadata is a flat value while an index operation was issued.'); + } + + $old[$index] = $meta; + $meta = $old; + } else { + $meta = unserialize($meta); + } + + if (isset($entry)) { + $phar[$entry]->setMetadata($meta); + } else { + $phar->setMetadata($meta); + } + $phar->stopBuffering(); + } + // }}} + // {{{ public function cli_cmd_inf_met_get + /** + * Cli Command Inf Metaget + * + * @return string A description of the metaget arguments + */ + public function cli_cmd_inf_meta_get() + { + return "Get meta information of a PHAR entry or a PHAR package in serialized from. " . + "If no output file is specified for meta data then stdout is being used.\n" . + "You can also specify a particular index using -k. In that case the metadata is " . + "expected to be an array and the value of the given index is returned using echo " . + "rather than using serialize. If that index does not exist or no meta data is " . + "present then the return value is 1."; + } + // }}} + // {{{ public function cli_cmd_arg_meta_get + /** + * Cli Command arg metaget + * + * @return array The arguments for meta get. + */ + public function cli_cmd_arg_meta_get() + { + return self::phar_args('Fek', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_meta_get + /** + * Cli Command Run Metaget + * + * @see $this->args + * @see $phar[$x]->hasMetadata() + * @see $phar->getMetadata() + */ + public function cli_cmd_run_meta_get() + { + $phar = $this->args['f']['val']; + $entry = $this->args['e']['val']; + $index = $this->args['k']['val']; + + if (isset($entry)) { + if (!$phar[$entry]->hasMetadata()) { + echo "No Metadata\n"; + exit(1); + } + echo serialize($phar[$entry]->getMetadata()); + } else { + if (!$phar->hasMetadata()) { + echo "No Metadata\n"; + exit(1); + } + $meta = $phar->getMetadata(); + } + + if (isset($index)) { + if (isset($index)) { + if (isset($meta[$index])) { + echo $meta[$index]; + exit(0); + } else { + echo "No Metadata\n"; + exit(1); + } + } else { + echo serialize($meta); + } + } + } + // }}} + // {{{ public function cli_cmd_inf_meta_del + /** + * Cli Command Inf Metadel + * + * @return string A description of the metadel function + */ + public function cli_cmd_inf_meta_del() + { + return "Delete meta information of a PHAR entry or a PHAR package.\n" . + "If -k is given then the metadata is expected to be an array " . + "and the given index is being deleted.\n" . + "If something was deleted the return value is 0 otherwise it is 1."; + } + // }}} + // {{{ public function cli_cmd_arg_meta_del + /** + * CliC ommand Arg Metadelete + * + * @return array The arguments for metadel + */ + public function cli_cmd_arg_meta_del() + { + return self::phar_args('Fek', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_meta_del + /** + * Cli Command Run MetaDel + * + * @see $phar[$x]->delMetadata() + * @see $phar->delMetadata() + */ + public function cli_cmd_run_meta_del() + { + $phar = $this->args['f']['val']; + $entry = $this->args['e']['val']; + $index = $this->args['k']['val']; + + if (isset($entry)) { + if (isset($index)) { + if (!$phar[$entry]->hasMetadata()) { + exit(1); + } + $meta = $phar[$entry]->getMetadata(); + + // @todo add error message here. + if (!is_array($meta)) { + exit(1); + } + + unset($meta[$index]); + $phar[$entry]->setMetadata($meta); + } else { + exit($phar[$entry]->delMetadata() ? 0 : 1); + } + } else { + if (isset($index)) { + if (!$phar->hasMetadata()) { + exit(1); + } + + $meta = $phar->getMetadata(); + + // @todo Add error message + if (!is_array($meta)) { + exit(1); + } + + unset($meta[$index]); + $phar->setMetadata($meta); + } else { + exit($phar->delMetadata() ? 0 : 1); + } + } + } + // }}} + // {{{ public function cli_cmd_inf_info + /** + * CLi Command Inf Info + * + * @return string A description about the info commands. + */ + public function cli_cmd_inf_info() + { + return "Get information about a PHAR package.\n" . + "By using -k it is possible to return a single value."; + } + // }}} + // {{{ public function cli_cmd_arg_info + /** + * Cli Command Arg Infos + * + * @return array The arguments for info command. + */ + public function cli_cmd_arg_info() + { + return self::phar_args('Fk', 'phar'); + } + // }}} + // {{{ public function cli_cmd_run_info + /** + * Cli Command Run Info + * + * @param args $args + */ + public function cli_cmd_run_info() + { + $phar = $this->args['f']['val']; + $index = $this->args['k']['val']; + + $hash = $phar->getSignature(); + $infos = array(); + + if ($phar->getAlias()) { + $infos['Alias'] = $phar->getAlias(); + } + + if (!$hash) { + $infos['Hash-type'] = 'NONE'; + } else { + $infos['Hash-type'] = $hash['hash_type']; + $infos['Hash'] = $hash['hash']; + } + + $csize = 0; + $usize = 0; + $count = 0; + $ccount = 0; + $ucount = 0; + $mcount = 0; + $compalg = array('GZ'=>0, 'BZ2'=>0); + + foreach(new RecursiveIteratorIterator($phar) as $ent) { + $count++; + if ($ent->isCompressed()) { + $ccount++; + $csize += $ent->getCompressedSize(); + if ($ent->isCompressed(Phar::GZ)) { + $compalg['GZ']++; + } elseif ($ent->isCompressed(Phar::BZ2)) { + $compalg['BZ2']++; + } + } else { + $ucount++; + $csize += $ent->getSize(); + } + + $usize += $ent->getSize(); + + if ($ent->hasMetadata()) { + $mcount++; + } + } + + $infos['Entries'] = $count; + $infos['Uncompressed-files'] = $ucount; + $infos['Compressed-files'] = $ccount; + $infos['Compressed-gz'] = $compalg['GZ']; + $infos['Compressed-bz2'] = $compalg['BZ2']; + $infos['Uncompressed-size'] = $usize; + $infos['Compressed-size'] = $csize; + $infos['Compression-ratio'] = sprintf('%.3g%%', $usize ? ($csize * 100) / $usize : 100); + $infos['Metadata-global'] = $phar->hasMetadata() * 1; + $infos['Metadata-files'] = $mcount; + $infos['Stub-size'] = strlen($phar->getStub()); + + if (isset($index)) { + if (!isset($infos[$index])) { + self::error("Requested value does not exist.\n"); + } + + echo $infos[$index]; + exit(0); + } + + $l = 0; + foreach($infos as $which => $val) { + $l = max(strlen($which), $l); + } + + foreach($infos as $which => $val) { + echo $which . ':' . str_repeat(' ', $l + 1 - strlen($which)) . $val . "\n"; + } + } + // }}} + // {{{ public function cli_cmd_inf_version + /** + * CLi Command Inf Version + * + * @return string A description about the info commands. + */ + public function cli_cmd_inf_version() + { + return "Get information about the PHAR environment and the tool version."; + } + // }}} + // {{{ public function cli_cmd_arg_version + /** + * Cli Command Arg Version + * + * @return array The arguments for version command. + */ + public function cli_cmd_arg_version() + { + return self::phar_args('', NULL); + } + // }}} + // {{{ public function cli_cmd_run_info + /** + * Cli Command Run Info + * + * @param args $args + */ + public function cli_cmd_run_version() + { + $use_ext = extension_loaded('phar'); + $version = array( + 'PHP Version' => phpversion(), + 'phar.phar version' => '$Id$', + 'Phar EXT version' => $use_ext ? phpversion('phar') : 'Not available', + 'Phar API version' => Phar::apiVersion(), + 'Phar-based phar archives' => true, + 'Tar-based phar archives' => $use_ext, + 'ZIP-based phar archives' => $use_ext, + 'gzip compression' => extension_loaded('zlib'), + 'bzip2 compression' => extension_loaded('bz2'), + 'supported signatures' => $use_ext ? join(', ', Phar::getSupportedSignatures()) : '', + ); + $klen = 0; + foreach($version as $k => $v) + { + $klen = max($klen, strlen($k)); + } + ++$klen; + foreach($version as $k => $v) { + if (is_bool($v)) { + $v = $v ? 'enabled' : 'disabled'; + } + printf("%-${klen}s %s\n", $k.':', $v); + } + } + // }}} } // }}} ?> diff --git a/ext/phar/tests/003.phpt b/ext/phar/tests/003.phpt index fcc95a848155..6d57ebd40047 100644 --- a/ext/phar/tests/003.phpt +++ b/ext/phar/tests/003.phpt @@ -6,8 +6,8 @@ Phar::canCompress --EXPECT-- bool(true) diff --git a/ext/phar/tests/018.phpt b/ext/phar/tests/018.phpt index 0f97b361d5bc..2b61b7e739bf 100644 --- a/ext/phar/tests/018.phpt +++ b/ext/phar/tests/018.phpt @@ -22,8 +22,8 @@ include 'files/phar_test.inc'; include $fname; $dir = opendir('phar://hio/'); while (false !== ($a = readdir($dir))) { - var_dump($a); - var_dump(is_dir('phar://hio/' . $a)); + var_dump($a); + var_dump(is_dir('phar://hio/' . $a)); } ?> --CLEAN-- diff --git a/ext/phar/tests/019.phpt b/ext/phar/tests/019.phpt index 44e2580f18c3..92f7b51f88ba 100644 --- a/ext/phar/tests/019.phpt +++ b/ext/phar/tests/019.phpt @@ -25,10 +25,10 @@ include $fname; $dir = opendir('phar://hio/b'); if ($dir) { - while (false !== ($a = readdir($dir))) { - var_dump($a); - var_dump(is_dir('phar://hio/b/' . $a)); - } + while (false !== ($a = readdir($dir))) { + var_dump($a); + var_dump(is_dir('phar://hio/b/' . $a)); + } } ?> diff --git a/ext/phar/tests/019b.phpt b/ext/phar/tests/019b.phpt index 99415eaa95af..34404966b998 100644 --- a/ext/phar/tests/019b.phpt +++ b/ext/phar/tests/019b.phpt @@ -24,21 +24,21 @@ include $fname; function dump($phar, $base) { - var_dump($phar . $base); - $dir = opendir($phar . $base); - if ($base == '/') - { - $base = ''; - } - while (false !== ($entry = readdir($dir))) { - $entry = $base . '/' . $entry; - var_dump($entry); - var_dump(is_dir($phar . $entry)); - if (is_dir($phar . $entry)) - { - dump($phar, $entry); - } - } + var_dump($phar . $base); + $dir = opendir($phar . $base); + if ($base == '/') + { + $base = ''; + } + while (false !== ($entry = readdir($dir))) { + $entry = $base . '/' . $entry; + var_dump($entry); + var_dump(is_dir($phar . $entry)); + if (is_dir($phar . $entry)) + { + dump($phar, $entry); + } + } } dump('phar://hio', '/'); diff --git a/ext/phar/tests/019c.phpt b/ext/phar/tests/019c.phpt index 5eaac90ac75e..460b8f53976d 100644 --- a/ext/phar/tests/019c.phpt +++ b/ext/phar/tests/019c.phpt @@ -24,25 +24,25 @@ include $fname; function dump($phar, $base) { - var_dump($phar . $base); - $dir = opendir($phar . $base); - if ($base == '/') - { - $base = ''; - } - while (false !== ($entry = readdir($dir))) { - $entry = $base . '/' . $entry; - var_dump($entry); - var_dump(is_dir($phar . $entry)); - if (is_dir($phar . $entry)) - { - dump($phar, $entry); - } - else - { - var_dump(file_get_contents($phar . $entry)); - } - } + var_dump($phar . $base); + $dir = opendir($phar . $base); + if ($base == '/') + { + $base = ''; + } + while (false !== ($entry = readdir($dir))) { + $entry = $base . '/' . $entry; + var_dump($entry); + var_dump(is_dir($phar . $entry)); + if (is_dir($phar . $entry)) + { + dump($phar, $entry); + } + else + { + var_dump(file_get_contents($phar . $entry)); + } + } } dump('phar://hio', '/'); diff --git a/ext/phar/tests/024-opcache-win32.phpt b/ext/phar/tests/024-opcache-win32.phpt index afcd93e5f5b5..b9d80929cc8b 100644 --- a/ext/phar/tests/024-opcache-win32.phpt +++ b/ext/phar/tests/024-opcache-win32.phpt @@ -39,15 +39,15 @@ include $pname . '/b/c.php'; $cache_dir = ini_get("opcache.file_cache"); if (is_dir($cache_dir)) { - $it = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST - ); - foreach ($it as $fi) { - $fn = ($fi->isDir() ? 'rmdir' : 'unlink'); - $fn($fi->getRealPath()); - } - - rmdir($cache_dir); + $it = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST + ); + foreach ($it as $fi) { + $fn = ($fi->isDir() ? 'rmdir' : 'unlink'); + $fn($fi->getRealPath()); + } + + rmdir($cache_dir); } ?> diff --git a/ext/phar/tests/027.phpt b/ext/phar/tests/027.phpt index 23e51db0df76..4820c74c2e2d 100644 --- a/ext/phar/tests/027.phpt +++ b/ext/phar/tests/027.phpt @@ -23,21 +23,21 @@ include 'files/phar_test.inc'; function dump($phar, $base) { - var_dump(str_replace(__DIR__, '*', $phar) . $base); - $dir = opendir($phar . $base); - if ($base == '/') - { - $base = ''; - } - while (false !== ($entry = readdir($dir))) { - $entry = $base . '/' . $entry; - var_dump($entry); - var_dump(is_dir($phar . $entry)); - if (is_dir($phar . $entry)) - { - dump($phar, $entry); - } - } + var_dump(str_replace(__DIR__, '*', $phar) . $base); + $dir = opendir($phar . $base); + if ($base == '/') + { + $base = ''; + } + while (false !== ($entry = readdir($dir))) { + $entry = $base . '/' . $entry; + var_dump($entry); + var_dump(is_dir($phar . $entry)); + if (is_dir($phar . $entry)) + { + dump($phar, $entry); + } + } } dump($pname, '/'); diff --git a/ext/phar/tests/029.phpt b/ext/phar/tests/029.phpt index d87064685ce5..470516ef7631 100644 --- a/ext/phar/tests/029.phpt +++ b/ext/phar/tests/029.phpt @@ -29,11 +29,11 @@ var_dump(Phar::loadPhar($fname1, 'copy')); $a = new Phar($fname1); try { - var_dump(Phar::loadPhar($fname2, 'copy')); + var_dump(Phar::loadPhar($fname2, 'copy')); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/033a.phpt b/ext/phar/tests/033a.phpt index 6b5956a714db..3186c1853bd4 100644 --- a/ext/phar/tests/033a.phpt +++ b/ext/phar/tests/033a.phpt @@ -15,14 +15,14 @@ $files = array(); $files['a.php'] = ''; include 'files/phar_test.inc'; try { - $a = new Phar($fname); - var_dump($a['a.php']->isExecutable()); - $a['a.php']->chmod(0777); - var_dump($a['a.php']->isExecutable()); - $a['a.php']->chmod(0666); - var_dump($a['a.php']->isExecutable()); + $a = new Phar($fname); + var_dump($a['a.php']->isExecutable()); + $a['a.php']->chmod(0777); + var_dump($a['a.php']->isExecutable()); + $a['a.php']->chmod(0666); + var_dump($a['a.php']->isExecutable()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/badparameters.phpt b/ext/phar/tests/badparameters.phpt index 62c3be2e23a9..3ee49890c91c 100644 --- a/ext/phar/tests/badparameters.phpt +++ b/ext/phar/tests/badparameters.phpt @@ -29,12 +29,12 @@ try { echo $e->getMessage(), "\n"; } try { - $a = new Phar(array()); + $a = new Phar(array()); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } try { - $a = new Phar(__DIR__ . '/files/frontcontroller10.phar'); + $a = new Phar(__DIR__ . '/files/frontcontroller10.phar'); } catch (PharException $e) { echo $e->getMessage(), "\n"; } @@ -49,12 +49,12 @@ try { echo $e->getMessage(), "\n"; } try { - $b = new PharData(__DIR__ . '/whatever.tar'); + $b = new PharData(__DIR__ . '/whatever.tar'); } catch (PharException $e) { echo $e->getMessage(), "\n"; } try { - $c = new PharData(__DIR__ . '/whatever.zip'); + $c = new PharData(__DIR__ . '/whatever.zip'); } catch (PharException $e) { echo $e->getMessage(), "\n"; } diff --git a/ext/phar/tests/bug13727.phpt b/ext/phar/tests/bug13727.phpt index 345968cdbbc5..ea406a4d8f09 100644 --- a/ext/phar/tests/bug13727.phpt +++ b/ext/phar/tests/bug13727.phpt @@ -14,11 +14,11 @@ $pname = 'phar://' . $fname; $pArchive="DataArchive.phar"; $p = new Phar($fname, 0, $pArchive); for ($i = 0; $i < 4*1024; $i++){ - echo("$i\n"); - if (!is_dir($fileDir="$dirName/test_data")) - mkdir($fileDir, 0777, true); - file_put_contents("$fileDir/$i", ""); - $p->addFile("$fileDir/$i", "$dirName"); + echo("$i\n"); + if (!is_dir($fileDir="$dirName/test_data")) + mkdir($fileDir, 0777, true); + file_put_contents("$fileDir/$i", ""); + $p->addFile("$fileDir/$i", "$dirName"); } echo("\n Written Files($i)\n"); ?> diff --git a/ext/phar/tests/bug13786.phpt b/ext/phar/tests/bug13786.phpt index 0ef1c33037fd..76f05ef1fc56 100644 --- a/ext/phar/tests/bug13786.phpt +++ b/ext/phar/tests/bug13786.phpt @@ -10,13 +10,13 @@ phar.readonly=0 try { for ($i = 0; $i < 2; $i++) { - $fname = "DataArchive.phar"; - $path = __DIR__ . DIRECTORY_SEPARATOR . $fname; - $phar = new Phar($path); - $phar->addFromString($i, "file $i in $fname"); - var_dump(file_get_contents($phar[$i])); - unset($phar); - unlink($path); + $fname = "DataArchive.phar"; + $path = __DIR__ . DIRECTORY_SEPARATOR . $fname; + $phar = new Phar($path); + $phar->addFromString($i, "file $i in $fname"); + var_dump(file_get_contents($phar[$i])); + unset($phar); + unlink($path); } echo("\nWritten files: $i\n"); diff --git a/ext/phar/tests/bug45218_SLOWTEST.phpt b/ext/phar/tests/bug45218_SLOWTEST.phpt index 1282ac22e96e..aee2aae78868 100644 --- a/ext/phar/tests/bug45218_SLOWTEST.phpt +++ b/ext/phar/tests/bug45218_SLOWTEST.phpt @@ -39,16 +39,16 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar($fname); - $ret = $phar->buildFromIterator(new myIterator); - foreach ($ret as $a => $val) { - $ret[$a] = str_replace(dirname($fname2) . DIRECTORY_SEPARATOR, '*', $val); - } - var_dump($ret); + chdir(__DIR__); + $phar = new Phar($fname); + $ret = $phar->buildFromIterator(new myIterator); + foreach ($ret as $a => $val) { + $ret[$a] = str_replace(dirname($fname2) . DIRECTORY_SEPARATOR, '*', $val); + } + var_dump($ret); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/bug46032.phpt b/ext/phar/tests/bug46032.phpt index a20e95d3ed29..8f21bf4d5901 100644 --- a/ext/phar/tests/bug46032.phpt +++ b/ext/phar/tests/bug46032.phpt @@ -9,13 +9,13 @@ Phar: bug #46032: PharData::__construct wrong memory read $a = __DIR__ .'/mytest'; try { - new phar($a); + new phar($a); } catch (exception $e) { } var_dump($a); try { - new phar($a); + new phar($a); } catch (exception $e) { } var_dump($a); diff --git a/ext/phar/tests/bug48377.2.phpt b/ext/phar/tests/bug48377.2.phpt index 04df8940f23e..cdc8a42953dd 100644 --- a/ext/phar/tests/bug48377.2.phpt +++ b/ext/phar/tests/bug48377.2.phpt @@ -12,9 +12,9 @@ $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.zip'; $phar = new PharData($fname); $phar['x'] = 'hi'; try { - $phar->convertToData(Phar::ZIP, Phar::NONE, 'phar.zip'); + $phar->convertToData(Phar::ZIP, Phar::NONE, 'phar.zip'); } catch (BadMethodCallException $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/bug48377.phpt b/ext/phar/tests/bug48377.phpt index ec52c1a0f52a..338d98a52f67 100644 --- a/ext/phar/tests/bug48377.phpt +++ b/ext/phar/tests/bug48377.phpt @@ -15,9 +15,9 @@ touch($fname2); $phar = new Phar($fname, 0, 'a.phar'); $phar['x'] = 'hi'; try { - $phar->convertToData(Phar::ZIP, Phar::NONE, 'zip'); + $phar->convertToData(Phar::ZIP, Phar::NONE, 'zip'); } catch (BadMethodCallException $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/bug54395.phpt b/ext/phar/tests/bug54395.phpt index a3d90a1b3e8c..fb041bc6ff5b 100644 --- a/ext/phar/tests/bug54395.phpt +++ b/ext/phar/tests/bug54395.phpt @@ -6,9 +6,9 @@ Bug #54395 (Phar::mount() crashes when calling with wrong parameters) getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/phar/tests/bug60261.phpt b/ext/phar/tests/bug60261.phpt index 31baa82394da..7f32bf64822c 100644 --- a/ext/phar/tests/bug60261.phpt +++ b/ext/phar/tests/bug60261.phpt @@ -7,9 +7,9 @@ Bug #60261 (phar dos null pointer) try { $nx = new Phar(); - $nx->getLinkTarget(); + $nx->getLinkTarget(); } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/ext/phar/tests/bug64931/bug64931.phpt b/ext/phar/tests/bug64931/bug64931.phpt index 0de8d43e786d..6bf3bea7c319 100644 --- a/ext/phar/tests/bug64931/bug64931.phpt +++ b/ext/phar/tests/bug64931/bug64931.phpt @@ -13,33 +13,33 @@ echo "Test\n"; $phar = new Phar(__DIR__."/bug64931.phar"); $phar->addFile(__DIR__."/src/.pharignore", ".pharignore"); try { - $phar->addFile(__DIR__."/src/.pharignore", ".phar/gotcha"); + $phar->addFile(__DIR__."/src/.pharignore", ".phar/gotcha"); } catch (Exception $e) { - echo "CAUGHT: ". $e->getMessage() ."\n"; + echo "CAUGHT: ". $e->getMessage() ."\n"; } try { - $phar->addFromString(".phar", "gotcha"); + $phar->addFromString(".phar", "gotcha"); } catch (Exception $e) { - echo "CAUGHT: ". $e->getMessage() ."\n"; + echo "CAUGHT: ". $e->getMessage() ."\n"; } try { - $phar->addFromString(".phar//", "gotcha"); + $phar->addFromString(".phar//", "gotcha"); } catch (Exception $e) { - echo "CAUGHT: ". $e->getMessage() ."\n"; + echo "CAUGHT: ". $e->getMessage() ."\n"; } try { - $phar->addFromString(".phar\\", "gotcha"); + $phar->addFromString(".phar\\", "gotcha"); } catch (Exception $e) { - echo "CAUGHT: ". $e->getMessage() ."\n"; + echo "CAUGHT: ". $e->getMessage() ."\n"; } try { - $phar->addFromString(".phar\0", "gotcha"); + $phar->addFromString(".phar\0", "gotcha"); } catch (TypeError $e) { - echo "CAUGHT: ". $e->getMessage() ."\n"; + echo "CAUGHT: ". $e->getMessage() ."\n"; } ?> diff --git a/ext/phar/tests/bug65028.phpt b/ext/phar/tests/bug65028.phpt index 7d24ead69d78..106b3ad6336a 100644 --- a/ext/phar/tests/bug65028.phpt +++ b/ext/phar/tests/bug65028.phpt @@ -8,120 +8,120 @@ phar.readonly=0 addFromString($file, ""); + $phar->addFromString($file, ""); } // Copy phar @@ -138,12 +138,12 @@ copy(__DIR__ . "/bug65028.phar", __DIR__ . "/bug65028-copy.phar"); // Open phar try { - $phar = new Phar(__DIR__ . "/bug65028-copy.phar"); - echo "No exception thrown.\n"; + $phar = new Phar(__DIR__ . "/bug65028-copy.phar"); + echo "No exception thrown.\n"; } catch(UnexpectedValueException $ex) { - echo "Exception thrown: " . $ex->getMessage() . "\n"; + echo "Exception thrown: " . $ex->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/bug69324.phpt b/ext/phar/tests/bug69324.phpt index b3311c865122..1735fc8afe32 100644 --- a/ext/phar/tests/bug69324.phpt +++ b/ext/phar/tests/bug69324.phpt @@ -11,7 +11,7 @@ $p = new Phar(__DIR__.'/bug69324.phar', 0); $meta=$p->getMetadata(); var_dump($meta); } catch(Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } --EXPECTF-- internal corruption of phar "%s" (truncated manifest entry) diff --git a/ext/phar/tests/bug69441.phpt b/ext/phar/tests/bug69441.phpt index b08d0158433f..4dd136c506c9 100644 --- a/ext/phar/tests/bug69441.phpt +++ b/ext/phar/tests/bug69441.phpt @@ -8,7 +8,7 @@ $fname = __DIR__ . '/bug69441.phar'; try { $r = new Phar($fname, 0); } catch(UnexpectedValueException $e) { - echo $e; + echo $e; } ?> diff --git a/ext/phar/tests/bug69453.phpt b/ext/phar/tests/bug69453.phpt index eb7d5f248fc0..18b4a3949fa1 100644 --- a/ext/phar/tests/bug69453.phpt +++ b/ext/phar/tests/bug69453.phpt @@ -8,7 +8,7 @@ $fname = __DIR__ . '/bug69453.tar.phar'; try { $r = new Phar($fname, 0); } catch(UnexpectedValueException $e) { - echo $e; + echo $e; } ?> diff --git a/ext/phar/tests/bug69720.phpt b/ext/phar/tests/bug69720.phpt index 5c57d6360ae0..cdb4741ff834 100644 --- a/ext/phar/tests/bug69720.phpt +++ b/ext/phar/tests/bug69720.phpt @@ -8,13 +8,13 @@ try { // open an existing phar $p = new Phar(__DIR__."/bug69720.phar",0); // Phar extends SPL's DirectoryIterator class - echo $p->getMetadata(); + echo $p->getMetadata(); foreach (new RecursiveIteratorIterator($p) as $file) { // $file is a PharFileInfo class, and inherits from SplFileInfo - $temp=""; + $temp=""; $temp= $file->getFileName() . "\n"; $temp.=file_get_contents($file->getPathName()) . "\n"; // display contents - var_dump($file->getMetadata()); + var_dump($file->getMetadata()); } } catch (Exception $e) { diff --git a/ext/phar/tests/bug71498.phpt b/ext/phar/tests/bug71498.phpt index 4157ac20b680..af24724e5c09 100644 --- a/ext/phar/tests/bug71498.phpt +++ b/ext/phar/tests/bug71498.phpt @@ -7,7 +7,7 @@ Phar: bug #71498: Out-of-Bound Read in phar_parse_zipfile() try { $p = new PharData(__DIR__."/bug71498.zip"); } catch(UnexpectedValueException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/phar/tests/bug72321.phpt b/ext/phar/tests/bug72321.phpt index 6e63da42d93c..05413a0295f4 100644 --- a/ext/phar/tests/bug72321.phpt +++ b/ext/phar/tests/bug72321.phpt @@ -12,7 +12,7 @@ $phar = new PharData("72321_2.zip"); try { $phar->extractTo("test72321"); } catch(PharException $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } ?> DONE diff --git a/ext/phar/tests/bug72928.phpt b/ext/phar/tests/bug72928.phpt index 1277e8871105..6d0e0ff62384 100644 --- a/ext/phar/tests/bug72928.phpt +++ b/ext/phar/tests/bug72928.phpt @@ -9,7 +9,7 @@ try { $phar = new PharData('bug72928.zip'); var_dump($phar); } catch(UnexpectedValueException $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } ?> DONE diff --git a/ext/phar/tests/bug73035.phpt b/ext/phar/tests/bug73035.phpt index ffdd36c52e5b..fefd0583bd4d 100644 --- a/ext/phar/tests/bug73035.phpt +++ b/ext/phar/tests/bug73035.phpt @@ -9,7 +9,7 @@ try { $phar = new PharData('bug73035.tar'); var_dump($phar); } catch(UnexpectedValueException $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } ?> DONE diff --git a/ext/phar/tests/bug73764.phpt b/ext/phar/tests/bug73764.phpt index baff0832654a..fdabd78bbfad 100644 --- a/ext/phar/tests/bug73764.phpt +++ b/ext/phar/tests/bug73764.phpt @@ -9,7 +9,7 @@ try { $p = Phar::LoadPhar('bug73764.phar', 'alias.phar'); echo "OK\n"; } catch(PharException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECTF-- diff --git a/ext/phar/tests/bug73768.phpt b/ext/phar/tests/bug73768.phpt index 3062268b80db..cdaa6fa723fd 100644 --- a/ext/phar/tests/bug73768.phpt +++ b/ext/phar/tests/bug73768.phpt @@ -9,7 +9,7 @@ try { $p = Phar::LoadPhar('bug73768.phar', 'alias.phar'); echo "OK\n"; } catch(PharException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECTF-- diff --git a/ext/phar/tests/bug77022.phpt b/ext/phar/tests/bug77022.phpt index c78d1bdafda5..c287bb339f09 100644 --- a/ext/phar/tests/bug77022.phpt +++ b/ext/phar/tests/bug77022.phpt @@ -14,16 +14,16 @@ $sFile = tempnam(__DIR__, 'test77022'); var_dump(decoct(stat($sFile)['mode'])); foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) { - clearstatcache(); - $phar = new PharData(__DIR__ . '/test77022.' . $ext, null, null, $mode); - $phar->addFile($sFile, 'test-file-phar'); - $phar->addFromString("test-from-string", 'test-file-phar'); - $phar->extractTo(__DIR__); - var_dump(decoct(stat(__DIR__ . '/test-file-phar')['mode'])); - var_dump(decoct(stat(__DIR__ . '/test-from-string')['mode'])); - unlink(__DIR__ . '/test-file-phar'); - unlink(__DIR__ . '/test-from-string'); - unlink(__DIR__ . '/test77022.' . $ext); + clearstatcache(); + $phar = new PharData(__DIR__ . '/test77022.' . $ext, null, null, $mode); + $phar->addFile($sFile, 'test-file-phar'); + $phar->addFromString("test-from-string", 'test-file-phar'); + $phar->extractTo(__DIR__); + var_dump(decoct(stat(__DIR__ . '/test-file-phar')['mode'])); + var_dump(decoct(stat(__DIR__ . '/test-from-string')['mode'])); + unlink(__DIR__ . '/test-file-phar'); + unlink(__DIR__ . '/test-from-string'); + unlink(__DIR__ . '/test77022.' . $ext); } unlink($sFile); ?> diff --git a/ext/phar/tests/bug77143.phpt b/ext/phar/tests/bug77143.phpt index f9f80fc4f460..c19c9ed61057 100644 --- a/ext/phar/tests/bug77143.phpt +++ b/ext/phar/tests/bug77143.phpt @@ -11,7 +11,7 @@ try { var_dump(new Phar('bug77143.phar',0,'project.phar')); echo "OK\n"; } catch(UnexpectedValueException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECTF-- diff --git a/ext/phar/tests/bug77247.phpt b/ext/phar/tests/bug77247.phpt index 588975f9f2f8..3f7949293d1b 100644 --- a/ext/phar/tests/bug77247.phpt +++ b/ext/phar/tests/bug77247.phpt @@ -7,7 +7,7 @@ PHP bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext) try { var_dump(new Phar('a/.b', 0,'test.phar')); } catch(UnexpectedValueException $e) { - echo "OK"; + echo "OK"; } ?> --EXPECT-- diff --git a/ext/phar/tests/cache_list/files/blog.phar.inc b/ext/phar/tests/cache_list/files/blog.phar.inc index 62d86c5c3f03..a73f0c89ce21 100644 --- a/ext/phar/tests/cache_list/files/blog.phar.inc +++ b/ext/phar/tests/cache_list/files/blog.phar.inc @@ -10,8 +10,8 @@ $phar->setStub(''); $phar['index.php'] = ''; diff --git a/ext/phar/tests/cache_list/files/phar_oo_test.inc b/ext/phar/tests/cache_list/files/phar_oo_test.inc index 0691e4dc804b..38443add613a 100644 --- a/ext/phar/tests/cache_list/files/phar_oo_test.inc +++ b/ext/phar/tests/cache_list/files/phar_oo_test.inc @@ -12,23 +12,23 @@ if (!isset($pharconfig)) $pharconfig = 0; switch($pharconfig) { - default: - case 0: - $files['a.php'] = ''; - $files['b.php'] = ''; - $files['b/c.php'] = ''; - $files['b/d.php'] = ''; - $files['e.php'] = ''; - break; - case 1: - $files['a.csv'] =<< $cont) { - global $gflags, $files; - - $comp = NULL; - $crc32= NULL; - $clen = NULL; - $ulen = NULL; - $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006); - $flags= 0; - $perm = 0x000001B6; - $meta = NULL; - - // overwrite if array - if (is_array($cont)) - { - foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what) - { - if (isset($cont[$what])) - { - $$what = $cont[$what]; - } - } - } - - // create if not yet done - 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 (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; - - // globals - $gflags |= $flags; - $files[$name] = $comp; + global $gflags, $files; + + $comp = NULL; + $crc32= NULL; + $clen = NULL; + $ulen = NULL; + $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006); + $flags= 0; + $perm = 0x000001B6; + $meta = NULL; + + // overwrite if array + if (is_array($cont)) + { + foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what) + { + if (isset($cont[$what])) + { + $$what = $cont[$what]; + } + } + } + + // create if not yet done + 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 (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; + + // globals + $gflags |= $flags; + $files[$name] = $comp; } if (!isset($alias)) $alias = 'hio'; @@ -56,21 +56,21 @@ $file .= pack('V', strlen($manifest)) . $manifest; foreach($files as $cont) { - $file .= (binary)$cont; + $file .= (binary)$cont; } file_put_contents($fname, $file); if (@$gzip) { - $fp = gzopen($fname, 'w'); - fwrite($fp, $file); - fclose($fp); + $fp = gzopen($fname, 'w'); + fwrite($fp, $file); + fclose($fp); } if (@$bz2) { - $fp = bzopen($fname, 'w'); - fwrite($fp, $file); - fclose($fp); + $fp = bzopen($fname, 'w'); + fwrite($fp, $file); + fclose($fp); } ?> diff --git a/ext/phar/tests/cache_list/files/write5.phar.inc b/ext/phar/tests/cache_list/files/write5.phar.inc index 5e7b9bb8862f..1cb6b4e4c06d 100644 --- a/ext/phar/tests/cache_list/files/write5.phar.inc +++ b/ext/phar/tests/cache_list/files/write5.phar.inc @@ -16,11 +16,11 @@ var_dump($arr); $phar2 = new Phar(__FILE__); $arr = array(); foreach ($phar2 as $name => $file) { - $arr[$name] = $file->getContent(); + $arr[$name] = $file->getContent(); } ksort($arr); foreach ($arr as $name => $content) { - echo $name, " ", $content; + echo $name, " ", $content; } echo "ok\n"; __HALT_COMPILER(); diff --git a/ext/phar/tests/cache_list/files/write6.phar.inc b/ext/phar/tests/cache_list/files/write6.phar.inc index 3ba5db3c544d..543568f5ee57 100644 --- a/ext/phar/tests/cache_list/files/write6.phar.inc +++ b/ext/phar/tests/cache_list/files/write6.phar.inc @@ -17,11 +17,11 @@ var_dump($arr); $phar2 = new Phar(__FILE__); $arr = array(); foreach ($phar2 as $name => $file) { - $arr[$name] = $file->getContent(); + $arr[$name] = $file->getContent(); } ksort($arr); foreach ($arr as $name => $content) { - echo $name, " ", $content; + echo $name, " ", $content; } echo "ok\n"; __HALT_COMPILER(); diff --git a/ext/phar/tests/cached_manifest_1.phpt b/ext/phar/tests/cached_manifest_1.phpt index 55669b6956f9..f3d065e56fad 100644 --- a/ext/phar/tests/cached_manifest_1.phpt +++ b/ext/phar/tests/cached_manifest_1.phpt @@ -15,7 +15,7 @@ while (false !== ($b = readdir($a))) { var_dump($b); } foreach (new RecursiveIteratorIterator(new Phar($pname)) as $f) { - var_dump($f->getPathName()); + var_dump($f->getPathName()); } var_dump(is_dir($pname . '/b')); var_dump(is_dir($pname . '/d')); diff --git a/ext/phar/tests/create_new_phar.phpt b/ext/phar/tests/create_new_phar.phpt index 078d75491a0f..73aca42528ee 100644 --- a/ext/phar/tests/create_new_phar.phpt +++ b/ext/phar/tests/create_new_phar.phpt @@ -9,12 +9,12 @@ phar.require_hash=1 diff --git a/ext/phar/tests/create_new_phar_b.phpt b/ext/phar/tests/create_new_phar_b.phpt index 3dc142b94c88..3a531fd1e4e6 100644 --- a/ext/phar/tests/create_new_phar_b.phpt +++ b/ext/phar/tests/create_new_phar_b.phpt @@ -9,7 +9,7 @@ phar.require_hash=1 diff --git a/ext/phar/tests/create_new_phar_c.phpt b/ext/phar/tests/create_new_phar_c.phpt index dc52dbf45b1d..547544d758e6 100644 --- a/ext/phar/tests/create_new_phar_c.phpt +++ b/ext/phar/tests/create_new_phar_c.phpt @@ -9,7 +9,7 @@ phar.require_hash=1 getMessage() . "\n"; - } + try + { + $phar[$check] = 'error'; + } + catch (TypeError $e) + { + echo 'Exception: ' . $e->getMessage() . "\n"; + } } ?> diff --git a/ext/phar/tests/files/blog.phar.inc b/ext/phar/tests/files/blog.phar.inc index c2599abef8fa..a3b4a82f20c9 100644 --- a/ext/phar/tests/files/blog.phar.inc +++ b/ext/phar/tests/files/blog.phar.inc @@ -12,8 +12,8 @@ if(file_exists(dirname(__FILE__) . "/files/config.xml")) { Phar::webPhar("blog", "index.php"); __HALT_COMPILER(); ?>'); $phar['index.php'] = ''; diff --git a/ext/phar/tests/files/phar_oo_test.inc b/ext/phar/tests/files/phar_oo_test.inc index 3883d494c15a..a6f4cee5ee65 100644 --- a/ext/phar/tests/files/phar_oo_test.inc +++ b/ext/phar/tests/files/phar_oo_test.inc @@ -13,23 +13,23 @@ if (!isset($pharconfig)) $pharconfig = 0; switch($pharconfig) { - default: - case 0: - $files['a.php'] = ''; - $files['b.php'] = ''; - $files['b/c.php'] = ''; - $files['b/d.php'] = ''; - $files['e.php'] = ''; - break; - case 1: - $files['a.csv'] =<< $cont) { - global $gflags, $files; - - $comp = NULL; - $crc32= NULL; - $clen = NULL; - $ulen = NULL; - $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006); - $flags= 0; - $perm = 0x000001B6; - $meta = NULL; - - // overwrite if array - if (is_array($cont)) - { - foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what) - { - if (isset($cont[$what])) - { - $$what = $cont[$what]; - } - } - } - - // create if not yet done - 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 (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; - - // globals - $gflags |= $flags; - $files[$name] = $comp; + global $gflags, $files; + + $comp = NULL; + $crc32= NULL; + $clen = NULL; + $ulen = NULL; + $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006); + $flags= 0; + $perm = 0x000001B6; + $meta = NULL; + + // overwrite if array + if (is_array($cont)) + { + foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what) + { + if (isset($cont[$what])) + { + $$what = $cont[$what]; + } + } + } + + // create if not yet done + 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 (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; + + // globals + $gflags |= $flags; + $files[$name] = $comp; } if (!isset($alias)) $alias = 'hio'; @@ -56,21 +56,21 @@ $file .= pack('V', strlen($manifest)) . $manifest; foreach($files as $cont) { - $file .= (binary)$cont; + $file .= (binary)$cont; } file_put_contents($fname, $file); if (@$gzip) { - $fp = gzopen($fname, 'w'); - fwrite($fp, $file); - fclose($fp); + $fp = gzopen($fname, 'w'); + fwrite($fp, $file); + fclose($fp); } if (@$bz2) { - $fp = bzopen($fname, 'w'); - fwrite($fp, $file); - fclose($fp); + $fp = bzopen($fname, 'w'); + fwrite($fp, $file); + fclose($fp); } ?> diff --git a/ext/phar/tests/invalid_alias.phpt b/ext/phar/tests/invalid_alias.phpt index 255bef52d7c8..9039b8aa0d64 100644 --- a/ext/phar/tests/invalid_alias.phpt +++ b/ext/phar/tests/invalid_alias.phpt @@ -10,26 +10,26 @@ $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar'; $p = new Phar($fname); try { - $p->setAlias('hi/'); + $p->setAlias('hi/'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p->setAlias('hi\\l'); + $p->setAlias('hi\\l'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p->setAlias('hil;'); + $p->setAlias('hil;'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p->setAlias(':hil'); + $p->setAlias(':hil'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/invalid_setstubalias.phpt b/ext/phar/tests/invalid_setstubalias.phpt index 545666270974..df1b8c90c91f 100644 --- a/ext/phar/tests/invalid_setstubalias.phpt +++ b/ext/phar/tests/invalid_setstubalias.phpt @@ -11,25 +11,25 @@ $fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip'; $p = new Phar($fname); try { - $p['.phar/stub.php'] = 'hi'; + $p['.phar/stub.php'] = 'hi'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p['.phar/alias.txt'] = 'hi'; + $p['.phar/alias.txt'] = 'hi'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $p = new Phar($fname2); try { - $p['.phar/stub.php'] = 'hi'; + $p['.phar/stub.php'] = 'hi'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p['.phar/alias.txt'] = 'hi'; + $p['.phar/alias.txt'] = 'hi'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/metadata_read.phpt b/ext/phar/tests/metadata_read.phpt index f67bf692d836..5450dee801de 100644 --- a/ext/phar/tests/metadata_read.phpt +++ b/ext/phar/tests/metadata_read.phpt @@ -20,18 +20,18 @@ $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); include 'files/phar_test.inc'; foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } $phar = new Phar($fname); foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } unset($phar); foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } ?> --CLEAN-- diff --git a/ext/phar/tests/metadata_write.phpt b/ext/phar/tests/metadata_write.phpt index fefa2bc0c0a4..56d2956aab80 100644 --- a/ext/phar/tests/metadata_write.phpt +++ b/ext/phar/tests/metadata_write.phpt @@ -21,7 +21,7 @@ $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); include 'files/phar_test.inc'; foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } $phar = new Phar($fname); @@ -31,13 +31,13 @@ $phar['c']->setMetadata(array(25, 'foo'=>'bar')); $phar['d']->setMetadata(true); foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } unset($phar); foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } ?> --CLEAN-- diff --git a/ext/phar/tests/metadata_write_commit.phpt b/ext/phar/tests/metadata_write_commit.phpt index 02fceee29dd8..2fdd6fd88475 100644 --- a/ext/phar/tests/metadata_write_commit.phpt +++ b/ext/phar/tests/metadata_write_commit.phpt @@ -21,7 +21,7 @@ $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); include 'files/phar_test.inc'; foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } $phar = new Phar($fname); @@ -32,7 +32,7 @@ $phar['c']->setMetadata(array(25, 'foo'=>'bar')); $phar['d']->setMetadata(true); foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } $phar->stopBuffering(); @@ -41,11 +41,11 @@ unset($phar); $phar = new Phar($fname); foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } ?> --CLEAN-- diff --git a/ext/phar/tests/mounteddir.phpt b/ext/phar/tests/mounteddir.phpt index 5e2e94ad71a5..fe28a56919fc 100644 --- a/ext/phar/tests/mounteddir.phpt +++ b/ext/phar/tests/mounteddir.phpt @@ -47,19 +47,19 @@ include $fname; $a = opendir($pname . '/testit'); $out = array(); while (false !== ($b = readdir($a))) { - $out[] = $b; + $out[] = $b; } sort($out); foreach ($out as $b) { - echo "$b\n"; + echo "$b\n"; } $out = array(); foreach (new Phar($pname . '/testit') as $b) { - $out[] = $b->getPathName(); + $out[] = $b->getPathName(); } sort($out); foreach ($out as $b) { - echo "$b\n"; + echo "$b\n"; } try { Phar::mount($pname . '/testit', 'another\\..\\mistake'); diff --git a/ext/phar/tests/opendir.phpt b/ext/phar/tests/opendir.phpt index f3f437d67ce3..3bccb5c4a22f 100644 --- a/ext/phar/tests/opendir.phpt +++ b/ext/phar/tests/opendir.phpt @@ -12,9 +12,9 @@ $a = new Phar($fname); $a['index.php'] = ''; $a['dir/file1.txt'] = 'hi'; diff --git a/ext/phar/tests/phar_buildfromdirectory1.phpt b/ext/phar/tests/phar_buildfromdirectory1.phpt index 71afd1647b46..62a3689072da 100644 --- a/ext/phar/tests/phar_buildfromdirectory1.phpt +++ b/ext/phar/tests/phar_buildfromdirectory1.phpt @@ -9,11 +9,11 @@ phar.readonly=0 buildFromDirectory(1); + ini_set('phar.readonly', 1); + $phar->buildFromDirectory(1); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromdirectory2-win.phpt b/ext/phar/tests/phar_buildfromdirectory2-win.phpt index be8ee60b5261..e67d03638805 100644 --- a/ext/phar/tests/phar_buildfromdirectory2-win.phpt +++ b/ext/phar/tests/phar_buildfromdirectory2-win.phpt @@ -11,11 +11,11 @@ phar.readonly=0 --FILE-- buildFromDirectory(1); + $phar = new Phar(__DIR__ . '/buildfromdirectory2.phar'); + $phar->buildFromDirectory(1); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromdirectory2.phpt b/ext/phar/tests/phar_buildfromdirectory2.phpt index e92b94eb1b3c..d02d6146d64c 100644 --- a/ext/phar/tests/phar_buildfromdirectory2.phpt +++ b/ext/phar/tests/phar_buildfromdirectory2.phpt @@ -11,11 +11,11 @@ phar.readonly=0 --FILE-- buildFromDirectory(1); + $phar = new Phar(__DIR__ . '/buildfromdirectory2.phar'); + $phar->buildFromDirectory(1); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromdirectory4.phpt b/ext/phar/tests/phar_buildfromdirectory4.phpt index 78bc0f2f8bc3..a492592c5581 100644 --- a/ext/phar/tests/phar_buildfromdirectory4.phpt +++ b/ext/phar/tests/phar_buildfromdirectory4.phpt @@ -15,13 +15,13 @@ foreach(range(1, 4) as $i) { } try { - $phar = new Phar(__DIR__ . '/buildfromdirectory4.phar'); - $a = $phar->buildFromDirectory(__DIR__ . '/testdir4'); - asort($a); - var_dump($a); + $phar = new Phar(__DIR__ . '/buildfromdirectory4.phar'); + $a = $phar->buildFromDirectory(__DIR__ . '/testdir4'); + asort($a); + var_dump($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } var_dump(file_exists(__DIR__ . '/buildfromdirectory4.phar')); diff --git a/ext/phar/tests/phar_buildfromdirectory5.phpt b/ext/phar/tests/phar_buildfromdirectory5.phpt index d1402dd07829..f5c48ee16354 100644 --- a/ext/phar/tests/phar_buildfromdirectory5.phpt +++ b/ext/phar/tests/phar_buildfromdirectory5.phpt @@ -14,13 +14,13 @@ foreach(range(1, 4) as $i) { } try { - $phar = new Phar(__DIR__ . '/buildfromdirectory5.phar'); - $a = $phar->buildFromDirectory(__DIR__ . '/testdir5', '/\.txt/'); - asort($a); - var_dump($a); + $phar = new Phar(__DIR__ . '/buildfromdirectory5.phar'); + $a = $phar->buildFromDirectory(__DIR__ . '/testdir5', '/\.txt/'); + asort($a); + var_dump($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } var_dump(file_exists(__DIR__ . '/buildfromdirectory5.phar')); diff --git a/ext/phar/tests/phar_buildfromdirectory6.phpt b/ext/phar/tests/phar_buildfromdirectory6.phpt index 3780ffbb1778..e25439a64be5 100644 --- a/ext/phar/tests/phar_buildfromdirectory6.phpt +++ b/ext/phar/tests/phar_buildfromdirectory6.phpt @@ -14,11 +14,11 @@ foreach(range(1, 4) as $i) { } try { - $phar = new Phar(__DIR__ . '/buildfromdirectory6.phar'); - var_dump($phar->buildFromDirectory(__DIR__ . '/testdir6', '/\.php$/')); + $phar = new Phar(__DIR__ . '/buildfromdirectory6.phar'); + var_dump($phar->buildFromDirectory(__DIR__ . '/testdir6', '/\.php$/')); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } var_dump(file_exists(__DIR__ . '/buildfromdirectory6.phar')); diff --git a/ext/phar/tests/phar_buildfromiterator1.phpt b/ext/phar/tests/phar_buildfromiterator1.phpt index bd81538a0b46..aac85ff33eff 100644 --- a/ext/phar/tests/phar_buildfromiterator1.phpt +++ b/ext/phar/tests/phar_buildfromiterator1.phpt @@ -9,11 +9,11 @@ phar.readonly=0 buildFromIterator(1); + ini_set('phar.readonly', 1); + $phar->buildFromIterator(1); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator10.phpt b/ext/phar/tests/phar_buildfromiterator10.phpt index 735a53f656cc..6db0c93cdd6a 100644 --- a/ext/phar/tests/phar_buildfromiterator10.phpt +++ b/ext/phar/tests/phar_buildfromiterator10.phpt @@ -10,16 +10,16 @@ phar.readonly=0 --FILE-- buildFromIterator(new RegexIterator($iter, '/_\d{3}\.phpt$/'), __DIR__ . DIRECTORY_SEPARATOR); - asort($a); - var_dump($a); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator10.phar'); + $dir = new RecursiveDirectoryIterator('.'); + $iter = new RecursiveIteratorIterator($dir); + $a = $phar->buildFromIterator(new RegexIterator($iter, '/_\d{3}\.phpt$/'), __DIR__ . DIRECTORY_SEPARATOR); + asort($a); + var_dump($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator4.phpt b/ext/phar/tests/phar_buildfromiterator4.phpt index 14266bab54b4..fbe51fd1a330 100644 --- a/ext/phar/tests/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/phar_buildfromiterator4.phpt @@ -36,19 +36,19 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator4.phar'); - var_dump($phar->buildFromIterator(new myIterator( - array( - 'a' => basename(__FILE__, 'php') . 'phpt', - // demonstrate that none of these are added - '.phar/stub.php' => basename(__FILE__, 'php') . 'phpt', - '.phar/alias.txt' => basename(__FILE__, 'php') . 'phpt', - '.phar/oops' => basename(__FILE__, 'php') . 'phpt', - )))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator4.phar'); + var_dump($phar->buildFromIterator(new myIterator( + array( + 'a' => basename(__FILE__, 'php') . 'phpt', + // demonstrate that none of these are added + '.phar/stub.php' => basename(__FILE__, 'php') . 'phpt', + '.phar/alias.txt' => basename(__FILE__, 'php') . 'phpt', + '.phar/oops' => basename(__FILE__, 'php') . 'phpt', + )))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt index 9417f9a84c4b..57b132829320 100644 --- a/ext/phar/tests/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/phar_buildfromiterator5.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator5.phar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator5.phar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator6.phpt b/ext/phar/tests/phar_buildfromiterator6.phpt index 982c094caac8..612b114e9b9d 100644 --- a/ext/phar/tests/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/phar_buildfromiterator6.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator6.phar'); - var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator6.phar'); + var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator7.phpt b/ext/phar/tests/phar_buildfromiterator7.phpt index aa0cd7bf48eb..d3fa437a18b1 100644 --- a/ext/phar/tests/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/phar_buildfromiterator7.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator7.phar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator7.phar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator8.phpt b/ext/phar/tests/phar_buildfromiterator8.phpt index ff50fd7748f1..b3dc947d9ee6 100644 --- a/ext/phar/tests/phar_buildfromiterator8.phpt +++ b/ext/phar/tests/phar_buildfromiterator8.phpt @@ -7,14 +7,14 @@ phar.readonly=0 --FILE-- buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^\d{0,3}\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR); - asort($a); - var_dump($a); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator8.phar'); + $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^\d{0,3}\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR); + asort($a); + var_dump($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_buildfromiterator9.phpt b/ext/phar/tests/phar_buildfromiterator9.phpt index 9dd091eee5c0..20637453e050 100644 --- a/ext/phar/tests/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/phar_buildfromiterator9.phpt @@ -36,13 +36,13 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator9.phar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); - fclose($a); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator9.phar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); + fclose($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_construct_invalidurl.phpt b/ext/phar/tests/phar_construct_invalidurl.phpt index 295159fd0b9f..2b39cc765972 100644 --- a/ext/phar/tests/phar_construct_invalidurl.phpt +++ b/ext/phar/tests/phar_construct_invalidurl.phpt @@ -7,19 +7,19 @@ default_charset=UTF-8 --FILE-- getMessage(),"\n"; + echo $e->getMessage(),"\n"; } try { - $a = new Phar('http://'); + $a = new Phar('http://'); } catch (UnexpectedValueException $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } try { - $a = new Phar('http:/'); + $a = new Phar('http:/'); } catch (UnexpectedValueException $e) { - echo $e->getMessage(),"\n"; + echo $e->getMessage(),"\n"; } ?> --EXPECT-- diff --git a/ext/phar/tests/phar_convert_repeated_b.phpt b/ext/phar/tests/phar_convert_repeated_b.phpt index 484789cf1f24..4bb3e81bcfab 100644 --- a/ext/phar/tests/phar_convert_repeated_b.phpt +++ b/ext/phar/tests/phar_convert_repeated_b.phpt @@ -43,14 +43,14 @@ var_dump($phar->getAlias()); echo "================= convertToPhar() ====================\n"; try { - $phar = $phar->convertToExecutable(Phar::PHAR); - var_dump($phar->isFileFormat(Phar::PHAR)); - var_dump($phar->isFileFormat(Phar::TAR)); - var_dump($phar->isFileFormat(Phar::ZIP)); - var_dump(strlen($phar->getStub())); - var_dump($phar->getAlias()); + $phar = $phar->convertToExecutable(Phar::PHAR); + var_dump($phar->isFileFormat(Phar::PHAR)); + var_dump($phar->isFileFormat(Phar::TAR)); + var_dump($phar->isFileFormat(Phar::ZIP)); + var_dump(strlen($phar->getStub())); + var_dump($phar->getAlias()); } catch(Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } echo "================ convertToTar(GZ) ====================\n"; @@ -65,14 +65,14 @@ var_dump($phar->getAlias()); echo "================= convertToPhar() ====================\n"; try { - $phar = $phar->convertToExecutable(Phar::PHAR); - var_dump($phar->isFileFormat(Phar::PHAR)); - var_dump($phar->isFileFormat(Phar::TAR)); - var_dump($phar->isFileFormat(Phar::ZIP)); - var_dump(strlen($phar->getStub())); - var_dump($phar->getAlias()); + $phar = $phar->convertToExecutable(Phar::PHAR); + var_dump($phar->isFileFormat(Phar::PHAR)); + var_dump($phar->isFileFormat(Phar::TAR)); + var_dump($phar->isFileFormat(Phar::ZIP)); + var_dump(strlen($phar->getStub())); + var_dump($phar->getAlias()); } catch(Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_copy.phpt b/ext/phar/tests/phar_copy.phpt index 4ab45aad80ef..c450efaba59e 100644 --- a/ext/phar/tests/phar_copy.phpt +++ b/ext/phar/tests/phar_copy.phpt @@ -20,21 +20,21 @@ $p = new Phar($fname); try { - $p['a'] = 'hi'; - $p->startBuffering(); - $p->copy('a', 'b'); - echo file_get_contents($p['b']->getPathName()); - $p['a']->compress(Phar::GZ); - $p['b']->setMetadata('a'); - $p->copy('b', 'c'); - $p->stopBuffering(); - echo file_get_contents($p['c']->getPathName()); - copy($fname, $fname2); - $p->copy('a', $ename); + $p['a'] = 'hi'; + $p->startBuffering(); + $p->copy('a', 'b'); + echo file_get_contents($p['b']->getPathName()); + $p['a']->compress(Phar::GZ); + $p['b']->setMetadata('a'); + $p->copy('b', 'c'); + $p->stopBuffering(); + echo file_get_contents($p['c']->getPathName()); + copy($fname, $fname2); + $p->copy('a', $ename); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ini_set('phar.readonly',1); $p2 = new Phar($fname2); diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt index 3a7b38f6985b..2f5af26c415a 100644 --- a/ext/phar/tests/phar_create_in_cwd.phpt +++ b/ext/phar/tests/phar_create_in_cwd.phpt @@ -9,10 +9,10 @@ phar.readonly=0 getStub())); - $p->setStub("getStub())); + $p->setStub(""); - var_dump($p->getStub()); + var_dump($p->getStub()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_dir_iterate.phpt b/ext/phar/tests/phar_dir_iterate.phpt index 95a0775a87ab..bc5132aade84 100644 --- a/ext/phar/tests/phar_dir_iterate.phpt +++ b/ext/phar/tests/phar_dir_iterate.phpt @@ -15,7 +15,7 @@ $phar['sub/top.txt'] = 'there'; $phar['another.file.txt'] = 'wowee'; $newphar = new Phar($fname); foreach (new RecursiveIteratorIterator($newphar) as $path => $obj) { - var_dump($obj->getPathName()); + var_dump($obj->getPathName()); } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt index 89f3dc29a307..a354e0a608b8 100644 --- a/ext/phar/tests/phar_extract.phpt +++ b/ext/phar/tests/phar_extract.phpt @@ -25,13 +25,13 @@ $a->extractTo(__DIR__ . '/extract'); $out = array(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/extract', 0x00003000), RecursiveIteratorIterator::CHILD_FIRST) as $p => $b) { - $out[] = $p; + $out[] = $p; } sort($out); foreach ($out as $b) { - echo "$b\n"; + echo "$b\n"; } $a->extractTo(__DIR__ . '/extract1', 'file1.txt'); @@ -45,9 +45,9 @@ var_dump(file_get_contents(__DIR__ . '/extract1-2/file2.txt')); var_dump(is_dir(__DIR__ . '/extract1-2/one/level')); try { - $a->extractTo(__DIR__ . '/whatever', 134); + $a->extractTo(__DIR__ . '/whatever', 134); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } try { @@ -57,29 +57,29 @@ try { } try { - $a->extractTo(''); + $a->extractTo(''); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } file_put_contents(__DIR__ . '/oops', 'I is file'); try { - $a->extractTo(__DIR__ . '/oops', 'file1.txt'); + $a->extractTo(__DIR__ . '/oops', 'file1.txt'); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } try { - $a->extractTo(__DIR__ . '/oops1', array(array(), 'file1.txt')); + $a->extractTo(__DIR__ . '/oops1', array(array(), 'file1.txt')); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } try { - $a->extractTo(__DIR__ . '/extract', 'file1.txt'); + $a->extractTo(__DIR__ . '/extract', 'file1.txt'); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } file_put_contents(__DIR__ . '/extract/file1.txt', 'first'); @@ -89,17 +89,17 @@ $a->extractTo(__DIR__ . '/extract', 'file1.txt', true); var_dump(file_get_contents(__DIR__ . '/extract/file1.txt')); try { - $a->extractTo(str_repeat('a', 20000), 'file1.txt'); + $a->extractTo(str_repeat('a', 20000), 'file1.txt'); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } $a[str_repeat('a', 20000)] = 'long'; try { - $a->extractTo(__DIR__ . '/extract', str_repeat('a', 20000)); + $a->extractTo(__DIR__ . '/extract', str_repeat('a', 20000)); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/ext/phar/tests/phar_extract2.phpt b/ext/phar/tests/phar_extract2.phpt index 719189fbf38a..8692358827f2 100644 --- a/ext/phar/tests/phar_extract2.phpt +++ b/ext/phar/tests/phar_extract2.phpt @@ -24,13 +24,13 @@ $phar->extractTo(__DIR__ . '/extract2'); $out = array(); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/extract2', 0x00003000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) { - $extracted[] = $path; + $extracted[] = $path; } sort($extracted); foreach ($extracted as $out) { - echo "$out\n"; + echo "$out\n"; } ?> diff --git a/ext/phar/tests/phar_extract3.phpt b/ext/phar/tests/phar_extract3.phpt index f342dc6e5a81..6a7e6e0815d1 100644 --- a/ext/phar/tests/phar_extract3.phpt +++ b/ext/phar/tests/phar_extract3.phpt @@ -14,20 +14,20 @@ $extract = __DIR__ . '/test-extract3'; $phar = new PharData($fname); try { - $phar->extractTo($extract); + $phar->extractTo($extract); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } $phar = new PharData($fname2); foreach ($phar as $filename) { - echo "$filename\n"; + echo "$filename\n"; } try { - $phar->extractTo($extract); + $phar->extractTo($extract); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/ext/phar/tests/phar_metadata_read.phpt b/ext/phar/tests/phar_metadata_read.phpt index 56d46713f265..428daf38c8bf 100644 --- a/ext/phar/tests/phar_metadata_read.phpt +++ b/ext/phar/tests/phar_metadata_read.phpt @@ -22,7 +22,7 @@ $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); include 'files/phar_test.inc'; foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } $phar = new Phar($fname); @@ -33,17 +33,17 @@ var_dump($phar->getMetaData()); var_dump($phar->delMetaData()); var_dump($phar->getMetaData()); foreach($files as $name => $cont) { - echo " meta $name\n"; - var_dump($phar[$name]->hasMetadata()); - var_dump($phar[$name]->getMetadata()); - var_dump($phar[$name]->delMetadata()); - var_dump($phar[$name]->getMetadata()); + echo " meta $name\n"; + var_dump($phar[$name]->hasMetadata()); + var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->delMetadata()); + var_dump($phar[$name]->getMetadata()); } unset($phar); foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_metadata_write.phpt b/ext/phar/tests/phar_metadata_write.phpt index 7a70491f4996..484795ecff06 100644 --- a/ext/phar/tests/phar_metadata_write.phpt +++ b/ext/phar/tests/phar_metadata_write.phpt @@ -21,7 +21,7 @@ $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); include 'files/phar_test.inc'; foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } $phar = new Phar($fname); @@ -35,13 +35,13 @@ $phar['c']->setMetadata(array(25, 'foo'=>'bar')); $phar['d']->setMetadata(true); foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } unset($phar); foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_offset_check.phpt b/ext/phar/tests/phar_offset_check.phpt index 32b67685cc5b..415a886446bb 100644 --- a/ext/phar/tests/phar_offset_check.phpt +++ b/ext/phar/tests/phar_offset_check.phpt @@ -18,45 +18,45 @@ $phar['a.txt'] = "first file\n"; $phar['b.txt'] = "second file\n"; try { - $phar->offsetGet('.phar/stub.php'); + $phar->offsetGet('.phar/stub.php'); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } try { - $phar->offsetGet('.phar/alias.txt'); + $phar->offsetGet('.phar/alias.txt'); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } try { - $phar->offsetSet('.phar/stub.php', ''); + $phar->offsetSet('.phar/stub.php', ''); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } var_dump(strlen($phar->getStub())); try { - $phar->offsetUnset('.phar/stub.php'); + $phar->offsetUnset('.phar/stub.php'); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } var_dump(strlen($phar->getStub())); try { - $phar->offsetSet('.phar/alias.txt', 'dolly'); + $phar->offsetSet('.phar/alias.txt', 'dolly'); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } var_dump($phar->getAlias()); try { - $phar->offsetUnset('.phar/alias.txt'); + $phar->offsetUnset('.phar/alias.txt'); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } var_dump($phar->getAlias()); diff --git a/ext/phar/tests/phar_offset_get_error.phpt b/ext/phar/tests/phar_offset_get_error.phpt index b49035fd6667..643009284643 100644 --- a/ext/phar/tests/phar_offset_get_error.phpt +++ b/ext/phar/tests/phar_offset_get_error.phpt @@ -18,11 +18,11 @@ $p[$iname] = "foobar\n"; try { - $p[$ename] = "foobar\n"; + $p[$ename] = "foobar\n"; } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } include($pname . $iname); diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt index ba93c8810736..303e08c15bd2 100644 --- a/ext/phar/tests/phar_oo_001.phpt +++ b/ext/phar/tests/phar_oo_001.phpt @@ -18,26 +18,26 @@ var_dump(count($phar)); class MyPhar extends Phar { - function __construct() - { - } + function __construct() + { + } } try { - $phar = new MyPhar(); - var_dump($phar->getVersion()); + $phar = new MyPhar(); + var_dump($phar->getVersion()); } catch (LogicException $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { - $phar = new Phar('test.phar'); - $phar->__construct('oops'); + $phar = new Phar('test.phar'); + $phar->__construct('oops'); } catch (LogicException $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/phar/tests/phar_oo_002.phpt b/ext/phar/tests/phar_oo_002.phpt index 9be0877676d5..85723df9a8ca 100644 --- a/ext/phar/tests/phar_oo_002.phpt +++ b/ext/phar/tests/phar_oo_002.phpt @@ -16,19 +16,19 @@ $phar = new Phar($fname); $phar->setInfoClass('SplFileInfo'); foreach($phar as $name => $ent) { - var_dump(str_replace(str_replace('\\', '/', __DIR__), '*', $name)); - var_dump($ent->getFilename()); - var_dump($ent->getSize()); - var_dump($ent->getType()); - var_dump($ent->isWritable()); - var_dump($ent->isReadable()); - var_dump($ent->isExecutable()); - var_dump($ent->isFile()); - var_dump($ent->isDir()); - var_dump($ent->isLink()); - var_dump($ent->getCTime()); - var_dump($ent->getMTime()); - var_dump($ent->getATime()); + var_dump(str_replace(str_replace('\\', '/', __DIR__), '*', $name)); + var_dump($ent->getFilename()); + var_dump($ent->getSize()); + var_dump($ent->getType()); + var_dump($ent->isWritable()); + var_dump($ent->isReadable()); + var_dump($ent->isExecutable()); + var_dump($ent->isFile()); + var_dump($ent->isDir()); + var_dump($ent->isLink()); + var_dump($ent->getCTime()); + var_dump($ent->getMTime()); + var_dump($ent->getATime()); } echo "==RECURSIVE==\n"; @@ -36,12 +36,12 @@ echo "==RECURSIVE==\n"; $phar = new Phar($fname); foreach(new RecursiveIteratorIterator($phar) as $name => $ent) { - var_dump(str_replace(str_replace('\\', '/', __DIR__), '*', $name)); - var_dump(str_replace('\\', '/', $ent->getFilename())); - var_dump($ent->getCompressedSize()); - var_dump($ent->isCRCChecked()); - var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL); - var_dump($ent->getPharFlags()); + var_dump(str_replace(str_replace('\\', '/', __DIR__), '*', $name)); + var_dump(str_replace('\\', '/', $ent->getFilename())); + var_dump($ent->getCompressedSize()); + var_dump($ent->isCRCChecked()); + var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL); + var_dump($ent->getPharFlags()); } ?> diff --git a/ext/phar/tests/phar_oo_003.phpt b/ext/phar/tests/phar_oo_003.phpt index 110dcec9e708..8442534152c2 100644 --- a/ext/phar/tests/phar_oo_003.phpt +++ b/ext/phar/tests/phar_oo_003.phpt @@ -13,13 +13,13 @@ $phar = new Phar($fname); $phar->setInfoClass(); foreach($phar as $name => $ent) { - var_dump($ent->getFilename()); - if ($ent->isDir()) { - var_dump('DIR'); - } else { - var_dump($ent->openFile()->fgets()); - include $ent->getPathName(); - } + var_dump($ent->getFilename()); + if ($ent->isDir()) { + var_dump('DIR'); + } else { + var_dump($ent->openFile()->fgets()); + include $ent->getPathName(); + } } ?> diff --git a/ext/phar/tests/phar_oo_004.phpt b/ext/phar/tests/phar_oo_004.phpt index 5130f816d4ae..d1dc4ca78c9b 100644 --- a/ext/phar/tests/phar_oo_004.phpt +++ b/ext/phar/tests/phar_oo_004.phpt @@ -15,10 +15,10 @@ $it = new DirectoryIterator('phar://'.$fname); foreach($it as $name => $ent) { - var_dump($name); - var_dump($ent->getFilename()); - var_dump($ent->isDir()); - var_dump($ent->isDot()); + var_dump($name); + var_dump($ent->getFilename()); + var_dump($ent->isDir()); + var_dump($ent->isDot()); } ?> @@ -27,49 +27,49 @@ foreach($it as $name => $ent) class MyDirectoryIterator extends DirectoryIterator { - function __construct($dir) - { - echo __METHOD__ . "\n"; - parent::__construct($dir); - } + function __construct($dir) + { + echo __METHOD__ . "\n"; + parent::__construct($dir); + } - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } } $it = new MyDirectoryIterator('phar://'.$fname); foreach($it as $name => $ent) { - var_dump($name); - var_dump($ent->getFilename()); + var_dump($name); + var_dump($ent->getFilename()); } ?> diff --git a/ext/phar/tests/phar_oo_005.phpt b/ext/phar/tests/phar_oo_005.phpt index 7b414435c428..83dd3fc16b34 100644 --- a/ext/phar/tests/phar_oo_005.phpt +++ b/ext/phar/tests/phar_oo_005.phpt @@ -17,12 +17,12 @@ $it = new RecursiveIteratorIterator($it); foreach($it as $name => $ent) { - var_dump(str_replace(array('\\', $fname), array('/', '*'), $name)); - var_dump(str_replace(array('\\', $fname), array('/', '*'), $ent->getPathname())); - var_dump(str_replace('\\', '/', $it->getSubPath())); - var_dump(str_replace('\\', '/', $it->getSubPathName())); - $sub = $it->getPathInfo(); - var_dump(str_replace('\\', '/', $sub->getFilename())); + var_dump(str_replace(array('\\', $fname), array('/', '*'), $name)); + var_dump(str_replace(array('\\', $fname), array('/', '*'), $ent->getPathname())); + var_dump(str_replace('\\', '/', $it->getSubPath())); + var_dump(str_replace('\\', '/', $it->getSubPathName())); + $sub = $it->getPathInfo(); + var_dump(str_replace('\\', '/', $sub->getFilename())); } ?> diff --git a/ext/phar/tests/phar_oo_006.phpt b/ext/phar/tests/phar_oo_006.phpt index 9e14127a8efe..4b1201cc24eb 100644 --- a/ext/phar/tests/phar_oo_006.phpt +++ b/ext/phar/tests/phar_oo_006.phpt @@ -11,21 +11,21 @@ require_once 'files/phar_oo_test.inc'; class MyFile extends SplFileObject { - function __construct($what) - { - echo __METHOD__ . "($what)\n"; - parent::__construct($what); - } + function __construct($what) + { + echo __METHOD__ . "($what)\n"; + parent::__construct($what); + } } $phar = new Phar($fname); try { - $phar->setFileClass('SplFileInfo'); + $phar->setFileClass('SplFileInfo'); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $phar->setInfoClass('MyFile'); diff --git a/ext/phar/tests/phar_oo_007.phpt b/ext/phar/tests/phar_oo_007.phpt index 7cb803f15e29..14eca23c0441 100644 --- a/ext/phar/tests/phar_oo_007.phpt +++ b/ext/phar/tests/phar_oo_007.phpt @@ -11,11 +11,11 @@ require_once 'files/phar_oo_test.inc'; class MyFile extends SplFileObject { - function __construct($name) - { - echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', __DIR__), '*', $name) . ")\n"; - parent::__construct($name); - } + function __construct($name) + { + echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', __DIR__), '*', $name) . ")\n"; + parent::__construct($name); + } } $phar = new Phar($fname); diff --git a/ext/phar/tests/phar_oo_008.phpt b/ext/phar/tests/phar_oo_008.phpt index 7ae68c034d1d..40027fd97f70 100644 --- a/ext/phar/tests/phar_oo_008.phpt +++ b/ext/phar/tests/phar_oo_008.phpt @@ -18,7 +18,7 @@ $f = $phar['a.csv']; echo "===1===\n"; foreach($f as $k => $v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } $f->setFlags(SplFileObject::DROP_NEW_LINE); @@ -26,15 +26,15 @@ $f->setFlags(SplFileObject::DROP_NEW_LINE); echo "===2===\n"; foreach($f as $k => $v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } class MyCSVFile extends SplFileObject { - function current() - { - return parent::fgetcsv(',', '"'); - } + function current() + { + return parent::fgetcsv(',', '"'); + } } $phar->setInfoClass('MyCSVFile'); @@ -43,30 +43,30 @@ $v = $phar['a.csv']; echo "===3===\n"; while(!$v->eof()) { - echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n"; + echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n"; } echo "===4===\n"; $v->rewind(); while(!$v->eof()) { - $l = $v->fgetcsv(); - echo $v->key() . "=>" . join('|',$l) . "\n"; + $l = $v->fgetcsv(); + echo $v->key() . "=>" . join('|',$l) . "\n"; } echo "===5===\n"; foreach($v as $k => $d) { - echo "$k=>" . join('|',$d) . "\n"; + echo "$k=>" . join('|',$d) . "\n"; } class MyCSVFile2 extends SplFileObject { - function getCurrentLine() - { - echo __METHOD__ . "\n"; - return parent::fgetcsv(',', '"'); - } + function getCurrentLine() + { + echo __METHOD__ . "\n"; + return parent::fgetcsv(',', '"'); + } } $phar->setInfoClass('MyCSVFile2'); @@ -75,7 +75,7 @@ $v = $phar['a.csv']; echo "===6===\n"; foreach($v as $k => $d) { - echo "$k=>" . join('|',$d) . "\n"; + echo "$k=>" . join('|',$d) . "\n"; } ?> diff --git a/ext/phar/tests/phar_oo_009.phpt b/ext/phar/tests/phar_oo_009.phpt index a630ceb7a360..99c368452343 100644 --- a/ext/phar/tests/phar_oo_009.phpt +++ b/ext/phar/tests/phar_oo_009.phpt @@ -19,7 +19,7 @@ $f = $phar['a.csv']; $f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE); foreach($f as $k => $v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } ?> @@ -29,7 +29,7 @@ foreach($f as $k => $v) $f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV); foreach($f as $k => $v) { - echo "$k=>" . join('|', $v) . "\n"; + echo "$k=>" . join('|', $v) . "\n"; } ?> diff --git a/ext/phar/tests/phar_oo_011b.phpt b/ext/phar/tests/phar_oo_011b.phpt index fcba17e0be98..a1d2234bba3c 100644 --- a/ext/phar/tests/phar_oo_011b.phpt +++ b/ext/phar/tests/phar_oo_011b.phpt @@ -10,20 +10,20 @@ phar.require_hash=0 try { - $pharconfig = 0; + $pharconfig = 0; - require_once 'files/phar_oo_test.inc'; + require_once 'files/phar_oo_test.inc'; - $phar = new Phar($fname); + $phar = new Phar($fname); - $phar['f.php'] = 'hi'; - var_dump(isset($phar['f.php'])); - echo $phar['f.php']; - echo "\n"; + $phar['f.php'] = 'hi'; + var_dump(isset($phar['f.php'])); + echo $phar['f.php']; + echo "\n"; } catch (BadMethodCallException $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/phar_oo_012b.phpt b/ext/phar/tests/phar_oo_012b.phpt index 6f85ac19c0b6..26cbe65e2a16 100644 --- a/ext/phar/tests/phar_oo_012b.phpt +++ b/ext/phar/tests/phar_oo_012b.phpt @@ -10,23 +10,23 @@ phar.require_hash=0 try { - $pharconfig = 0; + $pharconfig = 0; - require_once 'files/phar_oo_test.inc'; + require_once 'files/phar_oo_test.inc'; - $phar = new Phar($fname); - $phar->setInfoClass('SplFileObject'); + $phar = new Phar($fname); + $phar->setInfoClass('SplFileObject'); - $phar['f.php'] = 'hi'; - var_dump(isset($phar['f.php'])); - echo $phar['f.php']; - echo "\n"; - unset($phar['f.php']); - var_dump(isset($phar['f.php'])); + $phar['f.php'] = 'hi'; + var_dump(isset($phar['f.php'])); + echo $phar['f.php']; + echo "\n"; + unset($phar['f.php']); + var_dump(isset($phar['f.php'])); } catch (BadMethodCallException $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/phar_setalias2.phpt b/ext/phar/tests/phar_setalias2.phpt index 6a0876b5f9e2..82a25f56e1c9 100644 --- a/ext/phar/tests/phar_setalias2.phpt +++ b/ext/phar/tests/phar_setalias2.phpt @@ -25,14 +25,14 @@ echo $phar->getAlias() . "\n"; $b = $phar; $phar = new Phar(__DIR__ . '/notphar.phar'); try { - $phar->setAlias('test'); + $phar->setAlias('test'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $b = new Phar(__DIR__ . '/nope.phar', 0, 'test'); + $b = new Phar(__DIR__ . '/nope.phar', 0, 'test'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/phar_setdefaultstub.phpt b/ext/phar/tests/phar_setdefaultstub.phpt index 6fed7929666a..3aa5b7243a6e 100644 --- a/ext/phar/tests/phar_setdefaultstub.phpt +++ b/ext/phar/tests/phar_setdefaultstub.phpt @@ -35,16 +35,16 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub(str_repeat('a', 400)); - $phar->stopBuffering(); - var_dump(strlen($phar->getStub())); + $phar->setDefaultStub(str_repeat('a', 400)); + $phar->stopBuffering(); + var_dump(strlen($phar->getStub())); - $phar->setDefaultStub(str_repeat('a', 401)); - $phar->stopBuffering(); - var_dump(strlen($phar->getStub())); + $phar->setDefaultStub(str_repeat('a', 401)); + $phar->stopBuffering(); + var_dump(strlen($phar->getStub())); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/phar_stub.phpt b/ext/phar/tests/phar_stub.phpt index e2fec8054ce6..cfca8fcb4ef2 100644 --- a/ext/phar/tests/phar_stub.phpt +++ b/ext/phar/tests/phar_stub.phpt @@ -61,7 +61,7 @@ fclose($fp); $fp = fopen($fname, 'rb'); echo fread($fp, strlen($file)) . "\n"; if (fread($fp, strlen('booya')) == 'booya') { - echo 'failed - copied booya'; + echo 'failed - copied booya'; } fclose($fp); $phar['testing'] = 'hi'; @@ -70,7 +70,7 @@ $phar['testing'] = 'hi'; $fp = fopen($fname, 'rb'); echo fread($fp, strlen($file)) . "\n"; if (fread($fp, strlen('booya')) == 'booya') { - echo 'failed - copied booya'; + echo 'failed - copied booya'; } fclose($fp); diff --git a/ext/phar/tests/phar_stub_error.phpt b/ext/phar/tests/phar_stub_error.phpt index 0a95e290de7f..972af851ee9d 100644 --- a/ext/phar/tests/phar_stub_error.phpt +++ b/ext/phar/tests/phar_stub_error.phpt @@ -25,11 +25,11 @@ var_dump($phar->getStub() == $stub); $newstub = ''; try { - $phar->setStub($newstub); + $phar->setStub($newstub); } catch(exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } var_dump($phar->getStub()); var_dump($phar->getStub() == $stub); diff --git a/ext/phar/tests/tar/033.phpt b/ext/phar/tests/tar/033.phpt index d881ea125b0c..cf45cab11d38 100644 --- a/ext/phar/tests/tar/033.phpt +++ b/ext/phar/tests/tar/033.phpt @@ -18,19 +18,19 @@ $phar->addEmptyDir('test'); $phar->stopBuffering(); try { - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0777); - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0666); - var_dump($phar['a.php']->isExecutable()); - echo "test dir\n"; - var_dump($phar['test']->isReadable()); - $phar['test']->chmod(0000); - var_dump($phar['test']->isReadable()); - $phar['test']->chmod(0666); - var_dump($phar['test']->isReadable()); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0777); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0666); + var_dump($phar['a.php']->isExecutable()); + echo "test dir\n"; + var_dump($phar['test']->isReadable()); + $phar['test']->chmod(0000); + var_dump($phar['test']->isReadable()); + $phar['test']->chmod(0666); + var_dump($phar['test']->isReadable()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/tar/033a.phpt b/ext/phar/tests/tar/033a.phpt index 3930407087ad..67216c3317b1 100644 --- a/ext/phar/tests/tar/033a.phpt +++ b/ext/phar/tests/tar/033a.phpt @@ -19,19 +19,19 @@ $phar->stopBuffering(); ini_set('phar.readonly', 1); try { - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0777); - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0666); - var_dump($phar['a.php']->isExecutable()); - echo "test dir\n"; - var_dump($phar['test']->isReadable()); - $phar['test']->chmod(0000); - var_dump($phar['test']->isReadable()); - $phar['test']->chmod(0666); - var_dump($phar['test']->isReadable()); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0777); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0666); + var_dump($phar['a.php']->isExecutable()); + echo "test dir\n"; + var_dump($phar['test']->isReadable()); + $phar['test']->chmod(0000); + var_dump($phar['test']->isReadable()); + $phar['test']->chmod(0666); + var_dump($phar['test']->isReadable()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/badchecksum.phpt b/ext/phar/tests/tar/badchecksum.phpt index b6b404726349..964f6024349d 100644 --- a/ext/phar/tests/tar/badchecksum.phpt +++ b/ext/phar/tests/tar/badchecksum.phpt @@ -14,9 +14,9 @@ $a->addFile('hithere', 'contents', null, 'checksum'); $a->close(); try { - $p = new PharData($fname); + $p = new PharData($fname); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/tar/bignames.phpt b/ext/phar/tests/tar/bignames.phpt index a22d5bd40d59..f4fefcb13ec2 100644 --- a/ext/phar/tests/tar/bignames.phpt +++ b/ext/phar/tests/tar/bignames.phpt @@ -21,23 +21,23 @@ echo $p2[str_repeat('a', 100) . '/b']->getContent() . "\n"; echo $p2[str_repeat('a', 155) . '/' . str_repeat('b', 100)]->getContent() . "\n"; try { - $p2[str_repeat('a', 400)] = 'yuck'; + $p2[str_repeat('a', 400)] = 'yuck'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p2 = new PharData($fname3); - $p2[str_repeat('a', 101)] = 'yuck'; + $p2 = new PharData($fname3); + $p2[str_repeat('a', 101)] = 'yuck'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $p2 = new PharData($fname4); - $p2[str_repeat('b', 160) . '/' . str_repeat('a', 90)] = 'yuck'; + $p2 = new PharData($fname4); + $p2[str_repeat('b', 160) . '/' . str_repeat('a', 90)] = 'yuck'; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/bignames_overflow.phpt b/ext/phar/tests/tar/bignames_overflow.phpt index 3d3247a8068a..f3bf29a27a3c 100644 --- a/ext/phar/tests/tar/bignames_overflow.phpt +++ b/ext/phar/tests/tar/bignames_overflow.phpt @@ -20,7 +20,7 @@ $tar->close(); $p1 = new PharData($fname); foreach ($p1 as $file) { - echo $file->getFileName(), "\n"; + echo $file->getFileName(), "\n"; } echo $p1['a/' . str_repeat('a', 100)]->getContent() . "\n"; echo $p1[str_repeat('a', 155) . '/' . str_repeat('a', 100)]->getContent() . "\n"; diff --git a/ext/phar/tests/tar/bug49910.phpt b/ext/phar/tests/tar/bug49910.phpt index 0854c7284bcd..04ea48503597 100644 --- a/ext/phar/tests/tar/bug49910.phpt +++ b/ext/phar/tests/tar/bug49910.phpt @@ -9,7 +9,7 @@ $fname = str_replace('\\', '/', __DIR__ . '/files/Structures_Graph-1.0.3.tgz'); $tar = new PharData($fname); $files = array(); foreach (new RecursiveIteratorIterator($tar) as $file) { - $files[] = str_replace($fname, '*', $file->getPathName()); + $files[] = str_replace($fname, '*', $file->getPathName()); } print_r($files); ?> diff --git a/ext/phar/tests/tar/bug71317-duplicate-filename.phpt b/ext/phar/tests/tar/bug71317-duplicate-filename.phpt index ee3219c1db3d..77fbdd50f226 100644 --- a/ext/phar/tests/tar/bug71317-duplicate-filename.phpt +++ b/ext/phar/tests/tar/bug71317-duplicate-filename.phpt @@ -22,17 +22,17 @@ $tar->close(); $fname = str_replace('\\', '/', $testTarFilename); try { - mkdir($testDirectory); - $tar = new PharData($fname); - $tar->extractTo($testDirectory); + mkdir($testDirectory); + $tar = new PharData($fname); + $tar->extractTo($testDirectory); - $fileContent = file_get_contents($testDirectory . '/file2.txt'); - $expectedContent = 'file2a'; - if ($fileContent !== $expectedContent) { - throw new Exception(sprintf('Contents of file2.txt ("%s") is invalid, expected "%s"', $fileContent, $expectedContent)); - } + $fileContent = file_get_contents($testDirectory . '/file2.txt'); + $expectedContent = 'file2a'; + if ($fileContent !== $expectedContent) { + throw new Exception(sprintf('Contents of file2.txt ("%s") is invalid, expected "%s"', $fileContent, $expectedContent)); + } } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> ===DONE=== diff --git a/ext/phar/tests/tar/bug71504.phpt b/ext/phar/tests/tar/bug71504.phpt index fde572beeab0..9352d8037411 100644 --- a/ext/phar/tests/tar/bug71504.phpt +++ b/ext/phar/tests/tar/bug71504.phpt @@ -7,9 +7,9 @@ Bug #71504: Parsing of tar file with duplicate filenames causes memory leak getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> ===DONE=== diff --git a/ext/phar/tests/tar/create_new_phar_b.phpt b/ext/phar/tests/tar/create_new_phar_b.phpt index b8a7d4322b48..6d9f3fd00972 100644 --- a/ext/phar/tests/tar/create_new_phar_b.phpt +++ b/ext/phar/tests/tar/create_new_phar_b.phpt @@ -9,7 +9,7 @@ phar.require_hash=1 diff --git a/ext/phar/tests/tar/exists_as_phar.phpt b/ext/phar/tests/tar/exists_as_phar.phpt index 2a87dc7327ee..667287f61ea8 100644 --- a/ext/phar/tests/tar/exists_as_phar.phpt +++ b/ext/phar/tests/tar/exists_as_phar.phpt @@ -21,9 +21,9 @@ copy($fname, $tname); $phar->setAlias('hio2'); try { - $p = new Phar($tname); + $p = new Phar($tname); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc b/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc index 4e30dca17470..9663d8933658 100644 --- a/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc +++ b/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc @@ -112,7 +112,7 @@ class corrupt_tarmaker $checksum = 256; // 8 * ord(' '); $checksum += array_reduce($checkheader, '_pear2tarchecksum'); - if ($corrupt === 'checksum') $checksum++; + if ($corrupt === 'checksum') $checksum++; $checksum = pack('a8', sprintf('%6s ', decoct($checksum))); fwrite($this->tmp, $block . $checksum . $blockend, 512); diff --git a/ext/phar/tests/tar/files/make_invalid_tar.php.inc b/ext/phar/tests/tar/files/make_invalid_tar.php.inc index 895977bf2fbc..2ccdf00201c0 100644 --- a/ext/phar/tests/tar/files/make_invalid_tar.php.inc +++ b/ext/phar/tests/tar/files/make_invalid_tar.php.inc @@ -3,7 +3,7 @@ include dirname(__FILE__) . '/tarmaker.php.inc'; class corrupter extends tarmaker { function close() { - fwrite($this->tmp, (binary)'oopsie'); - fclose($this->tmp); + fwrite($this->tmp, (binary)'oopsie'); + fclose($this->tmp); } } diff --git a/ext/phar/tests/tar/links.phpt b/ext/phar/tests/tar/links.phpt index 2d1c76b85e39..5af9811f4d8f 100644 --- a/ext/phar/tests/tar/links.phpt +++ b/ext/phar/tests/tar/links.phpt @@ -9,9 +9,9 @@ phar.require_hash=0 $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar'; copy(__DIR__ . '/files/links.tar', $fname); try { - $p = new PharData($fname); + $p = new PharData($fname); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } var_dump($p['testit/link']->getContent()); var_dump($p['testit/hard']->getContent()); diff --git a/ext/phar/tests/tar/links2.phpt b/ext/phar/tests/tar/links2.phpt index 75f5c51e2521..bd56fb4761bb 100644 --- a/ext/phar/tests/tar/links2.phpt +++ b/ext/phar/tests/tar/links2.phpt @@ -20,9 +20,9 @@ $a->addFile('hardlink', 'internal/file.txt', array( $a->close(); try { - $p = new PharData($fname); + $p = new PharData($fname); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/links3.phpt b/ext/phar/tests/tar/links3.phpt index b771da12605e..78243c7e128b 100644 --- a/ext/phar/tests/tar/links3.phpt +++ b/ext/phar/tests/tar/links3.phpt @@ -7,9 +7,9 @@ phar.require_hash=0 --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } echo $p['file.txt']->getContent(); echo $p['my/file']->getContent(); diff --git a/ext/phar/tests/tar/links4.phpt b/ext/phar/tests/tar/links4.phpt index 941197c67b79..10c3cf6b6e50 100644 --- a/ext/phar/tests/tar/links4.phpt +++ b/ext/phar/tests/tar/links4.phpt @@ -7,9 +7,9 @@ phar.require_hash=0 --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } echo $p['file.txt']->getContent(); echo $p['link.txt']->getContent(); diff --git a/ext/phar/tests/tar/links5.phpt b/ext/phar/tests/tar/links5.phpt index 17892370f77e..fdef2da64aa3 100644 --- a/ext/phar/tests/tar/links5.phpt +++ b/ext/phar/tests/tar/links5.phpt @@ -7,9 +7,9 @@ phar.require_hash=0 --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } echo $p['hi/test.txt']->getContent(); echo $p['hi/link.txt']->getContent(); diff --git a/ext/phar/tests/tar/open_for_write_existing.phpt b/ext/phar/tests/tar/open_for_write_existing.phpt index 05ab333bfd2c..247f2559ea5e 100644 --- a/ext/phar/tests/tar/open_for_write_existing.phpt +++ b/ext/phar/tests/tar/open_for_write_existing.phpt @@ -21,7 +21,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/open_for_write_existing_b.phpt b/ext/phar/tests/tar/open_for_write_existing_b.phpt index eaf1ed9ad211..958fb639c465 100644 --- a/ext/phar/tests/tar/open_for_write_existing_b.phpt +++ b/ext/phar/tests/tar/open_for_write_existing_b.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/open_for_write_existing_c.phpt b/ext/phar/tests/tar/open_for_write_existing_c.phpt index d70a96bf3b1e..c8871f1f498f 100644 --- a/ext/phar/tests/tar/open_for_write_existing_c.phpt +++ b/ext/phar/tests/tar/open_for_write_existing_c.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/open_for_write_newfile.phpt b/ext/phar/tests/tar/open_for_write_newfile.phpt index f5485eac1834..eb2d2509f3ac 100644 --- a/ext/phar/tests/tar/open_for_write_newfile.phpt +++ b/ext/phar/tests/tar/open_for_write_newfile.phpt @@ -21,7 +21,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/open_for_write_newfile_b.phpt b/ext/phar/tests/tar/open_for_write_newfile_b.phpt index fec1cf2d6c15..9494b867dd43 100644 --- a/ext/phar/tests/tar/open_for_write_newfile_b.phpt +++ b/ext/phar/tests/tar/open_for_write_newfile_b.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/open_for_write_newfile_c.phpt b/ext/phar/tests/tar/open_for_write_newfile_c.phpt index e6d371fb0f62..e5fc5836609a 100644 --- a/ext/phar/tests/tar/open_for_write_newfile_c.phpt +++ b/ext/phar/tests/tar/open_for_write_newfile_c.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/phar_buildfromiterator4.phpt b/ext/phar/tests/tar/phar_buildfromiterator4.phpt index bffc21b36c11..d78c3a0ed44f 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator4.phpt @@ -36,13 +36,13 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt')))); - var_dump($phar->isFileFormat(Phar::TAR)); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt')))); + var_dump($phar->isFileFormat(Phar::TAR)); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/phar_buildfromiterator5.phpt b/ext/phar/tests/tar/phar_buildfromiterator5.phpt index c5191ee3e014..73d23e3218de 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator5.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/phar_buildfromiterator6.phpt b/ext/phar/tests/tar/phar_buildfromiterator6.phpt index 58706a714c1a..5c856f58fa79 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator6.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); - var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); + var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/phar_buildfromiterator7.phpt b/ext/phar/tests/tar/phar_buildfromiterator7.phpt index 1ffc2da8d6bc..92be5ebd7a6b 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator7.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/phar_buildfromiterator8.phpt b/ext/phar/tests/tar/phar_buildfromiterator8.phpt index d2efdce66d39..f9497a01ceb5 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator8.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator8.phpt @@ -7,15 +7,15 @@ phar.readonly=0 --FILE-- buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR); - asort($a); - var_dump($a); - var_dump($phar->isFileFormat(Phar::TAR)); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); + $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR); + asort($a); + var_dump($a); + var_dump($phar->isFileFormat(Phar::TAR)); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/phar_buildfromiterator9.phpt b/ext/phar/tests/tar/phar_buildfromiterator9.phpt index 6653b1dbf27d..e113d211a80c 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator9.phpt @@ -36,13 +36,13 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); - fclose($a); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.tar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); + fclose($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/phar_copy.phpt b/ext/phar/tests/tar/phar_copy.phpt index 61938bf0b5e1..e760abddd854 100644 --- a/ext/phar/tests/tar/phar_copy.phpt +++ b/ext/phar/tests/tar/phar_copy.phpt @@ -20,20 +20,20 @@ $p = new Phar($fname); try { - $p['a'] = 'hi'; - $p->startBuffering(); - $p->copy('a', 'b'); - echo file_get_contents($p['b']->getPathName()); - $p->copy('b', 'c'); - $p->stopBuffering(); - echo file_get_contents($p['c']->getPathName()); - copy($fname, $fname2); - var_dump($p->isFileFormat(Phar::TAR)); - $p->copy('a', $ename); + $p['a'] = 'hi'; + $p->startBuffering(); + $p->copy('a', 'b'); + echo file_get_contents($p['b']->getPathName()); + $p->copy('b', 'c'); + $p->stopBuffering(); + echo file_get_contents($p['c']->getPathName()); + copy($fname, $fname2); + var_dump($p->isFileFormat(Phar::TAR)); + $p->copy('a', $ename); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ini_set('phar.readonly',1); $p2 = new Phar($fname2); diff --git a/ext/phar/tests/tar/phar_setalias.phpt b/ext/phar/tests/tar/phar_setalias.phpt index 929ba7f0b804..37d0a475e5f1 100644 --- a/ext/phar/tests/tar/phar_setalias.phpt +++ b/ext/phar/tests/tar/phar_setalias.phpt @@ -22,7 +22,7 @@ $files['b'] = 'b'; $files['c'] = 'c'; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/tar/phar_setalias2.phpt b/ext/phar/tests/tar/phar_setalias2.phpt index eb87c0a2212e..f9d708d58616 100644 --- a/ext/phar/tests/tar/phar_setalias2.phpt +++ b/ext/phar/tests/tar/phar_setalias2.phpt @@ -21,7 +21,7 @@ $files['b'] = 'b'; $files['c'] = 'c'; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); @@ -33,9 +33,9 @@ $b = $phar; $phar = new Phar(__DIR__ . '/notphar.phar'); try { - $phar->setAlias('test'); + $phar->setAlias('test'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/tar/phar_setdefaultstub.phpt b/ext/phar/tests/tar/phar_setdefaultstub.phpt index 0eedd4586154..6811c4c59dd2 100644 --- a/ext/phar/tests/tar/phar_setdefaultstub.phpt +++ b/ext/phar/tests/tar/phar_setdefaultstub.phpt @@ -20,10 +20,10 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub(); - $phar->stopBuffering(); + $phar->setDefaultStub(); + $phar->stopBuffering(); } catch(Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } var_dump($phar->getStub()); @@ -32,10 +32,10 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub('my/custom/thingy.php'); - $phar->stopBuffering(); + $phar->setDefaultStub('my/custom/thingy.php'); + $phar->stopBuffering(); } catch(Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } var_dump($phar->getStub()); @@ -44,10 +44,10 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); - $phar->stopBuffering(); + $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); + $phar->stopBuffering(); } catch(Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } var_dump($phar->getStub()); diff --git a/ext/phar/tests/tar/phar_stub_error.phpt b/ext/phar/tests/tar/phar_stub_error.phpt index 82c0cbf59ff6..c7f13858ddb4 100644 --- a/ext/phar/tests/tar/phar_stub_error.phpt +++ b/ext/phar/tests/tar/phar_stub_error.phpt @@ -23,9 +23,9 @@ var_dump($phar->getStub() == $stub); $newstub = ''; try { - $phar->setStub($newstub); + $phar->setStub($newstub); } catch(exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } var_dump($phar->getStub()); diff --git a/ext/phar/tests/tar/refcount1.phpt b/ext/phar/tests/tar/refcount1.phpt index df33e3a0d4da..cb8b8241aa9e 100644 --- a/ext/phar/tests/tar/refcount1.phpt +++ b/ext/phar/tests/tar/refcount1.phpt @@ -23,7 +23,7 @@ $files['b/c.php'] = ''; $files['.phar/alias.txt'] = 'hio'; foreach ($files as $n => $file) { - $tar->addFile($n, $file); + $tar->addFile($n, $file); } $tar->close(); diff --git a/ext/phar/tests/tar/rename.phpt b/ext/phar/tests/tar/rename.phpt index 2adf01d5f67e..430d7fabb594 100644 --- a/ext/phar/tests/tar/rename.phpt +++ b/ext/phar/tests/tar/rename.phpt @@ -21,7 +21,7 @@ $files = array(); $files['a'] = 'a'; foreach ($files as $n => $file) { - $tar->addFile($n, $file); + $tar->addFile($n, $file); } $tar->close(); diff --git a/ext/phar/tests/tar/rename_dir.phpt b/ext/phar/tests/tar/rename_dir.phpt index e1a3c5d9695d..e4c3afc700ee 100644 --- a/ext/phar/tests/tar/rename_dir.phpt +++ b/ext/phar/tests/tar/rename_dir.phpt @@ -21,7 +21,7 @@ $files = array(); $files['a/x'] = 'a'; foreach ($files as $n => $file) { - $tar->addFile($n, $file); + $tar->addFile($n, $file); } $tar->close(); diff --git a/ext/phar/tests/tar/require_hash.phpt b/ext/phar/tests/tar/require_hash.phpt index 1fd44e18a5cf..537cadfb31f9 100644 --- a/ext/phar/tests/tar/require_hash.phpt +++ b/ext/phar/tests/tar/require_hash.phpt @@ -21,20 +21,20 @@ $tar->addFile('.phar/stub.php', "__HALT_COMPILER();"); $tar->close(); try { - $phar = new Phar($fname); - var_dump($phar->getStub()); + $phar = new Phar($fname); + var_dump($phar->getStub()); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ini_set('phar.require_hash', 0); try { - $phar = new PharData($fname2); - $phar['file'] = 'hi'; - var_dump($phar->getSignature()); - $phar->setSignatureAlgorithm(Phar::MD5); - var_dump($phar->getSignature()); + $phar = new PharData($fname2); + $phar['file'] = 'hi'; + var_dump($phar->getSignature()); + $phar->setSignatureAlgorithm(Phar::MD5); + var_dump($phar->getSignature()); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> diff --git a/ext/phar/tests/tar/rmdir.phpt b/ext/phar/tests/tar/rmdir.phpt index 8e7b30b0f34a..9c48c510c256 100644 --- a/ext/phar/tests/tar/rmdir.phpt +++ b/ext/phar/tests/tar/rmdir.phpt @@ -21,7 +21,7 @@ $files = array(); $files['a/x'] = 'a'; foreach ($files as $n => $file) { - $tar->addFile($n, $file); + $tar->addFile($n, $file); } $tar->mkdir('a'); diff --git a/ext/phar/tests/tar/tar_001.phpt b/ext/phar/tests/tar/tar_001.phpt index 6fc2df3ae7ad..ec275434945a 100644 --- a/ext/phar/tests/tar/tar_001.phpt +++ b/ext/phar/tests/tar/tar_001.phpt @@ -13,10 +13,10 @@ $tar->close(); $tar = fopen('phar://' . __DIR__ . '/tar_001.phar.tar/tar_001.phpt', 'rb'); try { - $phar = new Phar(__DIR__ . '/tar_001.phar.tar'); - echo "should not execute\n"; + $phar = new Phar(__DIR__ . '/tar_001.phar.tar'); + echo "should not execute\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/tar_002.phpt b/ext/phar/tests/tar/tar_002.phpt index 3549035a4dde..188b0abb45f7 100644 --- a/ext/phar/tests/tar/tar_002.phpt +++ b/ext/phar/tests/tar/tar_002.phpt @@ -16,10 +16,10 @@ $tar->close(); $tar = fopen('phar://' . __DIR__ . '/tar_002.phar.tar/tar_002.phpt', 'rb'); try { - $phar = new Phar(__DIR__ . '/tar_002.phar.tar'); - echo "should not execute\n"; + $phar = new Phar(__DIR__ . '/tar_002.phar.tar'); + echo "should not execute\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/tar/tar_003.phpt b/ext/phar/tests/tar/tar_003.phpt index e7b0cf8a7e86..321f3f59cff5 100644 --- a/ext/phar/tests/tar/tar_003.phpt +++ b/ext/phar/tests/tar/tar_003.phpt @@ -32,8 +32,8 @@ echo $e->getMessage()."\n"; } while (false !== ($v = readdir($tar))) { - echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); - echo $v . "\n"; + echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); + echo $v . "\n"; } closedir($tar); @@ -41,8 +41,8 @@ closedir($tar); echo "second round\n"; $tar = opendir($alias . '/'); while (false !== ($v = readdir($tar))) { - echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); - echo $v . "\n"; + echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); + echo $v . "\n"; } closedir($tar); diff --git a/ext/phar/tests/tar/tar_nohash.phpt b/ext/phar/tests/tar/tar_nohash.phpt index e24fea16bf84..07caf79c24c3 100644 --- a/ext/phar/tests/tar/tar_nohash.phpt +++ b/ext/phar/tests/tar/tar_nohash.phpt @@ -9,10 +9,10 @@ phar.require_hash=1 --FILE-- getStub()); + $phar = new PharData(__DIR__ . '/files/Net_URL-1.0.15.tgz'); + var_dump($phar->getStub()); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> diff --git a/ext/phar/tests/tar/tar_nostub.phpt b/ext/phar/tests/tar/tar_nostub.phpt index d100feb83089..d9ae0cdf8366 100644 --- a/ext/phar/tests/tar/tar_nostub.phpt +++ b/ext/phar/tests/tar/tar_nostub.phpt @@ -19,19 +19,19 @@ $tar->addFile('internal/file/here', "hi there!\n"); $tar->close(); try { - $phar = new Phar($fname); - var_dump($phar->getStub()); + $phar = new Phar($fname); + var_dump($phar->getStub()); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } copy($fname, $fname2); try { - $phar = new PharData($fname2); - var_dump($phar->getStub()); + $phar = new PharData($fname2); + var_dump($phar->getStub()); } catch (Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> diff --git a/ext/phar/tests/tar/tar_openssl_hash.phpt b/ext/phar/tests/tar/tar_openssl_hash.phpt index 030ee79db449..b6ed80eeac03 100644 --- a/ext/phar/tests/tar/tar_openssl_hash.phpt +++ b/ext/phar/tests/tar/tar_openssl_hash.phpt @@ -10,9 +10,9 @@ phar.require_hash=1 --FILE-- getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> diff --git a/ext/phar/tests/tar/truncated.phpt b/ext/phar/tests/tar/truncated.phpt index 83adcde24397..f57b4ed5e9ec 100644 --- a/ext/phar/tests/tar/truncated.phpt +++ b/ext/phar/tests/tar/truncated.phpt @@ -5,9 +5,9 @@ Phar: truncated tar --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/zip/033.phpt b/ext/phar/tests/zip/033.phpt index 9eba82f78d1c..4554cfcecfcb 100644 --- a/ext/phar/tests/zip/033.phpt +++ b/ext/phar/tests/zip/033.phpt @@ -19,23 +19,23 @@ $phar->addEmptyDir('test'); $phar->stopBuffering(); try { - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0777); - copy($fname, $fname2); - $phar->setAlias('unused'); - $phar2 = new Phar($fname2); - var_dump($phar2['a.php']->isExecutable()); - $phar['a.php']->chmod(0666); - var_dump($phar['a.php']->isExecutable()); - echo "test dir\n"; - var_dump($phar['test']->isDir()); - var_dump($phar['test']->isReadable()); - $phar['test']->chmod(0000); - var_dump($phar['test']->isReadable()); - $phar['test']->chmod(0666); - var_dump($phar['test']->isReadable()); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0777); + copy($fname, $fname2); + $phar->setAlias('unused'); + $phar2 = new Phar($fname2); + var_dump($phar2['a.php']->isExecutable()); + $phar['a.php']->chmod(0666); + var_dump($phar['a.php']->isExecutable()); + echo "test dir\n"; + var_dump($phar['test']->isDir()); + var_dump($phar['test']->isReadable()); + $phar['test']->chmod(0000); + var_dump($phar['test']->isReadable()); + $phar['test']->chmod(0666); + var_dump($phar['test']->isReadable()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/033a.phpt b/ext/phar/tests/zip/033a.phpt index d0140fba1331..5b94c3e2243f 100644 --- a/ext/phar/tests/zip/033a.phpt +++ b/ext/phar/tests/zip/033a.phpt @@ -19,19 +19,19 @@ $phar->stopBuffering(); ini_set('phar.readonly', 1); try { - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0777); - var_dump($phar['a.php']->isExecutable()); - $phar['a.php']->chmod(0666); - var_dump($phar['a.php']->isExecutable()); - echo "test dir\n"; - var_dump($phar['test']->isExecutable()); - $phar['test']->chmod(0777); - var_dump($phar['test']->isExecutable()); - $phar['test']->chmod(0666); - var_dump($phar['test']->isExecutable()); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0777); + var_dump($phar['a.php']->isExecutable()); + $phar['a.php']->chmod(0666); + var_dump($phar['a.php']->isExecutable()); + echo "test dir\n"; + var_dump($phar['test']->isExecutable()); + $phar['test']->chmod(0777); + var_dump($phar['test']->isExecutable()); + $phar['test']->chmod(0666); + var_dump($phar['test']->isExecutable()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/bzip2.phpt b/ext/phar/tests/zip/bzip2.phpt index 0b1fb31081e9..13bdde3ea6b9 100644 --- a/ext/phar/tests/zip/bzip2.phpt +++ b/ext/phar/tests/zip/bzip2.phpt @@ -6,14 +6,14 @@ Phar: process bzip2-compressed zip entry --FILE-- $file) { - echo $file->getContent(); - } - $a = new Phar(dirname(__FILE__) . '/files/bz2_alias.phar.zip'); - var_dump($a->getAlias()); + $a = new PharData(dirname(__FILE__) . '/files/bzip2.zip'); + foreach ($a as $entry => $file) { + echo $file->getContent(); + } + $a = new Phar(dirname(__FILE__) . '/files/bz2_alias.phar.zip'); + var_dump($a->getAlias()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/phar/tests/zip/corrupt_001.phpt b/ext/phar/tests/zip/corrupt_001.phpt index 188d9719f75d..bccbdc5990b2 100644 --- a/ext/phar/tests/zip/corrupt_001.phpt +++ b/ext/phar/tests/zip/corrupt_001.phpt @@ -5,14 +5,14 @@ Phar: corrupted zip (count mismatch) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/count2.zip'); + new PharData(__DIR__ . '/files/count2.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_002.phpt b/ext/phar/tests/zip/corrupt_002.phpt index 15058fcb227d..4144e5e5b7e0 100644 --- a/ext/phar/tests/zip/corrupt_002.phpt +++ b/ext/phar/tests/zip/corrupt_002.phpt @@ -5,9 +5,9 @@ Phar: corrupted zip (no end of zip record) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_003.phpt b/ext/phar/tests/zip/corrupt_003.phpt index 02fc99e59b7b..6c2aebb9289b 100644 --- a/ext/phar/tests/zip/corrupt_003.phpt +++ b/ext/phar/tests/zip/corrupt_003.phpt @@ -5,9 +5,9 @@ Phar: corrupted zip (truncated file comment) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_004.phpt b/ext/phar/tests/zip/corrupt_004.phpt index bfef6cba5da8..c77722ca9bc0 100644 --- a/ext/phar/tests/zip/corrupt_004.phpt +++ b/ext/phar/tests/zip/corrupt_004.phpt @@ -5,9 +5,9 @@ Phar: corrupted zip (central directory offset incorrect) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_005.phpt b/ext/phar/tests/zip/corrupt_005.phpt index 795f3f17b223..6f46d27e1f5a 100644 --- a/ext/phar/tests/zip/corrupt_005.phpt +++ b/ext/phar/tests/zip/corrupt_005.phpt @@ -5,9 +5,9 @@ Phar: encrypted zip --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_006.phpt b/ext/phar/tests/zip/corrupt_006.phpt index 8c36cd98b838..91642cf6bc12 100644 --- a/ext/phar/tests/zip/corrupt_006.phpt +++ b/ext/phar/tests/zip/corrupt_006.phpt @@ -5,9 +5,9 @@ Phar: zip with file created from stdin --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_007.phpt b/ext/phar/tests/zip/corrupt_007.phpt index 21dcee826a67..d185d75825b7 100644 --- a/ext/phar/tests/zip/corrupt_007.phpt +++ b/ext/phar/tests/zip/corrupt_007.phpt @@ -5,9 +5,9 @@ Phar: corrupted zip (truncated filename record) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_008.phpt b/ext/phar/tests/zip/corrupt_008.phpt index 5fcde01c9418..dd0ffbf478f7 100644 --- a/ext/phar/tests/zip/corrupt_008.phpt +++ b/ext/phar/tests/zip/corrupt_008.phpt @@ -5,79 +5,79 @@ Phar: unsupported compression methods --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup2.zip'); + new PharData(__DIR__ . '/files/compress_unsup2.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup3.zip'); + new PharData(__DIR__ . '/files/compress_unsup3.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup4.zip'); + new PharData(__DIR__ . '/files/compress_unsup4.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup5.zip'); + new PharData(__DIR__ . '/files/compress_unsup5.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup6.zip'); + new PharData(__DIR__ . '/files/compress_unsup6.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup7.zip'); + new PharData(__DIR__ . '/files/compress_unsup7.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup9.zip'); + new PharData(__DIR__ . '/files/compress_unsup9.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup10.zip'); + new PharData(__DIR__ . '/files/compress_unsup10.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup14.zip'); + new PharData(__DIR__ . '/files/compress_unsup14.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup18.zip'); + new PharData(__DIR__ . '/files/compress_unsup18.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup19.zip'); + new PharData(__DIR__ . '/files/compress_unsup19.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup97.zip'); + new PharData(__DIR__ . '/files/compress_unsup97.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsup98.zip'); + new PharData(__DIR__ . '/files/compress_unsup98.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new PharData(__DIR__ . '/files/compress_unsupunknown.zip'); + new PharData(__DIR__ . '/files/compress_unsupunknown.zip'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_009.phpt b/ext/phar/tests/zip/corrupt_009.phpt index 9a86a933e651..20f85bcd7921 100644 --- a/ext/phar/tests/zip/corrupt_009.phpt +++ b/ext/phar/tests/zip/corrupt_009.phpt @@ -5,9 +5,9 @@ Phar: corrupted zip (extra field way too long) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/corrupt_010.phpt b/ext/phar/tests/zip/corrupt_010.phpt index 0106d308ae40..7850dcafdbbf 100644 --- a/ext/phar/tests/zip/corrupt_010.phpt +++ b/ext/phar/tests/zip/corrupt_010.phpt @@ -5,9 +5,9 @@ Phar: unable to process zip (zip spanning multiple archives) --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/create_new_phar_b.phpt b/ext/phar/tests/zip/create_new_phar_b.phpt index 7f838f3f8ae6..d14682f3dc3e 100644 --- a/ext/phar/tests/zip/create_new_phar_b.phpt +++ b/ext/phar/tests/zip/create_new_phar_b.phpt @@ -9,7 +9,7 @@ phar.require_hash=1 diff --git a/ext/phar/tests/zip/exists_as_phar.phpt b/ext/phar/tests/zip/exists_as_phar.phpt index e439eae0153f..31bec4b970b5 100644 --- a/ext/phar/tests/zip/exists_as_phar.phpt +++ b/ext/phar/tests/zip/exists_as_phar.phpt @@ -21,9 +21,9 @@ copy($fname, $tname); $phar->setAlias('hio2'); try { - $p = new Phar($tname); + $p = new Phar($tname); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc index 80c6a3eab6f7..fdbf3e2f6c6d 100644 --- a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc +++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc @@ -34,298 +34,298 @@ */ class corrupt_zipmaker { - /** - * @var int Current position in the writer - * @access private - */ - var $offset = 0; + /** + * @var int Current position in the writer + * @access private + */ + var $offset = 0; - /** - * @var string Optional comment to add to the zip - * @access private - */ - var $comment = ""; + /** + * @var string Optional comment to add to the zip + * @access private + */ + var $comment = ""; - /** - * @var string Data written at the end of the ZIP file - * @access private - */ - var $central = ""; + /** + * @var string Data written at the end of the ZIP file + * @access private + */ + var $central = ""; - /** - * @var string Data written at the start of the ZIP file - * @access private - */ - var $start = ""; + /** + * @var string Data written at the start of the ZIP file + * @access private + */ + var $start = ""; - /** - * Set a comment on the ZIP file - */ - function setComment($comment) { $this->comment = $comment; } + /** + * Set a comment on the ZIP file + */ + function setComment($comment) { $this->comment = $comment; } - /** - * @param int $time Unix timestamp of the date to convert - * @return the date formatted as a ZIP date - */ - function getMTime($time) - { - $mtime = ($time !== null ? getdate($time) : getdate()); - $mtime = preg_replace( - "/(..){1}(..){1}(..){1}(..){1}/", - "\\x\\4\\x\\3\\x\\2\\x\\1", - dechex(($mtime['year']-1980<<25)| - ($mtime['mon' ]<<21)| - ($mtime['mday' ]<<16)| - ($mtime['hours' ]<<11)| - ($mtime['minutes']<<5)| - ($mtime['seconds']>>1))); - eval('$mtime = "'.$mtime.'";'); - return $mtime; - } + /** + * @param int $time Unix timestamp of the date to convert + * @return the date formatted as a ZIP date + */ + function getMTime($time) + { + $mtime = ($time !== null ? getdate($time) : getdate()); + $mtime = preg_replace( + "/(..){1}(..){1}(..){1}(..){1}/", + "\\x\\4\\x\\3\\x\\2\\x\\1", + dechex(($mtime['year']-1980<<25)| + ($mtime['mon' ]<<21)| + ($mtime['mday' ]<<16)| + ($mtime['hours' ]<<11)| + ($mtime['minutes']<<5)| + ($mtime['seconds']>>1))); + eval('$mtime = "'.$mtime.'";'); + return $mtime; + } - private function getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $corrupt, $fakecomp) - { - switch ($corrupt) { - case null : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . - $filename . - $data; - break; - case 'compress' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $fakecomp) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . - $filename . - $data; - break; - case 'encrypt' : - $file = "PK\x03\x04\x14\x00\x01\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . - $filename . - $data; - break; - case 'crc32' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00) . - $filename . - $data; - break; - case 'complength' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength + 1, $uncomplength, strlen($filename), 0x00) . - $filename . - $data; - break; - case 'uncomplength' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00) . - $filename . - $data; - break; - case 'filename_len' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00) . - $filename . - $data; - break; - case 'extra_len' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 1) . - $filename . - $data; - break; - case 'filename' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . - substr($filename, 1) . - $data; - break; - case 'data' : - $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . - $filename . - substr($data, 1); - break; - } - return $file; - } + private function getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $corrupt, $fakecomp) + { + switch ($corrupt) { + case null : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'compress' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $fakecomp) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'encrypt' : + $file = "PK\x03\x04\x14\x00\x01\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'crc32' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'complength' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength + 1, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'uncomplength' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'filename_len' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00) . + $filename . + $data; + break; + case 'extra_len' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 1) . + $filename . + $data; + break; + case 'filename' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + substr($filename, 1) . + $data; + break; + case 'data' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + substr($data, 1); + break; + } + return $file; + } - private function getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $corrupt, &$offset, $fakecomp) - { - settype($comment, 'string'); - switch ($corrupt) { - case null : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'encrypt' : - $central = "PK\x01\x02\x00\x00\x14\x00\x01\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'compress' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $fakecomp) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'crc32' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'complength' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength - 1, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'uncomplength' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'filename_len' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'offset' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, - 0x0000, $this->offset - 1). - $filename . $comment; - $offset = strlen($central) - 1; - break; - case 'comment' : - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment) + 1,0x00,0x00, - 0x0000, $this->offset). - $filename . $comment; - $offset = strlen($central); - break; - case 'extralen1' : - $extra = 'nu' . 0xffff; // way huge size - $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . - $mtime . - pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00, - 0x0000, $this->offset). - $filename . $extra . $comment; - $offset = strlen($central); - break; - } - return $central; - } + private function getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $corrupt, &$offset, $fakecomp) + { + settype($comment, 'string'); + switch ($corrupt) { + case null : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'encrypt' : + $central = "PK\x01\x02\x00\x00\x14\x00\x01\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'compress' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $fakecomp) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'crc32' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'complength' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength - 1, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'uncomplength' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'filename_len' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'offset' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset - 1). + $filename . $comment; + $offset = strlen($central) - 1; + break; + case 'comment' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment) + 1,0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'extralen1' : + $extra = 'nu' . 0xffff; // way huge size + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $extra . $comment; + $offset = strlen($central); + break; + } + return $central; + } - function addFile($filename, $mtime, $data, $comment = null, $compress = null, $filecorrupt = null, $centralcorrupt = null, $fakecomp = 1) - { - $mtime = $this->getMTime($mtime ? $mtime : null); + function addFile($filename, $mtime, $data, $comment = null, $compress = null, $filecorrupt = null, $centralcorrupt = null, $fakecomp = 1) + { + $mtime = $this->getMTime($mtime ? $mtime : null); - $uncomplength = strlen($data); - $crc32 = crc32($data) & 0xFFFFFFFF; - $compmethod = 0; - switch ($compress) { - case 'gz' : - $data = gzcompress($data); - $compmethod = 8; - break; - case 'bz2' : - $data = bzcompress($data); - $compmethod = 12; - break; - } - $complength = strlen($data); + $uncomplength = strlen($data); + $crc32 = crc32($data) & 0xFFFFFFFF; + $compmethod = 0; + switch ($compress) { + case 'gz' : + $data = gzcompress($data); + $compmethod = 8; + break; + case 'bz2' : + $data = bzcompress($data); + $compmethod = 12; + break; + } + $complength = strlen($data); - $this->start .= ($file = $this->getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $filecorrupt, $fakecomp)); + $this->start .= ($file = $this->getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $filecorrupt, $fakecomp)); - $offset = 0; - $this->central .= $this->getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $centralcorrupt, $offset, $fakecomp); + $offset = 0; + $this->central .= $this->getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $centralcorrupt, $offset, $fakecomp); - $this->offset += $offset; - $this->count++; - } + $this->offset += $offset; + $this->count++; + } - function writeZip($zipfile, $corrupt = null) - { - $write = $this->start . $this->central; - switch ($corrupt) { - case null : - $write .= "PK\x05\x06\x00\x00\x00\x00" . - pack("vvVVv", $this->count, $this->count, - $this->offset, strlen($this->start), - strlen($this->comment)) . $this->comment; - break; - case 'disknumber' : - $write .= "PK\x05\x06\x01\x00\x01\x00" . - pack("vvVVv", $this->count, $this->count, - $this->offset, strlen($this->start), - strlen($this->comment)) . $this->comment; - break; - case 'count1' : - $write .= "PK\x05\x06\x00\x00\x00\x00" . - pack("vvVVv", $this->count + 1, $this->count, - $this->offset, strlen($this->start), - strlen($this->comment)) . $this->comment; - break; - case 'count2' : - $write .= "PK\x05\x06\x00\x00\x00\x00" . - pack("vvVVv", $this->count, $this->count + 1, - $this->offset, strlen($this->start), - strlen($this->comment)) . $this->comment; - break; - case 'cdir_offset' : - $write .= "PK\x05\x06\x00\x00\x00\x00" . - pack("vvVVv", $this->count, $this->count, - $this->offset, strlen($this->start) - 3, - strlen($this->comment)) . $this->comment; - break; - case 'cdir_len' : - $write .= "PK\x05\x06\x00\x00\x00\x00" . - pack("vvVVv", $this->count, $this->count, - $this->offset - 5, strlen($this->start), - strlen($this->comment)) . $this->comment; - break; - case 'comment' : - $write .= "PK\x05\x06\x00\x00\x00\x00" . - pack("vvVVv", $this->count, $this->count, - strlen($this->start), $this->offset + 1, - strlen($this->comment) + 1) . $this->comment; - break; - case 'none' : - } - file_put_contents($zipfile, $write); - } + function writeZip($zipfile, $corrupt = null) + { + $write = $this->start . $this->central; + switch ($corrupt) { + case null : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'disknumber' : + $write .= "PK\x05\x06\x01\x00\x01\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'count1' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count + 1, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'count2' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count + 1, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'cdir_offset' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start) - 3, + strlen($this->comment)) . $this->comment; + break; + case 'cdir_len' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset - 5, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'comment' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + strlen($this->start), $this->offset + 1, + strlen($this->comment) + 1) . $this->comment; + break; + case 'none' : + } + file_put_contents($zipfile, $write); + } } ?> diff --git a/ext/phar/tests/zip/files/make_invalid_tar.php.inc b/ext/phar/tests/zip/files/make_invalid_tar.php.inc index 4f4758bbb643..78fc06629cf6 100644 --- a/ext/phar/tests/zip/files/make_invalid_tar.php.inc +++ b/ext/phar/tests/zip/files/make_invalid_tar.php.inc @@ -3,10 +3,10 @@ include dirname(__FILE__) . '/tarmaker.php.inc'; class corrupter extends tarmaker { function close() { - parent::close(); - $fp = fopen($this->path, 'r+b'); - fseek($fp, 20); - fwrite($fp, 'oopsie'); - fclose($fp); + parent::close(); + $fp = fopen($this->path, 'r+b'); + fseek($fp, 20); + fwrite($fp, 'oopsie'); + fclose($fp); } } diff --git a/ext/phar/tests/zip/metadata_write_commit.phpt b/ext/phar/tests/zip/metadata_write_commit.phpt index 522ddd10e7d7..e0e09599af9b 100644 --- a/ext/phar/tests/zip/metadata_write_commit.phpt +++ b/ext/phar/tests/zip/metadata_write_commit.phpt @@ -23,7 +23,7 @@ $files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there')); $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar')); foreach($files as $name => $cont) { - var_dump(file_get_contents($p2name.'/'.$name)); + var_dump(file_get_contents($p2name.'/'.$name)); } copy($f2name, $fname); @@ -36,7 +36,7 @@ $phar['d']->setMetadata(true); $phar->setMetadata('hi'); foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } $phar->stopBuffering(); @@ -45,11 +45,11 @@ unset($phar); $phar = new Phar($fname); foreach($files as $name => $cont) { - var_dump(file_get_contents($pname.'/'.$name)); + var_dump(file_get_contents($pname.'/'.$name)); } foreach($files as $name => $cont) { - var_dump($phar[$name]->getMetadata()); + var_dump($phar[$name]->getMetadata()); } var_dump($phar->getMetadata()); ?> diff --git a/ext/phar/tests/zip/odt.phpt b/ext/phar/tests/zip/odt.phpt index 6f229440f37d..af3a52cc9db3 100644 --- a/ext/phar/tests/zip/odt.phpt +++ b/ext/phar/tests/zip/odt.phpt @@ -7,17 +7,17 @@ Phar: test a zip archive created by openoffice isDir()) { - echo "dir " . $b->getPathName() . "\n"; - } else { - echo $b->getPathName() . "\n"; - } + if ($b->isDir()) { + echo "dir " . $b->getPathName() . "\n"; + } else { + echo $b->getPathName() . "\n"; + } } // this next line is for increased code coverage try { - $b = new Phar(__DIR__ . '/files/odt.odt'); + $b = new Phar(__DIR__ . '/files/odt.odt'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/open_for_write_existing.phpt b/ext/phar/tests/zip/open_for_write_existing.phpt index c878f5cb1dde..f679df744e96 100644 --- a/ext/phar/tests/zip/open_for_write_existing.phpt +++ b/ext/phar/tests/zip/open_for_write_existing.phpt @@ -21,7 +21,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/open_for_write_existing_b.phpt b/ext/phar/tests/zip/open_for_write_existing_b.phpt index 68a2d14eddf1..dd605618eac3 100644 --- a/ext/phar/tests/zip/open_for_write_existing_b.phpt +++ b/ext/phar/tests/zip/open_for_write_existing_b.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/open_for_write_existing_c.phpt b/ext/phar/tests/zip/open_for_write_existing_c.phpt index f62cd4290b0a..c4eb78c6588d 100644 --- a/ext/phar/tests/zip/open_for_write_existing_c.phpt +++ b/ext/phar/tests/zip/open_for_write_existing_c.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/open_for_write_newfile.phpt b/ext/phar/tests/zip/open_for_write_newfile.phpt index a3db9558b888..3791689a3157 100644 --- a/ext/phar/tests/zip/open_for_write_newfile.phpt +++ b/ext/phar/tests/zip/open_for_write_newfile.phpt @@ -21,7 +21,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/open_for_write_newfile_b.phpt b/ext/phar/tests/zip/open_for_write_newfile_b.phpt index 35a50a12fb5d..167350abd13d 100644 --- a/ext/phar/tests/zip/open_for_write_newfile_b.phpt +++ b/ext/phar/tests/zip/open_for_write_newfile_b.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/open_for_write_newfile_c.phpt b/ext/phar/tests/zip/open_for_write_newfile_c.phpt index 0b8e86f7f598..1c2d34505057 100644 --- a/ext/phar/tests/zip/open_for_write_newfile_c.phpt +++ b/ext/phar/tests/zip/open_for_write_newfile_c.phpt @@ -23,7 +23,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/phar_buildfromiterator4.phpt b/ext/phar/tests/zip/phar_buildfromiterator4.phpt index 8e6f3993c32b..aa1e3596abb4 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator4.phpt @@ -36,13 +36,13 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt')))); - var_dump($phar->isFileFormat(Phar::ZIP)); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . 'phpt')))); + var_dump($phar->isFileFormat(Phar::ZIP)); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_buildfromiterator5.phpt b/ext/phar/tests/zip/phar_buildfromiterator5.phpt index cf7700b965bc..329a30a5c3f1 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator5.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => new stdClass)))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_buildfromiterator6.phpt b/ext/phar/tests/zip/phar_buildfromiterator6.phpt index 0853c8fa2467..a2c49f1d561f 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator6.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); - var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); + var_dump($phar->buildFromIterator(new myIterator(array(basename(__FILE__, 'php') . 'phpt')))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_buildfromiterator7.phpt b/ext/phar/tests/zip/phar_buildfromiterator7.phpt index d4f26e40dbab..45d36f41e06b 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator7.phpt @@ -36,12 +36,12 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => basename(__FILE__, 'php') . '/oopsie/there.phpt')))); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_buildfromiterator8.phpt b/ext/phar/tests/zip/phar_buildfromiterator8.phpt index 17131709818c..c411e6ee1281 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator8.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator8.phpt @@ -7,15 +7,15 @@ phar.readonly=0 --FILE-- buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR); - asort($a); - var_dump($a); - var_dump($phar->isFileFormat(Phar::ZIP)); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar.zip'); + $a = $phar->buildFromIterator(new RegexIterator(new DirectoryIterator('.'), '/^frontcontroller\d{0,2}\.phar\.phpt\\z|^\.\\z|^\.\.\\z/'), __DIR__ . DIRECTORY_SEPARATOR); + asort($a); + var_dump($a); + var_dump($phar->isFileFormat(Phar::ZIP)); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_buildfromiterator9.phpt b/ext/phar/tests/zip/phar_buildfromiterator9.phpt index 10361fbeb425..414924d80758 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator9.phpt @@ -36,13 +36,13 @@ class myIterator implements Iterator } } try { - chdir(__DIR__); - $phar = new Phar(__DIR__ . '/buildfromiterator.phar'); - var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); - fclose($a); + chdir(__DIR__); + $phar = new Phar(__DIR__ . '/buildfromiterator.phar'); + var_dump($phar->buildFromIterator(new myIterator(array('a' => $a = fopen(basename(__FILE__, 'php') . 'phpt', 'r'))))); + fclose($a); } catch (Exception $e) { - var_dump(get_class($e)); - echo $e->getMessage() . "\n"; + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_copy.phpt b/ext/phar/tests/zip/phar_copy.phpt index f6424936b7a5..ea4f108dfcb0 100644 --- a/ext/phar/tests/zip/phar_copy.phpt +++ b/ext/phar/tests/zip/phar_copy.phpt @@ -19,20 +19,20 @@ $p = new Phar($fname); try { - $p['a'] = 'hi'; - $p->startBuffering(); - $p->copy('a', 'b'); - echo file_get_contents($p['b']->getPathName()); - $p->copy('b', 'c'); - $p->stopBuffering(); - echo file_get_contents($p['c']->getPathName()); - copy($fname, $fname2); - var_dump($p->isFileFormat(Phar::ZIP)); - $p->copy('a', $ename); + $p['a'] = 'hi'; + $p->startBuffering(); + $p->copy('a', 'b'); + echo file_get_contents($p['b']->getPathName()); + $p->copy('b', 'c'); + $p->stopBuffering(); + echo file_get_contents($p['c']->getPathName()); + copy($fname, $fname2); + var_dump($p->isFileFormat(Phar::ZIP)); + $p->copy('a', $ename); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ini_set('phar.readonly',1); $p2 = new Phar($fname2); diff --git a/ext/phar/tests/zip/phar_setalias.phpt b/ext/phar/tests/zip/phar_setalias.phpt index 214831608663..96453a90ff50 100644 --- a/ext/phar/tests/zip/phar_setalias.phpt +++ b/ext/phar/tests/zip/phar_setalias.phpt @@ -25,7 +25,7 @@ $files['b'] = 'b'; $files['c'] = 'c'; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/phar_setalias2.phpt b/ext/phar/tests/zip/phar_setalias2.phpt index 0af688703b79..e438e64bb519 100644 --- a/ext/phar/tests/zip/phar_setalias2.phpt +++ b/ext/phar/tests/zip/phar_setalias2.phpt @@ -21,7 +21,7 @@ $files['b'] = 'b'; $files['c'] = 'c'; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); @@ -31,9 +31,9 @@ echo $phar->getAlias() . "\n"; $b = $phar; $phar = new Phar(__DIR__ . '/notphar.phar'); try { - $phar->setAlias('test'); + $phar->setAlias('test'); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --CLEAN-- diff --git a/ext/phar/tests/zip/phar_setdefaultstub.phpt b/ext/phar/tests/zip/phar_setdefaultstub.phpt index 92a721ba37c4..9b5f3959574b 100644 --- a/ext/phar/tests/zip/phar_setdefaultstub.phpt +++ b/ext/phar/tests/zip/phar_setdefaultstub.phpt @@ -20,10 +20,10 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub(); - $phar->stopBuffering(); + $phar->setDefaultStub(); + $phar->stopBuffering(); } catch(Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } var_dump($phar->getStub()); @@ -32,10 +32,10 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub('my/custom/thingy.php'); - $phar->stopBuffering(); + $phar->setDefaultStub('my/custom/thingy.php'); + $phar->stopBuffering(); } catch(Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } var_dump($phar->getStub()); @@ -44,10 +44,10 @@ echo "========================================================================== echo "============================================================================\n"; try { - $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); - $phar->stopBuffering(); + $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); + $phar->stopBuffering(); } catch(Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } var_dump($phar->getStub()); diff --git a/ext/phar/tests/zip/phar_stub_error.phpt b/ext/phar/tests/zip/phar_stub_error.phpt index 0d2cedebc30b..d19393f430e8 100644 --- a/ext/phar/tests/zip/phar_stub_error.phpt +++ b/ext/phar/tests/zip/phar_stub_error.phpt @@ -22,11 +22,11 @@ var_dump($phar->getStub() == $stub); $newstub = ''; try { - $phar->setStub($newstub); + $phar->setStub($newstub); } catch(exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } var_dump($phar->getStub()); var_dump($phar->getStub() == $stub); diff --git a/ext/phar/tests/zip/refcount1.phpt b/ext/phar/tests/zip/refcount1.phpt index e5db8285e184..0fd122a79c9f 100644 --- a/ext/phar/tests/zip/refcount1.phpt +++ b/ext/phar/tests/zip/refcount1.phpt @@ -22,7 +22,7 @@ $files['b.php'] = ''; $files['b/c.php'] = ''; foreach ($files as $n => $file) { - $phar[$n] = $file; + $phar[$n] = $file; } $phar->stopBuffering(); diff --git a/ext/phar/tests/zip/unixzip.phpt b/ext/phar/tests/zip/unixzip.phpt index e281a18f0b72..f1a51fede869 100644 --- a/ext/phar/tests/zip/unixzip.phpt +++ b/ext/phar/tests/zip/unixzip.phpt @@ -6,15 +6,15 @@ Phar: test a zip archive created by unix "zip" command isDir()) { - echo "dir " . $b->getPathName() . "\n"; - } else { - echo $b->getPathName(), "\n"; - echo file_get_contents($b->getPathName()), "\n"; - } + if ($b->isDir()) { + echo "dir " . $b->getPathName() . "\n"; + } else { + echo $b->getPathName(), "\n"; + echo file_get_contents($b->getPathName()), "\n"; + } } if (isset($a['notempty/hi.txt'])) { - echo $a['notempty/hi.txt']->getPathName() . "\n"; + echo $a['notempty/hi.txt']->getPathName() . "\n"; } ?> --EXPECTF-- diff --git a/ext/phar/tests/zip/zlib.phpt b/ext/phar/tests/zip/zlib.phpt index 5cd59fcac42f..96b63e73a6f4 100644 --- a/ext/phar/tests/zip/zlib.phpt +++ b/ext/phar/tests/zip/zlib.phpt @@ -6,10 +6,10 @@ Phar: process zlib-compressed zip alias --FILE-- getAlias()); + $a = new Phar(__DIR__ . '/files/zlib_alias.phar.zip'); + var_dump($a->getAlias()); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/posix/tests/posix_getgroups_basic.phpt b/ext/posix/tests/posix_getgroups_basic.phpt index fd8b3af30538..7a877d7663ba 100644 --- a/ext/posix/tests/posix_getgroups_basic.phpt +++ b/ext/posix/tests/posix_getgroups_basic.phpt @@ -11,9 +11,9 @@ Test posix_getgroups() function : basic functionality $groups = posix_getgroups(); if (!is_array($groups)) { - echo "TEST FAILED - array result expected\n"; + echo "TEST FAILED - array result expected\n"; } else { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } ?> diff --git a/ext/posix/tests/posix_kill_basic.phpt b/ext/posix/tests/posix_kill_basic.phpt index 4ce50ca49742..6e48ebed3b1f 100644 --- a/ext/posix/tests/posix_kill_basic.phpt +++ b/ext/posix/tests/posix_kill_basic.phpt @@ -8,24 +8,24 @@ Test posix_kill(), posix_get_last_error and posix_strerror() functions : basic f ===DONE==== diff --git a/ext/posix/tests/posix_times_basic.phpt b/ext/posix/tests/posix_times_basic.phpt index ad37834fd91a..49da6b8aebd0 100644 --- a/ext/posix/tests/posix_times_basic.phpt +++ b/ext/posix/tests/posix_times_basic.phpt @@ -14,8 +14,8 @@ Test posix_times() function : basic functionality if ($times == FALSE) { - $errno= posix_get_last_error(); - var_dump(posix_strerror($errno)); + $errno= posix_get_last_error(); + var_dump(posix_strerror($errno)); } ?> diff --git a/ext/pspell/tests/002.phpt b/ext/pspell/tests/002.phpt index 538775d01344..34913ae82664 100644 --- a/ext/pspell/tests/002.phpt +++ b/ext/pspell/tests/002.phpt @@ -18,11 +18,11 @@ var_dump(pspell_check($p, 'somebogusword')); $res = @pspell_clear_session($p); if ($res) { - var_dump($res); - var_dump(pspell_check($p, 'somebogusword')); + var_dump($res); + var_dump(pspell_check($p, 'somebogusword')); } else { - echo "bool(true)\n"; - echo "bool(false)\n"; + echo "bool(true)\n"; + echo "bool(false)\n"; } ?> --EXPECTF-- diff --git a/ext/readline/tests/libedit_callback_handler_install_001.phpt b/ext/readline/tests/libedit_callback_handler_install_001.phpt index fb69ba5cb027..c4cfced6278e 100644 --- a/ext/readline/tests/libedit_callback_handler_install_001.phpt +++ b/ext/readline/tests/libedit_callback_handler_install_001.phpt @@ -8,7 +8,7 @@ if (READLINE_LIB != "libedit") die("skip libedit only"); diff --git a/ext/reflection/tests/001.phpt b/ext/reflection/tests/001.phpt index 266a1ef5ffb4..d4760136532a 100644 --- a/ext/reflection/tests/001.phpt +++ b/ext/reflection/tests/001.phpt @@ -5,17 +5,17 @@ Reflection inheritance class ReflectionClassEx extends ReflectionClass { - public $bla; + public $bla; - function getMethodNames() - { - $res = array(); - foreach($this->getMethods() as $m) - { - $res[] = $m->class . '::' . $m->name; - } - return $res; - } + function getMethodNames() + { + $res = array(); + foreach($this->getMethods() as $m) + { + $res[] = $m->class . '::' . $m->name; + } + return $res; + } } $r = new ReflectionClassEx('ReflectionClassEx'); @@ -62,10 +62,10 @@ $res = $r->getMethodNames(); foreach($exp as $m) { - if (!in_array($m, $exp)) - { - $miss[] = $m; - } + if (!in_array($m, $exp)) + { + $miss[] = $m; + } } var_dump($miss); diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt index 6df97f0daacf..b10013d2a933 100644 --- a/ext/reflection/tests/002.phpt +++ b/ext/reflection/tests/002.phpt @@ -5,13 +5,13 @@ Reflection properties are read only class ReflectionMethodEx extends ReflectionMethod { - public $foo = "xyz"; + public $foo = "xyz"; - function __construct($c,$m) - { - echo __METHOD__ . "\n"; - parent::__construct($c,$m); - } + function __construct($c,$m) + { + echo __METHOD__ . "\n"; + parent::__construct($c,$m); + } } $r = new ReflectionMethodEx('ReflectionMethodEx','getName'); @@ -23,11 +23,11 @@ var_dump($r->foo); try { - $r->class = 'bullshit'; + $r->class = 'bullshit'; } catch(ReflectionException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { @@ -35,7 +35,7 @@ $r->name = 'bullshit'; } catch(ReflectionException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $r->foo = 'bar'; diff --git a/ext/reflection/tests/003.phpt b/ext/reflection/tests/003.phpt index 8c37d539ac29..dbafebfb8dab 100644 --- a/ext/reflection/tests/003.phpt +++ b/ext/reflection/tests/003.phpt @@ -5,18 +5,18 @@ ReflectionMethod::invoke() with base class method class Foo { - function Test() - { - echo __METHOD__ . "\n"; - } + function Test() + { + echo __METHOD__ . "\n"; + } } class Bar extends Foo { - function Test() - { - echo __METHOD__ . "\n"; - } + function Test() + { + echo __METHOD__ . "\n"; + } } $o = new Bar; diff --git a/ext/reflection/tests/004.phpt b/ext/reflection/tests/004.phpt index 924c3fe2833b..3739d2e55c94 100644 --- a/ext/reflection/tests/004.phpt +++ b/ext/reflection/tests/004.phpt @@ -4,8 +4,8 @@ ReflectionMethod::invoke() with non object or null value getDocComment())); foreach($r->getMethods() as $m) { - var_dump(strip_doc_comment($m->getDocComment())); + var_dump(strip_doc_comment($m->getDocComment())); } ?> diff --git a/ext/reflection/tests/006.phpt b/ext/reflection/tests/006.phpt index 28d4cc592b96..c21aa5af8b47 100644 --- a/ext/reflection/tests/006.phpt +++ b/ext/reflection/tests/006.phpt @@ -9,73 +9,73 @@ ReflectionClass::[gs]etStaticPropertyValue Class Test { - static public $pub = 'pub'; - static protected $pro = 'pro'; - static private $pri = 'pri'; + static public $pub = 'pub'; + static protected $pro = 'pro'; + static private $pri = 'pri'; - static function testing() - { - $ref = new ReflectionClass('Test'); + static function testing() + { + $ref = new ReflectionClass('Test'); - foreach(array('pub', 'pro', 'pri') as $name) - { - try - { - var_dump($ref->getStaticPropertyValue($name)); - var_dump($ref->getStaticPropertyValue($name)); - $ref->setStaticPropertyValue($name, 'updated'); - var_dump($ref->getStaticPropertyValue($name)); - } - catch(Exception $e) - { - echo "EXCEPTION\n"; - } - } - } + foreach(array('pub', 'pro', 'pri') as $name) + { + try + { + var_dump($ref->getStaticPropertyValue($name)); + var_dump($ref->getStaticPropertyValue($name)); + $ref->setStaticPropertyValue($name, 'updated'); + var_dump($ref->getStaticPropertyValue($name)); + } + catch(Exception $e) + { + echo "EXCEPTION\n"; + } + } + } } Class TestDerived extends Test { // static public $pub = 'pub'; // static protected $pro = 'pro'; - static private $pri = 'pri'; + static private $pri = 'pri'; - static function testing() - { - $ref = new ReflectionClass('Test'); + static function testing() + { + $ref = new ReflectionClass('Test'); - foreach(array('pub', 'pro', 'pri') as $name) - { - try - { - var_dump($ref->getStaticPropertyValue($name)); - var_dump($ref->getStaticPropertyValue($name)); - $ref->setStaticPropertyValue($name, 'updated'); - var_dump($ref->getStaticPropertyValue($name)); - } - catch(Exception $e) - { - echo "EXCEPTION\n"; - } - } - } + foreach(array('pub', 'pro', 'pri') as $name) + { + try + { + var_dump($ref->getStaticPropertyValue($name)); + var_dump($ref->getStaticPropertyValue($name)); + $ref->setStaticPropertyValue($name, 'updated'); + var_dump($ref->getStaticPropertyValue($name)); + } + catch(Exception $e) + { + echo "EXCEPTION\n"; + } + } + } } $ref = new ReflectionClass('Test'); foreach(array('pub', 'pro', 'pri') as $name) { - try - { - var_dump($ref->getStaticPropertyValue($name)); - var_dump($ref->getStaticPropertyValue($name)); - $ref->setStaticPropertyValue($name, 'updated'); - var_dump($ref->getStaticPropertyValue($name)); - } - catch(Exception $e) - { - echo "EXCEPTION\n"; - } + try + { + var_dump($ref->getStaticPropertyValue($name)); + var_dump($ref->getStaticPropertyValue($name)); + $ref->setStaticPropertyValue($name, 'updated'); + var_dump($ref->getStaticPropertyValue($name)); + } + catch(Exception $e) + { + echo "EXCEPTION\n"; + } } Test::testing(); diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt index 57e3ee47fe43..df1d97eea966 100644 --- a/ext/reflection/tests/007.phpt +++ b/ext/reflection/tests/007.phpt @@ -5,56 +5,56 @@ ReflectionClass::newInstance[Args] function test($class) { - echo "====>$class\n"; - try - { - $ref = new ReflectionClass($class); - } - catch (ReflectionException $e) - { - var_dump($e->getMessage()); - return; // only here - } - - echo "====>newInstance()\n"; - try - { - var_dump($ref->newInstance()); - } - catch (ReflectionException $e) - { - var_dump($e->getMessage()); - } - catch (Throwable $e) - { - echo "Exception: " . $e->getMessage() . "\n"; - } - - echo "====>newInstance(25)\n"; - try - { - var_dump($ref->newInstance(25)); - } - catch (ReflectionException $e) - { - var_dump($e->getMessage()); - } - - echo "====>newInstance(25, 42)\n"; - try - { - var_dump($ref->newInstance(25, 42)); - } - catch (ReflectionException $e) - { - var_dump($e->getMessage()); - } - - echo "\n"; + echo "====>$class\n"; + try + { + $ref = new ReflectionClass($class); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + return; // only here + } + + echo "====>newInstance()\n"; + try + { + var_dump($ref->newInstance()); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + } + catch (Throwable $e) + { + echo "Exception: " . $e->getMessage() . "\n"; + } + + echo "====>newInstance(25)\n"; + try + { + var_dump($ref->newInstance(25)); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + } + + echo "====>newInstance(25, 42)\n"; + try + { + var_dump($ref->newInstance(25, 42)); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + } + + echo "\n"; } spl_autoload_register(function ($class) { - echo __FUNCTION__ . "($class)\n"; + echo __FUNCTION__ . "($class)\n"; }); test('Class_does_not_exist'); @@ -67,22 +67,22 @@ test('NoCtor'); Class WithCtor { - function __construct() - { - echo __METHOD__ . "()\n"; - var_dump(func_get_args()); - } + function __construct() + { + echo __METHOD__ . "()\n"; + var_dump(func_get_args()); + } } test('WithCtor'); Class WithCtorWithArgs { - function __construct($arg) - { - echo __METHOD__ . "($arg)\n"; - var_dump(func_get_args()); - } + function __construct($arg) + { + echo __METHOD__ . "($arg)\n"; + var_dump(func_get_args()); + } } test('WithCtorWithArgs'); diff --git a/ext/reflection/tests/008.phpt b/ext/reflection/tests/008.phpt index 80a4a39218e0..10806b001566 100644 --- a/ext/reflection/tests/008.phpt +++ b/ext/reflection/tests/008.phpt @@ -6,22 +6,22 @@ ReflectionMethod::__construct() tests $a = array("", 1, "::", "a::", "::b", "a::b"); foreach ($a as $val) { - try { - new ReflectionMethod($val); - } catch (Exception $e) { - var_dump($e->getMessage()); - } + try { + new ReflectionMethod($val); + } catch (Exception $e) { + var_dump($e->getMessage()); + } } $a = array("", 1, ""); $b = array("", "", 1); foreach ($a as $key=>$val) { - try { - new ReflectionMethod($val, $b[$key]); - } catch (Exception $e) { - var_dump($e->getMessage()); - } + try { + new ReflectionMethod($val, $b[$key]); + } catch (Exception $e) { + var_dump($e->getMessage()); + } } echo "Done\n"; diff --git a/ext/reflection/tests/009.phpt b/ext/reflection/tests/009.phpt index d582623cbdd8..8a57ed9d1d3b 100644 --- a/ext/reflection/tests/009.phpt +++ b/ext/reflection/tests/009.phpt @@ -9,7 +9,7 @@ opcache.save_comments=1 hoho */ function test ($a, $b = 1, $c = "") { - static $var = 1; + static $var = 1; } $func = new ReflectionFunction("test"); diff --git a/ext/reflection/tests/010.phpt b/ext/reflection/tests/010.phpt index ae667b65ab91..ae1e4dff0b5d 100644 --- a/ext/reflection/tests/010.phpt +++ b/ext/reflection/tests/010.phpt @@ -3,12 +3,12 @@ ReflectionMethod::__toString() tests (overridden method) --FILE-- getDefaultProperties(); diff --git a/ext/reflection/tests/017.phpt b/ext/reflection/tests/017.phpt index 322065bf20e3..be306b53c6f3 100644 --- a/ext/reflection/tests/017.phpt +++ b/ext/reflection/tests/017.phpt @@ -3,7 +3,7 @@ ReflectionClass::__toString() (constants) --FILE-- hasProperty("p1")); diff --git a/ext/reflection/tests/021.phpt b/ext/reflection/tests/021.phpt index 42d11cc44566..fefcf34e78c0 100644 --- a/ext/reflection/tests/021.phpt +++ b/ext/reflection/tests/021.phpt @@ -3,7 +3,7 @@ ReflectionClass::hasConstant --FILE-- hasConstant("c1")); diff --git a/ext/reflection/tests/022.phpt b/ext/reflection/tests/022.phpt index 2cfd603dad19..4a6738f97cd2 100644 --- a/ext/reflection/tests/022.phpt +++ b/ext/reflection/tests/022.phpt @@ -3,7 +3,7 @@ ReflectionClass::getConstant --FILE-- getConstant("c1")); diff --git a/ext/reflection/tests/023.phpt b/ext/reflection/tests/023.phpt index fe10b2531a0e..7f8c5000154b 100644 --- a/ext/reflection/tests/023.phpt +++ b/ext/reflection/tests/023.phpt @@ -3,14 +3,14 @@ ReflectionClass::getDefaultProperties (filtering parent privates) --FILE-- getDefaultProperties()); diff --git a/ext/reflection/tests/024.phpt b/ext/reflection/tests/024.phpt index 2b894d3f31b5..0fb1cd6fe231 100644 --- a/ext/reflection/tests/024.phpt +++ b/ext/reflection/tests/024.phpt @@ -3,9 +3,9 @@ ReflectionObject::__toString (filtering privates/protected dynamic properties) --FILE-- next(); try { - $r->getTrace(); + $r->getTrace(); } catch (ReflectionException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECT-- diff --git a/ext/reflection/tests/028.phpt b/ext/reflection/tests/028.phpt index ed6950fce3e8..bf16785c185a 100644 --- a/ext/reflection/tests/028.phpt +++ b/ext/reflection/tests/028.phpt @@ -4,16 +4,16 @@ ReflectionGenerator::__construct() next(); try { - $r = new ReflectionGenerator($g); + $r = new ReflectionGenerator($g); } catch (ReflectionException $e) { - echo "Done!\n"; + echo "Done!\n"; } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_constructor_001.phpt b/ext/reflection/tests/ReflectionClass_constructor_001.phpt index 1a70fe1f59e9..0d4fa670c3e6 100644 --- a/ext/reflection/tests/ReflectionClass_constructor_001.phpt +++ b/ext/reflection/tests/ReflectionClass_constructor_001.phpt @@ -8,10 +8,10 @@ $myInstance = new stdClass; $r2 = new ReflectionClass($myInstance); class TrickClass { - function __toString() { - //Return the name of another class - return "Exception"; - } + function __toString() { + //Return the name of another class + return "Exception"; + } } $myTrickClass = new TrickClass; $r3 = new ReflectionClass($myTrickClass); diff --git a/ext/reflection/tests/ReflectionClass_constructor_002.phpt b/ext/reflection/tests/ReflectionClass_constructor_002.phpt index 7d8a312f5107..3744fec06cfd 100644 --- a/ext/reflection/tests/ReflectionClass_constructor_002.phpt +++ b/ext/reflection/tests/ReflectionClass_constructor_002.phpt @@ -3,45 +3,45 @@ ReflectionClass::__constructor() - bad arguments --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(new ReflectionClass(null)); + var_dump(new ReflectionClass(null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(new ReflectionClass(true)); + var_dump(new ReflectionClass(true)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(new ReflectionClass(1)); + var_dump(new ReflectionClass(1)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(new ReflectionClass(array(1,2,3))); + var_dump(new ReflectionClass(array(1,2,3))); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(new ReflectionClass("stdClass", 1)); + var_dump(new ReflectionClass("stdClass", 1)); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump(new ReflectionClass("X")); + var_dump(new ReflectionClass("X")); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt index 80d2be258564..2e050af209b2 100644 --- a/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt +++ b/ext/reflection/tests/ReflectionClass_export_array_bug72222.phpt @@ -3,8 +3,8 @@ ReflectionClass::__toString() - array constants --FILE-- diff --git a/ext/reflection/tests/ReflectionClass_export_basic1.phpt b/ext/reflection/tests/ReflectionClass_export_basic1.phpt index 784fc6a5fb90..318e47b35532 100644 --- a/ext/reflection/tests/ReflectionClass_export_basic1.phpt +++ b/ext/reflection/tests/ReflectionClass_export_basic1.phpt @@ -3,15 +3,15 @@ ReflectionClass::__toString() - various parameters --FILE-- getConstant('a')); - var_dump($rc->getConstant('doesnotexist')); + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + var_dump($rc->getConstant('a')); + var_dump($rc->getConstant('doesnotexist')); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_getConstant_error.phpt b/ext/reflection/tests/ReflectionClass_getConstant_error.phpt index 020ac6f7f5fb..ca9bc0ce2d1e 100644 --- a/ext/reflection/tests/ReflectionClass_getConstant_error.phpt +++ b/ext/reflection/tests/ReflectionClass_getConstant_error.phpt @@ -3,7 +3,7 @@ ReflectionClass::getConstant() - bad params --FILE-- getConstants()); + echo "Constants from class $class: \n"; + $rc = new ReflectionClass($class); + var_dump($rc->getConstants()); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt index df6880aedb80..bbf26e04a5c6 100644 --- a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt @@ -3,7 +3,7 @@ ReflectionClass::getConstructor() --FILE-- getConstructor(); - if ($rm != null) { - echo "Constructor of $class: " . $rm->getName() . "\n"; - } else { - echo "No constructor for $class\n"; - } + $rc = new ReflectionClass($class); + $rm = $rc->getConstructor(); + if ($rm != null) { + echo "Constructor of $class: " . $rm->getName() . "\n"; + } else { + echo "No constructor for $class\n"; + } } diff --git a/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt index 3778adb4036f..0adbd34335d0 100644 --- a/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getDefaultProperties_001.phpt @@ -8,68 +8,68 @@ Steve Seear class A { - static public $statPubC = "stat pubC in A"; - static protected $statProtC = "stat protC in A"; - static private $statPrivC = "stat privC in A"; + static public $statPubC = "stat pubC in A"; + static protected $statProtC = "stat protC in A"; + static private $statPrivC = "stat privC in A"; - static public $statPubA = "stat pubA in A"; - static protected $statProtA = "stat protA in A"; - static private $statPrivA = "stat privA in A"; + static public $statPubA = "stat pubA in A"; + static protected $statProtA = "stat protA in A"; + static private $statPrivA = "stat privA in A"; - public $pubC = "pubC in A"; - protected $protC = "protC in A"; - private $privC = "privC in A"; + public $pubC = "pubC in A"; + protected $protC = "protC in A"; + private $privC = "privC in A"; - public $pubA = "pubA in A"; - protected $protA = "protA in A"; - private $privA = "privA in A"; + public $pubA = "pubA in A"; + protected $protA = "protA in A"; + private $privA = "privA in A"; } class B extends A { - static public $statPubC = "stat pubC in B"; - static protected $statProtC = "stat protC in B"; - static private $statPrivC = "stat privC in B"; + static public $statPubC = "stat pubC in B"; + static protected $statProtC = "stat protC in B"; + static private $statPrivC = "stat privC in B"; - static public $statPubB = "stat pubB in B"; - static protected $statProtB = "stat protB in B"; - static private $statPrivB = "stat privB in B"; + static public $statPubB = "stat pubB in B"; + static protected $statProtB = "stat protB in B"; + static private $statPrivB = "stat privB in B"; - public $pubC = "pubC in B"; - protected $protC = "protC in B"; - private $privC = "privC in B"; + public $pubC = "pubC in B"; + protected $protC = "protC in B"; + private $privC = "privC in B"; - public $pubB = "pubB in B"; - protected $protB = "protB in B"; - private $privB = "privB in B"; + public $pubB = "pubB in B"; + protected $protB = "protB in B"; + private $privB = "privB in B"; } class C extends B { - static public $statPubC = "stat pubC in C"; - static protected $statProtC = "stat protC in C"; - static private $statPrivC = "stat privC in C"; + static public $statPubC = "stat pubC in C"; + static protected $statProtC = "stat protC in C"; + static private $statPrivC = "stat privC in C"; - public $pubC = "pubC in C"; - protected $protC = "protC in C"; - private $privC = "privC in C"; + public $pubC = "pubC in C"; + protected $protC = "protC in C"; + private $privC = "privC in C"; } class X { - static public $statPubC = "stat pubC in X"; - static protected $statProtC = "stat protC in X"; - static private $statPrivC = "stat privC in X"; + static public $statPubC = "stat pubC in X"; + static protected $statProtC = "stat protC in X"; + static private $statPrivC = "stat privC in X"; - public $pubC = "pubC in X"; - protected $protC = "protC in X"; - private $privC = "privC in X"; + public $pubC = "pubC in X"; + protected $protC = "protC in X"; + private $privC = "privC in X"; } $classes = array('A', 'B', 'C', 'X'); foreach ($classes as $class) { - $rc = new ReflectionClass($class); - echo "\n\n---- Static properties in $class ----\n"; - print_r($rc->getStaticProperties()); - echo "\n\n---- Default properties in $class ----\n"; - print_r($rc->getDefaultProperties()); + $rc = new ReflectionClass($class); + echo "\n\n---- Static properties in $class ----\n"; + print_r($rc->getStaticProperties()); + echo "\n\n---- Default properties in $class ----\n"; + print_r($rc->getDefaultProperties()); } ?> diff --git a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt index d4f3ed27f256..28b92abedbbf 100644 --- a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt @@ -48,9 +48,9 @@ final class G extends C implements I {} {} $classes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'I'); foreach ($classes as $class) { - echo "\n\n---> Doc comment for class $class:\n"; - $rc = new ReflectionClass($class); - var_dump($rc->getDocComment()); + echo "\n\n---> Doc comment for class $class:\n"; + $rc = new ReflectionClass($class); + var_dump($rc->getDocComment()); } diff --git a/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt b/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt index 310b22e69581..84e38b080207 100644 --- a/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getExtensionName_basic.phpt @@ -7,8 +7,8 @@ Rein Velt #testFest Roosendaal 2008-05-10 --FILE-- getExtensionName()) ; + $rc=new reflectionClass('domDocument'); + var_dump( $rc->getExtensionName()) ; ?> --EXPECT-- string(3) "dom" diff --git a/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt b/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt index 4f7834308188..4b4ed125a495 100644 --- a/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt +++ b/ext/reflection/tests/ReflectionClass_getExtensionName_variation.phpt @@ -6,13 +6,13 @@ Rein Velt --FILE-- getExtensionName()) ; + class myClass + { + public $varX; + public $varY; + } + $rc=new reflectionClass('myClass'); + var_dump( $rc->getExtensionName()) ; ?> --EXPECT-- bool(false) diff --git a/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt b/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt index dbe157acd6da..8cd1caad7428 100644 --- a/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getExtension_basic.phpt @@ -7,8 +7,8 @@ Rein Velt #testFest Roosendaal 2008-05-10 --FILE-- getExtension()) ; + $rc=new reflectionClass('domDocument'); + var_dump($rc->getExtension()) ; ?> --EXPECTF-- object(ReflectionExtension)#%d (1) { diff --git a/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt b/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt index f3697792db74..b8a881f9b353 100644 --- a/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt +++ b/ext/reflection/tests/ReflectionClass_getExtension_variation.phpt @@ -6,13 +6,13 @@ Rein Velt --FILE-- getExtension()) ; + class myClass + { + public $varX; + public $varY; + } + $rc=new reflectionClass('myClass'); + var_dump( $rc->getExtension()) ; ?> --EXPECT-- NULL diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt index 6f7561c4625d..feaa703c986b 100644 --- a/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getInterfaces_001.phpt @@ -29,16 +29,16 @@ class C6 implements I1, I2, I3, I4, I5, I6, I7 {} $classes = array( 'A0', 'A1', 'B0', 'B1', - 'I0', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', - 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6' ); + 'I0', 'I1', 'I2', 'I3', 'I4', 'I5', 'I6', 'I7', + 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6' ); foreach ($classes as $class) { - echo "---( Interfaces implemented by $class )---\n "; - $rc = new ReflectionClass($class); - $interfaces = $rc->getInterfaces(); - // Sort interfaces so that tests do not fail because of wrong order. - ksort($interfaces); - print_r($interfaces); + echo "---( Interfaces implemented by $class )---\n "; + $rc = new ReflectionClass($class); + $interfaces = $rc->getInterfaces(); + // Sort interfaces so that tests do not fail because of wrong order. + ksort($interfaces); + print_r($interfaces); } ?> diff --git a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt index e2a4eb9903ca..c8a2ed14edfa 100644 --- a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt @@ -6,43 +6,43 @@ Steve Seear --FILE-- Check for f(): "; - var_dump($rc->getMethod("f")); - echo " --> Check for s(): "; - var_dump($rc->getMethod("s")); - echo " --> Check for F(): "; - var_dump($rc->getMethod("F")); - echo " --> Check for doesNotExist(): "; - try { - var_dump($rc->getMethod("doesNotExist")); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + echo " --> Check for f(): "; + var_dump($rc->getMethod("f")); + echo " --> Check for s(): "; + var_dump($rc->getMethod("s")); + echo " --> Check for F(): "; + var_dump($rc->getMethod("F")); + echo " --> Check for doesNotExist(): "; + try { + var_dump($rc->getMethod("doesNotExist")); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt index 424550f67a0f..cebb5cd08958 100644 --- a/ext/reflection/tests/ReflectionClass_getMethod_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethod_002.phpt @@ -6,50 +6,50 @@ Steve Seear --FILE-- getMethod()); + var_dump($rc->getMethod()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod("f", "f")); + var_dump($rc->getMethod("f", "f")); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod(null)); + var_dump($rc->getMethod(null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod(1)); + var_dump($rc->getMethod(1)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod(1.5)); + var_dump($rc->getMethod(1.5)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod(true)); + var_dump($rc->getMethod(true)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod(array(1,2,3))); + var_dump($rc->getMethod(array(1,2,3))); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getMethod(new C)); + var_dump($rc->getMethod(new C)); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } diff --git a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt index dca9adb56dfc..1f2ed55ffb58 100644 --- a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt @@ -6,32 +6,32 @@ Steve Seear --FILE-- getMethods()); + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + var_dump($rc->getMethods()); } ?> diff --git a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt index b08fcaa4d49f..d40e0b91223f 100644 --- a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt @@ -6,14 +6,14 @@ Steve Seear --FILE-- getName(), Reflection::getModifierNames($obj->getModifiers())); + $obj = new ReflectionClass($class); + var_dump($obj->getName(), Reflection::getModifierNames($obj->getModifiers())); } function dump_methodModifierNames($class) { - $obj = new ReflectionClass($class); - foreach($obj->getMethods() as $method) { - var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers())); - } + $obj = new ReflectionClass($class); + foreach($obj->getMethods() as $method) { + var_dump($obj->getName() . "::" . $method->getName(), Reflection::getModifierNames($method->getModifiers())); + } } dump_modifierNames('a'); diff --git a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt index ffe88761338f..447f8d2edc4b 100644 --- a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt @@ -14,8 +14,8 @@ interface f extends d {} class g extends b {} function dump_modifiers($class) { - $obj = new ReflectionClass($class); - var_dump($obj->getModifiers()); + $obj = new ReflectionClass($class); + var_dump($obj->getModifiers()); } dump_modifiers('a'); diff --git a/ext/reflection/tests/ReflectionClass_getName_basic.phpt b/ext/reflection/tests/ReflectionClass_getName_basic.phpt index 37cec4bc81b6..f230165f0dce 100644 --- a/ext/reflection/tests/ReflectionClass_getName_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getName_basic.phpt @@ -3,10 +3,10 @@ ReflectionClass::getName() --FILE-- --FILE-- getProperties()); + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + var_dump($rc->getProperties()); } ?> diff --git a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt index fe3792a30f3d..63d5d476b4db 100644 --- a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt @@ -6,14 +6,14 @@ Steve Seear --FILE-- --FILE-- Check for s: "; - var_dump($rc->getProperty("s")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; - } - try { - echo " --> Check for a: "; - var_dump($rc->getProperty("a")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; - } - try { - echo " --> Check for A: "; - var_dump($rc->getProperty("A")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; - } - try { - echo " --> Check for doesNotExist: "; - var_dump($rc->getProperty("doesNotExist")); - } catch (exception $e) { - echo $e->getMessage() . "\n"; - } + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + try { + echo " --> Check for s: "; + var_dump($rc->getProperty("s")); + } catch (exception $e) { + echo $e->getMessage() . "\n"; + } + try { + echo " --> Check for a: "; + var_dump($rc->getProperty("a")); + } catch (exception $e) { + echo $e->getMessage() . "\n"; + } + try { + echo " --> Check for A: "; + var_dump($rc->getProperty("A")); + } catch (exception $e) { + echo $e->getMessage() . "\n"; + } + try { + echo " --> Check for doesNotExist: "; + var_dump($rc->getProperty("doesNotExist")); + } catch (exception $e) { + echo $e->getMessage() . "\n"; + } } ?> diff --git a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt index d9a2ebcd711e..904162b26314 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_002.phpt @@ -6,50 +6,50 @@ Steve Seear --FILE-- getProperty()); + var_dump($rc->getProperty()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty("a", "a")); + var_dump($rc->getProperty("a", "a")); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty(null)); + var_dump($rc->getProperty(null)); } catch (exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty(1)); + var_dump($rc->getProperty(1)); } catch (exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty(1.5)); + var_dump($rc->getProperty(1.5)); } catch (exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty(true)); + var_dump($rc->getProperty(true)); } catch (exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty(array(1,2,3))); + var_dump($rc->getProperty(array(1,2,3))); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getProperty(new C)); + var_dump($rc->getProperty(new C)); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt index 7011a0912cf7..34ade2fc5e57 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt @@ -6,56 +6,56 @@ Steve Seear --FILE-- getProperty($name); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - return; - } - try { - var_dump($rp); - var_dump($rp->getValue($myC)); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - return; - } + global $rc, $myC; + echo "--- (Reflecting on $name) ---\n"; + try { + $rp = $rc->getProperty($name); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + return; + } + try { + var_dump($rp); + var_dump($rp->getValue($myC)); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + return; + } } diff --git a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt index 95f821e4726d..b5396aae4045 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt @@ -6,56 +6,56 @@ Steve Seear --FILE-- getProperty($name); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - return; - } - try { - var_dump($rp); - var_dump($rp->getValue($myC)); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - return; - } + global $rc, $myC; + echo "--- (Reflecting on $name) ---\n"; + try { + $rp = $rc->getProperty($name); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + return; + } + try { + var_dump($rp); + var_dump($rp->getValue($myC)); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + return; + } } diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt index 365ec89ff14a..b11d2ec0d752 100644 --- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt @@ -6,15 +6,15 @@ Steve Seear --FILE-- getStaticPropertyValue("publicOverridden")); echo "\nRetrieving non-existent values from A with no default value:\n"; try { - var_dump($rcA->getStaticPropertyValue("protectedOverridden")); - echo "you should not see this"; + var_dump($rcA->getStaticPropertyValue("protectedOverridden")); + echo "you should not see this"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rcA->getStaticPropertyValue("privateOverridden")); - echo "you should not see this"; + var_dump($rcA->getStaticPropertyValue("privateOverridden")); + echo "you should not see this"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt index 7c071e5ba0fe..672c7f3e1dbb 100644 --- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_002.phpt @@ -6,34 +6,34 @@ Steve Seear --FILE-- getStaticPropertyValue("x", "default value", 'blah')); + var_dump($rc->getStaticPropertyValue("x", "default value", 'blah')); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getStaticPropertyValue()); + var_dump($rc->getStaticPropertyValue()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getStaticPropertyValue(null)); + var_dump($rc->getStaticPropertyValue(null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getStaticPropertyValue(1.5, 'def')); + var_dump($rc->getStaticPropertyValue(1.5, 'def')); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->getStaticPropertyValue(array(1,2,3))); + var_dump($rc->getStaticPropertyValue(array(1,2,3))); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } diff --git a/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt b/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt index 22ef1f50c5f3..5783b2b506d4 100644 --- a/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt +++ b/ext/reflection/tests/ReflectionClass_hasConstant_001.phpt @@ -6,7 +6,7 @@ Steve Seear --FILE-- --FILE-- --FILE-- Check for f(): "; - var_dump($rc->hasMethod("f")); - echo " --> Check for s(): "; - var_dump($rc->hasMethod("s")); - echo " --> Check for F(): "; - var_dump($rc->hasMethod("F")); - echo " --> Check for doesNotExist(): "; - var_dump($rc->hasMethod("doesNotExist")); + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + echo " --> Check for f(): "; + var_dump($rc->hasMethod("f")); + echo " --> Check for s(): "; + var_dump($rc->hasMethod("s")); + echo " --> Check for F(): "; + var_dump($rc->hasMethod("F")); + echo " --> Check for doesNotExist(): "; + var_dump($rc->hasMethod("doesNotExist")); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt index 77f2865a31ac..2bbc84551ef7 100644 --- a/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt +++ b/ext/reflection/tests/ReflectionClass_hasMethod_002.phpt @@ -6,7 +6,7 @@ Steve Seear --FILE-- --FILE-- Check for s: "; - var_dump($rc->hasProperty("s")); - echo " --> Check for a: "; - var_dump($rc->hasProperty("a")); - echo " --> Check for A: "; - var_dump($rc->hasProperty("A")); - echo " --> Check for doesNotExist: "; - var_dump($rc->hasProperty("doesNotExist")); + echo "Reflecting on class $class: \n"; + $rc = new ReflectionClass($class); + echo " --> Check for s: "; + var_dump($rc->hasProperty("s")); + echo " --> Check for a: "; + var_dump($rc->hasProperty("a")); + echo " --> Check for A: "; + var_dump($rc->hasProperty("A")); + echo " --> Check for doesNotExist: "; + var_dump($rc->hasProperty("doesNotExist")); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt b/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt index a1bbb9e73cb6..a1359390524a 100644 --- a/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt +++ b/ext/reflection/tests/ReflectionClass_hasProperty_002.phpt @@ -6,7 +6,7 @@ Steve Seear --FILE-- $child) { - foreach ($rcs as $parentName => $parent) { - echo "Does " . $childName . " implement " . $parentName . "? \n"; - echo " - Using object argument: "; - try { - var_dump($child->implementsInterface($parent)); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } - echo " - Using string argument: "; - try { - var_dump($child->implementsInterface($parentName)); - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - } - } + foreach ($rcs as $parentName => $parent) { + echo "Does " . $childName . " implement " . $parentName . "? \n"; + echo " - Using object argument: "; + try { + var_dump($child->implementsInterface($parent)); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } + echo " - Using string argument: "; + try { + var_dump($child->implementsInterface($parentName)); + } catch (Exception $e) { + echo $e->getMessage() . "\n"; + } + } } echo "\n\nTest bad arguments:\n"; try { - var_dump($rcs['A']->implementsInterface()); + var_dump($rcs['A']->implementsInterface()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rcs['A']->implementsInterface('C', 'C')); + var_dump($rcs['A']->implementsInterface('C', 'C')); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rcs['A']->implementsInterface(null)); + var_dump($rcs['A']->implementsInterface(null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rcs['A']->implementsInterface('ThisClassDoesNotExist')); + var_dump($rcs['A']->implementsInterface('ThisClassDoesNotExist')); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rcs['A']->implementsInterface(2)); + var_dump($rcs['A']->implementsInterface(2)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt index 361708a3154e..caf55fa64834 100644 --- a/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt +++ b/ext/reflection/tests/ReflectionClass_isCloneable_001.phpt @@ -17,8 +17,8 @@ var_dump($obj->isCloneable()); $h = clone $foo; class bar { - private function __clone() { - } + private function __clone() { + } } $bar = new bar; print "User class - private __clone\n"; diff --git a/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt b/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt index a108718894d1..e34176fe5178 100644 --- a/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isInstance_basic.phpt @@ -13,17 +13,17 @@ class X {} $classes = array("A", "B", "C", "I", "X"); $instances = array( "myA" => new A, - "myB" => new B, - "myC" => new C, - "myX" => new X ); + "myB" => new B, + "myC" => new C, + "myX" => new X ); foreach ($classes as $class) { - $rc = new ReflectionClass($class); + $rc = new ReflectionClass($class); - foreach ($instances as $name => $instance) { - echo "is $name a $class? "; - var_dump($rc->isInstance($instance)); - } + foreach ($instances as $name => $instance) { + echo "is $name a $class? "; + var_dump($rc->isInstance($instance)); + } } diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt index ef179721dc64..3bc79b3e7919 100644 --- a/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isInstantiable_basic.phpt @@ -6,28 +6,28 @@ class C { } interface iface { - function f1(); + function f1(); } class ifaceImpl implements iface { - function f1() {} + function f1() {} } abstract class abstractClass { - function f1() {} - abstract function f2(); + function f1() {} + abstract function f2(); } class D extends abstractClass { - function f2() {} + function f2() {} } $classes = array("C", "iface", "ifaceImpl", "abstractClass", "D"); foreach($classes as $class ) { - $reflectionClass = new ReflectionClass($class); - echo "Is $class instantiable? "; - var_dump($reflectionClass->IsInstantiable()); + $reflectionClass = new ReflectionClass($class); + echo "Is $class instantiable? "; + var_dump($reflectionClass->IsInstantiable()); } diff --git a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt index e688b40f466a..cdfaf911e408 100644 --- a/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt +++ b/ext/reflection/tests/ReflectionClass_isInstantiable_variation.phpt @@ -6,22 +6,22 @@ class noCtor { } class publicCtorNew { - public function __construct() {} + public function __construct() {} } class protectedCtorNew { - protected function __construct() {} + protected function __construct() {} } class privateCtorNew { - private function __construct() {} + private function __construct() {} } $classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew"); foreach ($classes as $class) { - $reflectionClass = new ReflectionClass($class); - echo "Is $class instantiable? "; - var_dump($reflectionClass->IsInstantiable()); + $reflectionClass = new ReflectionClass($class); + echo "Is $class instantiable? "; + var_dump($reflectionClass->IsInstantiable()); } ?> diff --git a/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt index 9c656a38b61d..48f0c963ea0e 100644 --- a/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt @@ -12,7 +12,7 @@ $r4 = new ReflectionClass("Exception"); $r5 = new ReflectionClass("C"); var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), - $r4->isInternal(), $r5->isInternal()); + $r4->isInternal(), $r5->isInternal()); ?> --EXPECT-- bool(true) diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt index af4ce9d2f4c1..ca3e4a8e8f2d 100644 --- a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt +++ b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt @@ -10,14 +10,14 @@ Interface ExtendsIterator extends Iterator { Interface ExtendsIteratorAggregate extends IteratorAggregate { } Class IteratorImpl implements Iterator { - public function next() {} - public function key() {} - public function rewind() {} - public function current() {} - public function valid() {} + public function next() {} + public function key() {} + public function rewind() {} + public function current() {} + public function valid() {} } Class IterarorAggregateImpl implements IteratorAggregate { - public function getIterator() {} + public function getIterator() {} } Class ExtendsIteratorImpl extends IteratorImpl { } @@ -27,12 +27,12 @@ Class A { } $classes = array('Traversable', 'Iterator', 'IteratorAggregate', 'ExtendsIterator', 'ExtendsIteratorAggregate', - 'IteratorImpl', 'IterarorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A'); + 'IteratorImpl', 'IterarorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A'); foreach($classes as $class) { - $rc = new ReflectionClass($class); - echo "Is $class iterable? "; - var_dump($rc->isIterateable()); + $rc = new ReflectionClass($class); + echo "Is $class iterable? "; + var_dump($rc->isIterateable()); } echo "\nTest static invocation:\n"; diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt index 8b65b9a0bd99..f11433eced36 100644 --- a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt @@ -6,25 +6,25 @@ Felix De Vliegher , Marc Veldman isIterateable()); + $reflection = new ReflectionClass($class); + var_dump($reflection->isIterateable()); } $classes = array("ArrayObject", "IteratorClass", "DerivedClass", "NonIterator"); foreach ($classes as $class) { - echo "Is $class iterateable? "; - dump_iterateable($class); + echo "Is $class iterateable? "; + dump_iterateable($class); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt index f6d0d5346a82..839867893a1b 100644 --- a/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt +++ b/ext/reflection/tests/ReflectionClass_isIterateable_variation1.phpt @@ -9,8 +9,8 @@ class BasicClass {} function dump_iterateable($obj) { - $reflection = new ReflectionClass($obj); - var_dump($reflection->isIterateable()); + $reflection = new ReflectionClass($obj); + var_dump($reflection->isIterateable()); } $basicClass = new BasicClass(); diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt index 03d17e223efd..b86b70018d47 100644 --- a/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt +++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_002.phpt @@ -10,29 +10,29 @@ $rc = new ReflectionClass('A'); echo "\n\nTest bad arguments:\n"; try { - var_dump($rc->isSubclassOf()); + var_dump($rc->isSubclassOf()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->isSubclassOf('C', 'C')); + var_dump($rc->isSubclassOf('C', 'C')); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->isSubclassOf(null)); + var_dump($rc->isSubclassOf(null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->isSubclassOf('ThisClassDoesNotExist')); + var_dump($rc->isSubclassOf('ThisClassDoesNotExist')); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->isSubclassOf(2)); + var_dump($rc->isSubclassOf(2)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt b/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt index c05ec27ccdd8..a52611fb2168 100644 --- a/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isSubclassOf_basic.phpt @@ -12,17 +12,17 @@ class X implements I {} $classNames = array('A', 'B', 'C', 'I', 'X'); foreach ($classNames as $className) { - $rcs[$className] = new ReflectionClass($className); + $rcs[$className] = new ReflectionClass($className); } foreach ($rcs as $childName => $child) { - foreach ($rcs as $parentName => $parent) { - echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; - echo " - Using object argument: "; - var_dump($child->isSubclassOf($parent)); - echo " - Using string argument: "; - var_dump($child->isSubclassOf($parentName)); - } + foreach ($rcs as $parentName => $parent) { + echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; + echo " - Using object argument: "; + var_dump($child->isSubclassOf($parent)); + echo " - Using string argument: "; + var_dump($child->isSubclassOf($parentName)); + } } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt index e9537c1e8a86..ee2206177dc8 100644 --- a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt @@ -12,7 +12,7 @@ $r4 = new ReflectionClass("Exception"); $r5 = new ReflectionClass("C"); var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), - $r4->isUserDefined(), $r5->isUserDefined()); + $r4->isUserDefined(), $r5->isUserDefined()); ?> --EXPECT-- bool(false) diff --git a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt index 1370228f046e..cb2a6555f195 100644 --- a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt +++ b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt @@ -14,11 +14,11 @@ interface I {} $classes = array("A", "B", "C", "D", "I"); foreach ($classes as $class) { - $rc = new ReflectionClass($class); - var_dump($rc->isFinal()); - var_dump($rc->isInterface()); - var_dump($rc->isAbstract()); - var_dump($rc->getModifiers()); + $rc = new ReflectionClass($class); + var_dump($rc->isFinal()); + var_dump($rc->isInterface()); + var_dump($rc->isAbstract()); + var_dump($rc->getModifiers()); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt index 9f721a4ad477..7dded54d3fae 100644 --- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_001.phpt @@ -7,21 +7,21 @@ Steve Seear newInstanceArgs(); + $rcB->newInstanceArgs(); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } var_dump($rcB->newInstanceArgs(array('x', 123))); try { - $rcC->newInstanceArgs(); - echo "you should not see this\n"; + $rcC->newInstanceArgs(); + echo "you should not see this\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $rcD->newInstanceArgs(); - echo "you should not see this\n"; + $rcD->newInstanceArgs(); + echo "you should not see this\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $e1 = $rcE->newInstanceArgs(); var_dump($e1); try { - $e2 = $rcE->newInstanceArgs(array('x')); - echo "you should not see this\n"; + $e2 = $rcE->newInstanceArgs(array('x')); + echo "you should not see this\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt b/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt index de4fe65acef1..3295f061089c 100644 --- a/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt @@ -6,9 +6,9 @@ Steve Seear --FILE-- newInstanceArgs('x'); diff --git a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt index bf68098a7d3a..22d06e328270 100644 --- a/ext/reflection/tests/ReflectionClass_newInstance_001.phpt +++ b/ext/reflection/tests/ReflectionClass_newInstance_001.phpt @@ -7,21 +7,21 @@ Steve Seear newInstance()); + var_dump($rcB->newInstance()); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump($rcB->newInstance('x', 123)); + var_dump($rcB->newInstance('x', 123)); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - $rcC->newInstance(); - echo "you should not see this\n"; + $rcC->newInstance(); + echo "you should not see this\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $rcD->newInstance(); - echo "you should not see this\n"; + $rcD->newInstance(); + echo "you should not see this\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $e1 = $rcE->newInstance(); var_dump($e1); try { - $e2 = $rcE->newInstance('x'); - echo "you should not see this\n"; + $e2 = $rcE->newInstance('x'); + echo "you should not see this\n"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt index bfefce369e00..f51f4136b1e6 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt @@ -6,15 +6,15 @@ Steve Seear --FILE-- getStaticProperties()); echo "\nSet non-existent values from A with no default value:\n"; try { - var_dump($rcA->setStaticPropertyValue("protectedOverridden", "new value 8")); - echo "you should not see this"; + var_dump($rcA->setStaticPropertyValue("protectedOverridden", "new value 8")); + echo "you should not see this"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rcA->setStaticPropertyValue("privateOverridden", "new value 9")); - echo "you should not see this"; + var_dump($rcA->setStaticPropertyValue("privateOverridden", "new value 9")); + echo "you should not see this"; } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt index 6d3cf3a44f26..9e4c69b4892b 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_002.phpt @@ -6,39 +6,39 @@ Steve Seear --FILE-- setStaticPropertyValue("x", "default value", 'blah')); + var_dump($rc->setStaticPropertyValue("x", "default value", 'blah')); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->setStaticPropertyValue()); + var_dump($rc->setStaticPropertyValue()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->setStaticPropertyValue(null)); + var_dump($rc->setStaticPropertyValue(null)); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->setStaticPropertyValue(null,null)); + var_dump($rc->setStaticPropertyValue(null,null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->setStaticPropertyValue(1.5, 'def')); + var_dump($rc->setStaticPropertyValue(1.5, 'def')); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah')); + var_dump($rc->setStaticPropertyValue(array(1,2,3), 'blah')); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt index 352a79ece852..959cc1bea079 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_003.phpt @@ -11,7 +11,7 @@ class Test { $rc = new ReflectionClass('Test'); try { - $rc->setStaticPropertyValue("y", "foo"); + $rc->setStaticPropertyValue("y", "foo"); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } var_dump(Test::$y); @@ -22,7 +22,7 @@ var_dump(Test::$y); Test::$x =& Test::$y; try { - $rc->setStaticPropertyValue("x", "foo"); + $rc->setStaticPropertyValue("x", "foo"); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } var_dump(Test::$y); diff --git a/ext/reflection/tests/ReflectionClass_toString_002.phpt b/ext/reflection/tests/ReflectionClass_toString_002.phpt index 5395ae66b9d0..a6824e540d0a 100644 --- a/ext/reflection/tests/ReflectionClass_toString_002.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_002.phpt @@ -6,21 +6,21 @@ Steve Seear --FILE-- diff --git a/ext/reflection/tests/ReflectionClass_toString_003.phpt b/ext/reflection/tests/ReflectionClass_toString_003.phpt index 1ce1fddf9196..a67d0bfac5fe 100644 --- a/ext/reflection/tests/ReflectionClass_toString_003.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_003.phpt @@ -6,21 +6,21 @@ Steve Seear --FILE-- diff --git a/ext/reflection/tests/ReflectionExtension_constructor_error.phpt b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt index a0b920ac0849..9f25858402da 100644 --- a/ext/reflection/tests/ReflectionExtension_constructor_error.phpt +++ b/ext/reflection/tests/ReflectionExtension_constructor_error.phpt @@ -6,21 +6,21 @@ Leon Luijkx --FILE-- getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - $obj = new ReflectionExtension('foo', 'bar'); + $obj = new ReflectionExtension('foo', 'bar'); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - $obj = new ReflectionExtension([]); + $obj = new ReflectionExtension([]); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } diff --git a/ext/reflection/tests/ReflectionFunction_001.phpt b/ext/reflection/tests/ReflectionFunction_001.phpt index 6785e5d0b1a8..4c0a58ca9d24 100644 --- a/ext/reflection/tests/ReflectionFunction_001.phpt +++ b/ext/reflection/tests/ReflectionFunction_001.phpt @@ -10,10 +10,10 @@ Steve Seear * my doc comment */ function foo () { - static $c; - static $a = 1; - static $b = "hello"; - $d = 5; + static $c; + static $a = 1; + static $b = "hello"; + $d = 5; } /*** @@ -23,13 +23,13 @@ function bar () {} function dumpFuncInfo($name) { - $funcInfo = new ReflectionFunction($name); - var_dump($funcInfo->getName()); - var_dump($funcInfo->isInternal()); - var_dump($funcInfo->isUserDefined()); - var_dump($funcInfo->getStartLine()); - var_dump($funcInfo->getEndLine()); - var_dump($funcInfo->getStaticVariables()); + $funcInfo = new ReflectionFunction($name); + var_dump($funcInfo->getName()); + var_dump($funcInfo->isInternal()); + var_dump($funcInfo->isUserDefined()); + var_dump($funcInfo->getStartLine()); + var_dump($funcInfo->getEndLine()); + var_dump($funcInfo->getStaticVariables()); } dumpFuncInfo('foo'); diff --git a/ext/reflection/tests/ReflectionFunction_construct.001.phpt b/ext/reflection/tests/ReflectionFunction_construct.001.phpt index eab542e005c9..945060b0738d 100644 --- a/ext/reflection/tests/ReflectionFunction_construct.001.phpt +++ b/ext/reflection/tests/ReflectionFunction_construct.001.phpt @@ -7,30 +7,30 @@ Steve Seear getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - $a = new ReflectionFunction('nonExistentFunction'); + $a = new ReflectionFunction('nonExistentFunction'); } catch (ReflectionException $e) { - echo $e->getMessage().PHP_EOL; + echo $e->getMessage().PHP_EOL; } try { - $a = new ReflectionFunction(); + $a = new ReflectionFunction(); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - $a = new ReflectionFunction(1, 2); + $a = new ReflectionFunction(1, 2); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - $a = new ReflectionFunction([]); + $a = new ReflectionFunction([]); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } ?> diff --git a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt index b8b969b0bc91..f7cb6b36ec7b 100644 --- a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt +++ b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt @@ -7,9 +7,9 @@ $rf = new ReflectionFunction($closure); var_dump($rf->getClosureScopeClass()); Class A { - public static function getClosure() { - return function($param) { return "this is a closure"; }; - } + public static function getClosure() { + return function($param) { return "this is a closure"; }; + } } $closure = A::getClosure(); diff --git a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt index bb72137f698b..7772da050978 100644 --- a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt +++ b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt @@ -12,12 +12,12 @@ echo "*** Testing ReflectionFunction::getClosure() : basic functionality ***\n"; function foo() { - var_dump( "Inside foo function" ); + var_dump( "Inside foo function" ); } function bar( $arg ) { - var_dump( "Arg is " . $arg ); + var_dump( "Arg is " . $arg ); } $func = new ReflectionFunction( 'foo' ); diff --git a/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt b/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt index 03cec2ee79f2..590f5cfa10d4 100644 --- a/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt +++ b/ext/reflection/tests/ReflectionFunction_getDocComment.001.phpt @@ -12,10 +12,10 @@ opcache.save_comments=1 * my doc comment */ function foo () { - static $c; - static $a = 1; - static $b = "hello"; - $d = 5; + static $c; + static $a = 1; + static $b = "hello"; + $d = 5; } /*** @@ -25,8 +25,8 @@ function bar () {} function dumpFuncInfo($name) { - $funcInfo = new ReflectionFunction($name); - var_dump($funcInfo->getDocComment()); + $funcInfo = new ReflectionFunction($name); + var_dump($funcInfo->getDocComment()); } dumpFuncInfo('foo'); diff --git a/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt b/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt index cd754185840e..39fa48a3ff0b 100644 --- a/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt +++ b/ext/reflection/tests/ReflectionFunction_getFileName.002.phpt @@ -10,10 +10,10 @@ Steve Seear * my doc comment */ function foo () { - static $c; - static $a = 1; - static $b = "hello"; - $d = 5; + static $c; + static $a = 1; + static $b = "hello"; + $d = 5; } /*** @@ -23,8 +23,8 @@ function bar () {} function dumpFuncInfo($name) { - $funcInfo = new ReflectionFunction($name); - var_dump($funcInfo->getFileName()); + $funcInfo = new ReflectionFunction($name); + var_dump($funcInfo->getFileName()); } dumpFuncInfo('foo'); diff --git a/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt b/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt index 8bbbfa516fcc..b9a84d49c425 100644 --- a/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt +++ b/ext/reflection/tests/ReflectionFunction_isGenerator_basic.phpt @@ -5,7 +5,7 @@ ReflectionFunction::isGenerator() $closure1 = function() {return "this is a closure"; }; $closure2 = function($param) { - yield $param; + yield $param; }; $rf1 = new ReflectionFunction($closure1); @@ -15,11 +15,11 @@ $rf2 = new ReflectionFunction($closure2); var_dump($rf2->isGenerator()); function func1() { - return 'func1'; + return 'func1'; } function func2() { - yield 'func2'; + yield 'func2'; } $rf1 = new ReflectionFunction('func1'); @@ -30,17 +30,17 @@ var_dump($rf2->isGenerator()); class Foo { - public function f1() { - } + public function f1() { + } - public function f2() { - yield; - } + public function f2() { + yield; + } } $rc = new ReflectionClass('Foo'); foreach($rc->getMethods() as $m) { - var_dump($m->isGenerator()); + var_dump($m->isGenerator()); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionGenerator_basic.phpt b/ext/reflection/tests/ReflectionGenerator_basic.phpt index 6f35b6c24471..f9ecc8e90eb4 100644 --- a/ext/reflection/tests/ReflectionGenerator_basic.phpt +++ b/ext/reflection/tests/ReflectionGenerator_basic.phpt @@ -4,33 +4,33 @@ ReflectionGenerator basic test a(), - (function() { - yield; - })(), - foo(), + (new class() { + function a() { + yield from foo(); + } + })->a(), + (function() { + yield; + })(), + foo(), ]; foreach ($gens as $gen) { - var_dump($gen); + var_dump($gen); - $gen->valid(); // start Generator - $ref = new ReflectionGenerator($gen); + $gen->valid(); // start Generator + $ref = new ReflectionGenerator($gen); - var_dump($ref->getTrace()); - var_dump($ref->getExecutingLine()); - var_dump($ref->getExecutingFile()); - var_dump($ref->getExecutingGenerator()); - var_dump($ref->getFunction()); - var_dump($ref->getThis()); + var_dump($ref->getTrace()); + var_dump($ref->getExecutingLine()); + var_dump($ref->getExecutingFile()); + var_dump($ref->getExecutingGenerator()); + var_dump($ref->getFunction()); + var_dump($ref->getThis()); } ?> diff --git a/ext/reflection/tests/ReflectionGenerator_getTrace.phpt b/ext/reflection/tests/ReflectionGenerator_getTrace.phpt index 05a46009e8bb..91b7160d4ba0 100644 --- a/ext/reflection/tests/ReflectionGenerator_getTrace.phpt +++ b/ext/reflection/tests/ReflectionGenerator_getTrace.phpt @@ -4,8 +4,8 @@ ReflectionGenerator::getTrace() over multiple Generators $method()); + if ($rec) { + call($ref, $method, false); + return; + } + var_dump($ref->$method()); } function doCalls(ReflectionGenerator $ref) { - call($ref, "getTrace"); - call($ref, "getExecutingLine"); - call($ref, "getExecutingFile"); - call($ref, "getExecutingGenerator"); - call($ref, "getFunction"); - call($ref, "getThis"); + call($ref, "getTrace"); + call($ref, "getExecutingLine"); + call($ref, "getExecutingFile"); + call($ref, "getExecutingGenerator"); + call($ref, "getFunction"); + call($ref, "getThis"); } ($gen = (function() use (&$gen) { - $ref = new ReflectionGenerator($gen); + $ref = new ReflectionGenerator($gen); - doCalls($ref); + doCalls($ref); - yield from (function() use ($ref) { - doCalls($ref); - yield; // Generator ! - })(); + yield from (function() use ($ref) { + doCalls($ref); + yield; // Generator ! + })(); })())->next(); ?> diff --git a/ext/reflection/tests/ReflectionMethod_006.phpt b/ext/reflection/tests/ReflectionMethod_006.phpt index 81f8116d77c3..bb29b1cbed1b 100644 --- a/ext/reflection/tests/ReflectionMethod_006.phpt +++ b/ext/reflection/tests/ReflectionMethod_006.phpt @@ -7,14 +7,14 @@ Steve Seear getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - new ReflectionMethod('a', 'b', 'c'); + new ReflectionMethod('a', 'b', 'c'); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } ?> diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt index 5c980536b9f9..186c61b2b0fc 100644 --- a/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt +++ b/ext/reflection/tests/ReflectionMethod_constructor_error1.phpt @@ -14,52 +14,52 @@ class TestClass try { - echo "\nWrong type of argument (bool):\n"; - $methodInfo = new ReflectionMethod(true); + echo "\nWrong type of argument (bool):\n"; + $methodInfo = new ReflectionMethod(true); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nWrong type of argument (int):\n"; - $methodInfo = new ReflectionMethod(3); + echo "\nWrong type of argument (int):\n"; + $methodInfo = new ReflectionMethod(3); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nWrong type of argument (bool, string):\n"; - $methodInfo = new ReflectionMethod(true, "foo"); + echo "\nWrong type of argument (bool, string):\n"; + $methodInfo = new ReflectionMethod(true, "foo"); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nWrong type of argument (string, bool):\n"; - $methodInfo = new ReflectionMethod('TestClass', true); + echo "\nWrong type of argument (string, bool):\n"; + $methodInfo = new ReflectionMethod('TestClass', true); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nNo method given:\n"; - $methodInfo = new ReflectionMethod("TestClass"); + echo "\nNo method given:\n"; + $methodInfo = new ReflectionMethod("TestClass"); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nClass and Method in same string, bad method name:\n"; - $methodInfo = new ReflectionMethod("TestClass::foop::dedoop"); + echo "\nClass and Method in same string, bad method name:\n"; + $methodInfo = new ReflectionMethod("TestClass::foop::dedoop"); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nClass and Method in same string, bad class name:\n"; - $methodInfo = new ReflectionMethod("TestCla::foo"); + echo "\nClass and Method in same string, bad class name:\n"; + $methodInfo = new ReflectionMethod("TestCla::foo"); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } try { - echo "\nClass and Method in same string (ok):\n"; - $methodInfo = new ReflectionMethod("TestClass::foo"); + echo "\nClass and Method in same string (ok):\n"; + $methodInfo = new ReflectionMethod("TestClass::foo"); } catch (Exception $e) { - print $e->__toString(); + print $e->__toString(); } ?> diff --git a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt index 723ab00f84f2..d84fa5dcff5c 100644 --- a/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt +++ b/ext/reflection/tests/ReflectionMethod_constructor_error2.phpt @@ -14,39 +14,39 @@ class TestClass try { - echo "Too few arguments:\n"; - $methodInfo = new ReflectionMethod(); + echo "Too few arguments:\n"; + $methodInfo = new ReflectionMethod(); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - echo "\nToo many arguments:\n"; - $methodInfo = new ReflectionMethod("TestClass", "foo", true); + echo "\nToo many arguments:\n"; + $methodInfo = new ReflectionMethod("TestClass", "foo", true); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - //invalid class - $methodInfo = new ReflectionMethod("InvalidClassName", "foo"); + //invalid class + $methodInfo = new ReflectionMethod("InvalidClassName", "foo"); } catch (ReflectionException $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - //invalid 1st param - $methodInfo = new ReflectionMethod([], "foo"); + //invalid 1st param + $methodInfo = new ReflectionMethod([], "foo"); } catch (ReflectionException $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try{ - //invalid 2nd param - $methodInfo = new ReflectionMethod("TestClass", []); + //invalid 2nd param + $methodInfo = new ReflectionMethod("TestClass", []); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } ?> diff --git a/ext/reflection/tests/ReflectionMethod_defaultArg.phpt b/ext/reflection/tests/ReflectionMethod_defaultArg.phpt index 1c04cade5f0f..521f29da582b 100644 --- a/ext/reflection/tests/ReflectionMethod_defaultArg.phpt +++ b/ext/reflection/tests/ReflectionMethod_defaultArg.phpt @@ -3,17 +3,17 @@ ReflectionMethod and RECV_INIT (bug #70957 and #70958) --FILE-- bar ); - } + public $bar = 42; + public function foo() + { + var_dump( "Example class, bar: " . $this->bar ); + } } // Initialize classes diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt index 105df87e73dd..3b0074e5a988 100644 --- a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt @@ -12,19 +12,19 @@ echo "*** Testing ReflectionMethod::getClosure() : basic functionality ***\n"; class StaticExample { - static function foo() - { - var_dump( "Static Example class, Hello World!" ); - } + static function foo() + { + var_dump( "Static Example class, Hello World!" ); + } } class Example { - public $bar = 42; - public function foo() - { - var_dump( "Example class, bar: " . $this->bar ); - } + public $bar = 42; + public function foo() + { + var_dump( "Example class, bar: " . $this->bar ); + } } // Initialize classes diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt index 70c77895d0e7..728ddf9265b3 100644 --- a/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt +++ b/ext/reflection/tests/ReflectionMethod_getClosure_error.phpt @@ -12,19 +12,19 @@ echo "*** Testing ReflectionMethod::getClosure() : error conditions ***\n"; class StaticExample { - static function foo() - { - var_dump( "Static Example class, Hello World!" ); - } + static function foo() + { + var_dump( "Static Example class, Hello World!" ); + } } class Example { - public $bar = 42; - public function foo() - { - var_dump( "Example class, bar: " . $this->bar ); - } + public $bar = 42; + public function foo() + { + var_dump( "Example class, bar: " . $this->bar ); + } } // Initialize classes diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt index f999b7281212..7cda871c18cf 100644 --- a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt @@ -25,7 +25,7 @@ class A { * My Doc Comment for A::finalStatPubf */ - final static public function finalStatPubf() {} + final static public function finalStatPubf() {} } diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt index d867993599bb..00c1514fd9a8 100644 --- a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt @@ -60,12 +60,12 @@ class TestClass class DerivedClass extends TestClass {} interface TestInterface { - public function int(); - public function __clone(); + public function int(); + public function __clone(); } abstract class AbstractClass { - public abstract function foo(); + public abstract function foo(); } diff --git a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt index 156cc9db5265..113cabbbeb8e 100644 --- a/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt +++ b/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt @@ -15,10 +15,10 @@ class TestClass { public static function staticMethod() { echo "Called staticMethod()\n"; try { - var_dump($this); - } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; - } + var_dump($this); + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } } private static function privateMethod() { diff --git a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt index 6711feb4ac92..3ff1052a0a0b 100644 --- a/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_invoke_basic.phpt @@ -23,10 +23,10 @@ class TestClass { public static function staticMethod() { echo "Called staticMethod()\n"; try { - var_dump($this); - } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; - } + var_dump($this); + } catch (Throwable $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } } private static function privateMethod() { @@ -74,9 +74,9 @@ var_dump($staticMethod->invoke(new stdClass())); echo "\nMethod that throws an exception:\n"; try { - var_dump($methodThatThrows->invoke($testClassInstance)); + var_dump($methodThatThrows->invoke($testClassInstance)); } catch (Exception $exc) { - var_dump($exc->getMessage()); + var_dump($exc->getMessage()); } ?> diff --git a/ext/reflection/tests/ReflectionNamedType.phpt b/ext/reflection/tests/ReflectionNamedType.phpt index 78fe1e8fd43e..5677d22cf27f 100644 --- a/ext/reflection/tests/ReflectionNamedType.phpt +++ b/ext/reflection/tests/ReflectionNamedType.phpt @@ -4,11 +4,11 @@ ReflectionNamedType::getName() and ReflectionNamedType::__toString() dynProp = 'hello'; diff --git a/ext/reflection/tests/ReflectionObject_export_basic1.phpt b/ext/reflection/tests/ReflectionObject_export_basic1.phpt index 43210ea68619..fdd25739bb11 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic1.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic1.phpt @@ -4,7 +4,7 @@ ReflectionObject::__toString() : very basic test with no dynamic properties dynProp = 'hello'; diff --git a/ext/reflection/tests/ReflectionObject_export_basic3.phpt b/ext/reflection/tests/ReflectionObject_export_basic3.phpt index a92c2d492128..612bfa5916bf 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic3.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic3.phpt @@ -3,7 +3,7 @@ ReflectionObject::__toString() - ensure dynamic property with same name as inher --FILE-- getConstant('a')); - var_dump($rc->getConstant('doesNotexist')); + echo "Reflecting on instance of class $class: \n"; + $rc = new ReflectionObject(new $class); + var_dump($rc->getConstant('a')); + var_dump($rc->getConstant('doesNotexist')); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt index 0ecbde7991bc..f5acde8be478 100644 --- a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt @@ -3,23 +3,23 @@ ReflectionObject::getConstants() - basic function test --FILE-- getConstants()); + echo "Reflecting on instance of class $class: \n"; + $rc = new ReflectionObject(new $class); + var_dump($rc->getConstants()); } ?> diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt index fee873fe0177..0401ed1e0cf1 100644 --- a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt @@ -3,45 +3,45 @@ ReflectionObject::getConstructor() - basic function test --FILE-- getConstructor(); - if ($rm != null) { - echo "Constructor of $class: " . $rm->getName() . "\n"; - } else { - echo "No constructor for $class\n"; - } + $rc = new ReflectionObject(new $class); + $rm = $rc->getConstructor(); + if ($rm != null) { + echo "Constructor of $class: " . $rm->getName() . "\n"; + } else { + echo "No constructor for $class\n"; + } } diff --git a/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt b/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt index ff310df09bdd..146ac5ccd9a5 100644 --- a/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isInstance_basic.phpt @@ -9,15 +9,15 @@ class X {} $classes = array("A", "B", "X"); $instances = array( "myA" => new A, - "myB" => new B, - "myX" => new X ); + "myB" => new B, + "myX" => new X ); foreach ($classes as $class) { - $ro = new ReflectionObject(new $class); - foreach ($instances as $name => $instance) { - echo "is $name a $class? "; - var_dump($ro->isInstance($instance)); - } + $ro = new ReflectionObject(new $class); + foreach ($instances as $name => $instance) { + echo "is $name a $class? "; + var_dump($ro->isInstance($instance)); + } } ?> diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt index 982580fc5673..1b30debc9d5e 100644 --- a/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isInstantiable_basic.phpt @@ -6,28 +6,28 @@ class C { } interface iface { - function f1(); + function f1(); } class ifaceImpl implements iface { - function f1() {} + function f1() {} } abstract class abstractClass { - function f1() {} - abstract function f2(); + function f1() {} + abstract function f2(); } class D extends abstractClass { - function f2() {} + function f2() {} } $classes = array("C", "ifaceImpl", "D"); foreach($classes as $class ) { - $ro = new ReflectionObject(new $class); - echo "Is $class instantiable? "; - var_dump($ro->IsInstantiable()); + $ro = new ReflectionObject(new $class); + echo "Is $class instantiable? "; + var_dump($ro->IsInstantiable()); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt index 3baa8a0950dc..dada6ffc789b 100644 --- a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt +++ b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt @@ -4,43 +4,43 @@ ReflectionObject::IsInstantiable() - variation - constructors getName(); - echo "Is $name instantiable? "; - var_dump($reflectionObject->IsInstantiable()); + $name = $reflectionObject->getName(); + echo "Is $name instantiable? "; + var_dump($reflectionObject->IsInstantiable()); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt index 234b8eb27e1a..8f1c6fc84198 100644 --- a/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt @@ -12,7 +12,7 @@ $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), - $r4->isInternal(), $r5->isInternal()); + $r4->isInternal(), $r5->isInternal()); ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt index a2484f9dc237..5cebd43016ee 100644 --- a/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt +++ b/ext/reflection/tests/ReflectionObject_isSubclassOf.002.phpt @@ -10,29 +10,29 @@ $ro = new ReflectionObject(new C); echo "\n\nTest bad arguments:\n"; try { - var_dump($ro->isSubclassOf()); + var_dump($ro->isSubclassOf()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($ro->isSubclassOf('C', 'C')); + var_dump($ro->isSubclassOf('C', 'C')); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($ro->isSubclassOf(null)); + var_dump($ro->isSubclassOf(null)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($ro->isSubclassOf('ThisClassDoesNotExist')); + var_dump($ro->isSubclassOf('ThisClassDoesNotExist')); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($ro->isSubclassOf(2)); + var_dump($ro->isSubclassOf(2)); } catch (Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt b/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt index 25c29c753454..095c59fa3400 100644 --- a/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isSubclassOf_basic.phpt @@ -13,28 +13,28 @@ $classNames = array('A', 'B', 'C', 'I', 'X'); //Create ReflectionClasses foreach ($classNames as $className) { - $rcs[$className] = new ReflectionClass($className); + $rcs[$className] = new ReflectionClass($className); } //Create ReflectionObjects foreach ($classNames as $className) { - if ($rcs[$className]->isInstantiable()) { - $ros[$className] = new ReflectionObject(new $className); - } + if ($rcs[$className]->isInstantiable()) { + $ros[$className] = new ReflectionObject(new $className); + } } foreach ($ros as $childName => $child) { - foreach ($rcs as $parentName => $parent) { - echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; - echo " - Using ReflectionClass object argument: "; - var_dump($child->isSubclassOf($parent)); - if ($parent->isInstantiable()) { - echo " - Using ReflectionObject object argument: "; - var_dump($child->isSubclassOf($ros[$parentName])); - } - echo " - Using string argument: "; - var_dump($child->isSubclassOf($parentName)); - } + foreach ($rcs as $parentName => $parent) { + echo "Is " . $childName . " a subclass of " . $parentName . "? \n"; + echo " - Using ReflectionClass object argument: "; + var_dump($child->isSubclassOf($parent)); + if ($parent->isInstantiable()) { + echo " - Using ReflectionObject object argument: "; + var_dump($child->isSubclassOf($ros[$parentName])); + } + echo " - Using string argument: "; + var_dump($child->isSubclassOf($parentName)); + } } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt index 1a9dea3aba80..f561b909e440 100644 --- a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt @@ -12,7 +12,7 @@ $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), - $r4->isUserDefined(), $r5->isUserDefined()); + $r4->isUserDefined(), $r5->isUserDefined()); ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionParameter_001.phpt b/ext/reflection/tests/ReflectionParameter_001.phpt index 822da2fe9ac5..b2b52187242f 100644 --- a/ext/reflection/tests/ReflectionParameter_001.phpt +++ b/ext/reflection/tests/ReflectionParameter_001.phpt @@ -11,11 +11,11 @@ class ReflectTestClass { } public function oneArgNonStatic($theParam) { - $theParam--; + $theParam--; } public function noArgs() { - echo "No arg function\n"; + echo "No arg function\n"; } } @@ -25,18 +25,18 @@ $method = new ReflectionMethod('ReflectTestClass', 'twoArgFunction'); $parameters = $method->getParameters(); echo "Parameters from twoArgMethod:\n\n"; foreach($parameters as $parameter) { - var_dump($parameter); - $name = $parameter->getName(); - echo "\n"; + var_dump($parameter); + $name = $parameter->getName(); + echo "\n"; } $method = new ReflectionMethod('ReflectTestClass', 'oneArgNonStatic'); $parameters = $method->getParameters(); echo "Parameters from oneArgNonStatic:\n\n"; foreach($parameters as $parameter) { - var_dump($parameter); - $name = $parameter->getName(); - echo "\n"; + var_dump($parameter); + $name = $parameter->getName(); + echo "\n"; } @@ -45,9 +45,9 @@ $parameters = $method->getParameters(); echo "Parameters from noArgs:\n\n"; var_dump($parameters); foreach($parameters as $parameter) { - var_dump($parameter); - $name = $parameter->getName(); - echo "\n"; + var_dump($parameter); + $name = $parameter->getName(); + echo "\n"; } echo "done\n"; diff --git a/ext/reflection/tests/ReflectionParameter_002.phpt b/ext/reflection/tests/ReflectionParameter_002.phpt index 571edac7a97f..7ff12c2d3386 100644 --- a/ext/reflection/tests/ReflectionParameter_002.phpt +++ b/ext/reflection/tests/ReflectionParameter_002.phpt @@ -21,11 +21,11 @@ $method = new ReflectionMethod('ReflectTestClass', 'staticMethod'); $parameters = $method->getParameters(); echo "Parameters from staticMethod:\n\n"; foreach($parameters as $parameter) { - var_dump($parameter); + var_dump($parameter); if($parameter->isPassedByReference()) { - echo "This param is passed by reference\n"; + echo "This param is passed by reference\n"; } else { - echo "This param is not passed by reference\n"; + echo "This param is not passed by reference\n"; } echo "\n"; } @@ -36,11 +36,11 @@ $method = new ReflectionMethod('ReflectTestClass', 'instanceMethod'); $parameters = $method->getParameters(); echo "Parameters from instanceMethod:\n\n"; foreach($parameters as $parameter) { - var_dump($parameter); + var_dump($parameter); if($parameter->isPassedByReference()) { - echo "This param is passed by reference\n"; + echo "This param is passed by reference\n"; } else { - echo "This param is not passed by reference\n"; + echo "This param is not passed by reference\n"; } echo "\n"; } diff --git a/ext/reflection/tests/ReflectionParameter_003.phpt b/ext/reflection/tests/ReflectionParameter_003.phpt index 581c486f6286..8396eeb97c3e 100644 --- a/ext/reflection/tests/ReflectionParameter_003.phpt +++ b/ext/reflection/tests/ReflectionParameter_003.phpt @@ -24,31 +24,31 @@ $refParameters = $refMethod->getParameters(); echo "parameter names from staticMethod method:\n\n"; foreach($refParameters as $parameter) { - var_dump($parameter); - if($parameter->isOptional()) { - echo "this parameter is optional\n"; - } else { - echo "this parameter is not optional\n"; - } + var_dump($parameter); + if($parameter->isOptional()) { + echo "this parameter is optional\n"; + } else { + echo "this parameter is not optional\n"; + } - if($parameter->isDefaultValueAvailable()) { - echo "this parameter has a default value\n"; - } else { - echo "this parameter has no default value\n"; - } + if($parameter->isDefaultValueAvailable()) { + echo "this parameter has a default value\n"; + } else { + echo "this parameter has no default value\n"; + } - /* - $val = 0; - try { - $val = $parameter->getDefaultValue(); - var_dump($val); - } catch (ReflectionException $e) { - print $e->getMessage(); - echo "\n"; - } - */ + /* + $val = 0; + try { + $val = $parameter->getDefaultValue(); + var_dump($val); + } catch (ReflectionException $e) { + print $e->getMessage(); + echo "\n"; + } + */ - echo "\n"; + echo "\n"; } ?> diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt index 7a92edc4cc4e..4f3f114bada6 100644 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic1.phpt @@ -6,30 +6,30 @@ ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() define("CONST_TEST_1", "const1"); function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1, $test3 = CASE_LOWER) { - echo $test; + echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $param) { - if($param->getName() == 'test1') { - var_dump($param->isDefaultValueConstant()); - } - if($param->getName() == 'test2') { - var_dump($param->isDefaultValueConstant()); - } - if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { - var_dump($param->getDefaultValueConstantName()); - } + if($param->getName() == 'test1') { + var_dump($param->isDefaultValueConstant()); + } + if($param->getName() == 'test2') { + var_dump($param->isDefaultValueConstant()); + } + if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { + var_dump($param->getDefaultValueConstantName()); + } } class Foo2 { - const bar = 'Foo2::bar'; + const bar = 'Foo2::bar'; } class Foo { - const bar = 'Foo::bar'; + const bar = 'Foo::bar'; - public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) { - } + public function baz($param1 = self::bar, $param2=Foo2::bar, $param3=CONST_TEST_1) { + } } $method = new ReflectionMethod('Foo', 'baz'); diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt index 1ee9e93735aa..28aeceeb2f83 100644 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_basic2.phpt @@ -4,24 +4,24 @@ ReflectionParameter::isDefaultValueConstant() && getDefaultValueConstantName() f getParameters() as $param) { - if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { - echo $param->getDefaultValueConstantName() . "\n"; - } - } - echo "==DONE=="; + function ReflectionParameterTest($test=ReflectionTestNamespace\TestClass::TEST_CONST_2, $test2 = ReflectionTestNamespace\CONST_TEST_1) { + echo $test; + } + $reflect = new ReflectionFunction('ReflectionParameterTest'); + foreach($reflect->getParameters() as $param) { + if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) { + echo $param->getDefaultValueConstantName() . "\n"; + } + } + echo "==DONE=="; } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt index a2c2d245829a..7f1451bbdb47 100644 --- a/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt +++ b/ext/reflection/tests/ReflectionParameter_DefaultValueConstant_error.phpt @@ -6,16 +6,16 @@ ReflectionParameter::getDefaultValueConstant() should raise exception on non opt define("CONST_TEST_1", "const1"); function ReflectionParameterTest($test, $test2 = CONST_TEST_1) { - echo $test; + echo $test; } $reflect = new ReflectionFunction('ReflectionParameterTest'); foreach($reflect->getParameters() as $param) { - try { - echo $param->getDefaultValueConstantName() . "\n"; - } - catch(ReflectionException $e) { - echo $e->getMessage() . "\n"; - } + try { + echo $param->getDefaultValueConstantName() . "\n"; + } + catch(ReflectionException $e) { + echo $e->getMessage() . "\n"; + } } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionParameter_export_basic.phpt b/ext/reflection/tests/ReflectionParameter_export_basic.phpt index 8286078135e7..22b25de6636c 100644 --- a/ext/reflection/tests/ReflectionParameter_export_basic.phpt +++ b/ext/reflection/tests/ReflectionParameter_export_basic.phpt @@ -5,11 +5,11 @@ Stefan Koopmanschap --FILE-- getParameters() as $key => $value) { - echo new ReflectionParameter('ReflectionParameterTest', $key), "\n"; + echo new ReflectionParameter('ReflectionParameterTest', $key), "\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionParameter_export_error2.phpt b/ext/reflection/tests/ReflectionParameter_export_error2.phpt index 38cd99171b0a..3def577e064e 100644 --- a/ext/reflection/tests/ReflectionParameter_export_error2.phpt +++ b/ext/reflection/tests/ReflectionParameter_export_error2.phpt @@ -5,25 +5,25 @@ Stefan Koopmanschap --FILE-- getParameters(); try { - foreach($params as $key => $value) { - ReflectionParameter::export($reflect, $key); - } + foreach($params as $key => $value) { + ReflectionParameter::export($reflect, $key); + } } catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - foreach($params as $key => $value) { - ReflectionParameter::export(42, $key); - } + foreach($params as $key => $value) { + ReflectionParameter::export(42, $key); + } } catch (ReflectionException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionParameter_export_error3.phpt b/ext/reflection/tests/ReflectionParameter_export_error3.phpt index b098a9251d99..822fca00329e 100644 --- a/ext/reflection/tests/ReflectionParameter_export_error3.phpt +++ b/ext/reflection/tests/ReflectionParameter_export_error3.phpt @@ -5,12 +5,12 @@ Stefan Koopmanschap --FILE-- getParameters(); foreach($params as $key => $value) { - ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter'); + ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter'); } --EXPECTF-- Deprecated: Function ReflectionParameter::export() is deprecated in %s on line %d diff --git a/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt b/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt index 18d4eb69a40a..7cbef6729235 100644 --- a/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt +++ b/ext/reflection/tests/ReflectionParameter_getDeclaringFunction_basic.phpt @@ -6,12 +6,12 @@ Stefan Koopmanschap --FILE-- getParameters(); foreach($params as $key => $value) { - echo $value->getDeclaringFunction() . "\n"; + echo $value->getDeclaringFunction() . "\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt b/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt index c5df520c4202..485ca37a2bbd 100644 --- a/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt +++ b/ext/reflection/tests/ReflectionParameter_getPosition_basic.phpt @@ -6,12 +6,12 @@ Stefan Koopmanschap --FILE-- getParameters(); foreach($params as $key => $value) { - var_dump($value->getPosition()); + var_dump($value->getPosition()); } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt index eb6d4644a03d..ee6ae86cba96 100644 --- a/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt +++ b/ext/reflection/tests/ReflectionParameter_invalidMethodInConstructor.phpt @@ -5,17 +5,17 @@ ReflectionParameter::__construct(): Invalid method as constructor // Invalid class name try { - new ReflectionParameter (array ('A', 'b'), 0); + new ReflectionParameter (array ('A', 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage()."\n"; } // Invalid class method try { - new ReflectionParameter (array ('C', 'b'), 0); + new ReflectionParameter (array ('C', 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } // Invalid object method try { - new ReflectionParameter (array (new C, 'b'), 0); + new ReflectionParameter (array (new C, 'b'), 0); } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } @@ -23,17 +23,17 @@ class C { } try { - new ReflectionParameter(array ('A', 'b')); + new ReflectionParameter(array ('A', 'b')); } catch(TypeError $e) { - printf( "Ok - %s\n", $e->getMessage()); + printf( "Ok - %s\n", $e->getMessage()); } try { - new ReflectionParameter(0, 0); + new ReflectionParameter(0, 0); } catch(ReflectionException $e) { - printf( "Ok - %s\n", $e->getMessage()); + printf( "Ok - %s\n", $e->getMessage()); } echo "Done.\n"; diff --git a/ext/reflection/tests/ReflectionParameter_toString_basic.phpt b/ext/reflection/tests/ReflectionParameter_toString_basic.phpt index 35134b7e2d20..053c3918db97 100644 --- a/ext/reflection/tests/ReflectionParameter_toString_basic.phpt +++ b/ext/reflection/tests/ReflectionParameter_toString_basic.phpt @@ -5,12 +5,12 @@ Stefan Koopmanschap --FILE-- getParameters(); foreach($params as $key => $value) { - echo $value->__toString() . "\n"; + echo $value->__toString() . "\n"; } ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt index 6f39f9db6cac..4456960dc7eb 100644 --- a/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt +++ b/ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt @@ -4,27 +4,27 @@ ReflectionProperty::__construct(): ensure inherited private props can't be acces getMessage(); - } - } + private $p = 1; + + static function testFromC() { + try { + $rp = new ReflectionProperty("D", "p"); + var_dump($rp); + } catch (Exception $e) { + echo $e->getMessage(); + } + } } class D extends C{ - static function testFromD() { - try { - $rp = new ReflectionProperty("D", "p"); - var_dump($rp); - } catch (Exception $e) { - echo $e->getMessage(); - } - } + static function testFromD() { + try { + $rp = new ReflectionProperty("D", "p"); + var_dump($rp); + } catch (Exception $e) { + echo $e->getMessage(); + } + } } echo "--> Reflect inherited private from global scope:\n"; @@ -32,7 +32,7 @@ try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } echo "\n\n--> Reflect inherited private from declaring scope:\n"; diff --git a/ext/reflection/tests/ReflectionProperty_error.phpt b/ext/reflection/tests/ReflectionProperty_error.phpt index a7fdff5000f3..052bfcb97c83 100644 --- a/ext/reflection/tests/ReflectionProperty_error.phpt +++ b/ext/reflection/tests/ReflectionProperty_error.phpt @@ -8,20 +8,20 @@ class C { } try { - new ReflectionProperty(); + new ReflectionProperty(); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - new ReflectionProperty('C::p'); + new ReflectionProperty('C::p'); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } try { - new ReflectionProperty('C', 'p', 'x'); + new ReflectionProperty('C', 'p', 'x'); } catch (TypeError $re) { - echo "Ok - ".$re->getMessage().PHP_EOL; + echo "Ok - ".$re->getMessage().PHP_EOL; } ?> diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt index a297a1043684..da6cf71b9cc8 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt @@ -7,15 +7,15 @@ Steve Seear getModifiers()); + echo "getModifiers():\n"; + var_dump($propInfo->getModifiers()); - echo "\n**********************************\n"; + echo "\n**********************************\n"; } class TestClass @@ -23,8 +23,8 @@ class TestClass public $pub; static public $stat = "static property"; /** - * This property has a comment. - */ + * This property has a comment. + */ protected $prot = 4; private $priv = "keepOut"; } diff --git a/ext/reflection/tests/ReflectionProperty_isInitialized.phpt b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt index f1f6e53ebd54..260084fae45d 100644 --- a/ext/reflection/tests/ReflectionProperty_isInitialized.phpt +++ b/ext/reflection/tests/ReflectionProperty_isInitialized.phpt @@ -4,12 +4,12 @@ Test ReflectionProperty::isInitialized() getProperties() as $name => $property) { - if ($property->hasType()) { - printf("public %s $%s;\n", - $property->getType()->getName(), $property->getName()); - } else printf("public $%s;\n", $property->getName()); + if ($property->hasType()) { + printf("public %s $%s;\n", + $property->getType()->getName(), $property->getName()); + } else printf("public $%s;\n", $property->getName()); } echo "*** resolved property types\n"; diff --git a/ext/reflection/tests/bug26640.phpt b/ext/reflection/tests/bug26640.phpt index 8a93d722475a..203785f1dc23 100644 --- a/ext/reflection/tests/bug26640.phpt +++ b/ext/reflection/tests/bug26640.phpt @@ -4,19 +4,19 @@ Reflection Bug #26640 (__autoload() not invoked by Reflection classes) diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt index 9166bd3aa946..596d3aba1e20 100644 --- a/ext/reflection/tests/bug29268.phpt +++ b/ext/reflection/tests/bug29268.phpt @@ -3,21 +3,21 @@ Reflection Bug #29268 (__autoload() not called with reflectionProperty->getClass --FILE-- getParameters(); foreach($parameters as $parameter) { - $class = $parameter->getClass(); - echo $class->name."\n"; + $class = $parameter->getClass(); + echo $class->name."\n"; } echo "ok\n"; ?> diff --git a/ext/reflection/tests/bug29523.phpt b/ext/reflection/tests/bug29523.phpt index fafc93ef4035..a85612935eca 100644 --- a/ext/reflection/tests/bug29523.phpt +++ b/ext/reflection/tests/bug29523.phpt @@ -16,15 +16,15 @@ $numberOfNotOptionalParameters = 0; $numberOfOptionalParameters = 0; foreach($function->getParameters() as $parameter) { - var_dump($parameter->isOptional()); - if ($parameter->isOptional()) - { - ++$numberOfOptionalParameters; - } - else - { - ++$numberOfNotOptionalParameters; - } + var_dump($parameter->isOptional()); + if ($parameter->isOptional()) + { + ++$numberOfOptionalParameters; + } + else + { + ++$numberOfNotOptionalParameters; + } } var_dump($function->getNumberOfRequiredParameters()); var_dump($numberOfNotOptionalParameters); diff --git a/ext/reflection/tests/bug29828.phpt b/ext/reflection/tests/bug29828.phpt index a5f3e30c6f62..15c1229cc051 100644 --- a/ext/reflection/tests/bug29828.phpt +++ b/ext/reflection/tests/bug29828.phpt @@ -5,15 +5,15 @@ Reflection Bug #29828 (Interfaces no longer work) interface Bla { - function bla(); + function bla(); } class BlaMore implements Bla { - function bla() - { - echo "Hello\n"; - } + function bla() + { + echo "Hello\n"; + } } $r = new ReflectionClass('BlaMore'); diff --git a/ext/reflection/tests/bug30209.phpt b/ext/reflection/tests/bug30209.phpt index 27b546d1cdbb..0dc453e6c021 100644 --- a/ext/reflection/tests/bug30209.phpt +++ b/ext/reflection/tests/bug30209.phpt @@ -5,20 +5,20 @@ Reflection Bug #30209 (ReflectionClass::getMethod() lowercases attribute) class Foo { - private $name = 'testBAR'; + private $name = 'testBAR'; - public function testBAR() - { - try - { - $class = new ReflectionClass($this); - var_dump($this->name); - $method = $class->getMethod($this->name); - var_dump($this->name); - } + public function testBAR() + { + try + { + $class = new ReflectionClass($this); + var_dump($this->name); + $method = $class->getMethod($this->name); + var_dump($this->name); + } - catch (Exception $e) {} - } + catch (Exception $e) {} + } } $foo = new Foo; diff --git a/ext/reflection/tests/bug31651.phpt b/ext/reflection/tests/bug31651.phpt index 59f19eae5d69..e356baf148a4 100644 --- a/ext/reflection/tests/bug31651.phpt +++ b/ext/reflection/tests/bug31651.phpt @@ -5,7 +5,7 @@ Reflection Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arra class Test { - public $a = array('a' => 1); + public $a = array('a' => 1); } $ref = new ReflectionClass('Test'); diff --git a/ext/reflection/tests/bug32981.phpt b/ext/reflection/tests/bug32981.phpt index 0e3b721a64ff..fc6960866f18 100644 --- a/ext/reflection/tests/bug32981.phpt +++ b/ext/reflection/tests/bug32981.phpt @@ -5,17 +5,17 @@ Reflection Bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.5 class TestClass { - static function test() - { - static $enabled = true; - } + static function test() + { + static $enabled = true; + } } $class = new ReflectionClass('TestClass'); foreach ($class->getMethods() as $method) { - var_dump($method->getName()); - $arr_static_vars[] = $method->getStaticVariables(); + var_dump($method->getName()); + $arr_static_vars[] = $method->getStaticVariables(); } var_dump($arr_static_vars); diff --git a/ext/reflection/tests/bug36434.phpt b/ext/reflection/tests/bug36434.phpt index 502ac741a908..04cdcbf01d78 100644 --- a/ext/reflection/tests/bug36434.phpt +++ b/ext/reflection/tests/bug36434.phpt @@ -5,24 +5,24 @@ Reflection Bug #36434 (Properties from parent class fail to indetify their true class ancester { public $ancester = 0; - function __construct() - { - return $this->ancester; - } + function __construct() + { + return $this->ancester; + } } class foo extends ancester { public $bar = "1"; - function __construct() - { - return $this->bar; - } + function __construct() + { + return $this->bar; + } } $r = new ReflectionClass('foo'); foreach ($r->GetProperties() as $p) { - echo $p->getName(). " ". $p->getDeclaringClass()->getName()."\n"; + echo $p->getName(). " ". $p->getDeclaringClass()->getName()."\n"; } ?> diff --git a/ext/reflection/tests/bug37816.phpt b/ext/reflection/tests/bug37816.phpt index 3942265a0e26..eec6f094114c 100644 --- a/ext/reflection/tests/bug37816.phpt +++ b/ext/reflection/tests/bug37816.phpt @@ -5,7 +5,7 @@ Bug #37816 (ReflectionProperty does not throw exception when accessing protected class TestClass { - protected $p = 2; + protected $p = 2; } $o = new TestClass; @@ -14,11 +14,11 @@ $r = new ReflectionProperty($o, 'p'); try { - $x = $r->getValue($o); + $x = $r->getValue($o); } catch (Exception $e) { - echo 'Caught: ' . $e->getMessage() . "\n"; + echo 'Caught: ' . $e->getMessage() . "\n"; } ?> diff --git a/ext/reflection/tests/bug37964.phpt b/ext/reflection/tests/bug37964.phpt index f3ebe9f72afa..59b5f8559025 100644 --- a/ext/reflection/tests/bug37964.phpt +++ b/ext/reflection/tests/bug37964.phpt @@ -4,19 +4,19 @@ Reflection Bug #37964 (Reflection shows private methods of parent class) newInstanceArgs()); class ObjectTwo { - public function __construct($var) { - var_dump($var); - } + public function __construct($var) { + var_dump($var); + } } $class= new ReflectionClass('ObjectTwo'); try { - var_dump($class->newInstanceArgs()); + var_dump($class->newInstanceArgs()); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } var_dump($class->newInstanceArgs(array('test'))); diff --git a/ext/reflection/tests/bug38653.phpt b/ext/reflection/tests/bug38653.phpt index 64b1aad15bd0..36504e7c7b66 100644 --- a/ext/reflection/tests/bug38653.phpt +++ b/ext/reflection/tests/bug38653.phpt @@ -4,9 +4,9 @@ Bug #38653 (memory leak in ReflectionClass::getConstant()) getProperty('x')->getDeclaringClass()->getName()); class Test { - private $x; + private $x; } class Test2 extends Test { - public $x; + public $x; } $rc = new ReflectionClass('Test2'); diff --git a/ext/reflection/tests/bug40431.phpt b/ext/reflection/tests/bug40431.phpt index 637b1457cd6c..41620a392651 100644 --- a/ext/reflection/tests/bug40431.phpt +++ b/ext/reflection/tests/bug40431.phpt @@ -56,7 +56,7 @@ var_dump($props[0]->isProtected()); echo "=== 4th test ===\n"; class test5 { - private $value = 1; + private $value = 1; } class test4 extends test5{ diff --git a/ext/reflection/tests/bug40794.phpt b/ext/reflection/tests/bug40794.phpt index c1830ddcd2ff..1f1bb61c5819 100644 --- a/ext/reflection/tests/bug40794.phpt +++ b/ext/reflection/tests/bug40794.phpt @@ -13,7 +13,7 @@ $reflect = new ReflectionObject($obj); $array = array(); foreach($reflect->getProperties() as $prop) { - $array[$prop->getName()] = $prop->getValue($obj); + $array[$prop->getName()] = $prop->getValue($obj); } var_dump($array); diff --git a/ext/reflection/tests/bug41884.phpt b/ext/reflection/tests/bug41884.phpt index 25d2b7cb74a1..ae9655765e7b 100644 --- a/ext/reflection/tests/bug41884.phpt +++ b/ext/reflection/tests/bug41884.phpt @@ -5,8 +5,8 @@ Bug #41884 (ReflectionClass::getDefaultProperties() does not handle static attri class Foo { - protected static $fooStatic = 'foo'; - protected $foo = 'foo'; + protected static $fooStatic = 'foo'; + protected $foo = 'foo'; } $class = new ReflectionClass('Foo'); diff --git a/ext/reflection/tests/bug42976.phpt b/ext/reflection/tests/bug42976.phpt index 0b147aa8112e..d8ab797b9266 100644 --- a/ext/reflection/tests/bug42976.phpt +++ b/ext/reflection/tests/bug42976.phpt @@ -4,9 +4,9 @@ Bug #42976 (Crash when constructor for newInstance() or newInstanceArgs() fails) getValue($o)); print "---------------------------\n"; try { - var_dump(new reflectionproperty($o, 'zz')); + var_dump(new reflectionproperty($o, 'zz')); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } var_dump(new reflectionproperty($o, 'zzz')); class test { - protected $a = 1; + protected $a = 1; } class bar extends test { - public function __construct() { - $this->foobar = 2; - $this->a = 200; + public function __construct() { + $this->foobar = 2; + $this->a = 200; - $p = new reflectionproperty($this, 'foobar'); - var_dump($p->getValue($this), $p->isDefault(), $p->isPublic()); - } + $p = new reflectionproperty($this, 'foobar'); + var_dump($p->getValue($this), $p->isDefault(), $p->isPublic()); + } } new bar; diff --git a/ext/reflection/tests/bug46064_2.phpt b/ext/reflection/tests/bug46064_2.phpt index 9e10167d301b..f1aac5b5c0e6 100644 --- a/ext/reflection/tests/bug46064_2.phpt +++ b/ext/reflection/tests/bug46064_2.phpt @@ -15,22 +15,22 @@ var_dump($p->getProperty('test')); class bar { - public function __construct() { - $this->a = 1; - } + public function __construct() { + $this->a = 1; + } } class test extends bar { - private $b = 2; + private $b = 2; - public function __construct() { - parent::__construct(); + public function __construct() { + parent::__construct(); - $p = new reflectionobject($this); - var_dump($h = $p->getProperty('a')); - var_dump($h->isDefault(), $h->isProtected(), $h->isPrivate(), $h->isPublic(), $h->isStatic()); - var_dump($p->getProperties()); - } + $p = new reflectionobject($this); + var_dump($h = $p->getProperty('a')); + var_dump($h->isDefault(), $h->isProtected(), $h->isPrivate(), $h->isPublic(), $h->isStatic()); + var_dump($p->getProperties()); + } } new test; diff --git a/ext/reflection/tests/bug46205.phpt b/ext/reflection/tests/bug46205.phpt index 5ca8ac1cd08f..78e381370e30 100644 --- a/ext/reflection/tests/bug46205.phpt +++ b/ext/reflection/tests/bug46205.phpt @@ -6,7 +6,7 @@ $x = new reflectionmethod('reflectionparameter', 'export'); $y = function() { }; try { - $x->invokeArgs(new reflectionparameter('trim', 'str'), array($y, 1)); + $x->invokeArgs(new reflectionparameter('trim', 'str'), array($y, 1)); } catch (Exception $e) { } ?> ok diff --git a/ext/reflection/tests/bug47254.phpt b/ext/reflection/tests/bug47254.phpt index b6f33fcfc645..6330d6603f11 100644 --- a/ext/reflection/tests/bug47254.phpt +++ b/ext/reflection/tests/bug47254.phpt @@ -8,13 +8,13 @@ Testfest 2009 Munich hasProperty('a')); - var_dump($ref->getProperty('a')); + var_dump(property_exists('b', 'a')); + var_dump(property_exists($b, 'a')); + var_dump($ref->hasProperty('a')); + var_dump($ref->getProperty('a')); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } class A2 { - private $a = 1; + private $a = 1; } class B2 extends A2 { - private $a = 2; + private $a = 2; } $b2 = new ReflectionClass('B2'); diff --git a/ext/reflection/tests/bug51905.phpt b/ext/reflection/tests/bug51905.phpt index 8969924e45f3..2d956386a55b 100644 --- a/ext/reflection/tests/bug51905.phpt +++ b/ext/reflection/tests/bug51905.phpt @@ -4,12 +4,12 @@ Bug #51905 (ReflectionParameter fails if default value is an array with an acces newInstance()); var_dump($c->newInstanceArgs(array())); try { - var_dump($c->newInstanceArgs(array(1))); + var_dump($c->newInstanceArgs(array(1))); } catch(ReflectionException $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --EXPECTF-- diff --git a/ext/reflection/tests/bug53915.phpt b/ext/reflection/tests/bug53915.phpt index f2f2ae56759d..f4df7cc8395a 100644 --- a/ext/reflection/tests/bug53915.phpt +++ b/ext/reflection/tests/bug53915.phpt @@ -4,8 +4,8 @@ Bug #53915 - ReflectionClass::getConstant(s) emits fatal error on selfreferencin message; - } + public function bravo() { + return $this->message; + } } $alpha = new Alpha(); diff --git a/ext/reflection/tests/bug70982.phpt b/ext/reflection/tests/bug70982.phpt index d530846f6453..644531e37399 100644 --- a/ext/reflection/tests/bug70982.phpt +++ b/ext/reflection/tests/bug70982.phpt @@ -3,11 +3,11 @@ Bug #70982 (setStaticPropertyValue behaviors inconsistently with 5.6) --FILE-- getMessage(), PHP_EOL; + echo get_class($e), ': ', $e->getMessage(), PHP_EOL; } function load_file() { - require __DIR__ . '/bug74454.inc'; + require __DIR__ . '/bug74454.inc'; } ?> --EXPECT-- diff --git a/ext/reflection/tests/bug74673.phpt b/ext/reflection/tests/bug74673.phpt index 42675f263e8e..321195c16ecf 100644 --- a/ext/reflection/tests/bug74673.phpt +++ b/ext/reflection/tests/bug74673.phpt @@ -5,9 +5,9 @@ Bug #74673 (Segfault when cast Reflection object to string with undefined consta class A { - public function method($test = PHP_SELF + 1) - { - } + public function method($test = PHP_SELF + 1) + { + } } $class = new ReflectionClass('A'); diff --git a/ext/reflection/tests/bug74949.phpt b/ext/reflection/tests/bug74949.phpt index 2970c5911f60..20e0fc00e101 100644 --- a/ext/reflection/tests/bug74949.phpt +++ b/ext/reflection/tests/bug74949.phpt @@ -12,9 +12,9 @@ unset($f); echo $r, "\n"; try { - echo $r->getPrototype(); + echo $r->getPrototype(); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> --EXPECT-- diff --git a/ext/reflection/tests/bug77882.phpt b/ext/reflection/tests/bug77882.phpt index ff1d21286136..71e430d17809 100644 --- a/ext/reflection/tests/bug77882.phpt +++ b/ext/reflection/tests/bug77882.phpt @@ -7,7 +7,7 @@ class Test { public function __construct() { throw new Exception(); } - + public function __destruct() { echo "__destruct\n"; } diff --git a/ext/reflection/tests/bug78895.phpt b/ext/reflection/tests/bug78895.phpt index 7e616c445681..b5f84e2d02ba 100644 --- a/ext/reflection/tests/bug78895.phpt +++ b/ext/reflection/tests/bug78895.phpt @@ -3,18 +3,18 @@ Fixed bug #78895 (Reflection detects abstract non-static class as abstract stati --FILE-- getModifiers())); diff --git a/ext/reflection/tests/closures_001.phpt b/ext/reflection/tests/closures_001.phpt index 926951eef220..56581c05b87d 100644 --- a/ext/reflection/tests/closures_001.phpt +++ b/ext/reflection/tests/closures_001.phpt @@ -11,10 +11,10 @@ var_dump($rm->getNumberOfParameters()); var_dump($rm->getNumberOfRequiredParameters()); $rms = $ro->getMethods(); foreach($rms as $rm) { - if ($rm->getName() == '__invoke') { - var_dump($rm->getNumberOfParameters()); - var_dump($rm->getNumberOfRequiredParameters()); - } + if ($rm->getName() == '__invoke') { + var_dump($rm->getNumberOfParameters()); + var_dump($rm->getNumberOfRequiredParameters()); + } } echo "---\n"; diff --git a/ext/reflection/tests/closures_002.phpt b/ext/reflection/tests/closures_002.phpt index 4b127810fb3b..9e606857b680 100644 --- a/ext/reflection/tests/closures_002.phpt +++ b/ext/reflection/tests/closures_002.phpt @@ -4,7 +4,7 @@ Reflection on invocable objects diff --git a/ext/reflection/tests/parameters_001.phpt b/ext/reflection/tests/parameters_001.phpt index 92869a2faf2d..6c57b2c3077b 100644 --- a/ext/reflection/tests/parameters_001.phpt +++ b/ext/reflection/tests/parameters_001.phpt @@ -4,8 +4,8 @@ ReflectionParameter Check for parameter being optional isOptional()); try { - $p = new ReflectionParameter(array('Test', 'func'), 'z'); - var_dump($p->isOptional()); + $p = new ReflectionParameter(array('Test', 'func'), 'z'); + var_dump($p->isOptional()); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/reflection/tests/parameters_002.phpt b/ext/reflection/tests/parameters_002.phpt index aed8d7afa07c..14cb7fdefbdc 100644 --- a/ext/reflection/tests/parameters_002.phpt +++ b/ext/reflection/tests/parameters_002.phpt @@ -10,61 +10,61 @@ function test($nix, Array $ar, &$ref, stdClass $std, class test { - function method($nix, Array $ar, &$ref, stdClass $std, + function method($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass $opt = NULL, $def = "FooBar") - { - } + { + } } function check_params_decl_func($r, $f) { - $c = $r->$f(); + $c = $r->$f(); $sep = $c instanceof ReflectionMethod ? $c->class . '::' : ''; - echo $f . ': ' . ($c ? $sep . $c->name : 'NULL') . "()\n"; + echo $f . ': ' . ($c ? $sep . $c->name : 'NULL') . "()\n"; } function check_params_decl_class($r, $f) { - $c = $r->$f(); - echo $f . ': ' . ($c ? $c->name : 'NULL') . "\n"; + $c = $r->$f(); + echo $f . ': ' . ($c ? $c->name : 'NULL') . "\n"; } function check_params_func($r, $f) { - echo $f . ': '; - $v = $r->$f(); - var_dump($v); + echo $f . ': '; + $v = $r->$f(); + var_dump($v); } function check_params($r) { - echo "#####" . ($r instanceof ReflectionMethod ? $r->class . '::' : '') . $r->name . "()#####\n"; - $i = 0; - foreach($r->getParameters() as $p) - { - echo "===" . $i . "===\n"; - $i++; - check_params_func($p, 'getName'); - check_params_func($p, 'isPassedByReference'); - try - { - check_params_decl_class($p, 'getClass'); - } - catch(ReflectionException $e) - { - echo $e->getMessage() . "\n"; - } - check_params_decl_class($p, 'getDeclaringClass'); + echo "#####" . ($r instanceof ReflectionMethod ? $r->class . '::' : '') . $r->name . "()#####\n"; + $i = 0; + foreach($r->getParameters() as $p) + { + echo "===" . $i . "===\n"; + $i++; + check_params_func($p, 'getName'); + check_params_func($p, 'isPassedByReference'); + try + { + check_params_decl_class($p, 'getClass'); + } + catch(ReflectionException $e) + { + echo $e->getMessage() . "\n"; + } + check_params_decl_class($p, 'getDeclaringClass'); // check_params_decl_func($p, 'getDeclaringFunction'); - check_params_func($p, 'isArray'); - check_params_func($p, 'allowsNull'); - check_params_func($p, 'isOptional'); - check_params_func($p, 'isDefaultValueAvailable'); - if ($p->isOptional()) - { - check_params_func($p, 'getDefaultValue'); - } - } + check_params_func($p, 'isArray'); + check_params_func($p, 'allowsNull'); + check_params_func($p, 'isOptional'); + check_params_func($p, 'isDefaultValueAvailable'); + if ($p->isOptional()) + { + check_params_func($p, 'getDefaultValue'); + } + } } check_params(new ReflectionFunction('test')); diff --git a/ext/reflection/tests/property_exists.phpt b/ext/reflection/tests/property_exists.phpt index 002ece12b317..a740589bab9f 100644 --- a/ext/reflection/tests/property_exists.phpt +++ b/ext/reflection/tests/property_exists.phpt @@ -5,54 +5,54 @@ Reflection and property_exists() class A { - public $a = 1; - protected $b = 2; - private $c = 3; + public $a = 1; + protected $b = 2; + private $c = 3; - public $empty; - public $init = 1; + public $empty; + public $init = 1; - function __toString() - { - return 'obj(' . get_class($this) . ')'; - } + function __toString() + { + return 'obj(' . get_class($this) . ')'; + } - static function test($oc, $props) - { - echo '===' . __CLASS__ . "===\n"; - foreach($props as $p2) { - echo $oc, '::$' , $p2, "\n"; - var_dump(property_exists($oc, $p2)); - } - } + static function test($oc, $props) + { + echo '===' . __CLASS__ . "===\n"; + foreach($props as $p2) { + echo $oc, '::$' , $p2, "\n"; + var_dump(property_exists($oc, $p2)); + } + } } class B extends A { - private $c = 4; + private $c = 4; - static function test($oc, $props) - { - echo '===' . __CLASS__ . "===\n"; - foreach($props as $p2) { - echo $oc, '::$' , $p2, "\n"; - var_dump(property_exists($oc, $p2)); - } - } + static function test($oc, $props) + { + echo '===' . __CLASS__ . "===\n"; + foreach($props as $p2) { + echo $oc, '::$' , $p2, "\n"; + var_dump(property_exists($oc, $p2)); + } + } } class C extends B { - private $d = 5; + private $d = 5; - static function test($oc, $props) - { - echo '===' . __CLASS__ . "===\n"; - foreach($props as $p2) { - echo $oc, '::$' , $p2, "\n"; - var_dump(property_exists($oc, $p2)); - } - } + static function test($oc, $props) + { + echo '===' . __CLASS__ . "===\n"; + foreach($props as $p2) { + echo $oc, '::$' , $p2, "\n"; + var_dump(property_exists($oc, $p2)); + } + } } $oA = new A; @@ -64,17 +64,17 @@ $pc = array($oA, 'A', 'B', 'C', $oC); $pr = array('a', 'b', 'c', 'd', 'e'); foreach($pc as $p1) { - if (is_object($p1)) { - $p1->test($p1, $pr); - } else { - $r = new ReflectionMethod($p1, 'test'); - $r->invoke(NULL, $p1, $pr); - } - echo "===GLOBAL===\n"; - foreach($pr as $p2) { - echo $p1, '::$' , $p2, "\n"; - var_dump(property_exists($p1, $p2)); - } + if (is_object($p1)) { + $p1->test($p1, $pr); + } else { + $r = new ReflectionMethod($p1, 'test'); + $r->invoke(NULL, $p1, $pr); + } + echo "===GLOBAL===\n"; + foreach($pr as $p2) { + echo $p1, '::$' , $p2, "\n"; + var_dump(property_exists($p1, $p2)); + } } echo "===PROBLEMS===\n"; diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt index 0e3baa9530d0..126aa784a0c1 100644 --- a/ext/reflection/tests/static_properties_002.phpt +++ b/ext/reflection/tests/static_properties_002.phpt @@ -4,29 +4,29 @@ Reflection and inheriting static properties allowsNull() ? "true" : "false") . "\n"; } } - + function test1(): X|Y|int|float|false|null { } function test2(): X|iterable|bool { } diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt index 0643dce51fde..adf63c5f6a93 100644 --- a/ext/session/tests/001.phpt +++ b/ext/session/tests/001.phpt @@ -12,9 +12,9 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; + public $bar = "ok"; - function method() { $this->yes = "done"; } + function method() { $this->yes = "done"; } } $baz = new foo; diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt index eae636593d86..a20bc9940d6c 100644 --- a/ext/session/tests/003.phpt +++ b/ext/session/tests/003.phpt @@ -13,8 +13,8 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; - function method() { $this->yes++; } + public $bar = "ok"; + function method() { $this->yes++; } } session_id("abtest"); diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt index 9e34b7123f92..4b81a088b2fa 100644 --- a/ext/session/tests/004.phpt +++ b/ext/session/tests/004.phpt @@ -33,7 +33,7 @@ class handler { function write($key, $val) { print "WRITE: $key, $val\n"; - $GLOBALS["hnd"]->data = $val; + $GLOBALS["hnd"]->data = $val; return true; } diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt index 4046b3aebc2d..a7b42de7fa38 100644 --- a/ext/session/tests/005.phpt +++ b/ext/session/tests/005.phpt @@ -14,7 +14,7 @@ error_reporting(E_ALL); ob_start(); class handler { - public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; function open($save_path, $session_name) { print "OPEN: $session_name\n"; @@ -22,7 +22,7 @@ class handler { } function close() { - print "CLOSE\n"; + print "CLOSE\n"; return true; } function read($key) @@ -34,7 +34,7 @@ class handler { function write($key, $val) { print "WRITE: $key, $val\n"; - $GLOBALS["hnd"]->data = $val; + $GLOBALS["hnd"]->data = $val; return true; } diff --git a/ext/session/tests/017.phpt b/ext/session/tests/017.phpt index baf7df8c574b..957fcb2e452f 100644 --- a/ext/session/tests/017.phpt +++ b/ext/session/tests/017.phpt @@ -13,10 +13,10 @@ session.save_handler=files error_reporting(E_ALL); class Kill { - function __construct() { - global $HTTP_SESSION_VARS; - session_start(); - } + function __construct() { + global $HTTP_SESSION_VARS; + session_start(); + } } $k = new Kill(); diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt index 584629176909..d9a478245b92 100644 --- a/ext/session/tests/019.phpt +++ b/ext/session/tests/019.phpt @@ -14,13 +14,13 @@ session.save_handler=files error_reporting(E_ALL); class TFoo { - public $c; - function __construct($c) { - $this->c = $c; - } - function inc() { - $this->c++; - } + public $c; + function __construct($c) { + $this->c = $c; + } + function inc() { + $this->c++; + } } session_id("abtest"); diff --git a/ext/session/tests/022.phpt b/ext/session/tests/022.phpt index 5923bbe0bf4e..e7e26f88b020 100644 --- a/ext/session/tests/022.phpt +++ b/ext/session/tests/022.phpt @@ -12,9 +12,9 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; + public $bar = "ok"; - function method() { $this->yes = "done"; } + function method() { $this->yes = "done"; } } $baz = new foo; diff --git a/ext/session/tests/023.phpt b/ext/session/tests/023.phpt index 592b4a8c3b8a..828358dc7823 100644 --- a/ext/session/tests/023.phpt +++ b/ext/session/tests/023.phpt @@ -13,8 +13,8 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; - function method() { $this->yes++; } + public $bar = "ok"; + function method() { $this->yes++; } } session_id("abtest"); diff --git a/ext/session/tests/024.phpt b/ext/session/tests/024.phpt index d417a82ca1b7..174f2e263963 100644 --- a/ext/session/tests/024.phpt +++ b/ext/session/tests/024.phpt @@ -34,7 +34,7 @@ class handler { function write($key, $val) { print "WRITE: $key, $val\n"; - $GLOBALS["hnd"]->data = $val; + $GLOBALS["hnd"]->data = $val; return true; } diff --git a/ext/session/tests/025.phpt b/ext/session/tests/025.phpt index aa1f995c494d..172ea579c650 100644 --- a/ext/session/tests/025.phpt +++ b/ext/session/tests/025.phpt @@ -23,7 +23,7 @@ class handler { } function close() { - print "CLOSE\n"; + print "CLOSE\n"; return true; } function read($key) diff --git a/ext/session/tests/bug31454.phpt b/ext/session/tests/bug31454.phpt index 24da588aa4f9..9e99135e5fda 100644 --- a/ext/session/tests/bug31454.phpt +++ b/ext/session/tests/bug31454.phpt @@ -6,12 +6,12 @@ Bug #31454 (session_set_save_handler crashes PHP when supplied non-existent obje diff --git a/ext/session/tests/bug32330.phpt b/ext/session/tests/bug32330.phpt index 4d432ef1d453..4240ff7160be 100644 --- a/ext/session/tests/bug32330.phpt +++ b/ext/session/tests/bug32330.phpt @@ -16,38 +16,38 @@ error_reporting(E_ALL); function sOpen($path, $name) { - echo "open: path = {$path}, name = {$name}\n"; - return TRUE; + echo "open: path = {$path}, name = {$name}\n"; + return TRUE; } function sClose() { - echo "close\n"; - return TRUE; + echo "close\n"; + return TRUE; } function sRead($id) { - echo "read: id = {$id}\n"; - return ''; + echo "read: id = {$id}\n"; + return ''; } function sWrite($id, $data) { - echo "write: id = {$id}, data = {$data}\n"; - return TRUE; + echo "write: id = {$id}, data = {$data}\n"; + return TRUE; } function sDestroy($id) { - echo "destroy: id = {$id}\n"; - return TRUE; + echo "destroy: id = {$id}\n"; + return TRUE; } function sGC($maxlifetime) { - echo "gc: maxlifetime = {$maxlifetime}\n"; - return TRUE; + echo "gc: maxlifetime = {$maxlifetime}\n"; + return TRUE; } session_set_save_handler( 'sOpen', 'sClose', 'sRead', 'sWrite', 'sDestroy', 'sGC' ); diff --git a/ext/session/tests/bug60634.phpt b/ext/session/tests/bug60634.phpt index 064f29a0d2db..b303134e5bce 100644 --- a/ext/session/tests/bug60634.phpt +++ b/ext/session/tests/bug60634.phpt @@ -16,15 +16,15 @@ function open($save_path, $session_name) { } function close() { - die("close: goodbye cruel world\n"); + die("close: goodbye cruel world\n"); } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - die("write: goodbye cruel world\n"); + die("write: goodbye cruel world\n"); } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_1.phpt b/ext/session/tests/bug60634_error_1.phpt index c573b65e36b0..9a1d2288a366 100644 --- a/ext/session/tests/bug60634_error_1.phpt +++ b/ext/session/tests/bug60634_error_1.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - return true; + echo "close: goodbye cruel world\n"; + return true; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - undefined_function(); + echo "write: goodbye cruel world\n"; + undefined_function(); } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_2.phpt b/ext/session/tests/bug60634_error_2.phpt index 4ca598b4e70c..ef0609569287 100644 --- a/ext/session/tests/bug60634_error_2.phpt +++ b/ext/session/tests/bug60634_error_2.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - return true; + echo "close: goodbye cruel world\n"; + return true; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - throw new Exception; + echo "write: goodbye cruel world\n"; + throw new Exception; } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_3.phpt b/ext/session/tests/bug60634_error_3.phpt index f97da00dce23..1909fc8ada45 100644 --- a/ext/session/tests/bug60634_error_3.phpt +++ b/ext/session/tests/bug60634_error_3.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - exit; + echo "close: goodbye cruel world\n"; + exit; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - undefined_function(); + echo "write: goodbye cruel world\n"; + undefined_function(); } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_4.phpt b/ext/session/tests/bug60634_error_4.phpt index ca8672e4f444..e3834f262c26 100644 --- a/ext/session/tests/bug60634_error_4.phpt +++ b/ext/session/tests/bug60634_error_4.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - exit; + echo "close: goodbye cruel world\n"; + exit; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - throw new Exception; + echo "write: goodbye cruel world\n"; + throw new Exception; } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_5.phpt b/ext/session/tests/bug60634_error_5.phpt index 5728d3a90c92..333c86c67fb8 100644 --- a/ext/session/tests/bug60634_error_5.phpt +++ b/ext/session/tests/bug60634_error_5.phpt @@ -16,16 +16,16 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - undefined_function(); + echo "close: goodbye cruel world\n"; + undefined_function(); } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - return true; + return true; } function destroy($id) { diff --git a/ext/session/tests/bug71162.phpt b/ext/session/tests/bug71162.phpt index 31d3370499be..b475ae608093 100644 --- a/ext/session/tests/bug71162.phpt +++ b/ext/session/tests/bug71162.phpt @@ -36,13 +36,13 @@ class MySessionHandler extends SessionHandler implements SessionUpdateTimestampH return TRUE; } - public function create_sid() { - return sha1(random_bytes(32)); - } + public function create_sid() { + return sha1(random_bytes(32)); + } - public function validateId($sid) { - return TRUE; - } + public function validateId($sid) { + return TRUE; + } public function updateTimestamp($sessid, $sessdata) { echo __FUNCTION__, PHP_EOL; diff --git a/ext/session/tests/bug71972.phpt b/ext/session/tests/bug71972.phpt index e4c5c6b6d394..1384cae21e33 100644 --- a/ext/session/tests/bug71972.phpt +++ b/ext/session/tests/bug71972.phpt @@ -13,13 +13,13 @@ $_SESSION['boogie'] = 1; $_SESSION['obj1'] = new stdClass(); for ( $x=2; $x < 20; $x++) { - cyclic_ref($x); + cyclic_ref($x); } function cyclic_ref($num) { - $_SESSION['obj'.$num] = new stdClass(); - $_SESSION['obj'.$num]->test = new stdClass();//NOTE: No bug if try commenting out this too. - $_SESSION['obj'.$num]->obj1 = $_SESSION['obj1']; + $_SESSION['obj'.$num] = new stdClass(); + $_SESSION['obj'.$num]->test = new stdClass();//NOTE: No bug if try commenting out this too. + $_SESSION['obj'.$num]->obj1 = $_SESSION['obj1']; } var_dump(session_decode(session_encode()) == $_SESSION); diff --git a/ext/session/tests/bug72562.phpt b/ext/session/tests/bug72562.phpt index b36cf6df255d..8421e8940a1f 100644 --- a/ext/session/tests/bug72562.phpt +++ b/ext/session/tests/bug72562.phpt @@ -27,12 +27,12 @@ var_dump($out_2); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/session/tests/save_handler_closures.inc b/ext/session/tests/save_handler_closures.inc index 50f33c10986f..acf72f00f644 100644 --- a/ext/session/tests/save_handler_closures.inc +++ b/ext/session/tests/save_handler_closures.inc @@ -3,7 +3,7 @@ require_once 'save_handler.inc'; foreach (array ('open', 'close', 'read', 'write', 'destroy', 'gc') as $fn) { - ${$fn.'_closure'} = function () use ($fn) { return call_user_func_array ($fn, func_get_args ()); }; + ${$fn.'_closure'} = function () use ($fn) { return call_user_func_array ($fn, func_get_args ()); }; } ?> diff --git a/ext/session/tests/session_decode_error2.phpt b/ext/session/tests/session_decode_error2.phpt index ff4e618a5ec1..20415c7a6308 100644 --- a/ext/session/tests/session_decode_error2.phpt +++ b/ext/session/tests/session_decode_error2.phpt @@ -18,7 +18,7 @@ $data = "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;"; var_dump(session_start()); for($index = 0; $index < strlen($data); $index++) { - if(session_status() != PHP_SESSION_ACTIVE) { session_start(); } + if(session_status() != PHP_SESSION_ACTIVE) { session_start(); } echo "\n-- Iteration $index --\n"; $encoded = substr($data, 0, $index); var_dump(session_decode($encoded)); diff --git a/ext/session/tests/session_regenerate_id_cookie.phpt b/ext/session/tests/session_regenerate_id_cookie.phpt index 79d99f337521..76667cdbcccb 100644 --- a/ext/session/tests/session_regenerate_id_cookie.phpt +++ b/ext/session/tests/session_regenerate_id_cookie.phpt @@ -32,16 +32,16 @@ file_put_contents($file, 'i; - echo 'Open ', session_id(), "\n"; - return parent::open($path, $name); - } - public function create_sid() { - // This method should be removed when 5.5 become unsupported. - ++$this->i; - echo 'Old Create SID ', session_id(), "\n"; - return parent::create_sid(); - } - public function read($key) { - ++$this->i; - echo 'Read ', session_id(), "\n"; - return parent::read($key); - } - public function write($key, $data) { - ++$this->i; - echo 'Write ', session_id(), "\n"; - return parent::write($key, $data); - } - public function close() { - ++$this->i; - echo 'Close ', session_id(), "\n"; - return parent::close(); - } - public function createSid() { - // User should use this rather than create_sid() - // If both create_sid() and createSid() exists, - // createSid() is used. - ++$this->i; - echo 'New Create ID ', session_id(), "\n"; - return parent::create_sid(); - } - public function validateId($key) { - ++$this->i; - echo 'Validate ID ', session_id(), "\n"; - return TRUE; - // User must implement their own method and - // cannot call parent as follows. - // return parent::validateSid($key); - } - public function updateTimestamp($key, $data) { - ++$this->i; - echo 'Update Timestamp ', session_id(), "\n"; - return parent::write($key, $data); - // User must implement their own method and - // cannot call parent as follows - // return parent::updateTimestamp($key, $data); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function create_sid() { + // This method should be removed when 5.5 become unsupported. + ++$this->i; + echo 'Old Create SID ', session_id(), "\n"; + return parent::create_sid(); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function write($key, $data) { + ++$this->i; + echo 'Write ', session_id(), "\n"; + return parent::write($key, $data); + } + public function close() { + ++$this->i; + echo 'Close ', session_id(), "\n"; + return parent::close(); + } + public function createSid() { + // User should use this rather than create_sid() + // If both create_sid() and createSid() exists, + // createSid() is used. + ++$this->i; + echo 'New Create ID ', session_id(), "\n"; + return parent::create_sid(); + } + public function validateId($key) { + ++$this->i; + echo 'Validate ID ', session_id(), "\n"; + return TRUE; + // User must implement their own method and + // cannot call parent as follows. + // return parent::validateSid($key); + } + public function updateTimestamp($key, $data) { + ++$this->i; + echo 'Update Timestamp ', session_id(), "\n"; + return parent::write($key, $data); + // User must implement their own method and + // cannot call parent as follows + // return parent::updateTimestamp($key, $data); + } } $oldHandler = ini_get('session.save_handler'); diff --git a/ext/session/tests/session_set_save_handler_class_002.phpt b/ext/session/tests/session_set_save_handler_class_002.phpt index 29b1d270c619..6343cfdc0eb5 100644 --- a/ext/session/tests/session_set_save_handler_class_002.phpt +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -19,46 +19,46 @@ ob_start(); echo "*** Testing session_set_save_handler() : full handler implementation ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - return true; - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + return true; + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } } $handler = new MySession2; session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); session_start(); $_SESSION['foo'] = "hello"; diff --git a/ext/session/tests/session_set_save_handler_class_003.phpt b/ext/session/tests/session_set_save_handler_class_003.phpt index ba0311b96b9c..b3aba7498923 100644 --- a/ext/session/tests/session_set_save_handler_class_003.phpt +++ b/ext/session/tests/session_set_save_handler_class_003.phpt @@ -19,22 +19,22 @@ ob_start(); echo "*** Testing session_set_save_handler() : inheritance ***\n"; class MySession3 extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - return parent::open($path, $name); - } - public function read($key) { - ++$this->i; - return parent::read($key); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + return parent::read($key); + } } class MySession4 extends MySession3 { - public function write($id, $data) { - $this->i = "hai"; - return parent::write($id, $data); - } + public function write($id, $data) { + $this->i = "hai"; + return parent::write($id, $data); + } } $handler = new MySession3; diff --git a/ext/session/tests/session_set_save_handler_class_005.phpt b/ext/session/tests/session_set_save_handler_class_005.phpt index bada7f52c5af..c6f8dfe62269 100644 --- a/ext/session/tests/session_set_save_handler_class_005.phpt +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -20,15 +20,15 @@ ob_start(); echo "*** Testing session_set_save_handler() : incomplete implementation ***\n"; class MySession6 extends SessionHandler { - public function open($path, $name) { - // don't call parent - return true; - } - - public function read($id) { - // should error because parent::open hasn't been called - return parent::read($id); - } + public function open($path, $name) { + // don't call parent + return true; + } + + public function read($id) { + // should error because parent::open hasn't been called + return parent::read($id); + } } $handler = new MySession6; diff --git a/ext/session/tests/session_set_save_handler_class_006.phpt b/ext/session/tests/session_set_save_handler_class_006.phpt index 3f86437207a1..5b7d3be0840d 100644 --- a/ext/session/tests/session_set_save_handler_class_006.phpt +++ b/ext/session/tests/session_set_save_handler_class_006.phpt @@ -19,19 +19,19 @@ ob_start(); echo "*** Testing session_set_save_handler() : using objects in close ***\n"; class MySession7_Foo { - public $state = 'ok'; - function __destruct() { - $this->state = 'destroyed'; - } + public $state = 'ok'; + function __destruct() { + $this->state = 'destroyed'; + } } class MySession7 extends SessionHandler { - public $foo; - public function close() { - var_dump($this->foo); - @var_dump($GLOBALS['bar']); - return parent::close(); - } + public $foo; + public function close() { + var_dump($this->foo); + @var_dump($GLOBALS['bar']); + return parent::close(); + } } $bar = new MySession7_Foo; diff --git a/ext/session/tests/session_set_save_handler_class_007.phpt b/ext/session/tests/session_set_save_handler_class_007.phpt index 0416a894c660..b2ad9eee3473 100644 --- a/ext/session/tests/session_set_save_handler_class_007.phpt +++ b/ext/session/tests/session_set_save_handler_class_007.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : manual shutdown, reopen ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - session_write_close(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_008.phpt b/ext/session/tests/session_set_save_handler_class_008.phpt index da9611a8c711..1d39fbd53521 100644 --- a/ext/session/tests/session_set_save_handler_class_008.phpt +++ b/ext/session/tests/session_set_save_handler_class_008.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : manual shutdown ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - session_write_close(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_009.phpt b/ext/session/tests/session_set_save_handler_class_009.phpt index d878450540e0..69695422516a 100644 --- a/ext/session/tests/session_set_save_handler_class_009.phpt +++ b/ext/session/tests/session_set_save_handler_class_009.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : implicit shutdown ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - $this->shutdown(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + $this->shutdown(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_010.phpt b/ext/session/tests/session_set_save_handler_class_010.phpt index 2424a08d68d0..8734f71f9fa3 100644 --- a/ext/session/tests/session_set_save_handler_class_010.phpt +++ b/ext/session/tests/session_set_save_handler_class_010.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : manual shutdown function ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - session_write_close(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_011.phpt b/ext/session/tests/session_set_save_handler_class_011.phpt index 05a84a359a63..396bdbc59f49 100644 --- a/ext/session/tests/session_set_save_handler_class_011.phpt +++ b/ext/session/tests/session_set_save_handler_class_011.phpt @@ -19,33 +19,33 @@ ob_start(); echo "*** Testing session_set_save_handler() : shutdown failure ***\n"; class MySession extends SessionHandler { - public $num; - public $destroyed = false; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - $this->destroyed = true; - } - public function write($id, $data) { - if ($this->destroyed) { - echo "(#$this->num) destroyed, cannot write\n"; - } else { - echo "(#$this->num) writing $id = $data\n"; - } - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - if ($this->destroyed) { - echo "(#$this->num) destroyed, cannot write\n"; - } else { - echo "(#$this->num) closing $id\n"; - } - return parent::close(); - } + public $num; + public $destroyed = false; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + $this->destroyed = true; + } + public function write($id, $data) { + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) writing $id = $data\n"; + } + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) closing $id\n"; + } + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_012.phpt b/ext/session/tests/session_set_save_handler_class_012.phpt index bbf125bc9a5d..f81207d2a751 100644 --- a/ext/session/tests/session_set_save_handler_class_012.phpt +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -20,19 +20,19 @@ ob_start(); echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***\n"; class MySession extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - echo 'Open ', session_id(), "\n"; - // This test was written for broken return value handling - // Mimmick what was actually being tested by returning true here - return (null === parent::open()); - } - public function read($key) { - ++$this->i; - echo 'Read ', session_id(), "\n"; - return parent::read($key); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + // This test was written for broken return value handling + // Mimmick what was actually being tested by returning true here + return (null === parent::open()); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } } $oldHandler = ini_get('session.save_handler'); diff --git a/ext/session/tests/session_set_save_handler_class_013.phpt b/ext/session/tests/session_set_save_handler_class_013.phpt index 79c732f30ce4..886d6440a7df 100644 --- a/ext/session/tests/session_set_save_handler_class_013.phpt +++ b/ext/session/tests/session_set_save_handler_class_013.phpt @@ -19,20 +19,20 @@ ob_start(); echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler close ***\n"; class MySession extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - echo 'Open ', session_id(), "\n"; - return parent::open($path, $name); - } - public function read($key) { - ++$this->i; - echo 'Read ', session_id(), "\n"; - return parent::read($key); - } - public function close() { - return parent::close(false); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function close() { + return parent::close(false); + } } $oldHandler = ini_get('session.save_handler'); diff --git a/ext/session/tests/session_set_save_handler_class_016.phpt b/ext/session/tests/session_set_save_handler_class_016.phpt index eadfead304bc..03bb8eaf957c 100644 --- a/ext/session/tests/session_set_save_handler_class_016.phpt +++ b/ext/session/tests/session_set_save_handler_class_016.phpt @@ -19,44 +19,44 @@ ob_start(); echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return parent::create_sid(); - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return parent::create_sid(); + } } $handler = new MySession2; diff --git a/ext/session/tests/session_set_save_handler_class_017.phpt b/ext/session/tests/session_set_save_handler_class_017.phpt index 456ea55dff31..563d86c01385 100644 --- a/ext/session/tests/session_set_save_handler_class_017.phpt +++ b/ext/session/tests/session_set_save_handler_class_017.phpt @@ -19,44 +19,44 @@ ob_start(); echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return pathinfo(__FILE__)['filename']; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } } $handler = new MySession2; diff --git a/ext/session/tests/session_set_save_handler_class_018.phpt b/ext/session/tests/session_set_save_handler_class_018.phpt index 7336b4ae88db..30d72b4708eb 100644 --- a/ext/session/tests/session_set_save_handler_class_018.phpt +++ b/ext/session/tests/session_set_save_handler_class_018.phpt @@ -19,48 +19,48 @@ ob_start(); echo "*** Testing session_set_save_handler() function: class with validate_sid ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return file_put_contents($this->path . $id, $data)===FALSE ? FALSE : TRUE ; - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return pathinfo(__FILE__)['filename']; - } - - public function validate_sid($id) { - return pathinfo(__FILE__)['filename']===$id; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data)===FALSE ? FALSE : TRUE ; + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } + + public function validate_sid($id) { + return pathinfo(__FILE__)['filename']===$id; + } } $handler = new MySession2; diff --git a/ext/session/tests/session_set_save_handler_iface_001.phpt b/ext/session/tests/session_set_save_handler_iface_001.phpt index 362ad90dd6b0..c1981c91b0da 100644 --- a/ext/session/tests/session_set_save_handler_iface_001.phpt +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -19,45 +19,45 @@ ob_start(); echo "*** Testing session_set_save_handler() function: interface ***\n"; class MySession2 implements SessionHandlerInterface { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } } $handler = new MySession2; session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); session_start(); $_SESSION['foo'] = "hello"; diff --git a/ext/session/tests/session_set_save_handler_iface_002.phpt b/ext/session/tests/session_set_save_handler_iface_002.phpt index cf01d8badb26..cd8f6af9d9b4 100644 --- a/ext/session/tests/session_set_save_handler_iface_002.phpt +++ b/ext/session/tests/session_set_save_handler_iface_002.phpt @@ -19,61 +19,61 @@ ob_start(); echo "*** Testing session_set_save_handler() function: interface wrong ***\n"; interface MySessionHandlerInterface { - public function open($path, $name); - public function close(); - public function read($id); - public function write($id, $data); - public function destroy($id); - public function gc($maxlifetime); + public function open($path, $name); + public function close(); + public function read($id); + public function write($id, $data); + public function destroy($id); + public function gc($maxlifetime); } class MySession2 implements MySessionHandlerInterface { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - echo "Unsupported session handler in use\n"; - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + echo "Unsupported session handler in use\n"; + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } } function good_write($id, $data) { - global $handler; - echo "good handler writing\n"; - return file_put_contents($handler->path . $id, $data); + global $handler; + echo "good handler writing\n"; + return file_put_contents($handler->path . $id, $data); } $handler = new MySession2; $ret = session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); + array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); var_dump($ret); try { diff --git a/ext/session/tests/session_set_save_handler_iface_003.phpt b/ext/session/tests/session_set_save_handler_iface_003.phpt index 40474cb72efc..61714e0bb3e4 100644 --- a/ext/session/tests/session_set_save_handler_iface_003.phpt +++ b/ext/session/tests/session_set_save_handler_iface_003.phpt @@ -19,45 +19,45 @@ ob_start(); echo "*** Testing session_set_save_handler() function: id interface ***\n"; class MySession2 implements SessionHandlerInterface, SessionIdInterface { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - // Empty $data = 0 = false - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return pathinfo(__FILE__)['filename']; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + // Empty $data = 0 = false + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } } $handler = new MySession2; diff --git a/ext/session/tests/session_set_save_handler_sid_001.phpt b/ext/session/tests/session_set_save_handler_sid_001.phpt index bd8c18424f06..d4097158ed8f 100644 --- a/ext/session/tests/session_set_save_handler_sid_001.phpt +++ b/ext/session/tests/session_set_save_handler_sid_001.phpt @@ -13,50 +13,50 @@ ob_start(); echo "*** Testing session_set_save_handler() function: create_sid ***\n"; class MySession2 { - public $path; + public $path; - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } - public function close() { - return true; - } + public function close() { + return true; + } - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } - public function write($id, $data) { - // Empty $data = 0 = false - return (bool)file_put_contents($this->path . $id, $data); - } + public function write($id, $data) { + // Empty $data = 0 = false + return (bool)file_put_contents($this->path . $id, $data); + } - public function destroy($id) { - @unlink($this->path . $id); - } + public function destroy($id) { + @unlink($this->path . $id); + } - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } - public function create_sid() { - return pathinfo(__FILE__)['filename']; - } + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } } $handler = new MySession2; session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); session_start(); $_SESSION['foo'] = "hello"; diff --git a/ext/session/tests/session_set_save_handler_sid_002.phpt b/ext/session/tests/session_set_save_handler_sid_002.phpt index 76ffb6399150..faa7663655fc 100644 --- a/ext/session/tests/session_set_save_handler_sid_002.phpt +++ b/ext/session/tests/session_set_save_handler_sid_002.phpt @@ -14,49 +14,49 @@ ob_start(); echo "*** Testing session_set_save_handler() function: create_sid ***\n"; class MySession2 { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return @file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return null; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return null; + } } $handler = new MySession2; session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); session_start(); $_SESSION['foo'] = "hello"; diff --git a/ext/session/tests/session_set_save_handler_variation4.phpt b/ext/session/tests/session_set_save_handler_variation4.phpt index bf74385839bf..abe3abbeb29c 100644 --- a/ext/session/tests/session_set_save_handler_variation4.phpt +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -23,9 +23,9 @@ ob_start(); echo "*** Testing session_set_save_handler() : variation ***\n"; function noisy_gc($maxlifetime) { - echo("GC [".$maxlifetime."]\n"); - echo gc($maxlifetime)." deleted\n"; - return true; + echo("GC [".$maxlifetime."]\n"); + echo gc($maxlifetime)." deleted\n"; + return true; } require_once "save_handler.inc"; diff --git a/ext/session/tests/session_set_save_handler_variation5.phpt b/ext/session/tests/session_set_save_handler_variation5.phpt index 23847aadf4e0..ad11729b94a3 100644 --- a/ext/session/tests/session_set_save_handler_variation5.phpt +++ b/ext/session/tests/session_set_save_handler_variation5.phpt @@ -22,9 +22,9 @@ ob_start(); */ function noisy_gc($maxlifetime) { - echo("GC [".$maxlifetime."]\n"); - echo gc($maxlifetime)." deleted\n"; - return true; + echo("GC [".$maxlifetime."]\n"); + echo gc($maxlifetime)." deleted\n"; + return true; } echo "*** Testing session_set_save_handler() : variation ***\n"; diff --git a/ext/session/tests/skipif.inc b/ext/session/tests/skipif.inc index e63f963c5c5d..c259d9eacaf0 100644 --- a/ext/session/tests/skipif.inc +++ b/ext/session/tests/skipif.inc @@ -9,17 +9,17 @@ if (!extension_loaded("session")) { } $save_path = ini_get("session.save_path"); if ($save_path) { - if (!file_exists($save_path)) { - die("skip Session save_path doesn't exist"); - } + if (!file_exists($save_path)) { + die("skip Session save_path doesn't exist"); + } - if ($save_path && !@is_writable($save_path)) { - if (($p = strpos($save_path, ';')) !== false) { - $save_path = substr($save_path, ++$p); - } - if (!@is_writable($save_path)) { - die("skip session.save_path $save_path is not writable\n"); - } - } + if ($save_path && !@is_writable($save_path)) { + if (($p = strpos($save_path, ';')) !== false) { + $save_path = substr($save_path, ++$p); + } + if (!@is_writable($save_path)) { + die("skip session.save_path $save_path is not writable\n"); + } + } } ?> diff --git a/ext/shmop/tests/001.phpt b/ext/shmop/tests/001.phpt index 471f82cbda58..48e722d2f0cb 100644 --- a/ext/shmop/tests/001.phpt +++ b/ext/shmop/tests/001.phpt @@ -8,73 +8,73 @@ shmop extension test ?> --FILE-- --EXPECTF-- shm open for create: ok diff --git a/ext/shmop/tests/002.phpt b/ext/shmop/tests/002.phpt index 12b1b6b95f46..c69c79391f36 100644 --- a/ext/shmop/tests/002.phpt +++ b/ext/shmop/tests/002.phpt @@ -13,39 +13,39 @@ edgarsandi - ?> --FILE-- --EXPECTF-- ## shmop_open function tests ## diff --git a/ext/simplexml/tests/000.phpt b/ext/simplexml/tests/000.phpt index f777c6727589..453865ef34cb 100644 --- a/ext/simplexml/tests/000.phpt +++ b/ext/simplexml/tests/000.phpt @@ -9,12 +9,12 @@ $sxe = simplexml_load_file(__DIR__.'/000.xml'); function test($what) { - global $sxe; - echo "===$what\n"; - eval("var_dump(isset(\$$what));"); - eval("var_dump((bool)\$$what);"); - eval("if (isset(\$$what)) var_dump(count(\$$what));"); - eval("var_dump(\$$what);"); + global $sxe; + echo "===$what\n"; + eval("var_dump(isset(\$$what));"); + eval("var_dump((bool)\$$what);"); + eval("if (isset(\$$what)) var_dump(count(\$$what));"); + eval("var_dump(\$$what);"); } test('sxe'); diff --git a/ext/simplexml/tests/006.phpt b/ext/simplexml/tests/006.phpt index 19df52c45071..5798e913c03e 100644 --- a/ext/simplexml/tests/006.phpt +++ b/ext/simplexml/tests/006.phpt @@ -34,29 +34,29 @@ EOF ); foreach($sxe as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } echo "===CLONE===\n"; foreach(clone $sxe as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } echo "===ELEMENT===\n"; foreach($sxe->elem11 as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } echo "===COMMENT===\n"; foreach($sxe->elem1 as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } ?> diff --git a/ext/simplexml/tests/009.phpt b/ext/simplexml/tests/009.phpt index 696580d49e71..4b2e685c3653 100644 --- a/ext/simplexml/tests/009.phpt +++ b/ext/simplexml/tests/009.phpt @@ -29,9 +29,9 @@ $sxe = simplexml_load_string(<<children() as $name=>$val) { - var_dump($name); - var_dump(get_class($val)); - var_dump(trim($val)); + var_dump($name); + var_dump(get_class($val)); + var_dump(trim($val)); } ?> --EXPECT-- diff --git a/ext/simplexml/tests/019.phpt b/ext/simplexml/tests/019.phpt index b2406e099122..47bb9aa5719d 100644 --- a/ext/simplexml/tests/019.phpt +++ b/ext/simplexml/tests/019.phpt @@ -34,29 +34,29 @@ EOF ); foreach($sxe->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } echo "===CLONE===\n"; foreach(clone $sxe->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } echo "===ELEMENT===\n"; foreach($sxe->elem11->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } echo "===COMMENT===\n"; foreach($sxe->elem1->children() as $name => $data) { - var_dump($name); - var_dump(trim($data)); + var_dump($name); + var_dump(trim($data)); } ?> diff --git a/ext/simplexml/tests/021.phpt b/ext/simplexml/tests/021.phpt index e1355fd5ed57..ac5a589e9b0f 100644 --- a/ext/simplexml/tests/021.phpt +++ b/ext/simplexml/tests/021.phpt @@ -8,10 +8,10 @@ SimpleXML: Element check $ok = 1; $doc = simplexml_load_string('foo'); if(!isset($doc->exists)) { - $ok *= 0; + $ok *= 0; } if(isset($doc->doesnotexist)) { - $ok *= 0; + $ok *= 0; } if ($ok) { print "Works\n"; diff --git a/ext/simplexml/tests/022.phpt b/ext/simplexml/tests/022.phpt index 58222e8a682f..de4663fd4184 100644 --- a/ext/simplexml/tests/022.phpt +++ b/ext/simplexml/tests/022.phpt @@ -21,8 +21,8 @@ var_dump($sxe->content->file); echo "===FOREACH===\n"; foreach($sxe->content->file as $file) { - var_dump($file); - var_dump($file['glob']); + var_dump($file); + var_dump($file['glob']); } ?> diff --git a/ext/simplexml/tests/024.phpt b/ext/simplexml/tests/024.phpt index 789b99a648ff..2c52ddbc91e4 100644 --- a/ext/simplexml/tests/024.phpt +++ b/ext/simplexml/tests/024.phpt @@ -18,10 +18,10 @@ $sxe = simplexml_load_string($xml); function test($xpath) { - global $sxe; + global $sxe; - echo "===$xpath===\n"; - var_dump($sxe->xpath($xpath)); + echo "===$xpath===\n"; + var_dump($sxe->xpath($xpath)); } test('elem/@attr2'); diff --git a/ext/simplexml/tests/029.phpt b/ext/simplexml/tests/029.phpt index 41d00d80d3c7..2b9193bc4ba4 100644 --- a/ext/simplexml/tests/029.phpt +++ b/ext/simplexml/tests/029.phpt @@ -20,9 +20,9 @@ $people = simplexml_load_string($xml); foreach($people as $person) { - var_dump((string)$person['name']); - var_dump(count($people)); - var_dump(count($person)); + var_dump((string)$person['name']); + var_dump(count($people)); + var_dump(count($person)); } ?> diff --git a/ext/simplexml/tests/030.phpt b/ext/simplexml/tests/030.phpt index 417c5a7f11cb..7bd8a034910a 100644 --- a/ext/simplexml/tests/030.phpt +++ b/ext/simplexml/tests/030.phpt @@ -5,7 +5,7 @@ SimpleXML: isset and unset by offset --FILE-- test test 2 diff --git a/ext/simplexml/tests/031.phpt b/ext/simplexml/tests/031.phpt index c26cad06377c..c370f9ad1883 100644 --- a/ext/simplexml/tests/031.phpt +++ b/ext/simplexml/tests/031.phpt @@ -5,7 +5,7 @@ SimpleXML: addChild and addAttribute --FILE-- test test 2 diff --git a/ext/simplexml/tests/SimpleXMLElement_addAttribute_basic.phpt b/ext/simplexml/tests/SimpleXMLElement_addAttribute_basic.phpt index 52f6222eea22..8c512c625224 100644 --- a/ext/simplexml/tests/SimpleXMLElement_addAttribute_basic.phpt +++ b/ext/simplexml/tests/SimpleXMLElement_addAttribute_basic.phpt @@ -4,11 +4,11 @@ SimpleXMLElement->addAttribute() --FILE-- addAttribute('type','novels'); + $simple = simplexml_load_file(__DIR__."/book.xml"); + $simple->addAttribute('type','novels'); - var_dump($simple->attributes()); - echo "Done"; + var_dump($simple->attributes()); + echo "Done"; ?> --EXPECT-- object(SimpleXMLElement)#2 (1) { diff --git a/ext/simplexml/tests/bug24392.phpt b/ext/simplexml/tests/bug24392.phpt index 08d73c630dcb..0a0c16b9a949 100644 --- a/ext/simplexml/tests/bug24392.phpt +++ b/ext/simplexml/tests/bug24392.phpt @@ -6,7 +6,7 @@ Bug #24392 (empty namespaces causing confusion) item as $item) { - echo $item->title . "\n"; + echo $item->title . "\n"; } ?> --EXPECT-- diff --git a/ext/simplexml/tests/bug37565.phpt b/ext/simplexml/tests/bug37565.phpt index 41ecbd3e27e8..53508dc9b6b4 100644 --- a/ext/simplexml/tests/bug37565.phpt +++ b/ext/simplexml/tests/bug37565.phpt @@ -6,7 +6,7 @@ Bug #37565 (Using reflection::export with simplexml causing a crash) ', 'Setting')); + Reflection::export(simplexml_load_string('', 'Setting')); } catch (Error $e) { - my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } try { - Reflection::export(simplexml_load_file('data:,', 'Setting')); + Reflection::export(simplexml_load_file('data:,', 'Setting')); } catch (Error $e) { - my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } ?> diff --git a/ext/simplexml/tests/bug38354.phpt b/ext/simplexml/tests/bug38354.phpt index c1147c5d09a2..9554280177ec 100644 --- a/ext/simplexml/tests/bug38354.phpt +++ b/ext/simplexml/tests/bug38354.phpt @@ -12,7 +12,7 @@ $xml = simplexml_load_string( ); foreach ($xml->xpath("//*") as $element) { - var_dump($element->asXML()); + var_dump($element->asXML()); } echo "Done\n"; diff --git a/ext/simplexml/tests/bug40451.phpt b/ext/simplexml/tests/bug40451.phpt index dfecc25d1fa3..7cb01c031f17 100644 --- a/ext/simplexml/tests/bug40451.phpt +++ b/ext/simplexml/tests/bug40451.phpt @@ -7,9 +7,9 @@ Bug #40451 (addAttribute() may crash when used with non-existent child node) $string = << - - host.server.com - + + host.server.com + XML; $xml = simplexml_load_string($string); diff --git a/ext/simplexml/tests/bug41861.phpt b/ext/simplexml/tests/bug41861.phpt index 50c780f9ab87..f87c06144943 100644 --- a/ext/simplexml/tests/bug41861.phpt +++ b/ext/simplexml/tests/bug41861.phpt @@ -6,11 +6,11 @@ Bug #41861 (getNamespaces() returns the namespaces of a node's siblings) - - - - - + + + + + '); $name = $xml->getName(); @@ -21,13 +21,13 @@ echo "root(non-recursive): '$name' -- namespaces: ", implode(', ', $namespaces), foreach (array(null, '#ns1', '#ns2', '#ns3') as $ns) { - foreach ($xml->children($ns) as $child) - { - $name = $child->getName(); - $namespaces = $child->getNamespaces(false); + foreach ($xml->children($ns) as $child) + { + $name = $child->getName(); + $namespaces = $child->getNamespaces(false); - echo "children($ns): '$name' -- namespaces: ", implode(', ', $namespaces), "\n"; - } + echo "children($ns): '$name' -- namespaces: ", implode(', ', $namespaces), "\n"; + } } ?> --EXPECT-- diff --git a/ext/simplexml/tests/bug51615.phpt b/ext/simplexml/tests/bug51615.phpt index b935414b80da..d5759b21fcc9 100644 --- a/ext/simplexml/tests/bug51615.phpt +++ b/ext/simplexml/tests/bug51615.phpt @@ -14,7 +14,7 @@ $html = simplexml_import_dom($dom); var_dump($html->body->span); foreach ($html->body->span as $obj) { - var_dump((string)$obj->title); + var_dump((string)$obj->title); } ?> diff --git a/ext/simplexml/tests/bug69169.phpt b/ext/simplexml/tests/bug69169.phpt index 08cf299290d9..ff0d0e9410eb 100644 --- a/ext/simplexml/tests/bug69169.phpt +++ b/ext/simplexml/tests/bug69169.phpt @@ -8,12 +8,12 @@ if (!extension_loaded("simplexml")) die("skip SimpleXML not available"); - - - - - - + + + + + + '; $b = str_replace(array("\n", "\r", "\t"), "", $a); $simple_xml = simplexml_load_string($b); diff --git a/ext/simplexml/tests/bug72588.phpt b/ext/simplexml/tests/bug72588.phpt index f32ec2510455..1f1769505470 100644 --- a/ext/simplexml/tests/bug72588.phpt +++ b/ext/simplexml/tests/bug72588.phpt @@ -13,16 +13,16 @@ $dummy = &$tpnb; $xmlStruct = << - - - - - - - - - - + + + + + + + + + + EOF; $tplxml = simplexml_load_string($xmlStruct); diff --git a/ext/simplexml/tests/profile02.phpt b/ext/simplexml/tests/profile02.phpt index f2e952bc36fa..1ec0894d3b44 100644 --- a/ext/simplexml/tests/profile02.phpt +++ b/ext/simplexml/tests/profile02.phpt @@ -12,7 +12,7 @@ $root = simplexml_load_string(' '); foreach ($root->child as $child) { - echo "$child "; + echo "$child "; } echo "\n---Done---\n"; ?> diff --git a/ext/simplexml/tests/profile12.phpt b/ext/simplexml/tests/profile12.phpt index e52dc5f3d163..973508d777c6 100644 --- a/ext/simplexml/tests/profile12.phpt +++ b/ext/simplexml/tests/profile12.phpt @@ -8,15 +8,15 @@ SimpleXML [profile]: Accessing namespaced root and non namespaced children $xml =<< - + EOF; diff --git a/ext/simplexml/tests/profile13.phpt b/ext/simplexml/tests/profile13.phpt index 2e692fbcd3f5..80aad0f4538a 100644 --- a/ext/simplexml/tests/profile13.phpt +++ b/ext/simplexml/tests/profile13.phpt @@ -8,15 +8,15 @@ SimpleXML [profile]: Accessing by namespace prefix $xml =<< - + EOF; diff --git a/ext/simplexml/tests/simplexml_import_dom.phpt b/ext/simplexml/tests/simplexml_import_dom.phpt index 02fbcdb4ddb3..82c80e81bc32 100644 --- a/ext/simplexml/tests/simplexml_import_dom.phpt +++ b/ext/simplexml/tests/simplexml_import_dom.phpt @@ -14,7 +14,7 @@ if(!$dom) { $s = simplexml_import_dom($dom); $books = $s->book; foreach ($books as $book) { - echo "{$book->title} was written by {$book->author}\n"; + echo "{$book->title} was written by {$book->author}\n"; } ?> --EXPECT-- diff --git a/ext/simplexml/tests/simplexml_load_file.phpt b/ext/simplexml/tests/simplexml_load_file.phpt index 50ee4e903315..80a2a09550bc 100644 --- a/ext/simplexml/tests/simplexml_load_file.phpt +++ b/ext/simplexml/tests/simplexml_load_file.phpt @@ -4,10 +4,10 @@ simplexml_load_file() --FILE-- --EXPECT-- object(SimpleXMLElement)#1 (1) { diff --git a/ext/simplexml/tests/sxe_002.phpt b/ext/simplexml/tests/sxe_002.phpt index eeff0ee21550..b3f1b242df58 100644 --- a/ext/simplexml/tests/sxe_002.phpt +++ b/ext/simplexml/tests/sxe_002.phpt @@ -38,9 +38,9 @@ EOF; $sxe = simplexml_load_string($xml, 'SimpleXMLIterator'); foreach(new RecursiveIteratorIterator($sxe, 1) as $name => $data) { - var_dump($name); - var_dump(get_class($data)); - var_dump(trim($data)); + var_dump($name); + var_dump(get_class($data)); + var_dump(trim($data)); } echo "===DUMP===\n"; diff --git a/ext/simplexml/tests/sxe_003.phpt b/ext/simplexml/tests/sxe_003.phpt index 36ad9b6dcbd2..37a4e554d253 100644 --- a/ext/simplexml/tests/sxe_003.phpt +++ b/ext/simplexml/tests/sxe_003.phpt @@ -38,22 +38,22 @@ EOF; $sxe = simplexml_load_string($xml, 'SimpleXMLIterator'); foreach($sxe->getChildren() as $name => $data) { - var_dump($name); - var_dump(get_class($data)); - var_dump(trim($data)); + var_dump($name); + var_dump(get_class($data)); + var_dump(trim($data)); } echo "===RESET===\n"; for ($sxe->rewind(); $sxe->valid(); $sxe->next()) { - var_dump($sxe->hasChildren()); - var_dump(trim($sxe->key())); - var_dump(trim($sxe->current())); - foreach($sxe->getChildren() as $name => $data) { - var_dump($name); - var_dump(get_class($data)); - var_dump(trim($data)); - } + var_dump($sxe->hasChildren()); + var_dump(trim($sxe->key())); + var_dump(trim($sxe->current())); + foreach($sxe->getChildren() as $name => $data) { + var_dump($name); + var_dump(get_class($data)); + var_dump(trim($data)); + } } ?> diff --git a/ext/simplexml/tests/sxe_004.phpt b/ext/simplexml/tests/sxe_004.phpt index 7f06b1918f23..5e103cba5bd1 100644 --- a/ext/simplexml/tests/sxe_004.phpt +++ b/ext/simplexml/tests/sxe_004.phpt @@ -37,49 +37,49 @@ EOF; class SXETest extends SimpleXMLIterator { - function rewind() - { - echo __METHOD__ . "\n"; - return parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - return parent::next(); - } - function hasChildren() - { - echo __METHOD__ . "\n"; - return parent::hasChildren(); - } - function getChildren() - { - echo __METHOD__ . "\n"; - return parent::getChildren(); - } + function rewind() + { + echo __METHOD__ . "\n"; + return parent::rewind(); + } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } + function next() + { + echo __METHOD__ . "\n"; + return parent::next(); + } + function hasChildren() + { + echo __METHOD__ . "\n"; + return parent::hasChildren(); + } + function getChildren() + { + echo __METHOD__ . "\n"; + return parent::getChildren(); + } } $sxe = new SXETest($xml); $rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST); foreach($rit as $data) { - var_dump(get_class($data)); - var_dump(trim($data)); + var_dump(get_class($data)); + var_dump(trim($data)); } ?> diff --git a/ext/simplexml/tests/sxe_005.phpt b/ext/simplexml/tests/sxe_005.phpt index e1714489d343..59fe1d2f9cf9 100644 --- a/ext/simplexml/tests/sxe_005.phpt +++ b/ext/simplexml/tests/sxe_005.phpt @@ -19,11 +19,11 @@ EOF; class SXETest extends SimpleXMLIterator { - function count() - { - echo __METHOD__ . "\n"; - return parent::count(); - } + function count() + { + echo __METHOD__ . "\n"; + return parent::count(); + } } $sxe = new SXETest($xml); diff --git a/ext/snmp/tests/bug60749.phpt b/ext/snmp/tests/bug60749.phpt index 1ada8102c40f..b12aa3761486 100644 --- a/ext/snmp/tests/bug60749.phpt +++ b/ext/snmp/tests/bug60749.phpt @@ -13,14 +13,14 @@ require_once(__DIR__.'/snmp_include.inc'); $hostname = "php.net"; $ip = gethostbyname($hostname); if (ip2long($ip) === FALSE) { - echo "Could not resolve $hostname properly!\n"; - exit(1); + echo "Could not resolve $hostname properly!\n"; + exit(1); } $port = 1161; $session = new SNMP(SNMP::VERSION_1, "$hostname:$port", $community, $timeout, $retries); $info = $session->info; if (strcmp($info["hostname"], "$ip:$port") !== 0) { - echo "'" . $info["hostname"] . "' != '$ip:$port'\n"; + echo "'" . $info["hostname"] . "' != '$ip:$port'\n"; } var_dump($session->close()); ?> diff --git a/ext/snmp/tests/skipif.inc b/ext/snmp/tests/skipif.inc index ac623c350d35..f3fe225e5dba 100644 --- a/ext/snmp/tests/skipif.inc +++ b/ext/snmp/tests/skipif.inc @@ -9,4 +9,4 @@ require_once (dirname(__FILE__).'/snmp_include.inc'); //string $object_id [, int $timeout [, int $retries ]] ) if (@snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout) === false) - die('skip NO SNMPD on this host or community invalid'); + die('skip NO SNMPD on this host or community invalid'); diff --git a/ext/snmp/tests/snmp-object-error.phpt b/ext/snmp/tests/snmp-object-error.phpt index 299a76350d98..606a8cf7b0cc 100644 --- a/ext/snmp/tests/snmp-object-error.phpt +++ b/ext/snmp/tests/snmp-object-error.phpt @@ -15,40 +15,40 @@ snmp_set_quick_print(false); snmp_set_valueretrieval(SNMP_VALUE_PLAIN); try { - var_dump(new SNMP(SNMP::VERSION_1, $hostname)); + var_dump(new SNMP(SNMP::VERSION_1, $hostname)); } catch (TypeError $e) { - print $e->getMessage() . "\n"; + print $e->getMessage() . "\n"; } try { - var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, '')); + var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, '')); } catch (TypeError $e) { - print $e->getMessage() . "\n"; + print $e->getMessage() . "\n"; } try { - var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, '')); + var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, '')); } catch (TypeError $e) { - print $e->getMessage() . "\n"; + print $e->getMessage() . "\n"; } try { - var_dump(new SNMP(7, $hostname, $community)); + var_dump(new SNMP(7, $hostname, $community)); } catch (Exception $e) { - print $e->getMessage() . "\n"; + print $e->getMessage() . "\n"; } echo "Exception handling\n"; $session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries); try { - var_dump($session->get('.1.3.6.1.2.1.1.1..0')); + var_dump($session->get('.1.3.6.1.2.1.1.1..0')); } catch (SNMPException $e) { - var_dump($e->getCode()); - var_dump($e->getMessage()); + var_dump($e->getCode()); + var_dump($e->getMessage()); } $session->exceptions_enabled = SNMP::ERRNO_ANY; try { - var_dump($session->get('.1.3.6.1.2.1.1.1..0')); + var_dump($session->get('.1.3.6.1.2.1.1.1..0')); } catch (SNMPException $e) { - var_dump($e->getCode()); - var_dump($e->getMessage()); + var_dump($e->getCode()); + var_dump($e->getMessage()); } var_dump($session->close()); diff --git a/ext/snmp/tests/snmp-object.phpt b/ext/snmp/tests/snmp-object.phpt index 4f22b452f09d..22a77947b1a1 100644 --- a/ext/snmp/tests/snmp-object.phpt +++ b/ext/snmp/tests/snmp-object.phpt @@ -35,7 +35,7 @@ $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries) $orig = array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.5.0'); $result = $session->get($orig, TRUE); foreach($orig as $oid){ - var_dump($result[$oid]); + var_dump($result[$oid]); } var_dump($session->close()); diff --git a/ext/snmp/tests/snmp3.phpt b/ext/snmp/tests/snmp3.phpt index 68c14d058f86..91f563df9049 100644 --- a/ext/snmp/tests/snmp3.phpt +++ b/ext/snmp/tests/snmp3.phpt @@ -20,13 +20,13 @@ echo "GET single: noAuthNoPriv\n"; var_dump(snmp3_get($hostname, $user_noauth, 'noAuthNoPriv', '', '', '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); foreach(array('MD5', 'SHA') as $signalg) { - echo "GET single: $signalg\n"; - var_dump(snmp3_get($hostname, $user_auth_prefix . $signalg, 'authNoPriv', $signalg, $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); + echo "GET single: $signalg\n"; + var_dump(snmp3_get($hostname, $user_auth_prefix . $signalg, 'authNoPriv', $signalg, $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); } foreach(array('AES', 'DES', 'AES128') as $chipher) { - echo "GET single: MD5/$chipher\n"; - var_dump(snmp3_get($hostname, $user_auth_prefix . 'MD5' . $chipher, 'authPriv', 'MD5', $auth_pass, $chipher, $priv_pass, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); + echo "GET single: MD5/$chipher\n"; + var_dump(snmp3_get($hostname, $user_auth_prefix . 'MD5' . $chipher, 'authPriv', 'MD5', $auth_pass, $chipher, $priv_pass, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); } $username = $user_auth_prefix . 'MD5'; echo "GET multiple\n"; diff --git a/ext/snmp/tests/snmp_include.inc b/ext/snmp/tests/snmp_include.inc index d14de3effe8c..b31384f7cf1e 100644 --- a/ext/snmp/tests/snmp_include.inc +++ b/ext/snmp/tests/snmp_include.inc @@ -18,9 +18,9 @@ $timeout = getenv('SNMP_TIMEOUT') ?: -1; $retries = getenv('SNMP_RETRIES') ?: 1; if (stristr(PHP_OS, "FreeBSD")) { - $mibdir = getenv('SNMP_MIBDIR') ?: "/usr/local/share/snmp/mibs"; + $mibdir = getenv('SNMP_MIBDIR') ?: "/usr/local/share/snmp/mibs"; } else { - $mibdir = getenv('SNMP_MIBDIR') ?: "/usr/share/snmp/mibs"; + $mibdir = getenv('SNMP_MIBDIR') ?: "/usr/share/snmp/mibs"; } diff --git a/ext/soap/tests/any.phpt b/ext/soap/tests/any.phpt index d84443b06f6e..af9696bf5172 100644 --- a/ext/soap/tests/any.phpt +++ b/ext/soap/tests/any.phpt @@ -17,15 +17,15 @@ class SOAPComplexType { $struct = new SOAPComplexType('arg',34,325.325); function echoAnyElement($x) { - global $g; + global $g; - $g = $x; - $struct = $x->inputAny->any["SOAPComplexType"]; - if ($struct instanceof SOAPComplexType) { - return array("return" => array("any" => array("SOAPComplexType"=>new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPComplexType", "http://soapinterop.org/xsd", "SOAPComplexType", "http://soapinterop.org/")))); - } else { - return "?"; - } + $g = $x; + $struct = $x->inputAny->any["SOAPComplexType"]; + if ($struct instanceof SOAPComplexType) { + return array("return" => array("any" => array("SOAPComplexType"=>new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPComplexType", "http://soapinterop.org/xsd", "SOAPComplexType", "http://soapinterop.org/")))); + } else { + return "?"; + } } class TestSoapClient extends SoapClient { diff --git a/ext/soap/tests/bug46760.phpt b/ext/soap/tests/bug46760.phpt index 95cb58867f75..f591e1b3d6af 100644 --- a/ext/soap/tests/bug46760.phpt +++ b/ext/soap/tests/bug46760.phpt @@ -8,9 +8,9 @@ Bug #46760 (SoapClient doRequest fails when proxy is used) $client = new SoapClient(null, array('proxy_host' => "localhost", 'proxy_port' => '8080', 'login' => "user", - 'password' => "test", - 'uri' => 'mo:http://www.w3.org/', - 'location' => 'http://some.url')); + 'password' => "test", + 'uri' => 'mo:http://www.w3.org/', + 'location' => 'http://some.url')); var_dump($client->_proxy_port); ?> diff --git a/ext/soap/tests/bug48557.phpt b/ext/soap/tests/bug48557.phpt index aa20c14610f2..e4c4e8934237 100644 --- a/ext/soap/tests/bug48557.phpt +++ b/ext/soap/tests/bug48557.phpt @@ -9,7 +9,7 @@ ini_set('display_errors', 1); ini_set("soap.wsdl_cache_enabled", 0); function test($map) { - var_dump($map, $map[1], $map[2]);die; + var_dump($map, $map[1], $map[2]);die; } $y = new SoapServer(__DIR__ . '/bug48557.wsdl'); @@ -17,36 +17,36 @@ $y->addfunction("test"); $request = << - - - - - 1 - 123 - - - -1000 - 123 - - - 2 - 123.5 - - - -2000 - 123.5 - - - 011 - 123.5 - - - 012 - 123.5 - - - - + + + + + 1 + 123 + + + -1000 + 123 + + + 2 + 123.5 + + + -2000 + 123.5 + + + 011 + 123.5 + + + 012 + 123.5 + + + + XML; diff --git a/ext/soap/tests/bug69137.phpt b/ext/soap/tests/bug69137.phpt index 9160b91c2505..d34ba13e3e03 100644 --- a/ext/soap/tests/bug69137.phpt +++ b/ext/soap/tests/bug69137.phpt @@ -26,9 +26,9 @@ $client = new SoapClient($testServiceWsdl); unset($client); $parameters = [ - 'proxy_host' => $proxyHost, - 'proxy_port' => $proxyPort, - 'trace' => 1, + 'proxy_host' => $proxyHost, + 'proxy_port' => $proxyPort, + 'trace' => 1, ]; $client = new SoapClient($testServiceWsdl, $parameters); @@ -39,7 +39,7 @@ $lookup->ipAddress = '72.52.91.14'; $result = $client->ResolveIP($lookup); if ($result && is_object($result) && $result->ResolveIPResult && is_object($result->ResolveIPResult)) { - print "successful lookup"; + print "successful lookup"; } ?> --EXPECT-- diff --git a/ext/soap/tests/bug70388.phpt b/ext/soap/tests/bug70388.phpt index 6c0d1081ded8..fc67de1142af 100644 --- a/ext/soap/tests/bug70388.phpt +++ b/ext/soap/tests/bug70388.phpt @@ -6,10 +6,10 @@ Bug #70388 (SOAP serialize_function_call() type confusion / RCE) notexisting()); + var_dump($dummy->notexisting()); } catch(Exception $e) { - var_dump($e->getMessage()); - var_dump(get_class($e)); + var_dump($e->getMessage()); + var_dump(get_class($e)); } ?> --EXPECTF-- diff --git a/ext/soap/tests/bug70875.phpt b/ext/soap/tests/bug70875.phpt index 6f10462bfc35..86a16697ce33 100644 --- a/ext/soap/tests/bug70875.phpt +++ b/ext/soap/tests/bug70875.phpt @@ -9,19 +9,19 @@ soap.wsdl_cache_enabled=0 class bug70875 extends SOAPClient { - public function __doRequest($request, $location, $action, $version, $one_way = 0) - { - die("no SIGSEGV"); - } + public function __doRequest($request, $location, $action, $version, $one_way = 0) + { + die("no SIGSEGV"); + } } $c = new bug70875(__DIR__.'/bug70875.wsdl', [ - 'trace' => 1, - 'classmap' => [ - 'TestService' => 'TestService', - 'TestServiceRQ' => 'TestServiceRQ', - 'RqHeader' => 'RqHeader', - ], + 'trace' => 1, + 'classmap' => [ + 'TestService' => 'TestService', + 'TestServiceRQ' => 'TestServiceRQ', + 'RqHeader' => 'RqHeader', + ], ]); @@ -32,7 +32,7 @@ class TestService class TestServiceRQ { - public $RqHeader; + public $RqHeader; } class RqHeader diff --git a/ext/soap/tests/bug71610.phpt b/ext/soap/tests/bug71610.phpt index f00d57700a4d..f88124d50c0a 100644 --- a/ext/soap/tests/bug71610.phpt +++ b/ext/soap/tests/bug71610.phpt @@ -11,7 +11,7 @@ $exploit = unserialize('O:10:"SoapClient":3:{s:3:"uri";s:1:"a";s:8:"location";s: try { $exploit->blahblah(); } catch(SoapFault $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/soap/tests/bug73037.phpt b/ext/soap/tests/bug73037.phpt index dd5b5aa13b49..d835f2a2805f 100644 --- a/ext/soap/tests/bug73037.phpt +++ b/ext/soap/tests/bug73037.phpt @@ -20,46 +20,46 @@ include __DIR__ . "/../../../sapi/cli/tests/php_cli_server.inc"; function get_data($max) { - $piece = " - Empire Burlesque - Bob Dylan - USA - Columbia - 10.90 - 1985 - "; - - $begin = ''; - $end = ''; - - $min = strlen($begin) + strlen($piece) + strlen($end); - $max = $max < $min ? $min : $max; - - $data = $begin; - $data .= $piece; - while (strlen($data) + strlen($end) < $max) { - /* Randomize a bit, taking gzip in account. */ - $tmp = str_replace( - array( - "Empire Burlesque", - "Bob Dylan", - ), - array( - md5(uniqid()), - sha1(uniqid()), - ), - $piece - ); - - if (strlen($begin) + strlen($tmp) + strlen($end) > $max) { - break; - } - - $data .= $tmp; - } - $data .= $end; - - return $data; + $piece = " + Empire Burlesque + Bob Dylan + USA + Columbia + 10.90 + 1985 + "; + + $begin = ''; + $end = ''; + + $min = strlen($begin) + strlen($piece) + strlen($end); + $max = $max < $min ? $min : $max; + + $data = $begin; + $data .= $piece; + while (strlen($data) + strlen($end) < $max) { + /* Randomize a bit, taking gzip in account. */ + $tmp = str_replace( + array( + "Empire Burlesque", + "Bob Dylan", + ), + array( + md5(uniqid()), + sha1(uniqid()), + ), + $piece + ); + + if (strlen($begin) + strlen($tmp) + strlen($end) > $max) { + break; + } + + $data .= $tmp; + } + $data .= $end; + + return $data; } $router = "bug73037_server.php"; @@ -74,19 +74,19 @@ PHP; php_cli_server_start($code, $router, $args); foreach (array(1024-1, 1024*8-3, 1024*9+1, 1024*16-1, 1024*32-5, 1024*64+3, 1024*128-7) as $k => $i) { - echo "Iteration $k\n\n"; + echo "Iteration $k\n\n"; - /* with and without compression */ - foreach (array(false, true) as $b) { - $data = get_data($i); - if ($b) { - $data = gzencode($data); - } - $len = strlen($data); + /* with and without compression */ + foreach (array(false, true) as $b) { + $data = get_data($i); + if ($b) { + $data = gzencode($data); + } + $len = strlen($data); - //echo "len=$len\n"; + //echo "len=$len\n"; - $hdrs = <<"); - if (false === $pos) { - echo $out; - goto cleanup; - } - $pos0 = $pos + strlen(""); - $pos = strpos($out, ""); - if (false === $pos) { - echo $out; - goto cleanup; - } - $len = $pos - $pos0; - echo substr($out, $pos0, $len); - } + if ($b) { + $hdrs .="\nContent-Encoding: gzip"; + } + //echo "Headers sent:\n$hdrs\n\n"; + $fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT, $errno, $errstr, 5); + if (!$fp) { + die("connect failed"); + } + + if(fwrite($fp, "$hdrs\n\n$data")) { + $out = ""; + while (!feof($fp)) { + $out .= fread($fp, 1024); + } + + $pos = strpos($out, ""); + if (false === $pos) { + echo $out; + goto cleanup; + } + $pos0 = $pos + strlen(""); + $pos = strpos($out, ""); + if (false === $pos) { + echo $out; + goto cleanup; + } + $len = $pos - $pos0; + echo substr($out, $pos0, $len); + } cleanup: - fclose($fp); + fclose($fp); - echo "\n\n"; - } + echo "\n\n"; + } } ?> diff --git a/ext/soap/tests/bug77088.phpt b/ext/soap/tests/bug77088.phpt index e6f5e7582ead..17945e136fd7 100644 --- a/ext/soap/tests/bug77088.phpt +++ b/ext/soap/tests/bug77088.phpt @@ -11,7 +11,7 @@ try { $options = NULL; $sClient = new SoapClient("test.wsdl", $options); -} +} catch(TypeError $e) { var_dump($e); diff --git a/ext/soap/tests/bug77410.phpt b/ext/soap/tests/bug77410.phpt index 2b7410252342..4c36e6e9da49 100644 --- a/ext/soap/tests/bug77410.phpt +++ b/ext/soap/tests/bug77410.phpt @@ -11,7 +11,7 @@ $client = new class(__DIR__ . '/bug77410.wsdl', [ ]) extends SoapClient { public function __doRequest($request, $location, $action, $version, $one_way = 0) { echo $request, "\n"; - return ''; + return ''; } }; diff --git a/ext/soap/tests/bugs/bug28751.phpt b/ext/soap/tests/bugs/bug28751.phpt index 88187eb1097a..4b64b62a0643 100644 --- a/ext/soap/tests/bugs/bug28751.phpt +++ b/ext/soap/tests/bugs/bug28751.phpt @@ -5,11 +5,11 @@ Bug #28751 (SoapServer does not call _autoload()) --FILE-- "http://testuri.org")); diff --git a/ext/soap/tests/bugs/bug29795.phpt b/ext/soap/tests/bugs/bug29795.phpt index fce064ef4350..38d4da3a8d07 100644 --- a/ext/soap/tests/bugs/bug29795.phpt +++ b/ext/soap/tests/bugs/bug29795.phpt @@ -14,9 +14,9 @@ class LocalSoapClient extends SoapClient { function __doRequest($request, $location, $action, $version, $one_way = 0) { return <<3995USD EOF; } diff --git a/ext/soap/tests/bugs/bug30045.phpt b/ext/soap/tests/bugs/bug30045.phpt index 21889c2fd15b..63fbadc639cb 100644 --- a/ext/soap/tests/bugs/bug30045.phpt +++ b/ext/soap/tests/bugs/bug30045.phpt @@ -42,12 +42,12 @@ $soap = new LocalSoapClient(NULL, array("uri"=>"http://test-uri", "location"=>"t function test($type, $num) { global $soap; try { - printf(" %0.0f\n ", $num); - $ret = $soap->foo($type, new SoapVar($num, $type)); - printf(" %0.0f\n", $ret); - } catch (SoapFault $ex) { - var_dump($ex); - } + printf(" %0.0f\n ", $num); + $ret = $soap->foo($type, new SoapVar($num, $type)); + printf(" %0.0f\n", $ret); + } catch (SoapFault $ex) { + var_dump($ex); + } } /* echo "byte\n"; diff --git a/ext/soap/tests/bugs/bug30106.phpt b/ext/soap/tests/bugs/bug30106.phpt index b02b1bded203..96709d6aa3b2 100644 --- a/ext/soap/tests/bugs/bug30106.phpt +++ b/ext/soap/tests/bugs/bug30106.phpt @@ -7,25 +7,25 @@ Bug #30106 (SOAP cannot not parse 'ref' element. Causes Uncaught SoapFault excep ini_set("soap.wsdl_cache_enabled", 0); function getContinentList() { - return array("getContinentListResult"=>array( - "schema"=>"", - "any"=>"Hello World!Bye World!")); + return array("getContinentListResult"=>array( + "schema"=>"", + "any"=>"Hello World!Bye World!")); } class LocalSoapClient extends SoapClient { function __construct($wsdl, $options=array()) { parent::__construct($wsdl, $options); $this->server = new SoapServer($wsdl, $options); - $this->server->addFunction("getContinentList"); + $this->server->addFunction("getContinentList"); } function __doRequest($request, $location, $action, $version, $one_way = 0) { - echo $request; + echo $request; ob_start(); $this->server->handle($request); $response = ob_get_contents(); ob_end_clean(); - echo $response; + echo $response; return $response; } } diff --git a/ext/soap/tests/bugs/bug30799.phpt b/ext/soap/tests/bugs/bug30799.phpt index 92fd40f45204..81079efbb72f 100644 --- a/ext/soap/tests/bugs/bug30799.phpt +++ b/ext/soap/tests/bugs/bug30799.phpt @@ -5,9 +5,9 @@ Bug #30799 (SoapServer doesn't handle private or protected properties) --FILE-- + xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" + xmlns:tns="http://spock/kunta/kunta" + xmlns:types="http://spock/kunta/kunta/encodedTypes" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - - XXX - TASKTEST - - + + XXX + TASKTEST + + - - - + + + - - ABCabc123 - 123456 - + + ABCabc123 + 123456 + diff --git a/ext/soap/tests/bugs/bug31422.phpt b/ext/soap/tests/bugs/bug31422.phpt index 152781a4ecf9..c653d5e2f384 100644 --- a/ext/soap/tests/bugs/bug31422.phpt +++ b/ext/soap/tests/bugs/bug31422.phpt @@ -10,8 +10,8 @@ error_log= --FILE-- server = new SoapServer($wsdl, $options); - $this->server->addFunction("Test"); + $this->server->addFunction("Test"); } function __doRequest($request, $location, $action, $version, $one_way = 0) { - echo "$location\n"; + echo "$location\n"; ob_start(); $this->server->handle($request); $response = ob_get_contents(); diff --git a/ext/soap/tests/bugs/bug32776.phpt b/ext/soap/tests/bugs/bug32776.phpt index 316b0e15ed53..978dce877d60 100644 --- a/ext/soap/tests/bugs/bug32776.phpt +++ b/ext/soap/tests/bugs/bug32776.phpt @@ -10,8 +10,8 @@ soap.wsdl_cache_enabled=0 $d = null; function test($x) { - global $d; - $d = $x; + global $d; + $d = $x; } class LocalSoapClient extends SoapClient { diff --git a/ext/soap/tests/bugs/bug32941.phpt b/ext/soap/tests/bugs/bug32941.phpt index cbab7008d71d..59bd06992b2a 100644 --- a/ext/soap/tests/bugs/bug32941.phpt +++ b/ext/soap/tests/bugs/bug32941.phpt @@ -6,28 +6,28 @@ Bug #32941 (Sending structured exception kills a php) - - - soapenv:Server.userException - service.EchoServiceException - - - 105 - string param - - steckovic - - - + + + soapenv:Server.userException + service.EchoServiceException + + + 105 + string param + + steckovic + + + EOF; - } + } } ini_set("soap.wsdl_cache_enabled", 1); diff --git a/ext/soap/tests/bugs/bug34449.phpt b/ext/soap/tests/bugs/bug34449.phpt index f5766e29bc99..f4aa222477cd 100644 --- a/ext/soap/tests/bugs/bug34449.phpt +++ b/ext/soap/tests/bugs/bug34449.phpt @@ -6,8 +6,8 @@ Bug #34449 (ext/soap: XSD_ANYXML functionality not exposed) faultstring."\n"; - echo "ok\n"; + echo get_class($e)."\n"; + echo $e->faultstring."\n"; + echo "ok\n"; } catch (Exception $e) { - echo get_class($e)."\n"; + echo get_class($e)."\n"; } ?> --EXPECTF-- diff --git a/ext/soap/tests/bugs/bug35142.phpt b/ext/soap/tests/bugs/bug35142.phpt index f10885767c56..840dc8e9a8a8 100644 --- a/ext/soap/tests/bugs/bug35142.phpt +++ b/ext/soap/tests/bugs/bug35142.phpt @@ -11,8 +11,8 @@ $timestamp = "2005-11-08T11:22:07+03:00"; $wsdl = __DIR__."/bug35142.wsdl"; function PostEvents($x) { - var_dump($x); - exit(); + var_dump($x); + exit(); return $x; } @@ -25,7 +25,7 @@ class TestSoapClient extends SoapClient { } function __doRequest($request, $location, $action, $version, $one_way = 0) { - echo "$request\n"; + echo "$request\n"; $this->server->handle($request); return $response; } @@ -33,10 +33,10 @@ class TestSoapClient extends SoapClient { } $soapClient = new TestSoapClient($wsdl, - array('trace' => 1, 'exceptions' => 0, - 'classmap' => array('logOnEvent' => 'LogOnEvent', - 'logOffEvent' => 'LogOffEvent', - 'events' => 'IVREvents'))); + array('trace' => 1, 'exceptions' => 0, + 'classmap' => array('logOnEvent' => 'LogOnEvent', + 'logOffEvent' => 'LogOffEvent', + 'events' => 'IVREvents'))); $logOnEvent = new LogOnEvent(34567, $timestamp); $logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked"); diff --git a/ext/soap/tests/bugs/bug35273.phpt b/ext/soap/tests/bugs/bug35273.phpt index f04dc6864680..72c44adbb325 100644 --- a/ext/soap/tests/bugs/bug35273.phpt +++ b/ext/soap/tests/bugs/bug35273.phpt @@ -8,9 +8,9 @@ soap.wsdl_cache_enabled=0 server->handle($request); return $response; } @@ -33,11 +33,11 @@ class TestSoapClient extends SoapClient { } $soapClient = new TestSoapClient($wsdl, - array('trace' => 1, 'exceptions' => 0, - 'classmap' => array('logOnEvent' => 'LogOnEvent', - 'logOffEvent' => 'LogOffEvent', - 'events' => 'IVREvents'), - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); + array('trace' => 1, 'exceptions' => 0, + 'classmap' => array('logOnEvent' => 'LogOnEvent', + 'logOffEvent' => 'LogOffEvent', + 'events' => 'IVREvents'), + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); $logOnEvent = new LogOnEvent(34567, $timestamp); $logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked"); diff --git a/ext/soap/tests/bugs/bug36575.phpt b/ext/soap/tests/bugs/bug36575.phpt index 8e5f469546c3..dd5a5d99f1fd 100644 --- a/ext/soap/tests/bugs/bug36575.phpt +++ b/ext/soap/tests/bugs/bug36575.phpt @@ -7,24 +7,24 @@ soap.wsdl_cache_enabled=0 --FILE-- var1 = $a1->var1; - $a3->var2 = "var two"; - $a3->var3 = "var three"; - return $a3; + $a3 = new CT_A3(); + $a3->var1 = $a1->var1; + $a3->var2 = "var two"; + $a3->var3 = "var three"; + return $a3; } $classMap = array("A1" => "CT_A1", "A2" => "CT_A2", "A3" => "CT_A3"); diff --git a/ext/soap/tests/bugs/bug36999.phpt b/ext/soap/tests/bugs/bug36999.phpt index 443e90418fb3..c9d03f57bddf 100644 --- a/ext/soap/tests/bugs/bug36999.phpt +++ b/ext/soap/tests/bugs/bug36999.phpt @@ -36,12 +36,12 @@ $soap = new LocalSoapClient(__DIR__."/bug36999.wsdl"); function test($num) { global $soap; try { - printf("%s %0.0f\n", gettype($num), $num); - $ret = $soap->echoLong($num); - printf("%s %0.0f\n", gettype($ret), $ret); - } catch (SoapFault $ex) { - var_dump($ex); - } + printf("%s %0.0f\n", gettype($num), $num); + $ret = $soap->echoLong($num); + printf("%s %0.0f\n", gettype($ret), $ret); + } catch (SoapFault $ex) { + var_dump($ex); + } } test(3706790240); ?> diff --git a/ext/soap/tests/bugs/bug37083.phpt b/ext/soap/tests/bugs/bug37083.phpt index cfd698e4bef3..89b808eaa133 100644 --- a/ext/soap/tests/bugs/bug37083.phpt +++ b/ext/soap/tests/bugs/bug37083.phpt @@ -7,8 +7,8 @@ soap.wsdl_cache=3 --FILE-- @@ -38,19 +38,19 @@ class TestSoapClient extends SoapClient { maxDateTime2038-12-31T22:59:59.000ZminDateTime2004-11-01T16:58:00.000ZminLongitude108.11maxLongitude113.383maxLatitude-31.666minLatitude-35.075 EOF; - } + } } for ($i = 0; $i < 10; $i++) { - $ws=new TestSoapClient(__DIR__.'/bug37083.wsdl', + $ws=new TestSoapClient(__DIR__.'/bug37083.wsdl', array('encoding'=>'ISO-8859-1', 'cache_wsdl'=>WSDL_CACHE_BOTH)); - $search=new stdClass(); - $search->queryString='argo'; - $search->ranges[]=$r=new stdClass(); - $r->field='maxDateTime'; - $r->min='2003-04-01'; - $search->index='all'; - $res=$ws->search($search,0,10); + $search=new stdClass(); + $search->queryString='argo'; + $search->ranges[]=$r=new stdClass(); + $r->field='maxDateTime'; + $r->min='2003-04-01'; + $search->index='all'; + $res=$ws->search($search,0,10); } echo "ok\n"; ?> diff --git a/ext/soap/tests/bugs/bug38004.phpt b/ext/soap/tests/bugs/bug38004.phpt index 43d3e86d02da..81b8ffc50351 100644 --- a/ext/soap/tests/bugs/bug38004.phpt +++ b/ext/soap/tests/bugs/bug38004.phpt @@ -7,9 +7,9 @@ soap.wsdl_cache_enabled=0 --FILE-- strA."\n".$param->strB."\n"; - return $g; + global $g; + $g = $param->strA."\n".$param->strB."\n"; + return $g; } class TestSoapClient extends SoapClient { diff --git a/ext/soap/tests/bugs/bug38005.phpt b/ext/soap/tests/bugs/bug38005.phpt index 655786727771..6219141ab97b 100644 --- a/ext/soap/tests/bugs/bug38005.phpt +++ b/ext/soap/tests/bugs/bug38005.phpt @@ -7,7 +7,7 @@ soap.wsdl_cache_enabled=0 --FILE-- 'ISO-8859-1', - 'uri' => "test://", - 'location' => "test://", - 'soap_version'=>SOAP_1_2, - 'trace'=>1, - 'exceptions'=>0)); + 'uri' => "test://", + 'location' => "test://", + 'soap_version'=>SOAP_1_2, + 'trace'=>1, + 'exceptions'=>0)); $res = $client->Test(); echo($res->faultstring."\n"); echo($client->__getLastResponse()); diff --git a/ext/soap/tests/bugs/bug38055.phpt b/ext/soap/tests/bugs/bug38055.phpt index 7b5ed49a2708..df97e1034d44 100644 --- a/ext/soap/tests/bugs/bug38055.phpt +++ b/ext/soap/tests/bugs/bug38055.phpt @@ -7,10 +7,10 @@ soap.wsdl_cache_enabled=0 --FILE-- boolA; - $g2 = $param->boolB; - return 1; + global $g1, $g2; + $g1 = $param->boolA; + $g2 = $param->boolB; + return 1; } class TestSoapClient extends SoapClient { diff --git a/ext/soap/tests/bugs/bug38067.phpt b/ext/soap/tests/bugs/bug38067.phpt index 7664135de3db..0b935f30c247 100644 --- a/ext/soap/tests/bugs/bug38067.phpt +++ b/ext/soap/tests/bugs/bug38067.phpt @@ -7,9 +7,9 @@ soap.wsdl_cache_enabled=0 --FILE-- str; - return $g; + global $g; + $g = $param->str; + return $g; } class TestSoapClient extends SoapClient { @@ -29,7 +29,7 @@ class TestSoapClient extends SoapClient { } $client = new TestSoapClient(__DIR__.'/bug38067.wsdl', - array('encoding' => 'ISO-8859-1')); + array('encoding' => 'ISO-8859-1')); $str = 'test: Ä'; $res = $client->Test(array('str'=>$str)); echo $str."\n"; diff --git a/ext/soap/tests/bugs/bug41004.phpt b/ext/soap/tests/bugs/bug41004.phpt index c38bf0d62b8c..442e147bbc66 100644 --- a/ext/soap/tests/bugs/bug41004.phpt +++ b/ext/soap/tests/bugs/bug41004.phpt @@ -7,17 +7,17 @@ Bug #41004 (minOccurs="0" and null class member variable) ini_set('soap.wsdl_cache_enabled', false); class EchoBean{ - public $mandatoryElement; - public $optionalElement; + public $mandatoryElement; + public $optionalElement; } class EchoRequest{ - public $in; + public $in; } class EchoResponse{ - public $out; + public $out; } $wsdl = __DIR__."/bug41004.wsdl"; diff --git a/ext/soap/tests/bugs/bug41566.phpt b/ext/soap/tests/bugs/bug41566.phpt index 03ecdde043d1..557c61780abb 100644 --- a/ext/soap/tests/bugs/bug41566.phpt +++ b/ext/soap/tests/bugs/bug41566.phpt @@ -44,8 +44,8 @@ echo "ok\n"; $HTTP_RAW_POST_DATA = << - diff --git a/ext/soap/tests/bugs/bug42086.phpt b/ext/soap/tests/bugs/bug42086.phpt index bdaf55ac8364..0d4d30486fc2 100644 --- a/ext/soap/tests/bugs/bug42086.phpt +++ b/ext/soap/tests/bugs/bug42086.phpt @@ -12,17 +12,17 @@ $request = <<param = "firstFunctionWithoutParam"; - return $ret; + $ret = new firstFunctionWithoutParamResponse(); + $ret->param = "firstFunctionWithoutParam"; + return $ret; } $server = new SoapServer(__DIR__.'/bug42086.wsdl', - array('features'=>SOAP_SINGLE_ELEMENT_ARRAYS)); + array('features'=>SOAP_SINGLE_ELEMENT_ARRAYS)); $server->addFunction('firstFunctionWithoutParam'); $server->handle($request); ?> diff --git a/ext/soap/tests/bugs/bug42151.phpt b/ext/soap/tests/bugs/bug42151.phpt index ee53e6d525dc..f945a8753e5f 100644 --- a/ext/soap/tests/bugs/bug42151.phpt +++ b/ext/soap/tests/bugs/bug42151.phpt @@ -5,23 +5,23 @@ Bug #42151 (__destruct functions not called after catching a SoapFault exception --FILE-- getMessage() . "\n"; + echo $e->getMessage() . "\n"; } echo "ok\n"; ?> diff --git a/ext/soap/tests/bugs/bug42183.phpt b/ext/soap/tests/bugs/bug42183.phpt index 043487c9645e..0fed7f1d548a 100644 --- a/ext/soap/tests/bugs/bug42183.phpt +++ b/ext/soap/tests/bugs/bug42183.phpt @@ -13,11 +13,11 @@ $req = << 'http://ws.sit.com', - 'classmap' => array('Object' => 'PHPObject'))); + 'classmap' => array('Object' => 'PHPObject'))); $server->addFunction("test"); ob_start(); $server->handle($req); diff --git a/ext/soap/tests/bugs/bug42214.phpt b/ext/soap/tests/bugs/bug42214.phpt index a31f16dcb404..64cd631bc7c7 100644 --- a/ext/soap/tests/bugs/bug42214.phpt +++ b/ext/soap/tests/bugs/bug42214.phpt @@ -10,12 +10,12 @@ $request = <<'http://localhost/server.php', - 'send_errors'=>0)); + 'send_errors'=>0)); $server->addFunction('test'); $server->handle($request); ?> diff --git a/ext/soap/tests/bugs/bug42692.phpt b/ext/soap/tests/bugs/bug42692.phpt index b221a3a862b9..0a1310ab9e28 100644 --- a/ext/soap/tests/bugs/bug42692.phpt +++ b/ext/soap/tests/bugs/bug42692.phpt @@ -7,32 +7,32 @@ Bug #42692 (Procedure 'int1' not present with doc/lit SoapServer) ini_set('soap.wsdl_cache_enabled','0'); function checkAuth($peid,$auth) { - return $peid; + return $peid; } class TestSoap extends SoapClient { - function __construct($wsdl, $options) { - parent::__construct($wsdl, $options); - $this->server = new SoapServer($wsdl, $options); - $this->server->addFunction("checkAuth"); - } + function __construct($wsdl, $options) { + parent::__construct($wsdl, $options); + $this->server = new SoapServer($wsdl, $options); + $this->server->addFunction("checkAuth"); + } - function __doRequest($request, $location, $action, $version, $one_way = 0) { - ob_start(); - $this->server->handle($request); - $response = ob_get_contents(); - ob_end_clean(); - return $response; - } + function __doRequest($request, $location, $action, $version, $one_way = 0) { + ob_start(); + $this->server->handle($request); + $response = ob_get_contents(); + ob_end_clean(); + return $response; + } } $client = new TestSoap(__DIR__ . "/bug42692.wsdl", array("trace"=>1)); try { - $result = $client->checkAuth(1,"two"); - echo "Auth for 1 is $result\n"; + $result = $client->checkAuth(1,"two"); + echo "Auth for 1 is $result\n"; } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECT-- diff --git a/ext/soap/tests/bugs/bug43045.phpt b/ext/soap/tests/bugs/bug43045.phpt index f4f3983800ab..9c2139276dca 100644 --- a/ext/soap/tests/bugs/bug43045.phpt +++ b/ext/soap/tests/bugs/bug43045.phpt @@ -36,11 +36,11 @@ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> } } $client = new TestSoapClient(NULL, array( - "location" => "test://", - "uri" => 'urn:TestSOAP', - "style" => SOAP_RPC, - "use" => SOAP_ENCODED - )); + "location" => "test://", + "uri" => 'urn:TestSOAP', + "style" => SOAP_RPC, + "use" => SOAP_ENCODED + )); var_dump($client->test(0.1)); var_dump($client->test(NAN)); var_dump($response = $client->test(INF)); diff --git a/ext/soap/tests/bugs/bug44882.phpt b/ext/soap/tests/bugs/bug44882.phpt index 128011722f87..8357b0c979bd 100644 --- a/ext/soap/tests/bugs/bug44882.phpt +++ b/ext/soap/tests/bugs/bug44882.phpt @@ -9,10 +9,10 @@ soap.wsdl_cache_enabled=0 class TestSoapClient extends SoapClient { public function __doRequest($req, $loc, $act, $ver, $one_way = 0) - { - return << - @@ -35,7 +35,7 @@ class TestSoapClient extends SoapClient XML; - } + } } $client = new TestSoapClient(__DIR__.'/bug44882.wsdl'); diff --git a/ext/soap/tests/bugs/bug46427.phpt b/ext/soap/tests/bugs/bug46427.phpt index 38d53518b8dc..3d0b1a4d5127 100644 --- a/ext/soap/tests/bugs/bug46427.phpt +++ b/ext/soap/tests/bugs/bug46427.phpt @@ -8,10 +8,10 @@ Bug #46427 (SoapClient() stumbles over its "stream_context" parameter) function getSoapClient_1() { $ctx = stream_context_create(); return new SoapClient(NULL, array( - 'stream_context' => $ctx, - 'location' => 'test://', - 'uri' => 'test://', - 'exceptions' => false)); + 'stream_context' => $ctx, + 'location' => 'test://', + 'uri' => 'test://', + 'exceptions' => false)); } getSoapClient_1()->__soapCall('Help', array()); diff --git a/ext/soap/tests/bugs/bug47049.phpt b/ext/soap/tests/bugs/bug47049.phpt index 467df2b901c7..7ffc15d0cd02 100644 --- a/ext/soap/tests/bugs/bug47049.phpt +++ b/ext/soap/tests/bugs/bug47049.phpt @@ -7,7 +7,7 @@ soap.wsdl_cache_enabled=0 --FILE-- 1 , 'exceptions' => 0)); + array('trace' => 1 , 'exceptions' => 0)); $host = array('uuid' => 'foo'); $software_list = array(array('name' => 'package', 'version' => '1.2.3', 'state' => 'installed')); $updates = array(); diff --git a/ext/soap/tests/bugs/bug47273.phpt b/ext/soap/tests/bugs/bug47273.phpt index c23bb5a5929d..a393b701ab51 100644 --- a/ext/soap/tests/bugs/bug47273.phpt +++ b/ext/soap/tests/bugs/bug47273.phpt @@ -16,12 +16,12 @@ EOF; class SoapFaultTest { public function test1() { - // Test #1 + // Test #1 return 'Test #1 exception with some special chars: Äßö'; } public function test2() { // Test #2 - //throw new SoapFault('Server', 'Test #2 exception with some special chars: Äßö'); + //throw new SoapFault('Server', 'Test #2 exception with some special chars: Äßö'); throw new Exception('Test #2 exception with some special chars: Äßö'); } } @@ -32,9 +32,9 @@ $server = new SoapServer(null, array( $server->setClass('SoapFaultTest'); try { - $server->handle($request1); + $server->handle($request1); } catch (Exception $e) { - $server->fault("Sender", $e->getMessage()); + $server->fault("Sender", $e->getMessage()); } try { $server->handle($request2); diff --git a/ext/soap/tests/bugs/bug50675.phpt b/ext/soap/tests/bugs/bug50675.phpt index 017671620bac..00350b1000e3 100644 --- a/ext/soap/tests/bugs/bug50675.phpt +++ b/ext/soap/tests/bugs/bug50675.phpt @@ -13,29 +13,29 @@ class TestSoapClient extends SoapClient { xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - - soapenv:Server.userException - service.EchoServiceException - - - 105 - string param - - steckovic - - - + + + soapenv:Server.userException + service.EchoServiceException + + + 105 + string param + + steckovic + + + EOF; - } + } } ini_set('soap.wsdl_cache_enabled', 0); $parameters = [ - 'trace' => 1, - 'exceptions' => 0, + 'trace' => 1, + 'exceptions' => 0, ]; $client = new TestSoapClient(__DIR__ . '/bug50675.wsdl', $parameters); diff --git a/ext/soap/tests/bugs/bug50762.phpt b/ext/soap/tests/bugs/bug50762.phpt index c48c761ea2d7..d8ed9ce54453 100644 --- a/ext/soap/tests/bugs/bug50762.phpt +++ b/ext/soap/tests/bugs/bug50762.phpt @@ -5,13 +5,13 @@ Bug #50762 (in WSDL mode Soap Header handler function only being called if defin --FILE-- auth=true; - } - public function testHeader($param){ - return 'header handler ' . ($this->auth ? 'called' : 'not called'); - } + private $auth; + public function authToken($token){ + $this->auth=true; + } + public function testHeader($param){ + return 'header handler ' . ($this->auth ? 'called' : 'not called'); + } } class LocalSoapClient extends SoapClient { @@ -19,7 +19,7 @@ class LocalSoapClient extends SoapClient { function __construct($wsdl, $options) { parent::__construct($wsdl, $options); $this->server = new SoapServer($wsdl, $options); - $this->server->setObject(new testSoap()); + $this->server->setObject(new testSoap()); } function __doRequest($request, $location, $action, $version, $one_way = 0) { @@ -35,9 +35,9 @@ class LocalSoapClient extends SoapClient { $cl = new LocalSoapClient(__DIR__.'/bug50762.wsdl', array('cache_wsdl'=>WSDL_CACHE_NONE, 'trace'=>true)); class authToken{ - public function __construct($token){ - $this->authToken=$token; - } + public function __construct($token){ + $this->authToken=$token; + } } $cl->__setSoapHeaders(array(new SoapHeader('http://sova.pronto.ru/', 'authToken', new authToken('tokendata')))); diff --git a/ext/soap/tests/bugs/bug65018.phpt b/ext/soap/tests/bugs/bug65018.phpt index bbb9b5e42d36..762f4f6ec441 100644 --- a/ext/soap/tests/bugs/bug65018.phpt +++ b/ext/soap/tests/bugs/bug65018.phpt @@ -4,24 +4,24 @@ Bug #65018 (SoapHeader problems with SoapServer) --FILE-- '.PHP_EOL. - ''. - 'abc'. - ''; + $input = $input = + ''.PHP_EOL. + ''. + 'abc'. + ''; - $soap = new SoapServer(null, array('uri' => '127.0.0.1')); - $soap->setClass('Tool'); - $soap->handle($input); + $soap = new SoapServer(null, array('uri' => '127.0.0.1')); + $soap->setClass('Tool'); + $soap->handle($input); ?> --EXPECT-- diff --git a/ext/soap/tests/bugs/bug66112.phpt b/ext/soap/tests/bugs/bug66112.phpt index 743297ac2362..7dd067d614e9 100644 --- a/ext/soap/tests/bugs/bug66112.phpt +++ b/ext/soap/tests/bugs/bug66112.phpt @@ -8,12 +8,12 @@ soap.wsdl_cache_enabled=0 array(array("type_ns"=>"uri:mist", "type_name"=>"A")))); - try{ - $client->Mist(array("XX"=>"xx")); - }catch(SoapFault $x){ - } - return array("A"=>"ABC","B"=>"sss"); + $client=new soapclient(WSDL, array('typemap'=>array(array("type_ns"=>"uri:mist", "type_name"=>"A")))); + try{ + $client->Mist(array("XX"=>"xx")); + }catch(SoapFault $x){ + } + return array("A"=>"ABC","B"=>"sss"); } $s = new SoapServer(WSDL, array('typemap'=>array(array("type_ns"=>"uri:mist", "type_name"=>"A")))); $s->addFunction("Mist"); diff --git a/ext/soap/tests/bugs/bug69085.phpt b/ext/soap/tests/bugs/bug69085.phpt index cb27cfd89e7b..7d7f36e9bdf7 100644 --- a/ext/soap/tests/bugs/bug69085.phpt +++ b/ext/soap/tests/bugs/bug69085.phpt @@ -9,9 +9,9 @@ soap.wsdl_cache_enabled=0 $dummy = unserialize('O:10:"SoapClient":5:{s:3:"uri";s:1:"a";s:8:"location";s:22:"http://localhost/a.xml";s:17:"__default_headers";i:1337;s:15:"__last_response";s:1:"a";s:5:"trace";s:1:"x";}'); try { - $dummy->whatever(); + $dummy->whatever(); } catch (Exception $e) { - echo "okey"; + echo "okey"; } --EXPECT-- okey diff --git a/ext/soap/tests/bugs/bug69462.phpt b/ext/soap/tests/bugs/bug69462.phpt index eecd8d6749b3..003d62e495ce 100644 --- a/ext/soap/tests/bugs/bug69462.phpt +++ b/ext/soap/tests/bugs/bug69462.phpt @@ -9,18 +9,18 @@ $namespace = "http://example.com/ns"; $client = new SoapClient(null, [ 'exceptions' => 1, 'location' => "", 'uri' => $namespace ]); $soapvar = new SoapVar( - array( - new SoapVar('value', XSD_STRING, null, null, null, $namespace) - ), - SOAP_ENC_OBJECT, null, null, 'name', $namespace + array( + new SoapVar('value', XSD_STRING, null, null, null, $namespace) + ), + SOAP_ENC_OBJECT, null, null, 'name', $namespace ); try { - $client->__soapCall('method', array($soapvar)); + $client->__soapCall('method', array($soapvar)); } catch (Exception $e) { - /* ignore any errors, we're testing for segmentation fault anyway */ - echo "good"; + /* ignore any errors, we're testing for segmentation fault anyway */ + echo "good"; } ?> --EXPECT-- diff --git a/ext/soap/tests/bugs/multiport.phpt b/ext/soap/tests/bugs/multiport.phpt index 53e281130fcb..549a5b3c7266 100644 --- a/ext/soap/tests/bugs/multiport.phpt +++ b/ext/soap/tests/bugs/multiport.phpt @@ -7,7 +7,7 @@ soap.wsdl_cache_enabled=0 --FILE-- true, 'exceptions' => false)); + array('trace' => true, 'exceptions' => false)); $response = $client->GetSessionId(array('userId'=>'user', 'password'=>'password')); echo $client->__getLastRequest(); ?> diff --git a/ext/soap/tests/classmap001.phpt b/ext/soap/tests/classmap001.phpt index 1a3a472c27a2..c3f5301f461b 100644 --- a/ext/soap/tests/classmap001.phpt +++ b/ext/soap/tests/classmap001.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -25,21 +25,21 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; class test{ - function dotest(book $book){ - $classname=get_class($book); - return "Classname: ".$classname; - } + function dotest(book $book){ + $classname=get_class($book); + return "Classname: ".$classname; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schema.nothing.com', - 'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2') - ); + 'actor' =>'http://schema.nothing.com', + 'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2') + ); $server = new SoapServer(__DIR__."/classmap.wsdl",$options); $server->setClass("test"); diff --git a/ext/soap/tests/classmap002.phpt b/ext/soap/tests/classmap002.phpt index 2f16cf506a5a..cf3dd78e3f14 100644 --- a/ext/soap/tests/classmap002.phpt +++ b/ext/soap/tests/classmap002.phpt @@ -8,7 +8,7 @@ soap.wsdl_cache_enabled=0 @@ -17,19 +17,19 @@ class TestSoapClient extends SoapClient{ EOF; - } + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schema.nothing.com', - 'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2') - ); + 'actor' =>'http://schema.nothing.com', + 'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2') + ); $client = new TestSoapClient(__DIR__."/classmap.wsdl",$options); $ret = $client->dotest2("???"); diff --git a/ext/soap/tests/interop/Round2/Base/r2_base_014s.phpt b/ext/soap/tests/interop/Round2/Base/r2_base_014s.phpt index 681f604e6a3f..f81a0c13f470 100644 --- a/ext/soap/tests/interop/Round2/Base/r2_base_014s.phpt +++ b/ext/soap/tests/interop/Round2/Base/r2_base_014s.phpt @@ -7,9 +7,9 @@ precision=14 --FILE-- "test://","uri"=>"http://soapinterop.org/","trace"=>1,"exceptions"=>0)); $client->__soapCall("echoStruct", array($param), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/")); diff --git a/ext/soap/tests/interop/Round2/Base/r2_base_015s.phpt b/ext/soap/tests/interop/Round2/Base/r2_base_015s.phpt index efbad5a1211f..c167556f12a7 100644 --- a/ext/soap/tests/interop/Round2/Base/r2_base_015s.phpt +++ b/ext/soap/tests/interop/Round2/Base/r2_base_015s.phpt @@ -15,14 +15,14 @@ class SOAPStruct { } $struct1 = new SoapVar(array( - new SoapVar('arg', XSD_STRING, null, null, 'varString'), - new SoapVar('34', XSD_INT, null, null, 'varInt'), - new SoapVar('325.325', XSD_FLOAT, null, null, 'varFloat') + new SoapVar('arg', XSD_STRING, null, null, 'varString'), + new SoapVar('34', XSD_INT, null, null, 'varInt'), + new SoapVar('325.325', XSD_FLOAT, null, null, 'varFloat') ),SOAP_ENC_OBJECT,"SOAPStruct","http://soapinterop.org/xsd"); $struct2 = new SoapVar(array( - new SoapVar('arg', XSD_STRING, null, null, 'varString'), - new SoapVar('34', XSD_INT, null, null, 'varInt'), - new SoapVar('325.325', XSD_FLOAT, null, null, 'varFloat') + new SoapVar('arg', XSD_STRING, null, null, 'varString'), + new SoapVar('34', XSD_INT, null, null, 'varInt'), + new SoapVar('325.325', XSD_FLOAT, null, null, 'varFloat') ),SOAP_ENC_OBJECT,"SOAPStruct","http://soapinterop.org/xsd"); $param = new SoapParam(new SoapVar(array( diff --git a/ext/soap/tests/interop/Round2/GroupB/r2_groupB_004s.phpt b/ext/soap/tests/interop/Round2/GroupB/r2_groupB_004s.phpt index 126bdff26d6e..fe9d90c5090f 100644 --- a/ext/soap/tests/interop/Round2/GroupB/r2_groupB_004s.phpt +++ b/ext/soap/tests/interop/Round2/GroupB/r2_groupB_004s.phpt @@ -11,7 +11,7 @@ $param = new SoapParam(new SoapVar(array( new SoapVar(34, XSD_INT, null, null, "varInt"), new SoapVar(123.45, XSD_FLOAT, null, null, "varFloat"), new SoapVar(array( - new SoapVar("arg2", XSD_STRING, null, null, "varString"), + new SoapVar("arg2", XSD_STRING, null, null, "varString"), new SoapVar(342, XSD_INT, null, null, "varInt"), new SoapVar(123.452, XSD_FLOAT, null, null, "varFloat") ), SOAP_ENC_OBJECT, "SOAPStruct", "http://soapinterop.org/xsd", 'varStruct') diff --git a/ext/soap/tests/interop/Round2/GroupB/r2_groupB_005s.phpt b/ext/soap/tests/interop/Round2/GroupB/r2_groupB_005s.phpt index e8cacfacbb85..20d1d1426b46 100644 --- a/ext/soap/tests/interop/Round2/GroupB/r2_groupB_005s.phpt +++ b/ext/soap/tests/interop/Round2/GroupB/r2_groupB_005s.phpt @@ -11,9 +11,9 @@ $param = new SoapParam(new SoapVar(array( new SoapVar(34, XSD_INT, null, null, "varInt"), new SoapVar(325.325, XSD_FLOAT, null, null, "varFloat"), new SoapVar(array( - new SoapVar("red", XSD_STRING), - new SoapVar("blue", XSD_STRING), - new SoapVar("green", XSD_STRING), + new SoapVar("red", XSD_STRING), + new SoapVar("blue", XSD_STRING), + new SoapVar("green", XSD_STRING), ), SOAP_ENC_ARRAY, "ArrayOfString", "http://soapinterop.org/xsd", 'varArray') ), SOAP_ENC_OBJECT, "SOAPArrayStruct", "http://soapinterop.org/xsd"), "inputStruct"); $client = new SoapClient(NULL,array("location"=>"test://","uri"=>"http://soapinterop.org/","trace"=>1,"exceptions"=>0)); diff --git a/ext/soap/tests/interop/Round2/GroupB/round2_groupB.inc b/ext/soap/tests/interop/Round2/GroupB/round2_groupB.inc index 77b81271c9f5..c8fc93aaa366 100644 --- a/ext/soap/tests/interop/Round2/GroupB/round2_groupB.inc +++ b/ext/soap/tests/interop/Round2/GroupB/round2_groupB.inc @@ -11,8 +11,8 @@ class SOAP_Interop_GroupB { function echoSimpleTypesAsStruct($string, $int, $float) { return (object)array("varString" => $string, - "varInt" => $int, - "varFloat" => $float); + "varInt" => $int, + "varFloat" => $float); } function echoNestedStruct($struct) diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.inc b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.inc index a27f96e279cc..845d96d64496 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.inc +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_doclit.inc @@ -14,21 +14,21 @@ class SOAP_Interop_GroupH { } function echoMultipleFaults1($input) { - if ($input->whichFault == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $input->param2, "ComplexFault2"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, array("soapStruct"=>$input->param1), "ComplexFault1"); - } + if ($input->whichFault == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $input->param2, "ComplexFault2"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, array("soapStruct"=>$input->param1), "ComplexFault1"); + } } function echoMultipleFaults2($input) { - if ($input->whichFault == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param2, "ComplexFault2"); - } else if ($input->whichFault == 3) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param3, "ComplexFault3"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param1, "ComplexFault1"); - } + if ($input->whichFault == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param2, "ComplexFault2"); + } else if ($input->whichFault == 3) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param3, "ComplexFault3"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param1, "ComplexFault1"); + } } } diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.inc b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.inc index 52165ba56e0a..1e403e4488b3 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.inc +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_complex_rpcenc.inc @@ -14,21 +14,21 @@ class SOAP_Interop_GroupH { } function echoMultipleFaults1($which, $s1, $s2) { - if ($which == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $s2, "ComplexFault2"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, array("soapStruct"=>$s1), "ComplexFault1"); - } + if ($which == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $s2, "ComplexFault2"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, array("soapStruct"=>$s1), "ComplexFault1"); + } } function echoMultipleFaults2($which, $s1, $s2, $s3) { - if ($which == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $s2, "ComplexFault2"); - } else if ($which == 3) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $s3, "ComplexFault3"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $s1, "ComplexFault1"); - } + if ($which == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $s2, "ComplexFault2"); + } else if ($which == 3) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $s3, "ComplexFault3"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $s1, "ComplexFault1"); + } } } diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_doclit.inc b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_doclit.inc index e0e35f1821f7..17bcd9c41d50 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_doclit.inc +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_doclit.inc @@ -14,39 +14,39 @@ class SOAP_Interop_GroupH { } function echoMultipleFaults1($input) { - if ($input->whichFault == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $input->param1, "SimpleFault2"); - } else if ($input->whichFault == 3) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $input->param2, "SimpleFault3"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, null, "SimpleFault1"); - } + if ($input->whichFault == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $input->param1, "SimpleFault2"); + } else if ($input->whichFault == 3) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $input->param2, "SimpleFault3"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, null, "SimpleFault1"); + } } function echoMultipleFaults2($input) { - if ($input->whichFault == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param1, "SimpleFault1"); - } else if ($input->whichFault == 3) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param3, "SimpleFault3"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param2, "SimpleFault2"); - } + if ($input->whichFault == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param1, "SimpleFault1"); + } else if ($input->whichFault == 3) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param3, "SimpleFault3"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $input->param2, "SimpleFault2"); + } } function echoMultipleFaults3($input) { - if ($input->whichFault == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $input->param2, "SimpleFault2"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $input->param1, "SimpleFault1"); - } + if ($input->whichFault == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $input->param2, "SimpleFault2"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $input->param1, "SimpleFault1"); + } } function echoMultipleFaults4($input) { - if ($input->whichFault == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $input->param2, "SimpleFault2"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $input->param1, "SimpleFault1"); - } + if ($input->whichFault == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $input->param2, "SimpleFault2"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $input->param1, "SimpleFault1"); + } } } diff --git a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.inc b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.inc index d39f060963c4..01b9870a1a04 100644 --- a/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.inc +++ b/ext/soap/tests/interop/Round4/GroupH/round4_groupH_simple_rpcenc.inc @@ -14,39 +14,39 @@ class SOAP_Interop_GroupH { } function echoMultipleFaults1($param, $string, $floats) { - if ($param == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $string, "SimpleFault2"); - } else if ($param == 3) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $floats, "SimpleFault3"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, null, "SimpleFault1"); - } + if ($param == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $string, "SimpleFault2"); + } else if ($param == 3) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, $floats, "SimpleFault3"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults1'.", null, null, "SimpleFault1"); + } } function echoMultipleFaults2($param, $string, $float, $strings) { - if ($param == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $string, "SimpleFault1"); - } else if ($param == 3) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $strings, "SimpleFault3"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $float, "SimpleFault2"); - } + if ($param == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $string, "SimpleFault1"); + } else if ($param == 3) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $strings, "SimpleFault3"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults2'.", null, $float, "SimpleFault2"); + } } function echoMultipleFaults3($param, $param1, $param2) { - if ($param == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $param2, "SimpleFault2"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $param1, "SimpleFault1"); - } + if ($param == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $param2, "SimpleFault2"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults3'.", null, $param1, "SimpleFault1"); + } } function echoMultipleFaults4($param, $int, $enum) { - if ($param == 2) { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $enum, "SimpleFault2"); - } else { - return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $int, "SimpleFault1"); - } + if ($param == 2) { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $enum, "SimpleFault2"); + } else { + return new SoapFault("Server", "Fault in response to 'echoMultipleFaults4'.", null, $int, "SimpleFault1"); + } } } diff --git a/ext/soap/tests/interop/Round4/GroupI/round4_groupI_xsd.inc b/ext/soap/tests/interop/Round4/GroupI/round4_groupI_xsd.inc index af74db7c7476..c736bcde4b18 100644 --- a/ext/soap/tests/interop/Round4/GroupI/round4_groupI_xsd.inc +++ b/ext/soap/tests/interop/Round4/GroupI/round4_groupI_xsd.inc @@ -3,11 +3,11 @@ class SOAP_Interop_GroupI { function echoString($inputString) { - if (isset($inputString->inputString)) { - return array("return"=>$inputString->inputString); - } else { - return $inputString; - } + if (isset($inputString->inputString)) { + return array("return"=>$inputString->inputString); + } else { + return $inputString; + } } function echoInteger($inputInteger) @@ -26,11 +26,11 @@ class SOAP_Interop_GroupI { function echoBase64($inputBase64) { - if (isset($inputBase64->inputBase64)) { - return array("return"=>$inputBase64->inputBase64); - } else { - return $inputBase64; - } + if (isset($inputBase64->inputBase64)) { + return array("return"=>$inputBase64->inputBase64); + } else { + return $inputBase64; + } } function echoDate($timeInstant) @@ -40,56 +40,56 @@ class SOAP_Interop_GroupI { function echoComplexType($inputComplexType) { - if (isset($inputComplexType->inputComplexType)) { - return array("return"=>$inputComplexType->inputComplexType); - } else { - return $inputComplexType; - } + if (isset($inputComplexType->inputComplexType)) { + return array("return"=>$inputComplexType->inputComplexType); + } else { + return $inputComplexType; + } } function echoIntegerMultiOccurs($input) { - if (isset($input->inputIntegerMultiOccurs->int)) { - return array("return"=>$input->inputIntegerMultiOccurs->int); - } else { - return array(); - } + if (isset($input->inputIntegerMultiOccurs->int)) { + return array("return"=>$input->inputIntegerMultiOccurs->int); + } else { + return array(); + } } function echoFloatMultiOccurs($input) { - if (isset($input->inputFloatMultiOccurs->float)) { - return array("return"=>$input->inputFloatMultiOccurs->float); - } else { - return array(); - } + if (isset($input->inputFloatMultiOccurs->float)) { + return array("return"=>$input->inputFloatMultiOccurs->float); + } else { + return array(); + } } function echoStringMultiOccurs($input) { - if (isset($input->inputStringMultiOccurs->string)) { - return array("return"=>$input->inputStringMultiOccurs->string); - } else { - return array(); - } + if (isset($input->inputStringMultiOccurs->string)) { + return array("return"=>$input->inputStringMultiOccurs->string); + } else { + return array(); + } } function echoComplexTypeMultiOccurs($input) { - if (isset($input->inputComplexTypeMultiOccurs->SOAPComplexType)) { - return array("return"=>$input->inputComplexTypeMultiOccurs->SOAPComplexType); - } else { - return array(); - } + if (isset($input->inputComplexTypeMultiOccurs->SOAPComplexType)) { + return array("return"=>$input->inputComplexTypeMultiOccurs->SOAPComplexType); + } else { + return array(); + } } function echoHexBinary($hb) { - if (isset($hb->inputHexBinary)) { - return array("return"=>$hb->inputHexBinary); - } else { - return $hb; - } + if (isset($hb->inputHexBinary)) { + return array("return"=>$hb->inputHexBinary); + } else { + return $hb; + } } function echoDecimal($dec) @@ -104,53 +104,53 @@ class SOAP_Interop_GroupI { function echoComplexTypeAsSimpleTypes($input) { - if (isset($input->inputComplexType)) { - $ret = array("outputInteger" => $input->inputComplexType->varInt, - "outputFloat" => $input->inputComplexType->varFloat); - if (isset($input->inputComplexType->varString)) { - $ret["outputString"] = $input->inputComplexType->varString; - } - return $ret; - } else { - return array(); - } - } + if (isset($input->inputComplexType)) { + $ret = array("outputInteger" => $input->inputComplexType->varInt, + "outputFloat" => $input->inputComplexType->varFloat); + if (isset($input->inputComplexType->varString)) { + $ret["outputString"] = $input->inputComplexType->varString; + } + return $ret; + } else { + return array(); + } + } function echoSimpleTypesAsComplexType($input) { - $ret = array("varInt" => $input->inputInteger, - "varFloat" => $input->inputFloat); - if (isset($input->inputString)) { - $ret["varString"] = $input->inputString; - } - return array("return"=>$ret); + $ret = array("varInt" => $input->inputInteger, + "varFloat" => $input->inputFloat); + if (isset($input->inputString)) { + $ret["varString"] = $input->inputString; + } + return array("return"=>$ret); } function echoNestedComplexType($inputComplexType) { - if (isset($inputComplexType->inputComplexType)) { - return array("return"=>$inputComplexType->inputComplexType); - } else { - return $inputComplexType; - } + if (isset($inputComplexType->inputComplexType)) { + return array("return"=>$inputComplexType->inputComplexType); + } else { + return $inputComplexType; + } } function echoNestedMultiOccurs($inputComplexType) { - if (isset($inputComplexType->inputComplexType)) { - return array("return"=>$inputComplexType->inputComplexType); - } else { - return $inputComplexType; - } + if (isset($inputComplexType->inputComplexType)) { + return array("return"=>$inputComplexType->inputComplexType); + } else { + return $inputComplexType; + } } function echoChoice($input) { - if (isset($input->inputChoice)) { - return array("return"=>$input->inputChoice); - } else { - return $input; - } + if (isset($input->inputChoice)) { + return array("return"=>$input->inputChoice); + } else { + return $input; + } } function echoEnum($input) @@ -160,20 +160,20 @@ class SOAP_Interop_GroupI { function echoAnyType($input) { - if (isset($input->inputAnyType)) { - return array("return"=>$input->inputAnyType); - } else { - return $input; - } + if (isset($input->inputAnyType)) { + return array("return"=>$input->inputAnyType); + } else { + return $input; + } } function echoAnyElement($input) { - if (isset($input->inputAny)) { - return array("return"=>$input->inputAny); - } else { - return $input; - } + if (isset($input->inputAny)) { + return array("return"=>$input->inputAny); + } else { + return $input; + } } function echoVoidSoapHeader() diff --git a/ext/soap/tests/schema/schema001.phpt b/ext/soap/tests/schema/schema001.phpt index 9f2b7e5235d2..cb031e6ac6fe 100644 --- a/ext/soap/tests/schema/schema001.phpt +++ b/ext/soap/tests/schema/schema001.phpt @@ -6,9 +6,9 @@ SOAP XML Schema 1: simpleType/restriction - - + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema002.phpt b/ext/soap/tests/schema/schema002.phpt index 41f3bbe3fa2e..66485aa205cb 100644 --- a/ext/soap/tests/schema/schema002.phpt +++ b/ext/soap/tests/schema/schema002.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 2: simpleType/restriction (reference to type) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema003.phpt b/ext/soap/tests/schema/schema003.phpt index 75991001e0c5..d32dd2434e48 100644 --- a/ext/soap/tests/schema/schema003.phpt +++ b/ext/soap/tests/schema/schema003.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 3: simpleType/restriction (reference to type, that is not define - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema004.phpt b/ext/soap/tests/schema/schema004.phpt index 93ed1d17f157..b930e40b4c96 100644 --- a/ext/soap/tests/schema/schema004.phpt +++ b/ext/soap/tests/schema/schema004.phpt @@ -8,9 +8,9 @@ precision=14 - - + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema005.phpt b/ext/soap/tests/schema/schema005.phpt index 1db0c62f990e..ddfa92555bf1 100644 --- a/ext/soap/tests/schema/schema005.phpt +++ b/ext/soap/tests/schema/schema005.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 5: simpleType/restriction (inline type) - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema006.phpt b/ext/soap/tests/schema/schema006.phpt index e41f27545b5f..9255626581e4 100644 --- a/ext/soap/tests/schema/schema006.phpt +++ b/ext/soap/tests/schema/schema006.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 6: simpleType/restriction (referenced by ellement) - - - - - - - + + + + + + + + EOF; test_schema($schema,'element="tns:testElement"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema007.phpt b/ext/soap/tests/schema/schema007.phpt index fd93c7aa8e45..bf088e7b2dce 100644 --- a/ext/soap/tests/schema/schema007.phpt +++ b/ext/soap/tests/schema/schema007.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 7: simpleType/restriction (referenced by ellement) - - - - - - - + + + + + + + + EOF; test_schema($schema,'element="tns:testElement"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema008.phpt b/ext/soap/tests/schema/schema008.phpt index 7d8a440dd9c3..3a9b998580ac 100644 --- a/ext/soap/tests/schema/schema008.phpt +++ b/ext/soap/tests/schema/schema008.phpt @@ -7,13 +7,13 @@ SOAP XML Schema 8: simpleType/restriction (anonymous, inside an ellement) include "test_schema.inc"; $schema = << - - - - - - - + + + + + + + EOF; test_schema($schema,'element="tns:testElement"',123.5); diff --git a/ext/soap/tests/schema/schema009.phpt b/ext/soap/tests/schema/schema009.phpt index f7d10242ccf3..2de815f45569 100644 --- a/ext/soap/tests/schema/schema009.phpt +++ b/ext/soap/tests/schema/schema009.phpt @@ -6,9 +6,9 @@ SOAP XML Schema 9: simpleType/list (as string) - - + + + EOF; test_schema($schema,'type="tns:testType"',"one two"); echo "ok"; diff --git a/ext/soap/tests/schema/schema010.phpt b/ext/soap/tests/schema/schema010.phpt index 49136b9fe469..b50a5eeb970e 100644 --- a/ext/soap/tests/schema/schema010.phpt +++ b/ext/soap/tests/schema/schema010.phpt @@ -6,9 +6,9 @@ SOAP XML Schema 10: simpleType/list (as array) - - + + + EOF; test_schema($schema,'type="tns:testType"',array("one","two")); echo "ok"; diff --git a/ext/soap/tests/schema/schema011.phpt b/ext/soap/tests/schema/schema011.phpt index 8296311a4607..fca39291f3d7 100644 --- a/ext/soap/tests/schema/schema011.phpt +++ b/ext/soap/tests/schema/schema011.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 11: simpleType/list (inline type) (as string) - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',"123 456.7"); echo "ok"; diff --git a/ext/soap/tests/schema/schema012.phpt b/ext/soap/tests/schema/schema012.phpt index 1d542d81d8e7..d947980c00a6 100644 --- a/ext/soap/tests/schema/schema012.phpt +++ b/ext/soap/tests/schema/schema012.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 12: simpleType/list (inline type) (as array) - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',array(123,456.7)); echo "ok"; diff --git a/ext/soap/tests/schema/schema013.phpt b/ext/soap/tests/schema/schema013.phpt index 4794d2d0f13e..9c93ae4d2e8f 100644 --- a/ext/soap/tests/schema/schema013.phpt +++ b/ext/soap/tests/schema/schema013.phpt @@ -6,9 +6,9 @@ SOAP XML Schema 13: simpleType/union - - + + + EOF; test_schema($schema,'type="tns:testType"',"str"); echo "ok"; diff --git a/ext/soap/tests/schema/schema014.phpt b/ext/soap/tests/schema/schema014.phpt index 3dab5f350b6b..b2639fc1e2d1 100644 --- a/ext/soap/tests/schema/schema014.phpt +++ b/ext/soap/tests/schema/schema014.phpt @@ -8,9 +8,9 @@ precision=14 - - + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema015.phpt b/ext/soap/tests/schema/schema015.phpt index fe9b96b8cf24..6f280e78a97e 100644 --- a/ext/soap/tests/schema/schema015.phpt +++ b/ext/soap/tests/schema/schema015.phpt @@ -6,19 +6,19 @@ SOAP XML Schema 15: simpleType/union (inline type) - - - - - - - - - - - - + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',"str"); echo "ok"; diff --git a/ext/soap/tests/schema/schema016.phpt b/ext/soap/tests/schema/schema016.phpt index 11e9436bcb47..4878b710c50a 100644 --- a/ext/soap/tests/schema/schema016.phpt +++ b/ext/soap/tests/schema/schema016.phpt @@ -8,19 +8,19 @@ precision=14 - - - - - - - - - - - - + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema017.phpt b/ext/soap/tests/schema/schema017.phpt index 6689c363edbd..25a1da054a46 100644 --- a/ext/soap/tests/schema/schema017.phpt +++ b/ext/soap/tests/schema/schema017.phpt @@ -8,16 +8,16 @@ precision=14 - - - - - - - - - + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',123.5); echo "ok"; diff --git a/ext/soap/tests/schema/schema018.phpt b/ext/soap/tests/schema/schema018.phpt index 0f3e8b84ac09..8b85ea8af398 100644 --- a/ext/soap/tests/schema/schema018.phpt +++ b/ext/soap/tests/schema/schema018.phpt @@ -6,16 +6,16 @@ SOAP XML Schema 18: union with list - - - - - - - - - + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',"123.5"); echo "ok"; diff --git a/ext/soap/tests/schema/schema019.phpt b/ext/soap/tests/schema/schema019.phpt index 0d2d753764ea..afcae9b1b6b7 100644 --- a/ext/soap/tests/schema/schema019.phpt +++ b/ext/soap/tests/schema/schema019.phpt @@ -6,16 +6,16 @@ SOAP XML Schema 19: union with list - - - - - - - - - + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',"123.5 456.7"); echo "ok"; diff --git a/ext/soap/tests/schema/schema020.phpt b/ext/soap/tests/schema/schema020.phpt index 344757a3276f..e8ebf500e12b 100644 --- a/ext/soap/tests/schema/schema020.phpt +++ b/ext/soap/tests/schema/schema020.phpt @@ -8,16 +8,16 @@ precision=14 - - - - - - - - - + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',array(123.5,456.7)); echo "ok"; diff --git a/ext/soap/tests/schema/schema021.phpt b/ext/soap/tests/schema/schema021.phpt index 0628c6b3b887..18e1394775cf 100644 --- a/ext/soap/tests/schema/schema021.phpt +++ b/ext/soap/tests/schema/schema021.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 21: list of unions - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',"123 123.5 456.7 str"); echo "ok"; diff --git a/ext/soap/tests/schema/schema022.phpt b/ext/soap/tests/schema/schema022.phpt index a8f5bb9cad06..45bcd29c6ee5 100644 --- a/ext/soap/tests/schema/schema022.phpt +++ b/ext/soap/tests/schema/schema022.phpt @@ -8,13 +8,13 @@ precision=14 - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5,'str')); echo "ok"; diff --git a/ext/soap/tests/schema/schema023.phpt b/ext/soap/tests/schema/schema023.phpt index 550bacfe84ad..31bfe9ae6fe8 100644 --- a/ext/soap/tests/schema/schema023.phpt +++ b/ext/soap/tests/schema/schema023.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 23: SOAP 1.1 Array - - - - + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema024.phpt b/ext/soap/tests/schema/schema024.phpt index af836d1ffb54..cd58f7efb548 100644 --- a/ext/soap/tests/schema/schema024.phpt +++ b/ext/soap/tests/schema/schema024.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 24: SOAP 1.1 Array (second way) - - - - - - + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema025.phpt b/ext/soap/tests/schema/schema025.phpt index 748e45804d1f..5237e8979e0d 100644 --- a/ext/soap/tests/schema/schema025.phpt +++ b/ext/soap/tests/schema/schema025.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 25: SOAP 1.2 Array - - - - - + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema026.phpt b/ext/soap/tests/schema/schema026.phpt index e17b5ac60b5f..983ee8e5efda 100644 --- a/ext/soap/tests/schema/schema026.phpt +++ b/ext/soap/tests/schema/schema026.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 26: SOAP 1.2 Array (second way) - - - - - - + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema027.phpt b/ext/soap/tests/schema/schema027.phpt index e3b382ebe945..39ca3dc3cd48 100644 --- a/ext/soap/tests/schema/schema027.phpt +++ b/ext/soap/tests/schema/schema027.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 27: SOAP 1.1 Multidimensional array - - - - + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(array(123),array(123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema028.phpt b/ext/soap/tests/schema/schema028.phpt index 7cc4ba568adc..84a059b6025d 100644 --- a/ext/soap/tests/schema/schema028.phpt +++ b/ext/soap/tests/schema/schema028.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 28: SOAP 1.2 Multidimensional array - - - - - + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(array(123),array(123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema029.phpt b/ext/soap/tests/schema/schema029.phpt index 2081affc6d9d..70f1b21e9145 100644 --- a/ext/soap/tests/schema/schema029.phpt +++ b/ext/soap/tests/schema/schema029.phpt @@ -6,16 +6,16 @@ SOAP XML Schema 29: SOAP 1.2 Multidimensional array (second way) - - - - - - - + + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(array(123),array(123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema030.phpt b/ext/soap/tests/schema/schema030.phpt index e46861391614..10471192958f 100644 --- a/ext/soap/tests/schema/schema030.phpt +++ b/ext/soap/tests/schema/schema030.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 30: Structure (sequence) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema031.phpt b/ext/soap/tests/schema/schema031.phpt index 479abfee9d72..4b033583721d 100644 --- a/ext/soap/tests/schema/schema031.phpt +++ b/ext/soap/tests/schema/schema031.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 31: Structure (all) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema032.phpt b/ext/soap/tests/schema/schema032.phpt index 47b4af121cb7..397636083cc9 100644 --- a/ext/soap/tests/schema/schema032.phpt +++ b/ext/soap/tests/schema/schema032.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 32: Structure (choice) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema033.phpt b/ext/soap/tests/schema/schema033.phpt index b504bc077a3d..7c1ce0fc8a04 100644 --- a/ext/soap/tests/schema/schema033.phpt +++ b/ext/soap/tests/schema/schema033.phpt @@ -6,17 +6,17 @@ SOAP XML Schema 33: Nested complex types - - - - - - - - - - + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"nest"=>array("int"=>123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema034.phpt b/ext/soap/tests/schema/schema034.phpt index a83d6ea84648..42536d89c39b 100644 --- a/ext/soap/tests/schema/schema034.phpt +++ b/ext/soap/tests/schema/schema034.phpt @@ -6,18 +6,18 @@ SOAP XML Schema 34: Nested complex types (element ref) - - - - - - - - - - - + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"testType2"=>array("int"=>123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema035.phpt b/ext/soap/tests/schema/schema035.phpt index 8974ed00c549..d62dfbc98e67 100644 --- a/ext/soap/tests/schema/schema035.phpt +++ b/ext/soap/tests/schema/schema035.phpt @@ -6,19 +6,19 @@ SOAP XML Schema 35: Nested complex types (element ref + anonymous type) - - - - - - - - - - - - + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"testType2"=>array("int"=>123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema036.phpt b/ext/soap/tests/schema/schema036.phpt index 9d6dac45343a..12c5c40e0baf 100644 --- a/ext/soap/tests/schema/schema036.phpt +++ b/ext/soap/tests/schema/schema036.phpt @@ -6,18 +6,18 @@ SOAP XML Schema 36: Nested complex types (inline) - - - - - - - - - - - + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"testType2"=>array("int"=>123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema037.phpt b/ext/soap/tests/schema/schema037.phpt index 4e59981fc9a5..dbc5dc38c894 100644 --- a/ext/soap/tests/schema/schema037.phpt +++ b/ext/soap/tests/schema/schema037.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 37: Structure with attributes - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema038.phpt b/ext/soap/tests/schema/schema038.phpt index 2d37e89e0b53..70b5b207eeec 100644 --- a/ext/soap/tests/schema/schema038.phpt +++ b/ext/soap/tests/schema/schema038.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 38: Structure with attributes (ref) - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema039.phpt b/ext/soap/tests/schema/schema039.phpt index 0b7ef5afc462..5b3f454bf91c 100644 --- a/ext/soap/tests/schema/schema039.phpt +++ b/ext/soap/tests/schema/schema039.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 39: Structure with attributes (attributeGroup) - - - - - - - - + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema040.phpt b/ext/soap/tests/schema/schema040.phpt index f7ddc0454684..51bcd776e136 100644 --- a/ext/soap/tests/schema/schema040.phpt +++ b/ext/soap/tests/schema/schema040.phpt @@ -6,16 +6,16 @@ SOAP XML Schema 40: Structure with attributes (inline types) - - - - - - - - - + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema041.phpt b/ext/soap/tests/schema/schema041.phpt index 1264cf5c90d7..4613f157295c 100644 --- a/ext/soap/tests/schema/schema041.phpt +++ b/ext/soap/tests/schema/schema041.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 41: Structure (group) - - - - - - - - + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema042.phpt b/ext/soap/tests/schema/schema042.phpt index a8aa8857d9bf..c0a938aa2709 100644 --- a/ext/soap/tests/schema/schema042.phpt +++ b/ext/soap/tests/schema/schema042.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 42: Extension of simple type - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema043.phpt b/ext/soap/tests/schema/schema043.phpt index 08c29963634d..cc628eefea28 100644 --- a/ext/soap/tests/schema/schema043.phpt +++ b/ext/soap/tests/schema/schema043.phpt @@ -6,20 +6,20 @@ SOAP XML Schema 43: Extension of simple type (2) - - - - - - - - - - - - - + + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema044.phpt b/ext/soap/tests/schema/schema044.phpt index 8fc070551874..3158d46049a9 100644 --- a/ext/soap/tests/schema/schema044.phpt +++ b/ext/soap/tests/schema/schema044.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 44: Restriction of simple type - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema045.phpt b/ext/soap/tests/schema/schema045.phpt index 346a929d85b5..8055b39914a4 100644 --- a/ext/soap/tests/schema/schema045.phpt +++ b/ext/soap/tests/schema/schema045.phpt @@ -6,20 +6,20 @@ SOAP XML Schema 45: Restriction of simple type (2) - - - - - - - - - - - - - + + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema046.phpt b/ext/soap/tests/schema/schema046.phpt index 3f9d03afadd7..9f3efd79ca51 100644 --- a/ext/soap/tests/schema/schema046.phpt +++ b/ext/soap/tests/schema/schema046.phpt @@ -6,20 +6,20 @@ SOAP XML Schema 46: Extension of complex type - - - - - - - - - - - - - + + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema047.phpt b/ext/soap/tests/schema/schema047.phpt index 1265cfd3a381..a67973eeb08d 100644 --- a/ext/soap/tests/schema/schema047.phpt +++ b/ext/soap/tests/schema/schema047.phpt @@ -6,18 +6,18 @@ SOAP XML Schema 47: Extension of complex type (2) - - - - - - - - - - - + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema048.phpt b/ext/soap/tests/schema/schema048.phpt index 98d4d4be4438..c2a372e1d1ff 100644 --- a/ext/soap/tests/schema/schema048.phpt +++ b/ext/soap/tests/schema/schema048.phpt @@ -6,20 +6,20 @@ SOAP XML Schema 48: Restriction of complex type - - - - - - - - - - - - - + + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema049.phpt b/ext/soap/tests/schema/schema049.phpt index 7268a4b67a5a..84b22fe5e715 100644 --- a/ext/soap/tests/schema/schema049.phpt +++ b/ext/soap/tests/schema/schema049.phpt @@ -6,21 +6,21 @@ SOAP XML Schema 49: Restriction of complex type (2) - - - - - - - - - - - - - - + + + + + + + + + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>123.5,"int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema050.phpt b/ext/soap/tests/schema/schema050.phpt index 6c735125b765..0bb3d35dc92d 100644 --- a/ext/soap/tests/schema/schema050.phpt +++ b/ext/soap/tests/schema/schema050.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 50: Array in complex type (maxOccurs > 1, one value) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"int2"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema051.phpt b/ext/soap/tests/schema/schema051.phpt index 9636399814a9..0f5ad8b7188e 100644 --- a/ext/soap/tests/schema/schema051.phpt +++ b/ext/soap/tests/schema/schema051.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 51: Array in complex type (maxOccurs > 1, array) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"int2"=>array(123.5,456.7))); echo "ok"; diff --git a/ext/soap/tests/schema/schema052.phpt b/ext/soap/tests/schema/schema052.phpt index 8e7121ae2d0a..5e30c8287ef4 100644 --- a/ext/soap/tests/schema/schema052.phpt +++ b/ext/soap/tests/schema/schema052.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 52: Array in complex type (maxOccurs > 1, array with one value) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"int2"=>array(123.5))); echo "ok"; diff --git a/ext/soap/tests/schema/schema053.phpt b/ext/soap/tests/schema/schema053.phpt index 8893bf5df345..f276978a4c65 100644 --- a/ext/soap/tests/schema/schema053.phpt +++ b/ext/soap/tests/schema/schema053.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 52: Array in complex type (maxOccurs > 1, empty array) - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int"=>123.5,"int2"=>array())); echo "ok"; diff --git a/ext/soap/tests/schema/schema055.phpt b/ext/soap/tests/schema/schema055.phpt index 14dbdb7c1d98..1a23e2fa6e4e 100644 --- a/ext/soap/tests/schema/schema055.phpt +++ b/ext/soap/tests/schema/schema055.phpt @@ -8,12 +8,12 @@ precision=14 - - - + + + + - + EOF; test_schema($schema,'type="testType"',array('a'=>123,'b'=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema056.phpt b/ext/soap/tests/schema/schema056.phpt index 1ada78ea2a0b..d2aac098d013 100644 --- a/ext/soap/tests/schema/schema056.phpt +++ b/ext/soap/tests/schema/schema056.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 56: SOAP 1.1 Array (literal encoding) - - - - + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),'rpc','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema057.phpt b/ext/soap/tests/schema/schema057.phpt index 1848b9c24aa3..13521b2a605c 100644 --- a/ext/soap/tests/schema/schema057.phpt +++ b/ext/soap/tests/schema/schema057.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 57: SOAP 1.1 Array (second way, literal encoding) - - - - - - + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),'rpc','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema058.phpt b/ext/soap/tests/schema/schema058.phpt index b96fc9fccaad..aee0a9611115 100644 --- a/ext/soap/tests/schema/schema058.phpt +++ b/ext/soap/tests/schema/schema058.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 58: SOAP 1.2 Array (literal encoding) - - - - - + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),'rpc','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema059.phpt b/ext/soap/tests/schema/schema059.phpt index 875bae986869..bbed854fbb33 100644 --- a/ext/soap/tests/schema/schema059.phpt +++ b/ext/soap/tests/schema/schema059.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 59: SOAP 1.2 Array (second way, literal encoding) - - - - - - + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),'rpc','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema060.phpt b/ext/soap/tests/schema/schema060.phpt index 4daa83c191b1..9029a470e496 100644 --- a/ext/soap/tests/schema/schema060.phpt +++ b/ext/soap/tests/schema/schema060.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 60: SOAP 1.2 Multidimensional array (literal encoding) - - - - - + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(array(123),array(123.5)),'rpc','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema061.phpt b/ext/soap/tests/schema/schema061.phpt index bbd2aa657978..73cf1546d906 100644 --- a/ext/soap/tests/schema/schema061.phpt +++ b/ext/soap/tests/schema/schema061.phpt @@ -6,16 +6,16 @@ SOAP XML Schema 61: SOAP 1.2 Multidimensional array (second way, literal encodin - - - - - - - + + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(array(123),array(123.5)),'rpc','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema062.phpt b/ext/soap/tests/schema/schema062.phpt index 60b06568eda7..ae26c7b1cdf7 100644 --- a/ext/soap/tests/schema/schema062.phpt +++ b/ext/soap/tests/schema/schema062.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 62: NULL with attributes - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("_"=>NULL,"int"=>123.5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema064.phpt b/ext/soap/tests/schema/schema064.phpt index 913cbd16e057..88f58cf8cec3 100644 --- a/ext/soap/tests/schema/schema064.phpt +++ b/ext/soap/tests/schema/schema064.phpt @@ -10,30 +10,30 @@ require_once('skipif.inc'); ?> - - - - - - - - - - - + + + + + + + + + + + + EOF; $date = gmmktime(1,2,3,4,5,1976); putenv('TZ=GMT'); test_schema($schema,'type="tns:testType"',array( - 'dateTime' => $date, - 'time' => $date, - 'date' => $date, - 'gYearMonth' => $date, - 'gYear' => $date, - 'gMonthDay' => $date, - 'gDay' => $date, - 'gMonth' => $date + 'dateTime' => $date, + 'time' => $date, + 'date' => $date, + 'gYearMonth' => $date, + 'gYear' => $date, + 'gMonthDay' => $date, + 'gDay' => $date, + 'gMonth' => $date )); echo "ok"; ?> diff --git a/ext/soap/tests/schema/schema065.phpt b/ext/soap/tests/schema/schema065.phpt index 3199a6bc8fcb..0e5a66cd3f79 100644 --- a/ext/soap/tests/schema/schema065.phpt +++ b/ext/soap/tests/schema/schema065.phpt @@ -6,10 +6,10 @@ SOAP XML Schema 65: Attribute with default value - - - + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str")); echo "ok"; diff --git a/ext/soap/tests/schema/schema066.phpt b/ext/soap/tests/schema/schema066.phpt index 7fe47bbd2c16..c6692535a609 100644 --- a/ext/soap/tests/schema/schema066.phpt +++ b/ext/soap/tests/schema/schema066.phpt @@ -6,10 +6,10 @@ SOAP XML Schema 66: Attribute with fixed value (1) - - - + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str")); echo "ok"; diff --git a/ext/soap/tests/schema/schema067.phpt b/ext/soap/tests/schema/schema067.phpt index 5ee0036ebe65..7fb7eff233d2 100644 --- a/ext/soap/tests/schema/schema067.phpt +++ b/ext/soap/tests/schema/schema067.phpt @@ -6,10 +6,10 @@ SOAP XML Schema 67: Attribute with fixed value (2) - - - + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>5)); echo "ok"; diff --git a/ext/soap/tests/schema/schema068.phpt b/ext/soap/tests/schema/schema068.phpt index 5ab63be097a4..4372cdfa23e9 100644 --- a/ext/soap/tests/schema/schema068.phpt +++ b/ext/soap/tests/schema/schema068.phpt @@ -6,10 +6,10 @@ SOAP XML Schema 68: Attribute with fixed value (3) - - - + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>4)); echo "ok"; diff --git a/ext/soap/tests/schema/schema069.phpt b/ext/soap/tests/schema/schema069.phpt index ccaa342406a8..d944765e3208 100644 --- a/ext/soap/tests/schema/schema069.phpt +++ b/ext/soap/tests/schema/schema069.phpt @@ -6,11 +6,11 @@ SOAP XML Schema 69: Attribute with default value (reference) - - - - + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str")); echo "ok"; diff --git a/ext/soap/tests/schema/schema070.phpt b/ext/soap/tests/schema/schema070.phpt index 0c1e2493920f..3135183398a9 100644 --- a/ext/soap/tests/schema/schema070.phpt +++ b/ext/soap/tests/schema/schema070.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 70: Attribute with default value (attributeGroup) - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str")); echo "ok"; diff --git a/ext/soap/tests/schema/schema071.phpt b/ext/soap/tests/schema/schema071.phpt index 1991f7ad8ee9..65ea47bf9ec8 100644 --- a/ext/soap/tests/schema/schema071.phpt +++ b/ext/soap/tests/schema/schema071.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 71: SOAP 1.1 Array (document style) - - - - + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),'document','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema072.phpt b/ext/soap/tests/schema/schema072.phpt index 89a0ed3597ec..cbf08db00bc9 100644 --- a/ext/soap/tests/schema/schema072.phpt +++ b/ext/soap/tests/schema/schema072.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 72: SOAP 1.1 Array (document style, element with inline type) - - - - - + + + + + + - - + + EOF; test_schema($schema,'element="tns:testElement"',array(123,123.5),'document','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema073.phpt b/ext/soap/tests/schema/schema073.phpt index 22dd9e2604c1..3338684a9b2e 100644 --- a/ext/soap/tests/schema/schema073.phpt +++ b/ext/soap/tests/schema/schema073.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 73: SOAP 1.1 Array (document style, element with type ref) - - - - - + + + + + + - + EOF; test_schema($schema,'element="tns:testElement"',array(123,123.5),'document','literal'); echo "ok"; diff --git a/ext/soap/tests/schema/schema074.phpt b/ext/soap/tests/schema/schema074.phpt index 3dbba0cd251d..4735957bfa38 100644 --- a/ext/soap/tests/schema/schema074.phpt +++ b/ext/soap/tests/schema/schema074.phpt @@ -6,12 +6,12 @@ SOAP XML Schema 74: Structure with attributes and qualified elements - - - - - + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("str"=>"str","int"=>123.5), "rpc", "encoded", 'attributeFormDefault="qualified"'); diff --git a/ext/soap/tests/schema/schema075.phpt b/ext/soap/tests/schema/schema075.phpt index 5867e55a7c9a..eb3729a9b2ff 100644 --- a/ext/soap/tests/schema/schema075.phpt +++ b/ext/soap/tests/schema/schema075.phpt @@ -6,11 +6,11 @@ SOAP XML Schema 75: Attributes form qualified/unqualified (attributeFormDefault= - - - - + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded", 'attributeFormDefault="qualified"'); diff --git a/ext/soap/tests/schema/schema076.phpt b/ext/soap/tests/schema/schema076.phpt index 3ad2eae33a61..d4940deb6bf9 100644 --- a/ext/soap/tests/schema/schema076.phpt +++ b/ext/soap/tests/schema/schema076.phpt @@ -6,11 +6,11 @@ SOAP XML Schema 76: Attributes form qualified/unqualified (attributeFormDefault= - - - - + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded", 'attributeFormDefault="unqualified"'); diff --git a/ext/soap/tests/schema/schema077.phpt b/ext/soap/tests/schema/schema077.phpt index 16057cfcf90f..7da8b4a1a24f 100644 --- a/ext/soap/tests/schema/schema077.phpt +++ b/ext/soap/tests/schema/schema077.phpt @@ -6,11 +6,11 @@ SOAP XML Schema 77: Attributes form qualified/unqualified (attributeFormDefault - - - - + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "encoded"); diff --git a/ext/soap/tests/schema/schema078.phpt b/ext/soap/tests/schema/schema078.phpt index 7636a78f9369..a051acd8f26b 100644 --- a/ext/soap/tests/schema/schema078.phpt +++ b/ext/soap/tests/schema/schema078.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 78: Element form qualified/unqualified (elementFormDefault="qual - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal", 'elementFormDefault="qualified"'); diff --git a/ext/soap/tests/schema/schema079.phpt b/ext/soap/tests/schema/schema079.phpt index 34dcd9bee78b..de1a4480fea0 100644 --- a/ext/soap/tests/schema/schema079.phpt +++ b/ext/soap/tests/schema/schema079.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 79: Element form qualified/unqualified (elementFormDefault="unqu - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal", 'elementFormDefault="unqualified"'); diff --git a/ext/soap/tests/schema/schema080.phpt b/ext/soap/tests/schema/schema080.phpt index 7519d6a30d8e..926bc8ae22a1 100644 --- a/ext/soap/tests/schema/schema080.phpt +++ b/ext/soap/tests/schema/schema080.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 80: Element form qualified/unqualified (elementFormDefault - def - - - - - - + + + + + + + EOF; test_schema($schema,'type="tns:testType"',(object)array("int1"=>1.1,"int2"=>2.2,"int3"=>3.3), "rpc", "literal"); diff --git a/ext/soap/tests/schema/schema081.phpt b/ext/soap/tests/schema/schema081.phpt index 337f08126193..976d95baf817 100644 --- a/ext/soap/tests/schema/schema081.phpt +++ b/ext/soap/tests/schema/schema081.phpt @@ -6,13 +6,13 @@ SOAP XML Schema 81: SOAP 1.1 Array with SOAP_USE_XSI_ARRAY_TYPE - - - - + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),"rpc","encoded",'',SOAP_USE_XSI_ARRAY_TYPE); echo "ok"; diff --git a/ext/soap/tests/schema/schema082.phpt b/ext/soap/tests/schema/schema082.phpt index 34c4c76c2564..229e566afcb6 100644 --- a/ext/soap/tests/schema/schema082.phpt +++ b/ext/soap/tests/schema/schema082.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 82: SOAP 1.1 Array with SOAP_USE_XSI_ARRAY_TYPE (second way) - - - - - - + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),"rpc","encoded",'',SOAP_USE_XSI_ARRAY_TYPE); echo "ok"; diff --git a/ext/soap/tests/schema/schema083.phpt b/ext/soap/tests/schema/schema083.phpt index 854c4f9ff68f..8bcf6023050f 100644 --- a/ext/soap/tests/schema/schema083.phpt +++ b/ext/soap/tests/schema/schema083.phpt @@ -6,14 +6,14 @@ SOAP XML Schema 83: SOAP 1.2 Array with SOAP_USE_XSI_ARRAY_TYPE - - - - - + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),"rpc","encoded",'',SOAP_USE_XSI_ARRAY_TYPE); echo "ok"; diff --git a/ext/soap/tests/schema/schema084.phpt b/ext/soap/tests/schema/schema084.phpt index 94a9551faf1c..62804c9cccda 100644 --- a/ext/soap/tests/schema/schema084.phpt +++ b/ext/soap/tests/schema/schema084.phpt @@ -6,15 +6,15 @@ SOAP XML Schema 84: SOAP 1.2 Array with SOAP_USE_XSI_ARRAY_TYPE (second way) - - - - - - + + + + + + + - + EOF; test_schema($schema,'type="tns:testType"',array(123,123.5),"rpc","encoded",'',SOAP_USE_XSI_ARRAY_TYPE); echo "ok"; diff --git a/ext/soap/tests/schema/schema085.phpt b/ext/soap/tests/schema/schema085.phpt index 1a1ab159994b..206553bb515a 100644 --- a/ext/soap/tests/schema/schema085.phpt +++ b/ext/soap/tests/schema/schema085.phpt @@ -6,20 +6,20 @@ SOAP XML Schema 85: Extension of complex type (elements order) - - - - - - - - - - - - - + + + + + + + + + + + + + + EOF; class A { public $int = 1; diff --git a/ext/soap/tests/schema/test_schema.inc b/ext/soap/tests/schema/test_schema.inc index 7afc4e697ceb..a0ba2c4dc1e2 100644 --- a/ext/soap/tests/schema/test_schema.inc +++ b/ext/soap/tests/schema/test_schema.inc @@ -2,8 +2,8 @@ $val = null; function test($input) { - global $val; - $val = $input; + global $val; + $val = $input; } function test_schema($schema,$type,$param,$style="rpc",$use="encoded", $attributeFormDefault='',$features=0) { @@ -22,27 +22,27 @@ $wsdl = << - $schema + $schema - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -57,7 +57,7 @@ EOF; ini_set("soap.wsdl_cache_enabled",0); $x = new SoapClient($fname, array("trace"=>1,"exceptions"=>0,"features"=>$features)); $y = new SoapServer($fname, array("features"=>$features)); - $y->addfunction("test"); + $y->addfunction("test"); unlink($fname); $x->test($param); diff --git a/ext/soap/tests/server011.phpt b/ext/soap/tests/server011.phpt index 1c367d7d5645..53c65213144f 100644 --- a/ext/soap/tests/server011.phpt +++ b/ext/soap/tests/server011.phpt @@ -20,7 +20,7 @@ ob_end_clean(); if ($wsdl == file_get_contents(__DIR__."/test.wsdl")) { echo "ok\n"; } else { - echo "fail\n"; + echo "fail\n"; } ?> --EXPECT-- diff --git a/ext/soap/tests/server016.phpt b/ext/soap/tests/server016.phpt index 8934f46afe83..acef045a462a 100644 --- a/ext/soap/tests/server016.phpt +++ b/ext/soap/tests/server016.phpt @@ -5,8 +5,8 @@ SOAP Server 16: user fault --FILE-- fault("MyFault","My fault string"); + global $server; + $server->fault("MyFault","My fault string"); } $server = new soapserver(null,array('uri'=>"http://testuri.org")); diff --git a/ext/soap/tests/server017.phpt b/ext/soap/tests/server017.phpt index 3ff0acb4e9a1..a6350657501b 100644 --- a/ext/soap/tests/server017.phpt +++ b/ext/soap/tests/server017.phpt @@ -5,7 +5,7 @@ SOAP Server 17: user fault (through return) --FILE-- "http://testuri.org")); diff --git a/ext/soap/tests/server018.phpt b/ext/soap/tests/server018.phpt index b033ed9c571f..2c379d85dd20 100644 --- a/ext/soap/tests/server018.phpt +++ b/ext/soap/tests/server018.phpt @@ -5,7 +5,7 @@ SOAP Server 18: user fault (through throw) --FILE-- "http://testuri.org")); diff --git a/ext/soap/tests/server022.phpt b/ext/soap/tests/server022.phpt index ff79a1518ff8..82270f8eefb0 100644 --- a/ext/soap/tests/server022.phpt +++ b/ext/soap/tests/server022.phpt @@ -5,14 +5,14 @@ SOAP Server 22: user fault (through throw of subclass) --FILE-- "http://testuri.org")); diff --git a/ext/soap/tests/server023.phpt b/ext/soap/tests/server023.phpt index 5614599f3ae4..07f3aea55498 100644 --- a/ext/soap/tests/server023.phpt +++ b/ext/soap/tests/server023.phpt @@ -5,10 +5,10 @@ SOAP Server 23: Send SOAP headers those were not received --FILE-- addSoapHeader(new SoapHeader("http://testuri.org", "Test1", "Hello Header!")); - $server->addSoapHeader(new SoapHeader("http://testuri.org", "Test2", "Hello Header!")); - return "Hello Body!"; + global $server; + $server->addSoapHeader(new SoapHeader("http://testuri.org", "Test1", "Hello Header!")); + $server->addSoapHeader(new SoapHeader("http://testuri.org", "Test2", "Hello Header!")); + return "Hello Body!"; } $server = new soapserver(null,array('uri'=>"http://testuri.org")); diff --git a/ext/soap/tests/server024.phpt b/ext/soap/tests/server024.phpt index 7db30621d323..63cf06cd023e 100644 --- a/ext/soap/tests/server024.phpt +++ b/ext/soap/tests/server024.phpt @@ -5,22 +5,22 @@ SOAP Server 24: Send SOAP headers those were not received --FILE-- addSoapHeader(new TestHeader1("Hello Header!")); - $server->addSoapHeader(new TestHeader2("Hello Header!")); - return "Hello Body!"; + global $server; + $server->addSoapHeader(new TestHeader1("Hello Header!")); + $server->addSoapHeader(new TestHeader2("Hello Header!")); + return "Hello Body!"; } $server = new soapserver(null,array('uri'=>"http://testuri.org")); diff --git a/ext/soap/tests/server025.phpt b/ext/soap/tests/server025.phpt index 5366c7ad9155..871134f9356d 100644 --- a/ext/soap/tests/server025.phpt +++ b/ext/soap/tests/server025.phpt @@ -7,22 +7,22 @@ soap.wsdl_cache_enabled=0 --FILE-- addSoapHeader(new TestHeader1("Hello Header!")); - $server->addSoapHeader(new TestHeader2("Hello Header!")); - return "Hello Body!"; + global $server; + $server->addSoapHeader(new TestHeader1("Hello Header!")); + $server->addSoapHeader(new TestHeader2("Hello Header!")); + return "Hello Body!"; } $server = new soapserver(__DIR__."/server025.wsdl"); diff --git a/ext/soap/tests/server031.phpt b/ext/soap/tests/server031.phpt index c9f8d95f8e7a..987ad4ab596b 100644 --- a/ext/soap/tests/server031.phpt +++ b/ext/soap/tests/server031.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- a = $a; - } + public function __construct(array $a) { + $this->a = $a; + } public function rewind() { return reset($this->a); } public function current() { return current($this->a); } @@ -23,26 +23,26 @@ class ItemArray implements Iterator { class Item { public $text; - public function __construct($n) { - $this->text = 'text'.$n; - } + public function __construct($n) { + $this->text = 'text'.$n; + } } class handlerClass { public function getItems() { return new ItemArray(array( - new Item(0), - new Item(1), - new Item(2), - new Item(3), - new Item(4), - new Item(5), - new Item(6), - new Item(7), - new Item(8), - new Item(9) - )); + new Item(0), + new Item(1), + new Item(2), + new Item(3), + new Item(4), + new Item(5), + new Item(6), + new Item(7), + new Item(8), + new Item(9) + )); } } diff --git a/ext/soap/tests/soap12/T01.phpt b/ext/soap/tests/soap12/T01.phpt index d584812d0982..45aadbad861e 100644 --- a/ext/soap/tests/soap12/T01.phpt +++ b/ext/soap/tests/soap12/T01.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T01 echoOk - + foo diff --git a/ext/soap/tests/soap12/T02.phpt b/ext/soap/tests/soap12/T02.phpt index db2c260684a5..d7f9880143f6 100644 --- a/ext/soap/tests/soap12/T02.phpt +++ b/ext/soap/tests/soap12/T02.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T02 echoOk - + foo diff --git a/ext/soap/tests/soap12/T03.phpt b/ext/soap/tests/soap12/T03.phpt index 19c29dd3dd3e..1d7aa3b0d313 100644 --- a/ext/soap/tests/soap12/T03.phpt +++ b/ext/soap/tests/soap12/T03.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T03 echoOk - + foo diff --git a/ext/soap/tests/soap12/T04.phpt b/ext/soap/tests/soap12/T04.phpt index 7445caedee6a..2bef7626d860 100644 --- a/ext/soap/tests/soap12/T04.phpt +++ b/ext/soap/tests/soap12/T04.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T04 echoOk - + foo diff --git a/ext/soap/tests/soap12/T05.phpt b/ext/soap/tests/soap12/T05.phpt index 187eb2ee8378..c5e0054eb3ca 100644 --- a/ext/soap/tests/soap12/T05.phpt +++ b/ext/soap/tests/soap12/T05.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T05 echoOk - + foo diff --git a/ext/soap/tests/soap12/T10.phpt b/ext/soap/tests/soap12/T10.phpt index 54186f6a0db2..6c2a3ea41775 100644 --- a/ext/soap/tests/soap12/T10.phpt +++ b/ext/soap/tests/soap12/T10.phpt @@ -6,9 +6,9 @@ SOAP 1.2: T10 unknownHdr - + - foo diff --git a/ext/soap/tests/soap12/T11.phpt b/ext/soap/tests/soap12/T11.phpt index 3423d54329a4..d805596bede6 100644 --- a/ext/soap/tests/soap12/T11.phpt +++ b/ext/soap/tests/soap12/T11.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T11 unknownHdr - + - + - + - + - + - + - + - foo diff --git a/ext/soap/tests/soap12/T23.phpt b/ext/soap/tests/soap12/T23.phpt index c676fb176cfa..095e5e725fdb 100644 --- a/ext/soap/tests/soap12/T23.phpt +++ b/ext/soap/tests/soap12/T23.phpt @@ -6,11 +6,11 @@ SOAP 1.2: T23 echoOk - + - foo - foo diff --git a/ext/soap/tests/soap12/T24.phpt b/ext/soap/tests/soap12/T24.phpt index ebee3b764a4c..97bd56cf47ec 100644 --- a/ext/soap/tests/soap12/T24.phpt +++ b/ext/soap/tests/soap12/T24.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T24 echoOk - + foo diff --git a/ext/soap/tests/soap12/T25.phpt b/ext/soap/tests/soap12/T25.phpt index ac45e9c52ddd..ac5e1a0efd56 100644 --- a/ext/soap/tests/soap12/T25.phpt +++ b/ext/soap/tests/soap12/T25.phpt @@ -7,7 +7,7 @@ SOAP 1.2: T25 echoOk $HTTP_RAW_POST_DATA = << - + foo diff --git a/ext/soap/tests/soap12/T26.phpt b/ext/soap/tests/soap12/T26.phpt index 53c8cec49507..8b23ba7b6361 100644 --- a/ext/soap/tests/soap12/T26.phpt +++ b/ext/soap/tests/soap12/T26.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T26 echoOk - + foo diff --git a/ext/soap/tests/soap12/T27.phpt b/ext/soap/tests/soap12/T27.phpt index 81db8ee5bc9f..3cb42940be4b 100644 --- a/ext/soap/tests/soap12/T27.phpt +++ b/ext/soap/tests/soap12/T27.phpt @@ -9,14 +9,14 @@ $HTTP_RAW_POST_DATA = << - 1 - + diff --git a/ext/soap/tests/soap12/T28.phpt b/ext/soap/tests/soap12/T28.phpt index 751df133dbd4..019cabcdb972 100644 --- a/ext/soap/tests/soap12/T28.phpt +++ b/ext/soap/tests/soap12/T28.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T28 echoOk - + foo diff --git a/ext/soap/tests/soap12/T29.phpt b/ext/soap/tests/soap12/T29.phpt index 3784da4030ac..85a3a61ae1e4 100644 --- a/ext/soap/tests/soap12/T29.phpt +++ b/ext/soap/tests/soap12/T29.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T29 echoOk - + foo diff --git a/ext/soap/tests/soap12/T31.phpt b/ext/soap/tests/soap12/T31.phpt index f00e25a59af9..689f62bd0094 100644 --- a/ext/soap/tests/soap12/T31.phpt +++ b/ext/soap/tests/soap12/T31.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T31 returnVoid - + diff --git a/ext/soap/tests/soap12/T32.phpt b/ext/soap/tests/soap12/T32.phpt index 8f77873f4c7f..7d9dc1006ad5 100644 --- a/ext/soap/tests/soap12/T32.phpt +++ b/ext/soap/tests/soap12/T32.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T32 echoHeader - + foo diff --git a/ext/soap/tests/soap12/T33.phpt b/ext/soap/tests/soap12/T33.phpt index 00ded875b559..76f90bce1bc5 100644 --- a/ext/soap/tests/soap12/T33.phpt +++ b/ext/soap/tests/soap12/T33.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T33 nonexistentMethod - + diff --git a/ext/soap/tests/soap12/T34.phpt b/ext/soap/tests/soap12/T34.phpt index 39e0095d43f4..873013cbc8fd 100644 --- a/ext/soap/tests/soap12/T34.phpt +++ b/ext/soap/tests/soap12/T34.phpt @@ -6,9 +6,9 @@ SOAP 1.2: T34 unknownHdr - + - foo diff --git a/ext/soap/tests/soap12/T35.phpt b/ext/soap/tests/soap12/T35.phpt index a736010ce0e0..b6511e8e80f8 100644 --- a/ext/soap/tests/soap12/T35.phpt +++ b/ext/soap/tests/soap12/T35.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T35 unknownHdr - + diff --git a/ext/soap/tests/soap12/T36.phpt b/ext/soap/tests/soap12/T36.phpt index d625813942cb..b1efaeaf90f2 100644 --- a/ext/soap/tests/soap12/T36.phpt +++ b/ext/soap/tests/soap12/T36.phpt @@ -6,10 +6,10 @@ SOAP 1.2: T36 unknownHdr - + foo diff --git a/ext/soap/tests/soap12/T37.phpt b/ext/soap/tests/soap12/T37.phpt index cdce8a4429dd..848c0a4aa44d 100644 --- a/ext/soap/tests/soap12/T37.phpt +++ b/ext/soap/tests/soap12/T37.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T37 unknownHdr - + foo diff --git a/ext/soap/tests/soap12/T38_1.phpt b/ext/soap/tests/soap12/T38_1.phpt index 30007e55ef34..8bc8cf185bec 100644 --- a/ext/soap/tests/soap12/T38_1.phpt +++ b/ext/soap/tests/soap12/T38_1.phpt @@ -6,13 +6,13 @@ SOAP 1.2: T38.1 doubleHdr - + foo foo diff --git a/ext/soap/tests/soap12/T38_2.phpt b/ext/soap/tests/soap12/T38_2.phpt index efff2f4db3f7..8408ab783f88 100644 --- a/ext/soap/tests/soap12/T38_2.phpt +++ b/ext/soap/tests/soap12/T38_2.phpt @@ -6,13 +6,13 @@ SOAP 1.2: T38.2 doubleHdr - + foo bar diff --git a/ext/soap/tests/soap12/T39.phpt b/ext/soap/tests/soap12/T39.phpt index 2b29562aba97..f4ddcc9d204e 100644 --- a/ext/soap/tests/soap12/T39.phpt +++ b/ext/soap/tests/soap12/T39.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T39 unknownHdr - + foo diff --git a/ext/soap/tests/soap12/T40.phpt b/ext/soap/tests/soap12/T40.phpt index 332e5768dd16..281430932113 100644 --- a/ext/soap/tests/soap12/T40.phpt +++ b/ext/soap/tests/soap12/T40.phpt @@ -6,10 +6,10 @@ SOAP 1.2: T40 echoOK - + foo diff --git a/ext/soap/tests/soap12/T46.phpt b/ext/soap/tests/soap12/T46.phpt index fe091323f131..fbbf543fdf28 100644 --- a/ext/soap/tests/soap12/T46.phpt +++ b/ext/soap/tests/soap12/T46.phpt @@ -18,7 +18,7 @@ $HTTP_RAW_POST_DATA = <<0.005 hello world + xmlns:enc="http://www.w3.org/2003/05/soap-encoding"> red blue green diff --git a/ext/soap/tests/soap12/T49.phpt b/ext/soap/tests/soap12/T49.phpt index 9687d03b94d2..01ac0e679f43 100644 --- a/ext/soap/tests/soap12/T49.phpt +++ b/ext/soap/tests/soap12/T49.phpt @@ -7,7 +7,7 @@ SOAP 1.2: T49 echoStringArray $HTTP_RAW_POST_DATA = << - - 1 - + diff --git a/ext/soap/tests/soap12/T59.phpt b/ext/soap/tests/soap12/T59.phpt index 2ceef325bb29..4c0ec5a38219 100644 --- a/ext/soap/tests/soap12/T59.phpt +++ b/ext/soap/tests/soap12/T59.phpt @@ -7,12 +7,12 @@ SOAP 1.2: T59 echoStringArray $HTTP_RAW_POST_DATA = << - hello world diff --git a/ext/soap/tests/soap12/T63.phpt b/ext/soap/tests/soap12/T63.phpt index 5a41ef010913..72b9ca35f5fb 100644 --- a/ext/soap/tests/soap12/T63.phpt +++ b/ext/soap/tests/soap12/T63.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T63 validateCountryCode - + ]> - + foo diff --git a/ext/soap/tests/soap12/T65.phpt b/ext/soap/tests/soap12/T65.phpt index cd96d4a82f87..e89ce995d818 100644 --- a/ext/soap/tests/soap12/T65.phpt +++ b/ext/soap/tests/soap12/T65.phpt @@ -11,7 +11,7 @@ $HTTP_RAW_POST_DATA = << ]> - + foo diff --git a/ext/soap/tests/soap12/T66.phpt b/ext/soap/tests/soap12/T66.phpt index cc7cc2e3e3b3..23586b8ee718 100644 --- a/ext/soap/tests/soap12/T66.phpt +++ b/ext/soap/tests/soap12/T66.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T66 echoOk - + foo diff --git a/ext/soap/tests/soap12/T67.phpt b/ext/soap/tests/soap12/T67.phpt index ddc527a6ec3c..dd197a1b82ff 100644 --- a/ext/soap/tests/soap12/T67.phpt +++ b/ext/soap/tests/soap12/T67.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T67 echoOk - + foo diff --git a/ext/soap/tests/soap12/T68.phpt b/ext/soap/tests/soap12/T68.phpt index acf42309736f..0dfa08ff16a1 100644 --- a/ext/soap/tests/soap12/T68.phpt +++ b/ext/soap/tests/soap12/T68.phpt @@ -5,7 +5,7 @@ SOAP 1.2: T68 echoOk --FILE-- + diff --git a/ext/soap/tests/soap12/T69.phpt b/ext/soap/tests/soap12/T69.phpt index 0fb02dec0680..8a64745f959e 100644 --- a/ext/soap/tests/soap12/T69.phpt +++ b/ext/soap/tests/soap12/T69.phpt @@ -8,7 +8,7 @@ $HTTP_RAW_POST_DATA = << - foo + foo EOF; diff --git a/ext/soap/tests/soap12/T70.phpt b/ext/soap/tests/soap12/T70.phpt index 3622c320e74b..9b665bf176e8 100644 --- a/ext/soap/tests/soap12/T70.phpt +++ b/ext/soap/tests/soap12/T70.phpt @@ -8,7 +8,7 @@ $HTTP_RAW_POST_DATA = << - foo + foo diff --git a/ext/soap/tests/soap12/T71.phpt b/ext/soap/tests/soap12/T71.phpt index fdb5b8d46066..dffaf585d384 100644 --- a/ext/soap/tests/soap12/T71.phpt +++ b/ext/soap/tests/soap12/T71.phpt @@ -9,7 +9,7 @@ $HTTP_RAW_POST_DATA = << - + foo diff --git a/ext/soap/tests/soap12/T72.phpt b/ext/soap/tests/soap12/T72.phpt index b8f5060c6bc0..3b4db8c3f3d7 100644 --- a/ext/soap/tests/soap12/T72.phpt +++ b/ext/soap/tests/soap12/T72.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T72 echoOk - diff --git a/ext/soap/tests/soap12/T74.phpt b/ext/soap/tests/soap12/T74.phpt index 703e1870a629..4f210b642eb3 100644 --- a/ext/soap/tests/soap12/T74.phpt +++ b/ext/soap/tests/soap12/T74.phpt @@ -6,12 +6,12 @@ SOAP 1.2: T74 doubleHdr - + foo - diff --git a/ext/soap/tests/soap12/T75.phpt b/ext/soap/tests/soap12/T75.phpt index 3e2166d957b7..cdee965db012 100644 --- a/ext/soap/tests/soap12/T75.phpt +++ b/ext/soap/tests/soap12/T75.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T75 echoResolvedRef - + - diff --git a/ext/soap/tests/soap12/T77_1.phpt b/ext/soap/tests/soap12/T77_1.phpt index d847b6cfd884..3cf3f4358a71 100644 --- a/ext/soap/tests/soap12/T77_1.phpt +++ b/ext/soap/tests/soap12/T77_1.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T77.1 isNil - diff --git a/ext/soap/tests/soap12/T77_2.phpt b/ext/soap/tests/soap12/T77_2.phpt index c829b57892a3..4d18b374dc1c 100644 --- a/ext/soap/tests/soap12/T77_2.phpt +++ b/ext/soap/tests/soap12/T77_2.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T77.2 isNil - diff --git a/ext/soap/tests/soap12/T77_3.phpt b/ext/soap/tests/soap12/T77_3.phpt index 0e1355a5a281..1242daf0ea99 100644 --- a/ext/soap/tests/soap12/T77_3.phpt +++ b/ext/soap/tests/soap12/T77_3.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T77.3 isNul - diff --git a/ext/soap/tests/soap12/T78.phpt b/ext/soap/tests/soap12/T78.phpt index 63d13c7cae17..228a88ad430e 100644 --- a/ext/soap/tests/soap12/T78.phpt +++ b/ext/soap/tests/soap12/T78.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T78 echoOk - + foo diff --git a/ext/soap/tests/soap12/T80.phpt b/ext/soap/tests/soap12/T80.phpt index 1ac114ba3288..e987338ea8e7 100644 --- a/ext/soap/tests/soap12/T80.phpt +++ b/ext/soap/tests/soap12/T80.phpt @@ -6,7 +6,7 @@ SOAP 1.2: T80 echoOk - + foo diff --git a/ext/soap/tests/soap12/soap12-test.inc b/ext/soap/tests/soap12/soap12-test.inc index e27712241f5b..550494e51655 100644 --- a/ext/soap/tests/soap12/soap12-test.inc +++ b/ext/soap/tests/soap12/soap12-test.inc @@ -1,124 +1,124 @@ $struct->varString, - 'outputInteger' => $struct->varInt, - 'outputFloat' => $struct->varFloat); - } - - function echoSimpleTypesAsStruct($string, $int, $float) { - return (object)array("varString" => $string, - "varInt" => $int, - "varFloat" => $float); - } - - function echoNestedStruct($struct) { - return $struct; - } - - function echo2DStringArray($ary) { - return $ary; - } - - function echoNestedArray($ary) { - return $ary; - } - - function countItems($input) { - return count($input); - } - - function isNil($input=NULL) { - return is_null($input); - } - - function returnVoid() { - } - - function emptyBody() { - } - - function requiredHeader($x) { - $this->header = $x; - } - - function echoHeader() { - return $this->header; - } - - function echoResolvedRef($ref) { - return $ref->RelativeReference->base.$ref->RelativeReference->href; - } - - function validateCountryCode($code) { - if (strlen($code) != 2) { - return new SoapFault("Client", "Not a valid country code", NULL, NULL, NULL, new SoapHeader("http://example.org/ts-tests", "validateCountryCodeFault", "Country code must be 2 letters.")); - } else { - return "OK"; - } - } + function echoDate($timeInstant) { + return $timeInstant; + } + + function echoHexBinary($hb) { + return $hb; + } + + function echoDecimal($dec) { + return $dec; + } + + function echoBoolean($boolean) { + return $boolean; + } + + function echoStructAsSimpleTypes ($struct) { + return array('outputString' => $struct->varString, + 'outputInteger' => $struct->varInt, + 'outputFloat' => $struct->varFloat); + } + + function echoSimpleTypesAsStruct($string, $int, $float) { + return (object)array("varString" => $string, + "varInt" => $int, + "varFloat" => $float); + } + + function echoNestedStruct($struct) { + return $struct; + } + + function echo2DStringArray($ary) { + return $ary; + } + + function echoNestedArray($ary) { + return $ary; + } + + function countItems($input) { + return count($input); + } + + function isNil($input=NULL) { + return is_null($input); + } + + function returnVoid() { + } + + function emptyBody() { + } + + function requiredHeader($x) { + $this->header = $x; + } + + function echoHeader() { + return $this->header; + } + + function echoResolvedRef($ref) { + return $ref->RelativeReference->base.$ref->RelativeReference->href; + } + + function validateCountryCode($code) { + if (strlen($code) != 2) { + return new SoapFault("Client", "Not a valid country code", NULL, NULL, NULL, new SoapHeader("http://example.org/ts-tests", "validateCountryCodeFault", "Country code must be 2 letters.")); + } else { + return "OK"; + } + } } diff --git a/ext/soap/tests/typemap001.phpt b/ext/soap/tests/typemap001.phpt index c582406f4123..04c72eb836f2 100644 --- a/ext/soap/tests/typemap001.phpt +++ b/ext/soap/tests/typemap001.phpt @@ -8,11 +8,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -26,31 +26,31 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_from_xml($xml) { - $sxe = simplexml_load_string($xml); - $obj = new book; - $obj->a = (string)$sxe->a; - $obj->b = (string)$sxe->b; - return $obj; + $sxe = simplexml_load_string($xml); + $obj = new book; + $obj->a = (string)$sxe->a; + $obj->b = (string)$sxe->b; + return $obj; } class test{ - function dotest($book){ - $classname=get_class($book); - return "Object: ".$classname. "(".$book->a.",".$book->b.")"; - } + function dotest($book){ + $classname=get_class($book); + return "Object: ".$classname. "(".$book->a.",".$book->b.")"; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "from_xml" => "book_from_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "from_xml" => "book_from_xml")) + ); $server = new SoapServer(__DIR__."/classmap.wsdl",$options); $server->setClass("test"); diff --git a/ext/soap/tests/typemap002.phpt b/ext/soap/tests/typemap002.phpt index 84ef043ac3fa..551d8ee71f0f 100644 --- a/ext/soap/tests/typemap002.phpt +++ b/ext/soap/tests/typemap002.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -22,30 +22,30 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_to_xml($book) { - return ''.$book->a.'!'.$book->b.'!'; + return ''.$book->a.'!'.$book->b.'!'; } class test{ - function dotest2($str){ - $book = new book; - $book->a = "foo"; - $book->b = "bar"; - return $book; - } + function dotest2($str){ + $book = new book; + $book->a = "foo"; + $book->b = "bar"; + return $book; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $server = new SoapServer(__DIR__."/classmap.wsdl",$options); $server->setClass("test"); diff --git a/ext/soap/tests/typemap003.phpt b/ext/soap/tests/typemap003.phpt index 0770d1be67ff..2cd0ac64e4b0 100644 --- a/ext/soap/tests/typemap003.phpt +++ b/ext/soap/tests/typemap003.phpt @@ -9,7 +9,7 @@ soap.wsdl_cache_enabled=0 @@ -18,29 +18,29 @@ class TestSoapClient extends SoapClient{ EOF; - } + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } function book_from_xml($xml) { - $sxe = simplexml_load_string($xml); - $obj = new book; - $obj->a = (string)$sxe->a; - $obj->b = (string)$sxe->b; - return $obj; + $sxe = simplexml_load_string($xml); + $obj = new book; + $obj->a = (string)$sxe->a; + $obj->b = (string)$sxe->b; + return $obj; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "from_xml" => "book_from_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "from_xml" => "book_from_xml")) + ); $client = new TestSoapClient(__DIR__."/classmap.wsdl",$options); $ret = $client->dotest2("???"); diff --git a/ext/soap/tests/typemap004.phpt b/ext/soap/tests/typemap004.phpt index 07d489db95a5..bf0a643abe2e 100644 --- a/ext/soap/tests/typemap004.phpt +++ b/ext/soap/tests/typemap004.phpt @@ -8,27 +8,27 @@ soap.wsdl_cache_enabled=0 '.$book->a.'!'.$book->b.'!'; + return ''.$book->a.'!'.$book->b.'!'; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $client = new TestSoapClient(__DIR__."/classmap.wsdl",$options); $book = new book(); diff --git a/ext/soap/tests/typemap005.phpt b/ext/soap/tests/typemap005.phpt index 5a8319fab7e6..4a4c81c118bc 100644 --- a/ext/soap/tests/typemap005.phpt +++ b/ext/soap/tests/typemap005.phpt @@ -8,11 +8,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -26,32 +26,32 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_from_xml($xml) { - $sxe = simplexml_load_string($xml); - $obj = new book; - $obj->a = (string)$sxe->a; - $obj->b = (string)$sxe->b; - return $obj; + $sxe = simplexml_load_string($xml); + $obj = new book; + $obj->a = (string)$sxe->a; + $obj->b = (string)$sxe->b; + return $obj; } class test{ - function dotest($book){ - $classname=get_class($book); - return "Object: ".$classname. "(".$book->a.",".$book->b.")"; - } + function dotest($book){ + $classname=get_class($book); + return "Object: ".$classname. "(".$book->a.",".$book->b.")"; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'uri' => "http://schemas.nothing.com", - 'actor' => 'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "from_xml" => "book_from_xml")) - ); + 'uri' => "http://schemas.nothing.com", + 'actor' => 'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "from_xml" => "book_from_xml")) + ); $server = new SoapServer(NULL,$options); $server->setClass("test"); diff --git a/ext/soap/tests/typemap006.phpt b/ext/soap/tests/typemap006.phpt index 9de9e245d2f8..ca8c3351e81b 100644 --- a/ext/soap/tests/typemap006.phpt +++ b/ext/soap/tests/typemap006.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -22,31 +22,31 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_to_xml($book) { - return ''.$book->a.'!'.$book->b.'!'; + return ''.$book->a.'!'.$book->b.'!'; } class test{ - function dotest2($str){ - $book = new book; - $book->a = "foo"; - $book->b = "bar"; - return new SoapVar($book, null, "book", "http://schemas.nothing.com"); - } + function dotest2($str){ + $book = new book; + $book->a = "foo"; + $book->b = "bar"; + return new SoapVar($book, null, "book", "http://schemas.nothing.com"); + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'uri' => "http://schemas.nothing.com", - 'actor' => 'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'uri' => "http://schemas.nothing.com", + 'actor' => 'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $server = new SoapServer(NULL,$options); $server->setClass("test"); diff --git a/ext/soap/tests/typemap007.phpt b/ext/soap/tests/typemap007.phpt index 1dd2becb61a2..5b7cbd10d73a 100644 --- a/ext/soap/tests/typemap007.phpt +++ b/ext/soap/tests/typemap007.phpt @@ -9,7 +9,7 @@ soap.wsdl_cache_enabled=0 @@ -18,31 +18,31 @@ class TestSoapClient extends SoapClient{ EOF; - } + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } function book_from_xml($xml) { - $sxe = simplexml_load_string($xml); - $obj = new book; - $obj->a = (string)$sxe->a; - $obj->b = (string)$sxe->b; - return $obj; + $sxe = simplexml_load_string($xml); + $obj = new book; + $obj->a = (string)$sxe->a; + $obj->b = (string)$sxe->b; + return $obj; } $options=Array( 'uri' => 'http://schemas.nothing.com', 'location' => 'test://', - 'actor' => 'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "from_xml" => "book_from_xml")) - ); + 'actor' => 'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "from_xml" => "book_from_xml")) + ); $client = new TestSoapClient(NULL, $options); $ret = $client->dotest2("???"); diff --git a/ext/soap/tests/typemap008.phpt b/ext/soap/tests/typemap008.phpt index 4ba1fb5befbf..c4bd649f511b 100644 --- a/ext/soap/tests/typemap008.phpt +++ b/ext/soap/tests/typemap008.phpt @@ -8,29 +8,29 @@ soap.wsdl_cache_enabled=0 '.$book->a.'!'.$book->b.'!'; + return ''.$book->a.'!'.$book->b.'!'; } $options=Array( 'uri' => 'http://schemas.nothing.com', 'location' => 'test://', - 'actor' => 'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'actor' => 'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $client = new TestSoapClient(NULL, $options); $book = new book(); diff --git a/ext/soap/tests/typemap009.phpt b/ext/soap/tests/typemap009.phpt index 37e73edecace..a36a64136f1b 100644 --- a/ext/soap/tests/typemap009.phpt +++ b/ext/soap/tests/typemap009.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -25,27 +25,27 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_from_xml($xml) { - throw new SoapFault("Server", "Conversion Failed"); + throw new SoapFault("Server", "Conversion Failed"); } class test{ - function dotest($book){ - $classname=get_class($book); - return "Object: ".$classname. "(".$book->a.",".$book->b.")"; - } + function dotest($book){ + $classname=get_class($book); + return "Object: ".$classname. "(".$book->a.",".$book->b.")"; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "from_xml" => "book_from_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "from_xml" => "book_from_xml")) + ); $server = new SoapServer(__DIR__."/classmap.wsdl",$options); $server->setClass("test"); diff --git a/ext/soap/tests/typemap010.phpt b/ext/soap/tests/typemap010.phpt index 46e9909a62d4..fde89a4603e5 100644 --- a/ext/soap/tests/typemap010.phpt +++ b/ext/soap/tests/typemap010.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -22,30 +22,30 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_to_xml($book) { - throw new SoapFault("Server", "Conversion Fault"); + throw new SoapFault("Server", "Conversion Fault"); } class test{ - function dotest2($str){ - $book = new book; - $book->a = "foo"; - $book->b = "bar"; - return $book; - } + function dotest2($str){ + $book = new book; + $book->a = "foo"; + $book->b = "bar"; + return $book; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $server = new SoapServer(__DIR__."/classmap.wsdl",$options); $server->setClass("test"); diff --git a/ext/soap/tests/typemap011.phpt b/ext/soap/tests/typemap011.phpt index ac6b9f392403..b0c75ce0c7ca 100644 --- a/ext/soap/tests/typemap011.phpt +++ b/ext/soap/tests/typemap011.phpt @@ -8,7 +8,7 @@ soap.wsdl_cache_enabled=0 @@ -17,31 +17,31 @@ class TestSoapClient extends SoapClient{ EOF; - } + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } function book_from_xml($xml) { - throw new SoapFault("Client", "Conversion Error"); + throw new SoapFault("Client", "Conversion Error"); } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "from_xml" => "book_from_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "from_xml" => "book_from_xml")) + ); $client = new TestSoapClient(__DIR__."/classmap.wsdl",$options); try { - $ret = $client->dotest2("???"); + $ret = $client->dotest2("???"); } catch (SoapFault $e) { - $ret = "SoapFault = " . $e->faultcode . " - " . $e->faultstring; + $ret = "SoapFault = " . $e->faultcode . " - " . $e->faultstring; } var_dump($ret); echo "ok\n"; diff --git a/ext/soap/tests/typemap012.phpt b/ext/soap/tests/typemap012.phpt index 837ae1fd8007..039a4f9ba769 100644 --- a/ext/soap/tests/typemap012.phpt +++ b/ext/soap/tests/typemap012.phpt @@ -8,36 +8,36 @@ soap.wsdl_cache_enabled=0 'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $client = new TestSoapClient(__DIR__."/classmap.wsdl",$options); $book = new book(); $book->a = "foo"; $book->b = "bar"; try { - $ret = $client->dotest($book); + $ret = $client->dotest($book); } catch (SoapFault $e) { - $ret = "SoapFault = " . $e->faultcode . " - " . $e->faultstring; + $ret = "SoapFault = " . $e->faultcode . " - " . $e->faultstring; } var_dump($ret); echo "ok\n"; diff --git a/ext/soap/tests/typemap013.phpt b/ext/soap/tests/typemap013.phpt index 6d414fdbc006..f73a257d75d0 100644 --- a/ext/soap/tests/typemap013.phpt +++ b/ext/soap/tests/typemap013.phpt @@ -7,11 +7,11 @@ soap.wsdl_cache_enabled=0 --FILE-- @@ -22,30 +22,30 @@ $GLOBALS['HTTP_RAW_POST_DATA']=" "; function book_to_xml($book) { - return ''.$book->a.'!'.$book->b.'!'; + return ''.$book->a.'!'.$book->b.'!'; } class test{ - function dotest2($str){ - $book = new book; - $book->a = "foo"; - $book->b = "bar"; - return $book; - } + function dotest2($str){ + $book = new book; + $book->a = "foo"; + $book->b = "bar"; + return $book; + } } class book{ - public $a="a"; - public $b="c"; + public $a="a"; + public $b="c"; } $options=Array( - 'actor' =>'http://schemas.nothing.com', - 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", - "type_name" => "book", - "to_xml" => "book_to_xml")) - ); + 'actor' =>'http://schemas.nothing.com', + 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", + "type_name" => "book", + "to_xml" => "book_to_xml")) + ); $server = new SoapServer(__DIR__."/classmap.wsdl",$options); $server->setClass("test"); diff --git a/ext/sockets/tests/ipv4loop.phpt b/ext/sockets/tests/ipv4loop.phpt index 7d72992012c3..4e5d15453bc4 100644 --- a/ext/sockets/tests/ipv4loop.phpt +++ b/ext/sockets/tests/ipv4loop.phpt @@ -8,45 +8,45 @@ IPv4 Loopback test ?> --FILE-- --EXPECT-- string(10) "ABCdef123 diff --git a/ext/sockets/tests/ipv6_skipif.inc b/ext/sockets/tests/ipv6_skipif.inc index 8c723a0b2003..b2a28bfb02aa 100644 --- a/ext/sockets/tests/ipv6_skipif.inc +++ b/ext/sockets/tests/ipv6_skipif.inc @@ -1,7 +1,7 @@ --FILE-- --EXPECT-- string(10) "ABCdef123 diff --git a/ext/sockets/tests/mcast_helpers.php.inc b/ext/sockets/tests/mcast_helpers.php.inc index ad65a3f9d62b..7b73a9d77ab7 100644 --- a/ext/sockets/tests/mcast_helpers.php.inc +++ b/ext/sockets/tests/mcast_helpers.php.inc @@ -1,8 +1,8 @@ $mcastaddr, - "interface" => $interface, + "group" => $mcastaddr, + "interface" => $interface, )); var_dump($so); @@ -54,101 +54,101 @@ var_dump($r); $i = 0; checktimeout($s, 500); while (($str = socket_read($s, 3000)) !== FALSE) { - $i++; - echo "$i> ", $str, "\n"; + $i++; + echo "$i> ", $str, "\n"; if ($i == 1) { - echo "leaving group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); - var_dump($r); + echo "leaving group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); + var_dump($r); } if ($i == 2) { - echo "re-joining group\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends2, $m = "ignored mcast packet (different interface)", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "re-joining group\n"; + $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends2, $m = "ignored mcast packet (different interface)", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 3) { - echo "blocking source\n"; - $so = socket_set_option($s, $level, MCAST_BLOCK_SOURCE, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); - var_dump($r); + echo "blocking source\n"; + $so = socket_set_option($s, $level, MCAST_BLOCK_SOURCE, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); + var_dump($r); } if ($i == 4) { - echo "unblocking source\n"; - $so = socket_set_option($s, $level, MCAST_UNBLOCK_SOURCE, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "unblocking source\n"; + $so = socket_set_option($s, $level, MCAST_UNBLOCK_SOURCE, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 5) { - echo "leaving group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); - var_dump($r); + echo "leaving group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); + var_dump($r); } if ($i == 6) { - echo "joining source group\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_SOURCE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "joining source group\n"; + $so = socket_set_option($s, $level, MCAST_JOIN_SOURCE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 7) { - echo "leaving source group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); - var_dump($r); + echo "leaving source group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000); + var_dump($r); } if ($i == 8) { /* echo "rjsg\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so);*/ - break; + $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so);*/ + break; } } diff --git a/ext/sockets/tests/mcast_ipv6_recv.phpt b/ext/sockets/tests/mcast_ipv6_recv.phpt index 62fa1a9c4d3e..10233b49a57e 100644 --- a/ext/sockets/tests/mcast_ipv6_recv.phpt +++ b/ext/sockets/tests/mcast_ipv6_recv.phpt @@ -63,8 +63,8 @@ $br = socket_bind($s, '::0', 3000) or die("err"); var_dump($br); $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, + "group" => $mcastaddr, + "interface" => $interface, )) or die("err"); var_dump($so); @@ -81,100 +81,100 @@ var_dump($r); $i = 0; checktimeout($s, 500); while (($str = socket_read($s, 3000)) !== FALSE) { - $i++; - echo "$i> ", $str, "\n"; + $i++; + echo "$i> ", $str, "\n"; if ($i == 1) { - echo "leaving group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); - var_dump($r); + echo "leaving group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); + var_dump($r); } if ($i == 2) { - echo "re-joining group\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "re-joining group\n"; + $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 3) { - echo "blocking source\n"; - $so = socket_set_option($s, $level, MCAST_BLOCK_SOURCE, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); - var_dump($r); + echo "blocking source\n"; + $so = socket_set_option($s, $level, MCAST_BLOCK_SOURCE, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); + var_dump($r); } if ($i == 4) { - echo "unblocking source\n"; - $so = socket_set_option($s, $level, MCAST_UNBLOCK_SOURCE, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "unblocking source\n"; + $so = socket_set_option($s, $level, MCAST_UNBLOCK_SOURCE, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 5) { - echo "leaving group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); - var_dump($r); + echo "leaving group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); + var_dump($r); } if ($i == 6) { - echo "joining source group\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_SOURCE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "mcast packet from desired source", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "joining source group\n"; + $so = socket_set_option($s, $level, MCAST_JOIN_SOURCE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "mcast packet from desired source", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 7) { - echo "leaving source group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); - var_dump($r); + echo "leaving source group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); + var_dump($r); } if ($i == 8) { - /*echo "joining source group\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_SOURCE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - "source" => $sblock, - )); - var_dump($so);*/ - break; + /*echo "joining source group\n"; + $so = socket_set_option($s, $level, MCAST_JOIN_SOURCE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + "source" => $sblock, + )); + var_dump($so);*/ + break; } } diff --git a/ext/sockets/tests/mcast_ipv6_recv_limited.phpt b/ext/sockets/tests/mcast_ipv6_recv_limited.phpt index c7392640624b..87b38c144c1c 100644 --- a/ext/sockets/tests/mcast_ipv6_recv_limited.phpt +++ b/ext/sockets/tests/mcast_ipv6_recv_limited.phpt @@ -58,8 +58,8 @@ $br = socket_bind($s, '::0', 3000) or die("err"); var_dump($br); $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, + "group" => $mcastaddr, + "interface" => $interface, )) or die("err"); var_dump($so); @@ -76,33 +76,33 @@ var_dump($r); $i = 0; checktimeout($s, 500); while (($str = socket_read($s, 3000, 500)) !== FALSE) { - $i++; - echo "$i> ", $str, "\n"; + $i++; + echo "$i> ", $str, "\n"; if ($i == 1) { - echo "leaving group\n"; - $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); - $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); - var_dump($r); + echo "leaving group\n"; + $so = socket_set_option($s, $level, MCAST_LEAVE_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); + $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000); + var_dump($r); } if ($i == 2) { - echo "re-joining group\n"; - $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( - "group" => $mcastaddr, - "interface" => $interface, - )); - var_dump($so); - $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); - var_dump($r); + echo "re-joining group\n"; + $so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array( + "group" => $mcastaddr, + "interface" => $interface, + )); + var_dump($so); + $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000); + var_dump($r); } if ($i == 3) { - break; + break; } } diff --git a/ext/sockets/tests/socket_abstract_path.phpt b/ext/sockets/tests/socket_abstract_path.phpt index 4c89dc42385f..bbe4debeaa58 100644 --- a/ext/sockets/tests/socket_abstract_path.phpt +++ b/ext/sockets/tests/socket_abstract_path.phpt @@ -28,8 +28,8 @@ socket_connect($clients, $path) or die("Error connecting"); $conns = socket_accept($servers) or die("Could not accept connection"); $r = socket_sendmsg($clients, [ - //"name" => [ "addr" => $path, ], - "iov" => ["test ", "thing", "\n"], + //"name" => [ "addr" => $path, ], + "iov" => ["test ", "thing", "\n"], ], 0); var_dump($r); checktimeout($conns, 500); diff --git a/ext/sockets/tests/socket_abstract_path_sendmsg.phpt b/ext/sockets/tests/socket_abstract_path_sendmsg.phpt index e8499e021c18..ca9ab3f5348b 100644 --- a/ext/sockets/tests/socket_abstract_path_sendmsg.phpt +++ b/ext/sockets/tests/socket_abstract_path_sendmsg.phpt @@ -24,8 +24,8 @@ $s = socket_create(AF_UNIX, SOCK_DGRAM, 0) or die("err"); socket_bind($s, $path) or die("err"); $r = socket_sendmsg($sends1, [ - "name" => [ "path" => $path], - "iov" => ["test ", "thing", "\n"], + "name" => [ "path" => $path], + "iov" => ["test ", "thing", "\n"], ], 0); var_dump($r); checktimeout($s, 500); diff --git a/ext/sockets/tests/socket_export_stream-3.phpt b/ext/sockets/tests/socket_export_stream-3.phpt index b59c7700da7f..ac48d865b9ee 100644 --- a/ext/sockets/tests/socket_export_stream-3.phpt +++ b/ext/sockets/tests/socket_export_stream-3.phpt @@ -23,8 +23,8 @@ socket_bind($sock, '0.0.0.0', 58393); $stream = socket_export_stream($sock); var_dump($stream); $so = socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array( - "group" => '224.0.0.23', - "interface" => "lo", + "group" => '224.0.0.23', + "interface" => "lo", )); var_dump($so); diff --git a/ext/sockets/tests/socket_export_stream-4-win.phpt b/ext/sockets/tests/socket_export_stream-4-win.phpt index 1d53fef361e9..24fc604f6e2a 100644 --- a/ext/sockets/tests/socket_export_stream-4-win.phpt +++ b/ext/sockets/tests/socket_export_stream-4-win.phpt @@ -12,32 +12,32 @@ if(substr(PHP_OS, 0, 3) != 'WIN' ) { getMessage(), "\n"; - } - echo "\n"; - } - if ($sock !== null) { - echo "socket_set_block "; - try { - print_r(socket_set_block($sock)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - echo "\n"; - echo "socket_get_option "; - try { - print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - echo "\n"; - } - echo "\n"; + if ($stream !== null) { + echo "stream_set_blocking "; + try { + print_r(stream_set_blocking($stream, 0)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + if ($sock !== null) { + echo "socket_set_block "; + try { + print_r(socket_set_block($sock)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + echo "socket_get_option "; + try { + print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + echo "\n"; } echo "normal\n"; diff --git a/ext/sockets/tests/socket_export_stream-4.phpt b/ext/sockets/tests/socket_export_stream-4.phpt index 668ac648d3bd..a42c31e1238d 100644 --- a/ext/sockets/tests/socket_export_stream-4.phpt +++ b/ext/sockets/tests/socket_export_stream-4.phpt @@ -12,32 +12,32 @@ if(substr(PHP_OS, 0, 3) == 'WIN' ) { getMessage(), "\n"; - } - echo "\n"; - } - if ($sock !== null) { - echo "socket_set_block "; - try { + if ($stream !== null) { + echo "stream_set_blocking "; + try { + print_r(stream_set_blocking($stream, 0)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + if ($sock !== null) { + echo "socket_set_block "; + try { print_r(socket_set_block($sock)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } - echo "\n"; - echo "socket_get_option "; - try { + echo "\n"; + echo "socket_get_option "; + try { print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } - echo "\n"; - } - echo "\n"; + echo "\n"; + } + echo "\n"; } echo "normal\n"; diff --git a/ext/sockets/tests/socket_getpeername_ipv4loop.phpt b/ext/sockets/tests/socket_getpeername_ipv4loop.phpt index c7eb1003e040..0c242e75c1bb 100644 --- a/ext/sockets/tests/socket_getpeername_ipv4loop.phpt +++ b/ext/sockets/tests/socket_getpeername_ipv4loop.phpt @@ -11,8 +11,8 @@ Tatjana Andersen tatjana.andersen@redpill-linpro.com ?> --FILE-- --FILE-- '224.0.0.23', - "interface" => "lo", + "group" => '224.0.0.23', + "interface" => "lo", )); var_dump($so); diff --git a/ext/sockets/tests/socket_import_stream-4-win.phpt b/ext/sockets/tests/socket_import_stream-4-win.phpt index 9161db2cf136..16a9c0087ec8 100644 --- a/ext/sockets/tests/socket_import_stream-4-win.phpt +++ b/ext/sockets/tests/socket_import_stream-4-win.phpt @@ -12,32 +12,32 @@ if(substr(PHP_OS, 0, 3) != 'WIN' ) { getMessage(), "\n"; - } - echo "\n"; - } - if ($sock !== null) { - echo "socket_set_block "; - try { - print_r(socket_set_block($sock)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - echo "\n"; - echo "socket_get_option "; - try { - print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - echo "\n"; - } - echo "\n"; + if ($stream !== null) { + echo "stream_set_blocking "; + try { + print_r(stream_set_blocking($stream, 0)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + if ($sock !== null) { + echo "socket_set_block "; + try { + print_r(socket_set_block($sock)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + echo "socket_get_option "; + try { + print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + echo "\n"; } echo "normal\n"; diff --git a/ext/sockets/tests/socket_import_stream-4.phpt b/ext/sockets/tests/socket_import_stream-4.phpt index 5a528c6e33a2..d0ccf6b71e0b 100644 --- a/ext/sockets/tests/socket_import_stream-4.phpt +++ b/ext/sockets/tests/socket_import_stream-4.phpt @@ -12,32 +12,32 @@ if(substr(PHP_OS, 0, 3) == 'WIN' ) { getMessage(), "\n"; - } - echo "\n"; - } - if ($sock !== null) { - echo "socket_set_block "; - try { - print_r(socket_set_block($sock)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - echo "\n"; - echo "socket_get_option "; - try { - print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - echo "\n"; - } - echo "\n"; + if ($stream !== null) { + echo "stream_set_blocking "; + try { + print_r(stream_set_blocking($stream, 0)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + if ($sock !== null) { + echo "socket_set_block "; + try { + print_r(socket_set_block($sock)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + echo "socket_get_option "; + try { + print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + echo "\n"; + } + echo "\n"; } echo "normal\n"; diff --git a/ext/sockets/tests/socket_sendrecvmsg_multi_msg-unix.phpt b/ext/sockets/tests/socket_sendrecvmsg_multi_msg-unix.phpt index be42447f58ac..2de272356a13 100644 --- a/ext/sockets/tests/socket_sendrecvmsg_multi_msg-unix.phpt +++ b/ext/sockets/tests/socket_sendrecvmsg_multi_msg-unix.phpt @@ -41,13 +41,13 @@ socket_set_option($s, IPPROTO_IPV6, IPV6_RECVPKTINFO, 1) or die("err"); socket_set_option($s, IPPROTO_IPV6, IPV6_RECVTCLASS, 1) or die("err"); $r = socket_sendmsg($sends1, [ - "name" => [ "addr" => "::1", "port" => 3002], - "iov" => ["test ", "thing", "\n"], - "control" => [[ - "level" => IPPROTO_IPV6, - "type" => IPV6_TCLASS, - "data" => 40, - ]] + "name" => [ "addr" => "::1", "port" => 3002], + "iov" => ["test ", "thing", "\n"], + "control" => [[ + "level" => IPPROTO_IPV6, + "type" => IPV6_TCLASS, + "data" => 40, + ]] ], 0); var_dump($r); checktimeout($s, 500); @@ -56,7 +56,7 @@ $data = [ "name" => ["family" => AF_INET6, "addr" => "::1"], "buffer_size" => 2000, "controllen" => socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO) + - socket_cmsg_space(IPPROTO_IPV6, IPV6_TCLASS), + socket_cmsg_space(IPPROTO_IPV6, IPV6_TCLASS), ]; if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); print_r($data); diff --git a/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt b/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt index f06e0a478931..ff61d3a230dd 100644 --- a/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt +++ b/ext/sockets/tests/socket_sendrecvmsg_multi_msg.phpt @@ -32,16 +32,16 @@ socket_set_option($s, IPPROTO_IPV6, IPV6_RECVPKTINFO, 1) or die("err"); socket_set_option($s, IPPROTO_IPV6, IPV6_RECVTCLASS, 1) or die("err"); $r = socket_sendmsg($sends1, [ - "name" => [ "addr" => "::1", "port" => 3003], - "iov" => ["test ", "thing", "\n"], - "control" => [[ - "level" => IPPROTO_IPV6, - "type" => IPV6_PKTINFO, - "data" => [ - 'addr' => '::1', + "name" => [ "addr" => "::1", "port" => 3003], + "iov" => ["test ", "thing", "\n"], + "control" => [[ + "level" => IPPROTO_IPV6, + "type" => IPV6_PKTINFO, + "data" => [ + 'addr' => '::1', 'ifindex' => 1 /* we're assuming loopback is 1. Is this a safe assumption? */ - ], - ]] + ], + ]] ], 0); var_dump($r); checktimeout($s, 500); @@ -50,7 +50,7 @@ $data = [ "name" => ["family" => AF_INET6, "addr" => "::1"], "buffer_size" => 2000, "controllen" => socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO) + - socket_cmsg_space(IPPROTO_IPV6, IPV6_TCLASS), + socket_cmsg_space(IPPROTO_IPV6, IPV6_TCLASS), ]; if (!socket_recvmsg($s, $data, 0)) die("recvmsg"); print_r($data); diff --git a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt index 600cbea59564..6e063c5b5201 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt @@ -28,10 +28,10 @@ if (!extension_loaded('sockets')) { $len = strlen($msg); $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address); if ($bytes_sent == -1) { - @unlink($address); + @unlink($address); die('An error occurred while sending to the socket'); } else if ($bytes_sent != $len) { - @unlink($address); + @unlink($address); die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' bytes expected'); } @@ -39,16 +39,16 @@ if (!extension_loaded('sockets')) { var_dump(socket_recvfrom($socket, $buf, 0, 0, $from)); // expect false $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from); if ($bytes_received == -1) { - @unlink($address); + @unlink($address); die('An error occurred while receiving from the socket'); } else if ($bytes_received != $len) { - @unlink($address); + @unlink($address); die($bytes_received . ' bytes have been received instead of the ' . $len . ' bytes expected'); } echo "Received $buf"; socket_close($socket); - @unlink($address); + @unlink($address); ?> --EXPECTF-- Warning: socket_create(): Unable to create socket [%d]: Protocol not supported in %s on line %d diff --git a/ext/sockets/tests/unixloop.phpt b/ext/sockets/tests/unixloop.phpt index cd4afd65c75b..31740c97c66e 100644 --- a/ext/sockets/tests/unixloop.phpt +++ b/ext/sockets/tests/unixloop.phpt @@ -11,47 +11,47 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { ?> --FILE-- --EXPECT-- string(10) "ABCdef123 diff --git a/ext/sockets/tests/wsaprotocol_info_0.phpt b/ext/sockets/tests/wsaprotocol_info_0.phpt index 8653fe1bab41..3e251914ed0a 100644 --- a/ext/sockets/tests/wsaprotocol_info_0.phpt +++ b/ext/sockets/tests/wsaprotocol_info_0.phpt @@ -11,40 +11,40 @@ if (!extension_loaded('sockets')) { ?> --FILE-- --EXPECTF-- bool(true) diff --git a/ext/sodium/tests/installed.phpt b/ext/sodium/tests/installed.phpt index e6101ed509db..f004efa71452 100644 --- a/ext/sodium/tests/installed.phpt +++ b/ext/sodium/tests/installed.phpt @@ -9,7 +9,7 @@ echo "sodium extension is available"; you can add regression tests for your extension here the output of your test code has to be equal to the - text in the --EXPECT-- section below for the tests + text in the--EXPECT-- section below for the tests to pass, differences between the output and the expected text are interpreted as failure */ diff --git a/ext/sodium/tests/pwhash_scrypt.phpt b/ext/sodium/tests/pwhash_scrypt.phpt index 92db7ac7e00f..8e02f7ba0e8f 100644 --- a/ext/sodium/tests/pwhash_scrypt.phpt +++ b/ext/sodium/tests/pwhash_scrypt.phpt @@ -9,9 +9,9 @@ $passwd = 'test'; $hash = sodium_crypto_pwhash_scryptsalsa208sha256_str ($passwd, SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE, - SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE); + SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE); var_dump(substr($hash, 0, 3) === - SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX); + SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX); $c = sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($hash, $passwd); var_dump($c); diff --git a/ext/sodium/tests/utils.phpt b/ext/sodium/tests/utils.phpt index 5823ab0b7f4a..eeca5363e1b6 100644 --- a/ext/sodium/tests/utils.phpt +++ b/ext/sodium/tests/utils.phpt @@ -93,7 +93,7 @@ if (defined('SODIUM_BASE64_VARIANT_ORIGINAL')) { var_dump('base64("O") case passed'); var_dump('abcd'); } - + function sodium_foo() { throw new SodiumException('test'); diff --git a/ext/spl/tests/CallbackFilterIteratorTest-002.phpt b/ext/spl/tests/CallbackFilterIteratorTest-002.phpt index 35795084729a..62beb88cd5ed 100644 --- a/ext/spl/tests/CallbackFilterIteratorTest-002.phpt +++ b/ext/spl/tests/CallbackFilterIteratorTest-002.phpt @@ -4,41 +4,41 @@ CallbackFilterIterator 002 getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new CallbackFilterIterator(null); + new CallbackFilterIterator(null); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new CallbackFilterIterator(new ArrayIterator(array()), null); + new CallbackFilterIterator(new ArrayIterator(array()), null); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - new CallbackFilterIterator(new ArrayIterator(array()), array()); + new CallbackFilterIterator(new ArrayIterator(array()), array()); } catch (TypeError $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $it = new CallbackFilterIterator(new ArrayIterator(array(1)), function() { - throw new Exception("some message"); + throw new Exception("some message"); }); try { - foreach($it as $e); + foreach($it as $e); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } --EXPECT-- CallbackFilterIterator::__construct() expects exactly 2 parameters, 0 given diff --git a/ext/spl/tests/CallbackFilterIteratorTest.phpt b/ext/spl/tests/CallbackFilterIteratorTest.phpt index 36bc770a955f..bf8f85b8db59 100644 --- a/ext/spl/tests/CallbackFilterIteratorTest.phpt +++ b/ext/spl/tests/CallbackFilterIteratorTest.phpt @@ -16,13 +16,13 @@ class B { } function test($value, $key, $inner) { - printf("%s / %s / %d / %d\n" - , $value - , $key - , $value == $inner->current() - , $key == $inner->key() - ); - return $value === 1 || $value === 4; + printf("%s / %s / %d / %d\n" + , $value + , $key + , $value == $inner->current() + , $key == $inner->key() + ); + return $value === 1 || $value === 4; } $tests = array( @@ -45,7 +45,7 @@ foreach($tests as $name => $test) { echo "=> $value\n"; } - // same test, with no reference to callback + // same test, with no reference to callback $it = new ArrayIterator(range(1, 5)); $it = new CallbackFilterIterator($it, $test()); diff --git a/ext/spl/tests/DirectoryIterator_by_reference.phpt b/ext/spl/tests/DirectoryIterator_by_reference.phpt index 570d09f4069c..0f28262190b3 100644 --- a/ext/spl/tests/DirectoryIterator_by_reference.phpt +++ b/ext/spl/tests/DirectoryIterator_by_reference.phpt @@ -7,7 +7,7 @@ Havard Eide --EXPECTF-- diff --git a/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt b/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt index f55afd8202bd..7620138eb9e4 100644 --- a/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt +++ b/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt @@ -16,16 +16,16 @@ class B { } function test($value, $key, $inner) { - if ($inner->hasChildren()) { - return true; - } - printf("%s / %s / %d / %d\n" - , print_r($value, true) - , $key - , $value == $inner->current() - , $key == $inner->key() - ); - return $value === 1 || $value === 4; + if ($inner->hasChildren()) { + return true; + } + printf("%s / %s / %d / %d\n" + , print_r($value, true) + , $key + , $value == $inner->current() + , $key == $inner->key() + ); + return $value === 1 || $value === 4; } $tests = array( @@ -41,7 +41,7 @@ foreach($tests as $name => $test) { $callback = $test(); $it = new RecursiveArrayIterator(array(1, array(2, 3), array(4, 5))); $it = new RecursiveCallbackFilterIterator($it, $callback); - $it = new RecursiveIteratorIterator($it); + $it = new RecursiveIteratorIterator($it); echo " = $name =\n"; @@ -49,11 +49,11 @@ foreach($tests as $name => $test) { echo "=> $value\n"; } - // same test, with no reference to callback + // same test, with no reference to callback $it = new RecursiveArrayIterator(array(1, array(2, 3), array(4, 5))); $it = new RecursiveCallbackFilterIterator($it, $test()); - $it = new RecursiveIteratorIterator($it); + $it = new RecursiveIteratorIterator($it); unset($callback); foreach($it as $value) { diff --git a/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt b/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt index 4d8c1394b6b2..c050f2e79eb8 100644 --- a/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt +++ b/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt @@ -21,7 +21,7 @@ while($it->valid()) { } asort($list); foreach ($list as $item) { - echo $item . "\n"; + echo $item . "\n"; } ?> --CLEAN-- diff --git a/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt b/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt index 6527d84bfe85..e7238252f098 100644 --- a/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt +++ b/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt @@ -24,7 +24,7 @@ while($it->valid()) { } asort($list); foreach ($list as $item) { - echo $item . "\n"; + echo $item . "\n"; } ?> --CLEAN-- diff --git a/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt b/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt index fa38d9342540..401d8ae1b3a7 100644 --- a/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt @@ -3,10 +3,10 @@ Check that SplDoublyLinkedList::add throws an exception with an invalid offset a --FILE-- add(12,'Offset 12 should not exist')); + $dll = new SplDoublyLinkedList(); + var_dump($dll->add(12,'Offset 12 should not exist')); } catch (OutOfRangeException $e) { - echo "Exception: ".$e->getMessage()."\n"; + echo "Exception: ".$e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt b/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt index b14c9ab01325..f8c58d9c705b 100644 --- a/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt @@ -3,10 +3,10 @@ Check that SplDoublyLinkedList::add throws an exception with an invalid offset a --FILE-- add(NULL,2)); + $dll = new SplDoublyLinkedList(); + var_dump($dll->add(NULL,2)); } catch (OutOfRangeException $e) { - echo "Exception: ".$e->getMessage()."\n"; + echo "Exception: ".$e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt b/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt index c5d10919ff48..b008715eefa7 100644 --- a/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt @@ -4,16 +4,16 @@ Check that SplDoublyLinkedList returns debug info when print_r is used. PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) --FILE-- push(1); - $dll->push(2); - $dll->push(3); + // Add some items to the list + $dll->push(1); + $dll->push(2); + $dll->push(3); - // Check the debug info - print_r($dll); + // Check the debug info + print_r($dll); ?> --EXPECT-- SplDoublyLinkedList Object diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt index 4e9e2b33dea2..8c8012202e46 100644 --- a/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt @@ -4,10 +4,10 @@ Check that SplDoublyLinkedList->isEmpty() correctly returns true for an empty li PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) --FILE-- isEmpty()); + var_dump($dll->isEmpty()); ?> --EXPECT-- bool(true) diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt index 4b308f345bdc..0d26da14d543 100644 --- a/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt @@ -4,16 +4,16 @@ Check that SplDoublyLinkedList->isEmpty() correctly returns true for a non-empty PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) --FILE-- push(1); - $dll->push(2); - $dll->push(3); - //var_dump($dll); + // Add some items to the list + $dll->push(1); + $dll->push(2); + $dll->push(3); + //var_dump($dll); - var_dump($dll->isEmpty()); + var_dump($dll->isEmpty()); ?> --EXPECT-- bool(false) diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt index fc8c4b7dcd99..a6c5db200e4f 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt @@ -12,17 +12,17 @@ $list->push('def'); // Validate that we can see the first value if($list->offsetExists(0) === true) { - echo "PASS\n"; + echo "PASS\n"; } // Validate that we can see the second value if($list->offsetExists(1) === true) { - echo "PASS\n"; + echo "PASS\n"; } // Check that there is no third value if($list->offsetExists(2) === false) { - echo "PASS\n"; + echo "PASS\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt index 838100be1eed..364eb5ca79a6 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt @@ -4,20 +4,20 @@ Check that SplDoublyLinkedList->offsetUnset() returns an error message when the PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) --FILE-- push(1); - $dll->push(2); - $dll->push(3); + // Add some items to the list + $dll->push(1); + $dll->push(2); + $dll->push(3); - try { - $dll->offsetUnset(-1); - } - catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + try { + $dll->offsetUnset(-1); + } + catch (Exception $e) { + echo $e->getMessage() . "\n"; + } ?> --EXPECT-- Offset out of range diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt index cd77f11aef77..5ba7b27e56bf 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt @@ -4,20 +4,20 @@ Check that SplDoublyLinkedList->offsetUnset() returns an error message when the PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) --FILE-- push(1); - $dll->push(2); - $dll->push(3); + // Add some items to the list + $dll->push(1); + $dll->push(2); + $dll->push(3); - try { - $dll->offsetUnset(3); - } - catch (Exception $e) { - echo $e->getMessage() . "\n"; - } + try { + $dll->offsetUnset(3); + } + catch (Exception $e) { + echo $e->getMessage() . "\n"; + } ?> --EXPECT-- Offset out of range diff --git a/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt index 28901050d30a..2580021426fd 100644 --- a/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt +++ b/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt @@ -4,10 +4,10 @@ SplFileObject::fgetcsv default path fputcsv(explode(',', $v)); + $fo->fputcsv(explode(',', $v)); } unset($fo); $res = file($file); foreach($res as &$val) { - $val = substr($val, 0, -1); + $val = substr($val, 0, -1); } echo '$list = ';var_export($res);echo ";\n"; @@ -44,7 +44,7 @@ $fp = fopen($file, "r"); $res = array(); while($l=fgetcsv($fp)) { - $res[] = join(',',$l); + $res[] = join(',',$l); } fclose($fp); diff --git a/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt index 831e855b856d..4e0642c6ae43 100644 --- a/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt +++ b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt @@ -23,9 +23,9 @@ $ftruncate_test = ""; //open an SplFileObject using the above test stream $obj = New SplFileObject("SPLtest://ftruncate_test"); try { - $obj->ftruncate(1); + $obj->ftruncate(1); } catch (LogicException $e) { - echo($e->getMessage()); + echo($e->getMessage()); } ?> --EXPECTF-- diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt index a8e36cd046ec..999adaa3c82e 100644 --- a/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt +++ b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt @@ -4,7 +4,7 @@ SplFileObject::fwrite function - writing with two parameters length < input stri fwrite('test_write',4); diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt index cea92a349c72..6c061eed8442 100644 --- a/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt +++ b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt @@ -4,7 +4,7 @@ SplFileObject::fwrite function - writing with two parameters, length > input str fwrite('test_write',12); diff --git a/ext/spl/tests/SplFileObject_seek_error_001.phpt b/ext/spl/tests/SplFileObject_seek_error_001.phpt index 8741e3b7887d..acebb66f4156 100644 --- a/ext/spl/tests/SplFileObject_seek_error_001.phpt +++ b/ext/spl/tests/SplFileObject_seek_error_001.phpt @@ -4,9 +4,9 @@ SplFileObject::seek function - test parameters seek(-1); + $obj->seek(-1); } catch (LogicException $e) { - echo($e->getMessage()); + echo($e->getMessage()); } ?> --EXPECTF-- diff --git a/ext/spl/tests/SplFixedArray__construct_param_array.phpt b/ext/spl/tests/SplFixedArray__construct_param_array.phpt index 89983c377e46..15e1c0c4385b 100644 --- a/ext/spl/tests/SplFixedArray__construct_param_array.phpt +++ b/ext/spl/tests/SplFixedArray__construct_param_array.phpt @@ -6,9 +6,9 @@ PHPNW Test Fest 2009 - Jordan Hatch getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } ?> diff --git a/ext/spl/tests/SplFixedArray__construct_param_string.phpt b/ext/spl/tests/SplFixedArray__construct_param_string.phpt index bfec39de32b5..654ac4b95f80 100644 --- a/ext/spl/tests/SplFixedArray__construct_param_string.phpt +++ b/ext/spl/tests/SplFixedArray__construct_param_string.phpt @@ -5,9 +5,9 @@ PHPNW Test Fest 2009 - Jordan Hatch --FILE-- getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } diff --git a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt index af9f5f3ee819..efb1d0e65d76 100644 --- a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt +++ b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt @@ -5,9 +5,9 @@ Philip Norton philipnorton42@gmail.com --FILE-- getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } ?> diff --git a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt index c649e3b6c3ed..8ec02b8d4901 100644 --- a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt +++ b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt @@ -5,8 +5,8 @@ Philip Norton philipnorton42@gmail.com --FILE-- 1, - 2 => '2', - 3 => false)); + 2 => '2', + 3 => false)); var_dump($array); ?> --EXPECT-- diff --git a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt index b3e749739756..af5f663f3380 100644 --- a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt +++ b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt @@ -5,9 +5,9 @@ Philip Norton philipnorton42@gmail.com --FILE-- 1, - 2 => '2', - 3 => false), - false); + 2 => '2', + 3 => false), + false); var_dump($array); ?> --EXPECT-- diff --git a/ext/spl/tests/SplFixedArray_key_setsize.phpt b/ext/spl/tests/SplFixedArray_key_setsize.phpt index 091c4650e22a..5c035e71c777 100644 --- a/ext/spl/tests/SplFixedArray_key_setsize.phpt +++ b/ext/spl/tests/SplFixedArray_key_setsize.phpt @@ -12,7 +12,7 @@ $array[1] = "world"; $array[2] = "elePHPant"; foreach ( $array as $value ) { - echo $array->key( ); + echo $array->key( ); } ?> diff --git a/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt b/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt index 9bfda3407318..da6acd15ca86 100644 --- a/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt +++ b/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt @@ -6,7 +6,7 @@ PHPNW TestFest 2009 - Ben Longden offsetExists(-10) === false) { - echo 'PASS'; + echo 'PASS'; } ?> --EXPECT-- diff --git a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt index 3b0e6bb2226b..1d7c50d39e18 100644 --- a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt +++ b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt @@ -4,18 +4,18 @@ Check removing an item from an array when the offset is not an integer. PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) --FILE-- offsetUnset("4"); + // remove an item + $fixedArray->offsetUnset("4"); - var_dump($fixedArray); + var_dump($fixedArray); ?> --EXPECT-- diff --git a/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt b/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt index fa2c7aabe90c..54fcc23d4dcf 100644 --- a/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt +++ b/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt @@ -9,9 +9,9 @@ $s = new SplObjectStorage(); $o1 = new stdClass(); try { - $s->offsetGet($o1); + $s->offsetGet($o1); } catch (UnexpectedValueException $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt b/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt index a5678eab4042..a0f3e8c93dd9 100644 --- a/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt +++ b/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt @@ -15,7 +15,7 @@ try { $so->unserialize($blob); var_dump($so); } catch(UnexpectedValueException $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } } echo "DONE\n"; diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt index 8ea0b6656e05..0ff158c85c57 100644 --- a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt +++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt @@ -15,7 +15,7 @@ $data_provider = array( foreach($data_provider as $input) { - $s = new SplObjectStorage(); + $s = new SplObjectStorage(); try { $s->unserialize($input); diff --git a/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt b/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt index c3071f2399cb..255f0cd2e4d2 100644 --- a/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt +++ b/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt @@ -7,11 +7,11 @@ PHPNW Test Fest 2009 - Jeremy Coates jeremy@phpnw.org.uk try { - $dll = new SplQueue(); - $dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); + $dll = new SplQueue(); + $dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/arrayObject___construct_basic2.phpt b/ext/spl/tests/arrayObject___construct_basic2.phpt index ddbf074bf36b..2e5970004eb1 100644 --- a/ext/spl/tests/arrayObject___construct_basic2.phpt +++ b/ext/spl/tests/arrayObject___construct_basic2.phpt @@ -3,11 +3,11 @@ SPL: ArrayObject::__construct basic usage. --FILE-- Access prop on instance of ArrayObject:\n"; @@ -21,29 +21,29 @@ $ao = new MyArrayObject($c); testAccess($c, $ao); function testAccess($c, $ao) { - echo " - Iteration:\n"; - foreach ($ao as $key=>$value) { - echo " $key=>$value\n"; - } + echo " - Iteration:\n"; + foreach ($ao as $key=>$value) { + echo " $key=>$value\n"; + } - echo " - Read:\n"; - @var_dump($ao->prop, $ao['prop']); + echo " - Read:\n"; + @var_dump($ao->prop, $ao['prop']); - echo " - Write:\n"; - $ao->prop = 'changed1'; - $ao['prop'] = 'changed2'; - var_dump($ao->prop, $ao['prop']); + echo " - Write:\n"; + $ao->prop = 'changed1'; + $ao['prop'] = 'changed2'; + var_dump($ao->prop, $ao['prop']); - echo " - Isset:\n"; - var_dump(isset($ao->prop), isset($ao['prop'])); + echo " - Isset:\n"; + var_dump(isset($ao->prop), isset($ao['prop'])); - echo " - Unset:\n"; - unset($ao->prop); - unset($ao['prop']); - var_dump($ao->prop, $ao['prop']); + echo " - Unset:\n"; + unset($ao->prop); + unset($ao['prop']); + var_dump($ao->prop, $ao['prop']); - echo " - After:\n"; - var_dump($ao, $c); + echo " - After:\n"; + var_dump($ao, $c); } ?> --EXPECTF-- diff --git a/ext/spl/tests/arrayObject___construct_basic3.phpt b/ext/spl/tests/arrayObject___construct_basic3.phpt index f162317773d2..2628c991a729 100644 --- a/ext/spl/tests/arrayObject___construct_basic3.phpt +++ b/ext/spl/tests/arrayObject___construct_basic3.phpt @@ -3,11 +3,11 @@ SPL: ArrayObject::__construct basic usage with ArrayObject::STD_PROP_LIST. --FILE-- Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST:\n"; @@ -21,29 +21,29 @@ $ao = new MyArrayObject($c, ArrayObject::STD_PROP_LIST); testAccess($c, $ao); function testAccess($c, $ao) { - echo " - Iteration:\n"; - foreach ($ao as $key=>$value) { - echo " $key=>$value\n"; - } + echo " - Iteration:\n"; + foreach ($ao as $key=>$value) { + echo " $key=>$value\n"; + } - echo " - Read:\n"; - @var_dump($ao->prop, $ao['prop']); + echo " - Read:\n"; + @var_dump($ao->prop, $ao['prop']); - echo " - Write:\n"; - $ao->prop = 'changed1'; - $ao['prop'] = 'changed2'; - var_dump($ao->prop, $ao['prop']); + echo " - Write:\n"; + $ao->prop = 'changed1'; + $ao['prop'] = 'changed2'; + var_dump($ao->prop, $ao['prop']); - echo " - Isset:\n"; - var_dump(isset($ao->prop), isset($ao['prop'])); + echo " - Isset:\n"; + var_dump(isset($ao->prop), isset($ao['prop'])); - echo " - Unset:\n"; - unset($ao->prop); - unset($ao['prop']); - var_dump($ao->prop, $ao['prop']); + echo " - Unset:\n"; + unset($ao->prop); + unset($ao['prop']); + var_dump($ao->prop, $ao['prop']); - echo " - After:\n"; - var_dump($ao, $c); + echo " - After:\n"; + var_dump($ao, $c); } ?> --EXPECTF-- diff --git a/ext/spl/tests/arrayObject___construct_basic4.phpt b/ext/spl/tests/arrayObject___construct_basic4.phpt index c136c949e249..ba0ab08ff631 100644 --- a/ext/spl/tests/arrayObject___construct_basic4.phpt +++ b/ext/spl/tests/arrayObject___construct_basic4.phpt @@ -3,11 +3,11 @@ SPL: ArrayObject::__construct basic usage with ArrayObject::ARRAY_AS_PROPS. Curr --FILE-- Access prop on instance of ArrayObject with ArrayObject::ARRAY_AS_PROPS:\n"; @@ -21,29 +21,29 @@ $ao = new MyArrayObject($c, ArrayObject::ARRAY_AS_PROPS); testAccess($c, $ao); function testAccess($c, $ao) { - echo " - Iteration:\n"; - foreach ($ao as $key=>$value) { - echo " $key=>$value\n"; - } + echo " - Iteration:\n"; + foreach ($ao as $key=>$value) { + echo " $key=>$value\n"; + } - echo " - Read:\n"; - @var_dump($ao->prop, $ao['prop']); + echo " - Read:\n"; + @var_dump($ao->prop, $ao['prop']); - echo " - Write:\n"; - $ao->prop = 'changed1'; - $ao['prop'] = 'changed2'; - var_dump($ao->prop, $ao['prop']); + echo " - Write:\n"; + $ao->prop = 'changed1'; + $ao['prop'] = 'changed2'; + var_dump($ao->prop, $ao['prop']); - echo " - Isset:\n"; - var_dump(isset($ao->prop), isset($ao['prop'])); + echo " - Isset:\n"; + var_dump(isset($ao->prop), isset($ao['prop'])); - echo " - Unset:\n"; - unset($ao->prop); - unset($ao['prop']); - var_dump($ao->prop, $ao['prop']); + echo " - Unset:\n"; + unset($ao->prop); + unset($ao['prop']); + var_dump($ao->prop, $ao['prop']); - echo " - After:\n"; - var_dump($ao, $c); + echo " - After:\n"; + var_dump($ao, $c); } ?> --EXPECTF-- diff --git a/ext/spl/tests/arrayObject___construct_basic5.phpt b/ext/spl/tests/arrayObject___construct_basic5.phpt index 0eb8904bac99..93fcf256eeb3 100644 --- a/ext/spl/tests/arrayObject___construct_basic5.phpt +++ b/ext/spl/tests/arrayObject___construct_basic5.phpt @@ -3,11 +3,11 @@ SPL: ArrayObject::__construct basic usage with ArrayObject::STD_PROP_LIST|ArrayO --FILE-- Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:\n"; @@ -21,29 +21,29 @@ $ao = new MyArrayObject($c, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PRO testAccess($c, $ao); function testAccess($c, $ao) { - echo " - Iteration:\n"; - foreach ($ao as $key=>$value) { - echo " $key=>$value\n"; - } + echo " - Iteration:\n"; + foreach ($ao as $key=>$value) { + echo " $key=>$value\n"; + } - echo " - Read:\n"; - @var_dump($ao->prop, $ao['prop']); + echo " - Read:\n"; + @var_dump($ao->prop, $ao['prop']); - echo " - Write:\n"; - $ao->prop = 'changed1'; - $ao['prop'] = 'changed2'; - var_dump($ao->prop, $ao['prop']); + echo " - Write:\n"; + $ao->prop = 'changed1'; + $ao['prop'] = 'changed2'; + var_dump($ao->prop, $ao['prop']); - echo " - Isset:\n"; - var_dump(isset($ao->prop), isset($ao['prop'])); + echo " - Isset:\n"; + var_dump(isset($ao->prop), isset($ao['prop'])); - echo " - Unset:\n"; - unset($ao->prop); - unset($ao['prop']); - var_dump($ao->prop, $ao['prop']); + echo " - Unset:\n"; + unset($ao->prop); + unset($ao['prop']); + var_dump($ao->prop, $ao['prop']); - echo " - After:\n"; - var_dump($ao, $c); + echo " - After:\n"; + var_dump($ao, $c); } ?> --EXPECTF-- diff --git a/ext/spl/tests/arrayObject___construct_basic6.phpt b/ext/spl/tests/arrayObject___construct_basic6.phpt index befa6eab3c5b..681e6e0d318a 100644 --- a/ext/spl/tests/arrayObject___construct_basic6.phpt +++ b/ext/spl/tests/arrayObject___construct_basic6.phpt @@ -3,8 +3,8 @@ SPL: ArrayObject::__construct: check impact of ArrayObject::STD_PROP_LIST on var --FILE-- exchangeArray() with objects:\n"; @@ -12,10 +12,10 @@ $original = new C; $ao = new ArrayObject($original); $swapIn = new C; try { - $copy = $ao->exchangeArray($swapIn); - $copy['addedToCopy'] = 'added To Copy'; + $copy = $ao->exchangeArray($swapIn); + $copy['addedToCopy'] = 'added To Copy'; } catch (Exception $e) { - echo "Exception:" . $e->getMessage() . "\n"; + echo "Exception:" . $e->getMessage() . "\n"; } $swapIn->addedToSwapIn = 'added To Swap-In'; $original->addedToOriginal = 'added To Original'; @@ -27,10 +27,10 @@ unset($original, $ao, $swapIn, $copy); $original = new C; $ao = new ArrayObject($original); try { - $copy = $ao->exchangeArray(); - $copy['addedToCopy'] = 'added To Copy'; + $copy = $ao->exchangeArray(); + $copy['addedToCopy'] = 'added To Copy'; } catch (TypeError $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } $original->addedToOriginal = 'added To Original'; var_dump($ao, $original, $copy); @@ -40,10 +40,10 @@ unset($original, $ao, $swapIn, $copy); $original = new C; $ao = new ArrayObject($original); try { - $copy = $ao->exchangeArray(null); - $copy['addedToCopy'] = 'added To Copy'; + $copy = $ao->exchangeArray(null); + $copy['addedToCopy'] = 'added To Copy'; } catch (Exception $e) { - echo "Exception:" . $e->getMessage() . "\n"; + echo "Exception:" . $e->getMessage() . "\n"; } $original->addedToOriginal = 'added To Original'; var_dump($ao, $original, $copy); diff --git a/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt b/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt index e6e950c628d0..58419c06bdda 100644 --- a/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt +++ b/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt @@ -4,40 +4,40 @@ SPL: ArrayObject::getIteratorClass and ArrayObject::setIteratorClass basic funct 1,'b'=>2,'c'=>3), 0, "MyIterator"); @@ -46,7 +46,7 @@ echo "--> Access using MyIterator:\n"; var_dump($ao->getIteratorClass()); var_dump($ao->getIterator()); foreach($ao as $key=>$value) { - echo " $key=>$value\n"; + echo " $key=>$value\n"; } echo "\n\n--> Access using ArrayIterator:\n"; @@ -54,7 +54,7 @@ var_dump($ao->setIteratorClass("ArrayIterator")); var_dump($ao->getIteratorClass()); var_dump($ao->getIterator()); foreach($ao as $key=>$value) { - echo "$key=>$value\n"; + echo "$key=>$value\n"; } ?> diff --git a/ext/spl/tests/arrayObject_ksort_basic2.phpt b/ext/spl/tests/arrayObject_ksort_basic2.phpt index fa0485aff8e0..6ef06b331b6f 100644 --- a/ext/spl/tests/arrayObject_ksort_basic2.phpt +++ b/ext/spl/tests/arrayObject_ksort_basic2.phpt @@ -11,10 +11,10 @@ SPL: Test ArrayObject::ksort() function : basic functionality with object base s echo "*** Testing ArrayObject::ksort() : basic functionality ***\n"; Class C { - public $x = 'prop1'; - public $z = 'prop2'; - public $a = 'prop3'; - private $b = 'prop4'; + public $x = 'prop1'; + public $z = 'prop2'; + public $a = 'prop3'; + private $b = 'prop4'; } $c = new C; diff --git a/ext/spl/tests/arrayObject_magicMethods1.phpt b/ext/spl/tests/arrayObject_magicMethods1.phpt index 351f68214a00..dbe75bff2420 100644 --- a/ext/spl/tests/arrayObject_magicMethods1.phpt +++ b/ext/spl/tests/arrayObject_magicMethods1.phpt @@ -3,28 +3,28 @@ SPL: ArrayObject: ensure a wrapped object's magic methods for property access ar --FILE-- x); - } + static function go($c) { + var_dump($c->x); + } } $c = new C(array('x'=>'public')); diff --git a/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt b/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt index d0910b3a0a95..591f84c3d4df 100644 --- a/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt +++ b/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt @@ -9,7 +9,7 @@ try { echo " $key=>$value\n"; } } catch (TypeError $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { @@ -19,7 +19,7 @@ try { echo " $key=>$value\n"; } } catch (TypeError $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } @@ -29,7 +29,7 @@ try { echo " $key=>$value\n"; } } catch (TypeError $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } try { @@ -38,7 +38,7 @@ try { echo " $key=>$value\n"; } } catch (TypeError $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/spl/tests/arrayObject_uasort_error1.phpt b/ext/spl/tests/arrayObject_uasort_error1.phpt index 55c5e200e6dc..5dc63373ef63 100644 --- a/ext/spl/tests/arrayObject_uasort_error1.phpt +++ b/ext/spl/tests/arrayObject_uasort_error1.phpt @@ -12,15 +12,15 @@ Test ArrayObject::uasort() function : wrong arg count $ao = new ArrayObject(); try { - $ao->uasort(); + $ao->uasort(); } catch (BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $ao->uasort(1,2); + $ao->uasort(1,2); } catch (BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/arrayObject_uksort_error1.phpt b/ext/spl/tests/arrayObject_uksort_error1.phpt index 3332839b8b0f..e2bbf9968cfa 100644 --- a/ext/spl/tests/arrayObject_uksort_error1.phpt +++ b/ext/spl/tests/arrayObject_uksort_error1.phpt @@ -12,15 +12,15 @@ Test ArrayObject::uksort() function : wrong arg count $ao = new ArrayObject(); try { - $ao->uksort(); + $ao->uksort(); } catch (BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $ao->uksort(1,2); + $ao->uksort(1,2); } catch (BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/array_003.phpt b/ext/spl/tests/array_003.phpt index f77b7862d1ef..e4c0a1f9f828 100644 --- a/ext/spl/tests/array_003.phpt +++ b/ext/spl/tests/array_003.phpt @@ -9,14 +9,14 @@ SPL: ArrayObject from object class test { - public $pub = "public"; - protected $pro = "protected"; - private $pri = "private"; - - function __construct() - { - $this->imp = "implicit"; - } + public $pub = "public"; + protected $pro = "protected"; + private $pri = "private"; + + function __construct() + { + $this->imp = "implicit"; + } }; $test = new test; @@ -30,7 +30,7 @@ print_r($object); foreach($test as $key => $val) { - echo "$key => $val\n"; + echo "$key => $val\n"; } ?> diff --git a/ext/spl/tests/array_004.phpt b/ext/spl/tests/array_004.phpt index c976bdd87b8c..e962477a9ed2 100644 --- a/ext/spl/tests/array_004.phpt +++ b/ext/spl/tests/array_004.phpt @@ -7,12 +7,12 @@ $arr = array(0=>0, 1=>1, 2=>2); $obj = new ArrayObject($arr); foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } + foreach($obj as $bk=>$bv) { + if ($ak==0 && $bk==0) { + $arr[0] = "modify"; + } + echo "$ak=>$av - $bk=>$bv\n"; + } } echo "Done\n"; diff --git a/ext/spl/tests/array_005.phpt b/ext/spl/tests/array_005.phpt index 00cc313f2a2c..cae8f422a785 100644 --- a/ext/spl/tests/array_005.phpt +++ b/ext/spl/tests/array_005.phpt @@ -5,73 +5,73 @@ SPL: ArrayObject/Iterator interaction class Student { - private $id; - private $name; + private $id; + private $name; public function __construct($id, $name) { - $this->id = $id; - $this->name = $name; + $this->id = $id; + $this->name = $name; } - public function __toString() - { - return $this->id . ', ' . $this->name; - } + public function __toString() + { + return $this->id . ', ' . $this->name; + } - public function getId() - { - return $this->id; - } + public function getId() + { + return $this->id; + } } class StudentIdFilter extends FilterIterator { - private $id; + private $id; - public function __construct(ArrayObject $students, Student $other) - { - FilterIterator::__construct($students->getIterator()); - $this->id = $other->getId(); - } + public function __construct(ArrayObject $students, Student $other) + { + FilterIterator::__construct($students->getIterator()); + $this->id = $other->getId(); + } - public function accept() - { - echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; - return $this->current()->getId() == $this->id; - } + public function accept() + { + echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; + return $this->current()->getId() == $this->id; + } } class StudentList implements IteratorAggregate { - private $students; + private $students; - public function __construct() - { - $this->students = new ArrayObject(array()); - } + public function __construct() + { + $this->students = new ArrayObject(array()); + } - public function add(Student $student) - { - if (!$this->contains($student)) { - $this->students[] = $student; - } - } + public function add(Student $student) + { + if (!$this->contains($student)) { + $this->students[] = $student; + } + } - public function contains(Student $student) - { - foreach ($this->students as $s) - { - if ($s->getId() == $student->getId()) { - return true; - } - } - return false; - } + public function contains(Student $student) + { + foreach ($this->students as $s) + { + if ($s->getId() == $student->getId()) { + return true; + } + } + return false; + } - public function getIterator() { - return $this->students->getIterator(); - } + public function getIterator() { + return $this->students->getIterator(); + } } $students = new StudentList(); @@ -80,7 +80,7 @@ $students->add(new Student('00000014', 'Bob')); $students->add(new Student('00000014', 'Foo')); foreach ($students as $student) { - echo $student, "\n"; + echo $student, "\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/array_006.phpt b/ext/spl/tests/array_006.phpt index 1a21cec1aa10..e46ca25cc35e 100644 --- a/ext/spl/tests/array_006.phpt +++ b/ext/spl/tests/array_006.phpt @@ -11,12 +11,12 @@ $arr = array(0=>0, 1=>1, 2=>2); $obj = new ArrayIterator($arr); foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } + foreach($obj as $bk=>$bv) { + if ($ak==0 && $bk==0) { + $arr[0] = "modify"; + } + echo "$ak=>$av - $bk=>$bv\n"; + } } ?> diff --git a/ext/spl/tests/array_007.phpt b/ext/spl/tests/array_007.phpt index e32f1389400e..13d841792c91 100644 --- a/ext/spl/tests/array_007.phpt +++ b/ext/spl/tests/array_007.phpt @@ -9,20 +9,20 @@ SPL: ArrayObject/Iterator from IteratorAggregate class test implements IteratorAggregate { - public $pub = "public"; - protected $pro = "protected"; - private $pri = "private"; + public $pub = "public"; + protected $pro = "protected"; + private $pri = "private"; - function __construct() - { - $this->imp = "implicit"; - } + function __construct() + { + $this->imp = "implicit"; + } - function getIterator() - { - $it = new ArrayObject($this); - return $it->getIterator(); - } + function getIterator() + { + $it = new ArrayObject($this); + return $it->getIterator(); + } }; $test = new test; @@ -34,7 +34,7 @@ print_r($test->getIterator()); foreach($test as $key => $val) { - echo "$key => $val\n"; + echo "$key => $val\n"; } ?> diff --git a/ext/spl/tests/array_008.phpt b/ext/spl/tests/array_008.phpt index 1165647d7bf8..6b4f42262d0f 100644 --- a/ext/spl/tests/array_008.phpt +++ b/ext/spl/tests/array_008.phpt @@ -7,12 +7,12 @@ $arr = array(0=>0, 1=>1, 2=>2); $obj = new ArrayObject($arr); foreach($obj as $ak=>&$av) { - foreach($obj as $bk=>&$bv) { - if ($ak==0 && $bk==0) { - $bv = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } + foreach($obj as $bk=>&$bv) { + if ($ak==0 && $bk==0) { + $bv = "modify"; + } + echo "$ak=>$av - $bk=>$bv\n"; + } } ?> diff --git a/ext/spl/tests/array_009.phpt b/ext/spl/tests/array_009.phpt index 91875639e26d..05c53e9b44f0 100644 --- a/ext/spl/tests/array_009.phpt +++ b/ext/spl/tests/array_009.phpt @@ -8,7 +8,7 @@ $array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); $dir = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($dir as $file) { - print "$file\n"; + print "$file\n"; } ?> diff --git a/ext/spl/tests/array_009a.phpt b/ext/spl/tests/array_009a.phpt index a642f2915616..451c22b565e3 100644 --- a/ext/spl/tests/array_009a.phpt +++ b/ext/spl/tests/array_009a.phpt @@ -5,15 +5,15 @@ SPL: ArrayIterator implementing RecursiveIterator class MyRecursiveArrayIterator extends ArrayIterator implements RecursiveIterator { - function hasChildren() - { - return is_array($this->current()); - } + function hasChildren() + { + return is_array($this->current()); + } - function getChildren() - { - return new MyRecursiveArrayIterator($this->current()); - } + function getChildren() + { + return new MyRecursiveArrayIterator($this->current()); + } } $array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); @@ -21,7 +21,7 @@ $array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); $dir = new RecursiveIteratorIterator(new MyRecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($dir as $file) { - print "$file\n"; + print "$file\n"; } ?> diff --git a/ext/spl/tests/array_011.phpt b/ext/spl/tests/array_011.phpt index 0ba0bd8769d0..647e1ed3bafd 100644 --- a/ext/spl/tests/array_011.phpt +++ b/ext/spl/tests/array_011.phpt @@ -7,7 +7,7 @@ $a = array('zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five //foreach (new ArrayIterator($a) as $k => $v) foreach (new LimitIterator(new ArrayIterator($a), 1, 3) as $k => $v) { - var_dump(array($k, $v)); + var_dump(array($k, $v)); } ?> diff --git a/ext/spl/tests/array_012.phpt b/ext/spl/tests/array_012.phpt index 3b2eb1f3f294..5d5993d93694 100644 --- a/ext/spl/tests/array_012.phpt +++ b/ext/spl/tests/array_012.phpt @@ -11,8 +11,8 @@ $it = new ArrayIterator($a); var_dump($it->count()); foreach($it as $key => $val) { - echo "$key=>$val\n"; - var_dump($it->count()); + echo "$key=>$val\n"; + var_dump($it->count()); } var_dump($it->count()); @@ -20,11 +20,11 @@ echo "===Object===\n"; class test { - public $zero = 0; - protected $pro; - public $one = 1; - private $pri; - public $two = 2; + public $zero = 0; + protected $pro; + public $one = 1; + private $pri; + public $two = 2; } $o = new test; @@ -33,8 +33,8 @@ $it = new ArrayIterator($o); var_dump($it->count()); foreach($it as $key => $val) { - echo "$key=>$val\n"; - var_dump($it->count()); + echo "$key=>$val\n"; + var_dump($it->count()); } var_dump($it->count()); diff --git a/ext/spl/tests/array_013.phpt b/ext/spl/tests/array_013.phpt index 54a798d80d2b..9ad11c8f38c7 100644 --- a/ext/spl/tests/array_013.phpt +++ b/ext/spl/tests/array_013.phpt @@ -5,7 +5,7 @@ SPL: ArrayIterator::append if (!class_exists('NoRewindIterator', false)) { - require_once(__DIR__ . '/../examples/norewinditerator.inc'); + require_once(__DIR__ . '/../examples/norewinditerator.inc'); } echo "===Array===\n"; @@ -15,7 +15,7 @@ $it = new ArrayIterator($a); foreach($it as $key => $val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Append===\n"; @@ -25,18 +25,18 @@ $it->append('four'); foreach(new NoRewindIterator($it) as $key => $val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Object===\n"; class test { - public $zero = 0; - protected $pro; - public $one = 1; - private $pri; - public $two = 2; + public $zero = 0; + protected $pro; + public $one = 1; + private $pri; + public $two = 2; } $o = new test; @@ -44,7 +44,7 @@ $it = new ArrayIterator($o); foreach($it as $key => $val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Append===\n"; @@ -54,7 +54,7 @@ $it->append('four'); foreach(new NoRewindIterator($it) as $key => $val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } var_dump($o->{0}); /* doesn't wotk anyway */ diff --git a/ext/spl/tests/array_014.phpt b/ext/spl/tests/array_014.phpt index 4793de34d699..37ed9abad507 100644 --- a/ext/spl/tests/array_014.phpt +++ b/ext/spl/tests/array_014.phpt @@ -11,29 +11,29 @@ $it->seek(4); var_dump($it->current()); try { - $it->seek(-1); - var_dump($it->current()); + $it->seek(-1); + var_dump($it->current()); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - $it->seek(12); - var_dump($it->current()); + $it->seek(12); + var_dump($it->current()); } catch(Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $pos = 0; foreach($it as $v) { - $it->seek($pos++); - var_dump($v); + $it->seek($pos++); + var_dump($v); } ?> diff --git a/ext/spl/tests/array_015.phpt b/ext/spl/tests/array_015.phpt index 8571e930d550..45cf466b7663 100644 --- a/ext/spl/tests/array_015.phpt +++ b/ext/spl/tests/array_015.phpt @@ -23,16 +23,16 @@ var_dump($ar); foreach($it as $k => $v) { - $ar->offsetUnset($k+1); - echo "$k=>$v\n"; + $ar->offsetUnset($k+1); + echo "$k=>$v\n"; } var_dump($ar); foreach($it as $k => $v) { - $ar->offsetUnset($k); - echo "$k=>$v\n"; + $ar->offsetUnset($k); + echo "$k=>$v\n"; } var_dump($ar); diff --git a/ext/spl/tests/array_016.phpt b/ext/spl/tests/array_016.phpt index 576ab6c80363..a40d4d5b8aa5 100644 --- a/ext/spl/tests/array_016.phpt +++ b/ext/spl/tests/array_016.phpt @@ -7,14 +7,14 @@ $it = new ArrayIterator(range(0,3)); foreach(new IteratorIterator($it) as $v) { - var_dump($v); + var_dump($v); } $it = new ArrayObject(range(0,3)); foreach(new IteratorIterator($it) as $v) { - var_dump($v); + var_dump($v); } ?> diff --git a/ext/spl/tests/array_017.phpt b/ext/spl/tests/array_017.phpt index ef739eb7e122..1165133b3502 100644 --- a/ext/spl/tests/array_017.phpt +++ b/ext/spl/tests/array_017.phpt @@ -5,113 +5,113 @@ SPL: ArrayObject::exchangeArray($this) class ArrayIteratorEx extends ArrayIterator { - public $pub2 = 1; - protected $pro2 = 2; - private $pri2 = 3; + public $pub2 = 1; + protected $pro2 = 2; + private $pri2 = 3; - function __construct($ar, $flags = 0) - { - echo __METHOD__ . "()\n"; - parent::__construct($ar, $flags); - $this->imp2 = 4; - } + function __construct($ar, $flags = 0) + { + echo __METHOD__ . "()\n"; + parent::__construct($ar, $flags); + $this->imp2 = 4; + } - function dump() - { - echo __METHOD__ . "()\n"; - var_dump(array('Flags'=>$this->getFlags() - ,'OVars'=>get_object_vars($this) - ,'$this'=>$this)); - } + function dump() + { + echo __METHOD__ . "()\n"; + var_dump(array('Flags'=>$this->getFlags() + ,'OVars'=>get_object_vars($this) + ,'$this'=>$this)); + } - function setFlags($flags) - { - echo __METHOD__ . "($flags)\n"; - ArrayIterator::setFlags($flags); - } + function setFlags($flags) + { + echo __METHOD__ . "($flags)\n"; + ArrayIterator::setFlags($flags); + } } class ArrayObjectEx extends ArrayObject { - public $pub1 = 1; - protected $pro1 = 2; - private $pri1 = 3; + public $pub1 = 1; + protected $pro1 = 2; + private $pri1 = 3; - function __construct($ar = array(), $flags = 0) - { - echo __METHOD__ . "()\n"; - parent::__construct($ar, $flags); - $this->imp1 = 4; - } + function __construct($ar = array(), $flags = 0) + { + echo __METHOD__ . "()\n"; + parent::__construct($ar, $flags); + $this->imp1 = 4; + } - function exchange() - { - echo __METHOD__ . "()\n"; - $this->exchangeArray($this); - } + function exchange() + { + echo __METHOD__ . "()\n"; + $this->exchangeArray($this); + } - function dump() - { - echo __METHOD__ . "()\n"; - var_dump(array('Flags'=>$this->getFlags() - ,'OVars'=>get_object_vars($this) - ,'$this'=>$this)); - } + function dump() + { + echo __METHOD__ . "()\n"; + var_dump(array('Flags'=>$this->getFlags() + ,'OVars'=>get_object_vars($this) + ,'$this'=>$this)); + } - function show() - { - echo __METHOD__ . "()\n"; - foreach($this as $n => $v) - { - var_dump(array($n => $v)); - } - } + function show() + { + echo __METHOD__ . "()\n"; + foreach($this as $n => $v) + { + var_dump(array($n => $v)); + } + } - function setFlags($flags) - { - echo __METHOD__ . "($flags)\n"; - ArrayObject::setFlags($flags); - } + function setFlags($flags) + { + echo __METHOD__ . "($flags)\n"; + ArrayObject::setFlags($flags); + } - function getIterator() - { - echo __METHOD__ . "()\n"; - $it = new ArrayIteratorEx($this, $this->getFlags()); - $it->dyn2 = 5; - $it->dump(); - return $it; - } + function getIterator() + { + echo __METHOD__ . "()\n"; + $it = new ArrayIteratorEx($this, $this->getFlags()); + $it->dyn2 = 5; + $it->dump(); + return $it; + } } function check($obj, $flags) { - echo "===CHECK===\n"; + echo "===CHECK===\n"; - $obj->setFlags($flags); - $obj->dump(); - $obj->show(); + $obj->setFlags($flags); + $obj->dump(); + $obj->show(); - echo "===FOREACH===\n"; + echo "===FOREACH===\n"; - $it = $obj->getIterator(); - foreach($it as $n => $v) - { - var_dump(array($n => $v)); - } + $it = $obj->getIterator(); + foreach($it as $n => $v) + { + var_dump(array($n => $v)); + } - echo "===PROPERTY===\n"; + echo "===PROPERTY===\n"; - var_dump($obj->pub1); - var_dump(isset($obj->a)); - $obj->setFlags($flags | 2); - var_dump($obj->pub1); - var_dump(isset($obj->a)); + var_dump($obj->pub1); + var_dump(isset($obj->a)); + $obj->setFlags($flags | 2); + var_dump($obj->pub1); + var_dump(isset($obj->a)); - var_dump($it->pub2); - var_dump(isset($it->pub1)); - $it->setFlags($flags | 2); - var_dump($it->pub2); - var_dump(isset($it->pub1)); + var_dump($it->pub2); + var_dump(isset($it->pub1)); + $it->setFlags($flags | 2); + var_dump($it->pub2); + var_dump(isset($it->pub1)); } $obj = new ArrayObjectEx(array(0=>1,'a'=>25, 'pub1'=>42), 0); diff --git a/ext/spl/tests/array_018.phpt b/ext/spl/tests/array_018.phpt index 2fe18daa596b..8da46a24dba9 100644 Binary files a/ext/spl/tests/array_018.phpt and b/ext/spl/tests/array_018.phpt differ diff --git a/ext/spl/tests/array_019.phpt b/ext/spl/tests/array_019.phpt index 9a10a2e36520..2a86e7058938 100644 --- a/ext/spl/tests/array_019.phpt +++ b/ext/spl/tests/array_019.phpt @@ -9,10 +9,10 @@ $ar = new RecursiveArrayIterator(array(3)); foreach($ar as &$v) var_dump($v); class ArrayIteratorEx extends ArrayIterator { - function current() - { - return ArrayIterator::current(); - } + function current() + { + return ArrayIterator::current(); + } } $ar = new ArrayIteratorEx(array(4)); foreach($ar as $v) var_dump($v); diff --git a/ext/spl/tests/array_020.phpt b/ext/spl/tests/array_020.phpt index 3a218bdabc16..fa96f92ab330 100644 --- a/ext/spl/tests/array_020.phpt +++ b/ext/spl/tests/array_020.phpt @@ -5,42 +5,42 @@ SPL: ArrayIterator overloading class ArrayIteratorEx extends ArrayIterator { - function rewind() - { - echo __METHOD__ . "\n"; - ArrayIterator::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + ArrayIterator::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - return ArrayIterator::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + return ArrayIterator::valid(); + } - function key() - { - echo __METHOD__ . "\n"; - return ArrayIterator::key(); - } + function key() + { + echo __METHOD__ . "\n"; + return ArrayIterator::key(); + } - function current() - { - echo __METHOD__ . "\n"; - return ArrayIterator::current(); - } + function current() + { + echo __METHOD__ . "\n"; + return ArrayIterator::current(); + } - function next() - { - echo __METHOD__ . "\n"; - return ArrayIterator::next(); - } + function next() + { + echo __METHOD__ . "\n"; + return ArrayIterator::next(); + } } $ar = new ArrayIteratorEx(array(1,2)); foreach($ar as $k => $v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } ?> diff --git a/ext/spl/tests/array_021.phpt b/ext/spl/tests/array_021.phpt index f2f0fd3d73c3..620347dcd7b7 100644 --- a/ext/spl/tests/array_021.phpt +++ b/ext/spl/tests/array_021.phpt @@ -5,22 +5,22 @@ SPL: ArrayObject::seek() and exceptions class foo extends ArrayObject { - public function seek($key) - { - echo __METHOD__ . "($key)\n"; - throw new Exception("hi"); - } + public function seek($key) + { + echo __METHOD__ . "($key)\n"; + throw new Exception("hi"); + } } $test = new foo(array(1,2,3)); try { - $test->seek('bar'); + $test->seek('bar'); } catch (Exception $e) { - echo "got exception\n"; + echo "got exception\n"; } ?> diff --git a/ext/spl/tests/array_022.phpt b/ext/spl/tests/array_022.phpt index ffb75ec3d432..f7407bf602c7 100644 --- a/ext/spl/tests/array_022.phpt +++ b/ext/spl/tests/array_022.phpt @@ -6,11 +6,11 @@ SPL: ArrayObject/Iterator and reference to self class MyArrayObject extends ArrayObject { - public function __construct() - { - parent::__construct($this); - $this['bar'] = 'baz'; - } + public function __construct() + { + parent::__construct($this); + $this['bar'] = 'baz'; + } } $a = new MyArrayObject; @@ -27,11 +27,11 @@ var_dump($b); class MyArrayIterator extends ArrayIterator { - public function __construct() - { - parent::__construct($this); - $this['bar'] = 'baz'; - } + public function __construct() + { + parent::__construct($this); + $this['bar'] = 'baz'; + } } $a = new MyArrayIterator; diff --git a/ext/spl/tests/bug31185.phpt b/ext/spl/tests/bug31185.phpt index 0086c64a3451..88cb3dbf7ca5 100644 --- a/ext/spl/tests/bug31185.phpt +++ b/ext/spl/tests/bug31185.phpt @@ -4,25 +4,25 @@ Bug #31185 (Crash when exceptions thrown from ArrayAccess::offsetUnset()) array[$index]); - } + public function offsetExists($index) { + return isset($this->array[$index]); + } - public function offsetGet($index) { - return $this->array[$index]; - } + public function offsetGet($index) { + return $this->array[$index]; + } - public function offsetSet($index, $value) { - echo __METHOD__ . "($index, $value)\n"; - $this->array[$index] = $value; - } + public function offsetSet($index, $value) { + echo __METHOD__ . "($index, $value)\n"; + $this->array[$index] = $value; + } - public function offsetUnset($index) { - throw new Exception('FAIL'); - unset($this->array[$index]); - } + public function offsetUnset($index) { + throw new Exception('FAIL'); + unset($this->array[$index]); + } } @@ -33,11 +33,11 @@ $foo[$j++] = $i++; $foo[$j++] = $i++; try { - unset($foo[1]); + unset($foo[1]); } catch (Exception $e) { - echo "CAUGHT: " . $e->getMessage() . "\n"; + echo "CAUGHT: " . $e->getMessage() . "\n"; } print_R($foo); diff --git a/ext/spl/tests/bug32134.phpt b/ext/spl/tests/bug32134.phpt index 7a6012b7f897..a81924ed1d29 100644 --- a/ext/spl/tests/bug32134.phpt +++ b/ext/spl/tests/bug32134.phpt @@ -13,7 +13,7 @@ class myArray extends ArrayIterator public function offsetGet($index) { - static $i = 0; + static $i = 0; echo __METHOD__ . "($index)\n"; if (++$i > 3) exit(1); return parent::offsetGet($index); diff --git a/ext/spl/tests/bug32394.phpt b/ext/spl/tests/bug32394.phpt index 8189b23f7a97..519b0b049e67 100644 --- a/ext/spl/tests/bug32394.phpt +++ b/ext/spl/tests/bug32394.phpt @@ -8,7 +8,7 @@ $object->append(1); foreach($object as $key => $value) { - $object->offsetUnset($key); + $object->offsetUnset($key); } ?> diff --git a/ext/spl/tests/bug33136.phpt b/ext/spl/tests/bug33136.phpt index 1e1e3a18dcb1..8b52eae5998d 100644 --- a/ext/spl/tests/bug33136.phpt +++ b/ext/spl/tests/bug33136.phpt @@ -5,25 +5,25 @@ Bug #33136 (method offsetSet in class extended from ArrayObject crash PHP) class Collection extends ArrayObject { - private $data; + private $data; - function __construct() - { - $this->data = array(); - parent::__construct($this->data); - } + function __construct() + { + $this->data = array(); + parent::__construct($this->data); + } - function offsetGet($index) - { - echo __METHOD__ . "($index)\n"; - return parent::offsetGet($index); - } + function offsetGet($index) + { + echo __METHOD__ . "($index)\n"; + return parent::offsetGet($index); + } - function offsetSet($index, $value) - { - echo __METHOD__ . "(" . (is_null($index) ? "NULL" : $index) . ",$value)\n"; - parent::offsetSet($index, $value); - } + function offsetSet($index, $value) + { + echo __METHOD__ . "(" . (is_null($index) ? "NULL" : $index) . ",$value)\n"; + parent::offsetSet($index, $value); + } } echo "\n\nInitiate Obj\n"; diff --git a/ext/spl/tests/bug34548.phpt b/ext/spl/tests/bug34548.phpt index 399aa3378807..4615b1306bd8 100644 --- a/ext/spl/tests/bug34548.phpt +++ b/ext/spl/tests/bug34548.phpt @@ -5,15 +5,15 @@ Bug #34548 (Method append() in class extended from ArrayObject crashes PHP) class Collection extends ArrayObject { - public function add($dataArray) - { - foreach($dataArray as $value) $this->append($value); - } + public function add($dataArray) + { + foreach($dataArray as $value) $this->append($value); + } - public function offsetSet($index, $value) - { - parent::offsetSet($index, $value); - } + public function offsetSet($index, $value) + { + parent::offsetSet($index, $value); + } } $data1=array('one', 'two', 'three'); diff --git a/ext/spl/tests/bug36258.phpt b/ext/spl/tests/bug36258.phpt index db7bfa7c70f7..5e61b2992879 100644 --- a/ext/spl/tests/bug36258.phpt +++ b/ext/spl/tests/bug36258.phpt @@ -6,9 +6,9 @@ Bug #36258 (SplFileObject::getPath() may lead to segfault) $diriter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator('.') ); foreach ($diriter as $key => $file) { - var_dump($file->getFilename()); - var_dump($file->getPath()); - break; + var_dump($file->getFilename()); + var_dump($file->getPath()); + break; } ?> diff --git a/ext/spl/tests/bug36287.phpt b/ext/spl/tests/bug36287.phpt index e4970cbf3b59..0fa6e1bc1eef 100644 --- a/ext/spl/tests/bug36287.phpt +++ b/ext/spl/tests/bug36287.phpt @@ -8,14 +8,14 @@ $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("."), true); $idx = 0; foreach($it as $file) { - echo "First\n"; - var_Dump($file->getFilename()); - echo "Second\n"; - var_dump($file->getFilename()); - if (++$idx > 1) - { - break; - } + echo "First\n"; + var_Dump($file->getFilename()); + echo "Second\n"; + var_dump($file->getFilename()); + if (++$idx > 1) + { + break; + } } ?> diff --git a/ext/spl/tests/bug36825.phpt b/ext/spl/tests/bug36825.phpt index 4aa6cf4d13b0..072009cf8424 100644 --- a/ext/spl/tests/bug36825.phpt +++ b/ext/spl/tests/bug36825.phpt @@ -5,22 +5,22 @@ Bug #36825 (Exceptions thrown in ArrayObject::offsetGet cause segfault) class foo extends ArrayObject { - public function offsetGet($key) - { - echo __METHOD__ . "($key)\n"; - throw new Exception("hi"); - } + public function offsetGet($key) + { + echo __METHOD__ . "($key)\n"; + throw new Exception("hi"); + } } $test = new foo(); try { - var_dump($test['bar']); + var_dump($test['bar']); } catch (Exception $e) { - echo "got exception\n"; + echo "got exception\n"; } ?> diff --git a/ext/spl/tests/bug37457.phpt b/ext/spl/tests/bug37457.phpt index 9f723c94fbff..792d5ae2a7a3 100644 --- a/ext/spl/tests/bug37457.phpt +++ b/ext/spl/tests/bug37457.phpt @@ -5,51 +5,51 @@ Bug #37457 (Crash when an exception is thrown in accept() method of FilterIterat class Collection implements Iterator { - protected $array, $valid = false; + protected $array, $valid = false; - public function __construct(array $a) - { - echo __METHOD__ . "\n"; - $this->array = $a; - } + public function __construct(array $a) + { + echo __METHOD__ . "\n"; + $this->array = $a; + } - public function current() - { - echo __METHOD__ . "\n"; - return current($this->array); - } + public function current() + { + echo __METHOD__ . "\n"; + return current($this->array); + } - public function key() - { - echo __METHOD__ . "\n"; - return key($this->array); - } + public function key() + { + echo __METHOD__ . "\n"; + return key($this->array); + } - public function next() - { - echo __METHOD__ . "\n"; - $this->valid = (false !== next($this->array)); - } + public function next() + { + echo __METHOD__ . "\n"; + $this->valid = (false !== next($this->array)); + } - public function valid() - { - echo __METHOD__ . "\n"; - return $this->valid; - } + public function valid() + { + echo __METHOD__ . "\n"; + return $this->valid; + } - public function rewind() - { - echo __METHOD__ . "\n"; - $this->valid = (false !== reset($this->array)); - } + public function rewind() + { + echo __METHOD__ . "\n"; + $this->valid = (false !== reset($this->array)); + } } class TestFilter extends FilterIterator { public function accept() { - echo __METHOD__ . "\n"; - throw new Exception("Failure in Accept"); + echo __METHOD__ . "\n"; + throw new Exception("Failure in Accept"); } } @@ -57,14 +57,14 @@ $test = new TestFilter(new Collection(array(0))); try { - foreach ($test as $item) - { - echo $item; - } + foreach ($test as $item) + { + echo $item; + } } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/spl/tests/bug40091.phpt b/ext/spl/tests/bug40091.phpt index f5719751e4ba..3bb1bbf15238 100644 --- a/ext/spl/tests/bug40091.phpt +++ b/ext/spl/tests/bug40091.phpt @@ -3,10 +3,10 @@ Bug #40091 (issue with spl_autoload_register() and 2 instances of the same class --FILE-- id = $id; - } - } + function __construct($id) { + $this->id = $id; + } + } - class ProjectsList extends ArrayIterator { - public function add(Project $item) { - $this->offsetSet($item->id, $item); - } - } + class ProjectsList extends ArrayIterator { + public function add(Project $item) { + $this->offsetSet($item->id, $item); + } + } - $projects = new ProjectsList(); - $projects->add(new Project('1')); - $projects->add(new Project(2)); + $projects = new ProjectsList(); + $projects->add(new Project('1')); + $projects->add(new Project(2)); - var_dump($projects->offsetExists(1)); - var_dump($projects->offsetExists('2')); + var_dump($projects->offsetExists(1)); + var_dump($projects->offsetExists('2')); ?> --EXPECT-- bool(true) diff --git a/ext/spl/tests/bug41691.phpt b/ext/spl/tests/bug41691.phpt index d1c53a6fe691..93af430b4884 100644 --- a/ext/spl/tests/bug41691.phpt +++ b/ext/spl/tests/bug41691.phpt @@ -4,12 +4,12 @@ Bug #41691 (ArrayObject::exchangeArray hangs Apache) $value) { - echo $key, $value; + echo $key, $value; } } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } var_dump($itit->current()); diff --git a/ext/spl/tests/bug45614.phpt b/ext/spl/tests/bug45614.phpt index d9e9207d2851..8c688555d379 100644 --- a/ext/spl/tests/bug45614.phpt +++ b/ext/spl/tests/bug45614.phpt @@ -3,12 +3,12 @@ SPL: Bug#45614 (ArrayIterator can show 1st private prop of wrapped object) --FILE-- p) misbehaves with ArrayObject::ARRAY_AS_PR 'array element')); diff --git a/ext/spl/tests/bug45622b.phpt b/ext/spl/tests/bug45622b.phpt index bf0ab8242e3c..c829b185dd6c 100644 --- a/ext/spl/tests/bug45622b.phpt +++ b/ext/spl/tests/bug45622b.phpt @@ -3,10 +3,10 @@ Ensure fix to bug45622 doesn't cause __isset() to be called when ArrayObject::AR --FILE-- offsetSet(0, 0); + $x = new splqueue; + $x->offsetSet(0, 0); } catch (Exception $e) { } ?> diff --git a/ext/spl/tests/bug50579.phpt b/ext/spl/tests/bug50579.phpt index 7bc5deede861..fcf75b4b8d7b 100644 --- a/ext/spl/tests/bug50579.phpt +++ b/ext/spl/tests/bug50579.phpt @@ -4,30 +4,30 @@ Bug #50579 (RegexIterator::REPLACE doesn't work) 'test888', - 'test2'=>'what?', - 'test3'=>'test999')); - } + public function __construct( ) { + parent::__construct(array( + 'test1'=>'test888', + 'test2'=>'what?', + 'test3'=>'test999')); + } } $h = new foo; $i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); $i->replacement = '[$0]'; foreach ($i as $name=>$value) { - echo $name . '=>' . $value . "\n"; + echo $name . '=>' . $value . "\n"; } $i->replacement = '$1'; foreach ($i as $name=>$value) { - echo $name . '=>' . $value . "\n"; + echo $name . '=>' . $value . "\n"; } $h = new foo; $i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); $i->replacement = '[$1]'; foreach ($i as $name=>$value) { - echo $name . '=>' . $value . "\n"; + echo $name . '=>' . $value . "\n"; } ?> diff --git a/ext/spl/tests/bug51068.phpt b/ext/spl/tests/bug51068.phpt index 0263536cc38e..fd49c03be3de 100644 --- a/ext/spl/tests/bug51068.phpt +++ b/ext/spl/tests/bug51068.phpt @@ -7,8 +7,8 @@ mkdir('bug.51068.dir'); touch('bug.51068.dir/lvl2.bug.51068'); $iter = new DirectoryIterator('glob://*.51068'); foreach ($iter as $f) { - var_dump($f->getFilename()); - var_dump($f->getSize()); + var_dump($f->getFilename()); + var_dump($f->getSize()); } $iter = new DirectoryIterator('glob://bug.51068.dir/*.51068'); foreach ($iter as $f) { diff --git a/ext/spl/tests/bug53071.phpt b/ext/spl/tests/bug53071.phpt index 4a2450e20159..9ab108cfd578 100644 --- a/ext/spl/tests/bug53071.phpt +++ b/ext/spl/tests/bug53071.phpt @@ -5,16 +5,16 @@ Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles) gc_enable(); class myClass { - public $member; + public $member; } function LimitedScope() { - $myA = new myClass(); - $myB = new SplObjectStorage(); - $myC = new myClass(); - $myC->member = $myA; // myC has a reference to myA - $myB->Attach($myC); // myB attaches myC - $myA->member = $myB; // myA has myB, comleting the cycle + $myA = new myClass(); + $myB = new SplObjectStorage(); + $myC = new myClass(); + $myC->member = $myA; // myC has a reference to myA + $myB->Attach($myC); // myB attaches myC + $myA->member = $myB; // myA has myB, comleting the cycle } LimitedScope(); var_dump(gc_collect_cycles()); diff --git a/ext/spl/tests/bug53362.phpt b/ext/spl/tests/bug53362.phpt index 7ae74ce5597b..eec1f037eba0 100644 --- a/ext/spl/tests/bug53362.phpt +++ b/ext/spl/tests/bug53362.phpt @@ -4,9 +4,9 @@ Bug #53362 (Segmentation fault when extending SplFixedArray) getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/spl/tests/bug54304.phpt b/ext/spl/tests/bug54304.phpt index 143c26e1537a..5c6991a1ad99 100644 --- a/ext/spl/tests/bug54304.phpt +++ b/ext/spl/tests/bug54304.phpt @@ -3,10 +3,10 @@ Bug #54304 (Setting replacement value for RegexIterator doesn't work) --FILE-- 'test999')); - } + public function __construct( ) { + parent::__construct(array( + 'test3'=>'test999')); + } } $h = new foo; @@ -14,7 +14,7 @@ $i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); $i->replacement = 42; var_dump($i->replacement); foreach ($i as $name=>$value) { - var_dump($name, $value); + var_dump($name, $value); } var_dump($i->replacement); ?> diff --git a/ext/spl/tests/bug54384.phpt b/ext/spl/tests/bug54384.phpt index a9dae2e73630..581845a43ab1 100644 --- a/ext/spl/tests/bug54384.phpt +++ b/ext/spl/tests/bug54384.phpt @@ -4,12 +4,12 @@ Bug #54384: Several SPL classes crash when the parent constructor is not called rewind(); + $o = new IteratorIteratorTest; + $o->rewind(); } ); echo "FilterIterator... "; @@ -27,8 +27,8 @@ class FilterIteratorTest extends FilterIterator { function accept(){} } test( function() { - $o = new FilterIteratorTest; - $o->rewind(); + $o = new FilterIteratorTest; + $o->rewind(); } ); echo "RecursiveFilterIterator... "; diff --git a/ext/spl/tests/bug61453.phpt b/ext/spl/tests/bug61453.phpt index e5b1387fd2e4..92312d542fda 100644 --- a/ext/spl/tests/bug61453.phpt +++ b/ext/spl/tests/bug61453.phpt @@ -5,13 +5,13 @@ Bug #61453: SplObjectStorage does not identify objects correctly $limit = 1000; $objects = new SplObjectStorage; for($i = 0; $i < $limit; $i++){ - $object = new StdClass; + $object = new StdClass; - if(isset($objects[$object])){ - die("this should never happen, but did after $i iteration"); - } + if(isset($objects[$object])){ + die("this should never happen, but did after $i iteration"); + } - $objects[$object] = 1; + $objects[$object] = 1; } ?> ==DONE== diff --git a/ext/spl/tests/bug64023.phpt b/ext/spl/tests/bug64023.phpt index cb984452798e..82924659e06a 100644 --- a/ext/spl/tests/bug64023.phpt +++ b/ext/spl/tests/bug64023.phpt @@ -4,7 +4,7 @@ Bug #64023: Overloading __toString() in SplFileInfo has no effect '', 'bar' => null, 'baz' => 42]; diff --git a/ext/spl/tests/bug67359.phpt b/ext/spl/tests/bug67359.phpt index 3e8f30cd2bb2..3a867f1f8766 100644 --- a/ext/spl/tests/bug67359.phpt +++ b/ext/spl/tests/bug67359.phpt @@ -4,20 +4,20 @@ Bug #67359 (Segfault in recursiveDirectoryIterator) seek(1); - while( $it->valid()) - { - if( $it->isFile() ) - { - $it->current(); - } + $rdi = new recursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS); + $it = new recursiveIteratorIterator( $rdi ); + $it->seek(1); + while( $it->valid()) + { + if( $it->isFile() ) + { + $it->current(); + } - $it->next(); - } + $it->next(); + } - $it->current(); + $it->current(); } catch(Exception $e) { diff --git a/ext/spl/tests/bug67582.phpt b/ext/spl/tests/bug67582.phpt index b22f61503464..331accbe7e72 100644 --- a/ext/spl/tests/bug67582.phpt +++ b/ext/spl/tests/bug67582.phpt @@ -4,8 +4,8 @@ Bug #67582: Cloned SplObjectStorage with overwritten getHash fails offsetExists( $value1) { // print all children echo "Children: "; foreach ($rRegexIterator->getChildren() as $key => $value) { - print_r($value); + print_r($value); } echo "\n"; } else { echo "No children "; - print_r($value1); - echo "\n"; + print_r($value1); + echo "\n"; } } diff --git a/ext/spl/tests/bug69108.phpt b/ext/spl/tests/bug69108.phpt index 1829e9b2a253..3122da599c64 100644 --- a/ext/spl/tests/bug69108.phpt +++ b/ext/spl/tests/bug69108.phpt @@ -7,9 +7,9 @@ zend.enable_gc=1 $a = array(); $b = new SplObjectStorage(); for ($i = 10000; $i > 0; $i--) { - $object = new StdClass(); - $a[] = $object; - $b->attach($object); + $object = new StdClass(); + $a[] = $object; + $b->attach($object); } $c = serialize(array($a, $b)); diff --git a/ext/spl/tests/bug69335.phpt b/ext/spl/tests/bug69335.phpt index 3b065b64738e..acd5588b3e8e 100644 --- a/ext/spl/tests/bug69335.phpt +++ b/ext/spl/tests/bug69335.phpt @@ -6,10 +6,10 @@ $a = array(1=>1, 3=>3, 5=>5, 7=>7); $a = new ArrayObject($a); foreach ($a as $k => $v) { - var_dump("$k => $v"); - if ($k == 3) { - $a['a'] = "?"; - } + var_dump("$k => $v"); + if ($k == 3) { + $a['a'] = "?"; + } } ?> --EXPECT-- diff --git a/ext/spl/tests/bug69845.phpt b/ext/spl/tests/bug69845.phpt index db88a8e10d31..09c9f2356d44 100644 --- a/ext/spl/tests/bug69845.phpt +++ b/ext/spl/tests/bug69845.phpt @@ -3,9 +3,9 @@ Fixed bug #69845 (ArrayObject with ARRAY_AS_PROPS broken) --FILE-- itemType = 'bulletin'; - var_dump(!is_null($data['itemType'])); + $data = new \ArrayObject(new stdClass(), ArrayObject::ARRAY_AS_PROPS); + $data->itemType = 'bulletin'; + var_dump(!is_null($data['itemType'])); } ?> --EXPECT-- diff --git a/ext/spl/tests/bug69970.phpt b/ext/spl/tests/bug69970.phpt index a488037b8cf9..c82d0b58c67a 100644 --- a/ext/spl/tests/bug69970.phpt +++ b/ext/spl/tests/bug69970.phpt @@ -10,12 +10,12 @@ class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { echo "dummy\n"; } function endChildren() { - global $count; - echo $this->getDepth(); - if (--$count > 0) { - // Trigger use-after-free - parent::rewind(); - } + global $count; + echo $this->getDepth(); + if (--$count > 0) { + // Trigger use-after-free + parent::rewind(); + } } } $arr = array("a", array("ba", array("bba", "bbb"))); diff --git a/ext/spl/tests/bug70068.phpt b/ext/spl/tests/bug70068.phpt index dc949da8fa68..54f3cca44963 100644 --- a/ext/spl/tests/bug70068.phpt +++ b/ext/spl/tests/bug70068.phpt @@ -5,7 +5,7 @@ Bug #70068 (Dangling pointer in the unserialization of ArrayObject items) try { $a = unserialize('a:3:{i:0;C:11:"ArrayObject":20:{x:i:0;r:3;;m:a:0:{};}i:1;d:11;i:2;S:31:"AAAAAAAABBBBCCCC\01\00\00\00\04\00\00\00\00\00\00\00\00\00\00";}'); } catch(Exception $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } ?> OK diff --git a/ext/spl/tests/bug70365.phpt b/ext/spl/tests/bug70365.phpt index c18110e3ca17..06786aaf16ea 100644 --- a/ext/spl/tests/bug70365.phpt +++ b/ext/spl/tests/bug70365.phpt @@ -3,10 +3,10 @@ SPL: Bug #70365 use-after-free vulnerability in unserialize() with SplObjectStor --FILE-- ryat = 1; - } + var $ryat; + function __wakeup() { + $this->ryat = 1; + } } $fakezval = ptr2str(1122334455); @@ -25,12 +25,12 @@ var_dump($data); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } --EXPECTF-- array(5) { diff --git a/ext/spl/tests/bug70366.phpt b/ext/spl/tests/bug70366.phpt index da4cc2d38959..d3d3317bff37 100644 --- a/ext/spl/tests/bug70366.phpt +++ b/ext/spl/tests/bug70366.phpt @@ -3,10 +3,10 @@ SPL: Bug #70366 use-after-free vulnerability in unserialize() with SplDoublyLink --FILE-- ryat = 1; - } + var $ryat; + function __wakeup() { + $this->ryat = 1; + } } $fakezval = ptr2str(1122334455); @@ -25,12 +25,12 @@ var_dump($data); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/spl/tests/bug70730.phpt b/ext/spl/tests/bug70730.phpt index 5710c9586de8..9d522384262c 100644 --- a/ext/spl/tests/bug70730.phpt +++ b/ext/spl/tests/bug70730.phpt @@ -4,20 +4,20 @@ Bug #70730 (Incorrect ArrayObject serialization if unset is called in serialize( foo = 'bar'; - } + public function __construct() + { + $this->foo = 'bar'; + } - public function serialize() - { - unset($this->foo); - $result = parent::serialize(); - $this->foo = 'bar'; - return $result; - } + public function serialize() + { + unset($this->foo); + $result = parent::serialize(); + $this->foo = 'bar'; + return $result; + } } $a = new A(); diff --git a/ext/spl/tests/bug70959.phpt b/ext/spl/tests/bug70959.phpt index 541807ae16fd..fde022ab9291 100644 --- a/ext/spl/tests/bug70959.phpt +++ b/ext/spl/tests/bug70959.phpt @@ -3,15 +3,15 @@ Bug #70959 (ArrayObject unserialize does not restore protected fields) --FILE-- test; - } + public function getTest() { + return $this->test; + } - public function setTest($test) { - $this->test = $test; - } + public function setTest($test) { + $this->test = $test; + } } $obj = new testObject(); diff --git a/ext/spl/tests/bug71028.phpt b/ext/spl/tests/bug71028.phpt index b8f0cc962f63..20aa4467e948 100644 --- a/ext/spl/tests/bug71028.phpt +++ b/ext/spl/tests/bug71028.phpt @@ -3,7 +3,7 @@ Bug #71028 (Undefined index with ArrayIterator) --FILE-- --EXPECT-- diff --git a/ext/spl/tests/bug71204.phpt b/ext/spl/tests/bug71204.phpt index 64fa13bfb13a..a984690fcbc4 100644 --- a/ext/spl/tests/bug71204.phpt +++ b/ext/spl/tests/bug71204.phpt @@ -4,7 +4,7 @@ Bug #71204 (segfault if clean spl_autoload_funcs while autoloading ) name = $name; - return $this; - } - - public function getName() - { - return $this->name; - } + private $name = null; + + public function __construct(array $input) + { + parent::__construct($input, ArrayObject::ARRAY_AS_PROPS); + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } } $test = new Test(['a' => 'a', 'b' => 'b']); diff --git a/ext/spl/tests/bug71735.phpt b/ext/spl/tests/bug71735.phpt index ea6cf347ea15..fd89cade786e 100644 --- a/ext/spl/tests/bug71735.phpt +++ b/ext/spl/tests/bug71735.phpt @@ -6,7 +6,7 @@ try { $var_1=new SplStack(); $var_1->offsetSet(100,new DateTime('2000-01-01')); } catch(OutOfRangeException $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/bug72051.phpt b/ext/spl/tests/bug72051.phpt index 1dfc056d7ed8..b0fe05169ab1 100644 --- a/ext/spl/tests/bug72051.phpt +++ b/ext/spl/tests/bug72051.phpt @@ -4,12 +4,12 @@ Bug #72051 (The reference in CallbackFilterIterator doesn't work as expected) rewind(); diff --git a/ext/spl/tests/bug72684.phpt b/ext/spl/tests/bug72684.phpt index 7a99901f5343..06665efdaab7 100644 --- a/ext/spl/tests/bug72684.phpt +++ b/ext/spl/tests/bug72684.phpt @@ -11,9 +11,9 @@ $appendIterator->append($generator); iterator_to_array($appendIterator); try { - iterator_to_array($appendIterator); + iterator_to_array($appendIterator); } catch (\Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/bug72888.phpt b/ext/spl/tests/bug72888.phpt index c27c8424efa8..5e1aa2344be9 100644 --- a/ext/spl/tests/bug72888.phpt +++ b/ext/spl/tests/bug72888.phpt @@ -5,9 +5,9 @@ Bug #72888 (Segfault on clone on splFileObject) $x = new SplFileObject(__FILE__); try { - $y=clone $x; + $y=clone $x; } catch (Error $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } var_dump($y); ?> diff --git a/ext/spl/tests/bug73029.phpt b/ext/spl/tests/bug73029.phpt index 8789e91df2be..5c3cd8420da8 100644 --- a/ext/spl/tests/bug73029.phpt +++ b/ext/spl/tests/bug73029.phpt @@ -7,7 +7,7 @@ $a = 'C:11:"ArrayObject":19:0x:i:0;r:2;;m:a:0:{}}'; $m = unserialize($a); $x = $m[2]; } catch(UnexpectedValueException $e) { - print $e->getMessage() . "\n"; + print $e->getMessage() . "\n"; } ?> DONE diff --git a/ext/spl/tests/bug73423.phpt b/ext/spl/tests/bug73423.phpt index 549ceabb8a29..451748e52b88 100644 --- a/ext/spl/tests/bug73423.phpt +++ b/ext/spl/tests/bug73423.phpt @@ -48,7 +48,7 @@ class fooIterator extends \RecursiveFilterIterator { public Function __destruct () { - eval("class A extends NotExists {}"); + eval("class A extends NotExists {}"); /* CRASH */ } diff --git a/ext/spl/tests/bug73686.phpt b/ext/spl/tests/bug73686.phpt index ae9a59c4aaa5..51858bc33ced 100644 --- a/ext/spl/tests/bug73686.phpt +++ b/ext/spl/tests/bug73686.phpt @@ -7,8 +7,8 @@ $ao = new ArrayObject; foreach ([1, 2, 3] as $i => $var) { - settype($var, 'string'); - $ao[$i] = $var; + settype($var, 'string'); + $ao[$i] = $var; } var_dump($ao); @@ -16,7 +16,7 @@ $ao = new ArrayObject; foreach ([1, 2, 3] as $i => $var) { - $ao[$i] = &$var; + $ao[$i] = &$var; } var_dump($ao); ?> diff --git a/ext/spl/tests/bug73896.phpt b/ext/spl/tests/bug73896.phpt index 08d8f1e6c8c7..18e54644a996 100644 --- a/ext/spl/tests/bug73896.phpt +++ b/ext/spl/tests/bug73896.phpt @@ -18,7 +18,7 @@ class teLoader { } protected function autoload($class) { - die("Protected autoload() called!\n"); + die("Protected autoload() called!\n"); } public function doSomething() { @@ -29,9 +29,9 @@ class teLoader { $teLoader = new teLoader(); try { - new teChild(); + new teChild(); } catch (Throwable $e) { - echo "Exception: ", $e->getMessage() , "\n"; + echo "Exception: ", $e->getMessage() , "\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/bug74519.phpt b/ext/spl/tests/bug74519.phpt index 537366d498b0..5a2b958d012e 100644 --- a/ext/spl/tests/bug74519.phpt +++ b/ext/spl/tests/bug74519.phpt @@ -10,8 +10,8 @@ $iterator->append($events); $events->next(); while($iterator->valid()) { - echo $iterator->current(), "\n"; - $iterator->next(); + echo $iterator->current(), "\n"; + $iterator->next(); } ?> --EXPECT-- diff --git a/ext/spl/tests/bug75049.phpt b/ext/spl/tests/bug75049.phpt index eafdb8454112..cf1f80367c31 100644 --- a/ext/spl/tests/bug75049.phpt +++ b/ext/spl/tests/bug75049.phpt @@ -9,7 +9,7 @@ echo (int)spl_autoload_register($autoloader); echo (int)spl_autoload_unregister($autoloader); echo (int)spl_autoload_register($autoloader); foreach (spl_autoload_functions() as $loader) { - echo (int)spl_autoload_unregister($loader); + echo (int)spl_autoload_unregister($loader); } echo (int)count(spl_autoload_functions()); --EXPECT-- diff --git a/ext/spl/tests/bug76367.phpt b/ext/spl/tests/bug76367.phpt index 38aefbc922ee..7e9d7e66ba18 100644 --- a/ext/spl/tests/bug76367.phpt +++ b/ext/spl/tests/bug76367.phpt @@ -7,7 +7,7 @@ $arr = [1,3,55,66,43,6]; $iter = new NoRewindIterator(new ArrayIterator($arr)); while($iter->valid()) { - $iter->next(); + $iter->next(); } var_dump($iter->current()); diff --git a/ext/spl/tests/class_implements_variation1.phpt b/ext/spl/tests/class_implements_variation1.phpt index 26368ca7094a..65fbe1a58a60 100644 --- a/ext/spl/tests/class_implements_variation1.phpt +++ b/ext/spl/tests/class_implements_variation1.phpt @@ -13,10 +13,10 @@ echo "*** Testing class_implements() : variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -33,9 +33,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/spl/tests/class_uses_variation1.phpt b/ext/spl/tests/class_uses_variation1.phpt index 5962e904c474..c26fb67e0f56 100644 --- a/ext/spl/tests/class_uses_variation1.phpt +++ b/ext/spl/tests/class_uses_variation1.phpt @@ -13,10 +13,10 @@ echo "*** Testing class_uses() : variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -33,9 +33,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/spl/tests/countable_count_variation1.phpt b/ext/spl/tests/countable_count_variation1.phpt index 0a9939932979..8ce29410d9ab 100644 --- a/ext/spl/tests/countable_count_variation1.phpt +++ b/ext/spl/tests/countable_count_variation1.phpt @@ -4,32 +4,32 @@ SPL: Countable::count() with wrong return types and exception. getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/dit_002.phpt b/ext/spl/tests/dit_002.phpt index 17f8d01346e9..f456101ed2f6 100644 --- a/ext/spl/tests/dit_002.phpt +++ b/ext/spl/tests/dit_002.phpt @@ -6,41 +6,41 @@ SPL: DirectoryIterator defaults 0, - 'FilesystemIterator' => 1, - 'RecursiveDirectoryIterator' => 1, - 'GlobIterator' => 1, + 'DirectoryIterator' => 0, + 'FilesystemIterator' => 1, + 'RecursiveDirectoryIterator' => 1, + 'GlobIterator' => 1, ); foreach ($classes as $class => $flags) { - echo "===$class===\n"; - $ref = new ReflectionClass($class); - $obj = $ref->newInstance('glob://*'); - echo get_class($obj->current()) . "\n"; - if ($flags) - { - var_dump($obj->getFlags()); - $flags = array( - FilesystemIterator::CURRENT_AS_FILEINFO => 0, - FilesystemIterator::CURRENT_AS_SELF => 0, - FilesystemIterator::CURRENT_AS_PATHNAME => 1, - ); - foreach($flags as $flag => $isstring) { - $obj->setFlags($flag); - $obj->rewind(); - var_dump($obj->getFlags()); - if ($isstring) { - $val = $obj->current(); - if (is_string($val)) { - var_dump(true); - } else { - var_dump($val); - } - } else { - echo get_class($obj->current()) . "\n"; - } - } - } + echo "===$class===\n"; + $ref = new ReflectionClass($class); + $obj = $ref->newInstance('glob://*'); + echo get_class($obj->current()) . "\n"; + if ($flags) + { + var_dump($obj->getFlags()); + $flags = array( + FilesystemIterator::CURRENT_AS_FILEINFO => 0, + FilesystemIterator::CURRENT_AS_SELF => 0, + FilesystemIterator::CURRENT_AS_PATHNAME => 1, + ); + foreach($flags as $flag => $isstring) { + $obj->setFlags($flag); + $obj->rewind(); + var_dump($obj->getFlags()); + if ($isstring) { + $val = $obj->current(); + if (is_string($val)) { + var_dump(true); + } else { + var_dump($val); + } + } else { + echo get_class($obj->current()) . "\n"; + } + } + } } ?> --EXPECTF-- diff --git a/ext/spl/tests/dit_003.phpt b/ext/spl/tests/dit_003.phpt index 0d44a3e8b2e7..f94307587831 100644 --- a/ext/spl/tests/dit_003.phpt +++ b/ext/spl/tests/dit_003.phpt @@ -5,7 +5,7 @@ SPL: FilesystemIterator and foreach $count = 0; foreach(new FilesystemIterator(__DIR__) as $ent) { - ++$count; + ++$count; } var_dump($count > 0); ?> diff --git a/ext/spl/tests/dllist_013.phpt b/ext/spl/tests/dllist_013.phpt index edab2b3056a8..49b89d39a8b5 100644 --- a/ext/spl/tests/dllist_013.phpt +++ b/ext/spl/tests/dllist_013.phpt @@ -5,9 +5,9 @@ SPL: DoublyLinkedList: insert operations $dll = new SplDoublyLinkedList(); // errors try { - $dll->add(2,5); + $dll->add(2,5); } catch (OutOfRangeException $e) { - echo "Exception: ".$e->getMessage()."\n"; + echo "Exception: ".$e->getMessage()."\n"; } $dll->add(0,6); // 6 diff --git a/ext/spl/tests/dualiterator.inc b/ext/spl/tests/dualiterator.inc index eeb8ae869ca0..0830ebe6449f 100644 --- a/ext/spl/tests/dualiterator.inc +++ b/ext/spl/tests/dualiterator.inc @@ -16,195 +16,195 @@ */ class DualIterator implements Iterator { - const CURRENT_LHS = 0x01; - const CURRENT_RHS = 0x02; - const CURRENT_ARRAY = 0x03; - const CURRENT_0 = 0x00; - - const KEY_LHS = 0x10; - const KEY_RHS = 0x20; - const KEY_0 = 0x00; - - const DEFAULT_FLAGS = 0x13; - - private $lhs; - private $rhs; - private $flags; - - /** construct iterator from two iterators - * - * @param lhs Left Hand Side Iterator - * @param rhs Right Hand Side Iterator - * @param flags iteration flags - */ - function __construct(Iterator $lhs, Iterator $rhs, - $flags = 0x13 /*DualIterator::DEFAULT_FLAGS*/) - { - $this->lhs = $lhs; - $this->rhs = $rhs; - $this->flags = $flags; - } - - /** @return Left Hand Side Iterator - */ - function getLHS() - { - return $this->lhs; - } - - /** @return Right Hand Side Iterator - */ - function getRHS() - { - return $this->rhs; - } - - /** @param flags new flags - */ - function setFlags($flags) - { - $this->flags = $flags; - } - - /** @return current flags - */ - function getFlags() - { - return $this->flags; - } - - /** rewind both inner iterators - */ - function rewind() - { - $this->lhs->rewind(); - $this->rhs->rewind(); - } - - /** @return whether both inner iterators are valid - */ - function valid() - { - return $this->lhs->valid() && $this->rhs->valid(); - } - - /** @return current value depending on CURRENT_* flags - */ - function current() - { - switch($this->flags & 0x0F) - { - default: - case self::CURRENT_ARRAY: - return array($this->lhs->current(), $this->rhs->current()); - case self::CURRENT_LHS: - return $this->lhs->current(); - case self::CURRENT_RHS: - return $this->rhs->current(); - case self::CURRENT_0: - return NULL; - } - } - - /** @return key value depending on KEY_* flags - */ - function key() - { - switch($this->flags & 0xF0) - { - default: - case self::KEY_LHS: - return $this->lhs->key(); - case self::KEY_RHS: - return $this->rhs->key(); - case self::KEY_0: - return NULL; - } - } - - /** move both inner iterators forward - */ - function next() - { - $this->lhs->next(); - $this->rhs->next(); - } - - /** @return whether both inner iterators are valid and have identical - * current and key values or both are non valid. - */ - function areIdentical() - { - return $this->valid() - ? $this->lhs->current() === $this->rhs->current() - && $this->lhs->key() === $this->rhs->key() - : $this->lhs->valid() == $this->rhs->valid(); - } - - /** @return whether both inner iterators are valid and have equal current - * and key values or both are non valid. - */ - function areEqual() - { - return $this->valid() - ? $this->lhs->current() == $this->rhs->current() - && $this->lhs->key() == $this->rhs->key() - : $this->lhs->valid() == $this->rhs->valid(); - } - - /** Compare two iterators - * - * @param lhs Left Hand Side Iterator - * @param rhs Right Hand Side Iterator - * @param identical whether to use areEqual() or areIdentical() - * @return whether both iterators are equal/identical - * - * @note If one implements RecursiveIterator the other must do as well. - * And if both do then a recursive comparison is being used. - */ - static function compareIterators(Iterator $lhs, Iterator $rhs, - $identical = false) - { - if ($lhs instanceof RecursiveIterator) - { - if ($rhs instanceof RecursiveIterator) - { - $it = new RecursiveDualIterator($lhs, $rhs, - self::CURRENT_0 | self::KEY_0); - $it = new RecursiveCompareDualIterator($it); - } - else - { - return false; - } - } - else - { - $it = new DualIterator($lhs, $rhs, self::CURRENT_0 | self::KEY_0); - } - - if ($identical) - { - foreach($it as $n) - { - if (!$it->areIdentical()) - { - return false; - } - } - } - else - { - foreach($it as $n) - { - if (!$it->areEqual()) - { - return false; - } - } - } - return $identical ? $it->areIdentical() : $it->areEqual(); - } + const CURRENT_LHS = 0x01; + const CURRENT_RHS = 0x02; + const CURRENT_ARRAY = 0x03; + const CURRENT_0 = 0x00; + + const KEY_LHS = 0x10; + const KEY_RHS = 0x20; + const KEY_0 = 0x00; + + const DEFAULT_FLAGS = 0x13; + + private $lhs; + private $rhs; + private $flags; + + /** construct iterator from two iterators + * + * @param lhs Left Hand Side Iterator + * @param rhs Right Hand Side Iterator + * @param flags iteration flags + */ + function __construct(Iterator $lhs, Iterator $rhs, + $flags = 0x13 /*DualIterator::DEFAULT_FLAGS*/) + { + $this->lhs = $lhs; + $this->rhs = $rhs; + $this->flags = $flags; + } + + /** @return Left Hand Side Iterator + */ + function getLHS() + { + return $this->lhs; + } + + /** @return Right Hand Side Iterator + */ + function getRHS() + { + return $this->rhs; + } + + /** @param flags new flags + */ + function setFlags($flags) + { + $this->flags = $flags; + } + + /** @return current flags + */ + function getFlags() + { + return $this->flags; + } + + /** rewind both inner iterators + */ + function rewind() + { + $this->lhs->rewind(); + $this->rhs->rewind(); + } + + /** @return whether both inner iterators are valid + */ + function valid() + { + return $this->lhs->valid() && $this->rhs->valid(); + } + + /** @return current value depending on CURRENT_* flags + */ + function current() + { + switch($this->flags & 0x0F) + { + default: + case self::CURRENT_ARRAY: + return array($this->lhs->current(), $this->rhs->current()); + case self::CURRENT_LHS: + return $this->lhs->current(); + case self::CURRENT_RHS: + return $this->rhs->current(); + case self::CURRENT_0: + return NULL; + } + } + + /** @return key value depending on KEY_* flags + */ + function key() + { + switch($this->flags & 0xF0) + { + default: + case self::KEY_LHS: + return $this->lhs->key(); + case self::KEY_RHS: + return $this->rhs->key(); + case self::KEY_0: + return NULL; + } + } + + /** move both inner iterators forward + */ + function next() + { + $this->lhs->next(); + $this->rhs->next(); + } + + /** @return whether both inner iterators are valid and have identical + * current and key values or both are non valid. + */ + function areIdentical() + { + return $this->valid() + ? $this->lhs->current() === $this->rhs->current() + && $this->lhs->key() === $this->rhs->key() + : $this->lhs->valid() == $this->rhs->valid(); + } + + /** @return whether both inner iterators are valid and have equal current + * and key values or both are non valid. + */ + function areEqual() + { + return $this->valid() + ? $this->lhs->current() == $this->rhs->current() + && $this->lhs->key() == $this->rhs->key() + : $this->lhs->valid() == $this->rhs->valid(); + } + + /** Compare two iterators + * + * @param lhs Left Hand Side Iterator + * @param rhs Right Hand Side Iterator + * @param identical whether to use areEqual() or areIdentical() + * @return whether both iterators are equal/identical + * + * @note If one implements RecursiveIterator the other must do as well. + * And if both do then a recursive comparison is being used. + */ + static function compareIterators(Iterator $lhs, Iterator $rhs, + $identical = false) + { + if ($lhs instanceof RecursiveIterator) + { + if ($rhs instanceof RecursiveIterator) + { + $it = new RecursiveDualIterator($lhs, $rhs, + self::CURRENT_0 | self::KEY_0); + $it = new RecursiveCompareDualIterator($it); + } + else + { + return false; + } + } + else + { + $it = new DualIterator($lhs, $rhs, self::CURRENT_0 | self::KEY_0); + } + + if ($identical) + { + foreach($it as $n) + { + if (!$it->areIdentical()) + { + return false; + } + } + } + else + { + foreach($it as $n) + { + if (!$it->areEqual()) + { + return false; + } + } + } + return $identical ? $it->areIdentical() : $it->areEqual(); + } } ?> diff --git a/ext/spl/tests/dualiterator_001.phpt b/ext/spl/tests/dualiterator_001.phpt index 2a8358ae9cd5..2bbdc0c56fbd 100644 --- a/ext/spl/tests/dualiterator_001.phpt +++ b/ext/spl/tests/dualiterator_001.phpt @@ -5,17 +5,17 @@ SPL: DualIterator function spl_examples_autoload($classname) { - include(__DIR__ . '/' . strtolower($classname) . '.inc'); + include(__DIR__ . '/' . strtolower($classname) . '.inc'); } spl_autoload_register('spl_examples_autoload'); function test($a, $b, $identical = false) { - var_dump(DualIterator::compareIterators( - new RecursiveArrayIterator($a), - new RecursiveArrayIterator($b), - $identical)); + var_dump(DualIterator::compareIterators( + new RecursiveArrayIterator($a), + new RecursiveArrayIterator($b), + $identical)); } test(array(1,2,3), array(1,2,3)); diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt index 7bd3e0c8bddc..5c2240b3c597 100644 --- a/ext/spl/tests/fileobject_001.phpt +++ b/ext/spl/tests/fileobject_001.phpt @@ -27,7 +27,7 @@ var_dump($o->key()); echo "===A===\n"; foreach($o as $n => $l) { - var_dump($n, $l); + var_dump($n, $l); } echo "===B===\n"; @@ -35,7 +35,7 @@ $o = new SplFileObject(__DIR__ . '/fileobject_001b.txt'); $o->setFlags(SplFileObject::DROP_NEW_LINE); foreach($o as $n => $l) { - var_dump($n, $l); + var_dump($n, $l); } ?> diff --git a/ext/spl/tests/fileobject_002.phpt b/ext/spl/tests/fileobject_002.phpt index e8ecad609eb9..ba30caf23a82 100644 --- a/ext/spl/tests/fileobject_002.phpt +++ b/ext/spl/tests/fileobject_002.phpt @@ -5,23 +5,23 @@ SPL: SplFileObject::fgetc function test($name) { - echo "===$name===\n"; + echo "===$name===\n"; - $o = new SplFileObject(__DIR__ . '/' . $name); + $o = new SplFileObject(__DIR__ . '/' . $name); - var_dump($o->key()); - while(($c = $o->fgetc()) !== false) - { + var_dump($o->key()); + while(($c = $o->fgetc()) !== false) + { // Kinda ugly but works around new lines mess if ($c === "\r") { continue; } - var_dump($o->key(), $c, $o->eof()); - } - echo "===EOF?===\n"; - var_dump($o->eof()); - var_dump($o->key()); - var_dump($o->eof()); + var_dump($o->key(), $c, $o->eof()); + } + echo "===EOF?===\n"; + var_dump($o->eof()); + var_dump($o->key()); + var_dump($o->eof()); } test('fileobject_001a.txt'); diff --git a/ext/spl/tests/fileobject_003.phpt b/ext/spl/tests/fileobject_003.phpt index 6c2751c89b52..4f33065d426b 100644 --- a/ext/spl/tests/fileobject_003.phpt +++ b/ext/spl/tests/fileobject_003.phpt @@ -5,40 +5,40 @@ SPL: SplFileInfo cloning function test($name, $lc, $lp) { - static $i = 0; - echo "===$i===\n"; - $i++; + static $i = 0; + echo "===$i===\n"; + $i++; - $o = new SplFileInfo($name); + $o = new SplFileInfo($name); - var_dump($o); - $c = clone $o; - var_dump($c); - var_dump($o === $c); - var_dump($o == $c); - var_dump($o->getPathname() == $c->getPathname()); + var_dump($o); + $c = clone $o; + var_dump($c); + var_dump($o === $c); + var_dump($o == $c); + var_dump($o->getPathname() == $c->getPathname()); - try { - $f = new SplFileObject($name); - var_dump($name); - var_dump($f->getPathName()); - $l = substr($f->getPathName(), -1); - var_dump($l != '/' && $l != '\\' && $l == $lc); - var_dump($f->getFileName()); - $l = substr($f->getFileName(), -1); - var_dump($l != '/' && $l != '\\' && $l == $lc); - var_dump($f->getPath()); - $l = substr($f->getPath(), -1); - var_dump($l != '/' && $l != '\\' && $l == $lp); - } catch (LogicException $e) { - echo "LogicException: ".$e->getMessage()."\n"; - } - try { - $fo = $o->openFile(); - var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath()); - } catch (LogicException $e) { - echo "LogicException: ".$e->getMessage()."\n"; - } + try { + $f = new SplFileObject($name); + var_dump($name); + var_dump($f->getPathName()); + $l = substr($f->getPathName(), -1); + var_dump($l != '/' && $l != '\\' && $l == $lc); + var_dump($f->getFileName()); + $l = substr($f->getFileName(), -1); + var_dump($l != '/' && $l != '\\' && $l == $lc); + var_dump($f->getPath()); + $l = substr($f->getPath(), -1); + var_dump($l != '/' && $l != '\\' && $l == $lp); + } catch (LogicException $e) { + echo "LogicException: ".$e->getMessage()."\n"; + } + try { + $fo = $o->openFile(); + var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath()); + } catch (LogicException $e) { + echo "LogicException: ".$e->getMessage()."\n"; + } } test(__DIR__ . '/' . 'fileobject_001a.txt', 't', substr(__DIR__,-1)); diff --git a/ext/spl/tests/filesystemiterator_flags.phpt b/ext/spl/tests/filesystemiterator_flags.phpt index c74129760c08..1a8cce034e33 100644 --- a/ext/spl/tests/filesystemiterator_flags.phpt +++ b/ext/spl/tests/filesystemiterator_flags.phpt @@ -9,19 +9,19 @@ $it = new FileSystemIterator("."); printflags($it); $it->setFlags(FileSystemIterator::CURRENT_AS_SELF | - FileSystemIterator::KEY_AS_FILENAME | - FileSystemIterator::SKIP_DOTS | - FileSystemIterator::UNIX_PATHS); + FileSystemIterator::KEY_AS_FILENAME | + FileSystemIterator::SKIP_DOTS | + FileSystemIterator::UNIX_PATHS); printflags($it); $it->setFlags(-1); printflags($it); function printflags($it) { - printf("%08X\n", $it->getFlags()); - printf("%08X\n", ($it->getFlags() & FileSystemIterator::CURRENT_MODE_MASK)); - printf("%08X\n", ($it->getFlags() & FileSystemIterator::KEY_MODE_MASK)); - printf("%08X\n", ($it->getFlags() & FileSystemIterator::OTHER_MODE_MASK)); + printf("%08X\n", $it->getFlags()); + printf("%08X\n", ($it->getFlags() & FileSystemIterator::CURRENT_MODE_MASK)); + printf("%08X\n", ($it->getFlags() & FileSystemIterator::KEY_MODE_MASK)); + printf("%08X\n", ($it->getFlags() & FileSystemIterator::OTHER_MODE_MASK)); } ?> diff --git a/ext/spl/tests/fixedarray_002.phpt b/ext/spl/tests/fixedarray_002.phpt index 27d25c0273a6..f111dd1bfc0f 100644 --- a/ext/spl/tests/fixedarray_002.phpt +++ b/ext/spl/tests/fixedarray_002.phpt @@ -3,8 +3,8 @@ SPL: FixedArray: overloading --FILE-- getMessage()); + var_dump($e->getMessage()); } ?> diff --git a/ext/spl/tests/fixedarray_005.phpt b/ext/spl/tests/fixedarray_005.phpt index 274fc34245a4..7295a317ab3e 100644 --- a/ext/spl/tests/fixedarray_005.phpt +++ b/ext/spl/tests/fixedarray_005.phpt @@ -4,21 +4,21 @@ SPL: FixedArray: Invalid arguments getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } try { - $a = new SplFixedArray('FOO'); + $a = new SplFixedArray('FOO'); } catch (TypeError $iae) { - echo "Ok - ".$iae->getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } try { - $a = new SplFixedArray(''); + $a = new SplFixedArray(''); } catch (TypeError $iae) { - echo "Ok - ".$iae->getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } ?> diff --git a/ext/spl/tests/fixedarray_006.phpt b/ext/spl/tests/fixedarray_006.phpt index 8641821ae314..2e762467c4f4 100644 --- a/ext/spl/tests/fixedarray_006.phpt +++ b/ext/spl/tests/fixedarray_006.phpt @@ -7,11 +7,11 @@ $b = 10000; $a = new SplFixedArray($b); try { - for ($i = 0; $i < 100; $i++) { - $a[] = new stdClass; - } + for ($i = 0; $i < 100; $i++) { + $a[] = new stdClass; + } } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } print "ok\n"; diff --git a/ext/spl/tests/fixedarray_007.phpt b/ext/spl/tests/fixedarray_007.phpt index 308ce315a593..65b4dad90e2b 100644 --- a/ext/spl/tests/fixedarray_007.phpt +++ b/ext/spl/tests/fixedarray_007.phpt @@ -7,15 +7,15 @@ $b = 10; $a = new SplFixedArray($b); try { - $a[1] = $a; + $a[1] = $a; } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } foreach ($a as $c) { - if ($c) { - echo $c->getSize(), "\n"; - } + if ($c) { + echo $c->getSize(), "\n"; + } } print "ok\n"; diff --git a/ext/spl/tests/fixedarray_008.phpt b/ext/spl/tests/fixedarray_008.phpt index 6d9c9cbf095b..8bac0824d138 100644 --- a/ext/spl/tests/fixedarray_008.phpt +++ b/ext/spl/tests/fixedarray_008.phpt @@ -13,11 +13,11 @@ $a[2] = $a; $a[2][0] = 3; foreach ($a as $x) { - if (is_object($x)) { - var_dump($x[0]); - } else { - var_dump($x); - } + if (is_object($x)) { + var_dump($x[0]); + } else { + var_dump($x); + } } var_dump($a->getSize()); diff --git a/ext/spl/tests/fixedarray_009.phpt b/ext/spl/tests/fixedarray_009.phpt index b885fe995723..71d6a42a6fac 100644 --- a/ext/spl/tests/fixedarray_009.phpt +++ b/ext/spl/tests/fixedarray_009.phpt @@ -4,9 +4,9 @@ SPL: FixedArray: Trying to instantiate passing string to constructor parameter getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } ?> --EXPECT-- diff --git a/ext/spl/tests/fixedarray_012.phpt b/ext/spl/tests/fixedarray_012.phpt index 3461b3a9b5f7..df725aad4611 100644 --- a/ext/spl/tests/fixedarray_012.phpt +++ b/ext/spl/tests/fixedarray_012.phpt @@ -6,9 +6,9 @@ SPL: FixedArray: Assigning the object to another variable using [] $a = new SplFixedArray(100); try { - $b = &$a[]; + $b = &$a[]; } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } print "ok\n"; diff --git a/ext/spl/tests/fixedarray_013.phpt b/ext/spl/tests/fixedarray_013.phpt index 52ae3c161ec3..cf43b3c7e773 100644 --- a/ext/spl/tests/fixedarray_013.phpt +++ b/ext/spl/tests/fixedarray_013.phpt @@ -7,13 +7,13 @@ $a = new SplFixedArray(100); function test(SplFixedArray &$arr) { - print "ok\n"; + print "ok\n"; } try { - test($a[]); + test($a[]); } catch (Exception $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/ext/spl/tests/fixedarray_014.phpt b/ext/spl/tests/fixedarray_014.phpt index de8e214dc05b..a6f2fc188c6d 100644 --- a/ext/spl/tests/fixedarray_014.phpt +++ b/ext/spl/tests/fixedarray_014.phpt @@ -4,10 +4,10 @@ SPL: FixedArray: Trying to access inexistent item getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/fixedarray_015.phpt b/ext/spl/tests/fixedarray_015.phpt index 3fedd3509007..2a2d5a26f74a 100644 --- a/ext/spl/tests/fixedarray_015.phpt +++ b/ext/spl/tests/fixedarray_015.phpt @@ -4,9 +4,9 @@ SPL: FixedArray: accessing uninitialized array getMessage().PHP_EOL; + echo "Ok - ".$iae->getMessage().PHP_EOL; } echo "Done\n"; diff --git a/ext/spl/tests/fixedarray_021.phpt b/ext/spl/tests/fixedarray_021.phpt index 813de176c8f6..db4962ef481b 100644 --- a/ext/spl/tests/fixedarray_021.phpt +++ b/ext/spl/tests/fixedarray_021.phpt @@ -11,17 +11,17 @@ var_dump($a->count()); /* negative init value */ try { - $b = new SplFixedArray(-10); + $b = new SplFixedArray(-10); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } /* resize and negative value */ $b = new SplFixedArray(); try { - $b->setSize(-5); + $b->setSize(-5); } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } /* calling __construct() twice */ @@ -43,11 +43,11 @@ $e[1] = 5; $e[2] = 10; try { - foreach ($e as $k=>&$v) { - var_dump($v); - } + foreach ($e as $k=>&$v) { + var_dump($v); + } } catch (Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } //non-long indexes diff --git a/ext/spl/tests/heap_corruption.phpt b/ext/spl/tests/heap_corruption.phpt index 47e8d008c085..9b14a0fe0b09 100644 --- a/ext/spl/tests/heap_corruption.phpt +++ b/ext/spl/tests/heap_corruption.phpt @@ -8,30 +8,30 @@ Mike Sullivan class myHeap extends SplHeap { - public $allow_compare = true; + public $allow_compare = true; - public function compare($v1, $v2) - { - if ($this->allow_compare == true) - { - if ($v1 > $v2) - { - return 1; - } - else if ($v1 < $v2) - { - return -1; - } - else - { - return 0; - } - } - else - { - throw new Exception('Compare exception'); - } - } + public function compare($v1, $v2) + { + if ($this->allow_compare == true) + { + if ($v1 > $v2) + { + return 1; + } + else if ($v1 < $v2) + { + return -1; + } + else + { + return 0; + } + } + else + { + throw new Exception('Compare exception'); + } + } } $heap = new myHeap(); @@ -45,17 +45,17 @@ $heap->allow_compare = false; var_dump($heap->isCorrupted()); try { - $heap->extract(); + $heap->extract(); } catch (Exception $e) { - echo "Compare Exception: " . $e->getMessage() . PHP_EOL; + echo "Compare Exception: " . $e->getMessage() . PHP_EOL; } try { - $heap->top(); + $heap->top(); } catch (Exception $e) { - echo "Corruption Exception: " . $e->getMessage() . PHP_EOL; + echo "Corruption Exception: " . $e->getMessage() . PHP_EOL; } var_dump($heap->isCorrupted()); diff --git a/ext/spl/tests/heap_current_variation_001.phpt b/ext/spl/tests/heap_current_variation_001.phpt index f67eb428c3a7..a55bb486e95a 100644 --- a/ext/spl/tests/heap_current_variation_001.phpt +++ b/ext/spl/tests/heap_current_variation_001.phpt @@ -8,10 +8,10 @@ Mike Sullivan class myHeap extends SplHeap { - public function compare($v1, $v2) - { - throw new Exception(''); - } + public function compare($v1, $v2) + { + throw new Exception(''); + } } $heap = new myHeap(); diff --git a/ext/spl/tests/heap_top_variation_002.phpt b/ext/spl/tests/heap_top_variation_002.phpt index 4d6bdd593aa7..add363eab312 100644 --- a/ext/spl/tests/heap_top_variation_002.phpt +++ b/ext/spl/tests/heap_top_variation_002.phpt @@ -7,9 +7,9 @@ TestFest London May 2009 insert(4); try { - $h->insert(5); + $h->insert(5); } catch (Exception $e) {} // call top, should fail with corrupted heap try { - $h->top(); + $h->top(); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECT-- diff --git a/ext/spl/tests/heap_top_variation_003.phpt b/ext/spl/tests/heap_top_variation_003.phpt index c2ea2bcd9511..40d70c5966b9 100644 --- a/ext/spl/tests/heap_top_variation_003.phpt +++ b/ext/spl/tests/heap_top_variation_003.phpt @@ -7,9 +7,9 @@ TestFest London May 2009 top(); + $h->top(); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_001.phpt b/ext/spl/tests/iterator_001.phpt index e87d49f140db..c8151533a8ee 100644 --- a/ext/spl/tests/iterator_001.phpt +++ b/ext/spl/tests/iterator_001.phpt @@ -5,69 +5,69 @@ SPL: Iterator aggregating inner iterator's methods class NumericArrayIterator implements Iterator { - protected $a; - protected $i = 0; + protected $a; + protected $i = 0; - public function __construct($a) - { - echo __METHOD__ . "\n"; - $this->a = $a; - } + public function __construct($a) + { + echo __METHOD__ . "\n"; + $this->a = $a; + } - public function rewind() - { - echo __METHOD__ . "\n"; - $this->i = 0; - } + public function rewind() + { + echo __METHOD__ . "\n"; + $this->i = 0; + } - public function valid() - { - $ret = $this->i < count($this->a); - echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n"; - return $ret; - } + public function valid() + { + $ret = $this->i < count($this->a); + echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n"; + return $ret; + } - public function key() - { - echo __METHOD__ . "\n"; - return $this->i; - } + public function key() + { + echo __METHOD__ . "\n"; + return $this->i; + } - public function current() - { - echo __METHOD__ . "\n"; - return $this->a[$this->i]; - } + public function current() + { + echo __METHOD__ . "\n"; + return $this->a[$this->i]; + } - public function next() - { - echo __METHOD__ . "\n"; - $this->i++; - } + public function next() + { + echo __METHOD__ . "\n"; + $this->i++; + } - public function greaterThan($comp) - { - echo get_class($this) . '::' . __FUNCTION__ . '(' . $comp . ")\n"; - return $this->current() > $comp; - } + public function greaterThan($comp) + { + echo get_class($this) . '::' . __FUNCTION__ . '(' . $comp . ")\n"; + return $this->current() > $comp; + } } class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator { - public function seek($index) - { - if ($index < count($this->a)) { - $this->i = $index; - } - echo __METHOD__ . '(' . $index . ")\n"; - } + public function seek($index) + { + if ($index < count($this->a)) { + $this->i = $index; + } + echo __METHOD__ . '(' . $index . ")\n"; + } } $a = array(1, 2, 3, 4, 5); $it = new LimitIterator(new NumericArrayIterator($a), 1, 3); foreach ($it as $v) { - print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; + print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } echo "===SEEKABLE===\n"; @@ -75,7 +75,7 @@ $a = array(1, 2, 3, 4, 5); $it = new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3); foreach($it as $v) { - print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; + print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } echo "===STACKED===\n"; @@ -84,7 +84,7 @@ $a = array(1, 2, 3, 4, 5); $it = new CachingIterator(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3)); foreach($it as $v) { - print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; + print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } ?> diff --git a/ext/spl/tests/iterator_002.phpt b/ext/spl/tests/iterator_002.phpt index 44943d64387f..da790988fcbe 100644 --- a/ext/spl/tests/iterator_002.phpt +++ b/ext/spl/tests/iterator_002.phpt @@ -5,33 +5,33 @@ SPL: Iterator using getInnerIterator class RecursiceArrayIterator extends ArrayIterator implements RecursiveIterator { - function hasChildren() - { - return is_array($this->current()); - } - - function getChildren() - { - return new RecursiceArrayIterator($this->current()); - } + function hasChildren() + { + return is_array($this->current()); + } + + function getChildren() + { + return new RecursiceArrayIterator($this->current()); + } } class CrashIterator extends FilterIterator implements RecursiveIterator { - function accept() - { - return true; - } - - function hasChildren() - { - return $this->getInnerIterator()->hasChildren(); - } - - function getChildren() - { - return new RecursiceArrayIterator($this->getInnerIterator()->current()); - } + function accept() + { + return true; + } + + function hasChildren() + { + return $this->getInnerIterator()->hasChildren(); + } + + function getChildren() + { + return new RecursiceArrayIterator($this->getInnerIterator()->current()); + } } $array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); @@ -39,7 +39,7 @@ $array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3); $dir = new RecursiveIteratorIterator(new CrashIterator(new RecursiceArrayIterator($array)), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($dir as $file) { - print "$file\n"; + print "$file\n"; } ?> diff --git a/ext/spl/tests/iterator_003.phpt b/ext/spl/tests/iterator_003.phpt index e2a4246075ed..b7b331a496d5 100644 --- a/ext/spl/tests/iterator_003.phpt +++ b/ext/spl/tests/iterator_003.phpt @@ -5,73 +5,73 @@ SPL: CachingIterator and __toString() class Student { - private $id; - private $name; + private $id; + private $name; public function __construct($id, $name) { - $this->id = $id; - $this->name = $name; + $this->id = $id; + $this->name = $name; } - public function __toString() - { - return $this->id . ', ' . $this->name; - } + public function __toString() + { + return $this->id . ', ' . $this->name; + } - public function getId() - { - return $this->id; - } + public function getId() + { + return $this->id; + } } class StudentIdFilter extends FilterIterator { - private $id; + private $id; - public function __construct(ArrayObject $students, Student $other) - { - FilterIterator::__construct($students->getIterator()); - $this->id = $other->getId(); - } + public function __construct(ArrayObject $students, Student $other) + { + FilterIterator::__construct($students->getIterator()); + $this->id = $other->getId(); + } - public function accept() - { - echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; - return $this->current()->getId() == $this->id; - } + public function accept() + { + echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n"; + return $this->current()->getId() == $this->id; + } } class StudentList implements IteratorAggregate { - private $students; + private $students; - public function __construct() - { - $this->students = new ArrayObject(array()); - } + public function __construct() + { + $this->students = new ArrayObject(array()); + } - public function add(Student $student) - { - if (!$this->contains($student)) { - $this->students[] = $student; - } - } + public function add(Student $student) + { + if (!$this->contains($student)) { + $this->students[] = $student; + } + } - public function contains(Student $student) - { - foreach ($this->students as $s) - { - if ($s->getId() == $student->getId()) { - return true; - } - } - return false; - } + public function contains(Student $student) + { + foreach ($this->students as $s) + { + if ($s->getId() == $student->getId()) { + return true; + } + } + return false; + } - public function getIterator() { - return new CachingIterator($this->students->getIterator(), true); - } + public function getIterator() { + return new CachingIterator($this->students->getIterator(), true); + } } $students = new StudentList(); @@ -84,7 +84,7 @@ $students->add(new Student('00000014', 'Foo')); // iterator's __toString() method. $it = $students->getIterator(); foreach ($it as $student) { - echo $it->__toString(), "\n"; + echo $it->__toString(), "\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_004.phpt b/ext/spl/tests/iterator_004.phpt index 17c03c865034..d131593ad205 100644 --- a/ext/spl/tests/iterator_004.phpt +++ b/ext/spl/tests/iterator_004.phpt @@ -5,69 +5,69 @@ SPL: SeekableIterator and string keys class NumericArrayIterator implements Iterator { - protected $a; - protected $i; + protected $a; + protected $i; - public function __construct($a) - { - echo __METHOD__ . "\n"; - $this->a = $a; - } + public function __construct($a) + { + echo __METHOD__ . "\n"; + $this->a = $a; + } - public function rewind() - { - echo __METHOD__ . "\n"; - $this->i = 0; - } + public function rewind() + { + echo __METHOD__ . "\n"; + $this->i = 0; + } - public function valid() - { - $ret = $this->i < count($this->a); - echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n"; - return $ret; - } + public function valid() + { + $ret = $this->i < count($this->a); + echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n"; + return $ret; + } - public function key() - { - echo __METHOD__ . "\n"; - return $this->i; - } + public function key() + { + echo __METHOD__ . "\n"; + return $this->i; + } - public function current() - { - echo __METHOD__ . "\n"; - return $this->a[$this->i]; - } + public function current() + { + echo __METHOD__ . "\n"; + return $this->a[$this->i]; + } - public function next() - { - echo __METHOD__ . "\n"; - $this->i++; - } + public function next() + { + echo __METHOD__ . "\n"; + $this->i++; + } } class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator { - public function seek($index) - { - if ($index < count($this->a)) { - $this->i = $index; - } - echo __METHOD__ . '(' . $index . ")\n"; - } + public function seek($index) + { + if ($index < count($this->a)) { + $this->i = $index; + } + echo __METHOD__ . '(' . $index . ")\n"; + } } $a = array(1, 2, 3, 4, 5); foreach (new LimitIterator(new NumericArrayIterator($a), 1, 3) as $v) { - print "$v\n"; + print "$v\n"; } echo "===SEEKABLE===\n"; $a = array(1, 2, 3, 4, 5); foreach(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3) as $v) { - print "$v\n"; + print "$v\n"; } echo "===SEEKING===\n"; @@ -75,8 +75,8 @@ $a = array(1, 2, 3, 4, 5); $l = new LimitIterator(new SeekableNumericArrayIterator($a)); for($i = 1; $i < 4; $i++) { - $l->seek($i); - print $l->current() . "\n"; + $l->seek($i); + print $l->current() . "\n"; } ?> diff --git a/ext/spl/tests/iterator_005.phpt b/ext/spl/tests/iterator_005.phpt index 8f8d11e31185..9f13889a1858 100644 --- a/ext/spl/tests/iterator_005.phpt +++ b/ext/spl/tests/iterator_005.phpt @@ -5,34 +5,34 @@ SPL: IteratorIterator and ArrayIterator/Object class ArrayIteratorEx extends ArrayIterator { - function rewind() - { - echo __METHOD__ . "\n"; - return parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + return parent::rewind(); + } } $it = new ArrayIteratorEx(range(0,3)); foreach(new IteratorIterator($it) as $v) { - var_dump($v); + var_dump($v); } class ArrayObjectEx extends ArrayObject { - function getIterator() - { - echo __METHOD__ . "\n"; - return parent::getIterator(); - } + function getIterator() + { + echo __METHOD__ . "\n"; + return parent::getIterator(); + } } $it = new ArrayObjectEx(range(0,3)); foreach(new IteratorIterator($it) as $v) { - var_dump($v); + var_dump($v); } ?> diff --git a/ext/spl/tests/iterator_006.phpt b/ext/spl/tests/iterator_006.phpt index 667c3cee1246..78c597a795a1 100644 --- a/ext/spl/tests/iterator_006.phpt +++ b/ext/spl/tests/iterator_006.phpt @@ -13,7 +13,7 @@ $root = simplexml_load_string(' '); foreach (new IteratorIterator($root->child) as $child) { - echo $child."\n"; + echo $child."\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_007.phpt b/ext/spl/tests/iterator_007.phpt index 4f63585d706a..8fb503c79a7a 100644 --- a/ext/spl/tests/iterator_007.phpt +++ b/ext/spl/tests/iterator_007.phpt @@ -5,72 +5,72 @@ SPL: NoRewindIterator class ArrayIteratorEx extends ArrayIterator { - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } } class NoRewindIteratorEx extends NoRewindIterator { - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } } $it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3))); echo "===0===\n"; foreach ($it->getInnerIterator() as $v) { - var_dump($v); + var_dump($v); } echo "===1===\n"; foreach ($it as $v) { - var_dump($v); + var_dump($v); } $pos =0; @@ -79,20 +79,20 @@ $it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3))); echo "===2===\n"; foreach ($it as $v) { - var_dump($v); - if ($pos++ > 1) { - break; - } + var_dump($v); + if ($pos++ > 1) { + break; + } } echo "===3===\n"; foreach ($it as $v) { - var_dump($v); + var_dump($v); } echo "===4===\n"; foreach ($it as $v) { - var_dump($v); + var_dump($v); } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_008.phpt b/ext/spl/tests/iterator_008.phpt index 0d6290f504f9..19c6038e3c4c 100644 --- a/ext/spl/tests/iterator_008.phpt +++ b/ext/spl/tests/iterator_008.phpt @@ -5,31 +5,31 @@ SPL: InfiniteIterator class ArrayIteratorEx extends ArrayIterator { - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } } $it = new InfiniteIterator(new ArrayIteratorEx(range(0,2))); @@ -37,10 +37,10 @@ $it = new InfiniteIterator(new ArrayIteratorEx(range(0,2))); $pos =0; foreach ($it as $v) { - var_dump($v); - if ($pos++ > 5) { - break; - } + var_dump($v); + if ($pos++ > 5) { + break; + } } ?> diff --git a/ext/spl/tests/iterator_009.phpt b/ext/spl/tests/iterator_009.phpt index 78213b6224d7..19447deac458 100644 --- a/ext/spl/tests/iterator_009.phpt +++ b/ext/spl/tests/iterator_009.phpt @@ -5,35 +5,35 @@ SPL: EmptyIterator class EmptyIteratorEx extends EmptyIterator { - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } } foreach (new EmptyIteratorEx() as $v) { - var_dump($v); + var_dump($v); } ?> diff --git a/ext/spl/tests/iterator_010.phpt b/ext/spl/tests/iterator_010.phpt index 15c79f8d4014..17e901f0c131 100644 --- a/ext/spl/tests/iterator_010.phpt +++ b/ext/spl/tests/iterator_010.phpt @@ -7,7 +7,7 @@ echo "===EmptyIterator===\n"; foreach(new LimitIterator(new EmptyIterator(), 0, 3) as $key => $val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } ?> diff --git a/ext/spl/tests/iterator_011.phpt b/ext/spl/tests/iterator_011.phpt index 3b703b79bddb..5d814ce1f7e3 100644 --- a/ext/spl/tests/iterator_011.phpt +++ b/ext/spl/tests/iterator_011.phpt @@ -7,7 +7,7 @@ echo "===EmptyIterator===\n"; foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===InfiniteIterator===\n"; @@ -17,7 +17,7 @@ $it = new InfiniteIterator($it); $it = new LimitIterator($it, 2, 5); foreach($it as $val=>$key) { - echo "$val=>$key\n"; + echo "$val=>$key\n"; } echo "===Infinite/LimitIterator===\n"; @@ -28,7 +28,7 @@ $it = new InfiniteIterator($it); $it = new LimitIterator($it, 2, 5); foreach($it as $val=>$key) { - echo "$val=>$key\n"; + echo "$val=>$key\n"; } ?> diff --git a/ext/spl/tests/iterator_012.phpt b/ext/spl/tests/iterator_012.phpt index f00cac697ebb..733dc10a1201 100644 --- a/ext/spl/tests/iterator_012.phpt +++ b/ext/spl/tests/iterator_012.phpt @@ -17,7 +17,7 @@ echo "===Foreach===\n"; foreach($it as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } ?> diff --git a/ext/spl/tests/iterator_013.phpt b/ext/spl/tests/iterator_013.phpt index edc8ea75ed90..daab33ab7ec7 100644 --- a/ext/spl/tests/iterator_013.phpt +++ b/ext/spl/tests/iterator_013.phpt @@ -9,7 +9,7 @@ $it = new AppendIterator; foreach($it as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Append===\n"; @@ -18,14 +18,14 @@ $it->append(new ArrayIterator(array(0 => 'A', 1 => 'B'))); foreach($it as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Rewind===\n"; foreach($it as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Append===\n"; @@ -34,14 +34,14 @@ $it->append(new ArrayIterator(array(2 => 'C', 3 => 'D'))); foreach(new NoRewindIterator($it) as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===Rewind===\n"; foreach($it as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } ?> diff --git a/ext/spl/tests/iterator_014.phpt b/ext/spl/tests/iterator_014.phpt index bbcacba51f09..363b2916fe9c 100644 --- a/ext/spl/tests/iterator_014.phpt +++ b/ext/spl/tests/iterator_014.phpt @@ -5,72 +5,72 @@ SPL: RecursiveIteratorIterator and beginChildren/endChildren class MyRecursiveArrayIterator extends RecursiveArrayIterator { - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } + function valid() + { + if (!parent::valid()) + { + echo __METHOD__ . " = false\n"; + return false; + } + else + { + return true; + } + } - function getChildren() - { - echo __METHOD__ . "\n"; - return parent::getChildren(); - } + function getChildren() + { + echo __METHOD__ . "\n"; + return parent::getChildren(); + } } class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function beginChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function endChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } } foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"))) as $k=>$v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_015.phpt b/ext/spl/tests/iterator_015.phpt index ea507143f86a..f83366bb1c43 100644 --- a/ext/spl/tests/iterator_015.phpt +++ b/ext/spl/tests/iterator_015.phpt @@ -5,28 +5,28 @@ SPL: RecursiveIteratorIterator and beginChildren/endChildren class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { - function rewind() - { - echo "
    \n"; - parent::rewind(); - } - function beginChildren() - { - echo str_repeat(' ',$this->getDepth())."
      \n"; - } + function rewind() + { + echo "
        \n"; + parent::rewind(); + } + function beginChildren() + { + echo str_repeat(' ',$this->getDepth())."
          \n"; + } - function endChildren() - { - echo str_repeat(' ',$this->getDepth())."
        \n"; - } - function valid() - { - if (!parent::valid()) { - echo "
          \n"; - return false; - } - return true; - } + function endChildren() + { + echo str_repeat(' ',$this->getDepth())."
        \n"; + } + function valid() + { + if (!parent::valid()) { + echo "
          \n"; + return false; + } + return true; + } } $arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"); @@ -34,7 +34,7 @@ $obj = new RecursiveArrayIterator($arr); $rit = new RecursiveArrayIteratorIterator($obj); foreach($rit as $k=>$v) { - echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; + echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_016.phpt b/ext/spl/tests/iterator_016.phpt index 95ffcdfc1948..966c05d989c8 100644 --- a/ext/spl/tests/iterator_016.phpt +++ b/ext/spl/tests/iterator_016.phpt @@ -5,41 +5,41 @@ SPL: RecursiveIteratorIterator and beginChildren/endChildren class Menu extends ArrayObject { - function getIterator() - { - echo __METHOD__ . "\n"; - return new RecursiveArrayIterator($this); - } + function getIterator() + { + echo __METHOD__ . "\n"; + return new RecursiveArrayIterator($this); + } } class MenuOutput extends RecursiveIteratorIterator { - function __construct(Menu $it) - { - parent::__construct($it); - } - function rewind() - { - echo "
            \n"; - parent::rewind(); - } - function beginChildren() - { - echo str_repeat(' ',$this->getDepth())."
              \n"; - } + function __construct(Menu $it) + { + parent::__construct($it); + } + function rewind() + { + echo "
                \n"; + parent::rewind(); + } + function beginChildren() + { + echo str_repeat(' ',$this->getDepth())."
                  \n"; + } - function endChildren() - { - echo str_repeat(' ',$this->getDepth())."
                \n"; - } - function valid() - { - if (!parent::valid()) { - echo "
                  \n"; - return false; - } - return true; - } + function endChildren() + { + echo str_repeat(' ',$this->getDepth())."
                \n"; + } + function valid() + { + if (!parent::valid()) { + echo "
                  \n"; + return false; + } + return true; + } } $arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"); @@ -47,7 +47,7 @@ $obj = new Menu($arr); $rit = new MenuOutput($obj); foreach($rit as $k=>$v) { - echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; + echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_018.phpt b/ext/spl/tests/iterator_018.phpt index 3b703b79bddb..5d814ce1f7e3 100644 --- a/ext/spl/tests/iterator_018.phpt +++ b/ext/spl/tests/iterator_018.phpt @@ -7,7 +7,7 @@ echo "===EmptyIterator===\n"; foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val) { - echo "$key=>$val\n"; + echo "$key=>$val\n"; } echo "===InfiniteIterator===\n"; @@ -17,7 +17,7 @@ $it = new InfiniteIterator($it); $it = new LimitIterator($it, 2, 5); foreach($it as $val=>$key) { - echo "$val=>$key\n"; + echo "$val=>$key\n"; } echo "===Infinite/LimitIterator===\n"; @@ -28,7 +28,7 @@ $it = new InfiniteIterator($it); $it = new LimitIterator($it, 2, 5); foreach($it as $val=>$key) { - echo "$val=>$key\n"; + echo "$val=>$key\n"; } ?> diff --git a/ext/spl/tests/iterator_021.phpt b/ext/spl/tests/iterator_021.phpt index 343dc411409e..433ced95e75f 100644 --- a/ext/spl/tests/iterator_021.phpt +++ b/ext/spl/tests/iterator_021.phpt @@ -5,105 +5,105 @@ SPL: RecursiveIteratorIterator and hasChildren class MyRecursiveArrayIterator extends RecursiveArrayIterator { - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } + function valid() + { + if (!parent::valid()) + { + echo __METHOD__ . " = false\n"; + return false; + } + else + { + return true; + } + } - function getChildren() - { - echo __METHOD__ . "\n"; - return parent::getChildren(); - } + function getChildren() + { + echo __METHOD__ . "\n"; + return parent::getChildren(); + } } class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { - private $max_depth; - private $over = 0; - private $skip = false; + private $max_depth; + private $over = 0; + private $skip = false; - function __construct($it, $max_depth) - { - $this->max_depth = $max_depth; - parent::__construct($it); - } + function __construct($it, $max_depth) + { + $this->max_depth = $max_depth; + parent::__construct($it); + } - function rewind() - { - echo __METHOD__ . "\n"; - $this->skip = false; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + $this->skip = false; + parent::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - if ($this->skip) - { - $this->skip = false; - $this->next(); - } - return parent::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + if ($this->skip) + { + $this->skip = false; + $this->next(); + } + return parent::valid(); + } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } - function callHasChildren() - { - $this->skip = false; - $has = parent::callHasChildren(); - $res = $this->getDepth() < $this->max_depth && $has; - echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; - if ($has && !$res) - { - $this->over++; - if ($this->over == 2) { - $this->skip = true; - } - } - return $res; - } + function callHasChildren() + { + $this->skip = false; + $has = parent::callHasChildren(); + $res = $this->getDepth() < $this->max_depth && $has; + echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; + if ($has && !$res) + { + $this->over++; + if ($this->over == 2) { + $this->skip = true; + } + } + return $res; + } - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function beginChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function endChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } } foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) { - if (is_array($v)) $v = join('',$v); - echo "$k=>$v\n"; + if (is_array($v)) $v = join('',$v); + echo "$k=>$v\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_022.phpt b/ext/spl/tests/iterator_022.phpt index 3ff52a101b47..ae7993282842 100644 --- a/ext/spl/tests/iterator_022.phpt +++ b/ext/spl/tests/iterator_022.phpt @@ -5,123 +5,123 @@ SPL: RecursiveIteratorIterator and callHasChildren/callGetChildren class MyRecursiveArrayIterator extends RecursiveArrayIterator { - function getChildren() - { - echo __METHOD__ . "\n"; - return $this->current(); - } + function getChildren() + { + echo __METHOD__ . "\n"; + return $this->current(); + } - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } + function valid() + { + if (!parent::valid()) + { + echo __METHOD__ . " = false\n"; + return false; + } + else + { + return true; + } + } } class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { - private $max_depth; - private $over = 0; - private $skip = false; + private $max_depth; + private $over = 0; + private $skip = false; - function __construct($it, $max_depth) - { - $this->max_depth = $max_depth; - parent::__construct($it); - } + function __construct($it, $max_depth) + { + $this->max_depth = $max_depth; + parent::__construct($it); + } - function rewind() - { - echo __METHOD__ . "\n"; - $this->skip = false; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + $this->skip = false; + parent::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - if ($this->skip) - { - $this->skip = false; - $this->next(); - } - return parent::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + if ($this->skip) + { + $this->skip = false; + $this->next(); + } + return parent::valid(); + } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } - function callHasChildren() - { - $this->skip = false; - $has = parent::callHasChildren(); - $res = $this->getDepth() < $this->max_depth && $has; - echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; - if ($has && !$res) - { - $this->over++; - if ($this->over == 2) { - $this->skip = true; - } - } - return $res; - } + function callHasChildren() + { + $this->skip = false; + $has = parent::callHasChildren(); + $res = $this->getDepth() < $this->max_depth && $has; + echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; + if ($has && !$res) + { + $this->over++; + if ($this->over == 2) { + $this->skip = true; + } + } + return $res; + } - function callGetChildren() - { - if ($this->over == 2) - { - echo __METHOD__ . "(skip)\n"; - return NULL; - } - echo __METHOD__ . "(ok:{$this->over})\n"; - return new MyRecursiveArrayIterator($this->current()); - } + function callGetChildren() + { + if ($this->over == 2) + { + echo __METHOD__ . "(skip)\n"; + return NULL; + } + echo __METHOD__ . "(ok:{$this->over})\n"; + return new MyRecursiveArrayIterator($this->current()); + } - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function beginChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function endChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } } try { - foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) - { - if (is_array($v)) $v = join('',$v); - echo "$k=>$v\n"; - } + foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) + { + if (is_array($v)) $v = join('',$v); + echo "$k=>$v\n"; + } } catch(UnexpectedValueException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/iterator_023.phpt b/ext/spl/tests/iterator_023.phpt index 3f27a620e27b..b75b2bcb7a40 100644 --- a/ext/spl/tests/iterator_023.phpt +++ b/ext/spl/tests/iterator_023.phpt @@ -5,123 +5,123 @@ SPL: RecursiveIteratorIterator and catch getChildren class MyRecursiveArrayIterator extends RecursiveArrayIterator { - function getChildren() - { - echo __METHOD__ . "\n"; - return $this->current(); - } + function getChildren() + { + echo __METHOD__ . "\n"; + return $this->current(); + } - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . " = false\n"; - return false; - } - else - { - return true; - } - } + function valid() + { + if (!parent::valid()) + { + echo __METHOD__ . " = false\n"; + return false; + } + else + { + return true; + } + } } class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { - private $max_depth; - private $over = 0; - private $skip = false; + private $max_depth; + private $over = 0; + private $skip = false; - function __construct($it, $max_depth) - { - $this->max_depth = $max_depth; - parent::__construct($it, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD); - } + function __construct($it, $max_depth) + { + $this->max_depth = $max_depth; + parent::__construct($it, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD); + } - function rewind() - { - echo __METHOD__ . "\n"; - $this->skip = false; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + $this->skip = false; + parent::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - if ($this->skip) - { - $this->skip = false; - $this->next(); - } - return parent::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + if ($this->skip) + { + $this->skip = false; + $this->next(); + } + return parent::valid(); + } - function current() - { - echo __METHOD__ . "\n"; - return parent::current(); - } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } - function key() - { - echo __METHOD__ . "\n"; - return parent::key(); - } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } - function next() - { - echo __METHOD__ . "\n"; - parent::next(); - } + function next() + { + echo __METHOD__ . "\n"; + parent::next(); + } - function callHasChildren() - { - $this->skip = false; - $has = parent::callHasChildren(); - $res = $this->getDepth() < $this->max_depth && $has; - echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; - if ($has && !$res) - { - $this->over++; - if ($this->over == 2) { - $this->skip = true; - } - } - return $res; - } + function callHasChildren() + { + $this->skip = false; + $has = parent::callHasChildren(); + $res = $this->getDepth() < $this->max_depth && $has; + echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; + if ($has && !$res) + { + $this->over++; + if ($this->over == 2) { + $this->skip = true; + } + } + return $res; + } - function callGetChildren() - { - if ($this->over == 2) - { - echo __METHOD__ . "(throw)\n"; - throw new Exception("Thrown in callGetChildren()"); - } - echo __METHOD__ . "(ok:{$this->over})\n"; - return new MyRecursiveArrayIterator($this->current()); - } + function callGetChildren() + { + if ($this->over == 2) + { + echo __METHOD__ . "(throw)\n"; + throw new Exception("Thrown in callGetChildren()"); + } + echo __METHOD__ . "(ok:{$this->over})\n"; + return new MyRecursiveArrayIterator($this->current()); + } - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function beginChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - } + function endChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + } } try { - foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) - { - if (is_array($v)) $v = join('',$v); - echo "$k=>$v\n"; - } + foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v) + { + if (is_array($v)) $v = join('',$v); + echo "$k=>$v\n"; + } } catch(UnexpectedValueException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/iterator_024.phpt b/ext/spl/tests/iterator_024.phpt index 1af642b3117d..21f0216d9b97 100644 --- a/ext/spl/tests/iterator_024.phpt +++ b/ext/spl/tests/iterator_024.phpt @@ -12,11 +12,11 @@ var_dump($it->getIteratorClass()); try { - foreach(new RecursiveIteratorIterator(new ArrayObject($ar)) as $v) echo "$v\n"; + foreach(new RecursiveIteratorIterator(new ArrayObject($ar)) as $v) echo "$v\n"; } catch (InvalidArgumentException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } echo "===MANUAL===\n"; diff --git a/ext/spl/tests/iterator_025.phpt b/ext/spl/tests/iterator_025.phpt index 34d418fe4ce9..f3df902a6461 100644 --- a/ext/spl/tests/iterator_025.phpt +++ b/ext/spl/tests/iterator_025.phpt @@ -5,15 +5,15 @@ SPL: RecursiveIteratorIterator and begin/endIteration() class MyRecursiveIteratorIterator extends RecursiveIteratorIterator { - function beginIteration() - { - echo __METHOD__ . "()\n"; - } + function beginIteration() + { + echo __METHOD__ . "()\n"; + } - function endIteration() - { - echo __METHOD__ . "()\n"; - } + function endIteration() + { + echo __METHOD__ . "()\n"; + } } $ar = array(1, 2, array(31, 32, array(331)), 4); @@ -37,15 +37,15 @@ echo "===MANUAL===\n"; $it->rewind(); while($it->valid()) { - echo $it->current() . "\n"; - $it->next(); - break; + echo $it->current() . "\n"; + $it->next(); + break; } $it->rewind(); while($it->valid()) { - echo $it->current() . "\n"; - $it->next(); + echo $it->current() . "\n"; + $it->next(); } ?> diff --git a/ext/spl/tests/iterator_026.phpt b/ext/spl/tests/iterator_026.phpt index 23a1173b65e6..1117b65f8a25 100644 --- a/ext/spl/tests/iterator_026.phpt +++ b/ext/spl/tests/iterator_026.phpt @@ -11,8 +11,8 @@ $it = new RecursiveIteratorIterator($it); foreach($it as $k=>$v) { - echo "$k=>$v\n"; - echo "hasNext: " . ($it->getInnerIterator()->hasNext() ? "yes" : "no") . "\n"; + echo "$k=>$v\n"; + echo "hasNext: " . ($it->getInnerIterator()->hasNext() ? "yes" : "no") . "\n"; } ?> diff --git a/ext/spl/tests/iterator_027.phpt b/ext/spl/tests/iterator_027.phpt index 0b7cd72b109a..1bd6990493d7 100644 --- a/ext/spl/tests/iterator_027.phpt +++ b/ext/spl/tests/iterator_027.phpt @@ -11,17 +11,17 @@ $it = new CachingIterator($it, CachingIterator::FULL_CACHE); foreach($it as $k=>$v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } echo "===CHECK===\n"; for ($i = 0; $i < 4; $i++) { - if (isset($it[$i])) - { - var_dump($i, $it[$i]); - } + if (isset($it[$i])) + { + var_dump($i, $it[$i]); + } } $it[2] = 'foo'; diff --git a/ext/spl/tests/iterator_028.phpt b/ext/spl/tests/iterator_028.phpt index 8a42985e02a9..5d681ccac05e 100644 --- a/ext/spl/tests/iterator_028.phpt +++ b/ext/spl/tests/iterator_028.phpt @@ -41,12 +41,12 @@ $it->setMaxDepth(-1); var_dump($it->getMaxDepth()); try { - $it->setMaxDepth(4); - $it->setMaxDepth(-2); + $it->setMaxDepth(4); + $it->setMaxDepth(-2); } catch(Exception $e) { - var_dump($e->getMessage()); + var_dump($e->getMessage()); } var_dump($it->getMaxDepth()); ?> diff --git a/ext/spl/tests/iterator_029.phpt b/ext/spl/tests/iterator_029.phpt index 5cafda584ca0..a6f79343c70c 100644 --- a/ext/spl/tests/iterator_029.phpt +++ b/ext/spl/tests/iterator_029.phpt @@ -7,7 +7,7 @@ $ar = array(0, "123", 123, 22 => "abc", "a2b", 22, "a2d" => 7, 42); foreach(new RegexIterator(new ArrayIterator($ar), "/2/") as $k => $v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } ?> @@ -16,7 +16,7 @@ foreach(new RegexIterator(new ArrayIterator($ar), "/2/") as $k => $v) foreach(new RegexIterator(new ArrayIterator($ar), "/2/", 0, RegexIterator::USE_KEY) as $k => $v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } ?> diff --git a/ext/spl/tests/iterator_030.phpt b/ext/spl/tests/iterator_030.phpt index c1c2b33a45b5..6a684ec30004 100644 --- a/ext/spl/tests/iterator_030.phpt +++ b/ext/spl/tests/iterator_030.phpt @@ -13,20 +13,20 @@ var_dump($it->valid()); try { - var_dump($it->key()); + var_dump($it->key()); } catch(BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } try { - var_dump($it->current()); + var_dump($it->current()); } catch(BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } var_dump($it->valid()); diff --git a/ext/spl/tests/iterator_031.phpt b/ext/spl/tests/iterator_031.phpt index f935e0393bc9..247e13bfff08 100644 --- a/ext/spl/tests/iterator_031.phpt +++ b/ext/spl/tests/iterator_031.phpt @@ -5,71 +5,71 @@ SPL: AppendIterator::append() rewinds when necessary class MyArrayIterator extends ArrayIterator { - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } } $it = new MyArrayIterator(array(1,2)); foreach($it as $k=>$v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } class MyAppendIterator extends AppendIterator { - function __construct() - { - echo __METHOD__ . "\n"; - } + function __construct() + { + echo __METHOD__ . "\n"; + } - function rewind() - { - echo __METHOD__ . "\n"; - parent::rewind(); - } + function rewind() + { + echo __METHOD__ . "\n"; + parent::rewind(); + } - function valid() - { - echo __METHOD__ . "\n"; - return parent::valid(); - } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } - function append(Iterator $what) - { - echo __METHOD__ . "\n"; - parent::append($what); - } + function append(Iterator $what) + { + echo __METHOD__ . "\n"; + parent::append($what); + } - function parent__construct() - { - parent::__construct(); - } + function parent__construct() + { + parent::__construct(); + } } $ap = new MyAppendIterator; try { - $ap->append($it); + $ap->append($it); } catch(LogicException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $ap->parent__construct(); try { - $ap->parent__construct($it); + $ap->parent__construct($it); } catch(BadMethodCallException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $ap->append($it); @@ -78,7 +78,7 @@ $ap->append($it); foreach($ap as $k=>$v) { - echo "$k=>$v\n"; + echo "$k=>$v\n"; } ?> diff --git a/ext/spl/tests/iterator_032.phpt b/ext/spl/tests/iterator_032.phpt index 258b3c693496..9f56d7574db7 100644 --- a/ext/spl/tests/iterator_032.phpt +++ b/ext/spl/tests/iterator_032.phpt @@ -7,17 +7,17 @@ $it = new LimitIterator(new ArrayIterator(array(1,2,3,4)), 1, 2); foreach($it as $k=>$v) { - echo "$k=>$v\n"; - var_dump($it->getPosition()); + echo "$k=>$v\n"; + var_dump($it->getPosition()); } try { - $it->seek(0); + $it->seek(0); } catch(OutOfBoundsException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $it->seek(2); @@ -25,11 +25,11 @@ var_dump($it->current()); try { - $it->seek(3); + $it->seek(3); } catch(OutOfBoundsException $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } $it->next(); diff --git a/ext/spl/tests/iterator_033.phpt b/ext/spl/tests/iterator_033.phpt index 44cde1962b3b..7e1f93a6ee4b 100644 --- a/ext/spl/tests/iterator_033.phpt +++ b/ext/spl/tests/iterator_033.phpt @@ -7,16 +7,16 @@ $it = new ParentIterator(new RecursiveArrayIterator(array(1,array(21,22, array(2 foreach(new RecursiveIteratorIterator($it) as $k=>$v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } echo "==SECOND==\n"; foreach(new RecursiveIteratorIterator($it, 1) as $k=>$v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } ?> diff --git a/ext/spl/tests/iterator_034.phpt b/ext/spl/tests/iterator_034.phpt index 402ef7e43cd7..76cc9589ce75 100644 --- a/ext/spl/tests/iterator_034.phpt +++ b/ext/spl/tests/iterator_034.phpt @@ -5,106 +5,106 @@ SPL: RecursiveIteratorIterator and break deep class MyRecursiveArrayIterator extends RecursiveArrayIterator { - function valid() - { - if (!parent::valid()) - { - echo __METHOD__ . "() = false\n"; - return false; - } - else - { - return true; - } - } - - function getChildren() - { - echo __METHOD__ . "()\n"; - return parent::getChildren(); - } - - function rewind() - { - echo __METHOD__ . "()\n"; - parent::rewind(); - } + function valid() + { + if (!parent::valid()) + { + echo __METHOD__ . "() = false\n"; + return false; + } + else + { + return true; + } + } + + function getChildren() + { + echo __METHOD__ . "()\n"; + return parent::getChildren(); + } + + function rewind() + { + echo __METHOD__ . "()\n"; + parent::rewind(); + } } class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { - private $max_depth; - private $over = 0; - - function __construct($it, $max_depth) - { - $this->max_depth = $max_depth; - parent::__construct($it); - } - - function rewind() - { - echo __METHOD__ . "() - BEGIN\n"; - parent::rewind(); - echo __METHOD__ . "() - DONE\n"; - } - - function valid() - { - echo __METHOD__ . "()\n"; - return parent::valid(); - } - - function current() - { - echo __METHOD__ . "()\n"; - return parent::current(); - } - - function key() - { - echo __METHOD__ . "()\n"; - return parent::key(); - } - - function next() - { - echo __METHOD__ . "()\n"; - parent::next(); - } - - function callHasChildren() - { - $has = parent::callHasChildren(); - $res = $this->getDepth() < $this->max_depth && $has; - echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; - return $res; - } - - function beginChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - parent::beginChildren(); - } - - function endChildren() - { - echo __METHOD__ . "(".$this->getDepth().")\n"; - parent::endChildren(); - } + private $max_depth; + private $over = 0; + + function __construct($it, $max_depth) + { + $this->max_depth = $max_depth; + parent::__construct($it); + } + + function rewind() + { + echo __METHOD__ . "() - BEGIN\n"; + parent::rewind(); + echo __METHOD__ . "() - DONE\n"; + } + + function valid() + { + echo __METHOD__ . "()\n"; + return parent::valid(); + } + + function current() + { + echo __METHOD__ . "()\n"; + return parent::current(); + } + + function key() + { + echo __METHOD__ . "()\n"; + return parent::key(); + } + + function next() + { + echo __METHOD__ . "()\n"; + parent::next(); + } + + function callHasChildren() + { + $has = parent::callHasChildren(); + $res = $this->getDepth() < $this->max_depth && $has; + echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n"; + return $res; + } + + function beginChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + parent::beginChildren(); + } + + function endChildren() + { + echo __METHOD__ . "(".$this->getDepth().")\n"; + parent::endChildren(); + } } $p = 0; $it = new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2); foreach($it as $k=>$v) { - if (is_array($v)) $v = join('',$v); - echo "$k=>$v\n"; - if ($p++ == 5) - { - echo "===BREAK===\n"; - break; - } + if (is_array($v)) $v = join('',$v); + echo "$k=>$v\n"; + if ($p++ == 5) + { + echo "===BREAK===\n"; + break; + } } echo "===FOREND===\n"; diff --git a/ext/spl/tests/iterator_036.phpt b/ext/spl/tests/iterator_036.phpt index 07a1f79134e9..bfe1825abe72 100644 --- a/ext/spl/tests/iterator_036.phpt +++ b/ext/spl/tests/iterator_036.phpt @@ -5,10 +5,10 @@ SPL: CachingIterator and __toString and flags = 0 function test($it) { - foreach($it as $v) - { - var_dump((string)$it); - } + foreach($it as $v) + { + var_dump((string)$it); + } } $ar = new ArrayIterator(array(1, 2, 3)); diff --git a/ext/spl/tests/iterator_037.phpt b/ext/spl/tests/iterator_037.phpt index 4b4f14e4d35f..1792b1cb66fa 100644 --- a/ext/spl/tests/iterator_037.phpt +++ b/ext/spl/tests/iterator_037.phpt @@ -5,51 +5,51 @@ SPL: CachingIterator and __toString function test($ar, $flags) { - echo "===$flags===\n"; - $it = new CachingIterator($ar, 0); - try - { - $it->setFlags($flags); - } - catch (Exception $e) - { - echo 'Exception: ' . $e->getMessage() . "\n"; - var_dump($it->getFlags()); - return; - } - var_dump($it->getFlags()); - try - { - foreach($it as $v) - { - var_dump((string)$it); - } - } - catch (Exception $e) - { - echo 'Exception: ' . $e->getMessage() . "\n"; - } + echo "===$flags===\n"; + $it = new CachingIterator($ar, 0); + try + { + $it->setFlags($flags); + } + catch (Exception $e) + { + echo 'Exception: ' . $e->getMessage() . "\n"; + var_dump($it->getFlags()); + return; + } + var_dump($it->getFlags()); + try + { + foreach($it as $v) + { + var_dump((string)$it); + } + } + catch (Exception $e) + { + echo 'Exception: ' . $e->getMessage() . "\n"; + } } class MyItem { - function __construct($value) - { - $this->value = $value; - } + function __construct($value) + { + $this->value = $value; + } - function __toString() - { - return (string)$this->value; - } + function __toString() + { + return (string)$this->value; + } } class MyArrayIterator extends ArrayIterator { - function __toString() - { - return $this->key() . ':' . $this->current(); - } + function __toString() + { + return $this->key() . ':' . $this->current(); + } } $ar = new MyArrayIterator(array(1, 2, 3)); @@ -70,21 +70,21 @@ test($ar, CachingIterator::TOSTRING_USE_KEY | CachingIterator::TOSTRING_USE_INNE echo "===X===\n"; try { - $it = new CachingIterator($ar, CachingIterator::CALL_TOSTRING); - $it->setFlags(0); + $it = new CachingIterator($ar, CachingIterator::CALL_TOSTRING); + $it->setFlags(0); } catch (Exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } try { - $it = new CachingIterator($ar, CachingIterator::TOSTRING_USE_INNER); - $it->setFlags(0); + $it = new CachingIterator($ar, CachingIterator::TOSTRING_USE_INNER); + $it->setFlags(0); } catch (Exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/iterator_038.phpt b/ext/spl/tests/iterator_038.phpt index 1ac32621811a..cb4d3a379510 100644 --- a/ext/spl/tests/iterator_038.phpt +++ b/ext/spl/tests/iterator_038.phpt @@ -5,8 +5,8 @@ SPL: RoRewindIterator and string keys foreach(new NoRewindIterator(new ArrayIterator(array('Hello'=>0, 'World'=>1))) as $k => $v) { - var_dump($v); - var_dump($k); + var_dump($v); + var_dump($k); } ?> diff --git a/ext/spl/tests/iterator_039.phpt b/ext/spl/tests/iterator_039.phpt index eb5018e07f9d..18f9a24168fa 100644 --- a/ext/spl/tests/iterator_039.phpt +++ b/ext/spl/tests/iterator_039.phpt @@ -5,52 +5,52 @@ SPL: LimitIterator and backward seeking class NumericArrayIterator implements Iterator { - protected $a; - protected $i = 0; + protected $a; + protected $i = 0; - public function __construct($a) - { - echo __METHOD__ . "\n"; - $this->a = $a; - } + public function __construct($a) + { + echo __METHOD__ . "\n"; + $this->a = $a; + } - public function valid() - { - echo __METHOD__ . "\n"; - return $this->i < count($this->a); - } + public function valid() + { + echo __METHOD__ . "\n"; + return $this->i < count($this->a); + } - public function rewind() - { - echo __METHOD__ . "\n"; - $this->i = 0; - } + public function rewind() + { + echo __METHOD__ . "\n"; + $this->i = 0; + } - public function key() - { - echo __METHOD__ . "\n"; - return $this->i; - } + public function key() + { + echo __METHOD__ . "\n"; + return $this->i; + } - public function current() - { - echo __METHOD__ . "\n"; - return $this->a[$this->i]; - } + public function current() + { + echo __METHOD__ . "\n"; + return $this->a[$this->i]; + } - public function next() - { - echo __METHOD__ . "\n"; - $this->i++; - } + public function next() + { + echo __METHOD__ . "\n"; + $this->i++; + } } $it = new LimitIterator(new NumericArrayIterator(array(12, 25, 42, 56))); foreach($it as $k => $v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } echo "===SEEK===\n"; @@ -61,8 +61,8 @@ echo "===LOOP===\n"; foreach(new NoRewindIterator($it) as $k => $v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } ?> diff --git a/ext/spl/tests/iterator_040.phpt b/ext/spl/tests/iterator_040.phpt index abc5193769a8..1e8bd5576454 100644 --- a/ext/spl/tests/iterator_040.phpt +++ b/ext/spl/tests/iterator_040.phpt @@ -5,10 +5,10 @@ SPL: RecursiveFilterIterator class MyRecursiveFilterIterator extends RecursiveFilterIterator { - function accept() - { - return true; - } + function accept() + { + return true; + } } $ar = array(1, array(21, 22), 3); @@ -18,10 +18,10 @@ $it = new RecursiveIteratorIterator($it); foreach($it as $k => $v) { - echo "===\n"; - var_dump($it->getDepth()); - var_dump($k); - var_dump($v); + echo "===\n"; + var_dump($it->getDepth()); + var_dump($k); + var_dump($v); } ?> diff --git a/ext/spl/tests/iterator_041.phpt b/ext/spl/tests/iterator_041.phpt index cb4ca9cd4604..98892c87e0d7 100644 --- a/ext/spl/tests/iterator_041.phpt +++ b/ext/spl/tests/iterator_041.phpt @@ -5,85 +5,85 @@ SPL: iterator_to_array() and exceptions class MyArrayIterator extends ArrayIterator { - static protected $fail = 0; - public $state; + static protected $fail = 0; + public $state; - static function fail($state, $method) - { - if (self::$fail == $state) - { - throw new Exception("State $state: $method()"); - } - } + static function fail($state, $method) + { + if (self::$fail == $state) + { + throw new Exception("State $state: $method()"); + } + } - function __construct() - { - $this->state = MyArrayIterator::$fail; - self::fail(0, __FUNCTION__); - parent::__construct(array(1, 2)); - self::fail(1, __FUNCTION__); - } + function __construct() + { + $this->state = MyArrayIterator::$fail; + self::fail(0, __FUNCTION__); + parent::__construct(array(1, 2)); + self::fail(1, __FUNCTION__); + } - function rewind() - { - self::fail(2, __FUNCTION__); - return parent::rewind(); - } + function rewind() + { + self::fail(2, __FUNCTION__); + return parent::rewind(); + } - function valid() - { - self::fail(3, __FUNCTION__); - return parent::valid(); - } + function valid() + { + self::fail(3, __FUNCTION__); + return parent::valid(); + } - function current() - { - self::fail(4, __FUNCTION__); - return parent::current(); - } + function current() + { + self::fail(4, __FUNCTION__); + return parent::current(); + } - function key() - { - self::fail(5, __FUNCTION__); - return parent::key(); - } + function key() + { + self::fail(5, __FUNCTION__); + return parent::key(); + } - function next() - { - self::fail(6, __FUNCTION__); - return parent::next(); - } + function next() + { + self::fail(6, __FUNCTION__); + return parent::next(); + } - function __destruct() - { + function __destruct() + { // self::fail(7, __FUNCTION__); - } + } - static function test($func, $skip = null) - { - echo "===$func===\n"; - self::$fail = 0; - while(self::$fail < 10) - { - try - { - var_dump($func(new MyArrayIterator())); - break; - } - catch (Exception $e) - { - echo $e->getMessage() . "\n"; - } - if (isset($skip[self::$fail])) - { - self::$fail = $skip[self::$fail]; - } - else - { - self::$fail++; - } - } - } + static function test($func, $skip = null) + { + echo "===$func===\n"; + self::$fail = 0; + while(self::$fail < 10) + { + try + { + var_dump($func(new MyArrayIterator())); + break; + } + catch (Exception $e) + { + echo $e->getMessage() . "\n"; + } + if (isset($skip[self::$fail])) + { + self::$fail = $skip[self::$fail]; + } + else + { + self::$fail++; + } + } + } } MyArrayIterator::test('iterator_to_array'); diff --git a/ext/spl/tests/iterator_041a.phpt b/ext/spl/tests/iterator_041a.phpt index e7277dcaf9ca..37b4341297c5 100644 --- a/ext/spl/tests/iterator_041a.phpt +++ b/ext/spl/tests/iterator_041a.phpt @@ -5,85 +5,85 @@ SPL: iterator_to_array() and exceptions from destruct class MyArrayIterator extends ArrayIterator { - static protected $fail = 0; - public $state; + static protected $fail = 0; + public $state; - static function fail($state, $method) - { - if (self::$fail == $state) - { - throw new Exception("State $state: $method()"); - } - } + static function fail($state, $method) + { + if (self::$fail == $state) + { + throw new Exception("State $state: $method()"); + } + } - function __construct() - { - $this->state = MyArrayIterator::$fail; - self::fail(0, __FUNCTION__); - parent::__construct(array(1, 2)); - self::fail(1, __FUNCTION__); - } + function __construct() + { + $this->state = MyArrayIterator::$fail; + self::fail(0, __FUNCTION__); + parent::__construct(array(1, 2)); + self::fail(1, __FUNCTION__); + } - function rewind() - { - self::fail(2, __FUNCTION__); - return parent::rewind(); - } + function rewind() + { + self::fail(2, __FUNCTION__); + return parent::rewind(); + } - function valid() - { - self::fail(3, __FUNCTION__); - return parent::valid(); - } + function valid() + { + self::fail(3, __FUNCTION__); + return parent::valid(); + } - function current() - { - self::fail(4, __FUNCTION__); - return parent::current(); - } + function current() + { + self::fail(4, __FUNCTION__); + return parent::current(); + } - function key() - { - self::fail(5, __FUNCTION__); - return parent::key(); - } + function key() + { + self::fail(5, __FUNCTION__); + return parent::key(); + } - function next() - { - self::fail(6, __FUNCTION__); - return parent::next(); - } + function next() + { + self::fail(6, __FUNCTION__); + return parent::next(); + } - function __destruct() - { - self::fail(7, __FUNCTION__); - } + function __destruct() + { + self::fail(7, __FUNCTION__); + } - static function test($func, $skip = null) - { - echo "===$func===\n"; - self::$fail = 7; - while(self::$fail < 10) - { - try - { - var_dump($func(new MyArrayIterator())); - break; - } - catch (Exception $e) - { - echo $e->getMessage() . "\n"; - } - if (isset($skip[self::$fail])) - { - self::$fail = $skip[self::$fail]; - } - else - { - self::$fail++; - } - } - } + static function test($func, $skip = null) + { + echo "===$func===\n"; + self::$fail = 7; + while(self::$fail < 10) + { + try + { + var_dump($func(new MyArrayIterator())); + break; + } + catch (Exception $e) + { + echo $e->getMessage() . "\n"; + } + if (isset($skip[self::$fail])) + { + self::$fail = $skip[self::$fail]; + } + else + { + self::$fail++; + } + } + } } MyArrayIterator::test('iterator_to_array'); diff --git a/ext/spl/tests/iterator_041b.phpt b/ext/spl/tests/iterator_041b.phpt index 829bde94f70a..517b8fc5e46b 100644 --- a/ext/spl/tests/iterator_041b.phpt +++ b/ext/spl/tests/iterator_041b.phpt @@ -5,89 +5,89 @@ SPL: iterator_to_array() and exceptions from delayed destruct class MyArrayIterator extends ArrayIterator { - static protected $fail = 0; - public $state; + static protected $fail = 0; + public $state; - static function fail($state, $method) - { - if (self::$fail == $state) - { - throw new Exception("State $state: $method()"); - } - } + static function fail($state, $method) + { + if (self::$fail == $state) + { + throw new Exception("State $state: $method()"); + } + } - function __construct() - { - $this->state = MyArrayIterator::$fail; - self::fail(0, __FUNCTION__); - parent::__construct(array(1, 2)); - self::fail(1, __FUNCTION__); - } + function __construct() + { + $this->state = MyArrayIterator::$fail; + self::fail(0, __FUNCTION__); + parent::__construct(array(1, 2)); + self::fail(1, __FUNCTION__); + } - function rewind() - { - self::fail(2, __FUNCTION__); - return parent::rewind(); - } + function rewind() + { + self::fail(2, __FUNCTION__); + return parent::rewind(); + } - function valid() - { - self::fail(3, __FUNCTION__); - return parent::valid(); - } + function valid() + { + self::fail(3, __FUNCTION__); + return parent::valid(); + } - function current() - { - self::fail(4, __FUNCTION__); - return parent::current(); - } + function current() + { + self::fail(4, __FUNCTION__); + return parent::current(); + } - function key() - { - self::fail(5, __FUNCTION__); - return parent::key(); - } + function key() + { + self::fail(5, __FUNCTION__); + return parent::key(); + } - function next() - { - self::fail(6, __FUNCTION__); - return parent::next(); - } + function next() + { + self::fail(6, __FUNCTION__); + return parent::next(); + } - function __destruct() - { - self::fail(7, __FUNCTION__); - } + function __destruct() + { + self::fail(7, __FUNCTION__); + } - static function test($func, $skip = null) - { - echo "===$func===\n"; - self::$fail = 0; - while(self::$fail < 10) - { - try - { - var_dump($func(new MyArrayIterator())); - break; - } - catch (Exception $e) - { - echo $e->getMessage() . "\n"; - } - if (isset($skip[self::$fail])) - { - self::$fail = $skip[self::$fail]; - } - else - { - self::$fail++; - } - try { - $e = null; - } catch (Exception $e) { - } - } - } + static function test($func, $skip = null) + { + echo "===$func===\n"; + self::$fail = 0; + while(self::$fail < 10) + { + try + { + var_dump($func(new MyArrayIterator())); + break; + } + catch (Exception $e) + { + echo $e->getMessage() . "\n"; + } + if (isset($skip[self::$fail])) + { + self::$fail = $skip[self::$fail]; + } + else + { + self::$fail++; + } + try { + $e = null; + } catch (Exception $e) { + } + } + } } MyArrayIterator::test('iterator_to_array'); diff --git a/ext/spl/tests/iterator_042.phpt b/ext/spl/tests/iterator_042.phpt index 9c656cbad72d..2c14fc3d4036 100644 --- a/ext/spl/tests/iterator_042.phpt +++ b/ext/spl/tests/iterator_042.phpt @@ -5,8 +5,8 @@ SPL: AppendIterator and its ArrayIterator function test_error_handler($errno, $msg, $filename, $linenum) { - echo "Error $msg in $filename on line $linenum\n"; - return true; + echo "Error $msg in $filename on line $linenum\n"; + return true; } set_error_handler('test_error_handler'); @@ -14,9 +14,9 @@ set_error_handler('test_error_handler'); $it = new AppendIterator; try { - $it->append(array()); + $it->append(array()); } catch (Error $e) { - test_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); + test_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } $it->append(new ArrayIterator(array(1))); $it->append(new ArrayIterator(array(21, 22))); @@ -31,10 +31,10 @@ $idx = 0; foreach($it as $k => $v) { - echo '===' . $idx++ . "===\n"; - var_dump($it->getIteratorIndex()); - var_dump($k); - var_dump($v); + echo '===' . $idx++ . "===\n"; + var_dump($it->getIteratorIndex()); + var_dump($k); + var_dump($v); } ?> diff --git a/ext/spl/tests/iterator_044.phpt b/ext/spl/tests/iterator_044.phpt index 68842cd6f02f..89d8bef77240 100644 --- a/ext/spl/tests/iterator_044.phpt +++ b/ext/spl/tests/iterator_044.phpt @@ -5,57 +5,57 @@ SPL: CachingIterator and offsetGet/Exists using flag FULL_CACHE class MyFoo { - function __toString() - { - return 'foo'; - } + function __toString() + { + return 'foo'; + } } class MyCachingIterator extends CachingIterator { - function __construct(Iterator $it, $flags = 0) - { - parent::__construct($it, $flags); - } - - function test($ar) - { - foreach($ar as $k => $v) - { - echo "===$k===\n"; - var_dump($v); - try { + function __construct(Iterator $it, $flags = 0) + { + parent::__construct($it, $flags); + } + + function test($ar) + { + foreach($ar as $k => $v) + { + echo "===$k===\n"; + var_dump($v); + try { var_dump($this->offsetExists($v)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } - try { + try { var_dump($this->offsetGet($v)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } - } - } + } + } } $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4))); try { - var_dump($it->offsetExists(0)); + var_dump($it->offsetExists(0)); } catch(Exception $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump($it->offsetGet(0)); + var_dump($it->offsetGet(0)); } catch(Exception $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4)), CachingIterator::FULL_CACHE); diff --git a/ext/spl/tests/iterator_045.phpt b/ext/spl/tests/iterator_045.phpt index e0e2070ec1af..63d78cc78e40 100644 --- a/ext/spl/tests/iterator_045.phpt +++ b/ext/spl/tests/iterator_045.phpt @@ -5,70 +5,70 @@ SPL: CachingIterator and offsetSet/Unset, getCache using flag FULL_CACHE class MyFoo { - function __toString() - { - return 'foo'; - } + function __toString() + { + return 'foo'; + } } class MyCachingIterator extends CachingIterator { - function __construct(Iterator $it, $flags = 0) - { - parent::__construct($it, $flags); - } + function __construct(Iterator $it, $flags = 0) + { + parent::__construct($it, $flags); + } - function testSet($ar) - { - echo __METHOD__ . "()\n"; - foreach($ar as $k => $v) - { - echo "set($k,$v)\n"; - $this->offsetSet($k, $v); - } - } + function testSet($ar) + { + echo __METHOD__ . "()\n"; + foreach($ar as $k => $v) + { + echo "set($k,$v)\n"; + $this->offsetSet($k, $v); + } + } - function testUnset($ar) - { - echo __METHOD__ . "()\n"; - foreach($ar as $k => $v) - { - echo "unset($v)\n"; - $this->offsetUnset($v); - } - } + function testUnset($ar) + { + echo __METHOD__ . "()\n"; + foreach($ar as $k => $v) + { + echo "unset($v)\n"; + $this->offsetUnset($v); + } + } - function fill() - { - echo __METHOD__ . "()\n"; - foreach($this as $v) ; - } + function fill() + { + echo __METHOD__ . "()\n"; + foreach($this as $v) ; + } - function show() - { - echo __METHOD__ . "()\n"; - var_dump($this->getCache()); - } + function show() + { + echo __METHOD__ . "()\n"; + var_dump($this->getCache()); + } } $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4))); try { - var_dump($it->offsetSet(0, 0)); + var_dump($it->offsetSet(0, 0)); } catch(Exception $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump($it->offsetUnset(0)); + var_dump($it->offsetUnset(0)); } catch(Exception $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } $it = new MyCachingIterator(new ArrayIterator(array(0, 1, 2, 3)), CachingIterator::FULL_CACHE); diff --git a/ext/spl/tests/iterator_046.phpt b/ext/spl/tests/iterator_046.phpt index 03d833921bf2..e377dcb731cd 100644 --- a/ext/spl/tests/iterator_046.phpt +++ b/ext/spl/tests/iterator_046.phpt @@ -5,33 +5,33 @@ SPL: CachingIterator and __toString using bypassed string keys class MyFoo { - function __toString() - { - return 'foo'; - } + function __toString() + { + return 'foo'; + } } class MyCachingIterator extends CachingIterator { - function __construct(Iterator $it, $flags = 0) - { - parent::__construct($it, $flags); - } + function __construct(Iterator $it, $flags = 0) + { + parent::__construct($it, $flags); + } - function fill() - { - echo __METHOD__ . "()\n"; - foreach($this as $v) ; - } + function fill() + { + echo __METHOD__ . "()\n"; + foreach($this as $v) ; + } - function show() - { - echo __METHOD__ . "()\n"; - foreach($this as $v) - { - var_dump((string)$this); - } - } + function show() + { + echo __METHOD__ . "()\n"; + foreach($this as $v) + { + var_dump((string)$this); + } + } } $it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 'bar'=>2)), CachingIterator::TOSTRING_USE_KEY); diff --git a/ext/spl/tests/iterator_047.phpt b/ext/spl/tests/iterator_047.phpt index 32495c5c40e2..9d7586bf4e24 100644 --- a/ext/spl/tests/iterator_047.phpt +++ b/ext/spl/tests/iterator_047.phpt @@ -5,54 +5,54 @@ SPL: RecursiveCachingIterator and exception in has/getChildren class MyRecursiveArrayIterator extends RecursiveArrayIterator { - static public $fail = 0; + static public $fail = 0; - static function fail($state, $method) - { - if (self::$fail == $state) - { - throw new Exception("State $state: $method()"); - } - } + static function fail($state, $method) + { + if (self::$fail == $state) + { + throw new Exception("State $state: $method()"); + } + } - function hasChildren() - { - echo __METHOD__ . "()\n"; - self::fail(1, __METHOD__); - return parent::hasChildren(); - } + function hasChildren() + { + echo __METHOD__ . "()\n"; + self::fail(1, __METHOD__); + return parent::hasChildren(); + } - function getChildren() - { - echo __METHOD__ . "()\n"; - self::fail(2, __METHOD__); - return parent::getChildren(); - } + function getChildren() + { + echo __METHOD__ . "()\n"; + self::fail(2, __METHOD__); + return parent::getChildren(); + } } class MyRecursiveCachingIterator extends RecursiveCachingIterator { - function show() - { - MyRecursiveArrayIterator::$fail = 0; - while(MyRecursiveArrayIterator::$fail < 4) - { - echo "===" . MyRecursiveArrayIterator::$fail . "===\n"; - try - { - foreach(new RecursiveIteratorIterator($this) as $k => $v) - { - var_dump($k); - var_dump($v); - } - } - catch (Exception $e) - { - echo "Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; - } - MyRecursiveArrayIterator::$fail++; - } - } + function show() + { + MyRecursiveArrayIterator::$fail = 0; + while(MyRecursiveArrayIterator::$fail < 4) + { + echo "===" . MyRecursiveArrayIterator::$fail . "===\n"; + try + { + foreach(new RecursiveIteratorIterator($this) as $k => $v) + { + var_dump($k); + var_dump($v); + } + } + catch (Exception $e) + { + echo "Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; + } + MyRecursiveArrayIterator::$fail++; + } + } } $it = new MyRecursiveArrayIterator(array(0, array(10), 2, array(30), 4)); diff --git a/ext/spl/tests/iterator_048.phpt b/ext/spl/tests/iterator_048.phpt index ba776881dd5c..ce5a06993a72 100644 --- a/ext/spl/tests/iterator_048.phpt +++ b/ext/spl/tests/iterator_048.phpt @@ -5,14 +5,14 @@ SPL: RecursiveRegexIterator and exception in has/getChildren class MyRecursiveRegexIterator extends RecursiveRegexIterator { - function show() - { - foreach(new RecursiveIteratorIterator($this) as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach(new RecursiveIteratorIterator($this) as $k => $v) + { + var_dump($k); + var_dump($v); + } + } } $ar = new RecursiveArrayIterator(array('Foo', array('Bar'), 'FooBar', array('Baz'), 'Biz')); diff --git a/ext/spl/tests/iterator_049b.phpt b/ext/spl/tests/iterator_049b.phpt index 5a374cafc8c7..54a2c2e0405b 100644 Binary files a/ext/spl/tests/iterator_049b.phpt and b/ext/spl/tests/iterator_049b.phpt differ diff --git a/ext/spl/tests/iterator_050.phpt b/ext/spl/tests/iterator_050.phpt index a0ef97606687..dd8ad544b8b2 100644 --- a/ext/spl/tests/iterator_050.phpt +++ b/ext/spl/tests/iterator_050.phpt @@ -5,14 +5,14 @@ SPL: RegexIterator::GET_MATCH class MyRegexIterator extends RegexIterator { - function show() - { - foreach($this as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach($this as $k => $v) + { + var_dump($k); + var_dump($v); + } + } } $ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,')); diff --git a/ext/spl/tests/iterator_051.phpt b/ext/spl/tests/iterator_051.phpt index 93a2df5f1c42..8b3c6563d13d 100644 --- a/ext/spl/tests/iterator_051.phpt +++ b/ext/spl/tests/iterator_051.phpt @@ -5,14 +5,14 @@ SPL: RegexIterator::GET_MATCH, USE_KEY class MyRegexIterator extends RegexIterator { - function show() - { - foreach($this as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach($this as $k => $v) + { + var_dump($k); + var_dump($v); + } + } } $ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6)); diff --git a/ext/spl/tests/iterator_052.phpt b/ext/spl/tests/iterator_052.phpt index 3ea69ac80b06..e73d40203d53 100644 --- a/ext/spl/tests/iterator_052.phpt +++ b/ext/spl/tests/iterator_052.phpt @@ -5,31 +5,31 @@ SPL: RegexIterator::ALL_MATCHES class MyRegexIterator extends RegexIterator { - public $uk, $re; + public $uk, $re; - function __construct($it, $re, $mode, $flags = 0) - { - $this->uk = $flags & self::USE_KEY; - $this->re = $re; - parent::__construct($it, $re, $mode, $flags); - } + function __construct($it, $re, $mode, $flags = 0) + { + $this->uk = $flags & self::USE_KEY; + $this->re = $re; + parent::__construct($it, $re, $mode, $flags); + } - function show() - { - foreach($this as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach($this as $k => $v) + { + var_dump($k); + var_dump($v); + } + } - function accept() - { - @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub); - $ret = parent::accept(); - var_dump($sub == $this->current()); - return $ret; - } + function accept() + { + @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub); + $ret = parent::accept(); + var_dump($sub == $this->current()); + return $ret; + } } $ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,')); diff --git a/ext/spl/tests/iterator_053.phpt b/ext/spl/tests/iterator_053.phpt index 02c18fdd6bd6..ac8f438a0461 100644 --- a/ext/spl/tests/iterator_053.phpt +++ b/ext/spl/tests/iterator_053.phpt @@ -5,31 +5,31 @@ SPL: RegexIterator::ALL_MATCHES class MyRegexIterator extends RegexIterator { - public $uk, $re; + public $uk, $re; - function __construct($it, $re, $mode, $flags = 0) - { - $this->uk = $flags & self::USE_KEY; - $this->re = $re; - parent::__construct($it, $re, $mode, $flags); - } + function __construct($it, $re, $mode, $flags = 0) + { + $this->uk = $flags & self::USE_KEY; + $this->re = $re; + parent::__construct($it, $re, $mode, $flags); + } - function show() - { - foreach($this as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach($this as $k => $v) + { + var_dump($k); + var_dump($v); + } + } - function accept() - { - @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub); - $ret = parent::accept(); - var_dump($sub == $this->current()); - return $ret; - } + function accept() + { + @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub); + $ret = parent::accept(); + var_dump($sub == $this->current()); + return $ret; + } } $ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,')); diff --git a/ext/spl/tests/iterator_054.phpt b/ext/spl/tests/iterator_054.phpt index b3df5a7e6be0..f40639dd36f1 100644 --- a/ext/spl/tests/iterator_054.phpt +++ b/ext/spl/tests/iterator_054.phpt @@ -5,14 +5,14 @@ SPL: RegexIterator::SPLIT class MyRegexIterator extends RegexIterator { - function show() - { - foreach($this as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach($this as $k => $v) + { + var_dump($k); + var_dump($v); + } + } } $ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,')); diff --git a/ext/spl/tests/iterator_055.phpt b/ext/spl/tests/iterator_055.phpt index 1ae21a66116f..58d710c04adf 100644 --- a/ext/spl/tests/iterator_055.phpt +++ b/ext/spl/tests/iterator_055.phpt @@ -5,14 +5,14 @@ SPL: RegexIterator::SPLIT, USE_KEY class MyRegexIterator extends RegexIterator { - function show() - { - foreach($this as $k => $v) - { - var_dump($k); - var_dump($v); - } - } + function show() + { + foreach($this as $k => $v) + { + var_dump($k); + var_dump($v); + } + } } $ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6)); diff --git a/ext/spl/tests/iterator_056.phpt b/ext/spl/tests/iterator_056.phpt index ec49e6b740df..28dd444856b9 100644 --- a/ext/spl/tests/iterator_056.phpt +++ b/ext/spl/tests/iterator_056.phpt @@ -6,7 +6,7 @@ Sebastian Schürmann getMessage(), "\n"; } try { - $it = new myCachingIterator(); + $it = new myCachingIterator(); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } try { - $it = new myRecursiveCachingIterator(); + $it = new myRecursiveCachingIterator(); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } try { - $it = new myParentIterator(); + $it = new myParentIterator(); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } try { - $it = new myLimitIterator(); + $it = new myLimitIterator(); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } try { - $it = new myNoRewindIterator(); + $it = new myNoRewindIterator(); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } diff --git a/ext/spl/tests/iterator_057.phpt b/ext/spl/tests/iterator_057.phpt index 61c1dfced617..e88e6a92b0ea 100644 --- a/ext/spl/tests/iterator_057.phpt +++ b/ext/spl/tests/iterator_057.phpt @@ -11,9 +11,9 @@ Sebastian Schürmann class myArrayIterator extends ArrayIterator { } try { - $it = new myArrayIterator(); + $it = new myArrayIterator(); } catch (InvalidArgumentException $e) { - echo 'InvalidArgumentException thrown'; + echo 'InvalidArgumentException thrown'; } echo 'no Exception thrown' ?> diff --git a/ext/spl/tests/iterator_058.phpt b/ext/spl/tests/iterator_058.phpt index 83d9d91feb60..ebe7a1ed2c16 100644 --- a/ext/spl/tests/iterator_058.phpt +++ b/ext/spl/tests/iterator_058.phpt @@ -6,17 +6,17 @@ Sebastian Schürmann diff --git a/ext/spl/tests/iterator_062.phpt b/ext/spl/tests/iterator_062.phpt index 3694cf19562d..30011343d2ec 100644 --- a/ext/spl/tests/iterator_062.phpt +++ b/ext/spl/tests/iterator_062.phpt @@ -9,9 +9,9 @@ class myRecursiveIteratorIterator extends RecursiveIteratorIterator { } try { - $it = new myRecursiveIteratorIterator(); + $it = new myRecursiveIteratorIterator(); } catch (InvalidArgumentException $e) { - echo 'InvalidArgumentException thrown'; + echo 'InvalidArgumentException thrown'; } ?> --EXPECT-- diff --git a/ext/spl/tests/iterator_067.phpt b/ext/spl/tests/iterator_067.phpt index e05a48d4e0d0..3c35bd06f782 100644 --- a/ext/spl/tests/iterator_067.phpt +++ b/ext/spl/tests/iterator_067.phpt @@ -6,10 +6,10 @@ Sebastian Schürmann --EXPECT-- diff --git a/ext/spl/tests/iterator_068.phpt b/ext/spl/tests/iterator_068.phpt index d44b219fa58c..00006a3b60fa 100644 --- a/ext/spl/tests/iterator_068.phpt +++ b/ext/spl/tests/iterator_068.phpt @@ -4,21 +4,21 @@ SPL: Iterator: Overloaded object and destruction foo(); - } + function __destruct() { + echo __METHOD__ . "()\n"; + $this->foo(); + } } $obj = new TestIteratorIterator(new Test); diff --git a/ext/spl/tests/iterator_071.phpt b/ext/spl/tests/iterator_071.phpt index 9f48f6ee1428..501771119ad7 100644 --- a/ext/spl/tests/iterator_071.phpt +++ b/ext/spl/tests/iterator_071.phpt @@ -11,7 +11,7 @@ $recArrIt = new RecursiveArrayIterator($arrOb->getIterator()); class MyRecursiveIteratorIterator extends RecursiveIteratorIterator { function nextelement() { - echo __METHOD__."\n"; + echo __METHOD__."\n"; } } diff --git a/ext/spl/tests/multiple_iterator_001.phpt b/ext/spl/tests/multiple_iterator_001.phpt index be7eeeac7e34..56a08da272dd 100644 --- a/ext/spl/tests/multiple_iterator_001.phpt +++ b/ext/spl/tests/multiple_iterator_001.phpt @@ -11,7 +11,7 @@ $m = new MultipleIterator(); echo "-- Default flags, no iterators --\n"; foreach($m as $value) { - var_dump($value); + var_dump($value); } var_dump($m->current()); @@ -24,17 +24,17 @@ echo "-- Default flags, MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_K var_dump($m->getFlags() === (MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC)); foreach($m as $key => $value) { - var_dump($key, $value); + var_dump($key, $value); } try { - $m->current(); + $m->current(); } catch(RuntimeException $e) { - echo "RuntimeException thrown: " . $e->getMessage() . "\n"; + echo "RuntimeException thrown: " . $e->getMessage() . "\n"; } try { - $m->key(); + $m->key(); } catch(RuntimeException $e) { - echo "RuntimeException thrown: " . $e->getMessage() . "\n"; + echo "RuntimeException thrown: " . $e->getMessage() . "\n"; } echo "-- Flags = MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC --\n"; @@ -43,7 +43,7 @@ $m->setFlags(MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC var_dump($m->getFlags() === (MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC)); foreach($m as $key => $value) { - var_dump($key, $value); + var_dump($key, $value); } echo "-- Default flags, added element --\n"; @@ -52,7 +52,7 @@ $m->setFlags(MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC $iter2[] = 3; foreach($m as $key => $value) { - var_dump($key, $value); + var_dump($key, $value); } echo "-- Flags |= MultipleIterator::MIT_KEYS_ASSOC, with iterator associated with NULL --\n"; @@ -60,9 +60,9 @@ echo "-- Flags |= MultipleIterator::MIT_KEYS_ASSOC, with iterator associated wit $m->setFlags(MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_ASSOC); $m->rewind(); try { - $m->current(); + $m->current(); } catch(InvalidArgumentException $e) { - echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n"; + echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n"; } echo "-- Flags |= MultipleIterator::MIT_KEYS_ASSOC --\n"; @@ -72,23 +72,23 @@ $m->attachIterator($iter2, "iter2"); $m->attachIterator($iter3, 3); foreach($m as $key => $value) { - var_dump($key, $value); + var_dump($key, $value); } echo "-- Associate with invalid value --\n"; try { - $m->attachIterator($iter3, new stdClass()); + $m->attachIterator($iter3, new stdClass()); } catch(InvalidArgumentException $e) { - echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n"; + echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n"; } echo "-- Associate with duplicate value --\n"; try { - $m->attachIterator($iter3, "iter1"); + $m->attachIterator($iter3, "iter1"); } catch(InvalidArgumentException $e) { - echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n"; + echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n"; } echo "-- Count, contains, detach, count, contains, iterate --\n"; @@ -99,7 +99,7 @@ var_dump($m->detachIterator($iter2)); var_dump($m->countIterators()); var_dump($m->containsIterator($iter2)); foreach($m as $key => $value) { - var_dump($key, $value); + var_dump($key, $value); } ?> diff --git a/ext/spl/tests/observer_001.phpt b/ext/spl/tests/observer_001.phpt index 05fe361dce31..72feb08a40cd 100644 --- a/ext/spl/tests/observer_001.phpt +++ b/ext/spl/tests/observer_001.phpt @@ -5,66 +5,66 @@ SPL: SplObserver and SplSubject (empty notify) class ObserverImpl implements SplObserver { - protected $name = ''; - - function __construct($name = 'obj') - { - $this->name = '$' . $name; - } - - function update(SplSubject $subject) - { - echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n"; - } - - function getName() - { - return $this->name; - } + protected $name = ''; + + function __construct($name = 'obj') + { + $this->name = '$' . $name; + } + + function update(SplSubject $subject) + { + echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n"; + } + + function getName() + { + return $this->name; + } } class SubjectImpl implements SplSubject { - protected $name = ''; - protected $observers = array(); + protected $name = ''; + protected $observers = array(); - function __construct($name = 'sub') - { - $this->name = '$' . $name; - } + function __construct($name = 'sub') + { + $this->name = '$' . $name; + } function attach(SplObserver $observer) { - echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - if (!in_array($observer, $this->observers)) - { - $this->observers[] = $observer; - } + echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; + if (!in_array($observer, $this->observers)) + { + $this->observers[] = $observer; + } } function detach(SplObserver $observer) { - echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - $idx = array_search($observer, $this->observers); - if ($idx !== false) - { - unset($this->observers[$idx]); - } + echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n"; + $idx = array_search($observer, $this->observers); + if ($idx !== false) + { + unset($this->observers[$idx]); + } } function notify() { - echo '$sub->' . __METHOD__ . "();\n"; - foreach($this->observers as $observer) - { - $observer->update($this); - } + echo '$sub->' . __METHOD__ . "();\n"; + foreach($this->observers as $observer) + { + $observer->update($this); + } } - function getName() - { - return $this->name; - } + function getName() + { + return $this->name; + } } $sub = new SubjectImpl; diff --git a/ext/spl/tests/observer_002.phpt b/ext/spl/tests/observer_002.phpt index 3d5b31d4831a..2642c28bd57c 100644 --- a/ext/spl/tests/observer_002.phpt +++ b/ext/spl/tests/observer_002.phpt @@ -5,103 +5,103 @@ SPL: SplObjectStorage class MyObjectStorage extends SplObjectStorage { - function rewind() - { - echo __METHOD__ . "()\n"; - parent::rewind(); - } - - function valid() - { - echo __METHOD__ . "(" . (parent::valid() ? 1 : 0) . ")\n"; - return parent::valid(); - } - - function key() - { - echo __METHOD__ . "(" . parent::key() . ")\n"; - return parent::key(); - } - - function current() - { - echo __METHOD__ . "(" . parent::current()->getName() . ")\n"; - return parent::current(); - } - - function next() - { - echo __METHOD__ . "()\n"; - parent::next(); - } + function rewind() + { + echo __METHOD__ . "()\n"; + parent::rewind(); + } + + function valid() + { + echo __METHOD__ . "(" . (parent::valid() ? 1 : 0) . ")\n"; + return parent::valid(); + } + + function key() + { + echo __METHOD__ . "(" . parent::key() . ")\n"; + return parent::key(); + } + + function current() + { + echo __METHOD__ . "(" . parent::current()->getName() . ")\n"; + return parent::current(); + } + + function next() + { + echo __METHOD__ . "()\n"; + parent::next(); + } } class ObserverImpl implements SplObserver { - protected $name = ''; - - function __construct($name = 'obj') - { - $this->name = '$' . $name; - } - - function update(SplSubject $subject) - { - echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n"; - } - - function getName() - { - return $this->name; - } + protected $name = ''; + + function __construct($name = 'obj') + { + $this->name = '$' . $name; + } + + function update(SplSubject $subject) + { + echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n"; + } + + function getName() + { + return $this->name; + } } class SubjectImpl implements SplSubject { - protected $name = ''; - protected $observers; - - function __construct($name = 'sub') - { - $this->observers = new MyObjectStorage; - $this->name = '$' . $name; - } - - function attach(SplObserver $observer) - { - echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - $this->observers->attach($observer); - } - - function detach(SplObserver $observer) - { - echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; - $this->observers->detach($observer); - } - - function count() - { - return $this->observers->count(); - } - - function notify() - { - echo $this->name . '->' . __METHOD__ . "();\n"; - foreach($this->observers as $key => $observer) - { - $observer->update($this); - } - } - - function getName() - { - return $this->name; - } - - function contains($obj) - { - return $this->observers->contains($obj); - } + protected $name = ''; + protected $observers; + + function __construct($name = 'sub') + { + $this->observers = new MyObjectStorage; + $this->name = '$' . $name; + } + + function attach(SplObserver $observer) + { + echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; + $this->observers->attach($observer); + } + + function detach(SplObserver $observer) + { + echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n"; + $this->observers->detach($observer); + } + + function count() + { + return $this->observers->count(); + } + + function notify() + { + echo $this->name . '->' . __METHOD__ . "();\n"; + foreach($this->observers as $key => $observer) + { + $observer->update($this); + } + } + + function getName() + { + return $this->name; + } + + function contains($obj) + { + return $this->observers->contains($obj); + } } $sub = new SubjectImpl; diff --git a/ext/spl/tests/observer_003.phpt b/ext/spl/tests/observer_003.phpt index 185421054478..36ead9233658 100644 --- a/ext/spl/tests/observer_003.phpt +++ b/ext/spl/tests/observer_003.phpt @@ -5,12 +5,12 @@ SPL: SplObjectStorage serialization class TestClass { - public $test = 25; + public $test = 25; - public function __construct($test = 42) - { - $this->test = $test; - } + public function __construct($test = 42) + { + $this->test = $test; + } } $storage = new SplObjectStorage(); @@ -24,7 +24,7 @@ var_dump(count($storage)); foreach($storage as $object) { - var_dump($object->test); + var_dump($object->test); } var_dump(serialize($storage)); @@ -36,7 +36,7 @@ var_dump(count($storage2)); foreach($storage2 as $object) { - var_dump($object->test); + var_dump($object->test); } ?> diff --git a/ext/spl/tests/observer_004.phpt b/ext/spl/tests/observer_004.phpt index be09734f8081..7da7f1a651c7 100644 --- a/ext/spl/tests/observer_004.phpt +++ b/ext/spl/tests/observer_004.phpt @@ -5,22 +5,22 @@ SPL: SplObjectStorage serialization & overloading class TestClass { - public $test = 25; + public $test = 25; - public function __construct($test = 42) - { - $this->test = $test; - } + public function __construct($test = 42) + { + $this->test = $test; + } } class MyStorage extends SplObjectStorage { - public $bla = 25; + public $bla = 25; - public function __construct($bla = 26) - { - $this->bla = $bla; - } + public function __construct($bla = 26) + { + $this->bla = $bla; + } } $storage = new MyStorage(); @@ -34,7 +34,7 @@ var_dump(count($storage)); foreach($storage as $object) { - var_dump($object->test); + var_dump($object->test); } var_dump($storage); @@ -48,7 +48,7 @@ var_dump(count($storage2)); foreach($storage2 as $object) { - var_dump($object->test); + var_dump($object->test); } var_dump($storage2); diff --git a/ext/spl/tests/observer_005.phpt b/ext/spl/tests/observer_005.phpt index cf5db3bfdac5..57f632cfbc7e 100644 --- a/ext/spl/tests/observer_005.phpt +++ b/ext/spl/tests/observer_005.phpt @@ -5,17 +5,17 @@ SPL: SplObjectStorage serialization & visibility class TestClass { - public $def = 24; - public $pub = 25; - protected $pro = 26; - private $pri = 27; - - public function __construct($pub = 42, $pro = 43, $pri = 44) - { - $this->pub = $pub; - $this->pro = $pro; - $this->pri = $pri; - } + public $def = 24; + public $pub = 25; + protected $pro = 26; + private $pri = 27; + + public function __construct($pub = 42, $pro = 43, $pri = 44) + { + $this->pub = $pub; + $this->pro = $pro; + $this->pri = $pri; + } } class ExtTestClass @@ -24,17 +24,17 @@ class ExtTestClass class MyStorage extends SplObjectStorage { - public $def = 24; - public $pub = 25; - protected $pro = 26; - private $pri = 27; - - public function __construct($pub = 52, $pro = 53, $pri = 54) - { - $this->pub = $pub; - $this->pro = $pro; - $this->pri = $pri; - } + public $def = 24; + public $pub = 25; + protected $pro = 26; + private $pri = 27; + + public function __construct($pub = 52, $pro = 53, $pri = 54) + { + $this->pub = $pub; + $this->pro = $pro; + $this->pri = $pri; + } } class ExtStorage extends MyStorage @@ -52,7 +52,7 @@ var_dump(count($storage)); foreach($storage as $object) { - var_dump($object); + var_dump($object); } var_dump($storage); @@ -66,7 +66,7 @@ var_dump(count($storage2)); foreach($storage2 as $object) { - var_dump($object); + var_dump($object); } var_dump($storage2); diff --git a/ext/spl/tests/observer_006.phpt b/ext/spl/tests/observer_006.phpt index 89a3dabdbb97..e130f469ada4 100644 --- a/ext/spl/tests/observer_006.phpt +++ b/ext/spl/tests/observer_006.phpt @@ -5,22 +5,22 @@ SPL: SplObjectStorage with accociatied information class TestClass { - public $test = 25; + public $test = 25; - public function __construct($test = 42) - { - $this->test = $test; - } + public function __construct($test = 42) + { + $this->test = $test; + } } class MyStorage extends SplObjectStorage { - public $bla = 25; + public $bla = 25; - public function __construct($bla = 26) - { - $this->bla = $bla; - } + public function __construct($bla = 26) + { + $this->bla = $bla; + } } $storage = new MyStorage(); @@ -34,7 +34,7 @@ var_dump(count($storage)); foreach($storage as $object) { - var_dump($object->test); + var_dump($object->test); } var_dump($storage); @@ -48,7 +48,7 @@ var_dump(count($storage2)); foreach($storage2 as $object) { - var_dump($object->test); + var_dump($object->test); } var_dump($storage2); diff --git a/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt index cac0e2c4790f..e8b71ebb0d68 100644 --- a/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt +++ b/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt @@ -11,7 +11,7 @@ $recArrIt = new RecursiveArrayIterator($arrOb->getIterator()); class MyRecursiveIteratorIterator extends RecursiveIteratorIterator { function beginchildren() { - throw new Exception; + throw new Exception; } } diff --git a/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt index 1961517253d2..df669375251e 100644 --- a/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt +++ b/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt @@ -11,7 +11,7 @@ $recArrIt = new RecursiveArrayIterator($arrOb->getIterator()); class MyRecursiveIteratorIterator extends RecursiveIteratorIterator { function callHasChildren() { - throw new Exception; + throw new Exception; } } diff --git a/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt index 941f92be822c..7bd08d444f57 100644 --- a/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt +++ b/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt @@ -11,7 +11,7 @@ $recArrIt = new RecursiveArrayIterator($arrOb->getIterator()); class MyRecursiveIteratorIterator extends RecursiveIteratorIterator { function endchildren() { - throw new Exception; + throw new Exception; } } diff --git a/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt b/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt index dd4f038710dc..bd084f54e6f7 100644 --- a/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt +++ b/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt @@ -11,7 +11,7 @@ $recArrIt = new RecursiveArrayIterator($arrOb->getIterator()); class MyRecursiveIteratorIterator extends RecursiveIteratorIterator { function nextelement() { - throw new Exception; + throw new Exception; } } diff --git a/ext/spl/tests/recursive_tree_iterator_001.phpt b/ext/spl/tests/recursive_tree_iterator_001.phpt index 693593f85a63..c3172a58b720 100644 --- a/ext/spl/tests/recursive_tree_iterator_001.phpt +++ b/ext/spl/tests/recursive_tree_iterator_001.phpt @@ -4,44 +4,44 @@ SPL: RecursiveTreeIterator array( - "a", - 1, - ), - "a" => array( - 2, - "b", - 3 => array( - 4, - "c", - ), - "3" => array( - 4, - "c", - ), - ), + 0 => array( + "a", + 1, + ), + "a" => array( + 2, + "b", + 3 => array( + 4, + "c", + ), + "3" => array( + 4, + "c", + ), + ), ); $it = new RecursiveArrayIterator($ary); echo "-- flags = BYPASS_KEY --\n"; foreach(new RecursiveTreeIterator($it) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = BYPASS_CURRENT --\n"; foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = BYPASS_KEY|BYPASS_KEY --\n"; foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT|RecursiveTreeIterator::BYPASS_KEY) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = 0 --\n"; foreach(new RecursiveTreeIterator($it, 0) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --\n"; foreach(new RecursiveTreeIterator($it, 0, CachingIterator::CATCH_GET_CHILD) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } ?> diff --git a/ext/spl/tests/recursive_tree_iterator_002.phpt b/ext/spl/tests/recursive_tree_iterator_002.phpt index a67e3d1c7728..e32b3bd00ef1 100644 --- a/ext/spl/tests/recursive_tree_iterator_002.phpt +++ b/ext/spl/tests/recursive_tree_iterator_002.phpt @@ -5,9 +5,9 @@ error_reporting=E_ALL&~E_NOTICE --FILE-- --EXPECT-- diff --git a/ext/spl/tests/recursive_tree_iterator_003.phpt b/ext/spl/tests/recursive_tree_iterator_003.phpt index 84eef88d2fc7..c87f942f0d46 100644 --- a/ext/spl/tests/recursive_tree_iterator_003.phpt +++ b/ext/spl/tests/recursive_tree_iterator_003.phpt @@ -3,7 +3,7 @@ SPL: RecursiveTreeIterator(non-traversable) --FILE-- getMessage(), "\n"; } diff --git a/ext/spl/tests/recursive_tree_iterator_004.phpt b/ext/spl/tests/recursive_tree_iterator_004.phpt index 47ba4e880eef..28fe8e05f235 100644 --- a/ext/spl/tests/recursive_tree_iterator_004.phpt +++ b/ext/spl/tests/recursive_tree_iterator_004.phpt @@ -6,27 +6,27 @@ error_reporting=E_ALL&~E_NOTICE array( - "a", - 1, - ), - "a" => array( - 2, - "b", - 3 => array( - 4, - "c", - ), - "3" => array( - 4, - "c", - ), - ), + 0 => array( + "a", + 1, + ), + "a" => array( + 2, + "b", + 3 => array( + 4, + "c", + ), + "3" => array( + 4, + "c", + ), + ), ); $it = new RecursiveTreeIterator(new RecursiveArrayIterator($ary)); foreach($it as $k => $v) { - echo '[' . $it->key() . '] => ' . $it->getPrefix() . $it->getEntry() . $it->getPostfix() . "\n"; + echo '[' . $it->key() . '] => ' . $it->getPrefix() . $it->getEntry() . $it->getPostfix() . "\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/recursive_tree_iterator_005.phpt b/ext/spl/tests/recursive_tree_iterator_005.phpt index 2b42267b44b8..a63b26685c56 100644 --- a/ext/spl/tests/recursive_tree_iterator_005.phpt +++ b/ext/spl/tests/recursive_tree_iterator_005.phpt @@ -6,37 +6,37 @@ error_reporting=E_ALL&~E_NOTICE array( - (binary) "binary", - "abc2", - 1, - ), - (binary) "binary" => array( - 2, - "b", - 3 => array( - 4, - "c", - ), - "4abc" => array( - 4, - "c", - ), - ), + 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); + var_dump($v); } echo "\n----------------\n\n"; foreach($it as $k => $v) { - var_dump($k); + 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()); + var_dump($it->key(), $it->getEntry(), $it->current()); } ?> --EXPECT-- diff --git a/ext/spl/tests/recursive_tree_iterator_006.phpt b/ext/spl/tests/recursive_tree_iterator_006.phpt index 96ef815a6019..ba7158639607 100644 --- a/ext/spl/tests/recursive_tree_iterator_006.phpt +++ b/ext/spl/tests/recursive_tree_iterator_006.phpt @@ -4,54 +4,54 @@ SPL: RecursiveTreeIterator and IteratorAggregate array( - "a", - 1, - ), - "a" => array( - 2, - "b", - 3 => array( - 4, - "c", - ), - "3" => array( - 4, - "c", - ), - ), + 0 => array( + "a", + 1, + ), + "a" => array( + 2, + "b", + 3 => array( + 4, + "c", + ), + "3" => array( + 4, + "c", + ), + ), ); class RecursiveArrayIteratorAggregated implements IteratorAggregate { - public $it; - function __construct($it) { - $this->it = new RecursiveArrayIterator($it); - } - function getIterator() { - return $this->it; - } + public $it; + function __construct($it) { + $this->it = new RecursiveArrayIterator($it); + } + function getIterator() { + return $this->it; + } } $it = new RecursiveArrayIteratorAggregated($ary); echo "-- flags = BYPASS_KEY --\n"; foreach(new RecursiveTreeIterator($it) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = BYPASS_CURRENT --\n"; foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = BYPASS_KEY|BYPASS_KEY --\n"; foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT|RecursiveTreeIterator::BYPASS_KEY) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = 0 --\n"; foreach(new RecursiveTreeIterator($it, 0) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --\n"; foreach(new RecursiveTreeIterator($it, 0, CachingIterator::CATCH_GET_CHILD) as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } ?> diff --git a/ext/spl/tests/recursive_tree_iterator_007.phpt b/ext/spl/tests/recursive_tree_iterator_007.phpt index fc60d7038393..196f6a1d90d1 100644 --- a/ext/spl/tests/recursive_tree_iterator_007.phpt +++ b/ext/spl/tests/recursive_tree_iterator_007.phpt @@ -8,22 +8,22 @@ error_reporting=E_ALL&~E_NOTICE $ary = array(new stdClass); class RecursiveArrayIteratorAggregated implements IteratorAggregate { - public $it; - function __construct($it) { - $this->it = new RecursiveArrayIterator($it); - } - function getIterator() { - return $this->it; - } + public $it; + function __construct($it) { + $this->it = new RecursiveArrayIterator($it); + } + function getIterator() { + return $this->it; + } } $it = new RecursiveArrayIteratorAggregated($ary); try { - foreach(new RecursiveTreeIterator($it) as $k => $v) { - echo "[$k] => $v\n"; - } + foreach(new RecursiveTreeIterator($it) as $k => $v) { + echo "[$k] => $v\n"; + } } catch (Error $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } ?> diff --git a/ext/spl/tests/recursive_tree_iterator_008.phpt b/ext/spl/tests/recursive_tree_iterator_008.phpt index 5a522ef65f2c..fbdc3a5cb179 100644 --- a/ext/spl/tests/recursive_tree_iterator_008.phpt +++ b/ext/spl/tests/recursive_tree_iterator_008.phpt @@ -6,28 +6,28 @@ error_reporting=E_ALL&~E_NOTICE array("b"), - "c" => array("d"), + "a" => array("b"), + "c" => array("d"), ); $it = new RecursiveArrayIterator($ary); $it = new RecursiveTreeIterator($it); for($i = 0; $i < 6; ++$i) { - $it->setPrefixPart($i, $i); + $it->setPrefixPart($i, $i); } foreach($it as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } try { - $it->setPrefixPart(-1, ""); - $it->setPrefixPart(6, ""); + $it->setPrefixPart(-1, ""); + $it->setPrefixPart(6, ""); } catch (OutOfRangeException $e) { - echo "OutOfRangeException thrown\n"; + echo "OutOfRangeException thrown\n"; } try { - $it->setPrefixPart(6, ""); + $it->setPrefixPart(6, ""); } catch (OutOfRangeException $e) { - echo "OutOfRangeException thrown\n"; + echo "OutOfRangeException thrown\n"; } ?> --EXPECT-- diff --git a/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt b/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt index 8b39c32d5411..eea4da795aca 100644 --- a/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt +++ b/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt @@ -6,22 +6,22 @@ Joshua Thijssen (jthijssen@noxlogic.nl) array( - "a", - 1, - ), - "a" => array( - 2, - "b", - 3 => array( - 4, - "c", - ), - "3" => array( - 4, - "c", - ), - ), + 0 => array( + "a", + 1, + ), + "a" => array( + 2, + "b", + 3 => array( + 4, + "c", + ), + "3" => array( + 4, + "c", + ), + ), ); $it = new RecursiveArrayIterator($arr); @@ -38,7 +38,7 @@ echo "\n\n"; echo "----\n"; foreach($it as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } echo "----\n"; @@ -48,7 +48,7 @@ echo "\n\n"; echo "----\n"; foreach($it as $k => $v) { - echo "[$k] => $v\n"; + echo "[$k] => $v\n"; } diff --git a/ext/spl/tests/recursivecomparedualiterator.inc b/ext/spl/tests/recursivecomparedualiterator.inc index 5b63e9f0b3ef..ad0657b9bdb7 100644 --- a/ext/spl/tests/recursivecomparedualiterator.inc +++ b/ext/spl/tests/recursivecomparedualiterator.inc @@ -16,54 +16,54 @@ */ class RecursiveCompareDualIterator extends RecursiveIteratorIterator { - /** Used to keep end of recursion equality. That is en leaving a nesting - * level we need to check whether both child iterators are at their end. - */ - protected $equal = false; + /** Used to keep end of recursion equality. That is en leaving a nesting + * level we need to check whether both child iterators are at their end. + */ + protected $equal = false; - /** Construct from RecursiveDualIterator - * - * @param $it RecursiveDualIterator - * @param $mode should be LEAVES_ONLY - * @param $flags should be 0 - */ - function __construct(RecursiveDualIterator $it, $mode = self::LEAVES_ONLY, $flags = 0) - { - parent::__construct($it); - } + /** Construct from RecursiveDualIterator + * + * @param $it RecursiveDualIterator + * @param $mode should be LEAVES_ONLY + * @param $flags should be 0 + */ + function __construct(RecursiveDualIterator $it, $mode = self::LEAVES_ONLY, $flags = 0) + { + parent::__construct($it); + } - /** Rewind iteration andcomparison process. Starting with $equal = true. - */ - function rewind() - { - $this->equal = true; - parent::rewind(); - } + /** Rewind iteration andcomparison process. Starting with $equal = true. + */ + function rewind() + { + $this->equal = true; + parent::rewind(); + } - /** Calculate $equal - * @see $equal - */ - function endChildren() - { - $this->equal &= !$this->getInnerIterator()->getLHS()->valid() - && !$this->getInnerIterator()->getRHS()->valid(); - } + /** Calculate $equal + * @see $equal + */ + function endChildren() + { + $this->equal &= !$this->getInnerIterator()->getLHS()->valid() + && !$this->getInnerIterator()->getRHS()->valid(); + } - /** @return whether both inner iterators are valid and have identical - * current and key values or both are non valid. - */ - function areIdentical() - { - return $this->equal && $this->getInnerIterator()->areIdentical(); - } + /** @return whether both inner iterators are valid and have identical + * current and key values or both are non valid. + */ + function areIdentical() + { + return $this->equal && $this->getInnerIterator()->areIdentical(); + } - /** @return whether both inner iterators are valid and have equal current - * and key values or both are non valid. - */ - function areEqual() - { - return $this->equal && $this->getInnerIterator()->areEqual(); - } + /** @return whether both inner iterators are valid and have equal current + * and key values or both are non valid. + */ + function areEqual() + { + return $this->equal && $this->getInnerIterator()->areEqual(); + } } ?> diff --git a/ext/spl/tests/recursivedualiterator.inc b/ext/spl/tests/recursivedualiterator.inc index a56984e0832c..45abf4c8f455 100644 --- a/ext/spl/tests/recursivedualiterator.inc +++ b/ext/spl/tests/recursivedualiterator.inc @@ -16,57 +16,57 @@ */ class RecursiveDualIterator extends DualIterator implements RecursiveIterator { - private $ref; + private $ref; - /** construct iterator from two RecursiveIterator instances - * - * @param lhs Left Hand Side Iterator - * @param rhs Right Hand Side Iterator - * @param flags iteration flags - */ - function __construct(RecursiveIterator $lhs, RecursiveIterator $rhs, - $flags = 0x33 /*DualIterator::DEFAULT_FLAGS*/) - { - parent::__construct($lhs, $rhs, $flags); - } + /** construct iterator from two RecursiveIterator instances + * + * @param lhs Left Hand Side Iterator + * @param rhs Right Hand Side Iterator + * @param flags iteration flags + */ + function __construct(RecursiveIterator $lhs, RecursiveIterator $rhs, + $flags = 0x33 /*DualIterator::DEFAULT_FLAGS*/) + { + parent::__construct($lhs, $rhs, $flags); + } - /** @return whether both LHS and RHS have children - */ - function hasChildren() - { - return $this->getLHS()->hasChildren() && $this->getRHS()->hasChildren(); - } + /** @return whether both LHS and RHS have children + */ + function hasChildren() + { + return $this->getLHS()->hasChildren() && $this->getRHS()->hasChildren(); + } - /** @return new RecursiveDualIterator (late binding) for the two inner - * iterators current children. - */ - function getChildren() - { - if (empty($this->ref)) - { - $this->ref = new ReflectionClass($this); - } - return $this->ref->newInstance( - $this->getLHS()->getChildren(), $this->getRHS()->getChildren(), $this->getFlags()); - } + /** @return new RecursiveDualIterator (late binding) for the two inner + * iterators current children. + */ + function getChildren() + { + if (empty($this->ref)) + { + $this->ref = new ReflectionClass($this); + } + return $this->ref->newInstance( + $this->getLHS()->getChildren(), $this->getRHS()->getChildren(), $this->getFlags()); + } - /** @return whether both inner iterators are valid, have same hasChildren() - * state and identical current and key values or both are non valid. - */ - function areIdentical() - { - return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren() - && parent::areIdentical(); - } + /** @return whether both inner iterators are valid, have same hasChildren() + * state and identical current and key values or both are non valid. + */ + function areIdentical() + { + return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren() + && parent::areIdentical(); + } - /** @return whether both inner iterators are valid, have same hasChildren() - * state and equal current and key values or both are invalid. - */ - function areEqual() - { - return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren() - && parent::areEqual(); - } + /** @return whether both inner iterators are valid, have same hasChildren() + * state and equal current and key values or both are invalid. + */ + function areEqual() + { + return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren() + && parent::areEqual(); + } } ?> diff --git a/ext/spl/tests/regexIterator_setMode_error.phpt b/ext/spl/tests/regexIterator_setMode_error.phpt index 046086102be5..4816896d8a46 100644 --- a/ext/spl/tests/regexIterator_setMode_error.phpt +++ b/ext/spl/tests/regexIterator_setMode_error.phpt @@ -11,10 +11,10 @@ $regexIterator = new RegexIterator(new ArrayIterator($array), "/f/"); var_dump($regexIterator->getMode()); try { - $regexIterator->setMode(7); + $regexIterator->setMode(7); } catch (InvalidArgumentException $e) { - var_dump($e->getMessage()); - var_dump($e->getCode()); + var_dump($e->getMessage()); + var_dump($e->getCode()); } ?> diff --git a/ext/spl/tests/spl_001.phpt b/ext/spl/tests/spl_001.phpt index 98eec24ded1d..4fc0be3d0ca2 100644 --- a/ext/spl/tests/spl_001.phpt +++ b/ext/spl/tests/spl_001.phpt @@ -13,7 +13,7 @@ print_r($ar); foreach($ar as $v) { - var_dump($v); + var_dump($v); } ?> diff --git a/ext/spl/tests/spl_002.phpt b/ext/spl/tests/spl_002.phpt index e8e9424a219c..5442b1991d77 100644 --- a/ext/spl/tests/spl_002.phpt +++ b/ext/spl/tests/spl_002.phpt @@ -5,10 +5,10 @@ SPL: Countable class Test implements Countable { - function count() - { - return 4; - } + function count() + { + return 4; + } }; $a = new Test; diff --git a/ext/spl/tests/spl_004.phpt b/ext/spl/tests/spl_004.phpt index 7563f28001ad..570b4ae226c2 100644 --- a/ext/spl/tests/spl_004.phpt +++ b/ext/spl/tests/spl_004.phpt @@ -4,30 +4,30 @@ SPL: iterator_apply() key()); - var_dump($arg->current()); - } - else - { - var_dump($arg); - } - return true; + if ($arg instanceof Iterator) + { + var_dump($arg->key()); + var_dump($arg->current()); + } + else + { + var_dump($arg); + } + return true; } function test() { - static $arg = 0; - var_dump($arg++); - return true; + static $arg = 0; + var_dump($arg++); + return true; } $it = new RecursiveArrayIterator(array(1, array(21, 22), 3)); @@ -43,7 +43,7 @@ var_dump(iterator_apply($it, 'test')); echo "===ERRORS===\n"; try { - var_dump(iterator_apply($it, 'test', 1)); + var_dump(iterator_apply($it, 'test', 1)); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } diff --git a/ext/spl/tests/spl_autoload_001.phpt b/ext/spl/tests/spl_autoload_001.phpt index 8801d138334d..6025ac653833 100644 --- a/ext/spl/tests/spl_autoload_001.phpt +++ b/ext/spl/tests/spl_autoload_001.phpt @@ -17,7 +17,7 @@ if (!class_exists("TestClass")) { $test_exts = array(NULL, "1", ".inc,,.php.inc", ""); foreach($test_exts as $exts) { - echo "===($exts)===\n"; + echo "===($exts)===\n"; spl_autoload("TestClass", $exts); if (!class_exists("TestClass")) { echo "Class TestClass could not be loaded\n"; @@ -32,12 +32,12 @@ if (!class_exists("TestClass")) { function TestFunc1($classname) { - echo __METHOD__ . "($classname)\n"; + echo __METHOD__ . "($classname)\n"; } function TestFunc2($classname) { - echo __METHOD__ . "($classname)\n"; + echo __METHOD__ . "($classname)\n"; } echo "===SPL_AUTOLOAD()===\n"; @@ -66,11 +66,11 @@ echo "===NOFUNCTION===\n"; try { - spl_autoload_register("unavailable_autoload_function"); + spl_autoload_register("unavailable_autoload_function"); } catch(Exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/spl_autoload_003.phpt b/ext/spl/tests/spl_autoload_003.phpt index e9af346814e6..016bcf2394b6 100644 --- a/ext/spl/tests/spl_autoload_003.phpt +++ b/ext/spl/tests/spl_autoload_003.phpt @@ -7,18 +7,18 @@ include_path=. function TestFunc1($classname) { - echo __METHOD__ . "($classname)\n"; + echo __METHOD__ . "($classname)\n"; } function TestFunc2($classname) { - echo __METHOD__ . "($classname)\n"; - throw new Exception("Class $classname missing"); + echo __METHOD__ . "($classname)\n"; + throw new Exception("Class $classname missing"); } function TestFunc3($classname) { - echo __METHOD__ . "($classname)\n"; + echo __METHOD__ . "($classname)\n"; } spl_autoload_register("TestFunc1"); @@ -27,11 +27,11 @@ spl_autoload_register("TestFunc3"); try { - var_dump(class_exists("TestClass", true)); + var_dump(class_exists("TestClass", true)); } catch(Exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/spl_autoload_004.phpt b/ext/spl/tests/spl_autoload_004.phpt index 800112e262c0..8e1eafc37a5d 100644 --- a/ext/spl/tests/spl_autoload_004.phpt +++ b/ext/spl/tests/spl_autoload_004.phpt @@ -8,7 +8,7 @@ include_path=. class MyAutoLoader { static function autoLoad($className) { - echo __METHOD__ . "($className)\n"; + echo __METHOD__ . "($className)\n"; } } diff --git a/ext/spl/tests/spl_autoload_005.phpt b/ext/spl/tests/spl_autoload_005.phpt index 7e060494b36b..53fbf27663fe 100644 --- a/ext/spl/tests/spl_autoload_005.phpt +++ b/ext/spl/tests/spl_autoload_005.phpt @@ -9,23 +9,23 @@ class MyAutoLoader { function autoLoad($className) { - echo __METHOD__ . "($className)\n"; + echo __METHOD__ . "($className)\n"; } function autoThrow($className) { - echo __METHOD__ . "($className)\n"; - throw new Exception("Unavailable"); + echo __METHOD__ . "($className)\n"; + throw new Exception("Unavailable"); } } try { - spl_autoload_register(array('MyAutoLoader', 'autoLoad'), true); + spl_autoload_register(array('MyAutoLoader', 'autoLoad'), true); } catch(Exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } // and @@ -37,11 +37,11 @@ spl_autoload_register(array($myAutoLoader, 'autoThrow')); try { - var_dump(class_exists("TestClass", true)); + var_dump(class_exists("TestClass", true)); } catch(Exception $e) { - echo 'Exception: ' . $e->getMessage() . "\n"; + echo 'Exception: ' . $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/spl_autoload_006.phpt b/ext/spl/tests/spl_autoload_006.phpt index 5c0505cfe3b8..7db2b462ca36 100644 --- a/ext/spl/tests/spl_autoload_006.phpt +++ b/ext/spl/tests/spl_autoload_006.phpt @@ -8,7 +8,7 @@ include_path=. class MyAutoLoader { static function autoLoad($className) { - echo __METHOD__ . "($className)\n"; + echo __METHOD__ . "($className)\n"; } } diff --git a/ext/spl/tests/spl_autoload_007.phpt b/ext/spl/tests/spl_autoload_007.phpt index 44c5eb5fc301..db5f394260f3 100644 --- a/ext/spl/tests/spl_autoload_007.phpt +++ b/ext/spl/tests/spl_autoload_007.phpt @@ -8,48 +8,48 @@ include_path=. class MyAutoLoader { static protected function noAccess($className) { - echo __METHOD__ . "($className)\n"; + echo __METHOD__ . "($className)\n"; } static function autoLoad($className) { - echo __METHOD__ . "($className)\n"; + echo __METHOD__ . "($className)\n"; } function dynaLoad($className) { - echo __METHOD__ . "($className)\n"; + echo __METHOD__ . "($className)\n"; } } $obj = new MyAutoLoader; $funcs = array( - 'MyAutoLoader::notExist', - 'MyAutoLoader::noAccess', - 'MyAutoLoader::autoLoad', - 'MyAutoLoader::dynaLoad', - array('MyAutoLoader', 'notExist'), - array('MyAutoLoader', 'noAccess'), - array('MyAutoLoader', 'autoLoad'), - array('MyAutoLoader', 'dynaLoad'), - array($obj, 'notExist'), - array($obj, 'noAccess'), - array($obj, 'autoLoad'), - array($obj, 'dynaLoad'), + 'MyAutoLoader::notExist', + 'MyAutoLoader::noAccess', + 'MyAutoLoader::autoLoad', + 'MyAutoLoader::dynaLoad', + array('MyAutoLoader', 'notExist'), + array('MyAutoLoader', 'noAccess'), + array('MyAutoLoader', 'autoLoad'), + array('MyAutoLoader', 'dynaLoad'), + array($obj, 'notExist'), + array($obj, 'noAccess'), + array($obj, 'autoLoad'), + array($obj, 'dynaLoad'), ); foreach($funcs as $idx => $func) { - if ($idx) echo "\n"; - try - { - var_dump($func); - spl_autoload_register($func); - echo "ok\n"; - } - catch (Exception $e) - { - echo $e->getMessage() . "\n"; - } + if ($idx) echo "\n"; + try + { + var_dump($func); + spl_autoload_register($func); + echo "ok\n"; + } + catch (Exception $e) + { + echo $e->getMessage() . "\n"; + } } ?> diff --git a/ext/spl/tests/spl_autoload_008.phpt b/ext/spl/tests/spl_autoload_008.phpt index 85718014dd2c..eadc861ca16a 100644 --- a/ext/spl/tests/spl_autoload_008.phpt +++ b/ext/spl/tests/spl_autoload_008.phpt @@ -7,59 +7,59 @@ include_path=. function MyAutoLoad($className) { - echo __METHOD__ . "($className)\n"; - throw new Exception('Bla'); + echo __METHOD__ . "($className)\n"; + throw new Exception('Bla'); } class MyAutoLoader { - static function autoLoad($className) - { - echo __METHOD__ . "($className)\n"; - throw new Exception('Bla'); - } + static function autoLoad($className) + { + echo __METHOD__ . "($className)\n"; + throw new Exception('Bla'); + } - function dynaLoad($className) - { - echo __METHOD__ . "($className)\n"; - throw new Exception('Bla'); - } + function dynaLoad($className) + { + echo __METHOD__ . "($className)\n"; + throw new Exception('Bla'); + } } $obj = new MyAutoLoader; $funcs = array( - 'MyAutoLoad', - 'MyAutoLoader::autoLoad', - 'MyAutoLoader::dynaLoad', - array('MyAutoLoader', 'autoLoad'), - array('MyAutoLoader', 'dynaLoad'), - array($obj, 'autoLoad'), - array($obj, 'dynaLoad'), + 'MyAutoLoad', + 'MyAutoLoader::autoLoad', + 'MyAutoLoader::dynaLoad', + array('MyAutoLoader', 'autoLoad'), + array('MyAutoLoader', 'dynaLoad'), + array($obj, 'autoLoad'), + array($obj, 'dynaLoad'), ); foreach($funcs as $idx => $func) { - echo "====$idx====\n"; + echo "====$idx====\n"; - try - { - var_dump($func); - spl_autoload_register($func); - if (count(spl_autoload_functions())) - { - echo "registered\n"; + try + { + var_dump($func); + spl_autoload_register($func); + if (count(spl_autoload_functions())) + { + echo "registered\n"; - var_dump(class_exists("NoExistingTestClass", true)); - } - } - catch (Exception $e) - { - echo get_class($e) . ": " . $e->getMessage() . "\n"; - } + var_dump(class_exists("NoExistingTestClass", true)); + } + } + catch (Exception $e) + { + echo get_class($e) . ": " . $e->getMessage() . "\n"; + } - spl_autoload_unregister($func); - var_dump(count(spl_autoload_functions())); + spl_autoload_unregister($func); + var_dump(count(spl_autoload_functions())); } ?> diff --git a/ext/spl/tests/spl_autoload_009.phpt b/ext/spl/tests/spl_autoload_009.phpt index 10973ae44ad7..f12fd0af7e70 100644 --- a/ext/spl/tests/spl_autoload_009.phpt +++ b/ext/spl/tests/spl_autoload_009.phpt @@ -7,8 +7,8 @@ include_path=. function my_autoload($name) { - require $name . '.class.inc'; - var_dump(class_exists($name)); + require $name . '.class.inc'; + var_dump(class_exists($name)); } spl_autoload_register("spl_autoload"); diff --git a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt index cee557e330c0..92aae6dc78f0 100644 --- a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt +++ b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt @@ -13,7 +13,7 @@ symlink(__FILE__, $link ); $fileInfo = new SplFileInfo($link); if ($fileInfo->isLink()) { - echo $fileInfo->getLinkTarget() == __FILE__ ? 'same' : 'different',PHP_EOL; + echo $fileInfo->getLinkTarget() == __FILE__ ? 'same' : 'different',PHP_EOL; } var_dump(unlink($link)); ?> diff --git a/ext/spl/tests/spl_heap_count_basic.phpt b/ext/spl/tests/spl_heap_count_basic.phpt index 3bdd6580dcd9..2be8c432fcd9 100644 --- a/ext/spl/tests/spl_heap_count_basic.phpt +++ b/ext/spl/tests/spl_heap_count_basic.phpt @@ -24,9 +24,9 @@ class MyHeap extends SplHeap $heap = new MyHeap(); $heap->insert(1); try { - count($heap);// refers to MyHeap->count() method + count($heap);// refers to MyHeap->count() method } catch (Exception $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } ?> diff --git a/ext/spl/tests/spl_iterator_apply_error.phpt b/ext/spl/tests/spl_iterator_apply_error.phpt index 8e7cba483a59..c73fe468a100 100644 --- a/ext/spl/tests/spl_iterator_apply_error.phpt +++ b/ext/spl/tests/spl_iterator_apply_error.phpt @@ -4,9 +4,9 @@ SPL: Error: iterator_apply when an iterator method (eg rewind) throws exception getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/spl_iterator_apply_error_001.phpt b/ext/spl/tests/spl_iterator_apply_error_001.phpt index 54663c0da889..9c021cf98fe0 100644 --- a/ext/spl/tests/spl_iterator_apply_error_001.phpt +++ b/ext/spl/tests/spl_iterator_apply_error_001.phpt @@ -4,15 +4,15 @@ SPL: Error: iterator_apply when the callback throws an exception getMessage(); + echo $e->getMessage(); } ?> diff --git a/ext/spl/tests/spl_iterator_to_array_error.phpt b/ext/spl/tests/spl_iterator_to_array_error.phpt index 755ef7b99083..2704fea29d71 100644 --- a/ext/spl/tests/spl_iterator_to_array_error.phpt +++ b/ext/spl/tests/spl_iterator_to_array_error.phpt @@ -4,25 +4,25 @@ SPL: Error: iterator_to_array when the current operation throws an exception getMessage() . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } try { - // get values - $ar = iterator_to_array($it, false); + // get values + $ar = iterator_to_array($it, false); } catch (Exception $e) { - echo $e->getMessage() . PHP_EOL; + echo $e->getMessage() . PHP_EOL; } ?> diff --git a/ext/spl/tests/spl_pq_top_error_corrupt.phpt b/ext/spl/tests/spl_pq_top_error_corrupt.phpt index 30b6fde5a144..838e763447f8 100644 --- a/ext/spl/tests/spl_pq_top_error_corrupt.phpt +++ b/ext/spl/tests/spl_pq_top_error_corrupt.phpt @@ -8,13 +8,13 @@ Nathaniel McHugh nat@fishtrap.co.uk class myPriorityQueue extends SplPriorityQueue{ - public function compare($a, $b){ - if ($b == 2) { - throw new Exception('ignore me'); - } else { - return parent::compare($a, $b); - } - } + public function compare($a, $b){ + if ($b == 2) { + throw new Exception('ignore me'); + } else { + return parent::compare($a, $b); + } + } } $priorityQueue = new myPriorityQueue(); diff --git a/ext/spl/tests/spl_pqueue_gc.phpt b/ext/spl/tests/spl_pqueue_gc.phpt index cc392cbac28a..18c96c5a299c 100644 --- a/ext/spl/tests/spl_pqueue_gc.phpt +++ b/ext/spl/tests/spl_pqueue_gc.phpt @@ -1,7 +1,7 @@ --TEST-- Bug #78436: Broken GC for SplPriorityQueue --FILE-- -insert($pqueue, 1); diff --git a/ext/spl/tests/unserialize.phpt b/ext/spl/tests/unserialize.phpt index 81b0894990ac..97031ceac40c 100644 --- a/ext/spl/tests/unserialize.phpt +++ b/ext/spl/tests/unserialize.phpt @@ -6,16 +6,16 @@ SPL: unserialize with no data (for PHPUnit) $types = array('SplDoublyLinkedList', 'SplObjectStorage', 'ArrayObject'); foreach ($types as $type) { - // serialize an empty new object - $exp = serialize(new $type()); - // hack to instantiate an object without constructor - $str = sprintf('C:%d:"%s":0:{}', strlen($type), $type); - $obj = unserialize($str); - var_dump($obj); - // serialize result - $out = serialize($obj); - // both should match - var_dump($exp === $out); + // serialize an empty new object + $exp = serialize(new $type()); + // hack to instantiate an object without constructor + $str = sprintf('C:%d:"%s":0:{}', strlen($type), $type); + $obj = unserialize($str); + var_dump($obj); + // serialize result + $out = serialize($obj); + // both should match + var_dump($exp === $out); } ?> --EXPECTF-- diff --git a/ext/sqlite3/tests/bug45798.phpt b/ext/sqlite3/tests/bug45798.phpt index 9637c1fc9baa..7184d58d5457 100644 --- a/ext/sqlite3/tests/bug45798.phpt +++ b/ext/sqlite3/tests/bug45798.phpt @@ -18,7 +18,7 @@ $stmt->bindParam(1, $foo, SQLITE3_TEXT); $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/bug68760.phpt b/ext/sqlite3/tests/bug68760.phpt index 7eb97ee013a9..7cc646780b88 100644 --- a/ext/sqlite3/tests/bug68760.phpt +++ b/ext/sqlite3/tests/bug68760.phpt @@ -7,8 +7,8 @@ if (!extension_loaded('sqlite3')) die('skip'); --FILE-- --FILE-- createFunction('my_udf_md5', 'my_udf_md5'); try { - $result = $db->query('SELECT my_udf_md5("test")'); - var_dump($result); + $result = $db->query('SELECT my_udf_md5("test")'); + var_dump($result); } catch(\Exception $e) { - echo "Exception: ".$e->getMessage(); + echo "Exception: ".$e->getMessage(); } try { - $result = $db->querySingle('SELECT my_udf_md5("test")'); - var_dump($result); + $result = $db->querySingle('SELECT my_udf_md5("test")'); + var_dump($result); } catch(\Exception $e) { - echo "Exception: ".$e->getMessage(); + echo "Exception: ".$e->getMessage(); } $statement = $db->prepare('SELECT my_udf_md5("test")'); try { - $result = $statement->execute(); - var_dump($result); + $result = $statement->execute(); + var_dump($result); } catch(\Exception $e) { - echo "Exception: ".$e->getMessage(); + echo "Exception: ".$e->getMessage(); } ?> --EXPECT-- diff --git a/ext/sqlite3/tests/skipif.inc b/ext/sqlite3/tests/skipif.inc index 9614e679b96f..0f930332ea17 100644 --- a/ext/sqlite3/tests/skipif.inc +++ b/ext/sqlite3/tests/skipif.inc @@ -1,7 +1,7 @@ diff --git a/ext/sqlite3/tests/sqlite3_03_insert.phpt b/ext/sqlite3/tests/sqlite3_03_insert.phpt index 1a0690a000c7..60880de8805b 100644 --- a/ext/sqlite3/tests/sqlite3_03_insert.phpt +++ b/ext/sqlite3/tests/sqlite3_03_insert.phpt @@ -19,7 +19,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_04_update.phpt b/ext/sqlite3/tests/sqlite3_04_update.phpt index 3ce7d9cf8b3b..fe55464ef655 100644 --- a/ext/sqlite3/tests/sqlite3_04_update.phpt +++ b/ext/sqlite3/tests/sqlite3_04_update.phpt @@ -19,7 +19,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); @@ -30,7 +30,7 @@ echo "Checking results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_05_delete.phpt b/ext/sqlite3/tests/sqlite3_05_delete.phpt index 9ce50c4789e4..8768d0b575e7 100644 --- a/ext/sqlite3/tests/sqlite3_05_delete.phpt +++ b/ext/sqlite3/tests/sqlite3_05_delete.phpt @@ -19,7 +19,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); @@ -30,7 +30,7 @@ echo "Checking results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt b/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt index 710813e8f5ee..28fd2d264ab2 100644 --- a/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt +++ b/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt @@ -24,7 +24,7 @@ $foo = 'a'; $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt b/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt index d9a2408123ac..393386fead5e 100644 --- a/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt +++ b/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt @@ -23,7 +23,7 @@ var_dump($stmt->bindValue(1, $foo, SQLITE3_TEXT)); $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_08_udf.phpt b/ext/sqlite3/tests/sqlite3_08_udf.phpt index 7f00dbb1c49f..24862ddda889 100644 --- a/ext/sqlite3/tests/sqlite3_08_udf.phpt +++ b/ext/sqlite3/tests/sqlite3_08_udf.phpt @@ -7,7 +7,7 @@ SQLite3::createFunction function my_udf_md5($foo) { - return md5($foo); + return md5($foo); } require_once(__DIR__ . '/new_db.inc'); @@ -27,7 +27,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT my_udf_md5(id) FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt b/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt index 994503dd03ad..27497f744871 100644 --- a/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt +++ b/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt @@ -30,7 +30,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT id, quote(data) AS data FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt b/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt index 712ad2e53930..f7bd34f38873 100644 --- a/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt +++ b/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt @@ -25,7 +25,7 @@ var_dump($stmt->bindValue('id', $foo, SQLITE3_TEXT)); $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt b/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt index eac5a59a8a0f..e3e67f1ff453 100644 --- a/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt +++ b/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt @@ -19,9 +19,9 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); - /* Only read one row and break */ - break; + var_dump($result); + /* Only read one row and break */ + break; } echo "Closing database\n"; diff --git a/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt b/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt index daeacc083206..0bced8c19aa2 100644 --- a/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt +++ b/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt @@ -19,7 +19,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } echo "Done\n"; ?> diff --git a/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt b/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt index d9c7e2fa410f..4b75b3b28f02 100644 --- a/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt +++ b/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt @@ -19,9 +19,9 @@ $cmd = $icacls . ' ' . $unreadable . ' /inheritance:r /deny ' . $user . ':(F,M,R exec($cmd); try { - $db = new SQLite3($unreadable); + $db = new SQLite3($unreadable); } catch (Exception $e) { - echo $e . "\n"; + echo $e . "\n"; } echo "Done\n"; diff --git a/ext/sqlite3/tests/sqlite3_15_open_error.phpt b/ext/sqlite3/tests/sqlite3_15_open_error.phpt index 74bcc920d0e9..0c3e9537db2d 100644 --- a/ext/sqlite3/tests/sqlite3_15_open_error.phpt +++ b/ext/sqlite3/tests/sqlite3_15_open_error.phpt @@ -16,9 +16,9 @@ $unreadable = __DIR__ . '/unreadable.db'; touch($unreadable); chmod($unreadable, 0200); try { - $db = new SQLite3($unreadable); + $db = new SQLite3($unreadable); } catch (Exception $e) { - echo $e . "\n"; + echo $e . "\n"; } echo "Done\n"; unlink($unreadable); diff --git a/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt b/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt index 91875b68ad6b..08fe5eeb2421 100644 --- a/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt +++ b/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt @@ -15,7 +15,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_19_columninfo.phpt b/ext/sqlite3/tests/sqlite3_19_columninfo.phpt index 2395c7539998..51017bb0bcd3 100644 --- a/ext/sqlite3/tests/sqlite3_19_columninfo.phpt +++ b/ext/sqlite3/tests/sqlite3_19_columninfo.phpt @@ -18,10 +18,10 @@ var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")) echo "SELECTING results\n"; $result = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($row = $result->fetchArray(SQLITE3_NUM)) { - $totalColumns = $result->numColumns(); - for ($i = 0; $i < $totalColumns; $i++) { - echo "Name: " . $result->columnName($i) . " - Type: " . $result->columnType($i) . "\n"; - } + $totalColumns = $result->numColumns(); + for ($i = 0; $i < $totalColumns; $i++) { + echo "Name: " . $result->columnName($i) . " - Type: " . $result->columnType($i) . "\n"; + } } $result->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_20_error.phpt b/ext/sqlite3/tests/sqlite3_20_error.phpt index a9324c399916..9b1579a83ec6 100644 --- a/ext/sqlite3/tests/sqlite3_20_error.phpt +++ b/ext/sqlite3/tests/sqlite3_20_error.phpt @@ -10,8 +10,8 @@ require_once(__DIR__ . '/new_db.inc'); echo "SELECTING from invalid table\n"; $result = $db->query("SELECT * FROM non_existent_table"); if (!$result) { - echo "Error Code: " . $db->lastErrorCode() . "\n"; - echo "Error Msg: " . $db->lastErrorMsg() . "\n"; + echo "Error Code: " . $db->lastErrorCode() . "\n"; + echo "Error Msg: " . $db->lastErrorMsg() . "\n"; } echo "Closing database\n"; var_dump($db->close()); diff --git a/ext/sqlite3/tests/sqlite3_21_security.phpt b/ext/sqlite3/tests/sqlite3_21_security.phpt index 5221807cd588..407869b3f8f4 100644 --- a/ext/sqlite3/tests/sqlite3_21_security.phpt +++ b/ext/sqlite3/tests/sqlite3_21_security.phpt @@ -19,9 +19,9 @@ unlink($directory . $file); echo "Above test directory\n"; try { - $db = new SQLite3('../bad' . $file); + $db = new SQLite3('../bad' . $file); } catch (Exception $e) { - echo $e . "\n"; + echo $e . "\n"; } echo "Done\n"; diff --git a/ext/sqlite3/tests/sqlite3_23_escape_string.phpt b/ext/sqlite3/tests/sqlite3_23_escape_string.phpt index 6552c222a73e..f91213ae644b 100644 --- a/ext/sqlite3/tests/sqlite3_23_escape_string.phpt +++ b/ext/sqlite3/tests/sqlite3_23_escape_string.phpt @@ -19,7 +19,7 @@ echo "SELECTING results\n"; $results = $db->query("SELECT * FROM test ORDER BY id ASC"); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt b/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt index 84993571ec51..c8a033e7387d 100644 --- a/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt +++ b/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt @@ -8,17 +8,17 @@ SQLite3::createAggregate() test require_once(__DIR__ . '/new_db.inc'); function sum_list_step($context, $rows, $string) { - if (empty($context)) - { - $context = array('total' => 0, 'values' => array()); - } - $context['total'] += intval($string); - $context['values'][] = $context['total']; - return $context; + if (empty($context)) + { + $context = array('total' => 0, 'values' => array()); + } + $context['total'] += intval($string); + $context['values'][] = $context['total']; + return $context; } function sum_list_finalize($context) { - return implode(',', $context['values']); + return implode(',', $context['values']); } echo "Creating Table\n"; diff --git a/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt b/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt index ffd05d3329ce..39e9e4867635 100644 --- a/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt +++ b/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt @@ -23,11 +23,11 @@ var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); $foo = 'a'; $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $stmt->reset(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt b/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt index 646cb473f321..6257d6483c78 100644 --- a/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt +++ b/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt @@ -23,11 +23,11 @@ var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); $foo = 'a'; $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->reset(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt b/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt index a17e1fb3f18b..4472b878bc8c 100644 --- a/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt +++ b/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt @@ -23,14 +23,14 @@ var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); $foo = 'a'; $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $stmt->reset(); $stmt->clear(); var_dump($stmt->bindValue(1, 'b', SQLITE3_TEXT)); $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_36_create_collation.phpt b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt index 90fbd9d37b0e..644ceb02c632 100644 --- a/ext/sqlite3/tests/sqlite3_36_create_collation.phpt +++ b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt @@ -13,8 +13,8 @@ $db->exec('CREATE TABLE t (s varchar(4))'); $stmt = $db->prepare('INSERT INTO t VALUES (?)'); foreach(array('a1', 'a10', 'a2') as $s){ - $stmt->bindParam(1, $s); - $stmt->execute(); + $stmt->bindParam(1, $s); + $stmt->execute(); } $defaultSort = $db->query('SELECT s FROM t ORDER BY s'); //memcmp() sort @@ -22,12 +22,12 @@ $naturalSort = $db->query('SELECT s FROM t ORDER BY s COLLATE NAT'); //strnatcmp echo "default\n"; while ($row = $defaultSort->fetchArray()){ - echo $row['s'], "\n"; + echo $row['s'], "\n"; } echo "natural\n"; while ($row = $naturalSort->fetchArray()){ - echo $row['s'], "\n"; + echo $row['s'], "\n"; } $db->close(); diff --git a/ext/sqlite3/tests/sqlite3_40_setauthorizer.phpt b/ext/sqlite3/tests/sqlite3_40_setauthorizer.phpt index 57f05216dfdd..994c67e0c350 100644 --- a/ext/sqlite3/tests/sqlite3_40_setauthorizer.phpt +++ b/ext/sqlite3/tests/sqlite3_40_setauthorizer.phpt @@ -9,21 +9,21 @@ $db = new SQLite3(':memory:'); $db->enableExceptions(true); $db->setAuthorizer(function (int $action) { - if ($action == SQLite3::SELECT) { - return SQLite3::OK; - } + if ($action == SQLite3::SELECT) { + return SQLite3::OK; + } - return SQLite3::DENY; + return SQLite3::DENY; }); // This query should be accepted var_dump($db->querySingle('SELECT 1;')); try { - // This one should fail - var_dump($db->querySingle('CREATE TABLE test (a, b);')); + // This one should fail + var_dump($db->querySingle('CREATE TABLE test (a, b);')); } catch (\Exception $e) { - echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } // Test disabling the authorizer @@ -35,11 +35,11 @@ var_dump($db->querySingle('SELECT a FROM test;')); // Test if we are getting the correct arguments $db->setAuthorizer(function (int $action) { - $constants = (new ReflectionClass('SQLite3'))->getConstants(); - $constants = array_flip($constants); + $constants = (new ReflectionClass('SQLite3'))->getConstants(); + $constants = array_flip($constants); - var_dump($constants[$action], implode(',', array_slice(func_get_args(), 1))); - return SQLITE3::OK; + var_dump($constants[$action], implode(',', array_slice(func_get_args(), 1))); + return SQLITE3::OK; }); var_dump($db->exec('SELECT * FROM test WHERE a = 42;')); @@ -47,25 +47,25 @@ var_dump($db->exec('DROP TABLE test;')); // Try to return something invalid from the authorizer $db->setAuthorizer(function () { - return 'FAIL'; + return 'FAIL'; }); try { - var_dump($db->querySingle('SELECT 1;')); + var_dump($db->querySingle('SELECT 1;')); } catch (\Exception $e) { - echo $e->getMessage() . "\n"; - echo $e->getPrevious()->getMessage() . "\n"; + echo $e->getMessage() . "\n"; + echo $e->getPrevious()->getMessage() . "\n"; } $db->setAuthorizer(function () { - return 4200; + return 4200; }); try { - var_dump($db->querySingle('SELECT 1;')); + var_dump($db->querySingle('SELECT 1;')); } catch (\Exception $e) { - echo $e->getMessage() . "\n"; - echo $e->getPrevious()->getMessage() . "\n"; + echo $e->getMessage() . "\n"; + echo $e->getPrevious()->getMessage() . "\n"; } ?> diff --git a/ext/sqlite3/tests/sqlite3_bind_bug68849.phpt b/ext/sqlite3/tests/sqlite3_bind_bug68849.phpt index 9b6e3ae29ab1..179e04d35d26 100644 --- a/ext/sqlite3/tests/sqlite3_bind_bug68849.phpt +++ b/ext/sqlite3/tests/sqlite3_bind_bug68849.phpt @@ -8,9 +8,9 @@ Bug #68849 bindValue is not using the right data type $db = new SQLite3(':memory:'); $db->exec("CREATE TABLE test (a INTEGER, b TEXT, c REAL);" . - "INSERT INTO test VALUES (1, 'hello', 3.14);" . - "INSERT INTO test VALUES (3, 'world', 3.15);" . - "INSERT INTO test VALUES (0, '42', 0.42);" + "INSERT INTO test VALUES (1, 'hello', 3.14);" . + "INSERT INTO test VALUES (3, 'world', 3.15);" . + "INSERT INTO test VALUES (0, '42', 0.42);" ); $s = $db->prepare('SELECT * FROM test WHERE (a+2) = ?;'); diff --git a/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt b/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt index c35af945dbb9..de7edfbbacda 100644 --- a/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt +++ b/ext/sqlite3/tests/sqlite3_blob_bind_resource.phpt @@ -13,10 +13,10 @@ $insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (1, ?)"); class HelloWrapper { - public function stream_open() { return true; } - public function stream_eof() { return true; } - public function stream_read() { return NULL; } - public function stream_stat() { return array(); } + public function stream_open() { return true; } + public function stream_eof() { return true; } + public function stream_read() { return NULL; } + public function stream_stat() { return array(); } } stream_wrapper_register("hello", "HelloWrapper"); diff --git a/ext/sqlite3/tests/sqlite3_bound_value_at_name.phpt b/ext/sqlite3/tests/sqlite3_bound_value_at_name.phpt index d0eec87a2f0b..c441b1bc4ae1 100644 --- a/ext/sqlite3/tests/sqlite3_bound_value_at_name.phpt +++ b/ext/sqlite3/tests/sqlite3_bound_value_at_name.phpt @@ -23,7 +23,7 @@ var_dump($stmt->bindValue('@id', $foo, SQLITE3_TEXT)); $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { - var_dump($result); + var_dump($result); } $results->finalize(); diff --git a/ext/sqlite3/tests/sqlite3_prepare_001.phpt b/ext/sqlite3/tests/sqlite3_prepare_001.phpt index 5142081b3a3a..f97eaab021f5 100644 --- a/ext/sqlite3/tests/sqlite3_prepare_001.phpt +++ b/ext/sqlite3/tests/sqlite3_prepare_001.phpt @@ -6,8 +6,8 @@ SQLite3 - memory leak on SQLite3Result and SQLite3Stmt prepare('SELECT 1'); + $class = new SQLite3(':memory:'); + $x = $class->prepare('SELECT 1'); } test($foo); diff --git a/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt b/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt index a520f5715ba0..81eae9e566ca 100644 --- a/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt +++ b/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt @@ -16,21 +16,21 @@ var_dump($db->exec("INSERT INTO foobar (id, name, city) VALUES (2, 'doe', 'SF')" $queryArray = array( - "SELECT * FROM foobar WHERE id = ? ORDER BY id ASC", - "SELECT * FROM foobar WHERE id = 2 ORDER BY id ASC", - "SELECT * FROM foobar WHERE id = :id AND name = :name ORDER BY id ASC", - "SELECT * FROM foobar WHERE id = 1 AND name = :name ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = ? ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = 2 ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = :id AND name = :name ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = 1 AND name = :name ORDER BY id ASC", ); echo "SELECTING results\n"; foreach($queryArray as $key => $query) { - $stmt = $db->prepare($query); + $stmt = $db->prepare($query); - echo 'Param count for query ' . ($key + 1) . ":\n"; - var_dump($stmt->paramCount()); + echo 'Param count for query ' . ($key + 1) . ":\n"; + var_dump($stmt->paramCount()); - $result = $stmt->execute(); + $result = $stmt->execute(); } echo "Closing database\n"; diff --git a/ext/sqlite3/tests/stream_test.inc b/ext/sqlite3/tests/stream_test.inc index 13fd6f89f9a6..0d53d0f7be23 100644 --- a/ext/sqlite3/tests/stream_test.inc +++ b/ext/sqlite3/tests/stream_test.inc @@ -2,42 +2,42 @@ class SQLite3_Test_Stream { - private $position; - public static $string_length = 10; - public static $string = "abcdefg\0hi"; - - public function stream_open($path, $mode, $options, &$opened_path) - { - $this->position = 0; - return true; - } - - public function stream_read($count) - { - $ret = substr(self::$string, $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - public function stream_write($data) - { - return 0; - } - - public function stream_stat() - { - return array('size' => self::$string_length); - } - - public function stream_tell() - { - return $this->position; - } - - public function stream_eof() - { - return ($this->position >= self::$string_length); - } + private $position; + public static $string_length = 10; + public static $string = "abcdefg\0hi"; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $this->position = 0; + return true; + } + + public function stream_read($count) + { + $ret = substr(self::$string, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + public function stream_write($data) + { + return 0; + } + + public function stream_stat() + { + return array('size' => self::$string_length); + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return ($this->position >= self::$string_length); + } } stream_wrapper_register('sqliteBlobTest', "SQLite3_Test_Stream") or die("Unable to register sqliteBlobTest stream"); diff --git a/ext/standard/tests/array/002.phpt b/ext/standard/tests/array/002.phpt index 8d088f91297e..589514ae03b2 100644 --- a/ext/standard/tests/array/002.phpt +++ b/ext/standard/tests/array/002.phpt @@ -8,16 +8,16 @@ require(__DIR__ . '/data.inc'); function test_sort ($sort_function, $data) { echo "\n -- Testing $sort_function() -- \n"; - echo "No second argument:\n"; + echo "No second argument:\n"; $sort_function ($data); var_dump ($data); - echo "Using SORT_REGULAR:\n"; + echo "Using SORT_REGULAR:\n"; $sort_function ($data, SORT_REGULAR); var_dump ($data); - echo "Using SORT_NUMERIC:\n"; + echo "Using SORT_NUMERIC:\n"; $sort_function ($data, SORT_NUMERIC); var_dump ($data); - echo "Using SORT_STRING\n"; + echo "Using SORT_STRING\n"; $sort_function ($data, SORT_STRING); var_dump ($data); } diff --git a/ext/standard/tests/array/004.phpt b/ext/standard/tests/array/004.phpt index 765637b26ce0..0f9fc5507c1a 100644 --- a/ext/standard/tests/array/004.phpt +++ b/ext/standard/tests/array/004.phpt @@ -5,11 +5,11 @@ precision=14 --FILE-- 0, - 5=>'test2', - 'abc'=>'test10', - 'test21' + 'Test1', + 'teST2'=>0, + 5=>'test2', + 'abc'=>'test10', + 'test21' ); var_dump($data); diff --git a/ext/standard/tests/array/007.phpt b/ext/standard/tests/array/007.phpt index 4a1270eca6c8..a1c984a18be1 100644 --- a/ext/standard/tests/array/007.phpt +++ b/ext/standard/tests/array/007.phpt @@ -51,27 +51,27 @@ var_dump(array_diff_assoc($a,$b,$c)); echo "-=-=-=-=-=-=-=-=- New functionality from 5.0.0 -=-=-=-=-=-=-=-\n"; error_reporting(E_ALL); class cr { - private $priv_member; - public $public_member; - function __construct($val) { - $this->priv_member = $val; - $this->public_member = $val; - } - static function comp_func_cr($a, $b) { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } + private $priv_member; + public $public_member; + function __construct($val) { + $this->priv_member = $val; + $this->public_member = $val; + } + static function comp_func_cr($a, $b) { + if ($a->priv_member === $b->priv_member) return 0; + return ($a->priv_member > $b->priv_member)? 1:-1; + } } function comp_func($a, $b) { - if ($a === $b) return 0; - return ($a > $b)? 1:-1; + if ($a === $b) return 0; + return ($a > $b)? 1:-1; } function comp_func_cr($a, $b) { - if ($a->public_member === $b->public_member) return 0; - return ($a->public_member > $b->public_member)? 1:-1; + if ($a->public_member === $b->public_member) return 0; + return ($a->public_member > $b->public_member)? 1:-1; } diff --git a/ext/standard/tests/array/array_change_key_case.phpt b/ext/standard/tests/array/array_change_key_case.phpt index ca9a21128bce..115a7096d80e 100644 --- a/ext/standard/tests/array/array_change_key_case.phpt +++ b/ext/standard/tests/array/array_change_key_case.phpt @@ -52,10 +52,10 @@ echo "*** Testing basic operations ***\n"; $loop_counter = 1; foreach ($arrays as $item) { echo "** Iteration $loop_counter **\n"; $loop_counter++; - var_dump(array_change_key_case($item)); - var_dump(array_change_key_case($item, CASE_UPPER)); - var_dump(array_change_key_case($item, CASE_LOWER)); - echo "\n"; + var_dump(array_change_key_case($item)); + var_dump(array_change_key_case($item, CASE_UPPER)); + var_dump(array_change_key_case($item, CASE_LOWER)); + echo "\n"; } echo "end\n"; diff --git a/ext/standard/tests/array/array_change_key_case_variation4.phpt b/ext/standard/tests/array/array_change_key_case_variation4.phpt index 52017177ccfd..eaacfaac5814 100644 --- a/ext/standard/tests/array/array_change_key_case_variation4.phpt +++ b/ext/standard/tests/array/array_change_key_case_variation4.phpt @@ -15,9 +15,9 @@ echo "*** Testing array_change_key_case() : usage variations ***\n"; $input = array('One' => 'un', 'TWO' => 'deux', 'three' => 'trois'); for ($i = -5; $i <=5; $i += 1){ - echo "\n-- \$sort argument is $i --\n"; - $temp = $input; - var_dump(array_change_key_case($temp, $i)); + echo "\n-- \$sort argument is $i --\n"; + $temp = $input; + var_dump(array_change_key_case($temp, $i)); } echo "Done"; diff --git a/ext/standard/tests/array/array_change_key_case_variation8.phpt b/ext/standard/tests/array/array_change_key_case_variation8.phpt index 493862ccd41a..17455c54dade 100644 --- a/ext/standard/tests/array/array_change_key_case_variation8.phpt +++ b/ext/standard/tests/array/array_change_key_case_variation8.phpt @@ -14,18 +14,18 @@ Test array_change_key_case() function : usage variations - Different strings as echo "*** Testing array_change_key_case() : usage variations ***\n"; $inputs = array ( - // group of escape sequences - array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11), + // group of escape sequences + array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11), - // array contains combination of capital/small letters - array("lemoN" => 1, "Orange" => 2, "banana" => 3, "apple" => 4, "Test" => 5, "TTTT" => 6, "ttt" => 7, "ww" => 8, "x" => 9, "X" => 10, "oraNGe" => 11, "BANANA" => 12) + // array contains combination of capital/small letters + array("lemoN" => 1, "Orange" => 2, "banana" => 3, "apple" => 4, "Test" => 5, "TTTT" => 6, "ttt" => 7, "ww" => 8, "x" => 9, "X" => 10, "oraNGe" => 11, "BANANA" => 12) ); foreach($inputs as $input) { - echo "\n-- \$case = default --\n"; - var_dump(array_change_key_case($input)); - echo "-- \$case = upper --\n"; - var_dump(array_change_key_case($input, CASE_UPPER)); + echo "\n-- \$case = default --\n"; + var_dump(array_change_key_case($input)); + echo "-- \$case = upper --\n"; + var_dump(array_change_key_case($input, CASE_UPPER)); } echo "Done"; diff --git a/ext/standard/tests/array/array_chunk_variation10.phpt b/ext/standard/tests/array/array_chunk_variation10.phpt index be5fcdc7f30a..326d7de98f36 100644 --- a/ext/standard/tests/array/array_chunk_variation10.phpt +++ b/ext/standard/tests/array/array_chunk_variation10.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 10 $array = array (1 => 1, 2 => 2, 3 => 3); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation11.phpt b/ext/standard/tests/array/array_chunk_variation11.phpt index 09ec25574425..e3ce445370d5 100644 --- a/ext/standard/tests/array/array_chunk_variation11.phpt +++ b/ext/standard/tests/array/array_chunk_variation11.phpt @@ -6,11 +6,11 @@ $array = array (0 => 0, 3 => 2); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation12.phpt b/ext/standard/tests/array/array_chunk_variation12.phpt index f85f2a8c0dc5..3b0cb79beb0f 100644 --- a/ext/standard/tests/array/array_chunk_variation12.phpt +++ b/ext/standard/tests/array/array_chunk_variation12.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 12 $array = array (1 => 1, 5 => 2, 8 => 3); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation13.phpt b/ext/standard/tests/array/array_chunk_variation13.phpt index 5cd6f0ea34fa..f62d309c156d 100644 --- a/ext/standard/tests/array/array_chunk_variation13.phpt +++ b/ext/standard/tests/array/array_chunk_variation13.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 13 $array = array (1, 2); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation14.phpt b/ext/standard/tests/array/array_chunk_variation14.phpt index 97fce1e7224e..64746bf6e7ba 100644 --- a/ext/standard/tests/array/array_chunk_variation14.phpt +++ b/ext/standard/tests/array/array_chunk_variation14.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 14 $array = array (0, 1, 2); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation15.phpt b/ext/standard/tests/array/array_chunk_variation15.phpt index c48af63f6ced..294dd9f8f90c 100644 --- a/ext/standard/tests/array/array_chunk_variation15.phpt +++ b/ext/standard/tests/array/array_chunk_variation15.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 15 $array = array (1, 2, 3); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation16.phpt b/ext/standard/tests/array/array_chunk_variation16.phpt index 3426f9278bfc..b7159cba99f1 100644 --- a/ext/standard/tests/array/array_chunk_variation16.phpt +++ b/ext/standard/tests/array/array_chunk_variation16.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 16 $array = array (0, 1, 2, 3); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation17.phpt b/ext/standard/tests/array/array_chunk_variation17.phpt index 1a8bb5d34014..07826d06f8ab 100644 --- a/ext/standard/tests/array/array_chunk_variation17.phpt +++ b/ext/standard/tests/array/array_chunk_variation17.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 17 $array = array (1, 2, 3, 4); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation18.phpt b/ext/standard/tests/array/array_chunk_variation18.phpt index 593c702ce94d..1fa9ca6ec4d1 100644 --- a/ext/standard/tests/array/array_chunk_variation18.phpt +++ b/ext/standard/tests/array/array_chunk_variation18.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 18 $array = array (0, 1, 2, 3, 4); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation19.phpt b/ext/standard/tests/array/array_chunk_variation19.phpt index f160cba2631f..2591db89ebc3 100644 --- a/ext/standard/tests/array/array_chunk_variation19.phpt +++ b/ext/standard/tests/array/array_chunk_variation19.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 19 $array = array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation20.phpt b/ext/standard/tests/array/array_chunk_variation20.phpt index d47279915c9f..ec2e45b104e2 100644 --- a/ext/standard/tests/array/array_chunk_variation20.phpt +++ b/ext/standard/tests/array/array_chunk_variation20.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 20 $array = array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation21.phpt b/ext/standard/tests/array/array_chunk_variation21.phpt index e8c7784325a4..ce672a9209cf 100644 --- a/ext/standard/tests/array/array_chunk_variation21.phpt +++ b/ext/standard/tests/array/array_chunk_variation21.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 21 $array = array ("a" => 1); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation22.phpt b/ext/standard/tests/array/array_chunk_variation22.phpt index b0eeade3ab00..d67269f4e734 100644 --- a/ext/standard/tests/array/array_chunk_variation22.phpt +++ b/ext/standard/tests/array/array_chunk_variation22.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 22 $array = array ("b" => 1, "c" => 2); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation23.phpt b/ext/standard/tests/array/array_chunk_variation23.phpt index 87ced1513207..99138eaeb315 100644 --- a/ext/standard/tests/array/array_chunk_variation23.phpt +++ b/ext/standard/tests/array/array_chunk_variation23.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 23 $array = array ("p" => 1, "q" => 2, "r" => 3, "s" => 4, "u" => 5, "v" => 6); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation24.phpt b/ext/standard/tests/array/array_chunk_variation24.phpt index 69dce7be1746..c96d59d874eb 100644 --- a/ext/standard/tests/array/array_chunk_variation24.phpt +++ b/ext/standard/tests/array/array_chunk_variation24.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 24 $array = array ("a" => "A"); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation25.phpt b/ext/standard/tests/array/array_chunk_variation25.phpt index 09303c30ba75..978588e02cc5 100644 --- a/ext/standard/tests/array/array_chunk_variation25.phpt +++ b/ext/standard/tests/array/array_chunk_variation25.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 25 $array = array ("p" => "A", "q" => "B", "r" => "C", "s" => "D", "u" => "E", "v" => "F"); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation26.phpt b/ext/standard/tests/array/array_chunk_variation26.phpt index ca6975a64e9c..7b46215ffb64 100644 --- a/ext/standard/tests/array/array_chunk_variation26.phpt +++ b/ext/standard/tests/array/array_chunk_variation26.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 26 $array =array (0); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation27.phpt b/ext/standard/tests/array/array_chunk_variation27.phpt index aa91036a5206..a91a8b91b99d 100644 --- a/ext/standard/tests/array/array_chunk_variation27.phpt +++ b/ext/standard/tests/array/array_chunk_variation27.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 27 $array = array (1); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation28.phpt b/ext/standard/tests/array/array_chunk_variation28.phpt index 5389049ce40a..707b0cdefcaf 100644 --- a/ext/standard/tests/array/array_chunk_variation28.phpt +++ b/ext/standard/tests/array/array_chunk_variation28.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 28 $array = array (-1); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation29.phpt b/ext/standard/tests/array/array_chunk_variation29.phpt index f18de5ea8577..07187135bee6 100644 --- a/ext/standard/tests/array/array_chunk_variation29.phpt +++ b/ext/standard/tests/array/array_chunk_variation29.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 29 $array = array (0, 2); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation30.phpt b/ext/standard/tests/array/array_chunk_variation30.phpt index 0dbd9b63683f..5400b595ebaf 100644 --- a/ext/standard/tests/array/array_chunk_variation30.phpt +++ b/ext/standard/tests/array/array_chunk_variation30.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 30 $array = array (1, 2, 3); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation31.phpt b/ext/standard/tests/array/array_chunk_variation31.phpt index fd7f358ca0dd..ffdfa2bc1345 100644 --- a/ext/standard/tests/array/array_chunk_variation31.phpt +++ b/ext/standard/tests/array/array_chunk_variation31.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 31 $array = array (1 => 0); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation32.phpt b/ext/standard/tests/array/array_chunk_variation32.phpt index 09471a59aaf4..b0a01f209ae4 100644 --- a/ext/standard/tests/array/array_chunk_variation32.phpt +++ b/ext/standard/tests/array/array_chunk_variation32.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 32 $array = array (2 => 1); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation8.phpt b/ext/standard/tests/array/array_chunk_variation8.phpt index 64b9bb203617..2d8fa07c9738 100644 --- a/ext/standard/tests/array/array_chunk_variation8.phpt +++ b/ext/standard/tests/array/array_chunk_variation8.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 8 $array = array (3 => -1); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_chunk_variation9.phpt b/ext/standard/tests/array/array_chunk_variation9.phpt index a68240e6f642..2be7b81e8372 100644 --- a/ext/standard/tests/array/array_chunk_variation9.phpt +++ b/ext/standard/tests/array/array_chunk_variation9.phpt @@ -5,11 +5,11 @@ array_chunk() - variation 9 $array = array (1 => 0, 2 => 2); var_dump ($array); for ($i = 1; $i < (sizeof($array) + 1); $i++) { - echo "[$i]\n"; - var_dump (array_chunk ($array, $i)); - var_dump (array_chunk ($array, $i, TRUE)); - var_dump (array_chunk ($array, $i, FALSE)); - echo "\n"; + echo "[$i]\n"; + var_dump (array_chunk ($array, $i)); + var_dump (array_chunk ($array, $i, TRUE)); + var_dump (array_chunk ($array, $i, FALSE)); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/array_column_basic.phpt b/ext/standard/tests/array/array_column_basic.phpt index 418f373872f7..57056b971f70 100644 --- a/ext/standard/tests/array/array_column_basic.phpt +++ b/ext/standard/tests/array/array_column_basic.phpt @@ -12,21 +12,21 @@ Test array_column() function: basic functionality echo "*** Testing array_column() : basic functionality ***\n"; /* Array representing a possible record set returned from a database */ $records = array( - array( - 'id' => 1, - 'first_name' => 'John', - 'last_name' => 'Doe' - ), - array( - 'id' => 2, - 'first_name' => 'Sally', - 'last_name' => 'Smith' - ), - array( - 'id' => 3, - 'first_name' => 'Jane', - 'last_name' => 'Jones' - ) + array( + 'id' => 1, + 'first_name' => 'John', + 'last_name' => 'Doe' + ), + array( + 'id' => 2, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), + array( + 'id' => 3, + 'first_name' => 'Jane', + 'last_name' => 'Jones' + ) ); echo "-- first_name column from recordset --\n"; @@ -44,47 +44,47 @@ var_dump(array_column($records, 'last_name', 'first_name')); echo "\n*** Testing multiple data types ***\n"; $fh = fopen(__FILE__, 'r', true); $values = array( - array( - 'id' => 1, - 'value' => new stdClass - ), - array( - 'id' => 2, - 'value' => 34.2345 - ), - array( - 'id' => 3, - 'value' => true - ), - array( - 'id' => 4, - 'value' => false - ), - array( - 'id' => 5, - 'value' => null - ), - array( - 'id' => 6, - 'value' => 1234 - ), - array( - 'id' => 7, - 'value' => 'Foo' - ), - array( - 'id' => 8, - 'value' => $fh - ) + array( + 'id' => 1, + 'value' => new stdClass + ), + array( + 'id' => 2, + 'value' => 34.2345 + ), + array( + 'id' => 3, + 'value' => true + ), + array( + 'id' => 4, + 'value' => false + ), + array( + 'id' => 5, + 'value' => null + ), + array( + 'id' => 6, + 'value' => 1234 + ), + array( + 'id' => 7, + 'value' => 'Foo' + ), + array( + 'id' => 8, + 'value' => $fh + ) ); var_dump(array_column($values, 'value')); var_dump(array_column($values, 'value', 'id')); echo "\n*** Testing numeric column keys ***\n"; $numericCols = array( - array('aaa', '111'), - array('bbb', '222'), - array('ccc', '333', -1 => 'ddd') + array('aaa', '111'), + array('bbb', '222'), + array('ccc', '333', -1 => 'ddd') ); var_dump(array_column($numericCols, 1)); var_dump(array_column($numericCols, 1, 0)); diff --git a/ext/standard/tests/array/array_column_variant_objects.phpt b/ext/standard/tests/array/array_column_variant_objects.phpt index dc9c0e7e8fa7..612573e8fd12 100644 --- a/ext/standard/tests/array/array_column_variant_objects.phpt +++ b/ext/standard/tests/array/array_column_variant_objects.phpt @@ -5,14 +5,14 @@ Test array_column() function: testing with objects class User { - public $id, $first_name, $last_name; - - public function __construct($id, $first_name, $last_name) - { - $this->id = $id; - $this->first_name = $first_name; - $this->last_name = $last_name; - } + public $id, $first_name, $last_name; + + public function __construct($id, $first_name, $last_name) + { + $this->id = $id; + $this->first_name = $first_name; + $this->last_name = $last_name; + } } function newUser($id, $first_name, $last_name) @@ -27,15 +27,15 @@ function newUser($id, $first_name, $last_name) class Something { - public function __isset($name) - { - return $name == 'first_name'; - } - - public function __get($name) - { - return new User(4, 'Jack', 'Sparrow'); - } + public function __isset($name) + { + return $name == 'first_name'; + } + + public function __get($name) + { + return new User(4, 'Jack', 'Sparrow'); + } } $records = array( @@ -45,7 +45,7 @@ $records = array( new User(1, 'John', 'Doe'), new User(2, 'Sally', 'Smith'), new User(3, 'Jane', 'Jones'), - new Something, + new Something, ); echo "*** Testing array_column() : object property fetching (numeric property names) ***\n"; diff --git a/ext/standard/tests/array/array_combine.phpt b/ext/standard/tests/array/array_combine.phpt index 28eb54929e74..b1b707aed679 100644 --- a/ext/standard/tests/array/array_combine.phpt +++ b/ext/standard/tests/array/array_combine.phpt @@ -2,30 +2,30 @@ basic array_combine test --FILE-- --EXPECT-- Array diff --git a/ext/standard/tests/array/array_count_values.phpt b/ext/standard/tests/array/array_count_values.phpt index a6424aab9a6a..eb5151243096 100644 --- a/ext/standard/tests/array/array_count_values.phpt +++ b/ext/standard/tests/array/array_count_values.phpt @@ -3,23 +3,23 @@ array_count_values() --FILE-- --EXPECT-- diff --git a/ext/standard/tests/array/array_count_values2.phpt b/ext/standard/tests/array/array_count_values2.phpt index cb0c330965b7..a38b02c8be19 100644 --- a/ext/standard/tests/array/array_count_values2.phpt +++ b/ext/standard/tests/array/array_count_values2.phpt @@ -3,18 +3,18 @@ basic array_count_values test --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/array/array_count_values_variation.phpt b/ext/standard/tests/array/array_count_values_variation.phpt index 00f13c8a5b7a..2156db0ad9d8 100644 --- a/ext/standard/tests/array/array_count_values_variation.phpt +++ b/ext/standard/tests/array/array_count_values_variation.phpt @@ -15,9 +15,9 @@ Test array_count_values() function : Test all normal parameter variations echo "*** Testing array_count_values() : parameter variations ***\n"; class A { - static function hello() { - echo "Hello\n"; - } + static function hello() { + echo "Hello\n"; + } } $ob = new A(); diff --git a/ext/standard/tests/array/array_diff_assoc_variation1.phpt b/ext/standard/tests/array/array_diff_assoc_variation1.phpt index 270660a8cf1a..a723930b3445 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation1.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation1.phpt @@ -73,7 +73,7 @@ $inputs = array( // binary data /*21*/ b"binary", - (binary)"binary", + (binary)"binary", // object data /*23*/ new classA(), diff --git a/ext/standard/tests/array/array_diff_assoc_variation2.phpt b/ext/standard/tests/array/array_diff_assoc_variation2.phpt index 9185b5343937..dc5e7c87c3c9 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation2.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation2.phpt @@ -73,7 +73,7 @@ $inputs = array( // binary data /*21*/ b"binary", - (binary)"binary", + (binary)"binary", // object data /*23*/ new classA(), diff --git a/ext/standard/tests/array/array_diff_assoc_variation3.phpt b/ext/standard/tests/array/array_diff_assoc_variation3.phpt index 959ddd542804..023beb1ed012 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation3.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation3.phpt @@ -39,7 +39,7 @@ $inputs = array( // int data /*1*/ 'int' => array( - 0, + 0, 1, 12345, -2345), @@ -84,7 +84,7 @@ $inputs = array( /*7*/ 'binary' => array( b"binary", - (binary)"binary"), + (binary)"binary"), // object data /*8*/ diff --git a/ext/standard/tests/array/array_diff_assoc_variation4.phpt b/ext/standard/tests/array/array_diff_assoc_variation4.phpt index 8cb05f8562ca..70ea73f96d76 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation4.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation4.phpt @@ -75,7 +75,7 @@ $inputs = array( /*7*/ 'binary' => array( b"binary1" => 'binary 1', - (binary)"binary2" => 'binary 2'), + (binary)"binary2" => 'binary 2'), // undefined data /*8*/ diff --git a/ext/standard/tests/array/array_diff_assoc_variation6.phpt b/ext/standard/tests/array/array_diff_assoc_variation6.phpt index bfbb0582ea22..b4ef6d2304cc 100644 --- a/ext/standard/tests/array/array_diff_assoc_variation6.phpt +++ b/ext/standard/tests/array/array_diff_assoc_variation6.phpt @@ -28,41 +28,41 @@ $inputs = array ( //numeric keys => string values /*2*/ array(2 => '2.00000000000001', - 1 => '1', - 0 => 'zero', - 3 => 'a'), + 1 => '1', + 0 => 'zero', + 3 => 'a'), //string keys => string values /*3*/ array('2' => '2.00000000000001', - '1' => '1', - '0' => 'zero', - '3' => 'a') , + '1' => '1', + '0' => 'zero', + '3' => 'a') , //default keys => numeric values /*4*/ array(2, 1, 0), //numeric keys => numeric values /*5*/ array(2 => 2, - 1 => 1, - 0 => 0), + 1 => 1, + 0 => 0), //string keys => numeric values /*6*/ array('two' => 2, - '1' => 1, - '0' => 0), + '1' => 1, + '0' => 0), //default keys => float values /*7*/ array(2.00000000000001, 1.00, 0.01E-9), //numeric keys => float values /*8*/ array(2 => 2.00000000000001, - 1 => 1.00, - 0 => 0.01E-9), + 1 => 1.00, + 0 => 0.01E-9), //string keys => float values /*9*/ array ('two' => 2.00000000000001, - '1' => 1.00, - '0' =>0.01E-9) + '1' => 1.00, + '0' =>0.01E-9) ); // loop through each element of $inputs to check the behavior of array_diff_assoc diff --git a/ext/standard/tests/array/array_diff_key_variation1.phpt b/ext/standard/tests/array/array_diff_key_variation1.phpt index 7cc280c96681..bdfac2c19648 100644 --- a/ext/standard/tests/array/array_diff_key_variation1.phpt +++ b/ext/standard/tests/array/array_diff_key_variation1.phpt @@ -23,9 +23,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_diff_key_variation2.phpt b/ext/standard/tests/array/array_diff_key_variation2.phpt index e38c10a3c9bd..4f84db5dd1f2 100644 --- a/ext/standard/tests/array/array_diff_key_variation2.phpt +++ b/ext/standard/tests/array/array_diff_key_variation2.phpt @@ -23,9 +23,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_diff_key_variation8.phpt b/ext/standard/tests/array/array_diff_key_variation8.phpt index f96a1db57831..65c09557a387 100644 --- a/ext/standard/tests/array/array_diff_key_variation8.phpt +++ b/ext/standard/tests/array/array_diff_key_variation8.phpt @@ -12,7 +12,7 @@ echo "*** Testing array_diff_key() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) $array1 = array( - 'first' => array('blue' => 1, 'red' => 2), + 'first' => array('blue' => 1, 'red' => 2), 'second' => array('yellow' => 7), @@ -21,7 +21,7 @@ $array1 = array( $array2 = array ( - 'first' => array('blue' => 1, 'red' => 2,), + 'first' => array('blue' => 1, 'red' => 2,), 'second' => array('cyan' => 8), diff --git a/ext/standard/tests/array/array_diff_uassoc_variation1.phpt b/ext/standard/tests/array/array_diff_uassoc_variation1.phpt index b0cf97e0a415..0891cd2ee108 100644 --- a/ext/standard/tests/array/array_diff_uassoc_variation1.phpt +++ b/ext/standard/tests/array/array_diff_uassoc_variation1.phpt @@ -31,9 +31,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_diff_uassoc_variation2.phpt b/ext/standard/tests/array/array_diff_uassoc_variation2.phpt index a05cc8332f2b..0d5271d6ec7a 100644 --- a/ext/standard/tests/array/array_diff_uassoc_variation2.phpt +++ b/ext/standard/tests/array/array_diff_uassoc_variation2.phpt @@ -31,9 +31,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_diff_ukey_variation1.phpt b/ext/standard/tests/array/array_diff_ukey_variation1.phpt index 12df1487905e..a48ad44fd1e4 100644 --- a/ext/standard/tests/array/array_diff_ukey_variation1.phpt +++ b/ext/standard/tests/array/array_diff_ukey_variation1.phpt @@ -31,9 +31,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_diff_ukey_variation2.phpt b/ext/standard/tests/array/array_diff_ukey_variation2.phpt index ee0251f177c0..d39453086df0 100644 --- a/ext/standard/tests/array/array_diff_ukey_variation2.phpt +++ b/ext/standard/tests/array/array_diff_ukey_variation2.phpt @@ -33,9 +33,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_diff_ukey_variation5.phpt b/ext/standard/tests/array/array_diff_ukey_variation5.phpt index 10946aa0ba73..97ccfaab44d3 100644 --- a/ext/standard/tests/array/array_diff_ukey_variation5.phpt +++ b/ext/standard/tests/array/array_diff_ukey_variation5.phpt @@ -12,7 +12,7 @@ echo "*** Testing array_diff_ukey() : usage variation ***\n"; // Initialise function arguments not being substituted (if any) $array1 = array( - 'first' => array('blue' => 1, 'red' => 2), + 'first' => array('blue' => 1, 'red' => 2), 'second' => array('yellow' => 7), @@ -21,7 +21,7 @@ $array1 = array( $array2 = array ( - 'first' => array('blue' => 1, 'red' => 2,), + 'first' => array('blue' => 1, 'red' => 2,), 'second' => array('cyan' => 8), diff --git a/ext/standard/tests/array/array_diff_variation1.phpt b/ext/standard/tests/array/array_diff_variation1.phpt index 5b92231642d8..765fae39cdd9 100644 --- a/ext/standard/tests/array/array_diff_variation1.phpt +++ b/ext/standard/tests/array/array_diff_variation1.phpt @@ -73,7 +73,7 @@ $inputs = array( // binary data /*21*/ b"binary", - (binary)"binary", + (binary)"binary", // object data /*23*/ new classA(), diff --git a/ext/standard/tests/array/array_diff_variation2.phpt b/ext/standard/tests/array/array_diff_variation2.phpt index a9ddb22b8233..0bceeea1f043 100644 --- a/ext/standard/tests/array/array_diff_variation2.phpt +++ b/ext/standard/tests/array/array_diff_variation2.phpt @@ -73,7 +73,7 @@ $inputs = array( // binary data /*21*/ b"binary", - (binary)"binary", + (binary)"binary", // object data /*23*/ new classA(), diff --git a/ext/standard/tests/array/array_diff_variation3.phpt b/ext/standard/tests/array/array_diff_variation3.phpt index b7c842f21b7d..073d6ca5c9f0 100644 --- a/ext/standard/tests/array/array_diff_variation3.phpt +++ b/ext/standard/tests/array/array_diff_variation3.phpt @@ -80,7 +80,7 @@ $values = array( "binary" => array( // binary data b"binary", - (binary)"binary"), + (binary)"binary"), /*9*/ "undefined" => array( diff --git a/ext/standard/tests/array/array_diff_variation4.phpt b/ext/standard/tests/array/array_diff_variation4.phpt index 3b02c21b36c1..07bb7293bccb 100644 --- a/ext/standard/tests/array/array_diff_variation4.phpt +++ b/ext/standard/tests/array/array_diff_variation4.phpt @@ -80,7 +80,7 @@ $values = array( "binary" => array( // binary data b"binary", - (binary)"binary"), + (binary)"binary"), /*9*/ "undefined" => array( diff --git a/ext/standard/tests/array/array_fill.phpt b/ext/standard/tests/array/array_fill.phpt index 2c90402fe8d9..4f2aa41b0176 100644 --- a/ext/standard/tests/array/array_fill.phpt +++ b/ext/standard/tests/array/array_fill.phpt @@ -11,9 +11,9 @@ foreach($array1 as $start) foreach($array2 as $value) { echo '==========================='."\n"; - echo 'start: '.$start.' num: '.$num.' value: '.$value."\n"; - $output = array_fill($start, $num, $value); - var_dump($output); + echo 'start: '.$start.' num: '.$num.' value: '.$value."\n"; + $output = array_fill($start, $num, $value); + var_dump($output); } } } diff --git a/ext/standard/tests/array/array_fill_keys.phpt b/ext/standard/tests/array/array_fill_keys.phpt index fb222a414bae..eebfd0aafd90 100644 --- a/ext/standard/tests/array/array_fill_keys.phpt +++ b/ext/standard/tests/array/array_fill_keys.phpt @@ -4,10 +4,10 @@ basic array_fill_keys test precision=14 --FILE-- --EXPECT-- array(0) { diff --git a/ext/standard/tests/array/array_filter_variation10.phpt b/ext/standard/tests/array/array_filter_variation10.phpt index a32fdadc05ff..265daf1fb4bc 100644 --- a/ext/standard/tests/array/array_filter_variation10.phpt +++ b/ext/standard/tests/array/array_filter_variation10.phpt @@ -35,9 +35,9 @@ var_dump( array_filter($input, 'dump2', true) ); echo "*** Testing array_filter() : usage variations - 'callback' expecting second argument ***\n"; try { - var_dump( array_filter($small, 'dump', false) ); + var_dump( array_filter($small, 'dump', false) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "*** Testing array_filter() with various use types ***\n"; diff --git a/ext/standard/tests/array/array_intersect_1.phpt b/ext/standard/tests/array/array_intersect_1.phpt index ce8fdd1cac01..518dfd392f46 100644 --- a/ext/standard/tests/array/array_intersect_1.phpt +++ b/ext/standard/tests/array/array_intersect_1.phpt @@ -4,27 +4,27 @@ Test of the *intersect* bunch of functions (both assoc and non-assoc) priv_member = $val; - $this->public_member = $val; - } - static function comp_func_cr($a, $b) { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } + private $priv_member; + public $public_member; + function __construct($val) { + $this->priv_member = $val; + $this->public_member = $val; + } + static function comp_func_cr($a, $b) { + if ($a->priv_member === $b->priv_member) return 0; + return ($a->priv_member > $b->priv_member)? 1:-1; + } } function comp_func($a, $b) { - if ($a === $b) return 0; - return ($a > $b)? 1:-1; + if ($a === $b) return 0; + return ($a > $b)? 1:-1; } function comp_func_cr($a, $b) { - if ($a->public_member === $b->public_member) return 0; - return ($a->public_member > $b->public_member)? 1:-1; + if ($a->public_member === $b->public_member) return 0; + return ($a->public_member > $b->public_member)? 1:-1; } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); diff --git a/ext/standard/tests/array/array_intersect_key_variation1.phpt b/ext/standard/tests/array/array_intersect_key_variation1.phpt index 198cb1dfc6cb..fc1d858516ef 100644 --- a/ext/standard/tests/array/array_intersect_key_variation1.phpt +++ b/ext/standard/tests/array/array_intersect_key_variation1.phpt @@ -23,9 +23,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_intersect_key_variation2.phpt b/ext/standard/tests/array/array_intersect_key_variation2.phpt index c178480fcacb..bae7600b9d89 100644 --- a/ext/standard/tests/array/array_intersect_key_variation2.phpt +++ b/ext/standard/tests/array/array_intersect_key_variation2.phpt @@ -23,9 +23,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_intersect_key_variation8.phpt b/ext/standard/tests/array/array_intersect_key_variation8.phpt index 892863991a01..faa56eeb3d42 100644 --- a/ext/standard/tests/array/array_intersect_key_variation8.phpt +++ b/ext/standard/tests/array/array_intersect_key_variation8.phpt @@ -12,7 +12,7 @@ echo "*** Testing array_intersect_key() : usage variation ***\n"; /// Initialise function arguments not being substituted (if any) $array1 = array( - 'first' => array('blue' => 1, 'red' => 2), + 'first' => array('blue' => 1, 'red' => 2), 'second' => array('yellow' => 7), @@ -21,7 +21,7 @@ $array1 = array( $array2 = array ( - 'first' => array('blue' => 1, 'red' => 2,), + 'first' => array('blue' => 1, 'red' => 2,), 'second' => array('cyan' => 8), diff --git a/ext/standard/tests/array/array_intersect_uassoc_variation1.phpt b/ext/standard/tests/array/array_intersect_uassoc_variation1.phpt index a26a5d99ec2d..c663269b2a81 100644 --- a/ext/standard/tests/array/array_intersect_uassoc_variation1.phpt +++ b/ext/standard/tests/array/array_intersect_uassoc_variation1.phpt @@ -31,9 +31,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_intersect_uassoc_variation10.phpt b/ext/standard/tests/array/array_intersect_uassoc_variation10.phpt index d8accf288676..c7ef8174f1b8 100644 --- a/ext/standard/tests/array/array_intersect_uassoc_variation10.phpt +++ b/ext/standard/tests/array/array_intersect_uassoc_variation10.phpt @@ -15,13 +15,13 @@ $array2 = array("a" => "green", "yellow", "red"); // define some class with method class MyClass { - static function static_compare_func($a, $b) { - return strcasecmp($a, $b); - } + static function static_compare_func($a, $b) { + return strcasecmp($a, $b); + } - public function class_compare_func($a, $b) { - return strcasecmp($a, $b); - } + public function class_compare_func($a, $b) { + return strcasecmp($a, $b); + } } diff --git a/ext/standard/tests/array/array_intersect_uassoc_variation2.phpt b/ext/standard/tests/array/array_intersect_uassoc_variation2.phpt index 61877a0653ca..20701a5c0bf0 100644 --- a/ext/standard/tests/array/array_intersect_uassoc_variation2.phpt +++ b/ext/standard/tests/array/array_intersect_uassoc_variation2.phpt @@ -31,9 +31,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_intersect_ukey_variation1.phpt b/ext/standard/tests/array/array_intersect_ukey_variation1.phpt index 417087feca02..a02d3c03e31d 100644 --- a/ext/standard/tests/array/array_intersect_ukey_variation1.phpt +++ b/ext/standard/tests/array/array_intersect_ukey_variation1.phpt @@ -32,9 +32,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_intersect_ukey_variation2.phpt b/ext/standard/tests/array/array_intersect_ukey_variation2.phpt index f9f479915f4c..a8f01201d518 100644 --- a/ext/standard/tests/array/array_intersect_ukey_variation2.phpt +++ b/ext/standard/tests/array/array_intersect_ukey_variation2.phpt @@ -32,9 +32,9 @@ $fp = fopen(__FILE__, "r"); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_intersect_ukey_variation9.phpt b/ext/standard/tests/array/array_intersect_ukey_variation9.phpt index 09ff302a47d5..205991cd4123 100644 --- a/ext/standard/tests/array/array_intersect_ukey_variation9.phpt +++ b/ext/standard/tests/array/array_intersect_ukey_variation9.phpt @@ -15,13 +15,13 @@ $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); class MyClass { - static function static_compare_func($key1, $key2) { - return strcasecmp($key1, $key2); - } + static function static_compare_func($key1, $key2) { + return strcasecmp($key1, $key2); + } - public function class_compare_func($key1, $key2) { - return strcasecmp($key1, $key2); - } + public function class_compare_func($key1, $key2) { + return strcasecmp($key1, $key2); + } } diff --git a/ext/standard/tests/array/array_key_exists_variation3.phpt b/ext/standard/tests/array/array_key_exists_variation3.phpt index 11f0125be2c3..4a6409bb1fcc 100644 --- a/ext/standard/tests/array/array_key_exists_variation3.phpt +++ b/ext/standard/tests/array/array_key_exists_variation3.phpt @@ -21,15 +21,15 @@ $search = array ('zero', 'one', 'two'); $iterator = 1; foreach($keys as $key) { - echo "\n-- Iteration $iterator --\n"; - echo "Pass float as \$key:\n"; - try { - var_dump(array_key_exists($key, $search)); - } catch (TypeError $exception) { - echo $exception->getMessage() . "\n"; - } - echo "Cast float to int:\n"; - var_dump(array_key_exists((int)$key, $search)); + echo "\n-- Iteration $iterator --\n"; + echo "Pass float as \$key:\n"; + try { + var_dump(array_key_exists($key, $search)); + } catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; + } + echo "Cast float to int:\n"; + var_dump(array_key_exists((int)$key, $search)); } echo "Done"; diff --git a/ext/standard/tests/array/array_key_exists_variation6.phpt b/ext/standard/tests/array/array_key_exists_variation6.phpt index a801acdd3480..fb81d3277a7f 100644 --- a/ext/standard/tests/array/array_key_exists_variation6.phpt +++ b/ext/standard/tests/array/array_key_exists_variation6.phpt @@ -27,17 +27,17 @@ $array = array ('null' => null, //iterate through original array foreach($array as $name => $input) { - $iterator = 1; - echo "\n-- Key in \$search array is : $name --\n"; - $search[$input] = 'test'; + $iterator = 1; + echo "\n-- Key in \$search array is : $name --\n"; + $search[$input] = 'test'; - //iterate through array again to see which values are considered equal - foreach($array as $key) { - echo "Iteration $iterator: "; - var_dump(array_key_exists($key, $search)); - $iterator++; - } - $search = null; + //iterate through array again to see which values are considered equal + foreach($array as $key) { + echo "Iteration $iterator: "; + var_dump(array_key_exists($key, $search)); + $iterator++; + } + $search = null; } echo "Done"; diff --git a/ext/standard/tests/array/array_key_exists_variation8.phpt b/ext/standard/tests/array/array_key_exists_variation8.phpt index 1d98b0eefb6c..a52a9acdaa18 100644 --- a/ext/standard/tests/array/array_key_exists_variation8.phpt +++ b/ext/standard/tests/array/array_key_exists_variation8.phpt @@ -95,16 +95,16 @@ $inputs = array( // loop through each element of $inputs to check the behavior of array_key_exists() $iterator = 1; foreach($inputs as $type => $input) { - echo "\n-- Iteration $iterator: $type data --\n"; + echo "\n-- Iteration $iterator: $type data --\n"; - //iterate over again to get all different key values - foreach ($inputs as $new_type => $new_input) { - echo "-- \$key arguments are $new_type data:\n"; - foreach ($new_input as $key => $search) { - var_dump(array_key_exists($key, $input)); - } - } - $iterator++; + //iterate over again to get all different key values + foreach ($inputs as $new_type => $new_input) { + echo "-- \$key arguments are $new_type data:\n"; + foreach ($new_input as $key => $search) { + var_dump(array_key_exists($key, $input)); + } + } + $iterator++; }; echo "Done"; diff --git a/ext/standard/tests/array/array_keys_variation_003.phpt b/ext/standard/tests/array/array_keys_variation_003.phpt index adb2baea662d..3163820de00a 100644 --- a/ext/standard/tests/array/array_keys_variation_003.phpt +++ b/ext/standard/tests/array/array_keys_variation_003.phpt @@ -20,8 +20,8 @@ $types_arr = array( ); $values = array(TRUE, FALSE, 1, 0, -1, "1", "0", "-1", NULL, array(), "php", ""); foreach ($values as $value){ - var_dump($value); - var_dump(array_keys($types_arr, $value)); + var_dump($value); + var_dump(array_keys($types_arr, $value)); } echo "Done\n"; diff --git a/ext/standard/tests/array/array_map_001.phpt b/ext/standard/tests/array/array_map_001.phpt index c5d78c257e80..ffa56c130917 100644 --- a/ext/standard/tests/array/array_map_001.phpt +++ b/ext/standard/tests/array/array_map_001.phpt @@ -6,13 +6,13 @@ array_map() and exceptions in the callback $a = array(1,2,3); function foo() { - throw new exception(1); + throw new exception(1); } try { - array_map("foo", $a, array(2,3)); + array_map("foo", $a, array(2,3)); } catch (Exception $e) { - var_dump("exception caught!"); + var_dump("exception caught!"); } echo "Done\n"; diff --git a/ext/standard/tests/array/array_map_error.phpt b/ext/standard/tests/array/array_map_error.phpt index d15f28425eeb..4739bbf6630b 100644 --- a/ext/standard/tests/array/array_map_error.phpt +++ b/ext/standard/tests/array/array_map_error.phpt @@ -15,9 +15,9 @@ function callback1() { return 1; } try { - var_dump( array_map('callback1') ); + var_dump( array_map('callback1') ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- Testing array_map() function with less no. of arrays than callback function arguments --\n"; @@ -26,9 +26,9 @@ function callback2($p, $q) { return $p * $q; } try { - var_dump( array_map('callback2', $arr1) ); + var_dump( array_map('callback2', $arr1) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- Testing array_map() function with more no. of arrays than callback function arguments --\n"; diff --git a/ext/standard/tests/array/array_map_variation10.phpt b/ext/standard/tests/array/array_map_variation10.phpt index 184019cdf19f..d5324f3e2887 100644 --- a/ext/standard/tests/array/array_map_variation10.phpt +++ b/ext/standard/tests/array/array_map_variation10.phpt @@ -21,9 +21,9 @@ var_dump( array_map( function($a, $b) { return array($a, $b); }, $array1, $array echo "-- anonymous function with two parameters and passing one array --\n"; try { - var_dump( array_map( function($a, $b) { return array($a, $b); }, $array1)); + var_dump( array_map( function($a, $b) { return array($a, $b); }, $array1)); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "-- anonymous function with NULL parameter --\n"; diff --git a/ext/standard/tests/array/array_map_variation9.phpt b/ext/standard/tests/array/array_map_variation9.phpt index 9c70340b3086..7089f9abc69d 100644 --- a/ext/standard/tests/array/array_map_variation9.phpt +++ b/ext/standard/tests/array/array_map_variation9.phpt @@ -30,9 +30,9 @@ var_dump( array_map('callback1', $arr1) ); echo "-- checking binary safe array with two parameter callback function --\n"; try { - var_dump( array_map(b"callback2", $arr1) ); + var_dump( array_map(b"callback2", $arr1) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "Done"; diff --git a/ext/standard/tests/array/array_merge_variation3.phpt b/ext/standard/tests/array/array_merge_variation3.phpt index b8444ffb0918..1b15153c7faf 100644 --- a/ext/standard/tests/array/array_merge_variation3.phpt +++ b/ext/standard/tests/array/array_merge_variation3.phpt @@ -42,7 +42,7 @@ $inputs = array( // int data /*1*/ 'int' => array( - 0, + 0, 1, 12345, -2345, diff --git a/ext/standard/tests/array/array_multisort_case.phpt b/ext/standard/tests/array/array_multisort_case.phpt index e56d297e49cd..39d9280c28cf 100644 --- a/ext/standard/tests/array/array_multisort_case.phpt +++ b/ext/standard/tests/array/array_multisort_case.phpt @@ -11,23 +11,23 @@ Test array_multisort() function : case-sensitive echo "*** Testing array_multisort() : case-sensitive\n"; $a = array( - 'Second', - 'First.1', - 'First.2', - 'First.3', - 'Twentieth', - 'Tenth', - 'Third', + 'Second', + 'First.1', + 'First.2', + 'First.3', + 'Twentieth', + 'Tenth', + 'Third', ); $b = array( - '2 a', - '1 bb 1', - '1 bB 2', - '1 BB 3', - '20 c', - '10 d', - '3 e', + '2 a', + '1 bb 1', + '1 bB 2', + '1 BB 3', + '20 c', + '10 d', + '3 e', ); array_multisort($b, SORT_STRING, $a); diff --git a/ext/standard/tests/array/array_multisort_incase.phpt b/ext/standard/tests/array/array_multisort_incase.phpt index 4799d8bcb5d7..98be7d06bcf6 100644 --- a/ext/standard/tests/array/array_multisort_incase.phpt +++ b/ext/standard/tests/array/array_multisort_incase.phpt @@ -11,23 +11,23 @@ Test array_multisort() function : case-insensitive echo "*** Testing array_multisort() : case-insensitive\n"; $a = array( - 'Second', - 'First.1', - 'First.2', - 'First.3', - 'Twentieth', - 'Tenth', - 'Third', + 'Second', + 'First.1', + 'First.2', + 'First.3', + 'Twentieth', + 'Tenth', + 'Third', ); $b = array( - '2 a', - '1 bb 1', - '1 bB 2', - '1 BB 3', - '20 c', - '10 d', - '3 e', + '2 a', + '1 bb 1', + '1 bB 2', + '1 BB 3', + '20 c', + '10 d', + '3 e', ); array_multisort($b, SORT_STRING | SORT_FLAG_CASE, $a); diff --git a/ext/standard/tests/array/array_multisort_natural.phpt b/ext/standard/tests/array/array_multisort_natural.phpt index 27b22a799d7b..f56c1b00a22e 100644 --- a/ext/standard/tests/array/array_multisort_natural.phpt +++ b/ext/standard/tests/array/array_multisort_natural.phpt @@ -11,19 +11,19 @@ Test array_multisort() function : natural sorting echo "*** Testing array_multisort() : natural sorting\n"; $a = array( - 'Second', - 'First', - 'Twentieth', - 'Tenth', - 'Third', + 'Second', + 'First', + 'Twentieth', + 'Tenth', + 'Third', ); $b = array( - '2 a', - '1 b', - '20 c', - '10 d', - '3 e', + '2 a', + '1 b', + '20 c', + '10 d', + '3 e', ); array_multisort($b, SORT_NATURAL, $a); diff --git a/ext/standard/tests/array/array_multisort_natural_case.phpt b/ext/standard/tests/array/array_multisort_natural_case.phpt index 75db1565dff0..fc4221997216 100644 --- a/ext/standard/tests/array/array_multisort_natural_case.phpt +++ b/ext/standard/tests/array/array_multisort_natural_case.phpt @@ -11,23 +11,23 @@ Test array_multisort() function : natural sorting case-sensitive echo "*** Testing array_multisort() : natural sorting case-sensitive\n"; $a = array( - 'Second', - 'First.1', - 'First.2', - 'First.3', - 'Twentieth', - 'Tenth', - 'Third', + 'Second', + 'First.1', + 'First.2', + 'First.3', + 'Twentieth', + 'Tenth', + 'Third', ); $b = array( - '2 a', - '1 bb 1', - '1 bB 2', - '1 BB 3', - '20 c', - '10 d', - '3 e', + '2 a', + '1 bb 1', + '1 bB 2', + '1 BB 3', + '20 c', + '10 d', + '3 e', ); array_multisort($b, SORT_NATURAL, $a); diff --git a/ext/standard/tests/array/array_multisort_natural_incase.phpt b/ext/standard/tests/array/array_multisort_natural_incase.phpt index b603dd57a442..0b12bf776d16 100644 --- a/ext/standard/tests/array/array_multisort_natural_incase.phpt +++ b/ext/standard/tests/array/array_multisort_natural_incase.phpt @@ -11,23 +11,23 @@ Test array_multisort() function : natural sorting case-insensitive echo "*** Testing array_multisort() : natural sorting case-insensitive\n"; $a = array( - 'Second', - 'First.1', - 'First.2', - 'First.3', - 'Twentieth', - 'Tenth', - 'Third', + 'Second', + 'First.1', + 'First.2', + 'First.3', + 'Twentieth', + 'Tenth', + 'Third', ); $b = array( - '2 a', - '1 bb 1', - '1 bB 2', - '1 BB 3', - '20 c', - '10 d', - '3 e', + '2 a', + '1 bb 1', + '1 bB 2', + '1 BB 3', + '20 c', + '10 d', + '3 e', ); array_multisort($b, SORT_NATURAL | SORT_FLAG_CASE, $a); diff --git a/ext/standard/tests/array/array_multisort_variation1.phpt b/ext/standard/tests/array/array_multisort_variation1.phpt index a9126804216b..4cedadf07122 100644 --- a/ext/standard/tests/array/array_multisort_variation1.phpt +++ b/ext/standard/tests/array/array_multisort_variation1.phpt @@ -12,10 +12,10 @@ echo "*** Testing array_multisort() : usage variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -28,9 +28,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_multisort_variation2.phpt b/ext/standard/tests/array/array_multisort_variation2.phpt index f28988ecfae9..4900b838ae93 100644 --- a/ext/standard/tests/array/array_multisort_variation2.phpt +++ b/ext/standard/tests/array/array_multisort_variation2.phpt @@ -12,10 +12,10 @@ echo "*** Testing array_multisort() : usage variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -30,9 +30,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_multisort_variation3.phpt b/ext/standard/tests/array/array_multisort_variation3.phpt index 07669d7fd254..02883e87d14d 100644 --- a/ext/standard/tests/array/array_multisort_variation3.phpt +++ b/ext/standard/tests/array/array_multisort_variation3.phpt @@ -12,10 +12,10 @@ echo "*** Testing array_multisort() : usage variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -29,9 +29,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_multisort_variation7.phpt b/ext/standard/tests/array/array_multisort_variation7.phpt index f073cd5df26c..7ad9bd72a7e2 100644 --- a/ext/standard/tests/array/array_multisort_variation7.phpt +++ b/ext/standard/tests/array/array_multisort_variation7.phpt @@ -12,9 +12,9 @@ echo "*** Testing array_multisort() : usage variation - test sort order of all // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString { } diff --git a/ext/standard/tests/array/array_multisort_variation8.phpt b/ext/standard/tests/array/array_multisort_variation8.phpt index f0ef3e0dd504..5658e12420a3 100644 --- a/ext/standard/tests/array/array_multisort_variation8.phpt +++ b/ext/standard/tests/array/array_multisort_variation8.phpt @@ -12,15 +12,15 @@ echo "*** Testing array_multisort() : usage variation - test sort order of all // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - // We're testing sort order not errors so ignore. + // We're testing sort order not errors so ignore. } set_error_handler('test_error_handler'); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString { } diff --git a/ext/standard/tests/array/array_multisort_variation9.phpt b/ext/standard/tests/array/array_multisort_variation9.phpt index a5d689cc872d..63f42f407de6 100644 --- a/ext/standard/tests/array/array_multisort_variation9.phpt +++ b/ext/standard/tests/array/array_multisort_variation9.phpt @@ -12,9 +12,9 @@ echo "*** Testing array_multisort() : usage variation - test sort order of all // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString { } diff --git a/ext/standard/tests/array/array_reduce_variation1.phpt b/ext/standard/tests/array/array_reduce_variation1.phpt index 34c2856bac5c..6b1d21e04693 100644 --- a/ext/standard/tests/array/array_reduce_variation1.phpt +++ b/ext/standard/tests/array/array_reduce_variation1.phpt @@ -26,9 +26,9 @@ var_dump(array_reduce($array, "oneArg", 2)); echo "\n--- Testing with a callback with too many parameters ---\n"; try { - var_dump(array_reduce($array, "threeArgs", 2)); + var_dump(array_reduce($array, "threeArgs", 2)); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } ?> diff --git a/ext/standard/tests/array/array_replace.phpt b/ext/standard/tests/array/array_replace.phpt index 48b616ab04ee..c3edba008c6f 100644 --- a/ext/standard/tests/array/array_replace.phpt +++ b/ext/standard/tests/array/array_replace.phpt @@ -4,26 +4,26 @@ Test array_replace and array_replace_recursive 'dontclobber', - '1' => 'unclobbered', - 'test2' => 0.0, - 'test3' => array( - 'testarray2' => true, - 1 => array( - 'testsubarray1' => 'dontclobber2', - 'testsubarray2' => 'dontclobber3', - ), + 0 => 'dontclobber', + '1' => 'unclobbered', + 'test2' => 0.0, + 'test3' => array( + 'testarray2' => true, + 1 => array( + 'testsubarray1' => 'dontclobber2', + 'testsubarray2' => 'dontclobber3', + ), ), ); $array2 = array( - 1 => 'clobbered', - 'test3' => array( - 'testarray2' => false, - ), - 'test4' => array( - 'clobbered3' => array(0, 1, 2), - ), + 1 => 'clobbered', + 'test3' => array( + 'testarray2' => false, + ), + 'test4' => array( + 'clobbered3' => array(0, 1, 2), + ), ); $array3 = array(array(array(array()))); diff --git a/ext/standard/tests/array/array_shift_variation2.phpt b/ext/standard/tests/array/array_shift_variation2.phpt index 9e37cbb20457..fae2e06e0f46 100644 --- a/ext/standard/tests/array/array_shift_variation2.phpt +++ b/ext/standard/tests/array/array_shift_variation2.phpt @@ -39,7 +39,7 @@ $inputs = array( // int data /*1*/ 'int' => array( - 0, + 0, 1, 12345, -2345, diff --git a/ext/standard/tests/array/array_slice_variation5.phpt b/ext/standard/tests/array/array_slice_variation5.phpt index 5f127fd2eba5..06f79c7168bc 100644 --- a/ext/standard/tests/array/array_slice_variation5.phpt +++ b/ext/standard/tests/array/array_slice_variation5.phpt @@ -16,8 +16,8 @@ echo "*** Testing array_slice() : usage variations ***\n"; $input = array ('one' => 1, 2 => 'two', 'three', 9 => 'nine', 'ten' => 10); for ($i = -7; $i <= 7; $i++) { - echo "\n-- \$offset is $i --\n"; - var_dump(array_slice($input, $i)); + echo "\n-- \$offset is $i --\n"; + var_dump(array_slice($input, $i)); } echo "\n-- \$offset is maximum integer value --\n"; var_dump(array_slice($input, PHP_INT_MAX)); diff --git a/ext/standard/tests/array/array_slice_variation6.phpt b/ext/standard/tests/array/array_slice_variation6.phpt index 86bde4ae3cab..b54cd1a16bef 100644 --- a/ext/standard/tests/array/array_slice_variation6.phpt +++ b/ext/standard/tests/array/array_slice_variation6.phpt @@ -17,8 +17,8 @@ $input = array ('one' => 1, 2 => 'two', 'three', 9 => 'nine', 'ten' => 10); $offset = 1; for ($i = -6; $i <= 6; $i++) { - echo "\n-- \$length is $i --\n"; - var_dump(array_slice($input, $offset, $i)); + echo "\n-- \$length is $i --\n"; + var_dump(array_slice($input, $offset, $i)); } echo "\n-- \$length is maximum integer value --\n"; var_dump(array_slice($input, $offset, PHP_INT_MAX)); diff --git a/ext/standard/tests/array/array_splice_variation3.phpt b/ext/standard/tests/array/array_splice_variation3.phpt index b5a55ca14430..d5f76ac805c4 100644 --- a/ext/standard/tests/array/array_splice_variation3.phpt +++ b/ext/standard/tests/array/array_splice_variation3.phpt @@ -12,14 +12,14 @@ echo "*** array_splice() function : usage variations - lengths and offsets\n"; function test_splice ($offset, $length) { - echo " - No replacement\n"; - $input_array=array(0,1,2,3,4,5); - var_dump (array_splice ($input_array,$offset,$length)); - var_dump ($input_array); + echo " - No replacement\n"; + $input_array=array(0,1,2,3,4,5); + var_dump (array_splice ($input_array,$offset,$length)); + var_dump ($input_array); echo " - With replacement\n"; $input_array=array(0,1,2,3,4,5); var_dump (array_splice ($input_array,$offset,$length,array ("A","B","C"))); - var_dump ($input_array); + var_dump ($input_array); } echo "absolute offset - absolute length - cut from beginning\n"; diff --git a/ext/standard/tests/array/array_splice_variation4.phpt b/ext/standard/tests/array/array_splice_variation4.phpt index ddd966780e68..06eecdf00566 100644 --- a/ext/standard/tests/array/array_splice_variation4.phpt +++ b/ext/standard/tests/array/array_splice_variation4.phpt @@ -9,9 +9,9 @@ Test array_splice() function : usage variations - non array replacement values function test_splice ($replacement) { - $input_array=array(0,1); - var_dump (array_splice ($input_array,2,0,$replacement)); - var_dump ($input_array); + $input_array=array(0,1); + var_dump (array_splice ($input_array,2,0,$replacement)); + var_dump ($input_array); } test_splice (2); diff --git a/ext/standard/tests/array/array_sum.phpt b/ext/standard/tests/array/array_sum.phpt index 08aec2155ea7..9ba80beba687 100644 --- a/ext/standard/tests/array/array_sum.phpt +++ b/ext/standard/tests/array/array_sum.phpt @@ -7,8 +7,8 @@ memory_limit=128M getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- comparison function taking too few parameters --\n"; diff --git a/ext/standard/tests/array/array_udiff_uassoc_variation1.phpt b/ext/standard/tests/array/array_udiff_uassoc_variation1.phpt index dcfe07083f41..e59012cbb68f 100644 --- a/ext/standard/tests/array/array_udiff_uassoc_variation1.phpt +++ b/ext/standard/tests/array/array_udiff_uassoc_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_udiff_uassoc_variation2.phpt b/ext/standard/tests/array/array_udiff_uassoc_variation2.phpt index e15076db5f92..ee7cf405dc28 100644 --- a/ext/standard/tests/array/array_udiff_uassoc_variation2.phpt +++ b/ext/standard/tests/array/array_udiff_uassoc_variation2.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt b/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt index e6f256d79af0..2c917014caa2 100644 --- a/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt +++ b/ext/standard/tests/array/array_udiff_uassoc_variation6.phpt @@ -24,9 +24,9 @@ function too_many_parameters ($val1, $val2, $val3) { return 1; } try { - var_dump(array_udiff_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters')); + var_dump(array_udiff_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters')); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- comparison function taking too few parameters --\n"; diff --git a/ext/standard/tests/array/array_udiff_variation1.phpt b/ext/standard/tests/array/array_udiff_variation1.phpt index a90e3b0e6788..9e98bda727d4 100644 --- a/ext/standard/tests/array/array_udiff_variation1.phpt +++ b/ext/standard/tests/array/array_udiff_variation1.phpt @@ -23,9 +23,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_udiff_variation2.phpt b/ext/standard/tests/array/array_udiff_variation2.phpt index 5c37a3a20a12..28f1e8e1b146 100644 --- a/ext/standard/tests/array/array_udiff_variation2.phpt +++ b/ext/standard/tests/array/array_udiff_variation2.phpt @@ -23,9 +23,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_udiff_variation5.phpt b/ext/standard/tests/array/array_udiff_variation5.phpt index 1ca79779996f..24d1207ed4ac 100644 --- a/ext/standard/tests/array/array_udiff_variation5.phpt +++ b/ext/standard/tests/array/array_udiff_variation5.phpt @@ -25,9 +25,9 @@ function too_many_parameters ($val1, $val2, $val3) { return 0; } try { - var_dump(array_udiff($arr1, $arr2, 'too_many_parameters')); + var_dump(array_udiff($arr1, $arr2, 'too_many_parameters')); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- comparison function taking too few parameters --\n"; diff --git a/ext/standard/tests/array/array_uintersect_assoc_variation1.phpt b/ext/standard/tests/array/array_uintersect_assoc_variation1.phpt index c99a9947c536..8111006e3c95 100644 --- a/ext/standard/tests/array/array_uintersect_assoc_variation1.phpt +++ b/ext/standard/tests/array/array_uintersect_assoc_variation1.phpt @@ -23,9 +23,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_uintersect_assoc_variation2.phpt b/ext/standard/tests/array/array_uintersect_assoc_variation2.phpt index 00a50f3c2f11..5ce935321f87 100644 --- a/ext/standard/tests/array/array_uintersect_assoc_variation2.phpt +++ b/ext/standard/tests/array/array_uintersect_assoc_variation2.phpt @@ -23,9 +23,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt b/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt index 3b6befcc5e14..990a71121976 100644 --- a/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt +++ b/ext/standard/tests/array/array_uintersect_assoc_variation5.phpt @@ -24,9 +24,9 @@ function too_many_parameters ($val1, $val2, $val3) { return 1; } try { - var_dump(array_uintersect_assoc($arr1, $arr2, 'too_many_parameters')); + var_dump(array_uintersect_assoc($arr1, $arr2, 'too_many_parameters')); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- comparison function taking too few parameters --\n"; diff --git a/ext/standard/tests/array/array_uintersect_uassoc_variation1.phpt b/ext/standard/tests/array/array_uintersect_uassoc_variation1.phpt index 4889025872c1..908b39c85908 100644 --- a/ext/standard/tests/array/array_uintersect_uassoc_variation1.phpt +++ b/ext/standard/tests/array/array_uintersect_uassoc_variation1.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_uintersect_uassoc_variation2.phpt b/ext/standard/tests/array/array_uintersect_uassoc_variation2.phpt index a1d897d86e9a..c9b3e051c341 100644 --- a/ext/standard/tests/array/array_uintersect_uassoc_variation2.phpt +++ b/ext/standard/tests/array/array_uintersect_uassoc_variation2.phpt @@ -24,9 +24,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt b/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt index 5553adffb5c2..76d387d9c83a 100644 --- a/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt +++ b/ext/standard/tests/array/array_uintersect_uassoc_variation6.phpt @@ -24,9 +24,9 @@ function too_many_parameters ($val1, $val2, $val3) { return 1; } try { - var_dump(array_uintersect_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters')); + var_dump(array_uintersect_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters')); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- comparison function taking too few parameters --\n"; diff --git a/ext/standard/tests/array/array_uintersect_variation1.phpt b/ext/standard/tests/array/array_uintersect_variation1.phpt index 47534f70bcee..336ce0a169f8 100644 --- a/ext/standard/tests/array/array_uintersect_variation1.phpt +++ b/ext/standard/tests/array/array_uintersect_variation1.phpt @@ -23,9 +23,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_uintersect_variation2.phpt b/ext/standard/tests/array/array_uintersect_variation2.phpt index d79cf66c2177..851927e98b10 100644 --- a/ext/standard/tests/array/array_uintersect_variation2.phpt +++ b/ext/standard/tests/array/array_uintersect_variation2.phpt @@ -23,9 +23,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/array/array_uintersect_variation5.phpt b/ext/standard/tests/array/array_uintersect_variation5.phpt index 1996d386f178..bcfdac094b0e 100644 --- a/ext/standard/tests/array/array_uintersect_variation5.phpt +++ b/ext/standard/tests/array/array_uintersect_variation5.phpt @@ -24,9 +24,9 @@ function too_many_parameters ($val1, $val2, $val3) { return 1; } try { - var_dump(array_uintersect($arr1, $arr2, 'too_many_parameters')); + var_dump(array_uintersect($arr1, $arr2, 'too_many_parameters')); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "\n-- comparison function taking too few parameters --\n"; diff --git a/ext/standard/tests/array/array_values_variation2.phpt b/ext/standard/tests/array/array_values_variation2.phpt index 5105168c1ea7..a33414000143 100644 --- a/ext/standard/tests/array/array_values_variation2.phpt +++ b/ext/standard/tests/array/array_values_variation2.phpt @@ -38,7 +38,7 @@ $inputs = array( // int data /*1*/ 'int' => array( - 0, + 0, 1, 12345, -2345, diff --git a/ext/standard/tests/array/array_walk.phpt b/ext/standard/tests/array/array_walk.phpt index cf792bfa19a5..1f5457c9f74f 100644 --- a/ext/standard/tests/array/array_walk.phpt +++ b/ext/standard/tests/array/array_walk.phpt @@ -4,22 +4,22 @@ array_walk() tests getMessage()); + var_dump($e->getMessage()); } echo "Done\n"; diff --git a/ext/standard/tests/array/array_walk_closure.phpt b/ext/standard/tests/array/array_walk_closure.phpt index 7ac62d7484a7..6cc49cf9d373 100644 --- a/ext/standard/tests/array/array_walk_closure.phpt +++ b/ext/standard/tests/array/array_walk_closure.phpt @@ -10,8 +10,8 @@ echo "\nclosure with array\n"; $ar = ["one" => 1, "two"=>2, "three" => 3]; $user_data = ["sum" => 42]; $func = function($value, $key, &$udata) { - var_dump($udata); - $udata["sum"] += $value; + var_dump($udata); + $udata["sum"] += $value; }; var_dump(array_walk($ar, $func, $user_data)); @@ -22,8 +22,8 @@ echo "\nclosure with use\n"; $ar = ["one" => 1, "two"=>2, "three" => 3]; $user_data = ["sum" => 42]; $func = function($value, $key) use (&$user_data) { - var_dump($user_data); - $user_data["sum"] += $value; + var_dump($user_data); + $user_data["sum"] += $value; }; var_dump(array_walk($ar, $func, $user_data)); @@ -35,8 +35,8 @@ echo "\nclosure with object\n"; $ar = ["one" => 1, "two"=>2, "three" => 3]; $user_data = (object)["sum" => 42]; $func = function($value, $key, &$udata) { - var_dump($udata); - $udata->sum += $value; + var_dump($udata); + $udata->sum += $value; }; var_dump(array_walk($ar, $func, $user_data)); @@ -48,8 +48,8 @@ var_dump($user_data->sum); echo "\nfunction with object\n"; function sum_it_up_object($value, $key, $udata) { - var_dump($udata); - $udata->sum += $value; + var_dump($udata); + $udata->sum += $value; } $ar = ["one" => 1, "two"=>2, "three" => 3]; @@ -63,8 +63,8 @@ var_dump($user_data->sum); echo "\nfunction with array\n"; function sum_it_up_array($value, $key, $udata) { - var_dump($udata); - $udata['sum'] += $value; + var_dump($udata); + $udata['sum'] += $value; } $ar = ["one" => 1, "two"=>2, "three" => 3]; @@ -77,9 +77,9 @@ var_dump($user_data['sum']); echo "\nclosure and exception\n"; $ar = ["one" => 1, "two"=>2, "three" => 3]; try { - var_dump(array_walk($ar, function($v, $k) { if ($v == 2) throw new Exception; } )); + var_dump(array_walk($ar, function($v, $k) { if ($v == 2) throw new Exception; } )); } catch (Exception $e) { - var_dump($e->getTrace()); + var_dump($e->getTrace()); } diff --git a/ext/standard/tests/array/array_walk_error2.phpt b/ext/standard/tests/array/array_walk_error2.phpt index 73445892a6dd..dfc95d3af8b7 100644 --- a/ext/standard/tests/array/array_walk_error2.phpt +++ b/ext/standard/tests/array/array_walk_error2.phpt @@ -23,33 +23,33 @@ echo "*** Testing array_walk() : error conditions - callback parameters ***\n"; // expected: Missing argument Warning try { - var_dump( array_walk($input, "callback1") ); + var_dump( array_walk($input, "callback1") ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump( array_walk($input, "callback2", 4) ); + var_dump( array_walk($input, "callback2", 4) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } // expected: Warning is suppressed try { - var_dump( @array_walk($input, "callback1") ); + var_dump( @array_walk($input, "callback1") ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump( @array_walk($input, "callback2", 4) ); + var_dump( @array_walk($input, "callback2", 4) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "-- Testing array_walk() function with too many callback parameters --\n"; try { - var_dump( array_walk($input, "callback1", 20, 10) ); + var_dump( array_walk($input, "callback1", 20, 10) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "Done"; diff --git a/ext/standard/tests/array/array_walk_objects.phpt b/ext/standard/tests/array/array_walk_objects.phpt index 9f3ac8c1cd66..a4a517746d03 100644 --- a/ext/standard/tests/array/array_walk_objects.phpt +++ b/ext/standard/tests/array/array_walk_objects.phpt @@ -4,13 +4,13 @@ array_walk() and objects getMessage()); + var_dump($e->getMessage()); } echo "Done\n"; diff --git a/ext/standard/tests/array/array_walk_recursive_error2.phpt b/ext/standard/tests/array/array_walk_recursive_error2.phpt index e9bd7ea1758d..f1686d7acdc2 100644 --- a/ext/standard/tests/array/array_walk_recursive_error2.phpt +++ b/ext/standard/tests/array/array_walk_recursive_error2.phpt @@ -23,33 +23,33 @@ echo "*** Testing array_walk_recursive() : error conditions - callback parameter // expected: Missing argument Warning try { - var_dump( array_walk_recursive($input, "callback1") ); + var_dump( array_walk_recursive($input, "callback1") ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump( array_walk_recursive($input, "callback2", 4) ); + var_dump( array_walk_recursive($input, "callback2", 4) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } // expected: Warning is suppressed try { - var_dump( @array_walk_recursive($input, "callback1") ); + var_dump( @array_walk_recursive($input, "callback1") ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } try { - var_dump( @array_walk_recursive($input, "callback2", 4) ); + var_dump( @array_walk_recursive($input, "callback2", 4) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "-- Testing array_walk_recursive() function with too many callback parameters --\n"; try { - var_dump( array_walk_recursive($input, "callback1", 20, 10) ); + var_dump( array_walk_recursive($input, "callback1", 20, 10) ); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo "Exception: " . $e->getMessage() . "\n"; } echo "Done"; diff --git a/ext/standard/tests/array/arsort_basic.phpt b/ext/standard/tests/array/arsort_basic.phpt index afd8bb8f4917..7ed285aac779 100644 --- a/ext/standard/tests/array/arsort_basic.phpt +++ b/ext/standard/tests/array/arsort_basic.phpt @@ -21,9 +21,9 @@ echo "*** Testing arsort() : basic functionality ***\n"; // an array containing unsorted string values with indices $unsorted_strings = array( - "l" => "lemon", "o" => "orange", - "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", - "b" => "banana", + "l" => "lemon", "o" => "orange", + "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", + "b" => "banana", ); // an array containing unsorted numeric values with indices $unsorted_numerics = array( 1 => 100, 2 => 33, 3 => 555, 4 => 22 ); diff --git a/ext/standard/tests/array/asort_basic.phpt b/ext/standard/tests/array/asort_basic.phpt index c0ae2bc88d90..8b4a7c20811f 100644 --- a/ext/standard/tests/array/asort_basic.phpt +++ b/ext/standard/tests/array/asort_basic.phpt @@ -21,9 +21,9 @@ echo "*** Testing asort() : basic functionality ***\n"; // an array containing unsorted string values with indices $unsorted_strings = array( - "l" => "lemon", "o" => "orange", - "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", - "b" => "banana", + "l" => "lemon", "o" => "orange", + "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", + "b" => "banana", ); // an array containing unsorted numeric values with indices $unsorted_numerics = array( 1 => 100, 2 => 33, 3 => 555, 4 => 22 ); diff --git a/ext/standard/tests/array/bug12776.phpt b/ext/standard/tests/array/bug12776.phpt index 54c6f6fceb46..957832b97e18 100644 --- a/ext/standard/tests/array/bug12776.phpt +++ b/ext/standard/tests/array/bug12776.phpt @@ -5,10 +5,10 @@ Bug #12776 (array_walk crash) function test($val,$key) { - global $globalArray; - $globalArray[]=$key; // this will end up crashing - $globalArray[]=(string)$key; // this will end up OK - print "val: $val; key: $key\n"; flush(); + global $globalArray; + $globalArray[]=$key; // this will end up crashing + $globalArray[]=(string)$key; // this will end up OK + print "val: $val; key: $key\n"; flush(); } $arr=array('k'=>'v'); diff --git a/ext/standard/tests/array/bug14580.phpt b/ext/standard/tests/array/bug14580.phpt index 1cf27f22d662..8f4c7d5bd397 100644 --- a/ext/standard/tests/array/bug14580.phpt +++ b/ext/standard/tests/array/bug14580.phpt @@ -2,10 +2,10 @@ Bug #14580 (key() not binary safe) --FILE-- "foo\0bar"); - $key = key($arr); - echo strlen($key), ': '; - echo urlencode($key), "\n"; + $arr = array ("foo\0bar" => "foo\0bar"); + $key = key($arr); + echo strlen($key), ': '; + echo urlencode($key), "\n"; ?> --EXPECT-- 7: foo%00bar diff --git a/ext/standard/tests/array/bug20381.phpt b/ext/standard/tests/array/bug20381.phpt index 1adaa863b746..0da52d9fd99d 100644 --- a/ext/standard/tests/array/bug20381.phpt +++ b/ext/standard/tests/array/bug20381.phpt @@ -3,20 +3,20 @@ Bug #20381 (array_merge_recursive mangles input arrays) --FILE-- 1, - 'a2' => array( 1, 2, 3 ), - 'a3' => array( - 'a' => array( 10, 20, 30 ), - 'b' => 'b' - ) - ); + 'a1' => 1, + 'a2' => array( 1, 2, 3 ), + 'a3' => array( + 'a' => array( 10, 20, 30 ), + 'b' => 'b' + ) + ); $b = array( 'a1' => 2, - 'a2' => array( 3, 4, 5 ), - 'a3' => array( - 'c' => 'cc', - 'a' => array( 10, 40 ) - ) - ); + 'a2' => array( 3, 4, 5 ), + 'a3' => array( + 'c' => 'cc', + 'a' => array( 10, 40 ) + ) + ); var_dump($a); array_merge_recursive( $a, $b ); diff --git a/ext/standard/tests/array/bug20865.phpt b/ext/standard/tests/array/bug20865.phpt index f1edbabab5ab..6dfad2bcec05 100644 --- a/ext/standard/tests/array/bug20865.phpt +++ b/ext/standard/tests/array/bug20865.phpt @@ -2,10 +2,10 @@ Bug #20865 (array_key_exists and NULL key) --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/array/bug21918.phpt b/ext/standard/tests/array/bug21918.phpt index 8e440baf8c9f..e855aacd7e7e 100644 --- a/ext/standard/tests/array/bug21918.phpt +++ b/ext/standard/tests/array/bug21918.phpt @@ -7,8 +7,8 @@ echo "==Mixed==\n"; $a = array(-1=>'a', '-2'=>'b', 3=>'c', '4'=>'d', 5=>'e', '6001'=>'f', '07'=>'g'); foreach($a as $k => $v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } echo "==Normal==\n"; @@ -16,16 +16,16 @@ $b = array(); $b[] = 'a'; foreach($b as $k => $v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } echo "==Negative==\n"; $c = array('-2' => 'a'); foreach($c as $k => $v) { - var_dump($k); - var_dump($v); + var_dump($k); + var_dump($v); } ?> diff --git a/ext/standard/tests/array/bug22463.phpt b/ext/standard/tests/array/bug22463.phpt index 7993ac2576a0..434c2b6e2360 100644 --- a/ext/standard/tests/array/bug22463.phpt +++ b/ext/standard/tests/array/bug22463.phpt @@ -4,23 +4,23 @@ Bug #22463 (array_reduce() segfaults) --EXPECT-- array(2) { diff --git a/ext/standard/tests/array/bug24980.phpt b/ext/standard/tests/array/bug24980.phpt index 6c97562f6ce8..829e156afd78 100644 --- a/ext/standard/tests/array/bug24980.phpt +++ b/ext/standard/tests/array/bug24980.phpt @@ -5,9 +5,9 @@ Bug #24980 (array_reduce() uses first element as default running total) /* test #1: numeric data */ function add_up($running_total, $current_value) { - echo "running_total is ".(int)$running_total.", current_value is {$current_value}\n"; - $running_total += $current_value * $current_value; - return $running_total; + echo "running_total is ".(int)$running_total.", current_value is {$current_value}\n"; + $running_total += $current_value * $current_value; + return $running_total; } $numbers = array (2,3,5,7); @@ -18,20 +18,20 @@ print "Total is $total\n"; $a = array("a", "b", "c"); function foo ($a, $b) { - return $a . $b; + return $a . $b; } var_dump(array_reduce($a, "foo")); /* test #3: basic test (used to leak memory) */ function rsum($v, $w) { - $v += $w; - return $v; + $v += $w; + return $v; } function rmul($v, $w) { - $v *= $w; - return $v; + $v *= $w; + return $v; } $a = array(1, 2, 3, 4, 5); $x = array(); diff --git a/ext/standard/tests/array/bug25708.phpt b/ext/standard/tests/array/bug25708.phpt index ff8b9f4304a6..0e695b69c973 100644 --- a/ext/standard/tests/array/bug25708.phpt +++ b/ext/standard/tests/array/bug25708.phpt @@ -3,55 +3,55 @@ Bug #25708 (extract($GLOBALS, EXTR_REFS) mangles $GLOBALS) --FILE-- array("quote'")); - echo var_export($a, true); + $a = array ("quote'" => array("quote'")); + echo var_export($a, true); ?> --EXPECT-- array ( diff --git a/ext/standard/tests/array/bug29493.phpt b/ext/standard/tests/array/bug29493.phpt index 0cfe45910bed..30a7c058c282 100644 --- a/ext/standard/tests/array/bug29493.phpt +++ b/ext/standard/tests/array/bug29493.phpt @@ -4,68 +4,68 @@ Bug #29493 (extract(EXTR_REFS) fails if array has multiple referrals) 'aaa'); - // refcount($a) = 1 - // refcount($a['foo']) = 1 - $b = $a; - // refcount($a) = 2 - // refcount($a['foo']) = 1 - $b['foo'] = 'bbb'; - // refcount($a) = 1 - // refcount($a['foo']) = 1 + $a = array('foo' => 'aaa'); + // refcount($a) = 1 + // refcount($a['foo']) = 1 + $b = $a; + // refcount($a) = 2 + // refcount($a['foo']) = 1 + $b['foo'] = 'bbb'; + // refcount($a) = 1 + // refcount($a['foo']) = 1 - var_dump($a, $b); + var_dump($a, $b); - extract($a, EXTR_REFS); + extract($a, EXTR_REFS); - $foo = 'noo'; + $foo = 'noo'; - var_dump($a, $b); + var_dump($a, $b); } function t2() { - $a = array('foo' => 'aaa'); - // refcount($a) = 1 - // refcount($a['foo']) = 1 - $b = &$a; - // refcount($a) = 2 - // is_ref($a) = true - // refcount($a['foo']) = 1 - $b['foo'] = 'bbb'; - // refcount($a) = 2 - // refcount($a['foo']) = 1 + $a = array('foo' => 'aaa'); + // refcount($a) = 1 + // refcount($a['foo']) = 1 + $b = &$a; + // refcount($a) = 2 + // is_ref($a) = true + // refcount($a['foo']) = 1 + $b['foo'] = 'bbb'; + // refcount($a) = 2 + // refcount($a['foo']) = 1 - var_dump($a, $b); + var_dump($a, $b); - extract($a, EXTR_REFS); + extract($a, EXTR_REFS); - $foo = 'noo'; + $foo = 'noo'; - var_dump($a, $b); + var_dump($a, $b); } function t3() { - $a = array('foo' => 'aaa'); - // refcount($a) = 1 - // refcount($a['foo']) = 1 - $b = &$a; - // refcount($a) = 2 - // is_ref($a) = true - // refcount($a['foo']) = 1 - unset($b); - // refcount($a) = 1 - // is_ref($a) = true - // refcount($a['foo']) = 1 + $a = array('foo' => 'aaa'); + // refcount($a) = 1 + // refcount($a['foo']) = 1 + $b = &$a; + // refcount($a) = 2 + // is_ref($a) = true + // refcount($a['foo']) = 1 + unset($b); + // refcount($a) = 1 + // is_ref($a) = true + // refcount($a['foo']) = 1 - var_dump($a); + var_dump($a); - extract($a, EXTR_REFS); + extract($a, EXTR_REFS); - $foo = 'noo'; + $foo = 'noo'; - var_dump($a); + var_dump($a); } t1(); diff --git a/ext/standard/tests/array/bug30266.phpt b/ext/standard/tests/array/bug30266.phpt index 0a196c0cb8fa..2579714ae70f 100644 --- a/ext/standard/tests/array/bug30266.phpt +++ b/ext/standard/tests/array/bug30266.phpt @@ -4,13 +4,13 @@ Bug #30266 (Invalid opcode 137/1/8) and array_walk b = $val; - throw new Exception("Error"); - } + function crash($val) + { + $this->b = $val; + throw new Exception("Error"); + } } $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); @@ -19,16 +19,16 @@ $myobj = new testc(); function test($item2, $key, $userd) { - $userd->crash($item2); + $userd->crash($item2); } try { - array_walk($fruits, 'test', $myobj); + array_walk($fruits, 'test', $myobj); } catch(Exception $e) { - echo "Caught: " . $e->getMessage() . "\n"; + echo "Caught: " . $e->getMessage() . "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/array/bug31213.phpt b/ext/standard/tests/array/bug31213.phpt index 6aa31d5e0ef0..829c657d1e3d 100644 --- a/ext/standard/tests/array/bug31213.phpt +++ b/ext/standard/tests/array/bug31213.phpt @@ -3,27 +3,27 @@ Bug #31213 (Sideeffects caused by bug #29493) --FILE-- $a, - '_b' => &$b - ); + $arr = array( + '_a' => $a, + '_b' => &$b + ); - var_dump($a, $b); + var_dump($a, $b); - if ($use_extract) { - extract($arr, EXTR_REFS); - } else { - $_a = &$arr['_a']; - $_b = &$arr['_b']; - } + if ($use_extract) { + extract($arr, EXTR_REFS); + } else { + $_a = &$arr['_a']; + $_b = &$arr['_b']; + } - $_a++; - $_b++; + $_a++; + $_b++; - var_dump($a, $b, $_a, $_b, $arr); + var_dump($a, $b, $_a, $_b, $arr); } test(false); diff --git a/ext/standard/tests/array/bug34066.phpt b/ext/standard/tests/array/bug34066.phpt index 44710b042613..df524feb9c8f 100644 --- a/ext/standard/tests/array/bug34066.phpt +++ b/ext/standard/tests/array/bug34066.phpt @@ -245,21 +245,21 @@ function gen_xml($val, $key, $prefix) global $xml_fd; print "gen_xml(prefix=$prefix)\n"; if (is_array($val)) { - if (preg_match('/^\d+$/', $key)) { - if ($key == 1) { - print substr($prefix, 0, -1) . "\n"; - } - array_walk($val, "gen_xml", "$prefix@"); - } - else { - array_walk($val, "gen_xml", "$prefix$key/"); - } + if (preg_match('/^\d+$/', $key)) { + if ($key == 1) { + print substr($prefix, 0, -1) . "\n"; + } + array_walk($val, "gen_xml", "$prefix@"); } else { - if (strlen($val) > 0) - print "$prefix$key=$val\n"; - else - print "$prefix$key\n"; + array_walk($val, "gen_xml", "$prefix$key/"); + } + } + else { + if (strlen($val) > 0) + print "$prefix$key=$val\n"; + else + print "$prefix$key\n"; } print "gen_xml(prefix=$prefix) end\n"; } diff --git a/ext/standard/tests/array/bug34066_1.phpt b/ext/standard/tests/array/bug34066_1.phpt index 5200fa86a62c..5ded4ea816bc 100644 --- a/ext/standard/tests/array/bug34066_1.phpt +++ b/ext/standard/tests/array/bug34066_1.phpt @@ -245,21 +245,21 @@ function gen_xml($val, $key, $prefix) global $xml_fd; print "gen_xml(prefix=$prefix)\n"; if (is_array($val)) { - if (preg_match('/^\d+$/', $key)) { - if ($key == 1) { - print substr($prefix, 0, -1) . "\n"; - } - array_walk_recursive($val, "gen_xml", "$prefix@"); - } - else { - array_walk_recursive($val, "gen_xml", "$prefix$key/"); - } + if (preg_match('/^\d+$/', $key)) { + if ($key == 1) { + print substr($prefix, 0, -1) . "\n"; + } + array_walk_recursive($val, "gen_xml", "$prefix@"); } else { - if (strlen($val) > 0) - print "$prefix$key=$val\n"; - else - print "$prefix$key\n"; + array_walk_recursive($val, "gen_xml", "$prefix$key/"); + } + } + else { + if (strlen($val) > 0) + print "$prefix$key=$val\n"; + else + print "$prefix$key\n"; } print "gen_xml(prefix=$prefix) end\n"; } diff --git a/ext/standard/tests/array/bug35014.phpt b/ext/standard/tests/array/bug35014.phpt index b674590fd669..8980f00d80d8 100644 --- a/ext/standard/tests/array/bug35014.phpt +++ b/ext/standard/tests/array/bug35014.phpt @@ -7,18 +7,18 @@ precision=14 --FILE-- --EXPECT-- diff --git a/ext/standard/tests/array/bug35014_64bit.phpt b/ext/standard/tests/array/bug35014_64bit.phpt index 3b3d29b5be18..91face05afe9 100644 --- a/ext/standard/tests/array/bug35014_64bit.phpt +++ b/ext/standard/tests/array/bug35014_64bit.phpt @@ -7,18 +7,18 @@ precision=14 --FILE-- --EXPECT-- diff --git a/ext/standard/tests/array/bug35022.phpt b/ext/standard/tests/array/bug35022.phpt index 07138f138d50..8c67c5201a44 100644 --- a/ext/standard/tests/array/bug35022.phpt +++ b/ext/standard/tests/array/bug35022.phpt @@ -6,7 +6,7 @@ $state = array("one" => 1, "two" => 2, "three" => 3); function foo( &$state ) { $contentDict = end( $state ); for ( $contentDict = end( $state ); $contentDict !== false; $contentDict = prev( $state ) ) { - echo key($state) . " => " . current($state) . "\n"; + echo key($state) . " => " . current($state) . "\n"; } } foo($state); diff --git a/ext/standard/tests/array/bug35821.phpt b/ext/standard/tests/array/bug35821.phpt index 3b1ecb627881..e01ec6e39250 100644 --- a/ext/standard/tests/array/bug35821.phpt +++ b/ext/standard/tests/array/bug35821.phpt @@ -5,15 +5,15 @@ Bug #35821 (array_map() segfaults when exception is throwed from the callback) class Element { - public function ThrowException () - { - throw new Exception(); - } + public function ThrowException () + { + throw new Exception(); + } - public static function CallBack(Element $elem) - { - $elem->ThrowException(); - } + public static function CallBack(Element $elem) + { + $elem->ThrowException(); + } } $arr = array(new Element(), new Element(), new Element()); diff --git a/ext/standard/tests/array/bug39576.phpt b/ext/standard/tests/array/bug39576.phpt index bb58e791834e..3ac975694185 100644 --- a/ext/standard/tests/array/bug39576.phpt +++ b/ext/standard/tests/array/bug39576.phpt @@ -5,9 +5,9 @@ Bug #39576 (array_walk() doesn't separate userdata zval) class Test { - public $_table = ''; - public $_columns = array (); - public $_primary = array (); + public $_table = ''; + public $_columns = array (); + public $_primary = array (); } @@ -18,16 +18,16 @@ $test->_columns['name'] = new stdClass; function test ($value, $column, &$columns) {} array_walk ( - get_object_vars ($test), - 'test', - $test->_columns + get_object_vars ($test), + 'test', + $test->_columns ); var_dump($test); array_intersect_key ( - get_object_vars ($test), - $test->_primary + get_object_vars ($test), + $test->_primary ); echo "Done\n"; diff --git a/ext/standard/tests/array/bug41686.phpt b/ext/standard/tests/array/bug41686.phpt index d293fdf175ee..b94acb608d2a 100644 --- a/ext/standard/tests/array/bug41686.phpt +++ b/ext/standard/tests/array/bug41686.phpt @@ -6,12 +6,12 @@ $a = array(1,2,3); $b = array('a'=>1,'b'=>1,'c'=>2); var_dump( - array_slice($a, 1), - array_slice($a, 1, 2, TRUE), - array_slice($a, 1, NULL, TRUE), - array_slice($b, 1), - array_slice($b, 1, 2, TRUE), - array_slice($b, 1, NULL, TRUE) + array_slice($a, 1), + array_slice($a, 1, 2, TRUE), + array_slice($a, 1, NULL, TRUE), + array_slice($b, 1), + array_slice($b, 1, 2, TRUE), + array_slice($b, 1, NULL, TRUE) ); echo "Done\n"; diff --git a/ext/standard/tests/array/bug42233.phpt b/ext/standard/tests/array/bug42233.phpt index 0cebc428f77f..c02a620ae6cb 100644 --- a/ext/standard/tests/array/bug42233.phpt +++ b/ext/standard/tests/array/bug42233.phpt @@ -4,9 +4,9 @@ Bug #42233 (extract(): scandic characters not allowed as variable name) '1', - 'æ' => '2', - 'æøåäö' => '3', + 'a' => '1', + 'æ' => '2', + 'æøåäö' => '3', ); var_dump($test); diff --git a/ext/standard/tests/array/bug42838.phpt b/ext/standard/tests/array/bug42838.phpt index 5a09ae9c8e72..fbd8234987f0 100644 --- a/ext/standard/tests/array/bug42838.phpt +++ b/ext/standard/tests/array/bug42838.phpt @@ -5,10 +5,10 @@ Bug #42838 (Wrong results in array_diff_uassoc()) function key_compare_func($a, $b) { - if ($a === $b) { - return 0; - } - return ($a > $b)? 1:-1; + if ($a === $b) { + return 0; + } + return ($a > $b)? 1:-1; } $array1 = array("a" => "green", "b" => "Brown", 'c' => 'blue', 0 => 'red'); diff --git a/ext/standard/tests/array/bug45312.phpt b/ext/standard/tests/array/bug45312.phpt index 858bdfa4bf62..a31581410852 100644 --- a/ext/standard/tests/array/bug45312.phpt +++ b/ext/standard/tests/array/bug45312.phpt @@ -12,7 +12,7 @@ class cr { return ($a->priv_member > $b->priv_member) ? 1 : -1; } static function comp_func_cr2($a, $b) { - echo "."; + echo "."; if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member < $b->priv_member) ? 1 : -1; } @@ -24,11 +24,11 @@ $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1 => new cr $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1 => new cr(4), 2 => new cr(-15),); $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); foreach($result as $val) { - $val->dump(); + $val->dump(); } $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr2")); foreach($result as $val) { - $val->dump(); + $val->dump(); } ?> --EXPECT-- diff --git a/ext/standard/tests/array/bug68553.phpt b/ext/standard/tests/array/bug68553.phpt index fbee975d17a9..966c98b544a7 100644 --- a/ext/standard/tests/array/bug68553.phpt +++ b/ext/standard/tests/array/bug68553.phpt @@ -5,19 +5,19 @@ Bug #68553 (array_column: null values in $index_key become incrementing keys in $i = 100; /* increase the resource id to make test stable */ while ($i--) { - $fd = fopen(__FILE__, "r"); - fclose($fd); + $fd = fopen(__FILE__, "r"); + fclose($fd); } $a = [ - ['a' => 10], - ['a' => 20], - ['a' => true], - ['a' => false], - ['a' => fopen(__FILE__, "r")], - ['a' => -5], - ['a' => 7.38], - ['a' => null, "test"], - ['a' => null], + ['a' => 10], + ['a' => 20], + ['a' => true], + ['a' => false], + ['a' => fopen(__FILE__, "r")], + ['a' => -5], + ['a' => 7.38], + ['a' => null, "test"], + ['a' => null], ]; var_dump(array_column($a, null, 'a')); diff --git a/ext/standard/tests/array/bug69198.phpt b/ext/standard/tests/array/bug69198.phpt index 96a0f9a96326..3441bee5d7c8 100644 --- a/ext/standard/tests/array/bug69198.phpt +++ b/ext/standard/tests/array/bug69198.phpt @@ -3,7 +3,7 @@ Bug #69198 (Compact function generate array with length but no content) --FILE-- 'bar', 'fiz' => 'buz'); $filtered = array_filter($toFilter, function ($value, $key) { - if ($value === 'buz' - || $key === 'foo' - ) { - return false; - } - return true; + if ($value === 'buz' + || $key === 'foo' + ) { + return false; + } + return true; }, ARRAY_FILTER_USE_BOTH); var_dump($filtered); ?> diff --git a/ext/standard/tests/array/bug69723.phpt b/ext/standard/tests/array/bug69723.phpt index 23b3576a5171..88183c5aaede 100644 --- a/ext/standard/tests/array/bug69723.phpt +++ b/ext/standard/tests/array/bug69723.phpt @@ -3,23 +3,23 @@ Bug #69723 (Passing parameters by reference and array_column) --FILE-- 'superman', - 'nanana' => 'no nana' - ], - [ - 'superhero'=> 'acuaman', - 'nanana' => 'no nana' - ], + [ + 'superhero'=> 'superman', + 'nanana' => 'no nana' + ], + [ + 'superhero'=> 'acuaman', + 'nanana' => 'no nana' + ], - ]; + ]; var_dump(array_column($array, 'superhero')); byReference($array); diff --git a/ext/standard/tests/array/bug70713.phpt b/ext/standard/tests/array/bug70713.phpt index f24720607d1b..fab1661e84e0 100644 --- a/ext/standard/tests/array/bug70713.phpt +++ b/ext/standard/tests/array/bug70713.phpt @@ -5,17 +5,17 @@ Bug #70713: Use After Free Vulnerability in array_walk()/array_walk_recursive() class obj { - function __tostring() - { - global $arr; + function __tostring() + { + global $arr; - $arr = 1; - for ($i = 0; $i < 5; $i++) { - $v[$i] = 'hi'.$i; - } + $arr = 1; + for ($i = 0; $i < 5; $i++) { + $v[$i] = 'hi'.$i; + } - return 'hi'; - } + return 'hi'; + } } $arr = array('string' => new obj); diff --git a/ext/standard/tests/array/bug71334.phpt b/ext/standard/tests/array/bug71334.phpt index 7a37d0953a4e..ba14f08c1810 100644 --- a/ext/standard/tests/array/bug71334.phpt +++ b/ext/standard/tests/array/bug71334.phpt @@ -5,29 +5,29 @@ Bug #71334: Cannot access array keys while uksort() class myClass { - private $a = [ - 'foo-test' => [1], - '-' => [2], - 'bar-test' => [3] - ]; + private $a = [ + 'foo-test' => [1], + '-' => [2], + 'bar-test' => [3] + ]; - private function _mySort($x, $y) - { - if (!isset($this->a[$x])) { - throw new Exception('Missing X: "' . $x . '"'); - } + private function _mySort($x, $y) + { + if (!isset($this->a[$x])) { + throw new Exception('Missing X: "' . $x . '"'); + } - if (!isset($this->a[$y])) { - throw new Exception('Missing Y: "' . $y . '"'); - } + if (!isset($this->a[$y])) { + throw new Exception('Missing Y: "' . $y . '"'); + } - return $x < $y; - } + return $x < $y; + } - public function __construct() - { - uksort($this->a, [$this, '_mySort']); - } + public function __construct() + { + uksort($this->a, [$this, '_mySort']); + } } new myClass(); diff --git a/ext/standard/tests/array/bug71660.phpt b/ext/standard/tests/array/bug71660.phpt index c2d7192378e9..067f533381e2 100644 --- a/ext/standard/tests/array/bug71660.phpt +++ b/ext/standard/tests/array/bug71660.phpt @@ -4,7 +4,7 @@ Bug #71660 (array_column behaves incorrectly after foreach by reference) 12345, 'name' => 'sam'); foreach ($arr as &$v) { - $v = $v; + $v = $v; } $arr = [$arr]; diff --git a/ext/standard/tests/array/bug72622.phpt b/ext/standard/tests/array/bug72622.phpt index 66e22f3bf9a3..cf1a3ece8a48 100644 --- a/ext/standard/tests/array/bug72622.phpt +++ b/ext/standard/tests/array/bug72622.phpt @@ -4,11 +4,11 @@ Bug #72622 (array_walk + array_replace_recursive create references from nothing) 'foo']; diff --git a/ext/standard/tests/array/bug76713.phpt b/ext/standard/tests/array/bug76713.phpt index 0c993f5721ef..8bb8bf221fe8 100644 --- a/ext/standard/tests/array/bug76713.phpt +++ b/ext/standard/tests/array/bug76713.phpt @@ -4,7 +4,7 @@ Bug #76713 (Segmentation fault caused by property corruption) prop); class C { - public $name; - public function __get($name) { - return $this->name; - } + public $name; + public function __get($name) { + return $this->name; + } } $obj = new C; diff --git a/ext/standard/tests/array/bug77395.phpt b/ext/standard/tests/array/bug77395.phpt index bca1e3136cfc..a4a79f5e2f54 100644 --- a/ext/standard/tests/array/bug77395.phpt +++ b/ext/standard/tests/array/bug77395.phpt @@ -3,10 +3,10 @@ Bug #77395 (segfault about array_multisort) --FILE-- 'bb',], ['aa'=> 'bb',],]; diff --git a/ext/standard/tests/array/compact_variation2.phpt b/ext/standard/tests/array/compact_variation2.phpt index 17ac7882c7a4..fb186ae002f2 100644 --- a/ext/standard/tests/array/compact_variation2.phpt +++ b/ext/standard/tests/array/compact_variation2.phpt @@ -13,10 +13,10 @@ $a = 'main.a'; $b = 'main.b'; function f() { - $b = 'f.b'; - $c = 'f.c'; - var_dump(compact('a','b','c')); - var_dump(compact(array('a','b','c'))); + $b = 'f.b'; + $c = 'f.c'; + var_dump(compact('a','b','c')); + var_dump(compact(array('a','b','c'))); } f(); diff --git a/ext/standard/tests/array/count_recursive.phpt b/ext/standard/tests/array/count_recursive.phpt index dd5c2342fca9..a7d4afb53b8d 100644 --- a/ext/standard/tests/array/count_recursive.phpt +++ b/ext/standard/tests/array/count_recursive.phpt @@ -31,7 +31,7 @@ print "COUNT_NORMAL: should be 1, is ".count("string")."\n"; print "COUNT_NORMAL: should be 2, is ".count(array("a", array("b")))."\n"; $arr = array('a'=>array(NULL, NULL, NULL), 1=>array(NULL=>1, 1=>NULL), - array(array(array(array(array(NULL)))))); + array(array(array(array(array(NULL)))))); print "-- Testing really cool arrays --\n"; print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n"; print "COUNT_RECURSIVE: should be 13, is ".count($arr, COUNT_RECURSIVE)."\n"; @@ -47,7 +47,7 @@ $count_array = array( array( 4 => 1, 3 => -2.344, "3" => "string", "2" => NULL, 1 => -2.344, array()), array( TRUE => TRUE, FALSE => FALSE, "" => "", " " => " ", - NULL => NULL, "\x000" => "\x000", "\000" => "\000"), + NULL => NULL, "\x000" => "\x000", "\000" => "\000"), array( NULL, 1.23 => "Hi", "string" => "hello", array("" => "World", "-2.34" => "a", "0" => "b")) ); diff --git a/ext/standard/tests/array/current_variation2.phpt b/ext/standard/tests/array/current_variation2.phpt index 2bbc5dca42a2..8a6b56d99a19 100644 --- a/ext/standard/tests/array/current_variation2.phpt +++ b/ext/standard/tests/array/current_variation2.phpt @@ -39,7 +39,7 @@ $inputs = array( // int data /*1*/ 'int' => array( - 0, + 0, 1, 12345, -2345, diff --git a/ext/standard/tests/array/data.inc b/ext/standard/tests/array/data.inc index bbc8d43c2323..c8ad4fe29519 100644 --- a/ext/standard/tests/array/data.inc +++ b/ext/standard/tests/array/data.inc @@ -1,13 +1,13 @@ 'PHP: Hypertext Preprocessor', - 5=>'Test', - 'test'=>27, - 1000=>'test', - "-1000"=>array('banana', 'orange'), - 'monkey', - $tmp=>-1/3 + 'PHP', + 17=>'PHP: Hypertext Preprocessor', + 5=>'Test', + 'test'=>27, + 1000=>'test', + "-1000"=>array('banana', 'orange'), + 'monkey', + $tmp=>-1/3 ); ?> diff --git a/ext/standard/tests/array/extract_typed_ref.phpt b/ext/standard/tests/array/extract_typed_ref.phpt index 8b697d5ccb24..6d2a5a9272d7 100644 --- a/ext/standard/tests/array/extract_typed_ref.phpt +++ b/ext/standard/tests/array/extract_typed_ref.phpt @@ -2,17 +2,17 @@ extract() into typed references must respect their type --FILE-- i; $s =& $test->s; try { - extract(['i' => 'foo', 's' => 42]); + extract(['i' => 'foo', 's' => 42]); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } var_dump($test->i, $test->s); diff --git a/ext/standard/tests/array/extract_variation7.phpt b/ext/standard/tests/array/extract_variation7.phpt index 1502a523800c..eb5171bfc7aa 100644 --- a/ext/standard/tests/array/extract_variation7.phpt +++ b/ext/standard/tests/array/extract_variation7.phpt @@ -9,7 +9,7 @@ $a = array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "f var_dump ( extract($a, EXTR_PREFIX_ALL, "same")); $b = array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2.4 => "float", "F" => "FFF", - "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ); + "blank" => "", 3.7 => 3.7, 5.4 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ); var_dump ( extract($b, EXTR_PREFIX_ALL, "same")); var_dump ( extract($b, EXTR_PREFIX_ALL, "diff")); diff --git a/ext/standard/tests/array/key_variation2.phpt b/ext/standard/tests/array/key_variation2.phpt index 67c7105ec6ef..3a6022e08a8e 100644 --- a/ext/standard/tests/array/key_variation2.phpt +++ b/ext/standard/tests/array/key_variation2.phpt @@ -97,8 +97,8 @@ $iterator = 1; foreach($inputs as $key => $input) { echo "\n-- Iteration $iterator : $key data --\n"; while (key($input) !== NULL) { - var_dump(key($input)); - next($input); + var_dump(key($input)); + next($input); } $iterator++; }; diff --git a/ext/standard/tests/array/krsort_basic.phpt b/ext/standard/tests/array/krsort_basic.phpt index 642dfc2070ba..393b7f06e414 100644 --- a/ext/standard/tests/array/krsort_basic.phpt +++ b/ext/standard/tests/array/krsort_basic.phpt @@ -21,9 +21,9 @@ echo "*** Testing krsort() : basic functionality ***\n"; // an array containing unsorted string values with indices $unsorted_strings = array( "lemon" => "l", "orange" => "o", "banana" => "b" ); $unsorted_strings = array( - "l" => "lemon", "o" => "orange", - "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", - "b" => "banana", + "l" => "lemon", "o" => "orange", + "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", + "b" => "banana", ); // an array containing unsorted numeric values with indices $unsorted_numerics = array( 100 => 4, 33 => 3, 555 => 2, 22 => 1 ); diff --git a/ext/standard/tests/array/ksort_basic.phpt b/ext/standard/tests/array/ksort_basic.phpt index a24674ff3380..1a62f3ac2c02 100644 --- a/ext/standard/tests/array/ksort_basic.phpt +++ b/ext/standard/tests/array/ksort_basic.phpt @@ -19,9 +19,9 @@ echo "*** Testing ksort() : basic functionality ***\n"; // an array containing unsorted string values with indices $unsorted_strings = array( - "l" => "lemon", "o" => "orange", - "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", - "b" => "banana", + "l" => "lemon", "o" => "orange", + "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", + "b" => "banana", ); // an array containing unsorted numeric values with indices $unsorted_numerics = array( 100 => 4, 33 => 3, 555 => 2, 22 => 1 ); diff --git a/ext/standard/tests/array/natcasesort_object2.phpt b/ext/standard/tests/array/natcasesort_object2.phpt index 3eef4375880c..b82d0a0b7abb 100644 --- a/ext/standard/tests/array/natcasesort_object2.phpt +++ b/ext/standard/tests/array/natcasesort_object2.phpt @@ -17,20 +17,20 @@ echo "*** Testing natcasesort() : object functionality ***\n"; // class declaration for string objects class for_string_natcasesort { - public $public_class_value; - private $private_class_value; - protected $protected_class_value; - // initializing object member value - function __construct($value1, $value2,$value3){ - $this->public_class_value = $value1; - $this->private_class_value = $value2; - $this->protected_class_value = $value3; - } + public $public_class_value; + private $private_class_value; + protected $protected_class_value; + // initializing object member value + function __construct($value1, $value2,$value3){ + $this->public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } - // return string value - function __tostring() { - return (string)$this->public_class_value; - } + // return string value + function __tostring() { + return (string)$this->public_class_value; + } } diff --git a/ext/standard/tests/array/natcasesort_variation11.phpt b/ext/standard/tests/array/natcasesort_variation11.phpt index 365600edd774..27e41865f185 100644 --- a/ext/standard/tests/array/natcasesort_variation11.phpt +++ b/ext/standard/tests/array/natcasesort_variation11.phpt @@ -103,10 +103,10 @@ $inputs = array( // loop through each element of $inputs to check the behavior of natcasesort() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( natcasesort($input) ); - var_dump($input); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump( natcasesort($input) ); + var_dump($input); + $iterator++; }; echo "Done"; diff --git a/ext/standard/tests/array/natcasesort_variation2.phpt b/ext/standard/tests/array/natcasesort_variation2.phpt index ce34db1246b3..c9dbec1e1f3c 100644 --- a/ext/standard/tests/array/natcasesort_variation2.phpt +++ b/ext/standard/tests/array/natcasesort_variation2.phpt @@ -39,7 +39,7 @@ $inputs = array( // int data /*1*/ 'int' => array( - 0, + 0, 1, 12345, -2345, @@ -107,10 +107,10 @@ $inputs = array( // loop through each element of $inputs to check the behavior of natcasesort() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( natcasesort($input) ); - var_dump($input); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump( natcasesort($input) ); + var_dump($input); + $iterator++; }; fclose($fp); diff --git a/ext/standard/tests/array/natcasesort_variation3.phpt b/ext/standard/tests/array/natcasesort_variation3.phpt index c3400f4d6516..b2523dc4269a 100644 --- a/ext/standard/tests/array/natcasesort_variation3.phpt +++ b/ext/standard/tests/array/natcasesort_variation3.phpt @@ -34,9 +34,9 @@ $inputs = array ( $iterator = 1; foreach ($inputs as $array_arg) { - echo "\n-- Iteration $iterator --\n"; - var_dump(natcasesort($array_arg)); - var_dump($array_arg); + echo "\n-- Iteration $iterator --\n"; + var_dump(natcasesort($array_arg)); + var_dump($array_arg); } echo "Done"; diff --git a/ext/standard/tests/array/natcasesort_variation4.phpt b/ext/standard/tests/array/natcasesort_variation4.phpt index b8d4d2c220c1..452e2e48b2ed 100644 --- a/ext/standard/tests/array/natcasesort_variation4.phpt +++ b/ext/standard/tests/array/natcasesort_variation4.phpt @@ -14,16 +14,16 @@ Test natcasesort() function : usage variations - different string types echo "*** Testing natcasesort() : usage variation ***\n"; $inputs = array ( - // group of escape sequences - array(null, NULL, "\a", "\cx", "\e", "\f", "\n", "\t", "\xhh", "\ddd", "\v"), + // group of escape sequences + array(null, NULL, "\a", "\cx", "\e", "\f", "\n", "\t", "\xhh", "\ddd", "\v"), - // array contains combination of capital/small letters - array("lemoN", "Orange", "banana", "apple", "Test", "TTTT", "ttt", "ww", "x", "X", "oraNGe", "BANANA") + // array contains combination of capital/small letters + array("lemoN", "Orange", "banana", "apple", "Test", "TTTT", "ttt", "ww", "x", "X", "oraNGe", "BANANA") ); foreach ($inputs as $array_arg) { - var_dump( natcasesort($array_arg) ); - var_dump($array_arg); + var_dump( natcasesort($array_arg) ); + var_dump($array_arg); } echo "Done"; diff --git a/ext/standard/tests/array/prev_error2.phpt b/ext/standard/tests/array/prev_error2.phpt index 37049cf854a4..45d2930ad749 100644 --- a/ext/standard/tests/array/prev_error2.phpt +++ b/ext/standard/tests/array/prev_error2.phpt @@ -12,8 +12,8 @@ prev - ensure warning is received when passing an indirect temporary. */ function f() { - $array = array(1,2); - end($array); + $array = array(1,2); + end($array); return $array; } diff --git a/ext/standard/tests/array/rsort_basic.phpt b/ext/standard/tests/array/rsort_basic.phpt index 9d82ea5c941f..76123b7c02e0 100644 --- a/ext/standard/tests/array/rsort_basic.phpt +++ b/ext/standard/tests/array/rsort_basic.phpt @@ -15,9 +15,9 @@ echo "*** Testing rsort() : basic functionality ***\n"; // associative array containing unsorted string values $unsorted_strings = array( - "l" => "lemon", "o" => "orange", - "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", - "b" => "banana", + "l" => "lemon", "o" => "orange", + "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", + "b" => "banana", ); // array with default keys containing unsorted numeric values diff --git a/ext/standard/tests/array/rsort_object1.phpt b/ext/standard/tests/array/rsort_object1.phpt index fdbdaedb7bbd..df7ca491ffd5 100644 --- a/ext/standard/tests/array/rsort_object1.phpt +++ b/ext/standard/tests/array/rsort_object1.phpt @@ -16,27 +16,27 @@ echo "*** Testing rsort() : object functionality ***\n"; // class declaration for integer objects class for_integer_rsort { - public $class_value; - // initializing object member value - function __construct($value){ - $this->class_value = $value; - } + public $class_value; + // initializing object member value + function __construct($value){ + $this->class_value = $value; + } } // class declaration for string objects class for_string_rsort { - public $class_value; - // initializing object member value - function __construct($value){ - $this->class_value = $value; - } - - // return string value - function __tostring() { - return (string)$this->value; - } + public $class_value; + // initializing object member value + function __construct($value){ + $this->class_value = $value; + } + + // return string value + function __tostring() { + return (string)$this->value; + } } diff --git a/ext/standard/tests/array/rsort_object2.phpt b/ext/standard/tests/array/rsort_object2.phpt index 5f2eba168e6c..21789ba026cc 100644 --- a/ext/standard/tests/array/rsort_object2.phpt +++ b/ext/standard/tests/array/rsort_object2.phpt @@ -16,36 +16,36 @@ echo "*** Testing rsort() : object functionality ***\n"; // class declaration for integer objects class for_integer_rsort { - public $public_class_value; - private $private_class_value; - protected $protected_class_value; + public $public_class_value; + private $private_class_value; + protected $protected_class_value; - // initializing object member value - function __construct($value1, $value2,$value3){ - $this->public_class_value = $value1; - $this->private_class_value = $value2; - $this->protected_class_value = $value3; - } + // initializing object member value + function __construct($value1, $value2,$value3){ + $this->public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } } // class declaration for string objects class for_string_rsort { - public $public_class_value; - private $private_class_value; - protected $protected_class_value; - // initializing object member value - function __construct($value1, $value2,$value3){ - $this->public_class_value = $value1; - $this->private_class_value = $value2; - $this->protected_class_value = $value3; - } + public $public_class_value; + private $private_class_value; + protected $protected_class_value; + // initializing object member value + function __construct($value1, $value2,$value3){ + $this->public_class_value = $value1; + $this->private_class_value = $value2; + $this->protected_class_value = $value3; + } - // return string value - function __tostring() { - return (string)$this->value; - } + // return string value + function __tostring() { + return (string)$this->value; + } } diff --git a/ext/standard/tests/array/rsort_variation5.phpt b/ext/standard/tests/array/rsort_variation5.phpt index 44a8b2b47311..20d061f4c496 100644 --- a/ext/standard/tests/array/rsort_variation5.phpt +++ b/ext/standard/tests/array/rsort_variation5.phpt @@ -26,22 +26,22 @@ $flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING); $count = 1; // loop through to test rsort() with different arrays foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; + echo "\n-- Iteration $count --\n"; - echo "- With Default sort flag -\n"; - $temp_array = $array; - var_dump(rsort($temp_array) ); - var_dump($temp_array); + echo "- With Default sort flag -\n"; + $temp_array = $array; + var_dump(rsort($temp_array) ); + var_dump($temp_array); - // loop through $flags array and setting all possible flag values - foreach($flags as $key => $flag){ - echo "- Sort flag = $key -\n"; + // loop through $flags array and setting all possible flag values + foreach($flags as $key => $flag){ + echo "- Sort flag = $key -\n"; - $temp_array = $array; - var_dump(rsort($temp_array, $flag) ); - var_dump($temp_array); - } - $count++; + $temp_array = $array; + var_dump(rsort($temp_array, $flag) ); + var_dump($temp_array); + } + $count++; } echo "Done"; diff --git a/ext/standard/tests/array/rsort_variation9.phpt b/ext/standard/tests/array/rsort_variation9.phpt index d3b44ec0bb61..93cdff2228be 100644 --- a/ext/standard/tests/array/rsort_variation9.phpt +++ b/ext/standard/tests/array/rsort_variation9.phpt @@ -15,22 +15,22 @@ echo "*** Testing rsort() : variation ***\n"; // Associative arrays $various_arrays = array( - // numeric assoc. only array - array(5 => 55, 6 => 66, 2 => 22, 3 => 33, 1 => 11), + // numeric assoc. only array + array(5 => 55, 6 => 66, 2 => 22, 3 => 33, 1 => 11), - // two-dimensional assoc. and default key array - array("fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"), - "numbers" => array(1, 2, 3, 4, 5, 6), - "holes" => array("first", 5 => "second", "third")), + // two-dimensional assoc. and default key array + array("fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"), + "numbers" => array(1, 2, 3, 4, 5, 6), + "holes" => array("first", 5 => "second", "third")), - // numeric assoc. and default key array - array(1, 1, 8 => 1, 4 => 1, 19, 3 => 13), + // numeric assoc. and default key array + array(1, 1, 8 => 1, 4 => 1, 19, 3 => 13), - // mixed assoc. array - array('bar' => 'baz', "foo" => 1), + // mixed assoc. array + array('bar' => 'baz', "foo" => 1), - // assoc. only multi-dimensional array - array('a' => 1,'b' => array('e' => 2,'f' => 3),'c' => array('g' => 4),'d' => 5), + // assoc. only multi-dimensional array + array('a' => 1,'b' => array('e' => 2,'f' => 3),'c' => array('g' => 4),'d' => 5), ); $count = 1; diff --git a/ext/standard/tests/array/sort_basic.phpt b/ext/standard/tests/array/sort_basic.phpt index e409ac3d3343..451fd5788f53 100644 --- a/ext/standard/tests/array/sort_basic.phpt +++ b/ext/standard/tests/array/sort_basic.phpt @@ -21,9 +21,9 @@ echo "*** Testing sort() : basic functionality ***\n"; // associative array containing unsorted string values $unsorted_strings = array( - "l" => "lemon", "o" => "orange", - "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", - "b" => "banana", + "l" => "lemon", "o" => "orange", + "O" => "Orange", "O1" => "Orange1", "o2" => "orange2", "O3" => "Orange3", "o20" => "orange20", + "b" => "banana", ); // array with default keys containing unsorted numeric values diff --git a/ext/standard/tests/array/usort_object1.phpt b/ext/standard/tests/array/usort_object1.phpt index c1e20b181cbf..b1002a53e469 100644 --- a/ext/standard/tests/array/usort_object1.phpt +++ b/ext/standard/tests/array/usort_object1.phpt @@ -16,51 +16,51 @@ echo "*** Testing usort() : object functionality ***\n"; function simple_cmp($value1, $value2) { - if($value1 == $value2) { - return 0; - } - else if($value1 > $value2) { - return 1; - } - else - return -1; + if($value1 == $value2) { + return 0; + } + else if($value1 > $value2) { + return 1; + } + else + return -1; } // comparison function for SimpleClass2 objects which has more than one member function multiple_cmp($value1, $value2) { - if($value1->getValue() == $value2->getValue()) - return 0; - else if($value1->getValue() > $value2->getValue()) - return 1; - else - return -1; + if($value1->getValue() == $value2->getValue()) + return 0; + else if($value1->getValue() > $value2->getValue()) + return 1; + else + return -1; } // Simple class with single property class SimpleClass1 { - private $int_value; + private $int_value; - public function __construct($value) { - $this->int_value = $value; - } + public function __construct($value) { + $this->int_value = $value; + } } // Simple class with more than one property class SimpleClass2 { - private $int_value; - protected $float_value; - public $string_value; - public function __construct($int, $float, $str) { - $this->int_value = $int; - $this->float_value = $float; - $this->string_value = $str; - } - public function getValue() { - return $this->int_value; - } + private $int_value; + protected $float_value; + public $string_value; + public function __construct($int, $float, $str) { + $this->int_value = $int; + $this->float_value = $float; + $this->string_value = $str; + } + public function getValue() { + return $this->int_value; + } } // array of SimpleClass objects with only one property diff --git a/ext/standard/tests/array/usort_variation11.phpt b/ext/standard/tests/array/usort_variation11.phpt index b6cdeef766e3..d07dfb48e05d 100644 --- a/ext/standard/tests/array/usort_variation11.phpt +++ b/ext/standard/tests/array/usort_variation11.phpt @@ -4,20 +4,20 @@ Test usort() function : usage variations - binary return cmp $b; + return $a > $b; } $range = array(2, 4, 8, 16, 32, 64, 128); foreach ($range as $r) { - $backup = $array = range(0, $r); - shuffle($array); - usort($array, "ucmp"); - if ($array != $backup) { - var_dump($array); - var_dump($backup); - die("Whatever sorting algo you used, this test should never be broken"); - } + $backup = $array = range(0, $r); + shuffle($array); + usort($array, "ucmp"); + if ($array != $backup) { + var_dump($array); + var_dump($backup); + die("Whatever sorting algo you used, this test should never be broken"); + } } echo "okey"; ?> diff --git a/ext/standard/tests/array/var_export3.phpt b/ext/standard/tests/array/var_export3.phpt index 6d39946916c4..e7d3c851f27c 100644 --- a/ext/standard/tests/array/var_export3.phpt +++ b/ext/standard/tests/array/var_export3.phpt @@ -3,14 +3,14 @@ var_export() and classes --FILE-- mann = 42; - $this->kvinne = 43; - } + function __construct() + { + $this->mann = 42; + $this->kvinne = 43; + } } $kake = new kake; diff --git a/ext/standard/tests/assert/assert.phpt b/ext/standard/tests/assert/assert.phpt index 71b0649141e9..7935b7c8fd51 100644 --- a/ext/standard/tests/assert/assert.phpt +++ b/ext/standard/tests/assert/assert.phpt @@ -9,15 +9,15 @@ assert.bail = 0 [".assert_options(ASSERT_CALLBACK)."]\n"; echo "Initial values: ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n"; diff --git a/ext/standard/tests/bug49244.phpt b/ext/standard/tests/bug49244.phpt index 60942966a7d8..a50aacee8d08 100644 --- a/ext/standard/tests/bug49244.phpt +++ b/ext/standard/tests/bug49244.phpt @@ -4,8 +4,8 @@ Bug #49244 (Floating point NaN cause garbage characters) diff --git a/ext/standard/tests/bug64370_var2.phpt b/ext/standard/tests/bug64370_var2.phpt index 3618a469800e..601f8b93e06f 100644 --- a/ext/standard/tests/bug64370_var2.phpt +++ b/ext/standard/tests/bug64370_var2.phpt @@ -5,15 +5,15 @@ Test bug #64370 sequential microtime(true) calls $i = 0; while(100000 > $i++) { - $m0 = microtime(true); - $m1 = microtime(true); - $d = $m1 - $m0; + $m0 = microtime(true); + $m1 = microtime(true); + $d = $m1 - $m0; - /*echo "$d\n";*/ + /*echo "$d\n";*/ - if ($d < 0) { - die("failed in {$i}th iteration"); - } + if ($d < 0) { + die("failed in {$i}th iteration"); + } } echo "ok\n"; ?> diff --git a/ext/standard/tests/bug75220.phpt b/ext/standard/tests/bug75220.phpt index ca6c3ef4ea01..f0ba55a70238 100644 --- a/ext/standard/tests/bug75220.phpt +++ b/ext/standard/tests/bug75220.phpt @@ -9,16 +9,16 @@ $a->bar('foo'); class B {}; class A extends B { - function bar($func) - { - var_dump('foo'); - var_dump(is_callable('parent::foo')); - var_dump(is_callable(array('parent', 'foo'))); - } + function bar($func) + { + var_dump('foo'); + var_dump(is_callable('parent::foo')); + var_dump(is_callable(array('parent', 'foo'))); + } - function __call($func, $args) - { - } + function __call($func, $args) + { + } }; ?> diff --git a/ext/standard/tests/class_object/bug71442.phpt b/ext/standard/tests/class_object/bug71442.phpt index d6b3d6699b34..27a025c4e48b 100644 --- a/ext/standard/tests/class_object/bug71442.phpt +++ b/ext/standard/tests/class_object/bug71442.phpt @@ -5,29 +5,29 @@ Bug #71442 (forward_static_call crash) class A { - const NAME = 'A'; - public static function test() { - $args = func_get_args(); - echo static::NAME, " ".join(',', $args)." \n"; - } + const NAME = 'A'; + public static function test() { + $args = func_get_args(); + echo static::NAME, " ".join(',', $args)." \n"; + } } class B extends A { - const NAME = 'B'; + const NAME = 'B'; - public static function test() { - echo self::NAME, "\n"; - forward_static_call(array('A', 'test'), 'more', 'args'); - forward_static_call( 'test', 'other', 'args'); - } + public static function test() { + echo self::NAME, "\n"; + forward_static_call(array('A', 'test'), 'more', 'args'); + forward_static_call( 'test', 'other', 'args'); + } } B::test('foo'); function test() { - $args = func_get_args(); - echo "C ".join(',', $args)." \n"; + $args = func_get_args(); + echo "C ".join(',', $args)." \n"; } ?> diff --git a/ext/standard/tests/class_object/class_exists_basic_001.phpt b/ext/standard/tests/class_object/class_exists_basic_001.phpt index b95efecd65ce..9192ea80b767 100644 --- a/ext/standard/tests/class_object/class_exists_basic_001.phpt +++ b/ext/standard/tests/class_object/class_exists_basic_001.phpt @@ -11,7 +11,7 @@ Test class_exists() function : basic functionality echo "*** Testing class_exists() : basic functionality ***\n"; spl_autoload_register(function ($className) { - echo "In autoload($className)\n"; + echo "In autoload($className)\n"; }); echo "Calling class_exists() on non-existent class with autoload explicitly enabled:\n"; diff --git a/ext/standard/tests/class_object/forward_static_call_001.phpt b/ext/standard/tests/class_object/forward_static_call_001.phpt index 0eadad3d7900..30459f0c435b 100644 --- a/ext/standard/tests/class_object/forward_static_call_001.phpt +++ b/ext/standard/tests/class_object/forward_static_call_001.phpt @@ -5,41 +5,41 @@ forward_static_call() called from outside of a method. class A { - const NAME = 'A'; - public static function test() { - echo static::NAME, "\n"; - } + const NAME = 'A'; + public static function test() { + echo static::NAME, "\n"; + } } class B extends A { - const NAME = 'B'; + const NAME = 'B'; - public static function test() { - echo self::NAME, "\n"; - forward_static_call(array('parent', 'test')); - } + public static function test() { + echo self::NAME, "\n"; + forward_static_call(array('parent', 'test')); + } - public static function test2() { - echo self::NAME, "\n"; - forward_static_call(array('self', 'test')); - } + public static function test2() { + echo self::NAME, "\n"; + forward_static_call(array('self', 'test')); + } - public static function test3() { - echo self::NAME, "\n"; - forward_static_call(array('A', 'test')); - } + public static function test3() { + echo self::NAME, "\n"; + forward_static_call(array('A', 'test')); + } } class C extends B { - const NAME = 'C'; + const NAME = 'C'; - public static function test() - { - echo self::NAME, "\n"; - forward_static_call(array('A', 'test')); - } + public static function test() + { + echo self::NAME, "\n"; + forward_static_call(array('A', 'test')); + } } A::test(); diff --git a/ext/standard/tests/class_object/forward_static_call_002.phpt b/ext/standard/tests/class_object/forward_static_call_002.phpt index 64406feb3e40..7bc0092321c4 100644 --- a/ext/standard/tests/class_object/forward_static_call_002.phpt +++ b/ext/standard/tests/class_object/forward_static_call_002.phpt @@ -5,13 +5,13 @@ forward_static_call() from outside of a class method. class A { - public static function test() { - echo "A\n"; - } + public static function test() { + echo "A\n"; + } } function test() { - forward_static_call(array('A', 'test')); + forward_static_call(array('A', 'test')); } test(); diff --git a/ext/standard/tests/class_object/forward_static_call_003.phpt b/ext/standard/tests/class_object/forward_static_call_003.phpt index 8a846fe3da45..c2c0035f6bb8 100644 --- a/ext/standard/tests/class_object/forward_static_call_003.phpt +++ b/ext/standard/tests/class_object/forward_static_call_003.phpt @@ -5,30 +5,30 @@ forward_static_call() calling outside of the inheritance chain. class A { - const NAME = 'A'; - public static function test() { - echo static::NAME, "\n"; - } + const NAME = 'A'; + public static function test() { + echo static::NAME, "\n"; + } } class B extends A { - const NAME = 'B'; + const NAME = 'B'; - public static function test() { - echo self::NAME, "\n"; - forward_static_call(array('parent', 'test')); - } + public static function test() { + echo self::NAME, "\n"; + forward_static_call(array('parent', 'test')); + } } class C { - const NAME = 'C'; + const NAME = 'C'; - public static function test() { - echo self::NAME, "\n"; - forward_static_call(array('B', 'test')); - } + public static function test() { + echo self::NAME, "\n"; + forward_static_call(array('B', 'test')); + } } A::test(); diff --git a/ext/standard/tests/class_object/get_class_methods_basic_001.phpt b/ext/standard/tests/class_object/get_class_methods_basic_001.phpt index 843e9f1a536c..4c091da5652f 100644 --- a/ext/standard/tests/class_object/get_class_methods_basic_001.phpt +++ b/ext/standard/tests/class_object/get_class_methods_basic_001.phpt @@ -15,9 +15,9 @@ Test get_class_methods() function : basic functionality echo "*** Testing get_class_methods() : basic functionality ***\n"; class C { - function f() {} - function g() {} - function h() {} + function f() {} + function g() {} + function h() {} } echo "Argument is class name:\n"; diff --git a/ext/standard/tests/class_object/get_class_methods_basic_002.phpt b/ext/standard/tests/class_object/get_class_methods_basic_002.phpt index 8a11eba58963..59d8606d8dec 100644 --- a/ext/standard/tests/class_object/get_class_methods_basic_002.phpt +++ b/ext/standard/tests/class_object/get_class_methods_basic_002.phpt @@ -13,48 +13,48 @@ Test get_class_methods() function : basic functionality */ class C { - private function privC() {} - protected function protC() {} - public function pubC() {} + private function privC() {} + protected function protC() {} + public function pubC() {} - public static function testFromC() { - echo "Accessing C from C:\n"; - var_dump(get_class_methods("C")); - echo "Accessing D from C:\n"; - var_dump(get_class_methods("D")); - echo "Accessing X from C:\n"; - var_dump(get_class_methods("X")); - } + public static function testFromC() { + echo "Accessing C from C:\n"; + var_dump(get_class_methods("C")); + echo "Accessing D from C:\n"; + var_dump(get_class_methods("D")); + echo "Accessing X from C:\n"; + var_dump(get_class_methods("X")); + } } class D extends C { - private function privD() {} - protected function protD() {} - public function pubD() {} + private function privD() {} + protected function protD() {} + public function pubD() {} - public static function testFromD() { - echo "Accessing C from D:\n"; - var_dump(get_class_methods("C")); - echo "Accessing D from D:\n"; - var_dump(get_class_methods("D")); - echo "Accessing X from D:\n"; - var_dump(get_class_methods("X")); - } + public static function testFromD() { + echo "Accessing C from D:\n"; + var_dump(get_class_methods("C")); + echo "Accessing D from D:\n"; + var_dump(get_class_methods("D")); + echo "Accessing X from D:\n"; + var_dump(get_class_methods("X")); + } } class X { - private function privX() {} - protected function protX() {} - public function pubX() {} + private function privX() {} + protected function protX() {} + public function pubX() {} - public static function testFromX() { - echo "Accessing C from X:\n"; - var_dump(get_class_methods("C")); - echo "Accessing D from X:\n"; - var_dump(get_class_methods("D")); - echo "Accessing X from X:\n"; - var_dump(get_class_methods("X")); - } + public static function testFromX() { + echo "Accessing C from X:\n"; + var_dump(get_class_methods("C")); + echo "Accessing D from X:\n"; + var_dump(get_class_methods("D")); + echo "Accessing X from X:\n"; + var_dump(get_class_methods("X")); + } } echo "Accessing D from global scope:\n"; diff --git a/ext/standard/tests/class_object/get_class_methods_basic_003.phpt b/ext/standard/tests/class_object/get_class_methods_basic_003.phpt index c7662f86053d..e15d962b160d 100644 --- a/ext/standard/tests/class_object/get_class_methods_basic_003.phpt +++ b/ext/standard/tests/class_object/get_class_methods_basic_003.phpt @@ -13,23 +13,23 @@ Test get_class_methods() function : basic functionality */ interface I { - public function pubI(); + public function pubI(); } class C implements I { - public function pubI() {} + public function pubI() {} - private function privC() {} - protected function protC() {} - public function pubC() {} + private function privC() {} + protected function protC() {} + public function pubC() {} - public static function testFromC() { - echo "Accessing I from C:\n"; - var_dump(get_class_methods("I")); - echo "Accessing C from C:\n"; - var_dump(get_class_methods("C")); - } + public static function testFromC() { + echo "Accessing I from C:\n"; + var_dump(get_class_methods("I")); + echo "Accessing C from C:\n"; + var_dump(get_class_methods("C")); + } } diff --git a/ext/standard/tests/class_object/get_class_methods_variation_001.phpt b/ext/standard/tests/class_object/get_class_methods_variation_001.phpt index 2e2e1657af1d..e44a3d1fd917 100644 --- a/ext/standard/tests/class_object/get_class_methods_variation_001.phpt +++ b/ext/standard/tests/class_object/get_class_methods_variation_001.phpt @@ -10,7 +10,7 @@ Test get_class_methods() function : usage variations - unexpected types function test_error_handler($err_no, $err_msg, $filename, $linenum) { - echo "Error: $err_no - $err_msg\n"; + echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); diff --git a/ext/standard/tests/class_object/get_class_methods_variation_002.phpt b/ext/standard/tests/class_object/get_class_methods_variation_002.phpt index 23416234f9bd..449df8845c6d 100644 --- a/ext/standard/tests/class_object/get_class_methods_variation_002.phpt +++ b/ext/standard/tests/class_object/get_class_methods_variation_002.phpt @@ -11,7 +11,7 @@ Test get_class_methods() function : usage variations - case sensitivity echo "*** Testing get_class_methods() : usage variations ***\n"; class caseSensitivityTest { - function MyMeThOd() {} + function MyMeThOd() {} } var_dump( get_class_methods('CasesensitivitytesT') ); diff --git a/ext/standard/tests/class_object/get_declared_classes_basic_001.phpt b/ext/standard/tests/class_object/get_declared_classes_basic_001.phpt index 78d27fa3a50f..519f8beae0ac 100644 --- a/ext/standard/tests/class_object/get_declared_classes_basic_001.phpt +++ b/ext/standard/tests/class_object/get_declared_classes_basic_001.phpt @@ -16,9 +16,9 @@ echo "\n-- Testing get_declared_classes() function with Zero arguments --\n"; var_dump(get_declared_classes()); foreach (get_declared_classes() as $class) { - if (!class_exists($class)) { - echo "Error: $class is not a valid class.\n"; - } + if (!class_exists($class)) { + echo "Error: $class is not a valid class.\n"; + } } echo "\n-- Ensure userspace classes are listed --\n"; diff --git a/ext/standard/tests/class_object/get_declared_interfaces_basic_001.phpt b/ext/standard/tests/class_object/get_declared_interfaces_basic_001.phpt index 749ee69ab749..d328a02a03eb 100644 --- a/ext/standard/tests/class_object/get_declared_interfaces_basic_001.phpt +++ b/ext/standard/tests/class_object/get_declared_interfaces_basic_001.phpt @@ -16,9 +16,9 @@ echo "\n-- Testing get_declared_interfaces() function with Zero arguments --\n"; var_dump(get_declared_interfaces()); foreach (get_declared_interfaces() as $interface) { - if (!interface_exists($interface)) { - echo "Error: $interface is not a valid interface.\n"; - } + if (!interface_exists($interface)) { + echo "Error: $interface is not a valid interface.\n"; + } } echo "\n-- Ensure userspace classes are not listed --\n"; diff --git a/ext/standard/tests/class_object/get_declared_traits_basic_001.phpt b/ext/standard/tests/class_object/get_declared_traits_basic_001.phpt index 8ce2d2df561c..2ca0ce00ca6e 100644 --- a/ext/standard/tests/class_object/get_declared_traits_basic_001.phpt +++ b/ext/standard/tests/class_object/get_declared_traits_basic_001.phpt @@ -18,9 +18,9 @@ echo "\n-- Testing get_declared_traits() function with Zero arguments --\n"; var_dump(get_declared_traits()); foreach (get_declared_traits() as $trait) { - if (!trait_exists($trait)) { - echo "Error: $trait is not a valid trait.\n"; - } + if (!trait_exists($trait)) { + echo "Error: $trait is not a valid trait.\n"; + } } echo "\n-- Ensure trait is listed --\n"; diff --git a/ext/standard/tests/class_object/get_object_vars_basic_001.phpt b/ext/standard/tests/class_object/get_object_vars_basic_001.phpt index 253ebd2be4ee..1133202cbf1a 100644 --- a/ext/standard/tests/class_object/get_object_vars_basic_001.phpt +++ b/ext/standard/tests/class_object/get_object_vars_basic_001.phpt @@ -9,40 +9,40 @@ get_object_vars(): visibility from static methods (target object passed as arg) */ Class A { - private $hiddenPriv = 'A::hiddenPriv'; + private $hiddenPriv = 'A::hiddenPriv'; - public static function test($b) { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($b)); - } + public static function test($b) { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($b)); + } } Class B extends A { - private $hiddenPriv = 'B::hiddenPriv'; - private $priv = 'B::priv'; - protected $prot = 'B::prot'; - public $pub = 'B::pub'; + private $hiddenPriv = 'B::hiddenPriv'; + private $priv = 'B::priv'; + protected $prot = 'B::prot'; + public $pub = 'B::pub'; - public static function test($b) { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($b)); - } + public static function test($b) { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($b)); + } } Class C extends B { - private $hiddenPriv = 'C::hiddenPriv'; + private $hiddenPriv = 'C::hiddenPriv'; - public static function test($b) { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($b)); - } + public static function test($b) { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($b)); + } } Class X { - public static function test($b) { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($b)); - } + public static function test($b) { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($b)); + } } diff --git a/ext/standard/tests/class_object/get_object_vars_basic_002.phpt b/ext/standard/tests/class_object/get_object_vars_basic_002.phpt index 41a1758baaa0..ff0664ea46d2 100644 --- a/ext/standard/tests/class_object/get_object_vars_basic_002.phpt +++ b/ext/standard/tests/class_object/get_object_vars_basic_002.phpt @@ -9,24 +9,24 @@ get_object_vars(): visibility from non static methods (target object passed as a */ Class A { - private $hiddenPriv = 'A::hiddenPriv'; + private $hiddenPriv = 'A::hiddenPriv'; - public function testA($b) { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($b)); - } + public function testA($b) { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($b)); + } } Class B extends A { - private $hiddenPriv = 'B::hiddenPriv'; - private $priv = 'B::priv'; - protected $prot = 'B::prot'; - public $pub = 'B::pub'; - - public function testB($b) { - echo __METHOD__ . "\n"; - var_dump(get_object_vars($b)); - } + private $hiddenPriv = 'B::hiddenPriv'; + private $priv = 'B::priv'; + protected $prot = 'B::prot'; + public $pub = 'B::pub'; + + public function testB($b) { + echo __METHOD__ . "\n"; + var_dump(get_object_vars($b)); + } } diff --git a/ext/standard/tests/class_object/get_object_vars_variation_001.phpt b/ext/standard/tests/class_object/get_object_vars_variation_001.phpt index 2a310227a53a..0cc7d492c8b9 100644 --- a/ext/standard/tests/class_object/get_object_vars_variation_001.phpt +++ b/ext/standard/tests/class_object/get_object_vars_variation_001.phpt @@ -9,7 +9,7 @@ get_object_vars() - ensure statics are not shown */ Class A { - public static $var = 'hello'; + public static $var = 'hello'; } $a = new A; diff --git a/ext/standard/tests/class_object/get_parent_class_variation_002.phpt b/ext/standard/tests/class_object/get_parent_class_variation_002.phpt index 2aaa93fa8aaa..d564ad3cd0ee 100644 --- a/ext/standard/tests/class_object/get_parent_class_variation_002.phpt +++ b/ext/standard/tests/class_object/get_parent_class_variation_002.phpt @@ -9,11 +9,11 @@ Test get_parent_class() function : usage variations - unexpected argument type. */ spl_autoload_register(function ($className) { - echo "In autoload($className)\n"; + echo "In autoload($className)\n"; }); function test_error_handler($err_no, $err_msg, $filename, $linenum) { - echo "Error: $err_no - $err_msg\n"; + echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); diff --git a/ext/standard/tests/class_object/is_a.phpt b/ext/standard/tests/class_object/is_a.phpt index 92d289ba18b8..efb03b343492 100644 --- a/ext/standard/tests/class_object/is_a.phpt +++ b/ext/standard/tests/class_object/is_a.phpt @@ -4,51 +4,51 @@ is_a and is_subclass_of behaviour (with and without autoload) >> With Defined class\n"; - echo str_pad('is_a( OBJECT:'.get_class($this).', '.$sub.') = ', 60) . (is_a($this, $sub) ? 'yes' : 'no')."\n"; - echo str_pad('is_a( STRING:'.get_class($this).', '.$sub.') = ', 60). (is_a(get_class($this), $sub) ? 'yes' : 'no')."\n"; - echo str_pad('is_a( STRING:'.get_class($this).', '.$sub.', true) = ', 60). (is_a(get_class($this), $sub, true) ? 'yes' : 'no')."\n"; - echo str_pad('is_subclass_of( OBJECT:'.get_class($this).', '.$sub.') = ', 60). (is_subclass_of($this, $sub) ? 'yes' : 'no')."\n"; - echo str_pad('is_subclass_of( STRING:'.get_class($this).', '.$sub.') = ', 60). (is_subclass_of(get_class($this), $sub) ? 'yes' : 'no')."\n"; - echo str_pad('is_subclass_of( STRING:'.get_class($this).', '.$sub.',false) = ', 60). (is_subclass_of(get_class($this), $sub , false) ? 'yes' : 'no')."\n"; - - // with autoload options.. - echo ">>> With Undefined\n"; - echo str_pad('is_a( STRING:undefB, '.$sub.',true) = ', 60). (is_a('undefB', $sub, true) ? 'yes' : 'no')."\n"; - echo str_pad('is_a( STRING:undefB, '.$sub.') = ', 60). (is_a('undefB', $sub) ? 'yes' : 'no')."\n"; - echo str_pad('is_subclass_of( STRING:undefB, '.$sub.',false) = ', 60). (is_subclass_of('undefB', $sub, false) ? 'yes' : 'no')."\n"; - echo str_pad('is_subclass_of( STRING:undefB, '.$sub.') = ', 60). (is_subclass_of('undefB', $sub) ? 'yes' : 'no')."\n"; - } - function test() { - echo $this->_is_a('base'); - echo $this->_is_a('derived_a'); - echo $this->_is_a('if_a'); - echo $this->_is_a('undefA'); - echo "\n"; - } + function _is_a($sub) { + + echo "\n>>> With Defined class\n"; + echo str_pad('is_a( OBJECT:'.get_class($this).', '.$sub.') = ', 60) . (is_a($this, $sub) ? 'yes' : 'no')."\n"; + echo str_pad('is_a( STRING:'.get_class($this).', '.$sub.') = ', 60). (is_a(get_class($this), $sub) ? 'yes' : 'no')."\n"; + echo str_pad('is_a( STRING:'.get_class($this).', '.$sub.', true) = ', 60). (is_a(get_class($this), $sub, true) ? 'yes' : 'no')."\n"; + echo str_pad('is_subclass_of( OBJECT:'.get_class($this).', '.$sub.') = ', 60). (is_subclass_of($this, $sub) ? 'yes' : 'no')."\n"; + echo str_pad('is_subclass_of( STRING:'.get_class($this).', '.$sub.') = ', 60). (is_subclass_of(get_class($this), $sub) ? 'yes' : 'no')."\n"; + echo str_pad('is_subclass_of( STRING:'.get_class($this).', '.$sub.',false) = ', 60). (is_subclass_of(get_class($this), $sub , false) ? 'yes' : 'no')."\n"; + + // with autoload options.. + echo ">>> With Undefined\n"; + echo str_pad('is_a( STRING:undefB, '.$sub.',true) = ', 60). (is_a('undefB', $sub, true) ? 'yes' : 'no')."\n"; + echo str_pad('is_a( STRING:undefB, '.$sub.') = ', 60). (is_a('undefB', $sub) ? 'yes' : 'no')."\n"; + echo str_pad('is_subclass_of( STRING:undefB, '.$sub.',false) = ', 60). (is_subclass_of('undefB', $sub, false) ? 'yes' : 'no')."\n"; + echo str_pad('is_subclass_of( STRING:undefB, '.$sub.') = ', 60). (is_subclass_of('undefB', $sub) ? 'yes' : 'no')."\n"; + } + function test() { + echo $this->_is_a('base'); + echo $this->_is_a('derived_a'); + echo $this->_is_a('if_a'); + echo $this->_is_a('undefA'); + echo "\n"; + } } class derived_a extends base implements if_a { - function f_a() {} + function f_a() {} } class derived_b extends base implements if_a, if_b { - function f_a() {} - function f_b() {} + function f_a() {} + function f_b() {} } class derived_c extends derived_a implements if_b { - function f_b() {} + function f_b() {} } class derived_d extends derived_c { diff --git a/ext/standard/tests/class_object/is_subclass_of_variation_001.phpt b/ext/standard/tests/class_object/is_subclass_of_variation_001.phpt index 961ae9628767..37743f393efe 100644 --- a/ext/standard/tests/class_object/is_subclass_of_variation_001.phpt +++ b/ext/standard/tests/class_object/is_subclass_of_variation_001.phpt @@ -9,11 +9,11 @@ Test is_subclass_of() function : usage variations - unexpected type for arg 1 */ // Note: basic use cases in Zend/tests/is_a.phpt spl_autoload_register(function ($className) { - echo "In autoload($className)\n"; + echo "In autoload($className)\n"; }); function test_error_handler($err_no, $err_msg, $filename, $linenum) { - echo "Error: $err_no - $err_msg\n"; + echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); diff --git a/ext/standard/tests/class_object/is_subclass_of_variation_004.phpt b/ext/standard/tests/class_object/is_subclass_of_variation_004.phpt index dba37cc3f4fb..c9409dcac878 100644 --- a/ext/standard/tests/class_object/is_subclass_of_variation_004.phpt +++ b/ext/standard/tests/class_object/is_subclass_of_variation_004.phpt @@ -9,11 +9,11 @@ Test is_subclass_of() function : usage variations - unexpected type for arg 1 w */ // Note: basic use cases in Zend/tests/is_a.phpt spl_autoload_register(function ($className) { - echo "In autoload($className)\n"; + echo "In autoload($className)\n"; }); function test_error_handler($err_no, $err_msg, $filename, $linenum) { - echo "Error: $err_no - $err_msg\n"; + echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); diff --git a/ext/standard/tests/class_object/method_exists_basic_001.phpt b/ext/standard/tests/class_object/method_exists_basic_001.phpt index c0b656b3f9e5..5d1e2c89dfbb 100644 --- a/ext/standard/tests/class_object/method_exists_basic_001.phpt +++ b/ext/standard/tests/class_object/method_exists_basic_001.phpt @@ -9,30 +9,30 @@ method_exists() on userspace classes; static & non-static methods with various v */ Class B { - public function inherit_pub() {} - protected function inherit_prot() {} - private function inherit_priv() {} - static public function inherit_static_pub() {} - static protected function inherit_static_prot() {} - static private function inherit_static_priv() {} + public function inherit_pub() {} + protected function inherit_prot() {} + private function inherit_priv() {} + static public function inherit_static_pub() {} + static protected function inherit_static_prot() {} + static private function inherit_static_priv() {} } Class C extends B { - public function pub() {} - protected function prot() {} - private function priv() {} - static public function static_pub() {} - static protected function static_prot() {} - static private function static_priv() {} + public function pub() {} + protected function prot() {} + private function priv() {} + static public function static_pub() {} + static protected function static_prot() {} + static private function static_priv() {} } $methods = array( - 'inherit_pub', 'inherit_prot', 'inherit_priv', - 'inherit_static_pub', 'inherit_static_prot', 'inherit_static_priv', - 'pub', 'prot', 'priv', - 'static_pub', 'static_prot', 'static_priv', - 'non_existent'); + 'inherit_pub', 'inherit_prot', 'inherit_priv', + 'inherit_static_pub', 'inherit_static_prot', 'inherit_static_priv', + 'pub', 'prot', 'priv', + 'static_pub', 'static_prot', 'static_priv', + 'non_existent'); echo "\n ---(Using string class name)---\n"; foreach ($methods as $method) { diff --git a/ext/standard/tests/class_object/method_exists_basic_003.phpt b/ext/standard/tests/class_object/method_exists_basic_003.phpt index e92b7a91353e..42225a8ebd7a 100644 --- a/ext/standard/tests/class_object/method_exists_basic_003.phpt +++ b/ext/standard/tests/class_object/method_exists_basic_003.phpt @@ -9,7 +9,7 @@ method_exists() on non-existent class, with __autoload(). */ spl_autoload_register(function ($name) { - echo "In autoload($name)\n"; + echo "In autoload($name)\n"; }); var_dump(method_exists('UndefC', 'func')); diff --git a/ext/standard/tests/class_object/method_exists_variation_001.phpt b/ext/standard/tests/class_object/method_exists_variation_001.phpt index b975f819583a..0f2293cf7b42 100644 --- a/ext/standard/tests/class_object/method_exists_variation_001.phpt +++ b/ext/standard/tests/class_object/method_exists_variation_001.phpt @@ -9,11 +9,11 @@ Test method_exists() function : usage variations - unexpected type for arg 1 */ spl_autoload_register(function ($className) { - echo "In autoload($className)\n"; + echo "In autoload($className)\n"; }); function test_error_handler($err_no, $err_msg, $filename, $linenum) { - echo "Error: $err_no - $err_msg\n"; + echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); diff --git a/ext/standard/tests/class_object/method_exists_variation_003.phpt b/ext/standard/tests/class_object/method_exists_variation_003.phpt index d5835b0b8747..72b63f1e33d0 100644 --- a/ext/standard/tests/class_object/method_exists_variation_003.phpt +++ b/ext/standard/tests/class_object/method_exists_variation_003.phpt @@ -11,7 +11,7 @@ Test method_exists() function : variation - Case sensitivity echo "*** Testing method_exists() : variation ***\n"; Class caseSensitivityTest { - public function myMethod() {} + public function myMethod() {} } var_dump(method_exists(new casesensitivitytest, 'myMetHOD')); diff --git a/ext/standard/tests/class_object/trait_exists_basic_001.phpt b/ext/standard/tests/class_object/trait_exists_basic_001.phpt index 708c6c91e4af..55b92da0d2dd 100644 --- a/ext/standard/tests/class_object/trait_exists_basic_001.phpt +++ b/ext/standard/tests/class_object/trait_exists_basic_001.phpt @@ -11,7 +11,7 @@ Test trait_exists() function : basic functionality echo "*** Testing trait_exists() : basic functionality ***\n"; spl_autoload_register(function ($traitName) { - echo "In autoload($traitName)\n"; + echo "In autoload($traitName)\n"; }); trait MyTrait {} diff --git a/ext/standard/tests/dir/bug72625.phpt b/ext/standard/tests/dir/bug72625.phpt index e3594414add8..2ea6da969998 100644 --- a/ext/standard/tests/dir/bug72625.phpt +++ b/ext/standard/tests/dir/bug72625.phpt @@ -11,7 +11,7 @@ if (substr(PHP_OS, 0, 3) != 'WIN') { $base = sys_get_temp_dir() . "/" . md5(uniqid()); while (strlen($base) < 260) { - $base = "$base/" . md5(uniqid()); + $base = "$base/" . md5(uniqid()); } $f0 = "$base/_test/documents/projects/myproject/vendor/name/library/classpath"; @@ -22,21 +22,21 @@ mkdir($f0, 0777, true); var_dump( - $f0, - file_exists($f0), - realpath($f0), - dirname($f0), - - $f1, - file_exists($f1), - realpath($f1), - dirname($f1) + $f0, + file_exists($f0), + realpath($f0), + dirname($f0), + + $f1, + file_exists($f1), + realpath($f1), + dirname($f1) ); $tmp = $f0; while ($tmp > $base) { - rmdir($tmp); - $tmp = dirname($tmp); + rmdir($tmp); + $tmp = dirname($tmp); } ?> diff --git a/ext/standard/tests/dir/bug73877.phpt b/ext/standard/tests/dir/bug73877.phpt index 633a4eef819f..ceb272ea6527 100644 --- a/ext/standard/tests/dir/bug73877.phpt +++ b/ext/standard/tests/dir/bug73877.phpt @@ -21,10 +21,10 @@ mkdir($dir1); `mklink /J $junk0 $dir0`; var_dump( - readlink($dir0), - readlink($dir1), - readlink($junk0), - strlen(readlink($dir0)) === strlen(readlink($junk0)) + readlink($dir0), + readlink($dir1), + readlink($junk0), + strlen(readlink($dir0)) === strlen(readlink($junk0)) ); ?> diff --git a/ext/standard/tests/dir/closedir_basic-win32-mb.phpt b/ext/standard/tests/dir/closedir_basic-win32-mb.phpt index dad5b2b65737..7db6b7740a8a 100644 --- a/ext/standard/tests/dir/closedir_basic-win32-mb.phpt +++ b/ext/standard/tests/dir/closedir_basic-win32-mb.phpt @@ -34,7 +34,7 @@ echo "\n-- Call closedir() with \$dir_handle argument supplied: --\n"; $dh2 = opendir($dir_path); if ((int)$dh1 === (int)$dh2) { - echo "\nNo new resource created\n"; + echo "\nNo new resource created\n"; } var_dump(closedir($dh2)); echo "-- Check Directory Handle: --\n"; diff --git a/ext/standard/tests/dir/closedir_basic.phpt b/ext/standard/tests/dir/closedir_basic.phpt index 41b51f208078..5ec72cd8a5c4 100644 --- a/ext/standard/tests/dir/closedir_basic.phpt +++ b/ext/standard/tests/dir/closedir_basic.phpt @@ -28,7 +28,7 @@ echo "\n-- Call closedir() with \$dir_handle argument supplied: --\n"; $dh2 = opendir($dir_path); if ((int)$dh1 === (int)$dh2) { - echo "\nNo new resource created\n"; + echo "\nNo new resource created\n"; } var_dump(closedir($dh2)); echo "-- Check Directory Handle: --\n"; diff --git a/ext/standard/tests/dir/closedir_variation3.phpt b/ext/standard/tests/dir/closedir_variation3.phpt index 65418ca6360b..1d9c644a3e65 100644 --- a/ext/standard/tests/dir/closedir_variation3.phpt +++ b/ext/standard/tests/dir/closedir_variation3.phpt @@ -27,7 +27,7 @@ echo "\n-- Check file pointer: --\n"; var_dump($fp); if(is_resource($fp)) { - fclose($fp); + fclose($fp); } ?> --EXPECTF-- diff --git a/ext/standard/tests/dir/dir_bug73971.phpt b/ext/standard/tests/dir/dir_bug73971.phpt index e32516ea156b..1fd3eb669129 100644 --- a/ext/standard/tests/dir/dir_bug73971.phpt +++ b/ext/standard/tests/dir/dir_bug73971.phpt @@ -26,7 +26,7 @@ $d->close(); echo "\ntest DirectoryIterator\n"; $dir = new DirectoryIterator($base); foreach ($dir as $finfo) { - var_dump($finfo->getFilename()); + var_dump($finfo->getFilename()); } ?> diff --git a/ext/standard/tests/dir/opendir_variation3-win32-mb.phpt b/ext/standard/tests/dir/opendir_variation3-win32-mb.phpt index 7185cff7377e..82f2a330d07c 100644 --- a/ext/standard/tests/dir/opendir_variation3-win32-mb.phpt +++ b/ext/standard/tests/dir/opendir_variation3-win32-mb.phpt @@ -29,9 +29,9 @@ echo "\n-- Open directory second time: --\n"; var_dump($dh2 = opendir($path)); if ($dh1 !== $dh2) { - echo "\nNew resource created\n"; + echo "\nNew resource created\n"; } else { - echo "\nNo new resource created\n"; + echo "\nNo new resource created\n"; } closedir($dh1); diff --git a/ext/standard/tests/dir/opendir_variation3.phpt b/ext/standard/tests/dir/opendir_variation3.phpt index 83a265ab8150..2169684fba92 100644 --- a/ext/standard/tests/dir/opendir_variation3.phpt +++ b/ext/standard/tests/dir/opendir_variation3.phpt @@ -23,9 +23,9 @@ echo "\n-- Open directory second time: --\n"; var_dump($dh2 = opendir($path)); if ($dh1 !== $dh2) { - echo "\nNew resource created\n"; + echo "\nNew resource created\n"; } else { - echo "\nNo new resource created\n"; + echo "\nNo new resource created\n"; } closedir($dh1); diff --git a/ext/standard/tests/dir/opendir_variation4-win32-mb.phpt b/ext/standard/tests/dir/opendir_variation4-win32-mb.phpt index 319e178a2ef5..00d09985def0 100644 --- a/ext/standard/tests/dir/opendir_variation4-win32-mb.phpt +++ b/ext/standard/tests/dir/opendir_variation4-win32-mb.phpt @@ -70,10 +70,10 @@ clean_dh($dh); * and to ensure directory is not in use at CLEAN section so can me removed */ function clean_dh($dh){ - if (is_resource($dh)) { - closedir($dh); - } - unset($dh); + if (is_resource($dh)) { + closedir($dh); + } + unset($dh); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/opendir_variation4.phpt b/ext/standard/tests/dir/opendir_variation4.phpt index 6434c9ef52e4..c206ac4d1e4b 100644 --- a/ext/standard/tests/dir/opendir_variation4.phpt +++ b/ext/standard/tests/dir/opendir_variation4.phpt @@ -64,10 +64,10 @@ clean_dh($dh); * and to ensure directory is not in use at CLEAN section so can me removed */ function clean_dh($dh){ - if (is_resource($dh)) { - closedir($dh); - } - unset($dh); + if (is_resource($dh)) { + closedir($dh); + } + unset($dh); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/opendir_variation5.phpt b/ext/standard/tests/dir/opendir_variation5.phpt index f8023288d117..15e6e16c8fa0 100644 --- a/ext/standard/tests/dir/opendir_variation5.phpt +++ b/ext/standard/tests/dir/opendir_variation5.phpt @@ -57,10 +57,10 @@ $dir_handle2 = opendir($child_dir_path); // try to open, expected failure var_dump( $dir_handle2 ); // dump it if (is_resource($dir_handle1)) { - closedir($dir_handle1); + closedir($dir_handle1); } if (is_resource($dir_handle2)) { - closedir($dir_handle2); + closedir($dir_handle2); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/opendir_variation7.phpt b/ext/standard/tests/dir/opendir_variation7.phpt index fff52b88d9ca..aa45f443f0e6 100644 --- a/ext/standard/tests/dir/opendir_variation7.phpt +++ b/ext/standard/tests/dir/opendir_variation7.phpt @@ -48,23 +48,23 @@ $permission_values = array( $iterator = 1; foreach ($permission_values as $perm) { - echo "\n-- Iteration $iterator --\n"; - // try to remove the dir if exists & create - if (is_dir($dir_path)){ - chmod ($dir_path, 0777); // change dir permission to allow all operation - rmdir ($dir_path); - } - mkdir($dir_path); - - // change the dir permission to test dir on it - var_dump( chmod($dir_path, $perm) ); - - var_dump($dh = opendir($dir_path)); - - if (is_resource($dh)) { - closedir($dh); - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + // try to remove the dir if exists & create + if (is_dir($dir_path)){ + chmod ($dir_path, 0777); // change dir permission to allow all operation + rmdir ($dir_path); + } + mkdir($dir_path); + + // change the dir permission to test dir on it + var_dump( chmod($dir_path, $perm) ); + + var_dump($dh = opendir($dir_path)); + + if (is_resource($dh)) { + closedir($dh); + } + $iterator++; } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/readdir_basic-win32-mb.phpt b/ext/standard/tests/dir/readdir_basic-win32-mb.phpt index 18ee74e6b3b5..7b371ec3ace6 100644 --- a/ext/standard/tests/dir/readdir_basic-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_basic-win32-mb.phpt @@ -31,22 +31,22 @@ echo "\n-- Call readdir() with \$path argument --\n"; var_dump($dh = opendir($path)); $a = array(); while( FALSE !== ($file = readdir($dh)) ) { - $a[] = $file; + $a[] = $file; } sort($a); foreach($a as $file) { - var_dump($file); + var_dump($file); } echo "\n-- Call readdir() without \$path argument --\n"; var_dump($dh = opendir($path)); $a = array(); while( FALSE !== ( $file = readdir() ) ) { - $a[] = $file; + $a[] = $file; } sort($a); foreach($a as $file) { - var_dump($file); + var_dump($file); } delete_files($path, 3); diff --git a/ext/standard/tests/dir/readdir_basic.phpt b/ext/standard/tests/dir/readdir_basic.phpt index 9a45ee4002bb..16437eb5a66d 100644 --- a/ext/standard/tests/dir/readdir_basic.phpt +++ b/ext/standard/tests/dir/readdir_basic.phpt @@ -25,22 +25,22 @@ echo "\n-- Call readdir() with \$path argument --\n"; var_dump($dh = opendir($path)); $a = array(); while( FALSE !== ($file = readdir($dh)) ) { - $a[] = $file; + $a[] = $file; } sort($a); foreach($a as $file) { - var_dump($file); + var_dump($file); } echo "\n-- Call readdir() without \$path argument --\n"; var_dump($dh = opendir($path)); $a = array(); while( FALSE !== ( $file = readdir() ) ) { - $a[] = $file; + $a[] = $file; } sort($a); foreach($a as $file) { - var_dump($file); + var_dump($file); } delete_files($path, 3); diff --git a/ext/standard/tests/dir/readdir_variation2-win32-mb.phpt b/ext/standard/tests/dir/readdir_variation2-win32-mb.phpt index 01ae34fb8821..4e0a8d715868 100644 --- a/ext/standard/tests/dir/readdir_variation2-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_variation2-win32-mb.phpt @@ -25,18 +25,18 @@ $dir_handle = opendir($path); echo "\n-- Pass an empty directory to readdir() --\n"; function mysort($a,$b) { - return strlen($a) > strlen($b) ? 1 : -1; + return strlen($a) > strlen($b) ? 1 : -1; } $entries = array(); while(FALSE !== ($file = readdir($dir_handle))){ - $entries[] = $file; + $entries[] = $file; } closedir($dir_handle); usort($entries, "mysort"); foreach($entries as $entry) { - var_dump($entry); + var_dump($entry); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/readdir_variation2.phpt b/ext/standard/tests/dir/readdir_variation2.phpt index 3fb35a778e7e..979c4f40571c 100644 --- a/ext/standard/tests/dir/readdir_variation2.phpt +++ b/ext/standard/tests/dir/readdir_variation2.phpt @@ -19,18 +19,18 @@ $dir_handle = opendir($path); echo "\n-- Pass an empty directory to readdir() --\n"; function mysort($a,$b) { - return strlen($a) > strlen($b) ? 1 : -1; + return strlen($a) > strlen($b) ? 1 : -1; } $entries = array(); while(FALSE !== ($file = readdir($dir_handle))){ - $entries[] = $file; + $entries[] = $file; } closedir($dir_handle); usort($entries, "mysort"); foreach($entries as $entry) { - var_dump($entry); + var_dump($entry); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/readdir_variation3-win32-mb.phpt b/ext/standard/tests/dir/readdir_variation3-win32-mb.phpt index b3f831e067d9..594838fe1172 100644 --- a/ext/standard/tests/dir/readdir_variation3-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_variation3-win32-mb.phpt @@ -35,9 +35,9 @@ create_files($path_sub, 2); $dir_handle = opendir($path_top); while(FALSE !== ($file = readdir($dir_handle))) { - // different OS order files differently so will - // store file names into an array so can use sorted in expected output - $contents[] = $file; + // different OS order files differently so will + // store file names into an array so can use sorted in expected output + $contents[] = $file; } // more important to check that all contents are present than order they are returned in diff --git a/ext/standard/tests/dir/readdir_variation3.phpt b/ext/standard/tests/dir/readdir_variation3.phpt index 6adac51215fc..6cc6f9e0a45d 100644 --- a/ext/standard/tests/dir/readdir_variation3.phpt +++ b/ext/standard/tests/dir/readdir_variation3.phpt @@ -29,9 +29,9 @@ create_files($path_sub, 2); $dir_handle = opendir($path_top); while(FALSE !== ($file = readdir($dir_handle))) { - // different OS order files differently so will - // store file names into an array so can use sorted in expected output - $contents[] = $file; + // different OS order files differently so will + // store file names into an array so can use sorted in expected output + $contents[] = $file; } // more important to check that all contents are present than order they are returned in diff --git a/ext/standard/tests/dir/readdir_variation4-win32-mb.phpt b/ext/standard/tests/dir/readdir_variation4-win32-mb.phpt index 8e9e3b610ef9..c2bf8b16165e 100644 --- a/ext/standard/tests/dir/readdir_variation4-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_variation4-win32-mb.phpt @@ -55,24 +55,24 @@ $inputs = array( $iterator = 1; foreach($inputs as $key => $input) { - echo "\n-- Iteration $iterator --\n"; - $handle = "fp{$iterator}"; - var_dump( $$handle = @fopen($dir_path . "ç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™$input.tmp", 'w') ); - var_dump( fwrite($$handle, $key)); - fclose($$handle); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + $handle = "fp{$iterator}"; + var_dump( $$handle = @fopen($dir_path . "ç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™$input.tmp", 'w') ); + var_dump( fwrite($$handle, $key)); + fclose($$handle); + $iterator++; }; echo "\n-- Call to readdir() --\n"; $dir_handle = opendir($dir_path); while(FALSE !== ($file = readdir($dir_handle))){ - // different OS order files differently so will - // store file names into an array so can use sorted in expected output - $contents[] = $file; + // different OS order files differently so will + // store file names into an array so can use sorted in expected output + $contents[] = $file; - // remove files while going through directory - @unlink($dir_path . $file); + // remove files while going through directory + @unlink($dir_path . $file); } // more important to check that all contents are present than order they are returned in diff --git a/ext/standard/tests/dir/readdir_variation4.phpt b/ext/standard/tests/dir/readdir_variation4.phpt index 8bfe176946d8..37e5b80ecb2a 100644 --- a/ext/standard/tests/dir/readdir_variation4.phpt +++ b/ext/standard/tests/dir/readdir_variation4.phpt @@ -49,24 +49,24 @@ $inputs = array( $iterator = 1; foreach($inputs as $key => $input) { - echo "\n-- Iteration $iterator --\n"; - $handle = "fp{$iterator}"; - var_dump( $$handle = fopen(@"$dir_path$input.tmp", 'w') ); - var_dump( fwrite($$handle, $key)); - fclose($$handle); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + $handle = "fp{$iterator}"; + var_dump( $$handle = fopen(@"$dir_path$input.tmp", 'w') ); + var_dump( fwrite($$handle, $key)); + fclose($$handle); + $iterator++; }; echo "\n-- Call to readdir() --\n"; $dir_handle = opendir($dir_path); while(FALSE !== ($file = readdir($dir_handle))){ - // different OS order files differently so will - // store file names into an array so can use sorted in expected output - $contents[] = $file; + // different OS order files differently so will + // store file names into an array so can use sorted in expected output + $contents[] = $file; - // remove files while going through directory - @unlink($dir_path . $file); + // remove files while going through directory + @unlink($dir_path . $file); } // more important to check that all contents are present than order they are returned in diff --git a/ext/standard/tests/dir/readdir_variation5.phpt b/ext/standard/tests/dir/readdir_variation5.phpt index e9d88dc835e8..d1cdc1bd586b 100644 --- a/ext/standard/tests/dir/readdir_variation5.phpt +++ b/ext/standard/tests/dir/readdir_variation5.phpt @@ -46,23 +46,23 @@ $permission_values = array( // Open directory with different permission values, read and close, expected: none of them to succeed. $iterator = 1; foreach($permission_values as $perm) { - echo "\n-- Iteration $iterator --\n"; + echo "\n-- Iteration $iterator --\n"; - if (is_dir($dir_path)) { - chmod ($dir_path, 0777); // change dir permission to allow all operation - rmdir ($dir_path); - } - mkdir($dir_path); + if (is_dir($dir_path)) { + chmod ($dir_path, 0777); // change dir permission to allow all operation + rmdir ($dir_path); + } + mkdir($dir_path); - // change the dir permission to test dir on it - var_dump( chmod($dir_path, $perm) ); - var_dump($dh = opendir($dir_path)); + // change the dir permission to test dir on it + var_dump( chmod($dir_path, $perm) ); + var_dump($dh = opendir($dir_path)); - echo "-- Calling readdir() --\n"; - var_dump(readdir($dh)); + echo "-- Calling readdir() --\n"; + var_dump(readdir($dh)); - closedir($dh); - $iterator++; + closedir($dh); + $iterator++; } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt b/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt index 3646316247f3..806fdec87e6b 100644 --- a/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt +++ b/ext/standard/tests/dir/readdir_variation6-win32-mb.phpt @@ -39,21 +39,21 @@ opendir($dir_path); echo "\n-- Reading Directory Contents with Previous Handle --\n"; $a = array(); while (FALSE !== ($file = readdir($dir_handle1))) { - $a[] = $file; + $a[] = $file; } sort($a); foreach ($a as $file) { - var_dump($file); + var_dump($file); } echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n"; $a = array(); while (FALSE !== ($file = readdir())) { - $a[] = $file; + $a[] = $file; } sort($a); foreach ($a as $file) { - var_dump($file); + var_dump($file); } // delete temporary files diff --git a/ext/standard/tests/dir/readdir_variation6.phpt b/ext/standard/tests/dir/readdir_variation6.phpt index 19bb906f14cd..532a20fd21c7 100644 --- a/ext/standard/tests/dir/readdir_variation6.phpt +++ b/ext/standard/tests/dir/readdir_variation6.phpt @@ -33,21 +33,21 @@ opendir($dir_path); echo "\n-- Reading Directory Contents with Previous Handle --\n"; $a = array(); while (FALSE !== ($file = readdir($dir_handle1))) { - $a[] = $file; + $a[] = $file; } sort($a); foreach ($a as $file) { - var_dump($file); + var_dump($file); } echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n"; $a = array(); while (FALSE !== ($file = readdir())) { - $a[] = $file; + $a[] = $file; } sort($a); foreach ($a as $file) { - var_dump($file); + var_dump($file); } // delete temporary files diff --git a/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt b/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt index c16e993f83fb..fc5539666daa 100644 --- a/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt +++ b/ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt @@ -36,7 +36,7 @@ var_dump($dh2 = opendir($dir_path2)); $data = array(); echo "\n-- Read and rewind first directory (argument supplied) --\n"; while(FALSE !== $file1 = readdir($dh1)) { - $data[] = $file1; + $data[] = $file1; } $first = $data[0]; sort($data); @@ -48,7 +48,7 @@ var_dump(readdir($dh1) == $first); $data = array(); echo "\n-- Read and rewind second directory (no argument supplied) --\n"; while(FALSE !== $file2 = readdir()) { - $data[] = $file2; + $data[] = $file2; } $first = $data[0]; sort($data); diff --git a/ext/standard/tests/dir/rewinddir_basic.phpt b/ext/standard/tests/dir/rewinddir_basic.phpt index 1750121b3e69..714d75266c08 100644 --- a/ext/standard/tests/dir/rewinddir_basic.phpt +++ b/ext/standard/tests/dir/rewinddir_basic.phpt @@ -30,7 +30,7 @@ var_dump($dh2 = opendir($dir_path2)); $data = array(); echo "\n-- Read and rewind first directory (argument supplied) --\n"; while(FALSE !== $file1 = readdir($dh1)) { - $data[] = $file1; + $data[] = $file1; } $first = $data[0]; sort($data); @@ -42,7 +42,7 @@ var_dump(readdir($dh1) == $first); $data = array(); echo "\n-- Read and rewind second directory (no argument supplied) --\n"; while(FALSE !== $file2 = readdir()) { - $data[] = $file2; + $data[] = $file2; } $first = $data[0]; sort($data); diff --git a/ext/standard/tests/dir/rewinddir_variation3.phpt b/ext/standard/tests/dir/rewinddir_variation3.phpt index 2bd69e45fc3d..07508eac3f7a 100644 --- a/ext/standard/tests/dir/rewinddir_variation3.phpt +++ b/ext/standard/tests/dir/rewinddir_variation3.phpt @@ -28,9 +28,9 @@ $result2 = fread($fp, 5); echo "\n-- Check if rewinddir() has repositioned the file pointer --\n"; if ($result1 === $result2) { - echo "rewinddir() works on file pointers\n"; + echo "rewinddir() works on file pointers\n"; } else { - echo "rewinddir() does not work on file pointers\n"; + echo "rewinddir() does not work on file pointers\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/dir/scandir_variation7.phpt b/ext/standard/tests/dir/scandir_variation7.phpt index a0fede44ade9..eb4c7e9d214b 100644 --- a/ext/standard/tests/dir/scandir_variation7.phpt +++ b/ext/standard/tests/dir/scandir_variation7.phpt @@ -44,20 +44,20 @@ $permission_values = array( $iterator = 1; foreach ($permission_values as $perm) { - echo "\n-- Iteration $iterator --\n"; + echo "\n-- Iteration $iterator --\n"; - // Remove the directory if already exists - if (is_dir($dir_path)){ - chmod ($dir_path, 0777); // change dir permission to allow all operation - rmdir ($dir_path); - } - mkdir($dir_path); + // Remove the directory if already exists + if (is_dir($dir_path)){ + chmod ($dir_path, 0777); // change dir permission to allow all operation + rmdir ($dir_path); + } + mkdir($dir_path); - // change the dir permission to test dir on it - var_dump( chmod($dir_path, $perm) ); + // change the dir permission to test dir on it + var_dump( chmod($dir_path, $perm) ); - var_dump(scandir($dir_path)); - $iterator++; + var_dump(scandir($dir_path)); + $iterator++; } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/scandir_variation8-win32-mb.phpt b/ext/standard/tests/dir/scandir_variation8-win32-mb.phpt index ffeda65be77a..e353dc372591 100644 --- a/ext/standard/tests/dir/scandir_variation8-win32-mb.phpt +++ b/ext/standard/tests/dir/scandir_variation8-win32-mb.phpt @@ -55,11 +55,11 @@ $inputs = array( $iterator = 1; foreach($inputs as $key => $input) { - echo "\n-- Iteration $iterator --\n"; - $handle = "fp{$iterator}"; - var_dump( $$handle = @fopen($dir_path . "/ç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™$input.tmp", 'w') ); - fclose($$handle); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + $handle = "fp{$iterator}"; + var_dump( $$handle = @fopen($dir_path . "/ç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™$input.tmp", 'w') ); + fclose($$handle); + $iterator++; }; echo "\n-- Call to scandir() --\n"; @@ -67,8 +67,8 @@ var_dump($content = scandir($dir_path)); // remove all files in directory so can remove directory in CLEAN section foreach ($content as $file_name) { - // suppress errors as won't be able to remove "." and ".." entries - @unlink($dir_path . $file_name); + // suppress errors as won't be able to remove "." and ".." entries + @unlink($dir_path . $file_name); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/scandir_variation8.phpt b/ext/standard/tests/dir/scandir_variation8.phpt index 7734c1531f52..1eec187f70e3 100644 --- a/ext/standard/tests/dir/scandir_variation8.phpt +++ b/ext/standard/tests/dir/scandir_variation8.phpt @@ -49,11 +49,11 @@ $inputs = array( $iterator = 1; foreach($inputs as $key => $input) { - echo "\n-- Iteration $iterator --\n"; - $handle = "fp{$iterator}"; - var_dump( $$handle = fopen(@"$dir_path$input.tmp", 'w') ); - fclose($$handle); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + $handle = "fp{$iterator}"; + var_dump( $$handle = fopen(@"$dir_path$input.tmp", 'w') ); + fclose($$handle); + $iterator++; }; echo "\n-- Call to scandir() --\n"; @@ -61,8 +61,8 @@ var_dump($content = scandir($dir_path)); // remove all files in directory so can remove directory in CLEAN section foreach ($content as $file_name) { - // suppress errors as won't be able to remove "." and ".." entries - @unlink($dir_path . $file_name); + // suppress errors as won't be able to remove "." and ".." entries + @unlink($dir_path . $file_name); } ?> --CLEAN-- diff --git a/ext/standard/tests/dir/scandir_variation9-win32-mb.phpt b/ext/standard/tests/dir/scandir_variation9-win32-mb.phpt index 16b26fbb78a5..c609975dda2b 100644 --- a/ext/standard/tests/dir/scandir_variation9-win32-mb.phpt +++ b/ext/standard/tests/dir/scandir_variation9-win32-mb.phpt @@ -32,7 +32,7 @@ mkdir($dir); $ints = array (PHP_INT_MAX, -PHP_INT_MAX, 0); foreach($ints as $sorting_order) { - var_dump( scandir($dir, $sorting_order) ); + var_dump( scandir($dir, $sorting_order) ); } delete_files($dir, 2, "ç§ã¯ã‚¬ãƒ©ã‚¹ã‚’食ã¹ã‚‰ã‚Œã¾ã™file"); diff --git a/ext/standard/tests/dir/scandir_variation9.phpt b/ext/standard/tests/dir/scandir_variation9.phpt index 6bfbe28ea0ac..7e623c0e6f8d 100644 --- a/ext/standard/tests/dir/scandir_variation9.phpt +++ b/ext/standard/tests/dir/scandir_variation9.phpt @@ -26,7 +26,7 @@ mkdir($dir); $ints = array (PHP_INT_MAX, -PHP_INT_MAX, 0); foreach($ints as $sorting_order) { - var_dump( scandir($dir, $sorting_order) ); + var_dump( scandir($dir, $sorting_order) ); } delete_files($dir, 2); diff --git a/ext/standard/tests/directory/bug74589_utf8.phpt b/ext/standard/tests/directory/bug74589_utf8.phpt index 5bf047fbe27d..7a13b57f046e 100644 --- a/ext/standard/tests/directory/bug74589_utf8.phpt +++ b/ext/standard/tests/directory/bug74589_utf8.phpt @@ -23,9 +23,9 @@ mkdir($dir); file_put_contents($test_file, " diff --git a/ext/standard/tests/file/004.phpt b/ext/standard/tests/file/004.phpt index 522b8320e463..742457c7aa22 100644 --- a/ext/standard/tests/file/004.phpt +++ b/ext/standard/tests/file/004.phpt @@ -2,56 +2,56 @@ file_put_contents() test --FILE-- --EXPECT-- String Test: OK diff --git a/ext/standard/tests/file/basename_basic-win32.phpt b/ext/standard/tests/file/basename_basic-win32.phpt index ceccf9eef700..79de350eaeeb 100644 --- a/ext/standard/tests/file/basename_basic-win32.phpt +++ b/ext/standard/tests/file/basename_basic-win32.phpt @@ -60,7 +60,7 @@ $file_paths = array ( ); foreach ($file_paths as $file_path) { - var_dump(basename($file_path)); + var_dump(basename($file_path)); } ?> diff --git a/ext/standard/tests/file/basename_basic.phpt b/ext/standard/tests/file/basename_basic.phpt index 6354b2acd73b..55bd868c55c4 100644 --- a/ext/standard/tests/file/basename_basic.phpt +++ b/ext/standard/tests/file/basename_basic.phpt @@ -60,7 +60,7 @@ $file_paths = array ( ); foreach ($file_paths as $file_path) { - var_dump(basename($file_path)); + var_dump(basename($file_path)); } ?> diff --git a/ext/standard/tests/file/basename_variation1-win32.phpt b/ext/standard/tests/file/basename_variation1-win32.phpt index eb2a4ff497d9..b68765ca6889 100644 --- a/ext/standard/tests/file/basename_variation1-win32.phpt +++ b/ext/standard/tests/file/basename_variation1-win32.phpt @@ -12,25 +12,25 @@ if (substr(PHP_OS, 0, 3) != 'WIN') { $prefixes = array ( // drive letters - "A:/", + "A:/", "Z:/", "A:\\", // other prefixes "http://", "blah://", - "blah:\\", + "blah:\\", "hostname:", - // home directory ~ - "~/", - "~\\", + // home directory ~ + "~/", + "~\\", ); $paths = array ( - "foo", - "foo/", + "foo", + "foo/", "foo\\", "foo.bar", "foo.bar/", @@ -43,11 +43,11 @@ $paths = array ( ); foreach ($prefixes as $prefix) { - foreach ($paths as $path) { - $input = $prefix . $path; - echo "basename for path $input is:\n"; - var_dump(basename($input)); - } + foreach ($paths as $path) { + $input = $prefix . $path; + echo "basename for path $input is:\n"; + var_dump(basename($input)); + } } echo "\ndone\n"; diff --git a/ext/standard/tests/file/basename_variation1.phpt b/ext/standard/tests/file/basename_variation1.phpt index ea7cdfe8b72e..2b2ac3110e81 100644 --- a/ext/standard/tests/file/basename_variation1.phpt +++ b/ext/standard/tests/file/basename_variation1.phpt @@ -12,25 +12,25 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $prefixes = array ( // drive letters - "A:/", + "A:/", "Z:/", "A:\\", // other prefixes "http://", "blah://", - "blah:\\", + "blah:\\", "hostname:", - // home directory ~ - "~/", - "~\\", + // home directory ~ + "~/", + "~\\", ); $paths = array ( - "foo", - "foo/", + "foo", + "foo/", "foo\\", "foo.bar", "foo.bar/", @@ -43,11 +43,11 @@ $paths = array ( ); foreach ($prefixes as $prefix) { - foreach ($paths as $path) { - $input = $prefix . $path; - echo "basename for path $input is:\n"; - var_dump(basename($input)); - } + foreach ($paths as $path) { + $input = $prefix . $path; + echo "basename for path $input is:\n"; + var_dump(basename($input)); + } } echo "\ndone\n"; diff --git a/ext/standard/tests/file/basename_variation2-win32.phpt b/ext/standard/tests/file/basename_variation2-win32.phpt index 43d6de506093..870fc617dd9e 100644 --- a/ext/standard/tests/file/basename_variation2-win32.phpt +++ b/ext/standard/tests/file/basename_variation2-win32.phpt @@ -11,8 +11,8 @@ if (substr(PHP_OS, 0, 3) != 'WIN') { $paths = array ( - "foo", - "foo/", + "foo", + "foo/", "foo\\", "foo.bar", "foo.bar/", @@ -26,8 +26,8 @@ $paths = array ( $suffixes = array ( - ".bar", - ".b", + ".bar", + ".b", ".", " ", "foo", @@ -39,10 +39,10 @@ $suffixes = array ( ); foreach ($paths as $path) { - foreach ($suffixes as $suffix) { - echo "basename for path $path, supplying suffix $suffix is:\n"; - var_dump(basename($path, $suffix)); - } + foreach ($suffixes as $suffix) { + echo "basename for path $path, supplying suffix $suffix is:\n"; + var_dump(basename($path, $suffix)); + } } echo "\ndone\n"; diff --git a/ext/standard/tests/file/basename_variation2.phpt b/ext/standard/tests/file/basename_variation2.phpt index 195b98a6d394..a428d84e06bd 100644 --- a/ext/standard/tests/file/basename_variation2.phpt +++ b/ext/standard/tests/file/basename_variation2.phpt @@ -11,8 +11,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $paths = array ( - "foo", - "foo/", + "foo", + "foo/", "foo\\", "foo.bar", "foo.bar/", @@ -26,8 +26,8 @@ $paths = array ( $suffixes = array ( - ".bar", - ".b", + ".bar", + ".b", ".", " ", "foo", @@ -39,10 +39,10 @@ $suffixes = array ( ); foreach ($paths as $path) { - foreach ($suffixes as $suffix) { - echo "basename for path $path, supplying suffix $suffix is:\n"; - var_dump(basename($path, $suffix)); - } + foreach ($suffixes as $suffix) { + echo "basename for path $path, supplying suffix $suffix is:\n"; + var_dump(basename($path, $suffix)); + } } echo "\ndone\n"; diff --git a/ext/standard/tests/file/bug12556.phpt b/ext/standard/tests/file/bug12556.phpt index 30299899a187..83b39ad7822a 100644 --- a/ext/standard/tests/file/bug12556.phpt +++ b/ext/standard/tests/file/bug12556.phpt @@ -4,8 +4,8 @@ Bug #12556 (fgetcsv() ignores lengths when quotes not closed) diff --git a/ext/standard/tests/file/bug22382.phpt b/ext/standard/tests/file/bug22382.phpt index 7768a13b3ed1..c8dd01efd041 100644 --- a/ext/standard/tests/file/bug22382.phpt +++ b/ext/standard/tests/file/bug22382.phpt @@ -4,7 +4,7 @@ Bug #22382 (fgetcsv() does not handle escaped quotes correctly) diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt index c6e993ac9f98..55078568152c 100644 --- a/ext/standard/tests/file/bug22414.phpt +++ b/ext/standard/tests/file/bug22414.phpt @@ -5,33 +5,33 @@ output_handler= --FILE-- '.$tmpfile ; - } else { - $cmd = $php . $args . ' -r \"readfile(@getenv(\\\\\\"TEST_PHP_EXECUTABLE\\\\\\")); \"'; - $cmd = $php . $args . ' -r " passthru(\''.$cmd.'\');" > '.$tmpfile ; - } - exec($cmd); + if (substr(PHP_OS, 0, 3) != 'WIN') { + $cmd = $php . $args . ' -r \"readfile(@getenv(\'\\\'\'TEST_PHP_EXECUTABLE\'\\\'\')); \"'; + $cmd = $php . $args . ' -r \' passthru("'.$cmd.'"); \' > '.$tmpfile ; + } else { + $cmd = $php . $args . ' -r \"readfile(@getenv(\\\\\\"TEST_PHP_EXECUTABLE\\\\\\")); \"'; + $cmd = $php . $args . ' -r " passthru(\''.$cmd.'\');" > '.$tmpfile ; + } + exec($cmd); - if (md5_file($php) == md5_file($tmpfile)) { - echo "Works\n"; - } else { - echo "Does not work\n"; - } + if (md5_file($php) == md5_file($tmpfile)) { + echo "Works\n"; + } else { + echo "Does not work\n"; + } - @unlink($tmpfile); + @unlink($tmpfile); ?> --EXPECT-- HELLO diff --git a/ext/standard/tests/file/bug24313.phpt b/ext/standard/tests/file/bug24313.phpt index e5bceee856f7..0893889a020f 100644 --- a/ext/standard/tests/file/bug24313.phpt +++ b/ext/standard/tests/file/bug24313.phpt @@ -10,7 +10,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { open_basedir=/dev --FILE-- --EXPECT-- bool(false) diff --git a/ext/standard/tests/file/bug24482.phpt b/ext/standard/tests/file/bug24482.phpt index 9fe4d2d9ee56..ba3dd73318d3 100644 --- a/ext/standard/tests/file/bug24482.phpt +++ b/ext/standard/tests/file/bug24482.phpt @@ -18,24 +18,24 @@ $globdirs = glob("*", GLOB_ONLYDIR); $dirs = array(); $dh = opendir("."); while (is_string($file = readdir($dh))) { - if ($file[0] === ".") continue; - if (!is_dir($file)) continue; - $dirs[] = $file; + if ($file[0] === ".") continue; + if (!is_dir($file)) continue; + $dirs[] = $file; } closedir($dh); if (count($dirs) != count($globdirs)) { - echo "Directory count mismatch\n"; + echo "Directory count mismatch\n"; - echo "glob found:\n"; - sort($globdirs); - var_dump($globdirs); + echo "glob found:\n"; + sort($globdirs); + var_dump($globdirs); - echo "opendir/readdir/isdir found:\n"; - sort($dirs); - var_dump($dirs); + echo "opendir/readdir/isdir found:\n"; + sort($dirs); + var_dump($dirs); } else { - echo "OK\n"; + echo "OK\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/file/bug26615.phpt b/ext/standard/tests/file/bug26615.phpt index 3689fdfe161c..8a5df91ec183 100644 --- a/ext/standard/tests/file/bug26615.phpt +++ b/ext/standard/tests/file/bug26615.phpt @@ -7,9 +7,9 @@ variables_order=E $out = array(); $status = -1; if (substr(PHP_OS, 0, 3) != 'WIN') { - exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status); + exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status); } else { - exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r "for($i=1;$i<=5000;$i++) echo $i,\' \';"', $out, $status); + exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r "for($i=1;$i<=5000;$i++) echo $i,\' \';"', $out, $status); } print_r($out); ?> diff --git a/ext/standard/tests/file/bug26938.phpt b/ext/standard/tests/file/bug26938.phpt index d1ad6b652647..13732c03f630 100644 --- a/ext/standard/tests/file/bug26938.phpt +++ b/ext/standard/tests/file/bug26938.phpt @@ -6,19 +6,19 @@ $out = array(); $status = -1; $php = getenv('TEST_PHP_EXECUTABLE'); if (substr(PHP_OS, 0, 3) != 'WIN') { - exec($php . ' -n -r \'' - . '$lengths = array(10,20000,10000,5,10000,3);' - . 'foreach($lengths as $length) {' - . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' - . ' print "\n";' - . '}\'', $out, $status); + exec($php . ' -n -r \'' + . '$lengths = array(10,20000,10000,5,10000,3);' + . 'foreach($lengths as $length) {' + . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' + . ' print "\n";' + . '}\'', $out, $status); } else { - exec($php . ' -n -r "' - . '$lengths = array(10,20000,10000,5,10000,3);' - . 'foreach($lengths as $length) {' - . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' - . ' print \\"\\n\\";' - . '}"', $out, $status); + exec($php . ' -n -r "' + . '$lengths = array(10,20000,10000,5,10000,3);' + . 'foreach($lengths as $length) {' + . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);' + . ' print \\"\\n\\";' + . '}"', $out, $status); } for ($i=0;$i<6;$i++) print "md5(line $i)= " . md5($out[$i]) . " (length " . diff --git a/ext/standard/tests/file/bug27619.phpt b/ext/standard/tests/file/bug27619.phpt index 095a18c199ff..6f377b52a9c8 100644 --- a/ext/standard/tests/file/bug27619.phpt +++ b/ext/standard/tests/file/bug27619.phpt @@ -2,17 +2,17 @@ Bug #27619 (filters not applied to pre-buffered data) --FILE-- --EXPECT-- this IS A LOWERCASE STRING. diff --git a/ext/standard/tests/file/bug37158.phpt b/ext/standard/tests/file/bug37158.phpt index 3200a62cf928..9afeaeeb8c49 100644 --- a/ext/standard/tests/file/bug37158.phpt +++ b/ext/standard/tests/file/bug37158.phpt @@ -17,7 +17,7 @@ $file = __DIR__ . '/footest.txt'; $x = str_repeat(1, 8192); $fp = fopen($file, 'w'); for ($i = 0; $i < 5; $i++) { - fwrite($fp, $x); + fwrite($fp, $x); } fclose($fp); diff --git a/ext/standard/tests/file/bug37864.phpt b/ext/standard/tests/file/bug37864.phpt index f8743bd5ec09..1da8f161836c 100644 --- a/ext/standard/tests/file/bug37864.phpt +++ b/ext/standard/tests/file/bug37864.phpt @@ -2,10 +2,10 @@ Bug #37864 (file_get_contents() leaks on empty file) --FILE-- --EXPECT-- string(0) "" diff --git a/ext/standard/tests/file/bug38450.phpt b/ext/standard/tests/file/bug38450.phpt index eae86cf9a015..a82be7848a7b 100644 --- a/ext/standard/tests/file/bug38450.phpt +++ b/ext/standard/tests/file/bug38450.phpt @@ -4,85 +4,85 @@ Bug #38450 (constructor is not called for classes used in userspace stream wrapp varname = $url["host"]; - $this->position = 0; - - return true; - } - - function stream_read($count) - { - $ret = substr($GLOBALS[$this->varname], $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - function stream_write($data) - { - $left = substr($GLOBALS[$this->varname], 0, $this->position); - $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); - $GLOBALS[$this->varname] = $left . $data . $right; - $this->position += strlen($data); - return strlen($data); - } - - function stream_tell() - { - return $this->position; - } - - function stream_eof() - { - return $this->position >= strlen($GLOBALS[$this->varname]); - } - function stream_seek($offset, $whence) - { - switch ($whence) { - case SEEK_SET: - if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - - case SEEK_END: - if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; - } else { - return false; - } - break; - - default: - return false; - } - } + var $position; + var $varname; + + function __construct($var=null) { + var_dump("constructor!"); + } + + function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + function stream_read($count) + { + $ret = substr($GLOBALS[$this->varname], $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + function stream_write($data) + { + $left = substr($GLOBALS[$this->varname], 0, $this->position); + $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); + $GLOBALS[$this->varname] = $left . $data . $right; + $this->position += strlen($data); + return strlen($data); + } + + function stream_tell() + { + return $this->position; + } + + function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + function stream_seek($offset, $whence) + { + switch ($whence) { + case SEEK_SET: + if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + + case SEEK_END: + if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; + } else { + return false; + } + break; + + default: + return false; + } + } } stream_wrapper_register("var", "VariableStream") - or die("Failed to register protocol"); + or die("Failed to register protocol"); $myvar = ""; @@ -94,7 +94,7 @@ fwrite($fp, "line3\n"); rewind($fp); while (!feof($fp)) { - echo fgets($fp); + echo fgets($fp); } fclose($fp); var_dump($myvar); diff --git a/ext/standard/tests/file/bug38450_1.phpt b/ext/standard/tests/file/bug38450_1.phpt index 9cc383171b63..6eea9e200032 100644 --- a/ext/standard/tests/file/bug38450_1.phpt +++ b/ext/standard/tests/file/bug38450_1.phpt @@ -4,85 +4,85 @@ Bug #38450 (constructor is not called for classes used in userspace stream wrapp varname = $url["host"]; - $this->position = 0; - - return true; - } - - function stream_read($count) - { - $ret = substr($GLOBALS[$this->varname], $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - function stream_write($data) - { - $left = substr($GLOBALS[$this->varname], 0, $this->position); - $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); - $GLOBALS[$this->varname] = $left . $data . $right; - $this->position += strlen($data); - return strlen($data); - } - - function stream_tell() - { - return $this->position; - } - - function stream_eof() - { - return $this->position >= strlen($GLOBALS[$this->varname]); - } - function stream_seek($offset, $whence) - { - switch ($whence) { - case SEEK_SET: - if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - - case SEEK_END: - if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; - } else { - return false; - } - break; - - default: - return false; - } - } + var $position; + var $varname; + + function __construct($var = null) { + var_dump("constructor!"); + } + + function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + function stream_read($count) + { + $ret = substr($GLOBALS[$this->varname], $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + function stream_write($data) + { + $left = substr($GLOBALS[$this->varname], 0, $this->position); + $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); + $GLOBALS[$this->varname] = $left . $data . $right; + $this->position += strlen($data); + return strlen($data); + } + + function stream_tell() + { + return $this->position; + } + + function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + function stream_seek($offset, $whence) + { + switch ($whence) { + case SEEK_SET: + if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + + case SEEK_END: + if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; + } else { + return false; + } + break; + + default: + return false; + } + } } stream_wrapper_register("var", "VariableStream") - or die("Failed to register protocol"); + or die("Failed to register protocol"); $myvar = ""; @@ -94,7 +94,7 @@ fwrite($fp, "line3\n"); rewind($fp); while (!feof($fp)) { - echo fgets($fp); + echo fgets($fp); } fclose($fp); var_dump($myvar); diff --git a/ext/standard/tests/file/bug38450_2.phpt b/ext/standard/tests/file/bug38450_2.phpt index 33a13da0dbb5..cf4cb9192807 100644 --- a/ext/standard/tests/file/bug38450_2.phpt +++ b/ext/standard/tests/file/bug38450_2.phpt @@ -4,85 +4,85 @@ Bug #38450 (constructor is not called for classes used in userspace stream wrapp varname = $url["host"]; - $this->position = 0; - - return true; - } - - function stream_read($count) - { - $ret = substr($GLOBALS[$this->varname], $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - function stream_write($data) - { - $left = substr($GLOBALS[$this->varname], 0, $this->position); - $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); - $GLOBALS[$this->varname] = $left . $data . $right; - $this->position += strlen($data); - return strlen($data); - } - - function stream_tell() - { - return $this->position; - } - - function stream_eof() - { - return $this->position >= strlen($GLOBALS[$this->varname]); - } - function stream_seek($offset, $whence) - { - switch ($whence) { - case SEEK_SET: - if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - - case SEEK_END: - if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; - } else { - return false; - } - break; - - default: - return false; - } - } + var $position; + var $varname; + + function __construct($var = null) { + throw new Exception("constructor"); + } + + function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + function stream_read($count) + { + $ret = substr($GLOBALS[$this->varname], $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + function stream_write($data) + { + $left = substr($GLOBALS[$this->varname], 0, $this->position); + $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); + $GLOBALS[$this->varname] = $left . $data . $right; + $this->position += strlen($data); + return strlen($data); + } + + function stream_tell() + { + return $this->position; + } + + function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + function stream_seek($offset, $whence) + { + switch ($whence) { + case SEEK_SET: + if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + + case SEEK_END: + if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; + } else { + return false; + } + break; + + default: + return false; + } + } } stream_wrapper_register("var", "VariableStream") - or die("Failed to register protocol"); + or die("Failed to register protocol"); $myvar = ""; @@ -94,7 +94,7 @@ fwrite($fp, "line3\n"); rewind($fp); while (!feof($fp)) { - echo fgets($fp); + echo fgets($fp); } fclose($fp); var_dump($myvar); diff --git a/ext/standard/tests/file/bug38450_3.phpt b/ext/standard/tests/file/bug38450_3.phpt index 8a5c6965873a..cbd03e908e4a 100644 --- a/ext/standard/tests/file/bug38450_3.phpt +++ b/ext/standard/tests/file/bug38450_3.phpt @@ -4,85 +4,85 @@ Bug #38450 (constructor is not called for classes used in userspace stream wrapp varname = $url["host"]; - $this->position = 0; - - return true; - } - - function stream_read($count) - { - $ret = substr($GLOBALS[$this->varname], $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - function stream_write($data) - { - $left = substr($GLOBALS[$this->varname], 0, $this->position); - $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); - $GLOBALS[$this->varname] = $left . $data . $right; - $this->position += strlen($data); - return strlen($data); - } - - function stream_tell() - { - return $this->position; - } - - function stream_eof() - { - return $this->position >= strlen($GLOBALS[$this->varname]); - } - function stream_seek($offset, $whence) - { - switch ($whence) { - case SEEK_SET: - if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - - case SEEK_END: - if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; - } else { - return false; - } - break; - - default: - return false; - } - } + var $position; + var $varname; + + function __construct(array $var) { + var_dump("constructor!"); + } + + function stream_open($path, $mode, $options, &$opened_path) + { + $url = parse_url($path); + $this->varname = $url["host"]; + $this->position = 0; + + return true; + } + + function stream_read($count) + { + $ret = substr($GLOBALS[$this->varname], $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + function stream_write($data) + { + $left = substr($GLOBALS[$this->varname], 0, $this->position); + $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); + $GLOBALS[$this->varname] = $left . $data . $right; + $this->position += strlen($data); + return strlen($data); + } + + function stream_tell() + { + return $this->position; + } + + function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + function stream_seek($offset, $whence) + { + switch ($whence) { + case SEEK_SET: + if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + + case SEEK_END: + if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; + } else { + return false; + } + break; + + default: + return false; + } + } } stream_wrapper_register("var", "VariableStream") - or die("Failed to register protocol"); + or die("Failed to register protocol"); $myvar = ""; @@ -94,7 +94,7 @@ fwrite($fp, "line3\n"); rewind($fp); while (!feof($fp)) { - echo fgets($fp); + echo fgets($fp); } fclose($fp); var_dump($myvar); diff --git a/ext/standard/tests/file/bug39538.phpt b/ext/standard/tests/file/bug39538.phpt index cdff507b48ba..5f40192ec90d 100644 --- a/ext/standard/tests/file/bug39538.phpt +++ b/ext/standard/tests/file/bug39538.phpt @@ -7,8 +7,8 @@ $content = array("\"\nthis is an test\", \"next data\", \"p\narsed\"","\"\r\nthi $file = __DIR__ . "/bug39538.csv"; @unlink($file); foreach ($content as $v) { - file_put_contents($file, $v); - print_r (fgetcsv(fopen($file, "r"), filesize($file))); + file_put_contents($file, $v); + print_r (fgetcsv(fopen($file, "r"), filesize($file))); } @unlink($file); ?> diff --git a/ext/standard/tests/file/bug39551.phpt b/ext/standard/tests/file/bug39551.phpt index 2877c4951f35..c3d011351e28 100644 --- a/ext/standard/tests/file/bug39551.phpt +++ b/ext/standard/tests/file/bug39551.phpt @@ -6,12 +6,12 @@ Bug #39551 (Segfault with stream_bucket_new in user filter) $bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); class bucketFilter { - public function filter($in, $out, &$consumed, $closing ){ + public function filter($in, $out, &$consumed, $closing ){ - $bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); - stream_bucket_append($out, $bucket); - return PSFS_PASS_ON; - } + $bucket = stream_bucket_new(fopen('php://temp', 'w+'), ''); + stream_bucket_append($out, $bucket); + return PSFS_PASS_ON; + } } stream_filter_register('bucketfault', 'bucketFilter'); diff --git a/ext/standard/tests/file/bug39673.phpt b/ext/standard/tests/file/bug39673.phpt index 70a47e3fc115..64c66cc1414f 100644 --- a/ext/standard/tests/file/bug39673.phpt +++ b/ext/standard/tests/file/bug39673.phpt @@ -9,20 +9,20 @@ $filename = __DIR__.'/bug39673.txt'; file_put_contents($filename, $str); $offsets = array( - -1, - 0, - 3456*4, - 3456*4 - 1, - 3456*4 + 1, - 2000, - 5000, - 100000, + -1, + 0, + 3456*4, + 3456*4 - 1, + 3456*4 + 1, + 2000, + 5000, + 100000, ); foreach ($offsets as $offset) { - $r = file_get_contents($filename, false, null, $offset); - if ($r !== false) var_dump(strlen($r)); + $r = file_get_contents($filename, false, null, $offset); + if ($r !== false) var_dump(strlen($r)); } @unlink($filename); diff --git a/ext/standard/tests/file/bug41655_2.phpt b/ext/standard/tests/file/bug41655_2.phpt index 20c29844c1d7..61fdec10542e 100644 --- a/ext/standard/tests/file/bug41655_2.phpt +++ b/ext/standard/tests/file/bug41655_2.phpt @@ -4,9 +4,9 @@ Bug #41655 (open_basedir bypass via glob()) 2/2 open_basedir=/ --FILE-- --EXPECTF-- Array diff --git a/ext/standard/tests/file/bug41815.phpt b/ext/standard/tests/file/bug41815.phpt index 58f287cedff5..d77d73055bcb 100644 --- a/ext/standard/tests/file/bug41815.phpt +++ b/ext/standard/tests/file/bug41815.phpt @@ -12,7 +12,7 @@ fread($reader, 1); fwrite($writer, "foo"); if (strlen(fread($reader, 10)) > 0) { - echo "OK\n"; + echo "OK\n"; } fclose($writer); diff --git a/ext/standard/tests/file/bug43008.phpt b/ext/standard/tests/file/bug43008.phpt index 0d9d6ed98685..60bea3542901 100644 --- a/ext/standard/tests/file/bug43008.phpt +++ b/ext/standard/tests/file/bug43008.phpt @@ -9,12 +9,12 @@ allow_url_fopen=1 --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/file/bug43137.phpt b/ext/standard/tests/file/bug43137.phpt index 8125445bb00a..f0f17895b730 100644 --- a/ext/standard/tests/file/bug43137.phpt +++ b/ext/standard/tests/file/bug43137.phpt @@ -2,16 +2,16 @@ Bug #43137 (rmdir() and rename() do not clear statcache) --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/file/bug43522.phpt b/ext/standard/tests/file/bug43522.phpt index 10e44fc3527b..185f2c369714 100644 --- a/ext/standard/tests/file/bug43522.phpt +++ b/ext/standard/tests/file/bug43522.phpt @@ -9,10 +9,10 @@ DoTest($fp, 'ZZZ'); // test multi-char delimiter DoTest($fp, "Z"); // test single-char delimiter function DoTest($fp, $delim) { - echo "Delimiter: " . $delim . "\n"; - rewind($fp); - echo "\t" . stream_get_line($fp, 10, $delim) . "\n"; - echo "\t" . stream_get_line($fp, 10, $delim) . "\n"; + echo "Delimiter: " . $delim . "\n"; + rewind($fp); + echo "\t" . stream_get_line($fp, 10, $delim) . "\n"; + echo "\t" . stream_get_line($fp, 10, $delim) . "\n"; } ?> diff --git a/ext/standard/tests/file/bug44034.phpt b/ext/standard/tests/file/bug44034.phpt index 887b9eb08e5b..2b7e1168c8b9 100644 --- a/ext/standard/tests/file/bug44034.phpt +++ b/ext/standard/tests/file/bug44034.phpt @@ -11,8 +11,8 @@ $urls[] = "data://text/plain,\r\nfoo\r\nbar\r\n"; $urls[] = "data://text/plain,foo\r\nbar"; foreach($urls as $url) { - echo strtr($url, array("\r" => "\\r", "\n" => "\\n")) . "\n"; - var_dump(file($url, FILE_IGNORE_NEW_LINES)); + echo strtr($url, array("\r" => "\\r", "\n" => "\\n")) . "\n"; + var_dump(file($url, FILE_IGNORE_NEW_LINES)); } ?> --EXPECT-- diff --git a/ext/standard/tests/file/bug44805.phpt b/ext/standard/tests/file/bug44805.phpt index ac4e334f5301..0b81be6a0659 100644 --- a/ext/standard/tests/file/bug44805.phpt +++ b/ext/standard/tests/file/bug44805.phpt @@ -14,10 +14,10 @@ rename($file1, $file2); echo "reading file 2: "; readfile($file2); if (file_exists($file1)) { - unlink($file1); + unlink($file1); } if (file_exists($file2)) { - unlink($file2); + unlink($file2); } ?> --EXPECT-- diff --git a/ext/standard/tests/file/bug55124.phpt b/ext/standard/tests/file/bug55124.phpt index 7938196dbcd0..a894ff32e0af 100644 --- a/ext/standard/tests/file/bug55124.phpt +++ b/ext/standard/tests/file/bug55124.phpt @@ -6,10 +6,10 @@ $old_dir_path = getcwd(); chdir(__DIR__); mkdir('a/./b', 0755, true); if (is_dir('a/b')) { - rmdir('a/b'); + rmdir('a/b'); } if (is_dir('./a')) { - rmdir('a'); + rmdir('a'); } chdir($old_dir_path); echo "OK"; diff --git a/ext/standard/tests/file/bug60120.phpt b/ext/standard/tests/file/bug60120.phpt index 77ebf086bd30..9d964e34cb79 100644 --- a/ext/standard/tests/file/bug60120.phpt +++ b/ext/standard/tests/file/bug60120.phpt @@ -14,7 +14,7 @@ error_reporting(E_ALL); $php = getenv('TEST_PHP_EXECUTABLE'); if (!$php) { - die("No php executable defined\n"); + die("No php executable defined\n"); } $cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"'; $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')); diff --git a/ext/standard/tests/file/bug63512.phpt b/ext/standard/tests/file/bug63512.phpt index 927735925604..a22ba9f0cf2a 100644 --- a/ext/standard/tests/file/bug63512.phpt +++ b/ext/standard/tests/file/bug63512.phpt @@ -4,13 +4,13 @@ Fixed bug #63512 (parse_ini_file() with INI_SCANNER_RAW removes quotes from valu $file_path = __DIR__ . "/bug65701/"; if (!is_dir($file_path)) { - mkdir($file_path); + mkdir($file_path); } $src = $file_path . '/srcbug65701_file.txt'; diff --git a/ext/standard/tests/file/bug71287.phpt b/ext/standard/tests/file/bug71287.phpt index b7987829b05f..f88414f2c288 100644 --- a/ext/standard/tests/file/bug71287.phpt +++ b/ext/standard/tests/file/bug71287.phpt @@ -3,13 +3,13 @@ Bug #71287 (Error message contains hexadecimal instead of decimal number) --FILE-- array("pipe", "r")); $proc = proc_open($cmd, $desc, $pipes, getcwd(), array()); if (is_resource($proc)) { - echo stream_get_contents($pipes[0]); + echo stream_get_contents($pipes[0]); - proc_close($proc); + proc_close($proc); } unlink($fl); diff --git a/ext/standard/tests/file/chmod_basic-win32-mb.phpt b/ext/standard/tests/file/chmod_basic-win32-mb.phpt index 3970504ddb22..a3c0b62410af 100644 --- a/ext/standard/tests/file/chmod_basic-win32-mb.phpt +++ b/ext/standard/tests/file/chmod_basic-win32-mb.phpt @@ -17,10 +17,10 @@ $fd = fopen($filename, "w+"); fclose($fd); for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) { - chmod($filename, $perms_to_set); - $set_perms = (fileperms($filename) & PERMISSIONS_MASK); - clearstatcache(); - printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms); + chmod($filename, $perms_to_set); + $set_perms = (fileperms($filename) & PERMISSIONS_MASK); + clearstatcache(); + printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms); } var_dump(chmod($filename, 0777)); diff --git a/ext/standard/tests/file/chmod_basic-win32.phpt b/ext/standard/tests/file/chmod_basic-win32.phpt index 31d44c80aae3..072f98d644b1 100644 --- a/ext/standard/tests/file/chmod_basic-win32.phpt +++ b/ext/standard/tests/file/chmod_basic-win32.phpt @@ -17,10 +17,10 @@ $fd = fopen($filename, "w+"); fclose($fd); for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) { - chmod($filename, $perms_to_set); - $set_perms = (fileperms($filename) & PERMISSIONS_MASK); - clearstatcache(); - printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms); + chmod($filename, $perms_to_set); + $set_perms = (fileperms($filename) & PERMISSIONS_MASK); + clearstatcache(); + printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms); } var_dump(chmod($filename, 0777)); diff --git a/ext/standard/tests/file/chmod_basic.phpt b/ext/standard/tests/file/chmod_basic.phpt index fc983074fdc4..635ea8de7981 100644 --- a/ext/standard/tests/file/chmod_basic.phpt +++ b/ext/standard/tests/file/chmod_basic.phpt @@ -17,12 +17,12 @@ $fd = fopen($filename, "w+"); fclose($fd); for ($perms_to_set = 07777; $perms_to_set >= 0; $perms_to_set--) { - chmod($filename, $perms_to_set); - $set_perms = (fileperms($filename) & MODE_MASK); - clearstatcache(); - if ($set_perms != $perms_to_set) { - printf("Error: %o does not match %o\n", $set_perms, $perms_to_set); - } + chmod($filename, $perms_to_set); + $set_perms = (fileperms($filename) & MODE_MASK); + clearstatcache(); + if ($set_perms != $perms_to_set) { + printf("Error: %o does not match %o\n", $set_perms, $perms_to_set); + } } var_dump(chmod($filename, 0777)); diff --git a/ext/standard/tests/file/chmod_variation1.phpt b/ext/standard/tests/file/chmod_variation1.phpt index 935d30ce5585..f89c70fa5dd2 100644 --- a/ext/standard/tests/file/chmod_variation1.phpt +++ b/ext/standard/tests/file/chmod_variation1.phpt @@ -15,12 +15,12 @@ $dirname = __DIR__ . "/" . basename(__FILE__, ".php") . "testdir"; mkdir($dirname); for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) { - chmod($dirname, $perms_to_set); - $set_perms = (fileperms($dirname) & PERMISSIONS_MASK); - clearstatcache(); - if ($set_perms != $perms_to_set) { - printf("Error: %o does not match %o\n", $set_perms, $perms_to_set); - } + chmod($dirname, $perms_to_set); + $set_perms = (fileperms($dirname) & PERMISSIONS_MASK); + clearstatcache(); + if ($set_perms != $perms_to_set) { + printf("Error: %o does not match %o\n", $set_perms, $perms_to_set); + } } var_dump(chmod($dirname, 0777)); diff --git a/ext/standard/tests/file/dirname_basic-win32.phpt b/ext/standard/tests/file/dirname_basic-win32.phpt index f596f9a359e2..1ae436d1e163 100644 --- a/ext/standard/tests/file/dirname_basic-win32.phpt +++ b/ext/standard/tests/file/dirname_basic-win32.phpt @@ -20,40 +20,40 @@ echo "*** Testing dirname() : basic functionality ***\n"; // Initialise all required variables $paths = array( - '', - ' ', - 'c:', - 'c:\\', - 'c:/', - 'afile', - 'c:\test\afile', - 'c:\\test\\afile', - 'c://test//afile', - 'c:\test\afile\\', - '/usr/lib/locale/en_US', - '//usr/lib//locale/en_US', - '\\', - '\\\\', - '/', - '//', - '///', - '/usr/lib/locale/en_US/', - 'c:\windows/system32\drivers/etc\hosts', - '/usr\lib/locale\en_US', - ' c:\test\adir\afile.txt', - 'c:\test\adir\afile.txt ', - ' c:\test\adir\afile.txt ', - ' /usr/lib/locale/en_US', - '/usr/lib/locale/en_US ', - ' /usr/lib/locale/en_US ', - ' c:', - ' c:\test\adir\afile.txt', - '/usr', - '/usr/', - ); + '', + ' ', + 'c:', + 'c:\\', + 'c:/', + 'afile', + 'c:\test\afile', + 'c:\\test\\afile', + 'c://test//afile', + 'c:\test\afile\\', + '/usr/lib/locale/en_US', + '//usr/lib//locale/en_US', + '\\', + '\\\\', + '/', + '//', + '///', + '/usr/lib/locale/en_US/', + 'c:\windows/system32\drivers/etc\hosts', + '/usr\lib/locale\en_US', + ' c:\test\adir\afile.txt', + 'c:\test\adir\afile.txt ', + ' c:\test\adir\afile.txt ', + ' /usr/lib/locale/en_US', + '/usr/lib/locale/en_US ', + ' /usr/lib/locale/en_US ', + ' c:', + ' c:\test\adir\afile.txt', + '/usr', + '/usr/', + ); foreach ($paths as $path) { - var_dump( dirname($path) ); + var_dump( dirname($path) ); } ?> diff --git a/ext/standard/tests/file/dirname_basic.phpt b/ext/standard/tests/file/dirname_basic.phpt index 774192830a80..75355a7135e6 100644 --- a/ext/standard/tests/file/dirname_basic.phpt +++ b/ext/standard/tests/file/dirname_basic.phpt @@ -20,40 +20,40 @@ echo "*** Testing dirname() : basic functionality ***\n"; // Initialise all required variables $paths = array( - '', - ' ', - 'c:', - 'c:\\', - 'c:/', - 'afile', - 'c:\test\afile', - 'c:\\test\\afile', - 'c://test//afile', - 'c:\test\afile\\', - '/usr/lib/locale/en_US', - '//usr/lib//locale/en_US', - '\\', - '\\\\', - '/', - '//', - '///', - '/usr/lib/locale/en_US/', - 'c:\windows/system32\drivers/etc\hosts', - '/usr\lib/locale\en_US', - ' c:\test\adir\afile.txt', - 'c:\test\adir\afile.txt ', - ' c:\test\adir\afile.txt ', - ' /usr/lib/locale/en_US', - '/usr/lib/locale/en_US ', - ' /usr/lib/locale/en_US ', - ' c:', - ' c:\test\adir\afile.txt', - '/usr', - '/usr/' - ); + '', + ' ', + 'c:', + 'c:\\', + 'c:/', + 'afile', + 'c:\test\afile', + 'c:\\test\\afile', + 'c://test//afile', + 'c:\test\afile\\', + '/usr/lib/locale/en_US', + '//usr/lib//locale/en_US', + '\\', + '\\\\', + '/', + '//', + '///', + '/usr/lib/locale/en_US/', + 'c:\windows/system32\drivers/etc\hosts', + '/usr\lib/locale\en_US', + ' c:\test\adir\afile.txt', + 'c:\test\adir\afile.txt ', + ' c:\test\adir\afile.txt ', + ' /usr/lib/locale/en_US', + '/usr/lib/locale/en_US ', + ' /usr/lib/locale/en_US ', + ' c:', + ' c:\test\adir\afile.txt', + '/usr', + '/usr/' + ); foreach ($paths as $path) { - var_dump( dirname($path) ); + var_dump( dirname($path) ); } ?> diff --git a/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt b/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt index 6098ca2694ac..cde1e92e2493 100644 --- a/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt +++ b/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt @@ -10,15 +10,15 @@ if(substr(PHP_OS, 0, 3) != "WIN") $s = '/php_sanity/sanity.php?'; while (dirname($s) == "/php_sanity" && strlen($s) < 10000) { - $s .= str_repeat('X', 250); + $s .= str_repeat('X', 250); } if (strlen($s) >= 10000) { - echo "OK\n"; + echo "OK\n"; } else { - print "ERROR: " . PHP_EOL; - var_dump(dirname($s)); - var_dump(strlen($s)); + print "ERROR: " . PHP_EOL; + var_dump(dirname($s)); + var_dump(strlen($s)); } ?> --EXPECT-- diff --git a/ext/standard/tests/file/fflush_basic.phpt b/ext/standard/tests/file/fflush_basic.phpt index 2c9314394bf7..854a23db45d4 100644 --- a/ext/standard/tests/file/fflush_basic.phpt +++ b/ext/standard/tests/file/fflush_basic.phpt @@ -22,7 +22,7 @@ if($file_handle == false) exit("Error:failed to open file $filename"); if(substr(PHP_OS, 0, 3) == "WIN") { - $data = str_replace("\r",'', $data); + $data = str_replace("\r",'', $data); } // writing data to the file diff --git a/ext/standard/tests/file/fgetcsv.phpt b/ext/standard/tests/file/fgetcsv.phpt index 7a6d7d59dbb3..17ac19ca60c8 100644 --- a/ext/standard/tests/file/fgetcsv.phpt +++ b/ext/standard/tests/file/fgetcsv.phpt @@ -2,39 +2,39 @@ various fgetcsv() functionality tests --FILE-- --EXPECT-- array(2) { diff --git a/ext/standard/tests/file/fgets_socket_variation1.phpt b/ext/standard/tests/file/fgets_socket_variation1.phpt index 429ad67d6967..ac1086ef569e 100644 --- a/ext/standard/tests/file/fgets_socket_variation1.phpt +++ b/ext/standard/tests/file/fgets_socket_variation1.phpt @@ -18,7 +18,7 @@ for ($i=0; $i<100; $i++) { $client = fsockopen("tcp://127.0.0.1:$port"); if (!$client) { - die("Unable to create socket"); + die("Unable to create socket"); } /* Accept that connection */ @@ -38,7 +38,7 @@ echo "\n\nClose the server side socket and read the remaining data from the clie fclose($socket); fclose($server); while(!feof($client)) { - fread($client, 1); + fread($client, 1); } echo "done\n"; diff --git a/ext/standard/tests/file/fgets_socket_variation2.phpt b/ext/standard/tests/file/fgets_socket_variation2.phpt index da1f0b47ad4d..88fbbd45b989 100644 --- a/ext/standard/tests/file/fgets_socket_variation2.phpt +++ b/ext/standard/tests/file/fgets_socket_variation2.phpt @@ -12,7 +12,7 @@ $fd = fopen($filename, "w+"); // populate the file with lines of data define("LINE_OF_DATA", "12345678\n"); for ($i = 0; $i < 1000; $i++) { - fwrite($fd, LINE_OF_DATA); + fwrite($fd, LINE_OF_DATA); } fclose($fd); @@ -29,7 +29,7 @@ for ($i=0; $i<100; $i++) { $client = fsockopen("tcp://127.0.0.1:$port"); if (!$client) { - die("Unable to create socket"); + die("Unable to create socket"); } /* Accept that connection */ @@ -44,16 +44,16 @@ fclose($socket); echo "\nRead lines from the client\n"; while ($line = fgets($client,256)) { - if (strcmp($line, LINE_OF_DATA) != 0) { - echo "Error - $line does not match " . LINE_OF_DATA; - break; - } + if (strcmp($line, LINE_OF_DATA) != 0) { + echo "Error - $line does not match " . LINE_OF_DATA; + break; + } } echo "\nClose the server side socket and read the remaining data from the client\n"; fclose($server); while(!feof($client)) { - fread($client, 1); + fread($client, 1); } echo "done\n"; diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc index aaa151ac0dfb..08825f450268 100644 --- a/ext/standard/tests/file/file.inc +++ b/ext/standard/tests/file/file.inc @@ -309,7 +309,7 @@ function create_files( $file_path, /* Function: function create_links( $file_path, - $filename, + $filename, $link_count = 1, $link_type = "soft", $link_size = 1024, diff --git a/ext/standard/tests/file/file_get_contents_basic001.phpt b/ext/standard/tests/file/file_get_contents_basic001.phpt index 86569d7917b4..d54bf2bcb47f 100644 --- a/ext/standard/tests/file/file_get_contents_basic001.phpt +++ b/ext/standard/tests/file/file_get_contents_basic001.phpt @@ -4,13 +4,13 @@ file_get_contents() test using basic syntax "Blanche V.N." --FILE-- --CLEAN-- --FILE-- --EXPECT-- bool(false) diff --git a/ext/standard/tests/file/file_put_contents_variation2.phpt b/ext/standard/tests/file/file_put_contents_variation2.phpt index 279291f2cfeb..098ed375894b 100644 --- a/ext/standard/tests/file/file_put_contents_variation2.phpt +++ b/ext/standard/tests/file/file_put_contents_variation2.phpt @@ -14,10 +14,10 @@ echo "*** Testing file_put_contents() : usage variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg\n"; + } } set_error_handler('test_error_handler'); @@ -34,9 +34,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/file/file_variation6.phpt b/ext/standard/tests/file/file_variation6.phpt index b8078d2bd17b..e5d8b6d51a0d 100644 --- a/ext/standard/tests/file/file_variation6.phpt +++ b/ext/standard/tests/file/file_variation6.phpt @@ -10,7 +10,7 @@ fclose($fd); for ($flags = 0; $flags <= 32; $flags++) { try { - var_dump(file($filepath, $flags)); + var_dump(file($filepath, $flags)); } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } diff --git a/ext/standard/tests/file/file_variation9.phpt b/ext/standard/tests/file/file_variation9.phpt index 13860878d94d..39f58aa7888c 100644 --- a/ext/standard/tests/file/file_variation9.phpt +++ b/ext/standard/tests/file/file_variation9.phpt @@ -27,7 +27,7 @@ foreach ($contents as $content) { fwrite($h, $content); fclose($h); var_dump(file($testfile)); - unlink($testfile); + unlink($testfile); } echo "\n*** Done ***\n"; diff --git a/ext/standard/tests/file/fopen_include_path.inc b/ext/standard/tests/file/fopen_include_path.inc index e33dae491566..160f9aee5f53 100644 --- a/ext/standard/tests/file/fopen_include_path.inc +++ b/ext/standard/tests/file/fopen_include_path.inc @@ -11,82 +11,82 @@ $newdirs = array($dir1, $dir2, $dir3); $reldirs = array("dir1", "dir2", "dir3"); function generate_next_rel_path() { - global $reldirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($reldirs as $newdir) { - $newIncludePath .= $newdir.$pathSep; - } - return "dir4".$pathSep . $newIncludePath; + global $reldirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($reldirs as $newdir) { + $newIncludePath .= $newdir.$pathSep; + } + return "dir4".$pathSep . $newIncludePath; } function generate_next_path() { - global $newdirs, $dir4; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($newdirs as $newdir) { - $newIncludePath .= $newdir.$pathSep; - } - return $dir4.$pathSep . $newIncludePath; + global $newdirs, $dir4; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($newdirs as $newdir) { + $newIncludePath .= $newdir.$pathSep; + } + return $dir4.$pathSep . $newIncludePath; } function create_include_path() { - global $newdirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($newdirs as $newdir) { - mkdir($newdir); - $newIncludePath .= $newdir.$pathSep; - } - return $newIncludePath; + global $newdirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($newdirs as $newdir) { + mkdir($newdir); + $newIncludePath .= $newdir.$pathSep; + } + return $newIncludePath; } function relative_include_path() { - global $reldirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($reldirs as $newdir) { - mkdir($newdir); - $newIncludePath .= $newdir.$pathSep; - } - return $newIncludePath; + global $reldirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($reldirs as $newdir) { + mkdir($newdir); + $newIncludePath .= $newdir.$pathSep; + } + return $newIncludePath; } function teardown_include_path() { - global $newdirs; - // remove the directory structure - foreach($newdirs as $newdir) { - rmdir($newdir); - } + global $newdirs; + // remove the directory structure + foreach($newdirs as $newdir) { + rmdir($newdir); + } } function teardown_relative_path() { - global $reldirs; - // remove the directory structure - foreach($reldirs as $newdir) { - rmdir($newdir); - } + global $reldirs; + // remove the directory structure + foreach($reldirs as $newdir) { + rmdir($newdir); + } } ?> diff --git a/ext/standard/tests/file/fopen_unlink.phpt b/ext/standard/tests/file/fopen_unlink.phpt index c87a8bb05538..8e66ae0608bc 100644 --- a/ext/standard/tests/file/fopen_unlink.phpt +++ b/ext/standard/tests/file/fopen_unlink.phpt @@ -4,17 +4,17 @@ Test fopen() function : check fopen()ed descriptor is usable after the fs object diff --git a/ext/standard/tests/file/fopen_variation12.phpt b/ext/standard/tests/file/fopen_variation12.phpt index 8786337e2300..1ac67df0482a 100644 --- a/ext/standard/tests/file/fopen_variation12.phpt +++ b/ext/standard/tests/file/fopen_variation12.phpt @@ -15,33 +15,33 @@ testme(); function testme() { - $tmpfile = basename(__FILE__, ".php") . ".tmp"; - $h = fopen($tmpfile, "w", true); - fwrite($h, "This is the test file"); - fclose($h); + $tmpfile = basename(__FILE__, ".php") . ".tmp"; + $h = fopen($tmpfile, "w", true); + fwrite($h, "This is the test file"); + fclose($h); - $h = @fopen($tmpfile, "r"); - if ($h === false) { - echo "Not created in working dir\n"; - } - else { - echo "created in working dir\n"; - fclose($h); - unlink($tmpfile); - } + $h = @fopen($tmpfile, "r"); + if ($h === false) { + echo "Not created in working dir\n"; + } + else { + echo "created in working dir\n"; + fclose($h); + unlink($tmpfile); + } - $scriptDirFile = __DIR__.'/'.$tmpfile; - $h = @fopen($scriptDirFile, "r"); - if ($h === false) { - echo "Not created in script dir\n"; - } - else { - echo "created in script dir\n"; - fclose($h); - unlink($scriptDirFile); - } + $scriptDirFile = __DIR__.'/'.$tmpfile; + $h = @fopen($scriptDirFile, "r"); + if ($h === false) { + echo "Not created in script dir\n"; + } + else { + echo "created in script dir\n"; + fclose($h); + unlink($scriptDirFile); + } } ?> --EXPECT-- diff --git a/ext/standard/tests/file/fopen_variation13.phpt b/ext/standard/tests/file/fopen_variation13.phpt index 0609f42d3b6e..0c446485a390 100644 --- a/ext/standard/tests/file/fopen_variation13.phpt +++ b/ext/standard/tests/file/fopen_variation13.phpt @@ -25,23 +25,23 @@ teardown_include_path(); function runtest() { $tempDir = 'fopen_variation13.dir.tmp'; - $tmpfile = 'fopen_variation13.tmp'; - $absFile = getcwd().'/'.$tempDir.'/'.$tmpfile; - - mkdir($tempDir); - $h = fopen($absFile, "w", true); - fwrite($h, "This is the test file"); - fclose($h); - - - $h = fopen($absFile, "r"); - if ($h === false) { - echo "Not created absolute location\n"; - } - else { - echo "Created in correct location\n"; - fclose($h); - } + $tmpfile = 'fopen_variation13.tmp'; + $absFile = getcwd().'/'.$tempDir.'/'.$tmpfile; + + mkdir($tempDir); + $h = fopen($absFile, "w", true); + fwrite($h, "This is the test file"); + fclose($h); + + + $h = fopen($absFile, "r"); + if ($h === false) { + echo "Not created absolute location\n"; + } + else { + echo "Created in correct location\n"; + fclose($h); + } unlink($absFile); rmdir($tempDir); diff --git a/ext/standard/tests/file/fopen_variation14-win32.phpt b/ext/standard/tests/file/fopen_variation14-win32.phpt index 470a2efd1ee6..f989e8c420ea 100644 --- a/ext/standard/tests/file/fopen_variation14-win32.phpt +++ b/ext/standard/tests/file/fopen_variation14-win32.phpt @@ -78,21 +78,21 @@ function runtest($fileURIs) { // create the file to test write $h = fopen($fileURI, 'w'); if ($h !== false) { - fwrite($h, $writeData); - fclose($h); - - $h = fopen($absFile, 'r'); - if ($h !== false) { - if (fread($h, 4096) != $writeData) { - echo "contents not correct\n"; - } - else { - echo "test passed\n"; - } - fclose($h); - } - unlink($absFile); - } + fwrite($h, $writeData); + fclose($h); + + $h = fopen($absFile, 'r'); + if ($h !== false) { + if (fread($h, 4096) != $writeData) { + echo "contents not correct\n"; + } + else { + echo "test passed\n"; + } + fclose($h); + } + unlink($absFile); + } } } diff --git a/ext/standard/tests/file/fopen_variation14.phpt b/ext/standard/tests/file/fopen_variation14.phpt index df9f115d14f0..fc98194d349d 100644 --- a/ext/standard/tests/file/fopen_variation14.phpt +++ b/ext/standard/tests/file/fopen_variation14.phpt @@ -70,21 +70,21 @@ function runtest($fileURIs) { // create the file to test write $h = fopen($fileURI, 'w'); if ($h !== false) { - fwrite($h, $writeData); - fclose($h); - - $h = fopen($absFile, 'r'); - if ($h !== false) { - if (fread($h, 4096) != $writeData) { - echo "contents not correct\n"; - } - else { - echo "test passed\n"; - } - fclose($h); - } - unlink($absFile); - } + fwrite($h, $writeData); + fclose($h); + + $h = fopen($absFile, 'r'); + if ($h !== false) { + if (fread($h, 4096) != $writeData) { + echo "contents not correct\n"; + } + else { + echo "test passed\n"; + } + fclose($h); + } + unlink($absFile); + } } } diff --git a/ext/standard/tests/file/fopen_variation15-win32.phpt b/ext/standard/tests/file/fopen_variation15-win32.phpt index 9daac25c005b..f263b1b393e7 100644 --- a/ext/standard/tests/file/fopen_variation15-win32.phpt +++ b/ext/standard/tests/file/fopen_variation15-win32.phpt @@ -82,21 +82,21 @@ function runtest($fileURIs) { // create the file to test write $h = fopen($fileURI, 'w', true); if ($h !== false) { - fwrite($h, $writeData); - fclose($h); - - $h = fopen($absFile, 'r'); - if ($h !== false) { - if (fread($h, 4096) != $writeData) { - echo "contents not correct\n"; - } - else { - echo "test passed\n"; - } - fclose($h); - } - unlink($absFile); - } + fwrite($h, $writeData); + fclose($h); + + $h = fopen($absFile, 'r'); + if ($h !== false) { + if (fread($h, 4096) != $writeData) { + echo "contents not correct\n"; + } + else { + echo "test passed\n"; + } + fclose($h); + } + unlink($absFile); + } } } diff --git a/ext/standard/tests/file/fopen_variation15.phpt b/ext/standard/tests/file/fopen_variation15.phpt index 36b1455250a1..a86b7d964274 100644 --- a/ext/standard/tests/file/fopen_variation15.phpt +++ b/ext/standard/tests/file/fopen_variation15.phpt @@ -74,21 +74,21 @@ function runtest($fileURIs) { // create the file to test write $h = fopen($fileURI, 'w', true); if ($h !== false) { - fwrite($h, $writeData); - fclose($h); - - $h = fopen($absFile, 'r'); - if ($h !== false) { - if (fread($h, 4096) != $writeData) { - echo "contents not correct\n"; - } - else { - echo "test passed\n"; - } - fclose($h); - } - unlink($absFile); - } + fwrite($h, $writeData); + fclose($h); + + $h = fopen($absFile, 'r'); + if ($h !== false) { + if (fread($h, 4096) != $writeData) { + echo "contents not correct\n"; + } + else { + echo "test passed\n"; + } + fclose($h); + } + unlink($absFile); + } } } diff --git a/ext/standard/tests/file/fopen_variation16.phpt b/ext/standard/tests/file/fopen_variation16.phpt index 6fe240bec94d..fa2fc026825a 100644 --- a/ext/standard/tests/file/fopen_variation16.phpt +++ b/ext/standard/tests/file/fopen_variation16.phpt @@ -36,31 +36,31 @@ function runtest() { mkdir($dir1.'/'.$extraDir); mkdir($extraDir); - $tmpfile = $extraDir.'/fopen_variation16.tmp'; + $tmpfile = $extraDir.'/fopen_variation16.tmp'; - $h = fopen($tmpfile, "w+", true); - fwrite($h, "This is the test file"); - fclose($h); + $h = fopen($tmpfile, "w+", true); + fwrite($h, "This is the test file"); + fclose($h); - $h = @fopen($dir1.'/'.$tmpfile, "r"); - if ($h === false) { - echo "Not created in dir1\n"; - } - else { - echo "created in dir1\n"; - fclose($h); - } + $h = @fopen($dir1.'/'.$tmpfile, "r"); + if ($h === false) { + echo "Not created in dir1\n"; + } + else { + echo "created in dir1\n"; + fclose($h); + } - $h = fopen($tmpfile, "r", true); - if ($h === false) { - echo "could not find file for reading\n"; - } - else { - echo "found file - not in dir1\n"; - fclose($h); - } + $h = fopen($tmpfile, "r", true); + if ($h === false) { + echo "could not find file for reading\n"; + } + else { + echo "found file - not in dir1\n"; + fclose($h); + } - unlink($tmpfile); + unlink($tmpfile); rmdir($dir1.'/'.$extraDir); rmdir($extraDir); } diff --git a/ext/standard/tests/file/fopen_variation17.phpt b/ext/standard/tests/file/fopen_variation17.phpt index 851493eb0827..9565cf614c21 100644 --- a/ext/standard/tests/file/fopen_variation17.phpt +++ b/ext/standard/tests/file/fopen_variation17.phpt @@ -36,30 +36,30 @@ function runtest() { mkdir($dir1.'/'.$extraDir); mkdir($extraDir); - $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp"; - $h = fopen($tmpfile, "w+", true); - fwrite($h, "This is the test file"); - fclose($h); + $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp"; + $h = fopen($tmpfile, "w+", true); + fwrite($h, "This is the test file"); + fclose($h); - $h = @fopen($dir1.'/'.$tmpfile, "r"); - if ($h === false) { - echo "Not created in dir1\n"; - } - else { - echo "created in dir1\n"; - fclose($h); - } + $h = @fopen($dir1.'/'.$tmpfile, "r"); + if ($h === false) { + echo "Not created in dir1\n"; + } + else { + echo "created in dir1\n"; + fclose($h); + } - $h = fopen($tmpfile, "r", true); - if ($h === false) { - echo "could not find file for reading\n"; - } - else { - echo "found file for reading\n"; - fclose($h); - } + $h = fopen($tmpfile, "r", true); + if ($h === false) { + echo "could not find file for reading\n"; + } + else { + echo "found file for reading\n"; + fclose($h); + } - unlink($tmpfile); + unlink($tmpfile); rmdir($dir1.'/'.$extraDir); rmdir($extraDir); } diff --git a/ext/standard/tests/file/fopen_variation7.phpt b/ext/standard/tests/file/fopen_variation7.phpt index c4800ae9b2ce..2a1e0268bcf3 100644 --- a/ext/standard/tests/file/fopen_variation7.phpt +++ b/ext/standard/tests/file/fopen_variation7.phpt @@ -29,31 +29,31 @@ rmdir($thisTestDir); function runtest() { global $dir1; - $tmpfile = basename(__FILE__, ".php") . ".tmp"; - $h = fopen($tmpfile, "w", true); - fwrite($h, "This is the test file"); - fclose($h); - - - $h = @fopen($tmpfile, "r"); - if ($h === false) { - echo "Not created in working dir\n"; - } - else { - echo "created in working dir\n"; - fclose($h); - unlink($tmpfile); - } - - $h = @fopen($dir1.'/'.$tmpfile, "r"); - if ($h === false) { - echo "Not created in dir1\n"; - } - else { - echo "created in dir1\n"; - fclose($h); - unlink($dir1.'/'.$tmpfile); - } + $tmpfile = basename(__FILE__, ".php") . ".tmp"; + $h = fopen($tmpfile, "w", true); + fwrite($h, "This is the test file"); + fclose($h); + + + $h = @fopen($tmpfile, "r"); + if ($h === false) { + echo "Not created in working dir\n"; + } + else { + echo "created in working dir\n"; + fclose($h); + unlink($tmpfile); + } + + $h = @fopen($dir1.'/'.$tmpfile, "r"); + if ($h === false) { + echo "Not created in dir1\n"; + } + else { + echo "created in dir1\n"; + fclose($h); + unlink($dir1.'/'.$tmpfile); + } } ?> --EXPECT-- diff --git a/ext/standard/tests/file/fopen_variation9.phpt b/ext/standard/tests/file/fopen_variation9.phpt index 0f1c2bafb822..850bf138d617 100644 --- a/ext/standard/tests/file/fopen_variation9.phpt +++ b/ext/standard/tests/file/fopen_variation9.phpt @@ -29,31 +29,31 @@ chdir(".."); rmdir($thisTestDir); function runtest() { - $tmpfile = basename(__FILE__, ".php") . ".tmp"; - $h = fopen($tmpfile, "w", true); - fwrite($h, "This is the test file"); - fclose($h); - - - $h = @fopen($tmpfile, "r"); - if ($h === false) { - echo "Not created in working dir\n"; - } - else { - echo "created in working dir\n"; - fclose($h); - unlink($tmpfile); - } - - $h = @fopen('dir1/'.$tmpfile, "r"); - if ($h === false) { - echo "Not created in dir1\n"; - } - else { - echo "created in dir1\n"; - fclose($h); - unlink('dir1/'.$tmpfile); - } + $tmpfile = basename(__FILE__, ".php") . ".tmp"; + $h = fopen($tmpfile, "w", true); + fwrite($h, "This is the test file"); + fclose($h); + + + $h = @fopen($tmpfile, "r"); + if ($h === false) { + echo "Not created in working dir\n"; + } + else { + echo "created in working dir\n"; + fclose($h); + unlink($tmpfile); + } + + $h = @fopen('dir1/'.$tmpfile, "r"); + if ($h === false) { + echo "Not created in dir1\n"; + } + else { + echo "created in dir1\n"; + fclose($h); + unlink('dir1/'.$tmpfile); + } } ?> --EXPECT-- diff --git a/ext/standard/tests/file/fopencookie.phpt b/ext/standard/tests/file/fopencookie.phpt index 20fd181cbd65..03c9a84cd4d0 100644 --- a/ext/standard/tests/file/fopencookie.phpt +++ b/ext/standard/tests/file/fopencookie.phpt @@ -17,68 +17,68 @@ fopencookie detected and working (or cast mechanism works) */ class userstream { - public $position = 0; - public $data = "If you can read this, it worked"; + public $position = 0; + public $data = "If you can read this, it worked"; - function stream_open($path, $mode, $options, &$opened_path) - { - return true; - } + function stream_open($path, $mode, $options, &$opened_path) + { + return true; + } - function stream_read($count) - { - $ret = substr($this->data, $this->position, $count); - $this->position += strlen($ret); - return $ret; - } + function stream_read($count) + { + $ret = substr($this->data, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } - function stream_tell() - { - return $this->position; - } + function stream_tell() + { + return $this->position; + } - function stream_eof() - { - return $this->position >= strlen($this->data); - } + function stream_eof() + { + return $this->position >= strlen($this->data); + } - function stream_seek($offset, $whence) - { - switch($whence) { - case SEEK_SET: - if ($offset < strlen($this->data) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - case SEEK_END: - if (strlen($this->data) + $offset >= 0) { - $this->position = strlen($this->data) + $offset; - return true; - } else { - return false; - } - break; - default: - return false; - } - } - function stream_stat() { - return array('size' => strlen($this->data)); - } - function stream_set_option($option, $arg1, $arg2) { - return false; - } + function stream_seek($offset, $whence) + { + switch($whence) { + case SEEK_SET: + if ($offset < strlen($this->data) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + case SEEK_END: + if (strlen($this->data) + $offset >= 0) { + $this->position = strlen($this->data) + $offset; + return true; + } else { + return false; + } + break; + default: + return false; + } + } + function stream_stat() { + return array('size' => strlen($this->data)); + } + function stream_set_option($option, $arg1, $arg2) { + return false; + } } stream_wrapper_register("cookietest", "userstream"); diff --git a/ext/standard/tests/file/fpassthru_basic.phpt b/ext/standard/tests/file/fpassthru_basic.phpt index f453a484f954..3304de406d4c 100644 --- a/ext/standard/tests/file/fpassthru_basic.phpt +++ b/ext/standard/tests/file/fpassthru_basic.phpt @@ -14,7 +14,7 @@ $write_handle = fopen($file_name, "w"); $string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^ Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n"; if(substr(PHP_OS, 0, 3) == "WIN") { - $string = str_replace("\r",'', $string); + $string = str_replace("\r",'', $string); } fwrite($write_handle, $string); fclose($write_handle); diff --git a/ext/standard/tests/file/fputcsv.phpt b/ext/standard/tests/file/fputcsv.phpt index f7286254f276..b303554e9c6e 100644 --- a/ext/standard/tests/file/fputcsv.phpt +++ b/ext/standard/tests/file/fputcsv.phpt @@ -31,14 +31,14 @@ $file = __DIR__ . '/fputcsv.csv'; $fp = fopen($file, "w"); foreach ($list as $v) { - fputcsv($fp, explode(',', $v)); + fputcsv($fp, explode(',', $v)); } fclose($fp); $res = file($file); foreach($res as &$val) { - $val = substr($val, 0, -1); + $val = substr($val, 0, -1); } echo '$list = ';var_export($res);echo ";\n"; @@ -46,7 +46,7 @@ $fp = fopen($file, "r"); $res = array(); while($l=fgetcsv($fp)) { - $res[] = join(',',$l); + $res[] = join(',',$l); } fclose($fp); diff --git a/ext/standard/tests/file/fputcsv_variation15.phpt b/ext/standard/tests/file/fputcsv_variation15.phpt index 1715d09e28a5..150fdd69d538 100644 --- a/ext/standard/tests/file/fputcsv_variation15.phpt +++ b/ext/standard/tests/file/fputcsv_variation15.phpt @@ -33,14 +33,14 @@ $file = __DIR__ . '/fputcsv_variation15.csv'; $fp = fopen($file, "w"); foreach ($list as $v) { - fputcsv($fp, explode(',', $v), ',', '"', '/'); + fputcsv($fp, explode(',', $v), ',', '"', '/'); } fclose($fp); $res = file($file); foreach($res as &$val) { - $val = substr($val, 0, -1); + $val = substr($val, 0, -1); } echo '$list = ';var_export($res);echo ";\n"; @@ -48,7 +48,7 @@ $fp = fopen($file, "r"); $res = array(); while($l=fgetcsv($fp, 0, ',', '"', '/')) { - $res[] = join(',',$l); + $res[] = join(',',$l); } fclose($fp); diff --git a/ext/standard/tests/file/fscanf_variation19.phpt b/ext/standard/tests/file/fscanf_variation19.phpt index bfb5d40223ab..31cc83297b8f 100644 --- a/ext/standard/tests/file/fscanf_variation19.phpt +++ b/ext/standard/tests/file/fscanf_variation19.phpt @@ -31,8 +31,8 @@ $bool_types = array ( $string_formats = array( "%s", "%hs", "%ls", "%Ls", " %s", "%s ", "% s", - "\t%s", "\n%s", "%4s", - "%30s", "%[a-zA-Z0-9]", "%*s"); + "\t%s", "\n%s", "%4s", + "%30s", "%[a-zA-Z0-9]", "%*s"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation20.phpt b/ext/standard/tests/file/fscanf_variation20.phpt index 10f3a2142d6d..34dac83bf108 100644 --- a/ext/standard/tests/file/fscanf_variation20.phpt +++ b/ext/standard/tests/file/fscanf_variation20.phpt @@ -43,10 +43,10 @@ $valid_ints = array( ); // various char formats $char_formats = array( "%c", - "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-bA-B@#$&]", "%*c"); + "%hc", "%lc", "%Lc", + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-bA-B@#$&]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation21.phpt b/ext/standard/tests/file/fscanf_variation21.phpt index 39958c8de8f1..e0c8074eada4 100644 --- a/ext/standard/tests/file/fscanf_variation21.phpt +++ b/ext/standard/tests/file/fscanf_variation21.phpt @@ -42,9 +42,9 @@ $float_values = array ( $char_formats = array( "%c", "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation22.phpt b/ext/standard/tests/file/fscanf_variation22.phpt index b5656ce907be..2fb450750db3 100644 --- a/ext/standard/tests/file/fscanf_variation22.phpt +++ b/ext/standard/tests/file/fscanf_variation22.phpt @@ -32,10 +32,10 @@ $resource_types = array ( ); $char_formats = array( "%c", - "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); + "%hc", "%lc", "%Lc", + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation23.phpt b/ext/standard/tests/file/fscanf_variation23.phpt index 61d62fc05cb0..e8b9c0dae279 100644 --- a/ext/standard/tests/file/fscanf_variation23.phpt +++ b/ext/standard/tests/file/fscanf_variation23.phpt @@ -37,10 +37,10 @@ $array_types = array ( ); $char_formats = array( "%c", - "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); + "%hc", "%lc", "%Lc", + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation24.phpt b/ext/standard/tests/file/fscanf_variation24.phpt index 1177e2e2d0a4..576919c8863a 100644 --- a/ext/standard/tests/file/fscanf_variation24.phpt +++ b/ext/standard/tests/file/fscanf_variation24.phpt @@ -43,10 +43,10 @@ $strings = array ( ); $char_formats = array( "%c", - "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); + "%hc", "%lc", "%Lc", + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation25.phpt b/ext/standard/tests/file/fscanf_variation25.phpt index ba37a07a3ee2..0fea04e43832 100644 --- a/ext/standard/tests/file/fscanf_variation25.phpt +++ b/ext/standard/tests/file/fscanf_variation25.phpt @@ -29,10 +29,10 @@ $bool_types = array ( ); $char_formats = array( "%c", - "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); + "%hc", "%lc", "%Lc", + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation26.phpt b/ext/standard/tests/file/fscanf_variation26.phpt index bd499d37c551..5b1c5b0428bc 100644 --- a/ext/standard/tests/file/fscanf_variation26.phpt +++ b/ext/standard/tests/file/fscanf_variation26.phpt @@ -24,10 +24,10 @@ if($file_handle == false) $char_types = array( 'a', "a", 67, -67, 99 ); $char_formats = array( "%c", - "%hc", "%lc", "%Lc", - " %c", "%c ", "% c", - "\t%c", "\n%c", "%4c", - "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); + "%hc", "%lc", "%Lc", + " %c", "%c ", "% c", + "\t%c", "\n%c", "%4c", + "%30c", "%[a-zA-Z@#$&0-9]", "%*c"); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation29.phpt b/ext/standard/tests/file/fscanf_variation29.phpt index 1d25e81cebc4..1621958fa4ff 100644 --- a/ext/standard/tests/file/fscanf_variation29.phpt +++ b/ext/standard/tests/file/fscanf_variation29.phpt @@ -32,11 +32,11 @@ $resource_types = array ( ); $octal_formats = array( "%o", - "%ho", "%lo", "%Lo", - " %o", "%o ", "% o", - "\t%o", "\n%o", "%4o", - "%30o", "%[0-7]", "%*o" - ); + "%ho", "%lo", "%Lo", + " %o", "%o ", "% o", + "\t%o", "\n%o", "%4o", + "%30o", "%[0-7]", "%*o" + ); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation30.phpt b/ext/standard/tests/file/fscanf_variation30.phpt index 5b7dd0214757..3af42e34bc0e 100644 --- a/ext/standard/tests/file/fscanf_variation30.phpt +++ b/ext/standard/tests/file/fscanf_variation30.phpt @@ -37,11 +37,11 @@ $array_types = array ( ); $octal_formats = array ( "%o", - "%ho", "%lo", "%Lo", - " %o", "%o ", "% o", - "\t%o", "\n%o", "%4o", - "%30o", "%[0-7]", "%*o" - ); + "%ho", "%lo", "%Lo", + " %o", "%o ", "% o", + "\t%o", "\n%o", "%4o", + "%30o", "%[0-7]", "%*o" + ); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation32.phpt b/ext/standard/tests/file/fscanf_variation32.phpt index ef0c2b70369a..556f60363e12 100644 --- a/ext/standard/tests/file/fscanf_variation32.phpt +++ b/ext/standard/tests/file/fscanf_variation32.phpt @@ -29,11 +29,11 @@ $bool_types = array ( ); $octal_formats = array( "%o", - "%ho", "%lo", "%Lo", - " %o", "%o ", "% o", - "\t%o", "\n%o", "%4o", - "%30o", "%[0-7]", "%*o" - ); + "%ho", "%lo", "%Lo", + " %o", "%o ", "% o", + "\t%o", "\n%o", "%4o", + "%30o", "%[0-7]", "%*o" + ); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation33.phpt b/ext/standard/tests/file/fscanf_variation33.phpt index 357544d1c46f..2753a890b57c 100644 --- a/ext/standard/tests/file/fscanf_variation33.phpt +++ b/ext/standard/tests/file/fscanf_variation33.phpt @@ -49,11 +49,11 @@ $valid_ints = array( ); // various hexa formats $hexa_formats = array( "%x", - "%xx", "%lx", "%Lx", - " %x", "%x ", "% x", - "\t%x", "\n%x", "%4x", - "%30x", "%[0-9A-Fa-f]", "%*x" - ); + "%xx", "%lx", "%Lx", + " %x", "%x ", "% x", + "\t%x", "\n%x", "%4x", + "%30x", "%[0-9A-Fa-f]", "%*x" + ); $counter = 1; diff --git a/ext/standard/tests/file/fscanf_variation34.phpt b/ext/standard/tests/file/fscanf_variation34.phpt index 949ee5fb568b..ca0ca65e951b 100644 --- a/ext/standard/tests/file/fscanf_variation34.phpt +++ b/ext/standard/tests/file/fscanf_variation34.phpt @@ -47,10 +47,10 @@ $float_values = array ( ); $hexa_formats = array( "%x", - "%hx", "%lx", "%Lx", - " %x", "%x ", "% x", - "\t%x", "\n%x", "%4x", - "%30x", "%[0-9A-Za-z]", "%*x"); + "%hx", "%lx", "%Lx", + " %x", "%x ", "% x", + "\t%x", "\n%x", "%4x", + "%30x", "%[0-9A-Za-z]", "%*x"); $counter = 1; diff --git a/ext/standard/tests/file/fstat_variation8.phpt b/ext/standard/tests/file/fstat_variation8.phpt index 4376d6e563bc..95036f5013ee 100644 --- a/ext/standard/tests/file/fstat_variation8.phpt +++ b/ext/standard/tests/file/fstat_variation8.phpt @@ -15,10 +15,10 @@ foreach($stat_result as $key =>$value) { // windows, dev and rdev will not match this is expected } else { - if ($fstat_result[$key] != $value) { - echo "FAIL: stat differs at '$key'. $fstat_result[$key] -- $value\n"; - $failed = true; - } + if ($fstat_result[$key] != $value) { + echo "FAIL: stat differs at '$key'. $fstat_result[$key] -- $value\n"; + $failed = true; + } } } if ($failed !== true) { diff --git a/ext/standard/tests/file/ftruncate_bug76422.phpt b/ext/standard/tests/file/ftruncate_bug76422.phpt index d291ec2efc67..84134acfd076 100644 --- a/ext/standard/tests/file/ftruncate_bug76422.phpt +++ b/ext/standard/tests/file/ftruncate_bug76422.phpt @@ -33,7 +33,7 @@ $ftruncate_result = ftruncate($file_handle, $truncate_offset); if (false === $ftruncate_result) { // NOTE: unlink() is deliberately repeated - If this test runs out of disk space attempting to reserve space for this temporary file, - // then the --CLEAN-- script can't be run (if we don't delete the file), + // then the--CLEAN-- script can't be run (if we don't delete the file), // because there wouldn't be any free disk space to save a new php file. fclose($file_handle); unlink($fn); diff --git a/ext/standard/tests/file/include_streams.phpt b/ext/standard/tests/file/include_streams.phpt index 0b9446ff9eb2..90629d3ffc60 100644 --- a/ext/standard/tests/file/include_streams.phpt +++ b/ext/standard/tests/file/include_streams.phpt @@ -10,99 +10,99 @@ EOD; class mystream { - public $path; - public $mode; - public $options; - - public $position; - public $varname; - - function url_stat($path, $flags) { - return array(); - } - - function stream_stat() { - return array(); - } - - function stream_open($path, $mode, $options, &$opened_path) - { - $this->path = $path; - $this->mode = $mode; - $this->options = $options; - - $split = parse_url($path); - if ($split["host"] !== "GLOBALS" || - empty($split["path"]) || - empty($GLOBALS[substr($split["path"],1)])) { - return false; - } - $this->varname = substr($split["path"],1); - - if (strchr($mode, 'a')) - $this->position = strlen($GLOBALS[$this->varname]); - else - $this->position = 0; - - return true; - } - - function stream_read($count) - { - $ret = substr($GLOBALS[$this->varname], $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - function stream_tell() - { - return $this->position; - } - - function stream_eof() - { - return $this->position >= strlen($GLOBALS[$this->varname]); - } - - function stream_seek($offset, $whence) - { - switch($whence) { - case SEEK_SET: - if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - case SEEK_END: - if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; - } else { - return false; - } - break; - default: - return false; - } - } - - function stream_set_option($option, $arg1, $arg2) { - return false; - } + public $path; + public $mode; + public $options; + + public $position; + public $varname; + + function url_stat($path, $flags) { + return array(); + } + + function stream_stat() { + return array(); + } + + function stream_open($path, $mode, $options, &$opened_path) + { + $this->path = $path; + $this->mode = $mode; + $this->options = $options; + + $split = parse_url($path); + if ($split["host"] !== "GLOBALS" || + empty($split["path"]) || + empty($GLOBALS[substr($split["path"],1)])) { + return false; + } + $this->varname = substr($split["path"],1); + + if (strchr($mode, 'a')) + $this->position = strlen($GLOBALS[$this->varname]); + else + $this->position = 0; + + return true; + } + + function stream_read($count) + { + $ret = substr($GLOBALS[$this->varname], $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + function stream_tell() + { + return $this->position; + } + + function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + + function stream_seek($offset, $whence) + { + switch($whence) { + case SEEK_SET: + if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + case SEEK_END: + if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; + } else { + return false; + } + break; + default: + return false; + } + } + + function stream_set_option($option, $arg1, $arg2) { + return false; + } } if (!stream_wrapper_register("test", "mystream")) { - die("test wrapper registration failed"); + die("test wrapper registration failed"); } echo file_get_contents("test://GLOBALS/data1"); diff --git a/ext/standard/tests/file/include_userstream_001.phpt b/ext/standard/tests/file/include_userstream_001.phpt index d769a4f3b24d..988a8bf085fd 100644 --- a/ext/standard/tests/file/include_userstream_001.phpt +++ b/ext/standard/tests/file/include_userstream_001.phpt @@ -7,66 +7,66 @@ allow_url_include=0 '; - private $pos; + private $pos; - function stream_open($path, $mode, $options, &$opened_path) - { - if (strchr($mode, 'a')) - $this->pos = strlen($this->data); - else - $this->po = 0; + function stream_open($path, $mode, $options, &$opened_path) + { + if (strchr($mode, 'a')) + $this->pos = strlen($this->data); + else + $this->po = 0; - return true; - } + return true; + } - function stream_read($count) - { - $ret = substr($this->data, $this->pos, $count); - $this->pos += strlen($ret); - return $ret; - } + function stream_read($count) + { + $ret = substr($this->data, $this->pos, $count); + $this->pos += strlen($ret); + return $ret; + } - function stream_tell() - { - return $this->pos; - } + function stream_tell() + { + return $this->pos; + } - function stream_eof() - { - return $this->pos >= strlen($this->data); - } + function stream_eof() + { + return $this->pos >= strlen($this->data); + } - function stream_seek($offset, $whence) - { - switch($whence) { - case SEEK_SET: - if ($offset < $this->data && $offset >= 0) { - $this->pos = $offset; - return true; - } else { - return false; - } - break; - case SEEK_CUR: - if ($offset >= 0) { - $this->pos += $offset; - return true; - } else { - return false; - } - break; - case SEEK_END: - if (strlen($this->data) + $offset >= 0) { - $this->pos = strlen($this->data) + $offset; - return true; - } else { - return false; - } - break; - default: - return false; - } - } + function stream_seek($offset, $whence) + { + switch($whence) { + case SEEK_SET: + if ($offset < $this->data && $offset >= 0) { + $this->pos = $offset; + return true; + } else { + return false; + } + break; + case SEEK_CUR: + if ($offset >= 0) { + $this->pos += $offset; + return true; + } else { + return false; + } + break; + case SEEK_END: + if (strlen($this->data) + $offset >= 0) { + $this->pos = strlen($this->data) + $offset; + return true; + } else { + return false; + } + break; + default: + return false; + } + } } diff --git a/ext/standard/tests/file/include_userstream_002.phpt b/ext/standard/tests/file/include_userstream_002.phpt index 208248f873c2..15c05314a5e1 100644 --- a/ext/standard/tests/file/include_userstream_002.phpt +++ b/ext/standard/tests/file/include_userstream_002.phpt @@ -7,83 +7,83 @@ allow_url_include=0 '; - private $pos; - private $stream = null; + private $pos; + private $stream = null; - function stream_open($path, $mode, $options, &$opened_path) - { - if (strpos($path, "test2://") === 0) { - $this->stream = fopen("test1://".substr($path, 8), $mode); - return !empty($this->stream); - } - if (strchr($mode, 'a')) - $this->pos = strlen($this->data); - else - $this->po = 0; + function stream_open($path, $mode, $options, &$opened_path) + { + if (strpos($path, "test2://") === 0) { + $this->stream = fopen("test1://".substr($path, 8), $mode); + return !empty($this->stream); + } + if (strchr($mode, 'a')) + $this->pos = strlen($this->data); + else + $this->po = 0; - return true; - } + return true; + } - function stream_read($count) - { - if (!empty($this->stream)) { - return fread($this->stream, $count); - } - $ret = substr($this->data, $this->pos, $count); - $this->pos += strlen($ret); - return $ret; - } + function stream_read($count) + { + if (!empty($this->stream)) { + return fread($this->stream, $count); + } + $ret = substr($this->data, $this->pos, $count); + $this->pos += strlen($ret); + return $ret; + } - function stream_tell() - { - if (!empty($this->stream)) { - return ftell($this->stream); - } - return $this->pos; - } + function stream_tell() + { + if (!empty($this->stream)) { + return ftell($this->stream); + } + return $this->pos; + } - function stream_eof() - { - if (!empty($this->stream)) { - return feof($this->stream); - } - return $this->pos >= strlen($this->data); - } + function stream_eof() + { + if (!empty($this->stream)) { + return feof($this->stream); + } + return $this->pos >= strlen($this->data); + } - function stream_seek($offset, $whence) - { - if (!empty($this->stream)) { - return fseek($this->stream, $offset, $whence); - } - switch($whence) { - case SEEK_SET: - if ($offset < $this->data && $offset >= 0) { - $this->pos = $offset; - return true; - } else { - return false; - } - break; - case SEEK_CUR: - if ($offset >= 0) { - $this->pos += $offset; - return true; - } else { - return false; - } - break; - case SEEK_END: - if (strlen($this->data) + $offset >= 0) { - $this->pos = strlen($this->data) + $offset; - return true; - } else { - return false; - } - break; - default: - return false; - } - } + function stream_seek($offset, $whence) + { + if (!empty($this->stream)) { + return fseek($this->stream, $offset, $whence); + } + switch($whence) { + case SEEK_SET: + if ($offset < $this->data && $offset >= 0) { + $this->pos = $offset; + return true; + } else { + return false; + } + break; + case SEEK_CUR: + if ($offset >= 0) { + $this->pos += $offset; + return true; + } else { + return false; + } + break; + case SEEK_END: + if (strlen($this->data) + $offset >= 0) { + $this->pos = strlen($this->data) + $offset; + return true; + } else { + return false; + } + break; + default: + return false; + } + } } diff --git a/ext/standard/tests/file/include_userstream_003.phpt b/ext/standard/tests/file/include_userstream_003.phpt index 5ffe28a8406a..ae6ec62649e4 100644 --- a/ext/standard/tests/file/include_userstream_003.phpt +++ b/ext/standard/tests/file/include_userstream_003.phpt @@ -7,83 +7,83 @@ allow_url_include=1 '; - private $pos; - private $stream = null; - - function stream_open($path, $mode, $options, &$opened_path) - { - if (strpos($path, "test2://") === 0) { - $this->stream = fopen("test1://".substr($path, 8), $mode); - return !empty($this->stream); - } - if (strchr($mode, 'a')) - $this->pos = strlen($this->data); - else - $this->po = 0; - - return true; - } - - function stream_read($count) - { - if (!empty($this->stream)) { - return fread($this->stream, $count); - } - $ret = substr($this->data, $this->pos, $count); - $this->pos += strlen($ret); - return $ret; - } - - function stream_tell() - { - if (!empty($this->stream)) { - return ftell($this->stream); - } - return $this->pos; - } - - function stream_eof() - { - if (!empty($this->stream)) { - return feof($this->stream); - } - return $this->pos >= strlen($this->data); - } - - function stream_seek($offset, $whence) - { - if (!empty($this->stream)) { - return fseek($this->stream, $offset, $whence); - } - switch($whence) { - case SEEK_SET: - if ($offset < $this->data && $offset >= 0) { - $this->pos = $offset; - return true; - } else { - return false; - } - break; - case SEEK_CUR: - if ($offset >= 0) { - $this->pos += $offset; - return true; - } else { - return false; - } - break; - case SEEK_END: - if (strlen($this->data) + $offset >= 0) { - $this->pos = strlen($this->data) + $offset; - return true; - } else { - return false; - } - break; - default: - return false; - } - } + private $pos; + private $stream = null; + + function stream_open($path, $mode, $options, &$opened_path) + { + if (strpos($path, "test2://") === 0) { + $this->stream = fopen("test1://".substr($path, 8), $mode); + return !empty($this->stream); + } + if (strchr($mode, 'a')) + $this->pos = strlen($this->data); + else + $this->po = 0; + + return true; + } + + function stream_read($count) + { + if (!empty($this->stream)) { + return fread($this->stream, $count); + } + $ret = substr($this->data, $this->pos, $count); + $this->pos += strlen($ret); + return $ret; + } + + function stream_tell() + { + if (!empty($this->stream)) { + return ftell($this->stream); + } + return $this->pos; + } + + function stream_eof() + { + if (!empty($this->stream)) { + return feof($this->stream); + } + return $this->pos >= strlen($this->data); + } + + function stream_seek($offset, $whence) + { + if (!empty($this->stream)) { + return fseek($this->stream, $offset, $whence); + } + switch($whence) { + case SEEK_SET: + if ($offset < $this->data && $offset >= 0) { + $this->pos = $offset; + return true; + } else { + return false; + } + break; + case SEEK_CUR: + if ($offset >= 0) { + $this->pos += $offset; + return true; + } else { + return false; + } + break; + case SEEK_END: + if (strlen($this->data) + $offset >= 0) { + $this->pos = strlen($this->data) + $offset; + return true; + } else { + return false; + } + break; + default: + return false; + } + } } diff --git a/ext/standard/tests/file/parse_ini_file.phpt b/ext/standard/tests/file/parse_ini_file.phpt index eed17c00936a..817b92aa7f36 100644 --- a/ext/standard/tests/file/parse_ini_file.phpt +++ b/ext/standard/tests/file/parse_ini_file.phpt @@ -25,7 +25,7 @@ PHP_CONSTANT = 1.2345678 HELLO = HELLO [date] -date = +date = time = [paths] @@ -64,7 +64,7 @@ Non_alpha11 = / Non_alpha12 = \ ;These chars have a special meaning when used in the value, ; hence parser throws an error -;Non_alpha13 = & +;Non_alpha13 = & ;Non_alpha14 = ^ ;Non_alpha15 = {} ;Non_alpha16 = | @@ -172,7 +172,7 @@ Key16 = Null Key17 = nuLL Key18 = null -[ReservedKeys_as_Keys] +[ReservedKeys_as_Keys] ; Expected:error, reserved key words must not be used as keys for ini file ;YES = 1 ;Yes = 2 diff --git a/ext/standard/tests/file/pathinfo_basic1-win32.phpt b/ext/standard/tests/file/pathinfo_basic1-win32.phpt index acca647a9733..060c7e3423b4 100644 --- a/ext/standard/tests/file/pathinfo_basic1-win32.phpt +++ b/ext/standard/tests/file/pathinfo_basic1-win32.phpt @@ -16,45 +16,45 @@ if(substr(PHP_OS, 0, 3) != "WIN") echo "*** Testing basic functions of pathinfo() ***\n"; $paths = array ( - '', - ' ', - 'c:', - 'c:\\', - 'c:/', - 'afile', - 'c:\test\adir', - 'c:\test\adir\\', - '/usr/include/arpa', - '/usr/include/arpa/', - 'usr/include/arpa', - 'usr/include/arpa/', - 'c:\test\afile', - 'c:\\test\\afile', - 'c://test//afile', - 'c:\test\afile\\', - 'c:\test\prog.exe', - 'c:\\test\\prog.exe', - 'c:/test/prog.exe', - '/usr/include/arpa/inet.h', - '//usr/include//arpa/inet.h', - '\\', - '\\\\', - '/', - '//', - '///', - '/usr/include/arpa/inet.h', - 'c:\windows/system32\drivers/etc\hosts', - '/usr\include/arpa\inet.h', - ' c:\test\adir\afile.txt', - 'c:\test\adir\afile.txt ', - ' c:\test\adir\afile.txt ', - ' /usr/include/arpa/inet.h', - '/usr/include/arpa/inet.h ', - ' /usr/include/arpa/inet.h ', - ' c:', - ' c:\test\adir\afile.txt', - '/usr', - '/usr/' + '', + ' ', + 'c:', + 'c:\\', + 'c:/', + 'afile', + 'c:\test\adir', + 'c:\test\adir\\', + '/usr/include/arpa', + '/usr/include/arpa/', + 'usr/include/arpa', + 'usr/include/arpa/', + 'c:\test\afile', + 'c:\\test\\afile', + 'c://test//afile', + 'c:\test\afile\\', + 'c:\test\prog.exe', + 'c:\\test\\prog.exe', + 'c:/test/prog.exe', + '/usr/include/arpa/inet.h', + '//usr/include//arpa/inet.h', + '\\', + '\\\\', + '/', + '//', + '///', + '/usr/include/arpa/inet.h', + 'c:\windows/system32\drivers/etc\hosts', + '/usr\include/arpa\inet.h', + ' c:\test\adir\afile.txt', + 'c:\test\adir\afile.txt ', + ' c:\test\adir\afile.txt ', + ' /usr/include/arpa/inet.h', + '/usr/include/arpa/inet.h ', + ' /usr/include/arpa/inet.h ', + ' c:', + ' c:\test\adir\afile.txt', + '/usr', + '/usr/' ); $counter = 1; diff --git a/ext/standard/tests/file/pathinfo_basic1.phpt b/ext/standard/tests/file/pathinfo_basic1.phpt index c9e84522a89b..d195a76fb3b3 100644 --- a/ext/standard/tests/file/pathinfo_basic1.phpt +++ b/ext/standard/tests/file/pathinfo_basic1.phpt @@ -16,45 +16,45 @@ if(substr(PHP_OS, 0, 3) == "WIN") echo "*** Testing basic functions of pathinfo() ***\n"; $paths = array ( - '', - ' ', - 'c:', - 'c:\\', - 'c:/', - 'afile', - 'c:\test\adir', - 'c:\test\adir\\', - '/usr/include/arpa', - '/usr/include/arpa/', - 'usr/include/arpa', - 'usr/include/arpa/', - 'c:\test\afile', - 'c:\\test\\afile', - 'c://test//afile', - 'c:\test\afile\\', - 'c:\test\prog.exe', - 'c:\\test\\prog.exe', - 'c:/test/prog.exe', - '/usr/include/arpa/inet.h', - '//usr/include//arpa/inet.h', - '\\', - '\\\\', - '/', - '//', - '///', - '/usr/include/arpa/inet.h', - 'c:\windows/system32\drivers/etc\hosts', - '/usr\include/arpa\inet.h', - ' c:\test\adir\afile.txt', - 'c:\test\adir\afile.txt ', - ' c:\test\adir\afile.txt ', - ' /usr/include/arpa/inet.h', - '/usr/include/arpa/inet.h ', - ' /usr/include/arpa/inet.h ', - ' c:', - ' c:\test\adir\afile.txt', - '/usr', - '/usr/' + '', + ' ', + 'c:', + 'c:\\', + 'c:/', + 'afile', + 'c:\test\adir', + 'c:\test\adir\\', + '/usr/include/arpa', + '/usr/include/arpa/', + 'usr/include/arpa', + 'usr/include/arpa/', + 'c:\test\afile', + 'c:\\test\\afile', + 'c://test//afile', + 'c:\test\afile\\', + 'c:\test\prog.exe', + 'c:\\test\\prog.exe', + 'c:/test/prog.exe', + '/usr/include/arpa/inet.h', + '//usr/include//arpa/inet.h', + '\\', + '\\\\', + '/', + '//', + '///', + '/usr/include/arpa/inet.h', + 'c:\windows/system32\drivers/etc\hosts', + '/usr\include/arpa\inet.h', + ' c:\test\adir\afile.txt', + 'c:\test\adir\afile.txt ', + ' c:\test\adir\afile.txt ', + ' /usr/include/arpa/inet.h', + '/usr/include/arpa/inet.h ', + ' /usr/include/arpa/inet.h ', + ' c:', + ' c:\test\adir\afile.txt', + '/usr', + '/usr/' ); $counter = 1; diff --git a/ext/standard/tests/file/pathinfo_basic2-win32.phpt b/ext/standard/tests/file/pathinfo_basic2-win32.phpt index 5a88b648d356..97f38994260d 100644 --- a/ext/standard/tests/file/pathinfo_basic2-win32.phpt +++ b/ext/standard/tests/file/pathinfo_basic2-win32.phpt @@ -16,21 +16,21 @@ if(substr(PHP_OS, 0, 3) != "WIN") echo "*** Testing basic functions of pathinfo() ***\n"; $paths = array ( - 'c:\..\dir1', - 'c:\test\..\test2\.\adir\afile.txt', - '/usr/include/../arpa/./inet.h', - 'c:\test\adir\afile..txt', - '/usr/include/arpa/inet..h', - 'c:\test\adir\afile.', - '/usr/include/arpa/inet.', - '/usr/include/arpa/inet,h', - 'c:afile.txt', - '..\.\..\test\afile.txt', - '.././../test/afile', - '.', - '..', - '...', - '/usr/lib/.../afile' + 'c:\..\dir1', + 'c:\test\..\test2\.\adir\afile.txt', + '/usr/include/../arpa/./inet.h', + 'c:\test\adir\afile..txt', + '/usr/include/arpa/inet..h', + 'c:\test\adir\afile.', + '/usr/include/arpa/inet.', + '/usr/include/arpa/inet,h', + 'c:afile.txt', + '..\.\..\test\afile.txt', + '.././../test/afile', + '.', + '..', + '...', + '/usr/lib/.../afile' ); diff --git a/ext/standard/tests/file/pathinfo_basic2.phpt b/ext/standard/tests/file/pathinfo_basic2.phpt index 51de45d33d11..3ae6e1338cb6 100644 --- a/ext/standard/tests/file/pathinfo_basic2.phpt +++ b/ext/standard/tests/file/pathinfo_basic2.phpt @@ -16,21 +16,21 @@ if(substr(PHP_OS, 0, 3) == "WIN") echo "*** Testing basic functions of pathinfo() ***\n"; $paths = array ( - 'c:\..\dir1', - 'c:\test\..\test2\.\adir\afile.txt', - '/usr/include/../arpa/./inet.h', - 'c:\test\adir\afile..txt', - '/usr/include/arpa/inet..h', - 'c:\test\adir\afile.', - '/usr/include/arpa/inet.', - '/usr/include/arpa/inet,h', - 'c:afile.txt', - '..\.\..\test\afile.txt', - '.././../test/afile', - '.', - '..', - '...', - '/usr/lib/.../afile' + 'c:\..\dir1', + 'c:\test\..\test2\.\adir\afile.txt', + '/usr/include/../arpa/./inet.h', + 'c:\test\adir\afile..txt', + '/usr/include/arpa/inet..h', + 'c:\test\adir\afile.', + '/usr/include/arpa/inet.', + '/usr/include/arpa/inet,h', + 'c:afile.txt', + '..\.\..\test\afile.txt', + '.././../test/afile', + '.', + '..', + '...', + '/usr/lib/.../afile' ); diff --git a/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt b/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt index 2d9b2b92dc81..008cef36432b 100644 --- a/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt +++ b/ext/standard/tests/file/popen_pclose_basic-win32-mb.phpt @@ -28,7 +28,7 @@ echo "*** Testing popen(): writing to the pipe ***\n"; $arr = array("ggg", "ddd", "aaa", "sss"); // popen("sort", "w") fails if variables_order="GPCS" // this is set in the default INI file -// it doesn't seem to be changeable in the --INI-- section +// it doesn't seem to be changeable in the--INI-- section // also, doing: ini_set('variables_order', ''); doesn't work! // // the only solution is to either put the absolute path here, or diff --git a/ext/standard/tests/file/popen_pclose_basic-win32.phpt b/ext/standard/tests/file/popen_pclose_basic-win32.phpt index dfb00fbeb2db..5be3ee4ca870 100644 --- a/ext/standard/tests/file/popen_pclose_basic-win32.phpt +++ b/ext/standard/tests/file/popen_pclose_basic-win32.phpt @@ -28,7 +28,7 @@ echo "*** Testing popen(): writing to the pipe ***\n"; $arr = array("ggg", "ddd", "aaa", "sss"); // popen("sort", "w") fails if variables_order="GPCS" // this is set in the default INI file -// it doesn't seem to be changeable in the --INI-- section +// it doesn't seem to be changeable in the--INI-- section // also, doing: ini_set('variables_order', ''); doesn't work! // // the only solution is to either put the absolute path here, or diff --git a/ext/standard/tests/file/proc_open01.phpt b/ext/standard/tests/file/proc_open01.phpt index 66c601fb9187..2f74a17464f1 100644 --- a/ext/standard/tests/file/proc_open01.phpt +++ b/ext/standard/tests/file/proc_open01.phpt @@ -6,15 +6,15 @@ $pipes = array(1, 2, 3); $orig_pipes = $pipes; $php = getenv('TEST_PHP_EXECUTABLE'); if ($php === false) { - die("no php executable defined"); + die("no php executable defined"); } $proc = proc_open( - "$php -n", - array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')), - $pipes, getcwd(), array(), array() + "$php -n", + array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')), + $pipes, getcwd(), array(), array() ); if ($proc === false) { - print "something went wrong.\n"; + print "something went wrong.\n"; } var_dump($pipes); stream_set_blocking($pipes[1], FALSE); @@ -25,25 +25,25 @@ fclose($pipes[0]); $cnt = ''; $n=0; for ($left = strlen($test_string); $left > 0;) { - if (++$n >1000) { - print "terminated after 1000 iterations\n"; - break; - } - $read_fds = array($pipes[1]); - $write_fds = NULL; - $exp_fds = NULL; - $retval = stream_select($read_fds, $write_fds, $exp_fds, 5); - if ($retval === false) { - print "select() failed\n"; - break; - } - if ($retval === 0) { - print "timed out\n"; - break; - } - $buf = fread($pipes[1], 1024); - $cnt .= $buf; - $left -= strlen($buf); + if (++$n >1000) { + print "terminated after 1000 iterations\n"; + break; + } + $read_fds = array($pipes[1]); + $write_fds = NULL; + $exp_fds = NULL; + $retval = stream_select($read_fds, $write_fds, $exp_fds, 5); + if ($retval === false) { + print "select() failed\n"; + break; + } + if ($retval === 0) { + print "timed out\n"; + break; + } + $buf = fread($pipes[1], 1024); + $cnt .= $buf; + $left -= strlen($buf); } var_dump($cnt); fclose($pipes[1]); diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt index 83a4a88b29bc..e80acae01b9f 100644 --- a/ext/standard/tests/file/rename_variation13-win32.phpt +++ b/ext/standard/tests/file/rename_variation13-win32.phpt @@ -42,7 +42,7 @@ $file_path = __DIR__."/renameVar13"; $aFile = $file_path.'/afile.tmp'; if (!mkdir($file_path)) { - die("fail to create $file_path tmp dir"); + die("fail to create $file_path tmp dir"); } for( $i=0; $i < count($names_arr); $i++ ) { diff --git a/ext/standard/tests/file/rename_variation3-win32.phpt b/ext/standard/tests/file/rename_variation3-win32.phpt index b14b814295e4..a9e30573402a 100644 --- a/ext/standard/tests/file/rename_variation3-win32.phpt +++ b/ext/standard/tests/file/rename_variation3-win32.phpt @@ -25,7 +25,7 @@ mkdir($dirname); $filename = "$file_path/rename_variation3.tmp"; $fp = fopen($filename, "w"); if (!$fp) { - die("Cannot create $filename\n"); + die("Cannot create $filename\n"); } fclose($fp); diff --git a/ext/standard/tests/file/rename_variation7-win32.phpt b/ext/standard/tests/file/rename_variation7-win32.phpt index fb7c805cbf81..bf879ce7d92d 100644 --- a/ext/standard/tests/file/rename_variation7-win32.phpt +++ b/ext/standard/tests/file/rename_variation7-win32.phpt @@ -12,7 +12,7 @@ $tmp_link = __FILE__.".tmp.link"; $tmp_link2 = __FILE__.".tmp.link2"; if (symlink(__DIR__."/there_is_no_such_file", $tmp_link)) { - rename($tmp_link, $tmp_link2); + rename($tmp_link, $tmp_link2); } clearstatcache(); diff --git a/ext/standard/tests/file/stream_get_line.phpt b/ext/standard/tests/file/stream_get_line.phpt index 9421bd44c1a1..773efd2c8824 100644 --- a/ext/standard/tests/file/stream_get_line.phpt +++ b/ext/standard/tests/file/stream_get_line.phpt @@ -7,7 +7,7 @@ $path = __DIR__ . '/test.html'; file_put_contents($path, "foo
                  bar
                  foo"); $fp = fopen($path, "r"); while ($fp && !feof($fp)) { - echo stream_get_line($fp, 0, "
                  ")."\n"; + echo stream_get_line($fp, 0, "
                  ")."\n"; } fclose($fp); @unlink($path); diff --git a/ext/standard/tests/file/stream_rfc2397_002.phpt b/ext/standard/tests/file/stream_rfc2397_002.phpt index 162f1ea9eaa5..d145456fdb56 100644 --- a/ext/standard/tests/file/stream_rfc2397_002.phpt +++ b/ext/standard/tests/file/stream_rfc2397_002.phpt @@ -6,24 +6,24 @@ allow_url_fopen=1 'data://image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw + 'data://,A%20brief%20note', + 'data://application/vnd-xxx-query,select_vcount,fcol_from_fieldtable/local', + 'data://;base64,Zm9vYmFyIGZvb2Jhcg==', + 'stream_rfc2397_003.gif' => 'data://image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH hhx4dbgYKAAA7', - ); + ); foreach($streams as $original => $stream) { - if (is_string($original)) { - var_dump(file_get_contents(__DIR__ . '/' . $original) == file_get_contents($stream)); - } else { - var_dump(file_get_contents($stream)); - } + if (is_string($original)) { + var_dump(file_get_contents(__DIR__ . '/' . $original) == file_get_contents($stream)); + } else { + var_dump(file_get_contents($stream)); + } } ?> diff --git a/ext/standard/tests/file/stream_rfc2397_004.phpt b/ext/standard/tests/file/stream_rfc2397_004.phpt index 239a12e3bf2a..cb7012f650c1 100644 --- a/ext/standard/tests/file/stream_rfc2397_004.phpt +++ b/ext/standard/tests/file/stream_rfc2397_004.phpt @@ -6,17 +6,17 @@ allow_url_fopen=1 diff --git a/ext/standard/tests/file/stream_rfc2397_005.phpt b/ext/standard/tests/file/stream_rfc2397_005.phpt index fb1cb85a0756..38c0f4b77e40 100644 --- a/ext/standard/tests/file/stream_rfc2397_005.phpt +++ b/ext/standard/tests/file/stream_rfc2397_005.phpt @@ -6,20 +6,20 @@ allow_url_fopen=1 diff --git a/ext/standard/tests/file/stream_rfc2397_006.phpt b/ext/standard/tests/file/stream_rfc2397_006.phpt index 7caf1b666e0f..2c8b8fd7209a 100644 --- a/ext/standard/tests/file/stream_rfc2397_006.phpt +++ b/ext/standard/tests/file/stream_rfc2397_006.phpt @@ -6,19 +6,19 @@ allow_url_fopen=1 getMessage(), "\n"; - } + try { + var_dump(file_get_contents($stream)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } } ?> diff --git a/ext/standard/tests/file/stream_rfc2397_007.phpt b/ext/standard/tests/file/stream_rfc2397_007.phpt index a1558980c98b..56d916215753 100644 --- a/ext/standard/tests/file/stream_rfc2397_007.phpt +++ b/ext/standard/tests/file/stream_rfc2397_007.phpt @@ -6,76 +6,76 @@ allow_url_fopen=1 diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt index 33965b4f266d..3311b0bc7cb1 100644 --- a/ext/standard/tests/file/tempnam_variation3-win32.phpt +++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt @@ -18,76 +18,76 @@ obscure_filename echo "*** Testing tempnam() with obscure prefixes ***\n"; $file_path = __DIR__."/tempnamVar3"; if (!mkdir($file_path)) { - echo "Failed, cannot create temp dir $filepath\n"; - exit(1); + echo "Failed, cannot create temp dir $filepath\n"; + exit(1); } $file_path = realpath($file_path); /* An array of prefixes */ $names_arr = array( - /* Valid args (casting)*/ - -1, - TRUE, - FALSE, - NULL, - "", - " ", - "\0", - /* Invalid args */ - array(), + /* Valid args (casting)*/ + -1, + TRUE, + FALSE, + NULL, + "", + " ", + "\0", + /* Invalid args */ + array(), - /* Valid args*/ - /* prefix with path separator of a non existing directory*/ - "/no/such/file/dir", - "php/php" + /* Valid args*/ + /* prefix with path separator of a non existing directory*/ + "/no/such/file/dir", + "php/php" ); $res_arr = array( - /* Invalid args */ - true, - true, - true, - true, - true, - true, - true, - false, + /* Invalid args */ + true, + true, + true, + true, + true, + true, + true, + false, - /* prefix with path separator of a non existing directory*/ - true, - true + /* prefix with path separator of a non existing directory*/ + true, + true ); for( $i=0; $igetMessage(), "\n"; continue; } - /* creating the files in existing dir */ - if (file_exists($file_name) && !$res_arr[$i]) { - echo "Failed\n"; - } - if ($res_arr[$i]) { - $file_dir = dirname($file_name); - if (realpath($file_dir) == $file_path || realpath($file_dir . "\\") == $file_path) { - echo "OK\n"; - } else { - echo "Failed, not created in the correct directory " . realpath($file_dir) . ' vs ' . $file_path ."\n"; - } + /* creating the files in existing dir */ + if (file_exists($file_name) && !$res_arr[$i]) { + echo "Failed\n"; + } + if ($res_arr[$i]) { + $file_dir = dirname($file_name); + if (realpath($file_dir) == $file_path || realpath($file_dir . "\\") == $file_path) { + echo "OK\n"; + } else { + echo "Failed, not created in the correct directory " . realpath($file_dir) . ' vs ' . $file_path ."\n"; + } - if (!is_writable($file_name)) { - printf("%o\n", fileperms($file_name) ); + if (!is_writable($file_name)) { + printf("%o\n", fileperms($file_name) ); - } - } else { - echo "OK\n"; - } - @unlink($file_name); + } + } else { + echo "OK\n"; + } + @unlink($file_name); } rmdir($file_path); diff --git a/ext/standard/tests/file/tempnam_variation7-win32.phpt b/ext/standard/tests/file/tempnam_variation7-win32.phpt index bfc23a95412b..26ccaef84d2f 100644 --- a/ext/standard/tests/file/tempnam_variation7-win32.phpt +++ b/ext/standard/tests/file/tempnam_variation7-win32.phpt @@ -19,52 +19,52 @@ obscure_filename echo "*** Testing tempnam() with invalid/non-existing directory names ***\n"; /* An array of names, which will be passed as a dir name */ $names_arr = array( - /* Invalid args */ - -1, - TRUE, - FALSE, - NULL, - "", - " ", - "\0", - array(), + /* Invalid args */ + -1, + TRUE, + FALSE, + NULL, + "", + " ", + "\0", + array(), - /* Non-existing dirs */ - "/no/such/file/dir", - "php" + /* Non-existing dirs */ + "/no/such/file/dir", + "php" ); for( $i=0; $igetMessage(), "\n"; continue; } - if( file_exists($file_name) ){ + if( file_exists($file_name) ){ - echo "File name is => "; - print($file_name); - echo "\n"; + echo "File name is => "; + print($file_name); + echo "\n"; - echo "File permissions are => "; - printf("%o", fileperms($file_name) ); - echo "\n"; + echo "File permissions are => "; + printf("%o", fileperms($file_name) ); + echo "\n"; - echo "File created in => "; - $file_dir = dirname($file_name); - if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) { - echo "temp dir\n"; - } else { - echo "unknown location\n"; - } - } else { - echo "-- File is not created --\n"; - } + echo "File created in => "; + $file_dir = dirname($file_name); + if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) { + echo "temp dir\n"; + } else { + echo "unknown location\n"; + } + } else { + echo "-- File is not created --\n"; + } - unlink($file_name); + unlink($file_name); } ?> --EXPECTF-- diff --git a/ext/standard/tests/file/touch_variation5-win32.phpt b/ext/standard/tests/file/touch_variation5-win32.phpt index 02cc4cfb4ede..83d1879634cb 100644 --- a/ext/standard/tests/file/touch_variation5-win32.phpt +++ b/ext/standard/tests/file/touch_variation5-win32.phpt @@ -22,7 +22,7 @@ chdir($cwd); if (!mkdir($cwd . '/' . $workDir)) die("cannot create directory $workDir"); $paths = array( - // relative + // relative $workDir.'/'.$subDirOrFile, './'.$workDir.'/'.$subDirOrFile, $workDir.'/../'.$workDir.'/'.$subDirOrFile, @@ -66,66 +66,66 @@ rmdir($workDir); function test_nonexisting($paths) { - foreach($paths as $path) { - echo "--- testing $path ---\n"; - - if (is_dir($path) || is_file($path)) { - echo "FAILED: $path - exists\n"; - } - else { - $res = touch($path); - if ($res === true) { - // something was created - if (file_exists($path)) { - // something found - if (is_dir($path)) { - echo "FAILED: $path - unexpected directory\n"; - } - else { - echo "PASSED: $path - created\n"; - unlink($path); - } - } - else { - // nothing found - echo "FAILED: $path - touch returned true, nothing there\n"; - } - } - else { - // nothing created - if (file_exists($path)) { - //something found - echo "FAILED: $path - touch returned false, something there\n"; - if (is_dir($path)) { - rmdir($path); - } - else { - unlink($path); - } - } - } - } - } + foreach($paths as $path) { + echo "--- testing $path ---\n"; + + if (is_dir($path) || is_file($path)) { + echo "FAILED: $path - exists\n"; + } + else { + $res = touch($path); + if ($res === true) { + // something was created + if (file_exists($path)) { + // something found + if (is_dir($path)) { + echo "FAILED: $path - unexpected directory\n"; + } + else { + echo "PASSED: $path - created\n"; + unlink($path); + } + } + else { + // nothing found + echo "FAILED: $path - touch returned true, nothing there\n"; + } + } + else { + // nothing created + if (file_exists($path)) { + //something found + echo "FAILED: $path - touch returned false, something there\n"; + if (is_dir($path)) { + rmdir($path); + } + else { + unlink($path); + } + } + } + } + } } function test_existing($paths, $are_dirs) { - foreach($paths as $path) { - if ($are_dirs) { - $res = @mkdir($path); - if ($res == true) { + foreach($paths as $path) { + if ($are_dirs) { + $res = @mkdir($path); + if ($res == true) { test_path($path); rmdir($path); } - } - else { - $h = @fopen($path,"w"); - if ($h !== false) { - fclose($h); + } + else { + $h = @fopen($path,"w"); + if ($h !== false) { + fclose($h); test_path($path); unlink($path); } - } - } + } + } } diff --git a/ext/standard/tests/file/touch_variation5.phpt b/ext/standard/tests/file/touch_variation5.phpt index a42e50980949..67382f3b9935 100644 --- a/ext/standard/tests/file/touch_variation5.phpt +++ b/ext/standard/tests/file/touch_variation5.phpt @@ -22,7 +22,7 @@ mkdir($workDir); $cwd = getcwd(); $paths = array( - // relative + // relative $workDir.'/'.$subDirOrFile, './'.$workDir.'/'.$subDirOrFile, $workDir.'/../'.$workDir.'/'.$subDirOrFile, @@ -66,66 +66,66 @@ rmdir($workDir); function test_nonexisting($paths) { - foreach($paths as $path) { - echo "--- testing $path ---\n"; - - if (is_dir($path) || is_file($path)) { - echo "FAILED: $path - exists\n"; - } - else { - $res = touch($path); - if ($res === true) { - // something was created - if (file_exists($path)) { - // something found - if (is_dir($path)) { - echo "FAILED: $path - unexpected directory\n"; - } - else { - echo "PASSED: $path - created\n"; - unlink($path); - } - } - else { - // nothing found - echo "FAILED: $path - touch returned true, nothing there\n"; - } - } - else { - // nothing created - if (file_exists($path)) { - //something found - echo "FAILED: $path - touch returned false, something there\n"; - if (is_dir($path)) { - rmdir($path); - } - else { - unlink($path); - } - } - } - } - } + foreach($paths as $path) { + echo "--- testing $path ---\n"; + + if (is_dir($path) || is_file($path)) { + echo "FAILED: $path - exists\n"; + } + else { + $res = touch($path); + if ($res === true) { + // something was created + if (file_exists($path)) { + // something found + if (is_dir($path)) { + echo "FAILED: $path - unexpected directory\n"; + } + else { + echo "PASSED: $path - created\n"; + unlink($path); + } + } + else { + // nothing found + echo "FAILED: $path - touch returned true, nothing there\n"; + } + } + else { + // nothing created + if (file_exists($path)) { + //something found + echo "FAILED: $path - touch returned false, something there\n"; + if (is_dir($path)) { + rmdir($path); + } + else { + unlink($path); + } + } + } + } + } } function test_existing($paths, $are_dirs) { - foreach($paths as $path) { - if ($are_dirs) { - $res = @mkdir($path); - if ($res == true) { + foreach($paths as $path) { + if ($are_dirs) { + $res = @mkdir($path); + if ($res == true) { test_path($path); rmdir($path); } - } - else { - $h = @fopen($path,"w"); - if ($h !== false) { - fclose($h); + } + else { + $h = @fopen($path,"w"); + if ($h !== false) { + fclose($h); test_path($path); unlink($path); } - } - } + } + } } diff --git a/ext/standard/tests/file/touch_variation6-win32.phpt b/ext/standard/tests/file/touch_variation6-win32.phpt index d03671fff8fe..b9e9ce7a6cd7 100644 --- a/ext/standard/tests/file/touch_variation6-win32.phpt +++ b/ext/standard/tests/file/touch_variation6-win32.phpt @@ -25,7 +25,7 @@ $cwd = getcwd(); $unixifiedDirOrFile = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDirOrFile, 3); $paths = array( - // relative + // relative $workDir.'\\'.$subDirOrFile, '.\\'.$workDir.'\\'.$subDirOrFile, $workDir.'\\..\\'.$workDir.'\\'.$subDirOrFile, @@ -72,66 +72,66 @@ rmdir($workDir); function test_nonexisting($paths) { - foreach($paths as $path) { - echo "--- testing $path ---\n"; - - if (is_dir($path) || is_file($path)) { - echo "FAILED: $path - exists\n"; - } - else { - $res = touch($path); - if ($res === true) { - // something was created - if (file_exists($path)) { - // something found - if (is_dir($path)) { - echo "FAILED: $path - unexpected directory\n"; - } - else { - echo "PASSED: $path - created\n"; - unlink($path); - } - } - else { - // nothing found - echo "FAILED: $path - touch returned true, nothing there\n"; - } - } - else { - // nothing created - if (file_exists($path)) { - //something found - echo "FAILED: $path - touch returned false, something there\n"; - if (is_dir($path)) { - rmdir($path); - } - else { - unlink($path); - } - } - } - } - } + foreach($paths as $path) { + echo "--- testing $path ---\n"; + + if (is_dir($path) || is_file($path)) { + echo "FAILED: $path - exists\n"; + } + else { + $res = touch($path); + if ($res === true) { + // something was created + if (file_exists($path)) { + // something found + if (is_dir($path)) { + echo "FAILED: $path - unexpected directory\n"; + } + else { + echo "PASSED: $path - created\n"; + unlink($path); + } + } + else { + // nothing found + echo "FAILED: $path - touch returned true, nothing there\n"; + } + } + else { + // nothing created + if (file_exists($path)) { + //something found + echo "FAILED: $path - touch returned false, something there\n"; + if (is_dir($path)) { + rmdir($path); + } + else { + unlink($path); + } + } + } + } + } } function test_existing($paths, $are_dirs) { - foreach($paths as $path) { - if ($are_dirs) { - $res = @mkdir($path); - if ($res == true) { + foreach($paths as $path) { + if ($are_dirs) { + $res = @mkdir($path); + if ($res == true) { test_path($path); rmdir($path); } - } - else { - $h = @fopen($path,"w"); - if ($h !== false) { - fclose($h); + } + else { + $h = @fopen($path,"w"); + if ($h !== false) { + fclose($h); test_path($path); unlink($path); } - } - } + } + } } diff --git a/ext/standard/tests/file/unlink_variation10.phpt b/ext/standard/tests/file/unlink_variation10.phpt index 3a56a73a5ae3..ae48764d9bd7 100644 --- a/ext/standard/tests/file/unlink_variation10.phpt +++ b/ext/standard/tests/file/unlink_variation10.phpt @@ -56,18 +56,18 @@ rmdir($workDir); function test_link($linkedDir, $toLinkTo, $tounlink, $softlink) { if ($softlink == true) { - symlink($toLinkTo, $linkedDir); - $msg = "soft link"; + symlink($toLinkTo, $linkedDir); + $msg = "soft link"; } else { - link($toLinkTo, $linkedDir); - $msg = "hard link"; + link($toLinkTo, $linkedDir); + $msg = "hard link"; } echo "-- unlinking $msg $tounlink --\n"; $res = unlink($tounlink); if ($res === true) { if (is_link($tounlink) === false) { - echo "directory unlinked\n"; + echo "directory unlinked\n"; } else { echo "FAILED: directory not unlinked\n"; diff --git a/ext/standard/tests/file/unlink_variation8-win32.phpt b/ext/standard/tests/file/unlink_variation8-win32.phpt index efd24a22cb24..12b43a340fee 100644 --- a/ext/standard/tests/file/unlink_variation8-win32.phpt +++ b/ext/standard/tests/file/unlink_variation8-win32.phpt @@ -65,7 +65,7 @@ function test_realfile($file, $tounlink) { $res = unlink($tounlink); if ($res === true) { if (file_exists($tounlink) === false) { - echo "file removed\n"; + echo "file removed\n"; } else { echo "FAILED: file not removed\n"; diff --git a/ext/standard/tests/file/unlink_variation8.phpt b/ext/standard/tests/file/unlink_variation8.phpt index ee2540dd6910..41c18f710b69 100644 --- a/ext/standard/tests/file/unlink_variation8.phpt +++ b/ext/standard/tests/file/unlink_variation8.phpt @@ -70,7 +70,7 @@ function test_realfile($file, $tounlink) { $res = unlink($tounlink); if ($res === true) { if (file_exists($tounlink) === false) { - echo "file removed\n"; + echo "file removed\n"; } else { echo "FAILED: file not removed\n"; @@ -83,18 +83,18 @@ function test_realfile($file, $tounlink) { function test_link($linkedfile, $toLinkTo, $tounlink, $softlink) { if ($softlink == true) { - symlink($toLinkTo, $linkedfile); - $msg = "soft link"; + symlink($toLinkTo, $linkedfile); + $msg = "soft link"; } else { - link($toLinkTo, $linkedfile); - $msg = "hard link"; + link($toLinkTo, $linkedfile); + $msg = "hard link"; } echo "-- unlinking $msg $tounlink --\n"; $res = unlink($tounlink); if ($res === true) { if (file_exists($tounlink) === false) { - echo "file unlinked\n"; + echo "file unlinked\n"; } else { echo "FAILED: file not unlinked\n"; diff --git a/ext/standard/tests/file/unlink_variation9-win32.phpt b/ext/standard/tests/file/unlink_variation9-win32.phpt index 3c9d5e4a140e..83a3f5617de9 100644 --- a/ext/standard/tests/file/unlink_variation9-win32.phpt +++ b/ext/standard/tests/file/unlink_variation9-win32.phpt @@ -58,14 +58,14 @@ $files = array( foreach($files as $fileToUnlink) { - $file = $workDir.'/'.$tmpFile; - $tounlink = $fileToUnlink; + $file = $workDir.'/'.$tmpFile; + $tounlink = $fileToUnlink; touch($file); echo "-- removing $tounlink --\n"; $res = unlink($tounlink); if ($res === true) { if (file_exists($tounlink) === false) { - echo "file removed\n"; + echo "file removed\n"; } else { echo "FAILED: file not removed\n"; diff --git a/ext/standard/tests/file/userdirstream.phpt b/ext/standard/tests/file/userdirstream.phpt index a83e899b8300..e2f03dabb7f5 100644 --- a/ext/standard/tests/file/userdirstream.phpt +++ b/ext/standard/tests/file/userdirstream.phpt @@ -3,33 +3,33 @@ Directory Streams --FILE-- idx = 0; + function dir_opendir($path, $options) { + print "Opening\n"; + $this->idx = 0; - return true; - } + return true; + } - function dir_readdir() { - $sample = array('first','second','third','fourth'); + function dir_readdir() { + $sample = array('first','second','third','fourth'); - if ($this->idx >= count($sample)) return false; - else return $sample[$this->idx++]; - } + if ($this->idx >= count($sample)) return false; + else return $sample[$this->idx++]; + } - function dir_rewinddir() { - $this->idx = 0; + function dir_rewinddir() { + $this->idx = 0; - return true; - } + return true; + } - function dir_closedir() { - print "Closing up!\n"; + function dir_closedir() { + print "Closing up!\n"; - return true; - } + return true; + } } stream_wrapper_register('test', 'test'); diff --git a/ext/standard/tests/file/userstreams.phpt b/ext/standard/tests/file/userstreams.phpt index 790b74a0c3d9..5b753e02e4f3 100644 --- a/ext/standard/tests/file/userstreams.phpt +++ b/ext/standard/tests/file/userstreams.phpt @@ -22,7 +22,7 @@ call me what you will Free to speak my mind anywhere and Ill redefine anywhere Anywhere I roam - Where I lay my head is home + Where I lay my head is home ...and the earth becomes my throne I adapt to the unknown under wandering stars Ive grown @@ -38,12 +38,12 @@ call me what you will Free to speak my mind anywhere and Ill never mind anywhere Anywhere I roam - Where I lay my head is home + Where I lay my head is home But Ill take my time anywhere Free to speak my mind anywhere and Ill take my find anywhere Anywhere I roam - Where I lay my head is home + Where I lay my head is home carved upon my stone my body lie but still I roam Wherever I may roam. @@ -57,10 +57,10 @@ EOD; * to seek around... */ $DATA = ""; for ($i = 0; $i < 30; $i++) { - if ($i % 2 == 0) - $DATA .= str_rot13($lyrics); - else - $DATA .= $lyrics; + if ($i % 2 == 0) + $DATA .= str_rot13($lyrics); + else + $DATA .= $lyrics; } /* store the data in a regular file so that we can compare @@ -70,10 +70,10 @@ fwrite($tf, $DATA); $n = ftell($tf); rewind($tf) or die("failed to rewind tmp file!"); if (ftell($tf) != 0) - die("tmpfile is not at start!"); + die("tmpfile is not at start!"); $DATALEN = strlen($DATA); if ($n != $DATALEN) - die("tmpfile stored $n bytes; should be $DATALEN!"); + die("tmpfile stored $n bytes; should be $DATALEN!"); class uselessstream { @@ -81,150 +81,150 @@ class uselessstream class mystream { - public $path; - public $mode; - public $options; - - public $position; - public $varname; - - function stream_open($path, $mode, $options, &$opened_path) - { - $this->path = $path; - $this->mode = $mode; - $this->options = $options; - - $split = parse_url($path); - $this->varname = $split["host"]; - - if (strchr($mode, 'a')) - $this->position = strlen($GLOBALS[$this->varname]); - else - $this->position = 0; - - return true; - } - - function stream_read($count) - { - $ret = substr($GLOBALS[$this->varname], $this->position, $count); - $this->position += strlen($ret); - return $ret; - } - - function stream_tell() - { - return $this->position; - } - - function stream_eof() - { - return $this->position >= strlen($GLOBALS[$this->varname]); - } - - function stream_seek($offset, $whence) - { - switch($whence) { - case SEEK_SET: - if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; - } else { - return false; - } - break; - case SEEK_CUR: - if ($offset >= 0) { - $this->position += $offset; - return true; - } else { - return false; - } - break; - case SEEK_END: - if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; - } else { - return false; - } - break; - default: - return false; - } - } + public $path; + public $mode; + public $options; + + public $position; + public $varname; + + function stream_open($path, $mode, $options, &$opened_path) + { + $this->path = $path; + $this->mode = $mode; + $this->options = $options; + + $split = parse_url($path); + $this->varname = $split["host"]; + + if (strchr($mode, 'a')) + $this->position = strlen($GLOBALS[$this->varname]); + else + $this->position = 0; + + return true; + } + + function stream_read($count) + { + $ret = substr($GLOBALS[$this->varname], $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + function stream_tell() + { + return $this->position; + } + + function stream_eof() + { + return $this->position >= strlen($GLOBALS[$this->varname]); + } + + function stream_seek($offset, $whence) + { + switch($whence) { + case SEEK_SET: + if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { + $this->position = $offset; + return true; + } else { + return false; + } + break; + case SEEK_CUR: + if ($offset >= 0) { + $this->position += $offset; + return true; + } else { + return false; + } + break; + case SEEK_END: + if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; + } else { + return false; + } + break; + default: + return false; + } + } } if (@stream_wrapper_register("bogus", "class_not_exist")) { - die("Registered a non-existent class!!!???"); + die("Registered a non-existent class!!!???"); } echo "Not Registered\n"; if (!stream_wrapper_register("test", "mystream")) { - die("test wrapper registration failed"); + die("test wrapper registration failed"); } echo "Registered\n"; if (!stream_wrapper_register("bogon", "uselessstream")) { - die("bogon wrapper registration failed"); + die("bogon wrapper registration failed"); } echo "Registered\n"; $b = @fopen("bogon://url", "rb"); if (is_resource($b)) { - die("Opened a bogon??"); + die("Opened a bogon??"); } $fp = fopen("test://DATA", "rb"); if (!$fp || !is_resource($fp)) { - die("Failed to open resource"); + die("Failed to open resource"); } /* some default seeks that will cause buffer/cache misses */ $seeks = array( - array(SEEK_SET, 0, 0), - array(SEEK_CUR, 8450, 8450), - array(SEEK_CUR, -7904, 546), - array(SEEK_CUR, 12456, 13002), - - /* end up at BOF so that randomly generated seek offsets - * below will know where they are supposed to be */ - array(SEEK_SET, 0, 0) + array(SEEK_SET, 0, 0), + array(SEEK_CUR, 8450, 8450), + array(SEEK_CUR, -7904, 546), + array(SEEK_CUR, 12456, 13002), + + /* end up at BOF so that randomly generated seek offsets + * below will know where they are supposed to be */ + array(SEEK_SET, 0, 0) ); $whence_map = array( - SEEK_CUR, - SEEK_SET, - SEEK_END + SEEK_CUR, + SEEK_SET, + SEEK_END ); $whence_names = array( - SEEK_CUR => "SEEK_CUR", - SEEK_SET => "SEEK_SET", - SEEK_END => "SEEK_END" - ); + SEEK_CUR => "SEEK_CUR", + SEEK_SET => "SEEK_SET", + SEEK_END => "SEEK_END" + ); /* generate some random seek offsets */ $position = 0; for ($i = 0; $i < 256; $i++) { - $whence = $whence_map[array_rand($whence_map, 1)]; - switch($whence) { - case SEEK_SET: - $offset = rand(0, $DATALEN - 1); - $position = $offset; - break; - case SEEK_END: - $offset = -rand(0, $DATALEN - 1); - $position = $DATALEN + $offset; - break; - case SEEK_CUR: - $offset = rand(0, $DATALEN - 1); - $offset -= $position; - $position += $offset; - break; - } - - $seeks[] = array($whence, $offset, $position); + $whence = $whence_map[array_rand($whence_map, 1)]; + switch($whence) { + case SEEK_SET: + $offset = rand(0, $DATALEN - 1); + $position = $offset; + break; + case SEEK_END: + $offset = -rand(0, $DATALEN - 1); + $position = $DATALEN + $offset; + break; + case SEEK_CUR: + $offset = rand(0, $DATALEN - 1); + $offset -= $position; + $position += $offset; + break; + } + + $seeks[] = array($whence, $offset, $position); } /* we compare the results of fgets using differing line lengths to @@ -234,50 +234,50 @@ $fail_count = 0; ob_start(); foreach($line_lengths as $line_length) { - /* now compare the real stream with the user stream */ - $j = 0; - rewind($tf); - rewind($fp); - foreach($seeks as $seekdata) { - list($whence, $offset, $position) = $seekdata; - - $rpb = ftell($tf); - $rr = (int)fseek($tf, $offset, $whence); - $rpa = ftell($tf); - $rline = fgets($tf, $line_length); - (int)fseek($tf, - strlen($rline), SEEK_CUR); - - $upb = ftell($fp); - $ur = (int)fseek($fp, $offset, $whence); - $upa = ftell($fp); - $uline = fgets($fp, $line_length); - (int)fseek($fp, - strlen($uline), SEEK_CUR); - - printf("\n--[%d] whence=%s offset=%d line_length=%d position_should_be=%d --\n", - $j, $whence_names[$whence], $offset, $line_length, $position); - printf("REAL: pos=(%d,%d,%d) ret=%d line[%d]=`%s'\n", $rpb, $rpa, ftell($tf), $rr, strlen($rline), $rline); - printf("USER: pos=(%d,%d,%d) ret=%d line[%d]=`%s'\n", $upb, $upa, ftell($fp), $ur, strlen($uline), $uline); - - if ($rr != $ur || $rline != $uline || $rpa != $position || $upa != $position) { - $fail_count++; - echo "###################################### FAIL!\n"; - $dat = stream_get_meta_data($fp); - var_dump($dat); - break; - } - - $j++; - } - if ($fail_count) - break; + /* now compare the real stream with the user stream */ + $j = 0; + rewind($tf); + rewind($fp); + foreach($seeks as $seekdata) { + list($whence, $offset, $position) = $seekdata; + + $rpb = ftell($tf); + $rr = (int)fseek($tf, $offset, $whence); + $rpa = ftell($tf); + $rline = fgets($tf, $line_length); + (int)fseek($tf, - strlen($rline), SEEK_CUR); + + $upb = ftell($fp); + $ur = (int)fseek($fp, $offset, $whence); + $upa = ftell($fp); + $uline = fgets($fp, $line_length); + (int)fseek($fp, - strlen($uline), SEEK_CUR); + + printf("\n--[%d] whence=%s offset=%d line_length=%d position_should_be=%d --\n", + $j, $whence_names[$whence], $offset, $line_length, $position); + printf("REAL: pos=(%d,%d,%d) ret=%d line[%d]=`%s'\n", $rpb, $rpa, ftell($tf), $rr, strlen($rline), $rline); + printf("USER: pos=(%d,%d,%d) ret=%d line[%d]=`%s'\n", $upb, $upa, ftell($fp), $ur, strlen($uline), $uline); + + if ($rr != $ur || $rline != $uline || $rpa != $position || $upa != $position) { + $fail_count++; + echo "###################################### FAIL!\n"; + $dat = stream_get_meta_data($fp); + var_dump($dat); + break; + } + + $j++; + } + if ($fail_count) + break; } if ($fail_count == 0) { - ob_end_clean(); - echo "SEEK: OK\n"; + ob_end_clean(); + echo "SEEK: OK\n"; } else { - echo "SEEK: FAIL\n"; - ob_end_flush(); + echo "SEEK: FAIL\n"; + ob_end_flush(); } $fail_count = 0; @@ -286,23 +286,23 @@ fseek($fp, $DATALEN / 2, SEEK_SET); fseek($tf, $DATALEN / 2, SEEK_SET); if (ftell($fp) != ftell($tf)) { - echo "SEEK: positions do not match!\n"; + echo "SEEK: positions do not match!\n"; } $n = 0; while(!feof($fp)) { - $uline = fgets($fp, 1024); - $rline = fgets($tf, 1024); - - if ($uline != $rline) { - echo "FGETS: FAIL\niter=$n user=$uline [pos=" . ftell($fp) . "]\nreal=$rline [pos=" . ftell($tf) . "]\n"; - $fail_count++; - break; - } + $uline = fgets($fp, 1024); + $rline = fgets($tf, 1024); + + if ($uline != $rline) { + echo "FGETS: FAIL\niter=$n user=$uline [pos=" . ftell($fp) . "]\nreal=$rline [pos=" . ftell($tf) . "]\n"; + $fail_count++; + break; + } } if ($fail_count == 0) { - echo "FGETS: OK\n"; + echo "FGETS: OK\n"; } /* One final test to see if the position is respected when opened for append */ diff --git a/ext/standard/tests/file/userstreams_002.phpt b/ext/standard/tests/file/userstreams_002.phpt index b625e46f2603..95e085947ff3 100644 --- a/ext/standard/tests/file/userstreams_002.phpt +++ b/ext/standard/tests/file/userstreams_002.phpt @@ -3,30 +3,30 @@ User-space streams: stream_cast() --FILE-- return_value; - } + function stream_cast($castas) { + return $this->return_value; + } } function test($name, $fd, $return_value) { - echo "\n------ $name: -------\n"; - $data = stream_get_meta_data($fd); - $data['wrapper_data']->return_value = $return_value; - $r = array($fd); - $w = $e = null; - try { - var_dump(stream_select($r, $w, $e, 0) !== false); - } catch (TypeError|ValueError $e) { - echo $e->getMessage(), "\n"; - } + echo "\n------ $name: -------\n"; + $data = stream_get_meta_data($fd); + $data['wrapper_data']->return_value = $return_value; + $r = array($fd); + $w = $e = null; + try { + var_dump(stream_select($r, $w, $e, 0) !== false); + } catch (TypeError|ValueError $e) { + echo $e->getMessage(), "\n"; + } } var_dump(stream_wrapper_register('test', 'test_wrapper')); diff --git a/ext/standard/tests/file/userstreams_003.phpt b/ext/standard/tests/file/userstreams_003.phpt index 9ee71f2666ab..686963adf763 100644 --- a/ext/standard/tests/file/userstreams_003.phpt +++ b/ext/standard/tests/file/userstreams_003.phpt @@ -3,37 +3,37 @@ User-space streams: stream_set_option() --FILE-- expected_option . ":\n"; - var_dump($option === $this->expected_option); - echo "\$value === $value === " . $this->expected_value. ":\n"; - var_dump($value === $this->expected_value); - return $this->return_value; - } + function stream_set_option($option, $value, $ptrparam) { + echo "value:\n"; + var_dump($value); + echo "ptrparam:\n"; + var_dump($ptrparam); + echo "\$option === $option === " . $this->expected_option . ":\n"; + var_dump($option === $this->expected_option); + echo "\$value === $value === " . $this->expected_value. ":\n"; + var_dump($value === $this->expected_value); + return $this->return_value; + } } function test($name, $fd, $return_value, $func, $args, $expected_option, $expected_value) { - echo "\n------ $name: -------\n"; - $data = stream_get_meta_data($fd); - $data['wrapper_data']->return_value = $return_value; - $data['wrapper_data']->expected_option = $expected_option; - $data['wrapper_data']->expected_value = $expected_value; - var_dump(call_user_func_array($func, $args)); + echo "\n------ $name: -------\n"; + $data = stream_get_meta_data($fd); + $data['wrapper_data']->return_value = $return_value; + $data['wrapper_data']->expected_option = $expected_option; + $data['wrapper_data']->expected_value = $expected_value; + var_dump(call_user_func_array($func, $args)); } var_dump(stream_wrapper_register('test', 'test_wrapper')); diff --git a/ext/standard/tests/file/userstreams_004.phpt b/ext/standard/tests/file/userstreams_004.phpt index da9f148b5d5d..df1a9f3604c2 100644 --- a/ext/standard/tests/file/userstreams_004.phpt +++ b/ext/standard/tests/file/userstreams_004.phpt @@ -3,24 +3,24 @@ User-space streams: stream_lock() --FILE-- mode = $mode; - } + function stream_lock($mode) { + $this->mode = $mode; + } } function test($name, $fd, $mode) { - echo "------ $name: -------\n"; - flock($fd, $mode); - $data = stream_get_meta_data($fd); - var_dump($data['wrapper_data']->mode === $mode); + echo "------ $name: -------\n"; + flock($fd, $mode); + $data = stream_get_meta_data($fd); + var_dump($data['wrapper_data']->mode === $mode); } var_dump(stream_wrapper_register('test', 'test_wrapper')); @@ -32,8 +32,8 @@ $fd2 = fopen("test2://foo","r"); test("stream_lock not implemented", $fd2, LOCK_EX); foreach(array("LOCK_SH","LOCK_EX","LOCK_UN") as $mode) { - test("fclock($mode)", $fd, constant($mode)); - test("fclock($mode|LOCK_NB)", $fd, constant($mode)|LOCK_NB); + test("fclock($mode)", $fd, constant($mode)); + test("fclock($mode|LOCK_NB)", $fd, constant($mode)|LOCK_NB); } ?> diff --git a/ext/standard/tests/file/userstreams_005.phpt b/ext/standard/tests/file/userstreams_005.phpt index 0c3113c19763..5650df2aa01a 100644 --- a/ext/standard/tests/file/userstreams_005.phpt +++ b/ext/standard/tests/file/userstreams_005.phpt @@ -3,29 +3,29 @@ User-space streams: stream_truncate() --FILE-- 1, 'ino'=>2, 'mode'=>0644, 'nlink'=>3, 'uid'=>100, 'gid'=>1000, 'rdev'=>-1, 'size'=>31337, diff --git a/ext/standard/tests/file/windows_acls/bug44859.phpt b/ext/standard/tests/file/windows_acls/bug44859.phpt index 679734b3792a..513c3a6af8a2 100644 --- a/ext/standard/tests/file/windows_acls/bug44859.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859.phpt @@ -12,42 +12,42 @@ include_once __DIR__ . '/common.inc'; fix_acls(); $iteration = array( - PHPT_ACL_READ => false, - PHPT_ACL_NONE => false, - PHPT_ACL_WRITE => true, - PHPT_ACL_WRITE|PHPT_ACL_READ => true, + PHPT_ACL_READ => false, + PHPT_ACL_NONE => false, + PHPT_ACL_WRITE => true, + PHPT_ACL_WRITE|PHPT_ACL_READ => true, ); echo "Testing file:\n"; $i = 1; $path = $uniqueBasePath . '_file.txt'; foreach ($iteration as $perms => $exp) { - create_file($path, $perms); - clearstatcache(true, $path); - echo 'Iteration #' . $i++ . ': '; - if (is_writable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_writable($path), $exp); - echo "failed.\n"; - } - delete_file($path); + create_file($path, $perms); + clearstatcache(true, $path); + echo 'Iteration #' . $i++ . ': '; + if (is_writable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_writable($path), $exp); + echo "failed.\n"; + } + delete_file($path); } echo "Testing directory:\n"; $path = $uniqueBasePath . '_dir'; $i = 1; foreach ($iteration as $perms => $exp) { - create_dir($path, $perms); - clearstatcache(true, $path); - echo 'Iteration #' . $i++ . ': '; - if (is_writable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_writable($path), $exp); - echo "failed.\n"; - } - delete_dir($path); + create_dir($path, $perms); + clearstatcache(true, $path); + echo 'Iteration #' . $i++ . ': '; + if (is_writable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_writable($path), $exp); + echo "failed.\n"; + } + delete_dir($path); } ?> diff --git a/ext/standard/tests/file/windows_acls/bug44859_2.phpt b/ext/standard/tests/file/windows_acls/bug44859_2.phpt index b88d07f82007..4b5fd9e1399e 100644 --- a/ext/standard/tests/file/windows_acls/bug44859_2.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859_2.phpt @@ -12,42 +12,42 @@ include_once __DIR__ . '/common.inc'; fix_acls(); $iteration = array( - PHPT_ACL_READ => true, - PHPT_ACL_NONE => false, - PHPT_ACL_WRITE => false, - PHPT_ACL_WRITE|PHPT_ACL_READ => true, + PHPT_ACL_READ => true, + PHPT_ACL_NONE => false, + PHPT_ACL_WRITE => false, + PHPT_ACL_WRITE|PHPT_ACL_READ => true, ); echo "Testing file:\n"; $i = 1; $path = $uniqueBasePath . '_file.txt'; foreach ($iteration as $perms => $exp) { - create_file($path, $perms); - clearstatcache(true, $path); - echo 'Iteration #' . $i++ . ': '; - if (is_readable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_readable($path), $exp); - echo "failed.\n"; - } - delete_file($path); + create_file($path, $perms); + clearstatcache(true, $path); + echo 'Iteration #' . $i++ . ': '; + if (is_readable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_readable($path), $exp); + echo "failed.\n"; + } + delete_file($path); } echo "Testing directory:\n"; $path = $uniqueBasePath . '_dir'; $i = 1; foreach ($iteration as $perms => $exp) { - create_dir($path, $perms); - clearstatcache(true, $path); - echo 'Iteration #' . $i++ . ': '; - if (is_readable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_readable($path), $exp); - echo "failed.\n"; - } - delete_dir($path); + create_dir($path, $perms); + clearstatcache(true, $path); + echo 'Iteration #' . $i++ . ': '; + if (is_readable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_readable($path), $exp); + echo "failed.\n"; + } + delete_dir($path); } ?> diff --git a/ext/standard/tests/file/windows_acls/bug44859_3.phpt b/ext/standard/tests/file/windows_acls/bug44859_3.phpt index 35db1f29be61..465c7557ac05 100644 --- a/ext/standard/tests/file/windows_acls/bug44859_3.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859_3.phpt @@ -11,23 +11,23 @@ include_once __DIR__ . '/common.inc'; fix_acls(); $iteration = array( - 'tiny.exe' => true, - //'tiny.bat' => true, To be fixed in _access - __FILE__ => false + 'tiny.exe' => true, + //'tiny.bat' => true, To be fixed in _access + __FILE__ => false ); $i = 1; $path = __DIR__; foreach ($iteration as $file => $exp) { - $path = __DIR__ . '/' . $file; - echo 'Iteration #' . $i++ . ': '; - if (is_executable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_executable($path), $exp); - echo "failed.\n"; - } + $path = __DIR__ . '/' . $file; + echo 'Iteration #' . $i++ . ': '; + if (is_executable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_executable($path), $exp); + echo "failed.\n"; + } } diff --git a/ext/standard/tests/file/windows_acls/bug44859_4.phpt b/ext/standard/tests/file/windows_acls/bug44859_4.phpt index e0fbe11f4b25..483438bcf641 100644 --- a/ext/standard/tests/file/windows_acls/bug44859_4.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859_4.phpt @@ -14,42 +14,42 @@ include_once __DIR__ . '/common.inc'; fix_acls(); $iteration = array( - PHPT_ACL_READ => true, - PHPT_ACL_NONE => false, - PHPT_ACL_WRITE => false, - PHPT_ACL_WRITE|PHPT_ACL_READ => true, + PHPT_ACL_READ => true, + PHPT_ACL_NONE => false, + PHPT_ACL_WRITE => false, + PHPT_ACL_WRITE|PHPT_ACL_READ => true, ); echo "Testing file with relative path:\n"; $i = 1; $path = './' . $uniqueBaseName . '_file.txt'; foreach ($iteration as $perms => $exp) { - create_file($path, $perms); - clearstatcache(true, $path); - echo 'Iteration #' . $i++ . ': '; - if (is_readable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_readable($path), $exp); - echo "failed.\n"; - } - delete_file($path); + create_file($path, $perms); + clearstatcache(true, $path); + echo 'Iteration #' . $i++ . ': '; + if (is_readable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_readable($path), $exp); + echo "failed.\n"; + } + delete_file($path); } echo "Testing directory with relative path:\n"; $path = $uniqueBaseName . '_dir'; $i = 1; foreach ($iteration as $perms => $exp) { - create_dir($path, $perms); - clearstatcache(true, $path); - echo 'Iteration #' . $i++ . ': '; - if (is_readable($path) == $exp) { - echo "passed.\n"; - } else { - var_dump(is_readable($path), $exp); - echo "failed.\n"; - } - delete_dir($path); + create_dir($path, $perms); + clearstatcache(true, $path); + echo 'Iteration #' . $i++ . ': '; + if (is_readable($path) == $exp) { + echo "passed.\n"; + } else { + var_dump(is_readable($path), $exp); + echo "failed.\n"; + } + delete_dir($path); } ?> diff --git a/ext/standard/tests/file/windows_acls/common.inc b/ext/standard/tests/file/windows_acls/common.inc index 5d4b402840fb..b3490ebb432b 100644 --- a/ext/standard/tests/file/windows_acls/common.inc +++ b/ext/standard/tests/file/windows_acls/common.inc @@ -10,161 +10,161 @@ define('PHPT_ACL_GRANT', 1); define('PHPT_ACL_DENY', 2); function skipif() { - if(substr(PHP_OS, 0, 3) != 'WIN' ) { - die('skip windows only test'); - } - if(stripos(php_uname(), 'XP') !== FALSE) { - die('skip windows 2003 or newer only test'); - } + if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); + } + if(stripos(php_uname(), 'XP') !== FALSE) { + die('skip windows 2003 or newer only test'); + } } function get_username(){ - $user = getenv('USERNAME'); + $user = getenv('USERNAME'); - if (!$user) { - $user = get_current_user(); - } + if (!$user) { + $user = get_current_user(); + } - if (!$user) { - $user = exec('echo %USERNAME%'); - } + if (!$user) { + $user = exec('echo %USERNAME%'); + } - return $user; + return $user; } function get_domainname() { - $domain = getenv('USERDOMAIN'); + $domain = getenv('USERDOMAIN'); - return $domain; + return $domain; } function get_icacls() { - $sysroot = exec('echo %SYSTEMROOT%'); + $sysroot = exec('echo %SYSTEMROOT%'); - return "$sysroot\\System32\\icacls.exe"; + return "$sysroot\\System32\\icacls.exe"; } function fix_acls() { - $user = get_username(); - /* Current user needs to be owner of the test files. As well - all the other users having acls on the files must loose them. - The following fixes this just partially, as dynamically reading - all the users having acls on a file could be sophisticated. */ - exec(get_icacls() . ' ' . __DIR__ . ' /setowner ' . escapeshellarg($user) . ' /T /L /Q /C > nul 2>&1'); - exec(get_icacls() . ' ' . __DIR__ . ' /remove:g Administrators /T /L /Q /C > nul 2>&1'); + $user = get_username(); + /* Current user needs to be owner of the test files. As well + all the other users having acls on the files must loose them. + The following fixes this just partially, as dynamically reading + all the users having acls on a file could be sophisticated. */ + exec(get_icacls() . ' ' . __DIR__ . ' /setowner ' . escapeshellarg($user) . ' /T /L /Q /C > nul 2>&1'); + exec(get_icacls() . ' ' . __DIR__ . ' /remove:g Administrators /T /L /Q /C > nul 2>&1'); } function icacls_set($path, $mode, $perm) { - $icacls = get_icacls(); - $user = get_username(); - $path_escaped = '"' . $path . '"'; - $perm_entry = array(); - - if ($perm & PHPT_ACL_READ) $perm_entry[] = 'R'; - if ($perm & PHPT_ACL_WRITE) $perm_entry[] = 'W'; - if ($perm & PHPT_ACL_EXEC) $perm_entry[] = 'RX'; - if ($perm & PHPT_ACL_FULL) $perm_entry[] = 'F'; - - // Deny all - $cmd = $icacls . ' ' . $path_escaped . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)'; - exec($cmd); - - if ($perm & PHPT_ACL_NONE) { - /* - This is required to remove all the previously denied - permission for the USER. Just granting permission doesn't - remove the previously denied permission. - */ - $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; - exec($cmd); - $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; - exec($cmd); - return; - } - - if ($mode == PHPT_ACL_GRANT) { - $mode = 'grant'; - } else { - $mode = 'deny'; - } - - - // Deny all - $cmd = $icacls . ' ' . $path_escaped . ' /deny ' . $user . ':(F,M,R,RX,W)'; - exec($cmd); - - /* - This is required to remove all the previously denied - permission for the USER. Just granting permission doesn't - remove the previously denied permission. - */ - $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; - exec($cmd); - $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; - exec($cmd); - - - /* - Required to set no permission and check that is_readable() - returns false. If the $perm_entry contains 'N' skip this step. - This will make the file/dir with NO aceess. - */ - if (!in_array('N', $perm_entry)) { - /* - This is required to remove all the previously denied - permission for the USER. Just granting permission doesn't - remove the previously denied permission. - */ - $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; - exec($cmd); - $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; - exec($cmd); - - $cmd = $icacls . ' ' . $path_escaped . ' /' . $mode . ' ' . $user; - $cmd .= ':' . '(' . implode(',', $perm_entry) . ')'; - exec($cmd); - } + $icacls = get_icacls(); + $user = get_username(); + $path_escaped = '"' . $path . '"'; + $perm_entry = array(); + + if ($perm & PHPT_ACL_READ) $perm_entry[] = 'R'; + if ($perm & PHPT_ACL_WRITE) $perm_entry[] = 'W'; + if ($perm & PHPT_ACL_EXEC) $perm_entry[] = 'RX'; + if ($perm & PHPT_ACL_FULL) $perm_entry[] = 'F'; + + // Deny all + $cmd = $icacls . ' ' . $path_escaped . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)'; + exec($cmd); + + if ($perm & PHPT_ACL_NONE) { + /* + This is required to remove all the previously denied + permission for the USER. Just granting permission doesn't + remove the previously denied permission. + */ + $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; + exec($cmd); + $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; + exec($cmd); + return; + } + + if ($mode == PHPT_ACL_GRANT) { + $mode = 'grant'; + } else { + $mode = 'deny'; + } + + + // Deny all + $cmd = $icacls . ' ' . $path_escaped . ' /deny ' . $user . ':(F,M,R,RX,W)'; + exec($cmd); + + /* + This is required to remove all the previously denied + permission for the USER. Just granting permission doesn't + remove the previously denied permission. + */ + $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; + exec($cmd); + $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; + exec($cmd); + + + /* + Required to set no permission and check that is_readable() + returns false. If the $perm_entry contains 'N' skip this step. + This will make the file/dir with NO aceess. + */ + if (!in_array('N', $perm_entry)) { + /* + This is required to remove all the previously denied + permission for the USER. Just granting permission doesn't + remove the previously denied permission. + */ + $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; + exec($cmd); + $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; + exec($cmd); + + $cmd = $icacls . ' ' . $path_escaped . ' /' . $mode . ' ' . $user; + $cmd .= ':' . '(' . implode(',', $perm_entry) . ')'; + exec($cmd); + } } function create_dir($name, $perms) { - if (empty($name)) { - echo "create_dir: Empty name is not allowed\n"; - return; - } - - mkdir($name); - $dst = realpath($name); - icacls_set($name, PHPT_ACL_GRANT, $perms); + if (empty($name)) { + echo "create_dir: Empty name is not allowed\n"; + return; + } + + mkdir($name); + $dst = realpath($name); + icacls_set($name, PHPT_ACL_GRANT, $perms); } function create_file($name, $perms) { - if (empty($name)) { - echo "create_file: Empty name is not allowed\n"; - return; - } + if (empty($name)) { + echo "create_file: Empty name is not allowed\n"; + return; + } - touch($name); - icacls_set($name, PHPT_ACL_GRANT, $perms); + touch($name); + icacls_set($name, PHPT_ACL_GRANT, $perms); } function delete_file($path) { - icacls_set($path, PHPT_ACL_GRANT, PHPT_ACL_FULL); - if (is_file($path)) { - unlink($path); - } else { - echo "delete_file: '$path' is not a file\n"; - return; - } + icacls_set($path, PHPT_ACL_GRANT, PHPT_ACL_FULL); + if (is_file($path)) { + unlink($path); + } else { + echo "delete_file: '$path' is not a file\n"; + return; + } } function delete_dir($path) { - if (is_dir($path)) { - icacls_set($path, PHPT_ACL_GRANT, PHPT_ACL_FULL); - rmdir($path); - } else { - echo "delete_dir: '$path' is not a directory\n"; - return; - } + if (is_dir($path)) { + icacls_set($path, PHPT_ACL_GRANT, PHPT_ACL_FULL); + rmdir($path); + } else { + echo "delete_dir: '$path' is not a directory\n"; + return; + } } diff --git a/ext/standard/tests/file/windows_links/common.inc b/ext/standard/tests/file/windows_links/common.inc index 505368b8b029..4d4409e9d867 100644 --- a/ext/standard/tests/file/windows_links/common.inc +++ b/ext/standard/tests/file/windows_links/common.inc @@ -1,23 +1,23 @@ diff --git a/ext/standard/tests/file/windows_links/readlink_compat.phpt b/ext/standard/tests/file/windows_links/readlink_compat.phpt index e1194738951c..b4ac07682ea3 100644 --- a/ext/standard/tests/file/windows_links/readlink_compat.phpt +++ b/ext/standard/tests/file/windows_links/readlink_compat.phpt @@ -20,7 +20,7 @@ mkdir($tmpDir); // mounted volume $volume = trim(exec('mountvol C: /L')); exec(sprintf('mountvol "%s" %s', $tmpDir, $volume)); -var_dump(readlink($tmpDir)); +var_dump(readlink($tmpDir)); exec(sprintf('mountvol "%s" /D', $tmpDir)); mkdir($tmpDir . '\\test\\directory', 0777, true); @@ -35,7 +35,7 @@ rmdir($link); // junction to a directory $link = $tmpDir . '\\test\\directory_junction'; $target = $tmpDir . '\\test\\directory'; -exec(sprintf('mklink /J "%s" "%s"', $link, $target)); +exec(sprintf('mklink /J "%s" "%s"', $link, $target)); var_dump(readlink($link)); rmdir($link); @@ -56,7 +56,7 @@ fclose($fh); // symlink to a file (absolute and relative) $link = $tmpDir . '\\test\\file_symlink'; -exec(sprintf('mklink "%s" "%s"', $link, $filename)); +exec(sprintf('mklink "%s" "%s"', $link, $filename)); var_dump(readlink($link)); unlink($link); exec(sprintf('mklink "%s" directory\\a.php', $link)); @@ -64,7 +64,7 @@ var_dump(readlink($link)); unlink($link); // unexpected behaviour -echo "\n*** Unexpected behaviour when not a reparse point\n"; +echo "\n*** Unexpected behaviour when not a reparse point\n"; var_dump(readlink($tmpDir . '\\test\\directory')); var_dump(readlink($filename)); diff --git a/ext/standard/tests/file/windows_mb_path/bug54028.phpt b/ext/standard/tests/file/windows_mb_path/bug54028.phpt index 9c11be61f4da..6f3e6dab5141 100644 --- a/ext/standard/tests/file/windows_mb_path/bug54028.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug54028.phpt @@ -22,23 +22,23 @@ $dirs = array("a", "ソ", "ゾ", "şŞıİğĞ", "多国語", "王", "汚れ㦠mkdir($prefix); foreach ($dirs as $d) { - mkdir($prefix . $d); + mkdir($prefix . $d); } $directory = dir($prefix); while (false !== ($content = $directory->read())) { - if ("." == $content || ".." == $content) continue; + if ("." == $content || ".." == $content) continue; printf("Returned (%s)\n", $content); printf("Encoding: %s\n", mb_detect_encoding($content)); if ($content != get_basename_with_cp($prefix . $content, 65001, false)) { - echo "Verification failed!\n"; - } - echo "\n"; + echo "Verification failed!\n"; + } + echo "\n"; } foreach ($dirs as $d) { - rmdir($prefix . $d); + rmdir($prefix . $d); } rmdir($prefix); diff --git a/ext/standard/tests/file/windows_mb_path/bug54028_2.phpt b/ext/standard/tests/file/windows_mb_path/bug54028_2.phpt index 87e7c162b0fc..d6ef5925a8d3 100644 --- a/ext/standard/tests/file/windows_mb_path/bug54028_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug54028_2.phpt @@ -22,20 +22,20 @@ $dirs = array("a", "ソ", "ゾ", "şŞıİğĞ", "多国語", "王", "汚れ㦠mkdir($prefix); foreach ($dirs as $d) { - mkdir($prefix . $d); + mkdir($prefix . $d); } $old_cwd = getcwd(); foreach ($dirs as $d) { - $now = $prefix . $d; - var_dump(chdir($now)); - var_dump($dn = realpath(".")); - var_dump($d == get_basename_with_cp($dn, 65001, false)); + $now = $prefix . $d; + var_dump(chdir($now)); + var_dump($dn = realpath(".")); + var_dump($d == get_basename_with_cp($dn, 65001, false)); } chdir($old_cwd); foreach ($dirs as $d) { - rmdir($prefix . $d); + rmdir($prefix . $d); } rmdir($prefix); diff --git a/ext/standard/tests/file/windows_mb_path/bug54977.phpt b/ext/standard/tests/file/windows_mb_path/bug54977.phpt index b8749576ae5e..5edead63edb0 100644 --- a/ext/standard/tests/file/windows_mb_path/bug54977.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug54977.phpt @@ -22,19 +22,19 @@ $paths = array("多国語", "王", "æ±šã‚Œã¦æŽ˜ã‚‹"); mkdir($prefix); foreach ($paths as $d) { - mkdir($prefix . $d); - file_put_contents($prefix . $d . ".test", $d); + mkdir($prefix . $d); + file_put_contents($prefix . $d . ".test", $d); } $myDirectory = opendir($prefix); while($entryName = readdir($myDirectory)) { - echo get_basename_with_cp($prefix . $entryName, 65001, false) . "\n"; + echo get_basename_with_cp($prefix . $entryName, 65001, false) . "\n"; } closedir($myDirectory); foreach ($paths as $d) { - rmdir($prefix . $d); - unlink($prefix . $d . ".test"); + rmdir($prefix . $d); + unlink($prefix . $d . ".test"); } rmdir($prefix); diff --git a/ext/standard/tests/file/windows_mb_path/bug64506.phpt b/ext/standard/tests/file/windows_mb_path/bug64506.phpt index fa9653fbd282..0bcf0d778cd6 100644 --- a/ext/standard/tests/file/windows_mb_path/bug64506.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug64506.phpt @@ -22,9 +22,9 @@ $fnw = __DIR__ . DIRECTORY_SEPARATOR . "Å¡.txt"; // UTF-8 $f = fopen($fnw, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump($f, fwrite($f, "writing to an mb filename")); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(fclose($f)); diff --git a/ext/standard/tests/file/windows_mb_path/bug64699.phpt b/ext/standard/tests/file/windows_mb_path/bug64699.phpt index 8b6859176f87..20d4182b7197 100644 --- a/ext/standard/tests/file/windows_mb_path/bug64699.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug64699.phpt @@ -25,7 +25,7 @@ $dirs = array("a", "ソ", "ゾ", "şŞıİğĞ", "多国語", "表"); mkdir($prefix); foreach ($dirs as $d) { - mkdir($prefix . $d); + mkdir($prefix . $d); } $dir = $prefix; @@ -41,7 +41,7 @@ if ($dh = opendir($dir)) { } foreach ($dirs as $d) { - rmdir($prefix . $d); + rmdir($prefix . $d); } rmdir($prefix); diff --git a/ext/standard/tests/file/windows_mb_path/bug74923.phpt b/ext/standard/tests/file/windows_mb_path/bug74923.phpt index 544a7110ee09..9cffd5860f60 100644 --- a/ext/standard/tests/file/windows_mb_path/bug74923.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug74923.phpt @@ -12,7 +12,7 @@ if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 32) { - $dir .= DIRECTORY_SEPARATOR . str_repeat("a", 32); + $dir .= DIRECTORY_SEPARATOR . str_repeat("a", 32); } $dir .= DIRECTORY_SEPARATOR . str_repeat("a", $need_len - strlen($dir)); mkdir($dir, 0700, true); @@ -26,34 +26,34 @@ file_put_contents($fl, ""); $start = substr($dir, 0, strpos($dir, DIRECTORY_SEPARATOR, strlen(__DIR__)+1)); $iter = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator( - $start, - FilesystemIterator::SKIP_DOTS - ), - RecursiveIteratorIterator::CHILD_FIRST + new RecursiveDirectoryIterator( + $start, + FilesystemIterator::SKIP_DOTS + ), + RecursiveIteratorIterator::CHILD_FIRST ); foreach ($iter as $item) { - if (!$item->isDir()) { - var_dump($item->getPathname()); - } + if (!$item->isDir()) { + var_dump($item->getPathname()); + } } $iter->rewind(); foreach ($iter as $item) { - if ($item->isDir()) { - rmdir($item->getPathname()); - } else { - unlink($item->getPathname()); - } + if ($item->isDir()) { + rmdir($item->getPathname()); + } else { + unlink($item->getPathname()); + } } rmdir($start); var_dump(file_exists($start)); /*unlink($fl); do { - rmdir($dir); - $dir = dirname($dir); + rmdir($dir); + $dir = dirname($dir); } while (__DIR__ != $dir);*/ ?> diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt index 39a6d30c7799..41fd2e75526a 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "$item"; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_big5"); diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt index 5cc2c736ec59..5460ae9dfabd 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "{$item}25"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt index 4a6dd198643f..0dcc09dae9d7 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "$item"; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_big5"); diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt index e9294ababd2a..6269aaf05040 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "{$item}25"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt index 6de73c02a8b8..10db18c19b44 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1250"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt index 82255919ab4b..571daff09432 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt index d35915856435..568f56361b10 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1250"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt index d5230c37825f..ef9e17b7f279 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt index aeedc2c8750e..d1c4f0f4fcde 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1251"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt index 06bc8d2d8748..11617475640a 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}7"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt index dc870e829d3d..b780065d90e6 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1251"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt index b5192dcf84d8..251fa2c0006b 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}7"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt index 9694e54ffd7c..2f28a922e30e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open failed\n"; + echo "open failed\n"; } remove_data("file_cp1251"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt index 3788ef24119b..d6ff64e4e59e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open failed\n"; + echo "open failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt index 8a601bf6663c..e85636d989e1 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1252"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt index dc042a047582..0709d1270cf8 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}7"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt index 264558a657b7..3abbc5820564 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file2_cp1252"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt index 1945fc54beb4..8f45ed24e46e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}7"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt index 08ab2aa7bbdc..8ed2b2d97b35 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1253"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt index c1ea99e32b11..88f28fa2810d 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt index 675bdd12c4a9..4f0d601d4a91 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1253"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt index 8210704b3f80..af329eadcff2 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt index 1ceefc759e6b..d619576ad5f6 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1254"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt index 4de9478b32b6..f6357366e7e3 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt index 39308b336842..eac345d8beeb 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1254"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt index 1f0c7816ecc1..09caa2c38606 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt index 26388620a136..c360e82119f4 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1255"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt index 4b7ac57968c1..346620c6c55f 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt index c9517a18e3b3..c930515c57f2 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1255"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt index 363d1b02b5f0..8e18ca690f96 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt index 35ad1def2e05..5619b33f06fe 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1256"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt index b277fc208b40..e756a3e093ed 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt index 306414e5ca2f..d7e0ed5afcb1 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp1256"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt index 38ae6a475404..b05c4301e5f5 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt index 7beae3a6bb12..e8bc394a5d0d 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt @@ -22,27 +22,27 @@ default_charset=cp874 include __DIR__ . DIRECTORY_SEPARATOR . "util.inc"; $names = array( /* cp874 */ - "à»ç¹á¿éÁ·Õè·´Êͺ1", - "à»ç¹á¿éÁ·Õè·´Êͺ2", - "à»ç¹á¿éÁ·Õè·´Êͺ3", - "à»ç¹á¿éÁ·Õè·´Êͺ4", - "à»ç¹á¿éÁ·Õè·´Êͺ5", - "à»ç¹á¿éÁ·Õè·´Êͺ6", - "à»ç¹á¿éÁ·Õè·´Êͺ7", - "à»ç¹á¿éÁ·Õè·´Êͺ8", - "à»ç¹á¿éÁ·Õè·´Êͺ8 10", + "à»ç¹á¿éÁ·Õè·´Êͺ1", + "à»ç¹á¿éÁ·Õè·´Êͺ2", + "à»ç¹á¿éÁ·Õè·´Êͺ3", + "à»ç¹á¿éÁ·Õè·´Êͺ4", + "à»ç¹á¿éÁ·Õè·´Êͺ5", + "à»ç¹á¿éÁ·Õè·´Êͺ6", + "à»ç¹á¿éÁ·Õè·´Êͺ7", + "à»ç¹á¿éÁ·Õè·´Êͺ8", + "à»ç¹á¿éÁ·Õè·´Êͺ8 10", ); $i = 0; foreach ($names as $name) { - $path = __DIR__ . DIRECTORY_SEPARATOR . $name . ".txt"; + $path = __DIR__ . DIRECTORY_SEPARATOR . $name . ".txt"; - file_put_contents($path, "hello" . $i++); + file_put_contents($path, "hello" . $i++); - get_basename_with_cp($path, 874); - var_dump(file_get_contents($path)); + get_basename_with_cp($path, 874); + var_dump(file_get_contents($path)); - unlink($path); + unlink($path); } ?> diff --git a/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt index 009fcf16a518..c21f124b6e19 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt @@ -19,27 +19,27 @@ skip_if_no_required_exts(); include __DIR__ . DIRECTORY_SEPARATOR . "util.inc"; $names = array( /* cp874 */ - "à»ç¹á¿éÁ·Õè·´Êͺ1", - "à»ç¹á¿éÁ·Õè·´Êͺ2", - "à»ç¹á¿éÁ·Õè·´Êͺ3", - "à»ç¹á¿éÁ·Õè·´Êͺ4", - "à»ç¹á¿éÁ·Õè·´Êͺ5", - "à»ç¹á¿éÁ·Õè·´Êͺ6", - "à»ç¹á¿éÁ·Õè·´Êͺ7", - "à»ç¹á¿éÁ·Õè·´Êͺ8", - "à»ç¹á¿éÁ·Õè·´Êͺ8 10", + "à»ç¹á¿éÁ·Õè·´Êͺ1", + "à»ç¹á¿éÁ·Õè·´Êͺ2", + "à»ç¹á¿éÁ·Õè·´Êͺ3", + "à»ç¹á¿éÁ·Õè·´Êͺ4", + "à»ç¹á¿éÁ·Õè·´Êͺ5", + "à»ç¹á¿éÁ·Õè·´Êͺ6", + "à»ç¹á¿éÁ·Õè·´Êͺ7", + "à»ç¹á¿éÁ·Õè·´Êͺ8", + "à»ç¹á¿éÁ·Õè·´Êͺ8 10", ); $i = 0; foreach ($names as $name) { - $pathw = __DIR__ . DIRECTORY_SEPARATOR . iconv('cp874', 'utf-8', $name) . ".txt"; + $pathw = __DIR__ . DIRECTORY_SEPARATOR . iconv('cp874', 'utf-8', $name) . ".txt"; - file_put_contents($pathw, "hello" . $i++); + file_put_contents($pathw, "hello" . $i++); - get_basename_with_cp($pathw, 65001); - var_dump(file_get_contents($pathw)); + get_basename_with_cp($pathw, 65001); + var_dump(file_get_contents($pathw)); - unlink($pathw); + unlink($pathw); } ?> diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt index f56aa7231eae..afd1ef3e7aa1 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp932"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt index 51420195e860..97bad6412edf 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt index 40cef6362150..7da7aff1fc80 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp932"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt index 2c1adc9e0a3d..c8aaa0b56ba8 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt index 9b65cd6905d6..a67cc6683c00 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "$item"; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp936"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt index d0796664678c..c913f4e352db 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt @@ -27,10 +27,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "{$item}25"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt index 1be1f57f5f73..9653f2ec1ff2 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "$item"; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_cp936"); diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt index 9d6ba06c2196..ab0b836da780 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "{$item}25"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt index a8d4e99a6953..a72a80ac8bd7 100644 --- a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_eucjp"); diff --git a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt index dfd7de527375..f43e27bd2935 100644 --- a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt index 796abf986782..b9a855231360 100644 --- a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . $item; $f = fopen($fn, 'r'); if ($f) { - var_dump($f, fread($f, 42)); - var_dump(fclose($f)); + var_dump($f, fread($f, 42)); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } remove_data("file_kartuli"); diff --git a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt index 04b4dc0aa381..c0c881f0f3d1 100644 --- a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt @@ -24,10 +24,10 @@ $fn = $prefix . DIRECTORY_SEPARATOR . "${item}33"; $f = fopen($fn, 'w'); if ($f) { - var_dump($f, fwrite($f, "writing to an mb filename")); - var_dump(fclose($f)); + var_dump($f, fwrite($f, "writing to an mb filename")); + var_dump(fclose($f)); } else { - echo "open utf8 failed\n"; + echo "open utf8 failed\n"; } var_dump(file_get_contents($fn)); diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt index b88424471f91..3705582484cf 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt @@ -17,8 +17,8 @@ $s = str_repeat('a', 50); $how_many = 32; for ($i = 0; $i < $how_many; $i++) { - $p .= "$s"; - $p .= DIRECTORY_SEPARATOR; + $p .= "$s"; + $p .= DIRECTORY_SEPARATOR; } $p = realpath(__DIR__) . DIRECTORY_SEPARATOR . $p; @@ -30,8 +30,8 @@ var_dump(mkdir($p, 0777, true)); var_dump(file_exists($p)); for ($i = 0; $i < $how_many; $i++) { - $p0 = substr($p, 0, strlen($p) - $i*51); - rmdir($p0); + $p0 = substr($p, 0, strlen($p) - $i*51); + rmdir($p0); } var_dump(file_exists(realpath(__DIR__) . DIRECTORY_SEPARATOR . $s)); diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_1.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_1.phpt index ae3e1635a561..427f0e9cf5d0 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_1.phpt @@ -17,8 +17,8 @@ $how_many = 32; for ($i = 0; $i < $how_many; $i++) { - $p .= "$s"; - $p .= DIRECTORY_SEPARATOR; + $p .= "$s"; + $p .= DIRECTORY_SEPARATOR; } $p = realpath(__DIR__) . DIRECTORY_SEPARATOR . $p; @@ -37,8 +37,8 @@ var_dump(file_get_contents($p7)); unlink($p7); for ($i = 0; $i < $how_many; $i++) { - $p0 = substr($p, 0, strlen($p) - $i*51); - rmdir($p0); + $p0 = substr($p, 0, strlen($p) - $i*51); + rmdir($p0); } var_dump(file_exists(realpath(__DIR__) . DIRECTORY_SEPARATOR . $s)); diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_2.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_2.phpt index 2e39fa8d5c8c..05982133c167 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_2.phpt @@ -17,8 +17,8 @@ $how_many = 32; for ($i = 0; $i < $how_many; $i++) { - $p .= "$s"; - $p .= DIRECTORY_SEPARATOR; + $p .= "$s"; + $p .= DIRECTORY_SEPARATOR; } /* path doesn't exist at this point! */ @@ -43,8 +43,8 @@ var_dump(file_get_contents($p7)); unlink($p7); for ($i = 0; $i < $how_many; $i++) { - $p0 = substr($p, 0, strlen($p) - $i*(strlen($s) + 1)); - rmdir($p0); + $p0 = substr($p, 0, strlen($p) - $i*(strlen($s) + 1)); + rmdir($p0); } var_dump(file_exists(realpath(__DIR__) . DIRECTORY_SEPARATOR . $s)); diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_bug70943.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_bug70943.phpt index 72d78b3b606e..5b797d293b3b 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_bug70943.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_bug70943.phpt @@ -17,8 +17,8 @@ touch($testFile); echo "Opening file... "; if ($fp = fopen($testFile, "r")) { - fclose($fp); - echo "OK", "\n"; + fclose($fp); + echo "OK", "\n"; } unlink($testFile); diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_bug71103.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_bug71103.phpt index b98e087560c1..a81ff66dfb5d 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_bug71103.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_bug71103.phpt @@ -20,27 +20,27 @@ $bar = $d . '\\5b53796d666f6e795c42756e646c655c5477696742756e646c655c436f6e74726 mkdir($d, NULL, true); foreach (array($foo, $bar) as $f) { - touch($f); - - $foo_obj = new \SplFileInfo($f); - var_dump( - $f, - strlen($f) > 260, /* exceeds _MAX_PATH */ - file_exists($f), - file_exists($foo_obj), - is_readable($f), - is_readable($foo_obj), - is_writable($f), - is_writable($foo_obj) - ); - - unlink($f); + touch($f); + + $foo_obj = new \SplFileInfo($f); + var_dump( + $f, + strlen($f) > 260, /* exceeds _MAX_PATH */ + file_exists($f), + file_exists($foo_obj), + is_readable($f), + is_readable($foo_obj), + is_writable($f), + is_writable($foo_obj) + ); + + unlink($f); } $p = $d; do { - rmdir($p); - $p = dirname($p); + rmdir($p); + $p = dirname($p); } while ($p != $base); ?> diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_mkdir.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_mkdir.phpt index c3cceb6d1a71..1e3d7cd19cc0 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_mkdir.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_mkdir.phpt @@ -20,15 +20,15 @@ $s = str_repeat('a', 50); $how_many = 32; for ($i = 0; $i < $how_many; $i++) { - $p .= "$s\\"; + $p .= "$s\\"; } $start = realpath(__DIR__); $newstart = false; if (strlen($start) <= 248) { - // create the exact length - $start = $start . "\\" . str_repeat('a', 251 - strlen($start) - 1); - $newstart = true; + // create the exact length + $start = $start . "\\" . str_repeat('a', 251 - strlen($start) - 1); + $newstart = true; } var_dump($start); @@ -46,11 +46,11 @@ var_dump(file_get_contents($p7)); // cleanup unlink($p7); for ($i = 0; $i < $how_many; $i++) { - $p0 = substr($p, 0, strlen($p) - $i*51); - rmdir($p0); + $p0 = substr($p, 0, strlen($p) - $i*51); + rmdir($p0); } if ($newstart) { - rmdir($start); + rmdir($start); } ?> diff --git a/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt b/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt index 62db0c8c65e7..e671ef8f1d72 100644 --- a/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt @@ -47,7 +47,7 @@ if (is_dir($dirw)) { closedir($dh); } } else { - echo "is_dir failed\n"; + echo "is_dir failed\n"; } set_active_cp($old_cp); diff --git a/ext/standard/tests/file/windows_mb_path/util.inc b/ext/standard/tests/file/windows_mb_path/util.inc index fc80a7613fe4..a26a66c01751 100644 --- a/ext/standard/tests/file/windows_mb_path/util.inc +++ b/ext/standard/tests/file/windows_mb_path/util.inc @@ -2,153 +2,153 @@ function get_active_cp($kind = "") { - if (version_compare(PHP_VERSION, '7.1', '<')) { - $s = exec("chcp"); - preg_match(",.*: (\d+),", $s, $m); - - return $m[1]; - } else { - return sapi_windows_cp_get($kind); - } + if (version_compare(PHP_VERSION, '7.1', '<')) { + $s = exec("chcp"); + preg_match(",.*: (\d+),", $s, $m); + + return $m[1]; + } else { + return sapi_windows_cp_get($kind); + } } function set_active_cp($cp, $echo = true) { - if (version_compare(PHP_VERSION, '7.1', '<')) { - $ret = exec("chcp $cp"); - } else { - if (!sapi_windows_cp_set($cp)) { - echo "Failed to set cp $cp\n"; - return; - } - - if ($echo) echo "Active code page: ", get_active_cp(), "\n"; - } + if (version_compare(PHP_VERSION, '7.1', '<')) { + $ret = exec("chcp $cp"); + } else { + if (!sapi_windows_cp_set($cp)) { + echo "Failed to set cp $cp\n"; + return; + } + + if ($echo) echo "Active code page: ", get_active_cp(), "\n"; + } } function get_basename_with_cp($path, $cp, $echo = true) { - $old_cp = get_active_cp(); - set_active_cp($cp, $echo); + $old_cp = get_active_cp(); + set_active_cp($cp, $echo); - if ($echo) echo "getting basename of $path\n"; + if ($echo) echo "getting basename of $path\n"; - $cmd = "powershell -command \"Get-Item -Path '$path' | Format-Table -HideTableHeaders Name\""; - $out = trim(shell_exec($cmd)); + $cmd = "powershell -command \"Get-Item -Path '$path' | Format-Table -HideTableHeaders Name\""; + $out = trim(shell_exec($cmd)); - if ($echo) var_dump($out, $out == basename($path)); - if ($echo) var_dump(realpath($path)); + if ($echo) var_dump($out, $out == basename($path)); + if ($echo) var_dump(realpath($path)); - set_active_cp($old_cp, $echo); + set_active_cp($old_cp, $echo); - return $out; + return $out; } function skip_if_wrong_cp($cp, $kind = "") { - if (get_active_cp($kind) != $cp) { - die("skip this test expect codepage $cp"); - } + if (get_active_cp($kind) != $cp) { + die("skip this test expect codepage $cp"); + } } function skip_if_no_required_exts() { - $exts = func_get_args(); - $exts[] = "iconv"; - - foreach ($exts as $ext) { - if (!extension_loaded($ext)) { - die("skip $ext is not loaded"); - } - } + $exts = func_get_args(); + $exts[] = "iconv"; + + foreach ($exts as $ext) { + if (!extension_loaded($ext)) { + die("skip $ext is not loaded"); + } + } } function skip_if_not_win() { - if(substr(PHP_OS, 0, 3) != 'WIN' ) { - die('skip windows only test'); - } + if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); + } } function create_verify_file($prefix, $basename, $content = "", $cp = 65001) { - $full = $prefix . DIRECTORY_SEPARATOR . $basename; - - if (!touch($full)) { - echo "failed to touch create $full\n"; - return; - } - - $now = get_basename_with_cp($full, $cp, false); - if ($now !== $basename) { - echo "expected '$basename', got '$now'\n"; - return; - } - - if ($content) { - file_put_contents($full, $content); - } + $full = $prefix . DIRECTORY_SEPARATOR . $basename; + + if (!touch($full)) { + echo "failed to touch create $full\n"; + return; + } + + $now = get_basename_with_cp($full, $cp, false); + if ($now !== $basename) { + echo "expected '$basename', got '$now'\n"; + return; + } + + if ($content) { + file_put_contents($full, $content); + } } function create_verify_dir($prefix, $basename, $cp = 65001) { - $full = $prefix . DIRECTORY_SEPARATOR . $basename; + $full = $prefix . DIRECTORY_SEPARATOR . $basename; - if (!mkdir($full)) { - echo "failed to create dir '$full'\n"; - return; - } + if (!mkdir($full)) { + echo "failed to create dir '$full'\n"; + return; + } - $now = get_basename_with_cp($full, $cp, false); - if ($now !== $basename) { - echo "expected '$basename', got '$now'\n"; - } + $now = get_basename_with_cp($full, $cp, false); + if ($now !== $basename) { + echo "expected '$basename', got '$now'\n"; + } } function remove_data($id, $dir = NULL) { - if (!$dir) { - $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . $id; - } - - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (filetype($dir . DIRECTORY_SEPARATOR . $object) == "dir") - remove_data($id, $dir . DIRECTORY_SEPARATOR . $object); - else - unlink($dir . DIRECTORY_SEPARATOR . $object); - } - } - reset($objects); - rmdir($dir); - } + if (!$dir) { + $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . $id; + } + + if (is_dir($dir)) { + $objects = scandir($dir); + foreach ($objects as $object) { + if ($object != "." && $object != "..") { + if (filetype($dir . DIRECTORY_SEPARATOR . $object) == "dir") + remove_data($id, $dir . DIRECTORY_SEPARATOR . $object); + else + unlink($dir . DIRECTORY_SEPARATOR . $object); + } + } + reset($objects); + rmdir($dir); + } } function create_data($id, $item = "", $cp = 65001, $utf8 = true) { - if ($utf8) { - /* Keep this file ASCII, so zend.multibyte related stuff can be tasted as well. */ - include dirname(__FILE__) . DIRECTORY_SEPARATOR . "util_utf8.inc"; - return create_data_from_utf8($id, $item, $cp); - } else { - - $prefix = dirname(__FILE__) . DIRECTORY_SEPARATOR . $id; - - if (!is_dir($prefix)) { - mkdir($prefix); - } - - if (0 === strpos($id, "dir")) { - create_verify_dir($prefix, $item, $cp); - } else if (0 === strpos($id, "file")) { - /* a bit unhandy, but content can be put from outside, if needed */ - create_verify_file($prefix, $item, "dummy content", $cp); - } else { - echo "Item has either to start with \"dir\" or \"file\""; - } - } - - return $prefix; + if ($utf8) { + /* Keep this file ASCII, so zend.multibyte related stuff can be tasted as well. */ + include dirname(__FILE__) . DIRECTORY_SEPARATOR . "util_utf8.inc"; + return create_data_from_utf8($id, $item, $cp); + } else { + + $prefix = dirname(__FILE__) . DIRECTORY_SEPARATOR . $id; + + if (!is_dir($prefix)) { + mkdir($prefix); + } + + if (0 === strpos($id, "dir")) { + create_verify_dir($prefix, $item, $cp); + } else if (0 === strpos($id, "file")) { + /* a bit unhandy, but content can be put from outside, if needed */ + create_verify_file($prefix, $item, "dummy content", $cp); + } else { + echo "Item has either to start with \"dir\" or \"file\""; + } + } + + return $prefix; } diff --git a/ext/standard/tests/file/windows_mb_path/util_utf8.inc b/ext/standard/tests/file/windows_mb_path/util_utf8.inc index e09156499849..e51fad13b60b 100644 --- a/ext/standard/tests/file/windows_mb_path/util_utf8.inc +++ b/ext/standard/tests/file/windows_mb_path/util_utf8.inc @@ -2,93 +2,93 @@ function create_data_from_utf8($id, $item = "", $cp = 65001) { - $prefix = dirname(__FILE__) . DIRECTORY_SEPARATOR . $id; + $prefix = dirname(__FILE__) . DIRECTORY_SEPARATOR . $id; - if (!is_dir($prefix)) { - mkdir($prefix); - } + if (!is_dir($prefix)) { + mkdir($prefix); + } - /* Using a UTF-8 encoded filenames if !zend.multibyte, otherwise files in retrospective charset. */ - switch ($id) { + /* Using a UTF-8 encoded filenames if !zend.multibyte, otherwise files in retrospective charset. */ + switch ($id) { - case "file_mb3": - $content = " 0) { - fwrite($fp, $str); + fwrite($fp, $str); } $cnt = $size - ($str_len + $cnt); fclose($fp); diff --git a/ext/standard/tests/filters/bug35916.phpt b/ext/standard/tests/filters/bug35916.phpt index a890b41a5793..e234949303fc 100644 --- a/ext/standard/tests/filters/bug35916.phpt +++ b/ext/standard/tests/filters/bug35916.phpt @@ -9,22 +9,22 @@ class strtoupper_filter extends php_user_filter { function filter($in, $out, &$consumed, $closing) { - while($bucket=stream_bucket_make_writeable($in)) { - $bucket->data = strtoupper($bucket->data); - $consumed += $bucket->datalen; - stream_bucket_append($out, $bucket); - stream_bucket_append($out, $bucket); + while($bucket=stream_bucket_make_writeable($in)) { + $bucket->data = strtoupper($bucket->data); + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + stream_bucket_append($out, $bucket); } - return PSFS_PASS_ON; + return PSFS_PASS_ON; } - function onCreate() - { - echo "fffffffffff\n"; - } - function onClose() - { - echo "hello\n"; - } + function onCreate() + { + echo "fffffffffff\n"; + } + function onClose() + { + echo "hello\n"; + } } stream_filter_register("strtoupper", "strtoupper_filter"); diff --git a/ext/standard/tests/filters/bug46164-1.phpt b/ext/standard/tests/filters/bug46164-1.phpt index b2d2d4e85d7e..ecdd86bbe284 100644 --- a/ext/standard/tests/filters/bug46164-1.phpt +++ b/ext/standard/tests/filters/bug46164-1.phpt @@ -3,13 +3,13 @@ Bug #46164 - 1 (stream_filter_remove() closes the stream) --FILE-- datalen; - stream_bucket_append($out, $bucket); - } - return PSFS_PASS_ON; - } + function filter($in, $out, &$consumed, $closing) { + while($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } } stream_filter_register('user_filter','user_filter'); diff --git a/ext/standard/tests/filters/bug46164-2.phpt b/ext/standard/tests/filters/bug46164-2.phpt index 6a1bde59620c..c58295076f0b 100644 --- a/ext/standard/tests/filters/bug46164-2.phpt +++ b/ext/standard/tests/filters/bug46164-2.phpt @@ -3,14 +3,14 @@ Bug #46164 - 2 (stream_filter_remove() closes the stream) --FILE-- datalen; - stream_bucket_append($out, $bucket); - } - unset($this->stream); - return PSFS_PASS_ON; - } + function filter($in, $out, &$consumed, $closing) { + while($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + unset($this->stream); + return PSFS_PASS_ON; + } } stream_filter_register('user_filter','user_filter'); diff --git a/ext/standard/tests/filters/chunked_001.phpt b/ext/standard/tests/filters/chunked_001.phpt index c90dd403ecf7..094b49d7b95d 100644 --- a/ext/standard/tests/filters/chunked_001.phpt +++ b/ext/standard/tests/filters/chunked_001.phpt @@ -10,19 +10,19 @@ allow_url_fopen=1 --FILE-- --EXPECT-- diff --git a/ext/standard/tests/filters/filter_errors.inc b/ext/standard/tests/filters/filter_errors.inc index 8636fbe17f41..18711844f834 100644 --- a/ext/standard/tests/filters/filter_errors.inc +++ b/ext/standard/tests/filters/filter_errors.inc @@ -1,36 +1,36 @@ datalen; - stream_bucket_append($out, $bucket); - } - return PSFS_ERR_FATAL; - } + function filter($in, $out, &$consumed, $closing) { + while ($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + return PSFS_ERR_FATAL; + } } class test_filter3 extends php_user_filter { - function filter($in, $out, &$consumed, $closing) { - if (!$closing) { - $bucket = stream_bucket_new($this->stream, "42"); - stream_bucket_append($out, $bucket); - } - return PSFS_ERR_FATAL; - } + function filter($in, $out, &$consumed, $closing) { + if (!$closing) { + $bucket = stream_bucket_new($this->stream, "42"); + stream_bucket_append($out, $bucket); + } + return PSFS_ERR_FATAL; + } } class test_filter4 extends php_user_filter { - function filter($in, $out, &$consumed, $closing) { - if (!$closing) { - $bucket = stream_bucket_new($this->stream, "42"); - } - return PSFS_ERR_FATAL; - } + function filter($in, $out, &$consumed, $closing) { + if (!$closing) { + $bucket = stream_bucket_new($this->stream, "42"); + } + return PSFS_ERR_FATAL; + } } for($i = 0; $i < 5; ++$i) { - echo "test_filter$i\n"; - var_dump(stream_filter_register("test_filter$i", "test_filter$i")); - filter_errors_test("test_filter$i", "42"); + echo "test_filter$i\n"; + var_dump(stream_filter_register("test_filter$i", "test_filter$i")); + filter_errors_test("test_filter$i", "42"); } echo "test append / read / remove\n"; for($i = 0; $i < 5; ++$i) { - echo "test_filter$i\n"; - $stream = fopen('php://memory', 'wb+'); - fwrite($stream, "42"); - fseek($stream, 0, SEEK_SET); - $f = stream_filter_append($stream, "test_filter$i"); - stream_get_contents($stream); - stream_filter_remove($f); + echo "test_filter$i\n"; + $stream = fopen('php://memory', 'wb+'); + fwrite($stream, "42"); + fseek($stream, 0, SEEK_SET); + $f = stream_filter_append($stream, "test_filter$i"); + stream_get_contents($stream); + stream_filter_remove($f); } echo "test append all / read / remove all\n"; @@ -65,12 +65,12 @@ fwrite($stream, "42"); fseek($stream, 0, SEEK_SET); $filters = array(); for($i = 0; $i < 5; ++$i) { - echo "test_filter$i\n"; - $filters[] = stream_filter_append($stream, "test_filter$i"); + echo "test_filter$i\n"; + $filters[] = stream_filter_append($stream, "test_filter$i"); } stream_get_contents($stream); foreach($filters as $filter) { - stream_filter_remove($filter); + stream_filter_remove($filter); } echo "test append all / read / close\n"; @@ -79,8 +79,8 @@ fwrite($stream, "42"); fseek($stream, 0, SEEK_SET); $filters = array(); for($i = 0; $i < 5; ++$i) { - echo "test_filter$i\n"; - $filters[] = stream_filter_append($stream, "test_filter$i"); + echo "test_filter$i\n"; + $filters[] = stream_filter_append($stream, "test_filter$i"); } stream_get_contents($stream); fclose($stream); diff --git a/ext/standard/tests/general_functions/001.phpt b/ext/standard/tests/general_functions/001.phpt index 307122e1cb92..a43215c2c78c 100644 --- a/ext/standard/tests/general_functions/001.phpt +++ b/ext/standard/tests/general_functions/001.phpt @@ -7,41 +7,41 @@ $agent = sprintf("%.5s", "James Bond, 007"); echo("sprintf string truncate test: "); if ($agent == "James") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo("sprintf padding and align test: "); $test = sprintf("abc%04d %-20s%c", 20, "fisketur", 33); if ($test == "abc0020 fisketur !") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo("sprintf octal and hex test: "); $test = sprintf("%4o %4x %4X %0"."8x", 128, 1024, 49151, 3457925); if ($test == " 200 400 BFFF 0034c385") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo("sprintf octal binary test: "); $test = sprintf("%b", 3457925); if ($test == "1101001100001110000101") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo("sprintf float test: "); $test = sprintf("%0"."06.2f", 10000/3.0); if ($test == "003333.33") { - echo("passed\n"); + echo("passed\n"); } else { - echo("failed!\n"); + echo("failed!\n"); } echo sprintf("%.2f\n", "99.00"); diff --git a/ext/standard/tests/general_functions/002.phpt b/ext/standard/tests/general_functions/002.phpt index 58528da13aad..43c67ec07b43 100644 --- a/ext/standard/tests/general_functions/002.phpt +++ b/ext/standard/tests/general_functions/002.phpt @@ -1,9 +1,9 @@ --TEST-- quoted_printable_decode() function test --FILE-- - --EXPECT-- diff --git a/ext/standard/tests/general_functions/003.phpt b/ext/standard/tests/general_functions/003.phpt index 0388cf95b072..573491b8a206 100644 --- a/ext/standard/tests/general_functions/003.phpt +++ b/ext/standard/tests/general_functions/003.phpt @@ -6,18 +6,18 @@ levenshtein() function test function test_me($title,$expect,$text1,$text2,$cost1=0,$cost2=0,$cost3=0) { if($cost1==0) - $result=levenshtein($text1,$text2); - else + $result=levenshtein($text1,$text2); + else $result=levenshtein($text1,$text2,$cost1,$cost2,$cost3); - if($result==$expect) return 0; + if($result==$expect) return 0; - echo "$title: result is $result instead of $expect "; - echo "for '$text1'/'$text2' "; - if($cost1) echo "($cost1:$cost2:$cost3)"; - echo "\n"; + echo "$title: result is $result instead of $expect "; + echo "for '$text1'/'$text2' "; + if($cost1) echo "($cost1:$cost2:$cost3)"; + echo "\n"; - return 1; + return 1; } $n=0; diff --git a/ext/standard/tests/general_functions/004.phpt b/ext/standard/tests/general_functions/004.phpt index fa83c7c220a2..80a721693923 100644 --- a/ext/standard/tests/general_functions/004.phpt +++ b/ext/standard/tests/general_functions/004.phpt @@ -5,7 +5,7 @@ fgetcsv() with tab delimited fields (BUG #8258) chdir(__DIR__); $fp=fopen("004.data","r"); while($a=fgetcsv($fp,100,"\t")) { - echo join(",",$a)."\n"; + echo join(",",$a)."\n"; } fclose($fp); ?> diff --git a/ext/standard/tests/general_functions/006.phpt b/ext/standard/tests/general_functions/006.phpt index 6852286c5e78..80a8fd416894 100644 --- a/ext/standard/tests/general_functions/006.phpt +++ b/ext/standard/tests/general_functions/006.phpt @@ -1,9 +1,9 @@ --TEST-- quoted_printable_decode() function test with CR/LF --FILE-- - --EXPECT-- diff --git a/ext/standard/tests/general_functions/007.phpt b/ext/standard/tests/general_functions/007.phpt index 02fc6c64809b..e5775bb7427d 100644 --- a/ext/standard/tests/general_functions/007.phpt +++ b/ext/standard/tests/general_functions/007.phpt @@ -3,8 +3,8 @@ MD5 / Base64 --FILE-- --EXPECT-- bool(false) diff --git a/ext/standard/tests/general_functions/bug25038.phpt b/ext/standard/tests/general_functions/bug25038.phpt index 5bd549fd0f04..58acf1c977c0 100644 --- a/ext/standard/tests/general_functions/bug25038.phpt +++ b/ext/standard/tests/general_functions/bug25038.phpt @@ -9,19 +9,19 @@ function bar($x='no argument') } try { - bar('first try'); + bar('first try'); } catch (Exception $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } try { - call_user_func('bar','second try'); + call_user_func('bar','second try'); } catch (Exception $e) { - print $e->getMessage()."\n"; + print $e->getMessage()."\n"; } ?> diff --git a/ext/standard/tests/general_functions/bug29038.phpt b/ext/standard/tests/general_functions/bug29038.phpt index d0c87fb199c9..5502ecf61a4e 100644 --- a/ext/standard/tests/general_functions/bug29038.phpt +++ b/ext/standard/tests/general_functions/bug29038.phpt @@ -3,8 +3,8 @@ Bug #29038 (extract(), EXTR_PREFIX_SAME option prefixes empty strings) --FILE-- 1),EXTR_PREFIX_SAME,"prefix"); diff --git a/ext/standard/tests/general_functions/bug32647.phpt b/ext/standard/tests/general_functions/bug32647.phpt index 92fa547820fb..4f5697a0d452 100644 --- a/ext/standard/tests/general_functions/bug32647.phpt +++ b/ext/standard/tests/general_functions/bug32647.phpt @@ -10,8 +10,8 @@ function foo() class bar { - function barfoo () - { echo "bar!\n"; } + function barfoo () + { echo "bar!\n"; } } unset($obj); diff --git a/ext/standard/tests/general_functions/bug35229.phpt b/ext/standard/tests/general_functions/bug35229.phpt index 8e8895dd592a..c0b3614f6e72 100644 --- a/ext/standard/tests/general_functions/bug35229.phpt +++ b/ext/standard/tests/general_functions/bug35229.phpt @@ -9,9 +9,9 @@ class test2 { } spl_autoload_register(function ($class) { - eval('class test1 extends test2 {}'); + eval('class test1 extends test2 {}'); - test1::use_stack( + test1::use_stack( 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30 diff --git a/ext/standard/tests/general_functions/bug36011.phpt b/ext/standard/tests/general_functions/bug36011.phpt index 63e0015437b9..3fe4e774b49a 100644 --- a/ext/standard/tests/general_functions/bug36011.phpt +++ b/ext/standard/tests/general_functions/bug36011.phpt @@ -5,25 +5,25 @@ Bug #36011 (Strict errormsg wrong for call_user_func() and the likes) class TestClass { - static function test() - { - echo __METHOD__ . "()\n"; - } - - function whee() - { - array_map(array('TestClass', 'test'), array('array_value')); - } - - function whee4() - { - call_user_func(array('TestClass', 'test')); - } - - static function whee5() - { - call_user_func(array('TestClass', 'test')); - } + static function test() + { + echo __METHOD__ . "()\n"; + } + + function whee() + { + array_map(array('TestClass', 'test'), array('array_value')); + } + + function whee4() + { + call_user_func(array('TestClass', 'test')); + } + + static function whee5() + { + call_user_func(array('TestClass', 'test')); + } } TestClass::test(); diff --git a/ext/standard/tests/general_functions/bug40398.phpt b/ext/standard/tests/general_functions/bug40398.phpt index b187c64efe88..274faf83086b 100644 --- a/ext/standard/tests/general_functions/bug40398.phpt +++ b/ext/standard/tests/general_functions/bug40398.phpt @@ -5,64 +5,64 @@ Bug #40398 (parent and self callback functions erroneously called statically) class Base { - function __construct($msg) - { - echo __METHOD__ . "($msg)\n"; - } + function __construct($msg) + { + echo __METHOD__ . "($msg)\n"; + } } class Derived_1 extends Base { - public function __construct() - { - $args = func_get_args(); - call_user_func_array(array($this, 'Base::__construct'), $args); - } + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array($this, 'Base::__construct'), $args); + } } class Derived_2 extends Base { - public function __construct() - { - $args = func_get_args(); - call_user_func_array(array($this, 'parent::__construct'), $args); - } + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array($this, 'parent::__construct'), $args); + } } class Derived_3 extends Base { - public function __construct() - { - $args = func_get_args(); - call_user_func_array('Base::__construct', $args); - } + public function __construct() + { + $args = func_get_args(); + call_user_func_array('Base::__construct', $args); + } } class Derived_4 extends Base { - public function __construct() - { - $args = func_get_args(); - call_user_func_array('parent::__construct', $args); - } + public function __construct() + { + $args = func_get_args(); + call_user_func_array('parent::__construct', $args); + } } class Derived_5 extends Base { - public function __construct() - { - $args = func_get_args(); - call_user_func_array(array('Base', '__construct'), $args); - } + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array('Base', '__construct'), $args); + } } class Derived_6 extends Base { - public function __construct() - { - $args = func_get_args(); - call_user_func_array(array('parent', '__construct'), $args); - } + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array('parent', '__construct'), $args); + } } new Derived_1('1'); diff --git a/ext/standard/tests/general_functions/bug41037.phpt b/ext/standard/tests/general_functions/bug41037.phpt index b9bb5856d819..c8d0a668d010 100644 --- a/ext/standard/tests/general_functions/bug41037.phpt +++ b/ext/standard/tests/general_functions/bug41037.phpt @@ -4,8 +4,8 @@ Bug #41037 (unregister_tick_function() inside the tick function crash PHP) array('pipe', 'rb'), - 1 => array('pipe', 'wb'), + 0 => array('pipe', 'rb'), + 1 => array('pipe', 'wb'), ); $proc = proc_open('cat', $descriptor_spec, $pipes); diff --git a/ext/standard/tests/general_functions/bug47857.phpt b/ext/standard/tests/general_functions/bug47857.phpt index c06673bc344d..0d2b35b09f78 100644 --- a/ext/standard/tests/general_functions/bug47857.phpt +++ b/ext/standard/tests/general_functions/bug47857.phpt @@ -3,9 +3,9 @@ Bug #47851 (is_callable throws fatal error) --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/general_functions/bug71891.phpt b/ext/standard/tests/general_functions/bug71891.phpt index b1f7e200d8d1..4de58f2c29bd 100644 --- a/ext/standard/tests/general_functions/bug71891.phpt +++ b/ext/standard/tests/general_functions/bug71891.phpt @@ -4,10 +4,10 @@ Bug #71891 (header_register_callback() and register_shutdown_function()) --EXPECT-- diff --git a/ext/standard/tests/general_functions/bug72306.phpt b/ext/standard/tests/general_functions/bug72306.phpt index 05c25e6f1e9f..761a6454b3b1 100644 --- a/ext/standard/tests/general_functions/bug72306.phpt +++ b/ext/standard/tests/general_functions/bug72306.phpt @@ -3,8 +3,8 @@ Bug #72306 (Heap overflow through proc_open and $env parameter) --FILE-- a = 0; } - function __toString() { return $this->a++ ? str_repeat("a", 0x8000) : "a"; } + function __construct() { $this->a = 0; } + function __toString() { return $this->a++ ? str_repeat("a", 0x8000) : "a"; } } $env = array('some_option' => new moo()); diff --git a/ext/standard/tests/general_functions/bug72920.phpt b/ext/standard/tests/general_functions/bug72920.phpt index d3508044fb1d..24a87249044b 100644 --- a/ext/standard/tests/general_functions/bug72920.phpt +++ b/ext/standard/tests/general_functions/bug72920.phpt @@ -3,7 +3,7 @@ Bug #72920 (Accessing a private constant using constant() creates an exception A --FILE-- 1, "key2 " => 3); diff --git a/ext/standard/tests/general_functions/escapeshellarg_variation1-win32.phpt b/ext/standard/tests/general_functions/escapeshellarg_variation1-win32.phpt index 1a3eadbb80b4..309eca316eda 100644 --- a/ext/standard/tests/general_functions/escapeshellarg_variation1-win32.phpt +++ b/ext/standard/tests/general_functions/escapeshellarg_variation1-win32.phpt @@ -69,9 +69,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of escapeshellarg() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(escapeshellarg($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(escapeshellarg($input)); + $iterator++; }; ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/escapeshellarg_variation1.phpt b/ext/standard/tests/general_functions/escapeshellarg_variation1.phpt index ba56db69ea5f..e2aec56c27a4 100644 --- a/ext/standard/tests/general_functions/escapeshellarg_variation1.phpt +++ b/ext/standard/tests/general_functions/escapeshellarg_variation1.phpt @@ -69,9 +69,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of escapeshellarg() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(escapeshellarg($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(escapeshellarg($input)); + $iterator++; }; ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt b/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt index 5254e5d57ad7..3f014fdf811b 100644 --- a/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt +++ b/ext/standard/tests/general_functions/escapeshellcmd-win32.phpt @@ -10,21 +10,21 @@ if( substr(PHP_OS, 0, 3) != 'WIN' ) { ', - '()[]{}$', - '%^', - '#&;`|*?', - '~<>\\', - '%NOENV%', - '!NOENV!' + '"abc', + "'abc", + '?<>', + '()[]{}$', + '%^', + '#&;`|*?', + '~<>\\', + '%NOENV%', + '!NOENV!' ); $count = 1; foreach ($data AS $value) { - echo "-- Test " . $count++ . " --\n"; - var_dump(escapeshellcmd($value)); + echo "-- Test " . $count++ . " --\n"; + var_dump(escapeshellcmd($value)); } echo "Done\n"; diff --git a/ext/standard/tests/general_functions/floatval.phpt b/ext/standard/tests/general_functions/floatval.phpt index f6f354509a6a..a409f92a752a 100644 --- a/ext/standard/tests/general_functions/floatval.phpt +++ b/ext/standard/tests/general_functions/floatval.phpt @@ -13,23 +13,23 @@ $valid_floats = array( 1.0, -1.0, 1.234, - -1.234, + -1.234, 1.2e3, - -1.2e3, - 10.0000000000000000005, - 10.5e+5, + -1.2e3, + 10.0000000000000000005, + 10.5e+5, 1e5, - -1e5, + -1e5, 1e-5, - -1e-1, - 1e+5, - -1e+5, - 1E5, - -1E5, - 1E+5, - -1E+5, - .5e+7, - -.5e+7 + -1e-1, + 1e+5, + -1e+5, + 1E5, + -1E5, + 1E+5, + -1E+5, + .5e+7, + -.5e+7 ); /* loop to check that floatval() recognizes different @@ -65,12 +65,12 @@ $not_float_types = array ( $dfp, "0.0", // string "1.0", - "-1.3e3", - "bob-1.3e3", + "-1.3e3", + "bob-1.3e3", "10 Some dollars", - "10.2 Some Dollars", - "10.0 dollar" + 1, - "10.0 dollar" + 1.0, + "10.2 Some Dollars", + "10.0 dollar" + 1, + "10.0 dollar" + 1.0, "", true, NULL, diff --git a/ext/standard/tests/general_functions/floatval_basic.phpt b/ext/standard/tests/general_functions/floatval_basic.phpt index dc1c547731ed..d6a3b72a19f3 100644 --- a/ext/standard/tests/general_functions/floatval_basic.phpt +++ b/ext/standard/tests/general_functions/floatval_basic.phpt @@ -14,23 +14,23 @@ $valid_floats = array( "1.0" => 1.0, "-1.0" => -1.0, "1.234" => 1.234, - "-1.234" => -1.234, + "-1.234" => -1.234, "1.2e3" => 1.2e3, - "-1.2e3" => -1.2e3, - "10.0000000000000000005" => 10.0000000000000000005, - "10.5e+5" => 10.5e+5, + "-1.2e3" => -1.2e3, + "10.0000000000000000005" => 10.0000000000000000005, + "10.5e+5" => 10.5e+5, "1e5" => 1e5, - "-1e5" => -1e5, + "-1e5" => -1e5, "1e5" => 1e-5, - "-1e-1" => -1e-1, - "1e+5" => 1e+5, - "-1e+5" =>-1e+5, - "1E5" => 1E5, - "-1E5" => -1E5, - "1E+5" => 1E+5, - "-1E5" => -1E+5, - ".5e+7" => .5e+7, - "-.5e+7" =>-.5e+7 + "-1e-1" => -1e-1, + "1e+5" => 1e+5, + "-1e+5" =>-1e+5, + "1E5" => 1E5, + "-1E5" => -1E5, + "1E+5" => 1E+5, + "-1E5" => -1E+5, + ".5e+7" => .5e+7, + "-.5e+7" =>-.5e+7 ); /* loop to check that floatval() recognizes different diff --git a/ext/standard/tests/general_functions/floatval_variation1.phpt b/ext/standard/tests/general_functions/floatval_variation1.phpt index 098c4ad252c3..e688253e3f64 100644 --- a/ext/standard/tests/general_functions/floatval_variation1.phpt +++ b/ext/standard/tests/general_functions/floatval_variation1.phpt @@ -22,12 +22,12 @@ $not_float_types = array ( "directory resource" => $dfp, "\"0.0\"" => "0.0", // string "\"1.0\"" => "1.0", - "\"-1.3e3\"" => "-1.3e3", - "\"bob-1.3e3\"" => "bob-1.3e3", + "\"-1.3e3\"" => "-1.3e3", + "\"bob-1.3e3\"" => "bob-1.3e3", "\"10 Some dollars\"" => "10 Some dollars", - "\"10.2 Some Dollars\"" => "10.2 Some Dollars", - "\"10.0 dollar\" + 1" => "10.0 dollar" + 1, - "\"10.0 dollar\" + 1.0" => "10.0 dollar" + 1.0, + "\"10.2 Some Dollars\"" => "10.2 Some Dollars", + "\"10.0 dollar\" + 1" => "10.0 dollar" + 1, + "\"10.0 dollar\" + 1.0" => "10.0 dollar" + 1.0, "\"\"" => "", "true" => true, "NULL" => NULL, diff --git a/ext/standard/tests/general_functions/get_defined_constants_basic.phpt b/ext/standard/tests/general_functions/get_defined_constants_basic.phpt index 2aee70e6d004..7876540e8a71 100644 --- a/ext/standard/tests/general_functions/get_defined_constants_basic.phpt +++ b/ext/standard/tests/general_functions/get_defined_constants_basic.phpt @@ -22,9 +22,9 @@ $arr2 = get_defined_constants(); $n2 = count($arr2); if ($n2 == $n1 + 1 && array_key_exists("USER_CONSTANT", $arr2)) { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } else { - echo "TEST FAILED\n"; + echo "TEST FAILED\n"; } ?> diff --git a/ext/standard/tests/general_functions/get_defined_vars_basic.phpt b/ext/standard/tests/general_functions/get_defined_vars_basic.phpt index 7f2b7a180e7e..19b59fea9600 100644 --- a/ext/standard/tests/general_functions/get_defined_vars_basic.phpt +++ b/ext/standard/tests/general_functions/get_defined_vars_basic.phpt @@ -15,7 +15,7 @@ function f1() { $vars = get_defined_vars(); if (count($vars) != 0) { - echo "TEST FAILED\n"; + echo "TEST FAILED\n"; } echo "\n-- ..define some local variables --\n"; @@ -33,7 +33,7 @@ function f2() { $vars= get_defined_vars(); if (count($vars) != 0) { - echo "TEST FAILED\n"; + echo "TEST FAILED\n"; } echo "\n-- ...define some variables --\n"; diff --git a/ext/standard/tests/general_functions/get_include_path_basic.phpt b/ext/standard/tests/general_functions/get_include_path_basic.phpt index 809faf694d6e..bb7ccf542bb7 100644 --- a/ext/standard/tests/general_functions/get_include_path_basic.phpt +++ b/ext/standard/tests/general_functions/get_include_path_basic.phpt @@ -14,9 +14,9 @@ echo "*** Testing get_include_path()\n"; var_dump(get_include_path()); if (ini_get("include_path") == get_include_path()) { - echo "PASSED\n"; + echo "PASSED\n"; } else { - echo "FAILED\n"; + echo "FAILED\n"; } ?> diff --git a/ext/standard/tests/general_functions/getopt.phpt b/ext/standard/tests/general_functions/getopt.phpt index 67864e9a9602..4424072d1a3b 100644 --- a/ext/standard/tests/general_functions/getopt.phpt +++ b/ext/standard/tests/general_functions/getopt.phpt @@ -7,7 +7,7 @@ register_argc_argv=On variables_order=GPS --FILE-- --EXPECT-- array(5) { diff --git a/ext/standard/tests/general_functions/getopt_002.phpt b/ext/standard/tests/general_functions/getopt_002.phpt index 1bf65e70abbd..6ae2d3cb3dbc 100644 --- a/ext/standard/tests/general_functions/getopt_002.phpt +++ b/ext/standard/tests/general_functions/getopt_002.phpt @@ -7,7 +7,7 @@ register_argc_argv=On variables_order=GPS --FILE-- --EXPECT-- array(4) { diff --git a/ext/standard/tests/general_functions/getopt_003.phpt b/ext/standard/tests/general_functions/getopt_003.phpt index e1a514606510..e40de84674ae 100644 --- a/ext/standard/tests/general_functions/getopt_003.phpt +++ b/ext/standard/tests/general_functions/getopt_003.phpt @@ -7,7 +7,7 @@ register_argc_argv=On variables_order=GPS --FILE-- --EXPECT-- array(7) { diff --git a/ext/standard/tests/general_functions/getopt_004.phpt b/ext/standard/tests/general_functions/getopt_004.phpt index ac0aafe27b66..5e8e810d3853 100644 --- a/ext/standard/tests/general_functions/getopt_004.phpt +++ b/ext/standard/tests/general_functions/getopt_004.phpt @@ -7,7 +7,7 @@ register_argc_argv=On variables_order=GPS --FILE-- --EXPECT-- array(1) { diff --git a/ext/standard/tests/general_functions/getopt_005.phpt b/ext/standard/tests/general_functions/getopt_005.phpt index 3fa1791eab50..d75c4709eacf 100644 --- a/ext/standard/tests/general_functions/getopt_005.phpt +++ b/ext/standard/tests/general_functions/getopt_005.phpt @@ -7,7 +7,7 @@ register_argc_argv=On variables_order=GPS --FILE-- --EXPECT-- array(2) { diff --git a/ext/standard/tests/general_functions/getrusage_basic.phpt b/ext/standard/tests/general_functions/getrusage_basic.phpt index 7aaacd51a053..b057b57fae7b 100644 --- a/ext/standard/tests/general_functions/getrusage_basic.phpt +++ b/ext/standard/tests/general_functions/getrusage_basic.phpt @@ -15,7 +15,7 @@ echo "Simple testcase for getrusage() function\n"; $dat = getrusage(); if (!is_array($dat)) { - echo "TEST FAILED : getrusage should return an array\n"; + echo "TEST FAILED : getrusage should return an array\n"; } // echo the fields which are common to all platforms diff --git a/ext/standard/tests/general_functions/getservbyname_basic.phpt b/ext/standard/tests/general_functions/getservbyname_basic.phpt index adaa7afb4399..edc210fc3957 100644 --- a/ext/standard/tests/general_functions/getservbyname_basic.phpt +++ b/ext/standard/tests/general_functions/getservbyname_basic.phpt @@ -8,12 +8,12 @@ Simone Gentili (sensorario@gmail.com) --FILE-- diff --git a/ext/standard/tests/general_functions/getservbyport_basic.phpt b/ext/standard/tests/general_functions/getservbyport_basic.phpt index b9e0f83c9873..cc02a4508e58 100644 --- a/ext/standard/tests/general_functions/getservbyport_basic.phpt +++ b/ext/standard/tests/general_functions/getservbyport_basic.phpt @@ -7,21 +7,21 @@ Michele Orselli (mo@ideato.it) Simone Gentili (sensorario@gmail.com) --FILE-- --EXPECT-- PASS diff --git a/ext/standard/tests/general_functions/getservbyport_variation1.phpt b/ext/standard/tests/general_functions/getservbyport_variation1.phpt index f387161bf4fc..349fe16a945c 100644 --- a/ext/standard/tests/general_functions/getservbyport_variation1.phpt +++ b/ext/standard/tests/general_functions/getservbyport_variation1.phpt @@ -9,11 +9,11 @@ Michele Orselli (mo@ideato.it) Simone Gentili (sensorario@gmail.com) --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/general_functions/intval_variation1.phpt b/ext/standard/tests/general_functions/intval_variation1.phpt index 470fa036301b..c968b39a90a1 100644 --- a/ext/standard/tests/general_functions/intval_variation1.phpt +++ b/ext/standard/tests/general_functions/intval_variation1.phpt @@ -12,10 +12,10 @@ echo "*** Testing intval() : usage variation ***\n"; // Define error handler function test_error_handler($err_no, $err_msg, $filename, $linenum) { - if (error_reporting() & $err_no) { - // report non-silenced errors - echo "Error: $err_no - $err_msg, $filename($linenum)\n"; - } + if (error_reporting() & $err_no) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } } set_error_handler('test_error_handler'); @@ -29,9 +29,9 @@ unset ($unset_var); // define some classes class classWithToString { - public function __toString() { - return "Class A object"; - } + public function __toString() { + return "Class A object"; + } } class classWithoutToString diff --git a/ext/standard/tests/general_functions/is_resource.phpt b/ext/standard/tests/general_functions/is_resource.phpt index 2717e3fa4382..ff6f1fd4227e 100644 --- a/ext/standard/tests/general_functions/is_resource.phpt +++ b/ext/standard/tests/general_functions/is_resource.phpt @@ -2,9 +2,9 @@ Bug #27822 (is_resource() returns TRUE for closed resources) --FILE-- --EXPECT-- bool(false) diff --git a/ext/standard/tests/general_functions/is_resource_basic.phpt b/ext/standard/tests/general_functions/is_resource_basic.phpt index f8e9ff6369cb..06988850ee00 100644 --- a/ext/standard/tests/general_functions/is_resource_basic.phpt +++ b/ext/standard/tests/general_functions/is_resource_basic.phpt @@ -11,39 +11,39 @@ echo "*** Testing is_resource() : basic functionality ***\n"; class Hello { public function SayHello($arg) { - echo "Hello\n"; + echo "Hello\n"; } } $vars = array( - false, - true, - 10, - 10.5, - "Helo World", - array(1,2,3,4,5), - NULL, - new Hello()); + false, + true, + 10, + 10.5, + "Helo World", + array(1,2,3,4,5), + NULL, + new Hello()); $types = array( - "bool=false", - "bool=true", - "integer", - "double", - "string", - "array", - "NULL", - "object"); + "bool=false", + "bool=true", + "integer", + "double", + "string", + "array", + "NULL", + "object"); echo "\nNon-resource type cases\n"; for ($i=0; $i < count($vars); $i++) { - if (is_resource($vars[$i])) { - echo $types[$i]. " test returns TRUE\n"; - } else { - echo $types[$i]. " test returns FALSE\n"; - } + if (is_resource($vars[$i])) { + echo $types[$i]. " test returns TRUE\n"; + } else { + echo $types[$i]. " test returns FALSE\n"; + } } $res = fopen(__FILE__, "r"); @@ -51,9 +51,9 @@ echo "\nResource type..var_dump after file open returns\n"; var_dump($res); echo "Resource type..after file open is_resource() returns"; if (is_resource($res)) { - echo " TRUE\n"; + echo " TRUE\n"; } else { - echo " FALSE\n"; + echo " FALSE\n"; } fclose($res); @@ -61,9 +61,9 @@ echo "\nResource type..var_dump after file close returns\n"; var_dump($res); echo "Resource type..after file close is_resource() returns"; if (is_resource($res)) { - echo " TRUE\n"; + echo " TRUE\n"; } else { - echo " FALSE\n"; + echo " FALSE\n"; } diff --git a/ext/standard/tests/general_functions/is_string.phpt b/ext/standard/tests/general_functions/is_string.phpt index a062cc17e108..7760f7983186 100644 --- a/ext/standard/tests/general_functions/is_string.phpt +++ b/ext/standard/tests/general_functions/is_string.phpt @@ -17,7 +17,7 @@ EOT; /* heredoc string with only numerics */ $heredoc_numeric_string = << $l) { - if (!$n || empty($l)) { - continue; - } + foreach ($t as $n => $l) { + if (!$n || empty($l)) { + continue; + } - $d = []; + $d = []; - foreach ($m as $c) { - $d[] = (int) substr($l, $c + 1, strpos($l, ' ', $c + 2) - ($c + 1)); - } + foreach ($m as $c) { + $d[] = (int) substr($l, $c + 1, strpos($l, ' ', $c + 2) - ($c + 1)); + } - if ($d[0] === $pid) { - return $d[1]; - } - } + if ($d[0] === $pid) { + return $d[1]; + } + } - return false; + return false; } $p = [ - /* '' => ['', ''] */ + /* '' => ['', ''] */ - 'Idle' => [4, 10], - 'Below normal' => [6, 5], - 'Normal' => [8, 0], - 'Above normal' => [10, -5], - 'High priority' => [13, -10] - ]; + 'Idle' => [4, 10], + 'Below normal' => [6, 5], + 'Normal' => [8, 0], + 'Above normal' => [10, -5], + 'High priority' => [13, -10] + ]; foreach ($p as $test => $data) { - printf('Testing \'%s\' (%d): ', $test, $data[1]); + printf('Testing \'%s\' (%d): ', $test, $data[1]); - proc_nice($data[1]); + proc_nice($data[1]); - print (($wp = get_priority_from_wmic()) === $data[0] ? 'Passed' : 'Failed (' . $wp . ')') . PHP_EOL; + print (($wp = get_priority_from_wmic()) === $data[0] ? 'Passed' : 'Failed (' . $wp . ')') . PHP_EOL; } ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/proc_nice_basic.phpt b/ext/standard/tests/general_functions/proc_nice_basic.phpt index d14a5f62a942..687152ee100a 100644 --- a/ext/standard/tests/general_functions/proc_nice_basic.phpt +++ b/ext/standard/tests/general_functions/proc_nice_basic.phpt @@ -12,21 +12,21 @@ if(substr(strtoupper(PHP_OS), 0, 3) == 'WIN') die('skip. not for Windows'); ?> --FILE-- 2) - return $matches[2]; - else - return -1; - } - $delta = 10; - $pid = getmypid(); - $niceBefore = getNice($pid); - proc_nice($delta); - $niceAfter = getNice($pid); - var_dump($niceBefore == ($niceAfter - $delta)); + function getNice($id) + { + $res = shell_exec('ps -p ' . $id .' -o "pid,nice"'); + preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches); + if (count($matches) > 2) + return $matches[2]; + else + return -1; + } + $delta = 10; + $pid = getmypid(); + $niceBefore = getNice($pid); + proc_nice($delta); + $niceAfter = getNice($pid); + var_dump($niceBefore == ($niceAfter - $delta)); ?> --EXPECT-- bool(true) diff --git a/ext/standard/tests/general_functions/proc_open-mb0.phpt b/ext/standard/tests/general_functions/proc_open-mb0.phpt index 672a8cd35756..c97ebda9702d 100644 --- a/ext/standard/tests/general_functions/proc_open-mb0.phpt +++ b/ext/standard/tests/general_functions/proc_open-mb0.phpt @@ -13,24 +13,24 @@ $f = __DIR__ . DIRECTORY_SEPARATOR . "proc_only_mb0.php"; file_put_contents($f,''); $ds = array( - 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") - ); + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") + ); $p = proc_open( - "$php -n $f テストマルãƒãƒã‚¤ãƒˆãƒ»ãƒ‘ス füße карамба", - $ds, - $pipes, - NULL, - NULL, - array("bypass_shell" => true) - ); + "$php -n $f テストマルãƒãƒã‚¤ãƒˆãƒ»ãƒ‘ス füße карамба", + $ds, + $pipes, + NULL, + NULL, + array("bypass_shell" => true) + ); $out = ""; while (!feof($pipes[1])) { - $out .= fread($pipes[1], 1024); + $out .= fread($pipes[1], 1024); } proc_close($p); diff --git a/ext/standard/tests/general_functions/proc_open-mb1.phpt b/ext/standard/tests/general_functions/proc_open-mb1.phpt index af46346fbbc0..8a735cf306ed 100644 --- a/ext/standard/tests/general_functions/proc_open-mb1.phpt +++ b/ext/standard/tests/general_functions/proc_open-mb1.phpt @@ -13,21 +13,21 @@ $f = __DIR__ . DIRECTORY_SEPARATOR . "proc_only_mb1.php"; file_put_contents($f,''); $ds = array( - 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") - ); + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") + ); $p = proc_open( - "$php -n $f テストマルãƒãƒã‚¤ãƒˆãƒ»ãƒ‘ス füße карамба", - $ds, - $pipes - ); + "$php -n $f テストマルãƒãƒã‚¤ãƒˆãƒ»ãƒ‘ス füße карамба", + $ds, + $pipes + ); $out = ""; while (!feof($pipes[1])) { - $out .= fread($pipes[1], 1024); + $out .= fread($pipes[1], 1024); } proc_close($p); diff --git a/ext/standard/tests/general_functions/proc_open.phpt b/ext/standard/tests/general_functions/proc_open.phpt index 4d0a21d1658e..cf0bffffb5bc 100644 --- a/ext/standard/tests/general_functions/proc_open.phpt +++ b/ext/standard/tests/general_functions/proc_open.phpt @@ -8,16 +8,16 @@ if (!function_exists("proc_open")) echo "skip proc_open() is not available"; --FILE-- array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") - ); + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") + ); $cat = proc_open( - "/bin/cat", - $ds, - $pipes - ); + "/bin/cat", + $ds, + $pipes + ); proc_close($cat); diff --git a/ext/standard/tests/general_functions/proc_open02.phpt b/ext/standard/tests/general_functions/proc_open02.phpt index d5d878ed241b..a81ce5934fc7 100644 --- a/ext/standard/tests/general_functions/proc_open02.phpt +++ b/ext/standard/tests/general_functions/proc_open02.phpt @@ -10,9 +10,9 @@ if (getenv('SKIP_SLOW_TESTS')) echo 'skip slow test'; $ds = array(array('pipe', 'r')); $cat = proc_open( - '/bin/sleep 2', - $ds, - $pipes + '/bin/sleep 2', + $ds, + $pipes ); usleep(20000); // let the OS run the sleep process before sending the signal diff --git a/ext/standard/tests/general_functions/proc_open_pipes1.phpt b/ext/standard/tests/general_functions/proc_open_pipes1.phpt index dd0550f7fd39..076b8c941e2c 100644 --- a/ext/standard/tests/general_functions/proc_open_pipes1.phpt +++ b/ext/standard/tests/general_functions/proc_open_pipes1.phpt @@ -4,7 +4,7 @@ proc_open() with > 16 pipes = $sleeplow) { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } else { - echo "TEST FAILED - time is ${time} secs and sleep was ${sleeptime} secs\n"; + echo "TEST FAILED - time is ${time} secs and sleep was ${sleeptime} secs\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/general_functions/type.phpt b/ext/standard/tests/general_functions/type.phpt index 342b353baf78..a32e4b44a1d0 100644 --- a/ext/standard/tests/general_functions/type.phpt +++ b/ext/standard/tests/general_functions/type.phpt @@ -4,7 +4,7 @@ gettype(), settype() and friends getMessage(), "\n"; - } - var_dump($var); - } + foreach ($array as $var) { + try { + var_dump(settype($var, $type)); + } catch (Error $e) { + echo "Error: ", $e->getMessage(), "\n"; + } + var_dump($var); + } } echo "Done\n"; diff --git a/ext/standard/tests/general_functions/uniqid_basic.phpt b/ext/standard/tests/general_functions/uniqid_basic.phpt index 66cfdf8f9766..6bfc478fad4d 100644 --- a/ext/standard/tests/general_functions/uniqid_basic.phpt +++ b/ext/standard/tests/general_functions/uniqid_basic.phpt @@ -18,19 +18,19 @@ echo "uniqid() with a prefix\n"; // Use a fixed prefix so we can ensure length of o/p id is fixed $prefix = array ( - 99999, - "99999", - 10.5e2, - null, - true, - false - ); + 99999, + "99999", + 10.5e2, + null, + true, + false + ); for ($i = 0; $i < count($prefix); $i++) { - var_dump(uniqid($prefix[$i])); - var_dump(uniqid($prefix[$i], true)); - var_dump(uniqid($prefix[$i], false)); - echo "\n"; + var_dump(uniqid($prefix[$i])); + var_dump(uniqid($prefix[$i], true)); + var_dump(uniqid($prefix[$i], false)); + echo "\n"; } ?> diff --git a/ext/standard/tests/general_functions/usleep_basic.phpt b/ext/standard/tests/general_functions/usleep_basic.phpt index d057d47c115b..c2af61f8a260 100644 --- a/ext/standard/tests/general_functions/usleep_basic.phpt +++ b/ext/standard/tests/general_functions/usleep_basic.phpt @@ -30,9 +30,9 @@ $time = ($time_end - $time_start) * 1000 * 1000; $summary = "Thread slept for " . $time . " micro-seconds\n"; if ($time >= $sleeplow) { - echo "TEST PASSED: $summary"; + echo "TEST PASSED: $summary"; } else { - echo "TEST FAILED: $summary"; + echo "TEST FAILED: $summary"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/general_functions/var_export-locale.phpt b/ext/standard/tests/general_functions/var_export-locale.phpt index 351200662481..bdc61d992848 100644 --- a/ext/standard/tests/general_functions/var_export-locale.phpt +++ b/ext/standard/tests/general_functions/var_export-locale.phpt @@ -58,12 +58,12 @@ $counter++; echo "*** Testing var_export() with valid boolean values ***\n"; // different valid boolean values $valid_bool = array( - 1, - TRUE, + 1, + TRUE, true, 0, - FALSE, - false + FALSE, + false ); $counter = 1; /* Loop to check for above boolean values with var_export() */ diff --git a/ext/standard/tests/general_functions/var_export-locale_32.phpt b/ext/standard/tests/general_functions/var_export-locale_32.phpt index baaddcefaee6..d64fa3b8d78b 100644 --- a/ext/standard/tests/general_functions/var_export-locale_32.phpt +++ b/ext/standard/tests/general_functions/var_export-locale_32.phpt @@ -58,12 +58,12 @@ $counter++; echo "*** Testing var_export() with valid boolean values ***\n"; // different valid boolean values $valid_bool = array( - 1, - TRUE, + 1, + TRUE, true, 0, - FALSE, - false + FALSE, + false ); $counter = 1; /* Loop to check for above boolean values with var_export() */ diff --git a/ext/standard/tests/general_functions/var_export_basic1.phpt b/ext/standard/tests/general_functions/var_export_basic1.phpt index f97fab239609..27c56a7b8f13 100644 --- a/ext/standard/tests/general_functions/var_export_basic1.phpt +++ b/ext/standard/tests/general_functions/var_export_basic1.phpt @@ -40,12 +40,12 @@ $valid_ints = array( /* Loop to check for above integer values with var_export() */ echo "\n*** Output for integer values ***\n"; foreach($valid_ints as $key => $int_value) { - echo "\n-- Iteration: $key --\n"; - var_export( $int_value ); - echo "\n"; - var_export( $int_value, FALSE); - echo "\n"; - var_dump( var_export( $int_value, TRUE) ); + echo "\n-- Iteration: $key --\n"; + var_export( $int_value ); + echo "\n"; + var_export( $int_value, FALSE); + echo "\n"; + var_dump( var_export( $int_value, TRUE) ); } ?> diff --git a/ext/standard/tests/general_functions/var_export_basic1_32.phpt b/ext/standard/tests/general_functions/var_export_basic1_32.phpt index 7473fbd8a3f3..0eb6ce889f4b 100644 --- a/ext/standard/tests/general_functions/var_export_basic1_32.phpt +++ b/ext/standard/tests/general_functions/var_export_basic1_32.phpt @@ -40,12 +40,12 @@ $valid_ints = array( /* Loop to check for above integer values with var_export() */ echo "\n*** Output for integer values ***\n"; foreach($valid_ints as $key => $int_value) { - echo "\n-- Iteration: $key --\n"; - var_export( $int_value ); - echo "\n"; - var_export( $int_value, FALSE); - echo "\n"; - var_dump( var_export( $int_value, TRUE) ); + echo "\n-- Iteration: $key --\n"; + var_export( $int_value ); + echo "\n"; + var_export( $int_value, FALSE); + echo "\n"; + var_dump( var_export( $int_value, TRUE) ); } ?> diff --git a/ext/standard/tests/general_functions/var_export_basic2.phpt b/ext/standard/tests/general_functions/var_export_basic2.phpt index 87e92f20fd65..1698a2800110 100644 --- a/ext/standard/tests/general_functions/var_export_basic2.phpt +++ b/ext/standard/tests/general_functions/var_export_basic2.phpt @@ -12,24 +12,24 @@ Test var_export() function with valid boolean values echo "*** Testing var_export() with valid boolean values ***\n"; // different valid boolean values $valid_bool = array( - "1" => 1, - "TRUE" => TRUE, + "1" => 1, + "TRUE" => TRUE, "true" => true, "0" => 0, - "FALSE" => FALSE, - "false" => false + "FALSE" => FALSE, + "false" => false ); /* Loop to check for above boolean values with var_export() */ echo "\n*** Output for boolean values ***\n"; foreach($valid_bool as $key => $bool_value) { - echo "\n-- Iteration: $key --\n"; - var_export( $bool_value ); - echo "\n"; - var_export( $bool_value, FALSE); - echo "\n"; - var_dump( var_export( $bool_value, TRUE) ); - echo "\n"; + echo "\n-- Iteration: $key --\n"; + var_export( $bool_value ); + echo "\n"; + var_export( $bool_value, FALSE); + echo "\n"; + var_dump( var_export( $bool_value, TRUE) ); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/var_export_basic3.phpt b/ext/standard/tests/general_functions/var_export_basic3.phpt index 38618faea9d2..92d5bbbe7680 100644 --- a/ext/standard/tests/general_functions/var_export_basic3.phpt +++ b/ext/standard/tests/general_functions/var_export_basic3.phpt @@ -13,37 +13,37 @@ serialize_precision=17 echo "*** Testing var_export() with valid float values ***\n"; // different valid float values $valid_floats = array( - "-2147483649" => (float)-2147483649, // float value - "2147483648" => (float)2147483648, // float value - "-0x80000001" => (float)-0x80000001, // float value, beyond max negative int - "0x800000001" => (float)0x800000001, // float value, beyond max positive int - "020000000001" => (float)020000000001, // float value, beyond max positive int - "-020000000001" => (float)-020000000001, // float value, beyond max negative int - "0.0" => 0.0, - "-0.1" => -0.1, - "10.0000000000000000005" => 10.0000000000000000005, - "10.5e+5" => 10.5e+5, - "1e5" => 1e5, - "1e-5" => 1e-5, - "1e+5" => 1e+5, - "1E5" => 1E5, - "1E+5" => 1E+5, - "1E-5" => 1E-5, - ".5e+7" => .5e+7, - ".6e-19" => .6e-19, - ".05E+44" => .05E+44, - ".0034E-30" => .0034E-30 + "-2147483649" => (float)-2147483649, // float value + "2147483648" => (float)2147483648, // float value + "-0x80000001" => (float)-0x80000001, // float value, beyond max negative int + "0x800000001" => (float)0x800000001, // float value, beyond max positive int + "020000000001" => (float)020000000001, // float value, beyond max positive int + "-020000000001" => (float)-020000000001, // float value, beyond max negative int + "0.0" => 0.0, + "-0.1" => -0.1, + "10.0000000000000000005" => 10.0000000000000000005, + "10.5e+5" => 10.5e+5, + "1e5" => 1e5, + "1e-5" => 1e-5, + "1e+5" => 1e+5, + "1E5" => 1E5, + "1E+5" => 1E+5, + "1E-5" => 1E-5, + ".5e+7" => .5e+7, + ".6e-19" => .6e-19, + ".05E+44" => .05E+44, + ".0034E-30" => .0034E-30 ); /* Loop to check for above float values with var_export() */ echo "\n*** Output for float values ***\n"; foreach($valid_floats as $key => $float_value) { - echo "\n-- Iteration: $key --\n"; - var_export( $float_value ); - echo "\n"; - var_export( $float_value, FALSE); - echo "\n"; - var_dump( var_export( $float_value, TRUE) ); - echo "\n"; + echo "\n-- Iteration: $key --\n"; + var_export( $float_value ); + echo "\n"; + var_export( $float_value, FALSE); + echo "\n"; + var_dump( var_export( $float_value, TRUE) ); + echo "\n"; } ?> diff --git a/ext/standard/tests/general_functions/var_export_basic4.phpt b/ext/standard/tests/general_functions/var_export_basic4.phpt index c1b7b8cb5b04..789140d255b5 100644 --- a/ext/standard/tests/general_functions/var_export_basic4.phpt +++ b/ext/standard/tests/general_functions/var_export_basic4.phpt @@ -33,13 +33,13 @@ $valid_strings = array( /* Loop to check for above strings with var_export() */ echo "\n*** Output for strings ***\n"; foreach($valid_strings as $key => $str) { - echo "\n-- Iteration: $key --\n"; - var_export( $str ); - echo "\n"; - var_export( $str, FALSE); - echo "\n"; - var_dump( var_export( $str, TRUE) ); - echo "\n"; + echo "\n-- Iteration: $key --\n"; + var_export( $str ); + echo "\n"; + var_export( $str, FALSE); + echo "\n"; + var_dump( var_export( $str, TRUE) ); + echo "\n"; } ?> diff --git a/ext/standard/tests/general_functions/var_export_basic5.phpt b/ext/standard/tests/general_functions/var_export_basic5.phpt index 989197a23d3b..731e84ff990a 100644 --- a/ext/standard/tests/general_functions/var_export_basic5.phpt +++ b/ext/standard/tests/general_functions/var_export_basic5.phpt @@ -34,13 +34,13 @@ $valid_arrays = array( /* Loop to check for above arrays with var_export() */ echo "\n*** Output for arrays ***\n"; foreach($valid_arrays as $key => $arr) { - echo "\n--Iteration: $key --\n"; - var_export( $arr ); - echo "\n"; - var_export( $arr, FALSE); - echo "\n"; - var_dump( var_export( $arr, TRUE) ); - echo "\n"; + echo "\n--Iteration: $key --\n"; + var_export( $arr ); + echo "\n"; + var_export( $arr, FALSE); + echo "\n"; + var_dump( var_export( $arr, TRUE) ); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/var_export_basic6.phpt b/ext/standard/tests/general_functions/var_export_basic6.phpt index a120f2fd1a6a..4d09f0a79447 100644 --- a/ext/standard/tests/general_functions/var_export_basic6.phpt +++ b/ext/standard/tests/general_functions/var_export_basic6.phpt @@ -92,13 +92,13 @@ $valid_objects = array( /* Loop to check for above objects with var_export() */ echo "\n*** Output for objects ***\n"; foreach($valid_objects as $key => $obj) { - echo "\n-- Iteration: $key --\n"; - var_export( $obj ); - echo "\n"; - var_export( $obj, FALSE); - echo "\n"; - var_dump( var_export( $obj, TRUE) ); - echo "\n"; + echo "\n-- Iteration: $key --\n"; + var_export( $obj ); + echo "\n"; + var_export( $obj, FALSE); + echo "\n"; + var_dump( var_export( $obj, TRUE) ); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/var_export_basic7.phpt b/ext/standard/tests/general_functions/var_export_basic7.phpt index 928721b926b3..f9a68f0f132b 100644 --- a/ext/standard/tests/general_functions/var_export_basic7.phpt +++ b/ext/standard/tests/general_functions/var_export_basic7.phpt @@ -24,13 +24,13 @@ $valid_nulls = array( /* Loop to check for above null values with var_export() */ echo "\n*** Output for null values ***\n"; foreach($valid_nulls as $key => $null_value) { - echo "\n-- Iteration: $key --\n"; - var_export( $null_value ); - echo "\n"; - var_export( $null_value, FALSE); - echo "\n"; - var_dump( var_export( $null_value, true) ); - echo "\n"; + echo "\n-- Iteration: $key --\n"; + var_export( $null_value ); + echo "\n"; + var_export( $null_value, FALSE); + echo "\n"; + var_dump( var_export( $null_value, true) ); + echo "\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/general_functions/var_export_basic9.phpt b/ext/standard/tests/general_functions/var_export_basic9.phpt index fd78c18c8e9a..26815bec1b9c 100644 --- a/ext/standard/tests/general_functions/var_export_basic9.phpt +++ b/ext/standard/tests/general_functions/var_export_basic9.phpt @@ -2,9 +2,9 @@ Bug #55082: var_export() doesn't escape properties properly --FILE-- {'\'\\'} = 7; - echo var_export($x); + $x = new stdClass(); + $x->{'\'\\'} = 7; + echo var_export($x); --EXPECT-- (object) array( '\'\\' => 7, diff --git a/ext/standard/tests/hrtime/hrtime.phpt b/ext/standard/tests/hrtime/hrtime.phpt index bac127bf44e1..9cd31435b8ac 100644 --- a/ext/standard/tests/hrtime/hrtime.phpt +++ b/ext/standard/tests/hrtime/hrtime.phpt @@ -16,9 +16,9 @@ $d1 = $h1 - $h0; $d = abs($d0 - $d1)/$d1; if ($d > 0.05) { - print "FAIL, $d"; + print "FAIL, $d"; } else { - print "OK, $d"; + print "OK, $d"; } ?> diff --git a/ext/standard/tests/http/bug38802.phpt b/ext/standard/tests/http/bug38802.phpt index 53a607655d31..77fa16b5e4e5 100644 --- a/ext/standard/tests/http/bug38802.phpt +++ b/ext/standard/tests/http/bug38802.phpt @@ -10,31 +10,31 @@ require 'server.inc'; function do_test($context_options) { - $context = stream_context_create(array('http' => $context_options)); + $context = stream_context_create(array('http' => $context_options)); - $responses = array( - "data://text/plain,HTTP/1.0 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar2\r\n\r\n1", - "data://text/plain,HTTP/1.0 301 Moved Permanently\r\nLocation: http://127.0.0.1:12342/foo/bar3\r\n\r\n", - "data://text/plain,HTTP/1.0 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar4\r\n\r\n3", - "data://text/plain,HTTP/1.0 200 OK\r\n\r\ndone.", - ); + $responses = array( + "data://text/plain,HTTP/1.0 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar2\r\n\r\n1", + "data://text/plain,HTTP/1.0 301 Moved Permanently\r\nLocation: http://127.0.0.1:12342/foo/bar3\r\n\r\n", + "data://text/plain,HTTP/1.0 302 Moved Temporarily\r\nLocation: http://127.0.0.1:12342/foo/bar4\r\n\r\n3", + "data://text/plain,HTTP/1.0 200 OK\r\n\r\ndone.", + ); - $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); + $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); - $fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context); - var_dump($fd); + $fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context); + var_dump($fd); - if ($fd) { - $meta_data = stream_get_meta_data($fd); - var_dump($meta_data['wrapper_data']); + if ($fd) { + $meta_data = stream_get_meta_data($fd); + var_dump($meta_data['wrapper_data']); - var_dump(stream_get_contents($fd)); - } + var_dump(stream_get_contents($fd)); + } - fseek($output, 0, SEEK_SET); - var_dump(stream_get_contents($output)); + fseek($output, 0, SEEK_SET); + var_dump(stream_get_contents($output)); - http_server_kill($pid); + http_server_kill($pid); } echo "-- Test: follow all redirections --\n"; diff --git a/ext/standard/tests/http/bug43510.phpt b/ext/standard/tests/http/bug43510.phpt index d97361237206..45ba4fb20f44 100644 --- a/ext/standard/tests/http/bug43510.phpt +++ b/ext/standard/tests/http/bug43510.phpt @@ -9,17 +9,17 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", - "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", + "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", + "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", ); $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); foreach(array('r', 'rb') as $mode) { - $fd = fopen('http://127.0.0.1:12342/', $mode, false); - $meta = stream_get_meta_data($fd); - var_dump($meta['mode']); - fclose($fd); + $fd = fopen('http://127.0.0.1:12342/', $mode, false); + $meta = stream_get_meta_data($fd); + var_dump($meta['mode']); + fclose($fd); } http_server_kill($pid); diff --git a/ext/standard/tests/http/bug47021.phpt b/ext/standard/tests/http/bug47021.phpt index f3db3e1be239..b3acd1bc3ad0 100644 --- a/ext/standard/tests/http/bug47021.phpt +++ b/ext/standard/tests/http/bug47021.phpt @@ -13,7 +13,7 @@ function stream_notification_callback($notification_code, $severity, $message, $ switch($notification_code) { case STREAM_NOTIFY_MIME_TYPE_IS: echo "Type='$message'\n"; - break; + break; case STREAM_NOTIFY_FILE_SIZE_IS: echo "Size=$bytes_max\n"; break; diff --git a/ext/standard/tests/http/bug48929.phpt b/ext/standard/tests/http/bug48929.phpt index b31ed292befa..9a769d8674b4 100644 --- a/ext/standard/tests/http/bug48929.phpt +++ b/ext/standard/tests/http/bug48929.phpt @@ -10,24 +10,24 @@ require 'server.inc'; function do_test($context_options) { - $context = stream_context_create(array('http' => $context_options)); + $context = stream_context_create(array('http' => $context_options)); - $responses = array( - "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", - ); + $responses = array( + "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", + ); - $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); + $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); - foreach($responses as $r) { + foreach($responses as $r) { - $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context); + $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context); - fseek($output, 0, SEEK_SET); - var_dump(stream_get_contents($output)); - fseek($output, 0, SEEK_SET); - } + fseek($output, 0, SEEK_SET); + var_dump(stream_get_contents($output)); + fseek($output, 0, SEEK_SET); + } - http_server_kill($pid); + http_server_kill($pid); } echo "-- Test: requests with 'header' as array --\n"; diff --git a/ext/standard/tests/http/bug53198.phpt b/ext/standard/tests/http/bug53198.phpt index 2585c3df6e2e..add07c3f472f 100644 --- a/ext/standard/tests/http/bug53198.phpt +++ b/ext/standard/tests/http/bug53198.phpt @@ -11,22 +11,22 @@ require 'server.inc'; function do_test() { - $responses = array( - "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", - ); + $responses = array( + "data://text/plain,HTTP/1.0 200 OK\r\n\r\n", + ); - $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); + $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); - foreach($responses as $r) { + foreach($responses as $r) { - $fd = fopen('http://127.0.0.1:12342/', 'rb', false); + $fd = fopen('http://127.0.0.1:12342/', 'rb', false); - fseek($output, 0, SEEK_SET); - var_dump(stream_get_contents($output)); - fseek($output, 0, SEEK_SET); - } + fseek($output, 0, SEEK_SET); + var_dump(stream_get_contents($output)); + fseek($output, 0, SEEK_SET); + } - http_server_kill($pid); + http_server_kill($pid); } diff --git a/ext/standard/tests/http/bug60570.phpt b/ext/standard/tests/http/bug60570.phpt index b72011d5e2f3..3c16d7803313 100644 --- a/ext/standard/tests/http/bug60570.phpt +++ b/ext/standard/tests/http/bug60570.phpt @@ -10,30 +10,30 @@ require 'server.inc'; function do_test() { - $responses = array( - "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", - "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", - "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n" - ); + $responses = array( + "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", + "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", + "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n" + ); - $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); + $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); - $a = $b = count(get_resources()); + $a = $b = count(get_resources()); - $i = 3; - while ($i--) { - $context = stream_context_create(array('http'=>array('timeout'=>1))); - file_get_contents('http://127.0.0.1:12342/', 0, $context); - unset($context); + $i = 3; + while ($i--) { + $context = stream_context_create(array('http'=>array('timeout'=>1))); + file_get_contents('http://127.0.0.1:12342/', 0, $context); + unset($context); - $b = $a; - $a = count(get_resources()); - } + $b = $a; + $a = count(get_resources()); + } - http_server_kill($pid); + http_server_kill($pid); - echo "leak? penultimate iteration: $b, last one: $a\n"; - var_dump($a == $b); + echo "leak? penultimate iteration: $b, last one: $a\n"; + var_dump($a == $b); } do_test(); diff --git a/ext/standard/tests/http/bug61548.phpt b/ext/standard/tests/http/bug61548.phpt index 38b2bbf08675..04ea55341b72 100644 --- a/ext/standard/tests/http/bug61548.phpt +++ b/ext/standard/tests/http/bug61548.phpt @@ -11,8 +11,8 @@ require 'server.inc'; function do_test($header) { $options = [ 'http' => [ - 'method' => 'POST', - 'header' => $header, + 'method' => 'POST', + 'header' => $header, 'follow_location' => true, ], ]; @@ -20,9 +20,9 @@ function do_test($header) { $ctx = stream_context_create($options); $responses = [ - "data://text/plain,HTTP/1.1 201\r\nLocation: /foo\r\n\r\n", - "data://text/plain,HTTP/1.1 200\r\nConnection: close\r\n\r\n", - ]; + "data://text/plain,HTTP/1.1 201\r\nLocation: /foo\r\n\r\n", + "data://text/plain,HTTP/1.1 200\r\nConnection: close\r\n\r\n", + ]; $pid = http_server('tcp://127.0.0.1:12342', $responses, $output); $fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx); diff --git a/ext/standard/tests/http/bug69337.phpt b/ext/standard/tests/http/bug69337.phpt index c9c2a199dd79..7136ff474d3c 100644 --- a/ext/standard/tests/http/bug69337.phpt +++ b/ext/standard/tests/http/bug69337.phpt @@ -10,8 +10,8 @@ require 'server.inc'; function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) { - if($notification_code == STREAM_NOTIFY_REDIRECTED) { - // $http_response_header is now a string, but will be used as an array + if($notification_code == STREAM_NOTIFY_REDIRECTED) { + // $http_response_header is now a string, but will be used as an array // by php_stream_url_wrap_http_ex() later on $GLOBALS['http_response_header'] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\0\0\0\0"; } @@ -21,8 +21,8 @@ $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); $responses = array( - "data://text/plain,HTTP/1.0 302 Found\r\nLocation: http://127.0.0.1:22345/try-again\r\n\r\n", - "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", + "data://text/plain,HTTP/1.0 302 Found\r\nLocation: http://127.0.0.1:22345/try-again\r\n\r\n", + "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", ); $pid = http_server("tcp://127.0.0.1:22345", $responses, $output); diff --git a/ext/standard/tests/http/bug75535.phpt b/ext/standard/tests/http/bug75535.phpt index 57a75a3ee5e2..236a96820c8c 100644 --- a/ext/standard/tests/http/bug75535.phpt +++ b/ext/standard/tests/http/bug75535.phpt @@ -9,7 +9,7 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 200 Ok\r\nContent-Length\r\n", + "data://text/plain,HTTP/1.0 200 Ok\r\nContent-Length\r\n", ); $pid = http_server("tcp://127.0.0.1:22351", $responses, $output); diff --git a/ext/standard/tests/http/bug75981.phpt b/ext/standard/tests/http/bug75981.phpt index d415de66b900..52a560cfbc20 100644 --- a/ext/standard/tests/http/bug75981.phpt +++ b/ext/standard/tests/http/bug75981.phpt @@ -18,7 +18,7 @@ $options = [ $ctx = stream_context_create($options); $responses = [ - "data://text/plain,000000000100\xA\xA" + "data://text/plain,000000000100\xA\xA" ]; $pid = http_server('tcp://127.0.0.1:12342', $responses); diff --git a/ext/standard/tests/http/http_response_header_01.phpt b/ext/standard/tests/http/http_response_header_01.phpt index 9772c09b02ef..05037f24b1f7 100644 --- a/ext/standard/tests/http/http_response_header_01.phpt +++ b/ext/standard/tests/http/http_response_header_01.phpt @@ -9,7 +9,7 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 200 Ok\r\nSome: Header\r\nSome: Header\r\n\r\nBody", + "data://text/plain,HTTP/1.0 200 Ok\r\nSome: Header\r\nSome: Header\r\n\r\nBody", ); $pid = http_server("tcp://127.0.0.1:22346", $responses, $output); diff --git a/ext/standard/tests/http/http_response_header_02.phpt b/ext/standard/tests/http/http_response_header_02.phpt index 0868672b0176..873a8621a516 100644 --- a/ext/standard/tests/http/http_response_header_02.phpt +++ b/ext/standard/tests/http/http_response_header_02.phpt @@ -9,7 +9,7 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 302 Found\r\n" + "data://text/plain,HTTP/1.0 302 Found\r\n" . "Some: Header\r\nLocation: http://127.0.0.1:22347/try-again\r\n\r\n", "data://test/plain,HTTP/1.0 200 Ok\r\nSome: Header\r\n\r\nBody", ); diff --git a/ext/standard/tests/http/http_response_header_03.phpt b/ext/standard/tests/http/http_response_header_03.phpt index 1b743259add8..832382de237a 100644 --- a/ext/standard/tests/http/http_response_header_03.phpt +++ b/ext/standard/tests/http/http_response_header_03.phpt @@ -9,7 +9,7 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 302 Found\r\n" + "data://text/plain,HTTP/1.0 302 Found\r\n" . "Some: Header\r\nLocation: http://127.0.0.1:22348/try-again\r\n\r\n", "data://test/plain,HTTP/1.0 404 Not Found\r\nSome: Header\r\n\r\nBody", ); diff --git a/ext/standard/tests/http/http_response_header_04.phpt b/ext/standard/tests/http/http_response_header_04.phpt index 0d518327aaa4..89a4d466fd68 100644 --- a/ext/standard/tests/http/http_response_header_04.phpt +++ b/ext/standard/tests/http/http_response_header_04.phpt @@ -9,7 +9,7 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 200 Ok\r\nSome: Header \r\n\r\nBody", + "data://text/plain,HTTP/1.0 200 Ok\r\nSome: Header \r\n\r\nBody", ); $pid = http_server("tcp://127.0.0.1:22349", $responses, $output); diff --git a/ext/standard/tests/http/http_response_header_05.phpt b/ext/standard/tests/http/http_response_header_05.phpt index 97c275413dd2..372de1163d09 100644 --- a/ext/standard/tests/http/http_response_header_05.phpt +++ b/ext/standard/tests/http/http_response_header_05.phpt @@ -9,7 +9,7 @@ allow_url_fopen=1 require 'server.inc'; $responses = array( - "data://text/plain,HTTP/1.0 200 Ok\r\n \r\n\r\nBody", + "data://text/plain,HTTP/1.0 200 Ok\r\n \r\n\r\nBody", ); $pid = http_server("tcp://127.0.0.1:22350", $responses, $output); diff --git a/ext/standard/tests/http/ignore_errors.phpt b/ext/standard/tests/http/ignore_errors.phpt index 176d6dd2ce3c..38a1cf698537 100644 --- a/ext/standard/tests/http/ignore_errors.phpt +++ b/ext/standard/tests/http/ignore_errors.phpt @@ -10,33 +10,33 @@ require 'server.inc'; function do_test($context_options) { - $context = stream_context_create(array('http' => $context_options)); + $context = stream_context_create(array('http' => $context_options)); - $responses = array( - "data://text/plain,HTTP/1.0 200 Ok\r\nX-Foo: bar\r\n\r\n1", - "data://text/plain,HTTP/1.0 404 Not found\r\nX-bar: baz\r\n\r\n2", - ); + $responses = array( + "data://text/plain,HTTP/1.0 200 Ok\r\nX-Foo: bar\r\n\r\n1", + "data://text/plain,HTTP/1.0 404 Not found\r\nX-bar: baz\r\n\r\n2", + ); - $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); + $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); - foreach($responses as $r) { + foreach($responses as $r) { - $fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context); - var_dump($fd); + $fd = fopen('http://127.0.0.1:12342/foo/bar', 'rb', false, $context); + var_dump($fd); - if ($fd) { - $meta_data = stream_get_meta_data($fd); - var_dump($meta_data['wrapper_data']); + if ($fd) { + $meta_data = stream_get_meta_data($fd); + var_dump($meta_data['wrapper_data']); - var_dump(stream_get_contents($fd)); - } + var_dump(stream_get_contents($fd)); + } - fseek($output, 0, SEEK_SET); - var_dump(stream_get_contents($output)); - fseek($output, 0, SEEK_SET); - } + fseek($output, 0, SEEK_SET); + var_dump(stream_get_contents($output)); + fseek($output, 0, SEEK_SET); + } - http_server_kill($pid); + http_server_kill($pid); } echo "-- Test: requests without ignore_errors --\n"; diff --git a/ext/standard/tests/http/server.inc b/ext/standard/tests/http/server.inc index e58067492891..81cc131a8a56 100644 --- a/ext/standard/tests/http/server.inc +++ b/ext/standard/tests/http/server.inc @@ -2,34 +2,34 @@ function http_server_skipif($socket_string) { - if (!function_exists('pcntl_fork')) die('skip pcntl_fork() not available'); - if (!function_exists('posix_kill')) die('skip posix_kill() not available'); - if (!stream_socket_server($socket_string)) die('skip stream_socket_server() failed'); + if (!function_exists('pcntl_fork')) die('skip pcntl_fork() not available'); + if (!function_exists('posix_kill')) die('skip posix_kill() not available'); + if (!stream_socket_server($socket_string)) die('skip stream_socket_server() failed'); } function http_server_init($socket_string, &$output = null) { - pcntl_alarm(60); - - $server = stream_socket_server($socket_string, $errno, $errstr); - if (!$server) { - return false; - } - - if ($output === null) { - $output = tmpfile(); - if ($output === false) { - return false; - } - } - - $pid = pcntl_fork(); - if ($pid == -1) { - die('could not fork'); - } else if ($pid) { - return $pid; - } - - return $server; + pcntl_alarm(60); + + $server = stream_socket_server($socket_string, $errno, $errstr); + if (!$server) { + return false; + } + + if ($output === null) { + $output = tmpfile(); + if ($output === false) { + return false; + } + } + + $pid = pcntl_fork(); + if ($pid == -1) { + die('could not fork'); + } else if ($pid) { + return $pid; + } + + return $server; } /* Minimal HTTP server with predefined responses. @@ -40,79 +40,79 @@ function http_server_init($socket_string, &$output = null) { */ function http_server($socket_string, array $files, &$output = null) { - if (!is_resource($server = http_server_init($socket_string, $output))) { - return $server; - } + if (!is_resource($server = http_server_init($socket_string, $output))) { + return $server; + } - foreach($files as $file) { + foreach($files as $file) { - $sock = stream_socket_accept($server); - if (!$sock) { - exit(1); - } + $sock = stream_socket_accept($server); + if (!$sock) { + exit(1); + } - // read headers + // read headers - $content_length = 0; + $content_length = 0; - stream_set_blocking($sock, 0); - while (!feof($sock)) { + stream_set_blocking($sock, 0); + while (!feof($sock)) { - list($r, $w, $e) = array(array($sock), null, null); - if (!stream_select($r, $w, $e, 1)) continue; + list($r, $w, $e) = array(array($sock), null, null); + if (!stream_select($r, $w, $e, 1)) continue; - $line = stream_get_line($sock, 8192, "\r\n"); - if ($line === '') { - fwrite($output, "\r\n"); - break; - } else if ($line !== false) { - fwrite($output, "$line\r\n"); + $line = stream_get_line($sock, 8192, "\r\n"); + if ($line === '') { + fwrite($output, "\r\n"); + break; + } else if ($line !== false) { + fwrite($output, "$line\r\n"); - if (preg_match('#^Content-Length\s*:\s*([[:digit:]]+)\s*$#i', $line, $matches)) { - $content_length = (int) $matches[1]; - } - } - } - stream_set_blocking($sock, 1); + if (preg_match('#^Content-Length\s*:\s*([[:digit:]]+)\s*$#i', $line, $matches)) { + $content_length = (int) $matches[1]; + } + } + } + stream_set_blocking($sock, 1); - // read content + // read content - if ($content_length > 0) { - stream_copy_to_stream($sock, $output, $content_length); - } + if ($content_length > 0) { + stream_copy_to_stream($sock, $output, $content_length); + } - // send response + // send response - $fd = fopen($file, 'rb'); - stream_copy_to_stream($fd, $sock); + $fd = fopen($file, 'rb'); + stream_copy_to_stream($fd, $sock); - fclose($sock); - } + fclose($sock); + } - exit(0); + exit(0); } function http_server_sleep($socket_string, $micro_seconds = 500000) { - if (!is_resource($server = http_server_init($socket_string, $output))) { - return $server; - } + if (!is_resource($server = http_server_init($socket_string, $output))) { + return $server; + } - $sock = stream_socket_accept($server); - if (!$sock) { - exit(1); - } + $sock = stream_socket_accept($server); + if (!$sock) { + exit(1); + } - usleep($micro_seconds); + usleep($micro_seconds); - fclose($sock); + fclose($sock); - exit(0); + exit(0); } function http_server_kill($pid) { - posix_kill($pid, SIGTERM); - pcntl_waitpid($pid, $status); + posix_kill($pid, SIGTERM); + pcntl_waitpid($pid, $status); } ?> diff --git a/ext/standard/tests/image/getimagesize.phpt b/ext/standard/tests/image/getimagesize.phpt index db8213b7dca5..ed32ac7c0e91 100644 --- a/ext/standard/tests/image/getimagesize.phpt +++ b/ext/standard/tests/image/getimagesize.phpt @@ -6,21 +6,21 @@ GetImageSize() ?> --FILE-- --EXPECT-- array(16) { diff --git a/ext/standard/tests/image/getimagesize_246x247.phpt b/ext/standard/tests/image/getimagesize_246x247.phpt index 5908671f1c79..0e1290fcf25d 100644 --- a/ext/standard/tests/image/getimagesize_246x247.phpt +++ b/ext/standard/tests/image/getimagesize_246x247.phpt @@ -6,21 +6,21 @@ GetImageSize() with 246x247 pixels ?> --FILE-- --EXPECT-- array(1) { diff --git a/ext/standard/tests/image/getimagesize_384x385.phpt b/ext/standard/tests/image/getimagesize_384x385.phpt index 9ed110422003..cef9d73b3fd0 100644 --- a/ext/standard/tests/image/getimagesize_384x385.phpt +++ b/ext/standard/tests/image/getimagesize_384x385.phpt @@ -6,21 +6,21 @@ GetImageSize() with 384x385 pixels ?> --FILE-- --EXPECT-- array(1) { diff --git a/ext/standard/tests/image/getimagesize_jpgapp.phpt b/ext/standard/tests/image/getimagesize_jpgapp.phpt index 74fd4e57d784..b4c6413a08a6 100644 --- a/ext/standard/tests/image/getimagesize_jpgapp.phpt +++ b/ext/standard/tests/image/getimagesize_jpgapp.phpt @@ -19,7 +19,7 @@ $arr['APP1'] = "and this too"; getimagesize( __DIR__."/testAPP.jpg", $arr); foreach ($arr as $key => $value) { - echo "$key - length: ". strlen($value) ."; md5: " . md5($value) . "\n" ; + echo "$key - length: ". strlen($value) ."; md5: " . md5($value) . "\n" ; } ?> diff --git a/ext/standard/tests/image/getimagesize_swc.phpt b/ext/standard/tests/image/getimagesize_swc.phpt index 5e79a5d0a298..bba67d4f0995 100644 --- a/ext/standard/tests/image/getimagesize_swc.phpt +++ b/ext/standard/tests/image/getimagesize_swc.phpt @@ -8,7 +8,7 @@ GetImageSize() for compressed swf files ?> --FILE-- --EXPECT-- array(5) { diff --git a/ext/standard/tests/image/getimagesize_variation2.phpt b/ext/standard/tests/image/getimagesize_variation2.phpt index 6419881abc2b..7799303c6286 100644 --- a/ext/standard/tests/image/getimagesize_variation2.phpt +++ b/ext/standard/tests/image/getimagesize_variation2.phpt @@ -9,7 +9,7 @@ Test getimagesize() function : usage variations - unexpected type for arg 2 */ function test_error_handler($err_no, $err_msg, $filename, $linenum) { - echo "Error: $err_no - $err_msg\n"; + echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); diff --git a/ext/standard/tests/image/getimagesize_variation3.phpt b/ext/standard/tests/image/getimagesize_variation3.phpt index f65869af9e96..b50e822d7042 100644 --- a/ext/standard/tests/image/getimagesize_variation3.phpt +++ b/ext/standard/tests/image/getimagesize_variation3.phpt @@ -10,10 +10,10 @@ Test getimagesize() function : variation - Passing non image files $file_types_array = array ( //File containing text string - "File with text data" => "test.txt", + "File with text data" => "test.txt", - //File containing forcibly corrupted bmp image - "File with corrupted BMP data" => "200x100_unknown.unknown", + //File containing forcibly corrupted bmp image + "File with corrupted BMP data" => "200x100_unknown.unknown", //File which doesn't exist "Non-existent file" => "nofile.ext", diff --git a/ext/standard/tests/image/image_type_to_mime_type.phpt b/ext/standard/tests/image/image_type_to_mime_type.phpt index b1781aac2b7c..aff49ae58f21 100644 --- a/ext/standard/tests/image/image_type_to_mime_type.phpt +++ b/ext/standard/tests/image/image_type_to_mime_type.phpt @@ -6,22 +6,22 @@ image_type_to_mime_type() ?> --FILE-- --EXPECT-- array(16) { diff --git a/ext/standard/tests/image/image_type_to_mime_type_basic.phpt b/ext/standard/tests/image/image_type_to_mime_type_basic.phpt index 40b5a077259d..684056459ef9 100644 --- a/ext/standard/tests/image/image_type_to_mime_type_basic.phpt +++ b/ext/standard/tests/image/image_type_to_mime_type_basic.phpt @@ -12,28 +12,28 @@ image_type_to_mime_type() echo "Starting image_type_to_mime_type() test\n\n"; $image_types = array ( - IMAGETYPE_GIF, - IMAGETYPE_JPEG, - IMAGETYPE_PNG, - IMAGETYPE_SWF, - IMAGETYPE_PSD, - IMAGETYPE_BMP, - IMAGETYPE_TIFF_II, - IMAGETYPE_TIFF_MM, - IMAGETYPE_JPC, - IMAGETYPE_JP2, - IMAGETYPE_JPX, - IMAGETYPE_JB2, - IMAGETYPE_IFF, - IMAGETYPE_WBMP, - IMAGETYPE_JPEG2000, - IMAGETYPE_XBM, - IMAGETYPE_WEBP + IMAGETYPE_GIF, + IMAGETYPE_JPEG, + IMAGETYPE_PNG, + IMAGETYPE_SWF, + IMAGETYPE_PSD, + IMAGETYPE_BMP, + IMAGETYPE_TIFF_II, + IMAGETYPE_TIFF_MM, + IMAGETYPE_JPC, + IMAGETYPE_JP2, + IMAGETYPE_JPX, + IMAGETYPE_JB2, + IMAGETYPE_IFF, + IMAGETYPE_WBMP, + IMAGETYPE_JPEG2000, + IMAGETYPE_XBM, + IMAGETYPE_WEBP ); - foreach($image_types as $image_type) { - var_dump(image_type_to_mime_type($image_type)); - } + foreach($image_types as $image_type) { + var_dump(image_type_to_mime_type($image_type)); + } echo "\nDone image_type_to_mime_type() test\n"; ?> diff --git a/ext/standard/tests/mail/mail_basic7.phpt b/ext/standard/tests/mail/mail_basic7.phpt index c01fb5fe25e6..9c9c61d835e4 100644 --- a/ext/standard/tests/mail/mail_basic7.phpt +++ b/ext/standard/tests/mail/mail_basic7.phpt @@ -22,13 +22,13 @@ $to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = array( - 'KHeaders' => 'aaaa', - 'bcc'=>'foo@bar', - 'foo'=> - array( - "bar\r\n hoge", - "bar\r\n\t fuga", - ), + 'KHeaders' => 'aaaa', + 'bcc'=>'foo@bar', + 'foo'=> + array( + "bar\r\n hoge", + "bar\r\n\t fuga", + ), ); $outFile = "mailBasic7.out"; @unlink($outFile); @@ -48,14 +48,14 @@ $subject = 'Test Subject'; $message = 'A Message'; // Headers should not have array values $additional_headers = array( - 'orig-date' => array('foo1'), - 'from' => array('foo2'), - 'sender' => array('foo3'), - 'reply-to' => array('foo4'), - 'to' => array('foo5'), - 'bcc' => array('foo6'), - 'message-id' => array('foo7'), - 'in-reply-to'=> array('foo8'), + 'orig-date' => array('foo1'), + 'from' => array('foo2'), + 'sender' => array('foo3'), + 'reply-to' => array('foo4'), + 'to' => array('foo5'), + 'bcc' => array('foo6'), + 'message-id' => array('foo7'), + 'in-reply-to'=> array('foo8'), ); $outFile = "mailBasic7.out"; @unlink($outFile); @@ -74,13 +74,13 @@ $to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = array( - 'foo1' => array('foo1'=>'bar1'), - 'foo2' => array('foo2', array('foo3')), - 'foo3' => array(123), - 'foo4' => array(123.456), - 'foo5' => array(FALSE), - 'foo6' => array(NULL), - 'foo7' => array(new StdClass), + 'foo1' => array('foo1'=>'bar1'), + 'foo2' => array('foo2', array('foo3')), + 'foo3' => array(123), + 'foo4' => array(123.456), + 'foo5' => array(FALSE), + 'foo6' => array(NULL), + 'foo7' => array(new StdClass), ); $outFile = "mailBasic7.out"; @unlink($outFile); @@ -99,16 +99,16 @@ $to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = array( - '*:foo1' => array('bar1'), - 'foo2:::' => array('bar1'), - 'foo3()' => array('bar1'), - 'foo4@' => array('bar1'), - 'foo5|' => array('bar1'), - "\0foo6" => array('bar1'), - "foo7\0" => array('bar1'), - "foo8" => array(), - "foo9" => '%&$#!', - "foo10" => "abc\0\tdef", + '*:foo1' => array('bar1'), + 'foo2:::' => array('bar1'), + 'foo3()' => array('bar1'), + 'foo4@' => array('bar1'), + 'foo5|' => array('bar1'), + "\0foo6" => array('bar1'), + "foo7\0" => array('bar1'), + "foo8" => array(), + "foo9" => '%&$#!', + "foo10" => "abc\0\tdef", ); $outFile = "mailBasic7.out"; @unlink($outFile); diff --git a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt index c48634e99c76..5952a14f59ab 100644 --- a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt @@ -38,48 +38,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt index 3aff59a614aa..8c7a28983cea 100644 --- a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt @@ -35,48 +35,48 @@ $extra_headers = "from: user@example.com"; $res = mail($to, $subject, $message, $extra_headers); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt index 52d48937ed10..15fb701e28fa 100644 --- a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt @@ -35,48 +35,48 @@ $extra_headers = "FRom: user@example.com"; $res = mail($to, $subject, $message, $extra_headers); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt index a677312442e5..96c6fb11f5e2 100644 --- a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt @@ -36,48 +36,48 @@ $extra_parameters = "addons"; // should be ignored $res = mail($to, $subject, $message, $extra_headers, $extra_parameters); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_include.inc b/ext/standard/tests/mail/mail_include.inc index ba7ee121b5fb..c69d4a7182bd 100644 --- a/ext/standard/tests/mail/mail_include.inc +++ b/ext/standard/tests/mail/mail_include.inc @@ -18,32 +18,32 @@ $mailbox_prefix = "phpttest"; // name used for test mailbox * @return IMAP stream to new mailbox on success; FALSE on failure */ function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = null, $msg_type = "simple"){ - global $server, $default_mailbox, $username, $password; + global $server, $default_mailbox, $username, $password; - // open a stream to default mailbox - $imap_stream = imap_open($default_mailbox, $username, $password); + // open a stream to default mailbox + $imap_stream = imap_open($default_mailbox, $username, $password); - if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; - } + if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; + } - echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; - $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); - if ($new_mailbox === false) { - echo "Can't create a temporary mailbox: " . imap_last_error(). "\n"; - return false; - } + echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; + $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); + if ($new_mailbox === false) { + echo "Can't create a temporary mailbox: " . imap_last_error(). "\n"; + return false; + } - echo ".. mailbox '$new_mailbox' created\n"; + echo ".. mailbox '$new_mailbox' created\n"; - // reopen stream to new mailbox - if (imap_reopen($imap_stream, $new_mailbox) === false) { - echo "can't re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; - return false; - } + // reopen stream to new mailbox + if (imap_reopen($imap_stream, $new_mailbox) === false) { + echo "can't re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; + return false; + } - return $imap_stream; + return $imap_stream; } /** @@ -53,30 +53,30 @@ function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = nul * @param string $mailbox */ function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type= "simple"){ - global $default_mailbox, $mailbox_prefix; - $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; - - $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); - - // check mailbox does not already exist - if ($mailboxes) { - foreach($mailboxes as $value) { - if ($value->name == $mailbox) { - exit ("TEST FAILED : Mailbox '$mailbox' already exists\n"); - } - } - } - - if (imap_createmailbox($imap_stream, $mailbox) === false) { - return false; - } - - // Add number of test msgs requested - if ($message_count > 0) { - populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type); - } - - return $mailbox; + global $default_mailbox, $mailbox_prefix; + $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; + + $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); + + // check mailbox does not already exist + if ($mailboxes) { + foreach($mailboxes as $value) { + if ($value->name == $mailbox) { + exit ("TEST FAILED : Mailbox '$mailbox' already exists\n"); + } + } + } + + if (imap_createmailbox($imap_stream, $mailbox) === false) { + return false; + } + + // Add number of test msgs requested + if ($message_count > 0) { + populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type); + } + + return $mailbox; } /** @@ -87,48 +87,48 @@ function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type */ function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "simple"){ - global $users, $domain; - - for($i = 1; $i <= $message_count; $i++) { - if ($msg_type == "simple") { - $msg = "From: foo@anywhere.com\r\n" - . "To: $users[0]@$domain\r\n" - . "Subject: test$i\r\n" - . "\r\n" - . "$i: this is a test message, please ignore\r\n"; - } else { - $envelope["from"]= "foo@anywhere.com"; - $envelope["to"] = "$users[0]@$domain"; - $envelope["subject"] = "Test msg $i"; - - $part1["type"] = TYPEMULTIPART; - $part1["subtype"] = "mixed"; - - $part2["type"] = TYPETEXT; - $part2["subtype"] = "plain"; - $part2["description"] = "imap_mail_compose() function"; - $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; - - $part3["type"] = TYPETEXT; - $part3["subtype"] = "plain"; - $part3["description"] = "Example"; - $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; - - $part4["type"] = TYPETEXT; - $part4["subtype"] = "plain"; - $part4["description"] = "Return Values"; - $part4["contents.data"] = "message 3:zzzzzzzzzzzzzzzzzzzzzzzzzz"; - - $body[1] = $part1; - $body[2] = $part2; - $body[3] = $part3; - $body[4] = $part4; - - $msg = imap_mail_compose($envelope, $body); - } - - imap_append($imap_stream, $mailbox, $msg); - } + global $users, $domain; + + for($i = 1; $i <= $message_count; $i++) { + if ($msg_type == "simple") { + $msg = "From: foo@anywhere.com\r\n" + . "To: $users[0]@$domain\r\n" + . "Subject: test$i\r\n" + . "\r\n" + . "$i: this is a test message, please ignore\r\n"; + } else { + $envelope["from"]= "foo@anywhere.com"; + $envelope["to"] = "$users[0]@$domain"; + $envelope["subject"] = "Test msg $i"; + + $part1["type"] = TYPEMULTIPART; + $part1["subtype"] = "mixed"; + + $part2["type"] = TYPETEXT; + $part2["subtype"] = "plain"; + $part2["description"] = "imap_mail_compose() function"; + $part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx"; + + $part3["type"] = TYPETEXT; + $part3["subtype"] = "plain"; + $part3["description"] = "Example"; + $part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"; + + $part4["type"] = TYPETEXT; + $part4["subtype"] = "plain"; + $part4["description"] = "Return Values"; + $part4["contents.data"] = "message 3:zzzzzzzzzzzzzzzzzzzzzzzzzz"; + + $body[1] = $part1; + $body[2] = $part2; + $body[3] = $part3; + $body[4] = $part4; + + $msg = imap_mail_compose($envelope, $body); + } + + imap_append($imap_stream, $mailbox, $msg); + } } /** @@ -139,12 +139,12 @@ function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "s */ function get_mailbox_name($mailbox){ - if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { - echo "Unrecpognized mailbox name\n"; - return false; - } + if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { + echo "Unrecpognized mailbox name\n"; + return false; + } - return $match[1]; + return $match[1]; } ?> diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt index e60aa621b0e9..4f9e9423f4d1 100644 --- a/ext/standard/tests/mail/mail_log.phpt +++ b/ext/standard/tests/mail/mail_log.phpt @@ -9,7 +9,7 @@ date_default_timezone_set("UTC"); $logfile = ini_get("mail.log"); if (file_exists($logfile)) { - unlink($logfile); + unlink($logfile); } touch($logfile); clearstatcache(); diff --git a/ext/standard/tests/mail/mail_skipif.inc b/ext/standard/tests/mail/mail_skipif.inc index fedcfbbe4e4a..8f2468581d06 100644 --- a/ext/standard/tests/mail/mail_skipif.inc +++ b/ext/standard/tests/mail/mail_skipif.inc @@ -2,13 +2,13 @@ extension_loaded('imap') or die('skip imap extension not available in this build'); if( substr(PHP_OS, 0, 3) == 'WIN' && extension_loaded('sockets')) { - // be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f, - // the code below didn't skip test even though there was no mail server - // test then failed (no mail server to test against) - $socket = socket_create(AF_INET, SOCK_RAW, 1); - socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 10)); - // imap uses tcp port 143 - socket_connect($socket, "localhost", 143) or die ("skip can't socket to mail server"); + // be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f, + // the code below didn't skip test even though there was no mail server + // test then failed (no mail server to test against) + $socket = socket_create(AF_INET, SOCK_RAW, 1); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 10)); + // imap uses tcp port 143 + socket_connect($socket, "localhost", 143) or die ("skip can't socket to mail server"); } // Change these to make tests run successfully @@ -20,7 +20,7 @@ $retries = 0; // don't retry connect on failure $mbox = imap_open($mailbox, $username, $password, $options, $retries); if (!$mbox) { - die("skip could not connect to mailbox $mailbox"); + die("skip could not connect to mailbox $mailbox"); } imap_close($mbox); ?> diff --git a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt index 92a59477d0d6..155dc9815a6f 100644 --- a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt @@ -37,48 +37,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST COMPLETED : Unable to send test email\n"); + exit("TEST COMPLETED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt index 06c16eb5f8c7..36d971329f45 100644 --- a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt @@ -37,48 +37,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST COMPLETED : Unable to send test email\n"); + exit("TEST COMPLETED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_variation_alt3-win32.phpt b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt index 44eda4555b53..96d5d796bb0c 100644 --- a/ext/standard/tests/mail/mail_variation_alt3-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt @@ -36,48 +36,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST COMPLETED : Unable to send test email\n"); + exit("TEST COMPLETED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $current_msg_count = imap_check($imap_stream)->Nmsgs; - // Iterate over recent msgs to find the one we sent above - for ($i = 1; $i <= $current_msg_count; $i++) { - // get hdr details - $hdr = imap_headerinfo($imap_stream, $i); + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); - if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { - echo "Id of msg just sent is $i\n"; - echo ".. delete it\n"; - imap_delete($imap_stream, $i); - $found = true; - break; - } - } + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } - $repeat_count -= 1; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/math/abs.phpt b/ext/standard/tests/math/abs.phpt index af8732811d95..f1ff71b6f2ed 100644 --- a/ext/standard/tests/math/abs.phpt +++ b/ext/standard/tests/math/abs.phpt @@ -6,7 +6,7 @@ Simple math tests define('LONG_MAX', is_int(5000000000)? 9223372036854775807 : 0x7FFFFFFF); define('LONG_MIN', -LONG_MAX - 1); printf("%d,%d,%d,%d\n",is_int(LONG_MIN ),is_int(LONG_MAX ), - is_int(LONG_MIN-1),is_int(LONG_MAX+1)); + is_int(LONG_MIN-1),is_int(LONG_MAX+1)); $tests = << --EXPECT-- diff --git a/ext/standard/tests/math/abs_variation.phpt b/ext/standard/tests/math/abs_variation.phpt index f27a73559aef..854cb71181e7 100644 --- a/ext/standard/tests/math/abs_variation.phpt +++ b/ext/standard/tests/math/abs_variation.phpt @@ -72,13 +72,13 @@ $inputs = array( // loop through each element of $inputs to check the behavior of abs() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(abs($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(abs($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); diff --git a/ext/standard/tests/math/acos_basic.phpt b/ext/standard/tests/math/acos_basic.phpt index 6f73d40f4074..4f7962ce5eb0 100644 --- a/ext/standard/tests/math/acos_basic.phpt +++ b/ext/standard/tests/math/acos_basic.phpt @@ -19,20 +19,20 @@ echo "acos .5 = "; $acosv1 = 360.0 * acos(0.5) / (2.0 * M_PI ); var_dump($acosv1); if (allowed_rounding_error($acosv1 ,60 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "acos 0.86602540378444 = "; $acosv2 = 360.0 * acos(0.86602540378444) / (2.0 * M_PI ); var_dump($acosv2); if (allowed_rounding_error($acosv2 ,30 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } @@ -40,10 +40,10 @@ echo "acos 1.0 = "; $acosv3 = 360.0 * acos(1.0) / (2.0 * M_PI); var_dump($acosv3); if (allowed_rounding_error($acosv3 ,0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } @@ -51,10 +51,10 @@ echo "acos 0.0 = "; $acosv4 = 360.0 * acos(0.0) / (2.0 * M_PI ); var_dump($acosv4); if (allowed_rounding_error($acosv3 ,0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/acos_variation.phpt b/ext/standard/tests/math/acos_variation.phpt index 4fe8437fd581..20065d62eb3f 100644 --- a/ext/standard/tests/math/acos_variation.phpt +++ b/ext/standard/tests/math/acos_variation.phpt @@ -13,23 +13,23 @@ precision=10 //Test acos with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = acos($values[$i]); - var_dump($res); + $res = acos($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/acosh_basic.phpt b/ext/standard/tests/math/acosh_basic.phpt index a9ba199df5ec..aed150cba84b 100644 --- a/ext/standard/tests/math/acosh_basic.phpt +++ b/ext/standard/tests/math/acosh_basic.phpt @@ -16,20 +16,20 @@ echo "acosh 1.1276259652064= "; var_dump(acosh(1.1276259652064)); if (allowed_rounding_error(acosh(1.1276259652064), 0.5)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "acosh 10.067661995778= "; var_dump(acosh(10.067661995778)); if (allowed_rounding_error(acosh(10.067661995778), 3.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } diff --git a/ext/standard/tests/math/acosh_variation.phpt b/ext/standard/tests/math/acosh_variation.phpt index 12200e035cef..27e1a9ac24a9 100644 --- a/ext/standard/tests/math/acosh_variation.phpt +++ b/ext/standard/tests/math/acosh_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test acosh with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = acosh($values[$i]); - var_dump($res); + $res = acosh($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/allowed_rounding_error.inc b/ext/standard/tests/math/allowed_rounding_error.inc index 9ba754b58298..c4a1cce4bf01 100644 --- a/ext/standard/tests/math/allowed_rounding_error.inc +++ b/ext/standard/tests/math/allowed_rounding_error.inc @@ -1,18 +1,18 @@ $min ) { - return true; - } - else { - return false; - } + if ($number < $max && $number > $min ) { + return true; + } + else { + return false; + } } ?> diff --git a/ext/standard/tests/math/asin_basic.phpt b/ext/standard/tests/math/asin_basic.phpt index ec43d5069260..419a9ef34373 100644 --- a/ext/standard/tests/math/asin_basic.phpt +++ b/ext/standard/tests/math/asin_basic.phpt @@ -19,30 +19,30 @@ echo "asin .5 = "; $asinv1 = 360.0 * asin(0.5) / (2.0 * M_PI ); var_dump($asinv1); if (allowed_rounding_error($asinv1 ,30 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "asin 0.86602540378444 = "; $asinv2 = 360.0 * asin(0.86602540378444) / (2.0 * M_PI ); var_dump($asinv2); if (allowed_rounding_error($asinv2 ,60 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "asin 1.0 = "; $asinv3 = 360.0 * asin(1.0) / (2.0 * M_PI ); var_dump($asinv3); if (allowed_rounding_error($asinv3 ,90 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } @@ -50,10 +50,10 @@ echo "asin 0.0 = "; $asinv4 = 360.0 * asin(0.0) / (2.0 * M_PI ); var_dump($asinv4); if (allowed_rounding_error($asinv4 ,0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/asin_variation.phpt b/ext/standard/tests/math/asin_variation.phpt index c5d170e8dbdc..7c0e5a37d63b 100644 --- a/ext/standard/tests/math/asin_variation.phpt +++ b/ext/standard/tests/math/asin_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test asin with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = asin($values[$i]); - var_dump($res); + $res = asin($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/asinh_basic.phpt b/ext/standard/tests/math/asinh_basic.phpt index 8fd189c66a80..16380da128a7 100644 --- a/ext/standard/tests/math/asinh_basic.phpt +++ b/ext/standard/tests/math/asinh_basic.phpt @@ -16,20 +16,20 @@ echo "asinh 0.52109530549375= "; var_dump(asinh(0.52109530549375)); if (allowed_rounding_error(asinh(0.52109530549375), 0.5)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "asinh 10.01787492741= "; var_dump(asinh(10.01787492741)); if (allowed_rounding_error(asinh(10.01787492741), 3.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/asinh_variation.phpt b/ext/standard/tests/math/asinh_variation.phpt index 2470f7d401f3..f4304148cb96 100644 --- a/ext/standard/tests/math/asinh_variation.phpt +++ b/ext/standard/tests/math/asinh_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test asinh with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = asinh($values[$i]); - var_dump($res); + $res = asinh($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/atan2_basic.phpt b/ext/standard/tests/math/atan2_basic.phpt index f6dae6290065..fe015ac2aa36 100644 --- a/ext/standard/tests/math/atan2_basic.phpt +++ b/ext/standard/tests/math/atan2_basic.phpt @@ -5,37 +5,37 @@ precision=14 --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/atan2_basiclong_64bit.phpt b/ext/standard/tests/math/atan2_basiclong_64bit.phpt index 235be3eca8d0..e29501232d97 100644 --- a/ext/standard/tests/math/atan2_basiclong_64bit.phpt +++ b/ext/standard/tests/math/atan2_basiclong_64bit.phpt @@ -23,7 +23,7 @@ $otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MIN_32Bit, MAX_64Bit, MIN foreach ($longVals as $longVal) { foreach($otherVals as $otherVal) { - echo "--- testing: $longVal, $otherVal ---\n"; + echo "--- testing: $longVal, $otherVal ---\n"; var_dump(atan2($longVal, $otherVal)); } } diff --git a/ext/standard/tests/math/atan_basic.phpt b/ext/standard/tests/math/atan_basic.phpt index 24f1f4b9244f..9f41e58234af 100644 --- a/ext/standard/tests/math/atan_basic.phpt +++ b/ext/standard/tests/math/atan_basic.phpt @@ -16,20 +16,20 @@ echo "atan 1.7320508075689 = "; $atan1 = 360 * atan(1.7320508075689) / (2.0 * M_PI); var_dump($atan1); if (allowed_rounding_error($atan1 ,60 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "atan 0.57735026918963 = "; $atan2 = 360 * atan(0.57735026918963) / (2.0 * M_PI); var_dump($atan2); if (allowed_rounding_error($atan2 ,30 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/atan_variation.phpt b/ext/standard/tests/math/atan_variation.phpt index 625b6d0b8312..409f0b1719af 100644 --- a/ext/standard/tests/math/atan_variation.phpt +++ b/ext/standard/tests/math/atan_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test atan with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = atan($values[$i]); - var_dump($res); + $res = atan($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/atanh_basic.phpt b/ext/standard/tests/math/atanh_basic.phpt index 8b994bc5fd21..0a7040360b18 100644 --- a/ext/standard/tests/math/atanh_basic.phpt +++ b/ext/standard/tests/math/atanh_basic.phpt @@ -16,20 +16,20 @@ echo "atanh 0.46211715726001 = "; var_dump(atanh(0.46211715726001)); if (allowed_rounding_error(atanh(0.46211715726001), 0.5)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "atanh 0.99505475368673 = "; var_dump(atanh(0.99505475368673)); if (allowed_rounding_error(atanh(0.99505475368673), 3.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } diff --git a/ext/standard/tests/math/atanh_variation.phpt b/ext/standard/tests/math/atanh_variation.phpt index f14406bb0d26..610aaab3fb39 100644 --- a/ext/standard/tests/math/atanh_variation.phpt +++ b/ext/standard/tests/math/atanh_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test atanh with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = atanh($values[$i]); - var_dump($res); + $res = atanh($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/base_convert_basic.phpt b/ext/standard/tests/math/base_convert_basic.phpt index 14767faeea27..bdef339f3b37 100644 --- a/ext/standard/tests/math/base_convert_basic.phpt +++ b/ext/standard/tests/math/base_convert_basic.phpt @@ -6,26 +6,26 @@ $frombase = array(2,8,10,16,36); $tobase = array(2,8,10,16,36); $values = array(10, - 27, - 39, - 03, - 0x5F, - "10", - "27", - "39", - "5F", - "3XYZ" - ); + 27, + 39, + 03, + 0x5F, + "10", + "27", + "39", + "5F", + "3XYZ" + ); for ($f= 0; $f < count($frombase); $f++) { - echo "\n...from base is ", $frombase[$f], "\n"; - for ($t= 0; $t < count($tobase); $t++) { - echo "......to base is ", $tobase[$t], "\n"; - for ($i =0; $i < count($values); $i++){ - $res = base_convert($values[$i],$frombase[$f],$tobase[$t]); - echo ".........value= ", $values[$i], " res = ", $res, "\n"; - } - } + echo "\n...from base is ", $frombase[$f], "\n"; + for ($t= 0; $t < count($tobase); $t++) { + echo "......to base is ", $tobase[$t], "\n"; + for ($i =0; $i < count($values); $i++){ + $res = base_convert($values[$i],$frombase[$f],$tobase[$t]); + echo ".........value= ", $values[$i], " res = ", $res, "\n"; + } + } } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/base_convert_variation1.phpt b/ext/standard/tests/math/base_convert_variation1.phpt index 00eb9e758510..b0dba2b49bda 100644 --- a/ext/standard/tests/math/base_convert_variation1.phpt +++ b/ext/standard/tests/math/base_convert_variation1.phpt @@ -70,9 +70,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of base_convert() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(base_convert($input, 10, 8)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(base_convert($input, 10, 8)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/bindec_basic.phpt b/ext/standard/tests/math/bindec_basic.phpt index 70c29b6fd200..03eec8ee3066 100644 --- a/ext/standard/tests/math/bindec_basic.phpt +++ b/ext/standard/tests/math/bindec_basic.phpt @@ -9,28 +9,28 @@ precision=14 --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/math/bindec_basic_64bit.phpt b/ext/standard/tests/math/bindec_basic_64bit.phpt index 8408944acbfe..b8f46b6748dd 100644 --- a/ext/standard/tests/math/bindec_basic_64bit.phpt +++ b/ext/standard/tests/math/bindec_basic_64bit.phpt @@ -9,28 +9,28 @@ precision=14 --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/math/bindec_variation1.phpt b/ext/standard/tests/math/bindec_variation1.phpt index f215e8ee2604..2b166a3edd61 100644 --- a/ext/standard/tests/math/bindec_variation1.phpt +++ b/ext/standard/tests/math/bindec_variation1.phpt @@ -72,13 +72,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of bindec() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(bindec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(bindec($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/bindec_variation1_64bit.phpt b/ext/standard/tests/math/bindec_variation1_64bit.phpt index 3b5b3e82e05d..6784c136012e 100644 --- a/ext/standard/tests/math/bindec_variation1_64bit.phpt +++ b/ext/standard/tests/math/bindec_variation1_64bit.phpt @@ -72,13 +72,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of bindec() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(bindec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(bindec($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/bug24142.phpt b/ext/standard/tests/math/bug24142.phpt index 3696b6e79040..947deaebd669 100644 --- a/ext/standard/tests/math/bug24142.phpt +++ b/ext/standard/tests/math/bug24142.phpt @@ -4,8 +4,8 @@ Bug #24142 (round() problems) ".round($v, 2)."\n"; - $v += 0.01; + echo "round({$v}, 2) -> ".round($v, 2)."\n"; + $v += 0.01; } ?> --EXPECT-- diff --git a/ext/standard/tests/math/bug30695.phpt b/ext/standard/tests/math/bug30695.phpt index 938b0e7fc86a..a0034892db40 100644 --- a/ext/standard/tests/math/bug30695.phpt +++ b/ext/standard/tests/math/bug30695.phpt @@ -2,7 +2,7 @@ Bug #30695 (32 bit issues) --FILE-- --EXPECT-- A diff --git a/ext/standard/tests/math/ceil_basic.phpt b/ext/standard/tests/math/ceil_basic.phpt index 61c3dd683ddb..54b91836d167 100644 --- a/ext/standard/tests/math/ceil_basic.phpt +++ b/ext/standard/tests/math/ceil_basic.phpt @@ -11,30 +11,30 @@ precision=14 echo "*** Testing ceil() : basic functionality ***\n"; $values = array(0, - -0, - 0.5, - -0.5, - 1, - -1, - 1.5, - -1.5, - 2.6, - -2.6, - 037, - 0x5F, - "10.5", - "-10.5", - "3.95E3", - "-3.95E3", - "039", - true, - false, - null, - ); + -0, + 0.5, + -0.5, + 1, + -1, + 1.5, + -1.5, + 2.6, + -2.6, + 037, + 0x5F, + "10.5", + "-10.5", + "3.95E3", + "-3.95E3", + "039", + true, + false, + null, + ); for ($i = 0; $i < count($values); $i++) { - $res = ceil($values[$i]); - var_dump($res); + $res = ceil($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/ceil_variation1.phpt b/ext/standard/tests/math/ceil_variation1.phpt index a6f308d386c4..815093ea49df 100644 --- a/ext/standard/tests/math/ceil_variation1.phpt +++ b/ext/standard/tests/math/ceil_variation1.phpt @@ -66,13 +66,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of ceil() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(ceil($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(ceil($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/cos_basic.phpt b/ext/standard/tests/math/cos_basic.phpt index 863d44383078..5e471ae07f47 100644 --- a/ext/standard/tests/math/cos_basic.phpt +++ b/ext/standard/tests/math/cos_basic.phpt @@ -26,55 +26,55 @@ $threesixty = M_PI * 2.0; echo "cos 30 = "; var_dump(cos($thirty)); if (allowed_rounding_error(cos($thirty),0.86602540378444)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cos 60 = "; var_dump(cos($sixty)); if (allowed_rounding_error(cos($sixty),0.5)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cos 90 = "; var_dump(cos($ninety)); if (allowed_rounding_error(cos($ninety),0.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cos 180 = "; var_dump(cos($oneeighty)); if (allowed_rounding_error(cos($oneeighty),-1.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cos 270 = "; var_dump(cos($twoseventy)); if (allowed_rounding_error(cos($twoseventy),0.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cos 360 = "; var_dump(cos($threesixty)); if (allowed_rounding_error(cos($threesixty),1.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/cos_variation.phpt b/ext/standard/tests/math/cos_variation.phpt index f9d1b262460a..da92b6aafee0 100644 --- a/ext/standard/tests/math/cos_variation.phpt +++ b/ext/standard/tests/math/cos_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test cos with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = cos($values[$i]); - var_dump($res); + $res = cos($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/cosh_basic.phpt b/ext/standard/tests/math/cosh_basic.phpt index 5b52fb2a63c1..620bbbebcd11 100644 --- a/ext/standard/tests/math/cosh_basic.phpt +++ b/ext/standard/tests/math/cosh_basic.phpt @@ -16,37 +16,37 @@ echo "cosh .5 = "; var_dump(cosh(0.5)); if (allowed_rounding_error(cosh(0.5),1.1276259652064)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cosh -0.5 = "; var_dump(cosh(-0.5)); if (allowed_rounding_error(cosh(-0.5),1.1276259652064)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cosh 3 = "; var_dump(cosh(3.0)); if (allowed_rounding_error(cosh(3.0), 10.067661995778)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "cosh -3 = "; var_dump(cosh(-3.0)); if (allowed_rounding_error(cosh(-3.0), 10.067661995778)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/cosh_variation.phpt b/ext/standard/tests/math/cosh_variation.phpt index ec58c0151f92..a0b3b60f1935 100644 --- a/ext/standard/tests/math/cosh_variation.phpt +++ b/ext/standard/tests/math/cosh_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test cosh with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = cosh($values[$i]); - var_dump($res); + $res = cosh($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/decbin_basic.phpt b/ext/standard/tests/math/decbin_basic.phpt index b067030a484f..da681dfbe890 100644 --- a/ext/standard/tests/math/decbin_basic.phpt +++ b/ext/standard/tests/math/decbin_basic.phpt @@ -3,23 +3,23 @@ Test decbin() - basic function test --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/decbin_variation1.phpt b/ext/standard/tests/math/decbin_variation1.phpt index 46b509be3bdf..581e88b28314 100644 --- a/ext/standard/tests/math/decbin_variation1.phpt +++ b/ext/standard/tests/math/decbin_variation1.phpt @@ -84,9 +84,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of decbin() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(decbin($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(decbin($input)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt index 589c954651cc..91f79aaecbf4 100644 --- a/ext/standard/tests/math/decbin_variation1_64bit.phpt +++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt @@ -84,9 +84,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of decbin() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(decbin($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(decbin($input)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt index 9f6328c24a7a..690e2a9842c7 100644 --- a/ext/standard/tests/math/dechex_basic.phpt +++ b/ext/standard/tests/math/dechex_basic.phpt @@ -3,23 +3,23 @@ Test dechex() - basic function dechex() --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/dechex_variation1.phpt b/ext/standard/tests/math/dechex_variation1.phpt index e2a3e4ed677d..fd1ea6def198 100644 --- a/ext/standard/tests/math/dechex_variation1.phpt +++ b/ext/standard/tests/math/dechex_variation1.phpt @@ -84,9 +84,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of dechex() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(dechex($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(dechex($input)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt index 6d186fa0087e..a566001d62ab 100644 --- a/ext/standard/tests/math/dechex_variation1_64bit.phpt +++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt @@ -84,9 +84,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of dechex() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(dechex($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(dechex($input)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt index 19bda37bffec..46418df67d3d 100644 --- a/ext/standard/tests/math/decoct_basic.phpt +++ b/ext/standard/tests/math/decoct_basic.phpt @@ -3,23 +3,23 @@ Test decoct() - basic function test decoct() --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/decoct_variation1.phpt b/ext/standard/tests/math/decoct_variation1.phpt index ad6c63f0dc6a..174fddf470bf 100644 --- a/ext/standard/tests/math/decoct_variation1.phpt +++ b/ext/standard/tests/math/decoct_variation1.phpt @@ -85,9 +85,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of decoct() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(decoct($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(decoct($input)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt index 0a35475883f8..2ff2c4c48ee0 100644 --- a/ext/standard/tests/math/decoct_variation1_64bit.phpt +++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt @@ -85,9 +85,9 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of decoct() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(decoct($input)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(decoct($input)); + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/deg2rad_basic.phpt b/ext/standard/tests/math/deg2rad_basic.phpt index 6db1be4da8e6..ea1eba6ddf2f 100644 --- a/ext/standard/tests/math/deg2rad_basic.phpt +++ b/ext/standard/tests/math/deg2rad_basic.phpt @@ -22,38 +22,38 @@ echo "deg2rad $arg_0 = "; $r0 = deg2rad($arg_0); var_dump($r0); if (allowed_rounding_error($r0 ,0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "deg2rad $arg_1 = "; $r1 = deg2rad($arg_1); var_dump($r1); if (allowed_rounding_error($r1 ,1.5707963267949 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "deg2rad $arg_2 = "; $r2 = deg2rad($arg_2); var_dump($r2); if (allowed_rounding_error($r2 ,3.1415926535898 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "deg2rad $arg_3 = "; $r3 = deg2rad($arg_3); var_dump($r3); if (allowed_rounding_error($r3 ,6.2831853071796 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/deg2rad_variation.phpt b/ext/standard/tests/math/deg2rad_variation.phpt index eb3c7eae0e10..3e344540a22d 100644 --- a/ext/standard/tests/math/deg2rad_variation.phpt +++ b/ext/standard/tests/math/deg2rad_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test deg2rad with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = deg2rad($values[$i]); - var_dump($res); + $res = deg2rad($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/exp_basic.phpt b/ext/standard/tests/math/exp_basic.phpt index ba53e22f2841..b73889153f46 100644 --- a/ext/standard/tests/math/exp_basic.phpt +++ b/ext/standard/tests/math/exp_basic.phpt @@ -5,24 +5,24 @@ precision=14 --FILE-- diff --git a/ext/standard/tests/math/expm1_basic.phpt b/ext/standard/tests/math/expm1_basic.phpt index 9e926b869d27..296838570c15 100644 --- a/ext/standard/tests/math/expm1_basic.phpt +++ b/ext/standard/tests/math/expm1_basic.phpt @@ -12,25 +12,25 @@ precision=14 echo "*** Testing expm1() : basic functionality ***\n"; $values = array(10, - 10.3, - 3.9505e3, - 037, - 0x5F, - "10", - "3950.5", - "3.9505e3", - "039", - true, - false, - null, - ); + 10.3, + 3.9505e3, + 037, + 0x5F, + "10", + "3950.5", + "3.9505e3", + "039", + true, + false, + null, + ); // loop through each element of $values to check the behaviour of expm1() $iterator = 1; foreach($values as $value) { - echo "\n-- Iteration $iterator --\n"; - var_dump(expm1($value)); - $iterator++; + echo "\n-- Iteration $iterator --\n"; + var_dump(expm1($value)); + $iterator++; }; ?> --EXPECT-- diff --git a/ext/standard/tests/math/floor_basic.phpt b/ext/standard/tests/math/floor_basic.phpt index c5d2fc46b17e..84153af08e6f 100644 --- a/ext/standard/tests/math/floor_basic.phpt +++ b/ext/standard/tests/math/floor_basic.phpt @@ -11,30 +11,30 @@ precision=14 echo "*** Testing floor() : basic functionality ***\n"; $values = array(0, - -0, - 0.5, - -0.5, - 1, - -1, - 1.5, - -1.5, - 2.6, - -2.6, - 037, - 0x5F, - "10.5", - "-10.5", - "3.95E3", - "-3.95E3", - "039", - true, - false, - null, - ); + -0, + 0.5, + -0.5, + 1, + -1, + 1.5, + -1.5, + 2.6, + -2.6, + 037, + 0x5F, + "10.5", + "-10.5", + "3.95E3", + "-3.95E3", + "039", + true, + false, + null, + ); foreach($values as $value) { - echo "\n-- floor $value --\n"; - var_dump(floor($value)); + echo "\n-- floor $value --\n"; + var_dump(floor($value)); }; ?> diff --git a/ext/standard/tests/math/floor_variation1.phpt b/ext/standard/tests/math/floor_variation1.phpt index 6774816ead78..dd0e70b86378 100644 --- a/ext/standard/tests/math/floor_variation1.phpt +++ b/ext/standard/tests/math/floor_variation1.phpt @@ -66,13 +66,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of floor() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(floor($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(floor($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/fmod_basic.phpt b/ext/standard/tests/math/fmod_basic.phpt index 875ae8dd0564..e7b204f54083 100644 --- a/ext/standard/tests/math/fmod_basic.phpt +++ b/ext/standard/tests/math/fmod_basic.phpt @@ -5,37 +5,37 @@ precision=14 --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/fmod_basiclong_64bit.phpt b/ext/standard/tests/math/fmod_basiclong_64bit.phpt index e949aab00a5f..5ef283689e7c 100644 --- a/ext/standard/tests/math/fmod_basiclong_64bit.phpt +++ b/ext/standard/tests/math/fmod_basiclong_64bit.phpt @@ -23,7 +23,7 @@ $otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MIN_32Bit, MAX_64Bit, MIN foreach ($longVals as $longVal) { foreach($otherVals as $otherVal) { - echo "--- testing: $longVal, $otherVal ---\n"; + echo "--- testing: $longVal, $otherVal ---\n"; var_dump(fmod($longVal, $otherVal)); } } diff --git a/ext/standard/tests/math/hexdec_basic.phpt b/ext/standard/tests/math/hexdec_basic.phpt index 0ca2342d8189..748c641a1acf 100644 --- a/ext/standard/tests/math/hexdec_basic.phpt +++ b/ext/standard/tests/math/hexdec_basic.phpt @@ -7,26 +7,26 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/math/hexdec_basic_64bit.phpt b/ext/standard/tests/math/hexdec_basic_64bit.phpt index bb8c3d3f27a2..c7c59451f554 100644 --- a/ext/standard/tests/math/hexdec_basic_64bit.phpt +++ b/ext/standard/tests/math/hexdec_basic_64bit.phpt @@ -9,27 +9,27 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); echo "*** Testing hexdec() : basic functionality ***\n"; $values = array(0x123abc, - 0x789DEF, - 0x7FFFFFFF, - 0x80000000, - '0x123abc', - '0x789DEF', - '0x7FFFFFFF', - '0x80000000', - '0x123XYZABC', - 311015, - '311015', - 31101.3, - 31.1013e5, - 011237, - '011237', - true, - false, - null); + 0x789DEF, + 0x7FFFFFFF, + 0x80000000, + '0x123abc', + '0x789DEF', + '0x7FFFFFFF', + '0x80000000', + '0x123XYZABC', + 311015, + '311015', + 31101.3, + 31.1013e5, + 011237, + '011237', + true, + false, + null); foreach($values as $value) { - echo "\n-- hexdec $value --\n"; - var_dump(hexdec($value)); + echo "\n-- hexdec $value --\n"; + var_dump(hexdec($value)); }; ?> diff --git a/ext/standard/tests/math/hexdec_variation1.phpt b/ext/standard/tests/math/hexdec_variation1.phpt index d395f8a8f1ec..c50c550f61a1 100644 --- a/ext/standard/tests/math/hexdec_variation1.phpt +++ b/ext/standard/tests/math/hexdec_variation1.phpt @@ -76,13 +76,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of hexdec() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(hexdec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(hexdec($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/hexdec_variation1_64bit.phpt b/ext/standard/tests/math/hexdec_variation1_64bit.phpt index 35c17f727a35..d3b22d804098 100644 --- a/ext/standard/tests/math/hexdec_variation1_64bit.phpt +++ b/ext/standard/tests/math/hexdec_variation1_64bit.phpt @@ -76,13 +76,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of hexdec() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(hexdec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(hexdec($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/hypot_basic.phpt b/ext/standard/tests/math/hypot_basic.phpt index 796c1608104f..f9e5787f406c 100644 --- a/ext/standard/tests/math/hypot_basic.phpt +++ b/ext/standard/tests/math/hypot_basic.phpt @@ -13,39 +13,39 @@ precision=14 echo "*** Testing hypot() : basic functionality ***\n"; $valuesy = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "23abc", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "23abc", + null, + true, + false); $valuesx = array(33, - -33, - 3.345e1, - -3.345e1, - 0x27, - 037, - "33", - "43.45", - "1.345e1", - "33abc", - null, - true, - false); + -33, + 3.345e1, + -3.345e1, + 0x27, + 037, + "33", + "43.45", + "1.345e1", + "33abc", + null, + true, + false); for ($i = 0; $i < count($valuesy); $i++) { - for ($j = 0; $j < count($valuesx); $j++) { - echo "\nY:$valuesy[$i] X:$valuesx[$j] "; - $res = hypot($valuesy[$i], $valuesx[$j]); - var_dump($res); - } + for ($j = 0; $j < count($valuesx); $j++) { + echo "\nY:$valuesy[$i] X:$valuesx[$j] "; + $res = hypot($valuesy[$i], $valuesx[$j]); + var_dump($res); + } } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/hypot_basiclong_64bit.phpt b/ext/standard/tests/math/hypot_basiclong_64bit.phpt index 9a0b71ffc104..1e1ca60996ae 100644 --- a/ext/standard/tests/math/hypot_basiclong_64bit.phpt +++ b/ext/standard/tests/math/hypot_basiclong_64bit.phpt @@ -23,7 +23,7 @@ $otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MIN_32Bit, MAX_64Bit, MIN foreach ($longVals as $longVal) { foreach($otherVals as $otherVal) { - echo "--- testing: $longVal, $otherVal ---\n"; + echo "--- testing: $longVal, $otherVal ---\n"; var_dump(hypot($longVal, $otherVal)); } } diff --git a/ext/standard/tests/math/is_finite_basic.phpt b/ext/standard/tests/math/is_finite_basic.phpt index 11db785ae45d..9ee9d544e3c7 100644 --- a/ext/standard/tests/math/is_finite_basic.phpt +++ b/ext/standard/tests/math/is_finite_basic.phpt @@ -3,23 +3,23 @@ Test is_finite() - basic function test is_finite() --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/is_infinite_basic.phpt b/ext/standard/tests/math/is_infinite_basic.phpt index 4f903403117f..076f202c146e 100644 --- a/ext/standard/tests/math/is_infinite_basic.phpt +++ b/ext/standard/tests/math/is_infinite_basic.phpt @@ -3,23 +3,23 @@ Test is_infinite() - basic function test is_infinite() --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/is_nan_basic.phpt b/ext/standard/tests/math/is_nan_basic.phpt index 49d2ce4ccfd5..fabc40b97b61 100644 --- a/ext/standard/tests/math/is_nan_basic.phpt +++ b/ext/standard/tests/math/is_nan_basic.phpt @@ -3,24 +3,24 @@ Test is_nan() - basic function test is_nan() --FILE-- diff --git a/ext/standard/tests/math/lcg_value_basic.phpt b/ext/standard/tests/math/lcg_value_basic.phpt index 7660f67c2430..95811c6f3c2e 100644 --- a/ext/standard/tests/math/lcg_value_basic.phpt +++ b/ext/standard/tests/math/lcg_value_basic.phpt @@ -8,17 +8,17 @@ echo "MATHS test script started\n"; echo "\n lcg_value tests...\n"; for ($i = 0; $i < 100; $i++) { - $res = lcg_value(); + $res = lcg_value(); - if (!is_float($res) || $res < 0 || $res > 1) { - break; - } + if (!is_float($res) || $res < 0 || $res > 1) { + break; + } } if ($i != 100) { - echo "FAILED\n"; + echo "FAILED\n"; } else { - echo "PASSED\n"; + echo "PASSED\n"; } echo "MATHS test script completed\n"; diff --git a/ext/standard/tests/math/log10_basic.phpt b/ext/standard/tests/math/log10_basic.phpt index b81284faf27b..0997d3db4b70 100644 --- a/ext/standard/tests/math/log10_basic.phpt +++ b/ext/standard/tests/math/log10_basic.phpt @@ -20,30 +20,30 @@ echo "log10 $arg_0 = "; $r0 = log10($arg_0); var_dump($r0); if (allowed_rounding_error($r0 ,0.0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "log10 $arg_1 = "; $r1 = log10($arg_1); var_dump($r1); if (allowed_rounding_error($r1 ,1.0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "log10 $arg_2 = "; $r2 = log10($arg_2); var_dump($r2); if (allowed_rounding_error($r2 ,2.0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/log10_variation.phpt b/ext/standard/tests/math/log10_variation.phpt index 8dbea47a8463..e852d82ea916 100644 --- a/ext/standard/tests/math/log10_variation.phpt +++ b/ext/standard/tests/math/log10_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test log10 with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = log10($values[$i]); - var_dump($res); + $res = log10($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/log1p_basic.phpt b/ext/standard/tests/math/log1p_basic.phpt index 2b8c7f8cc5ec..115deec1d9eb 100644 --- a/ext/standard/tests/math/log1p_basic.phpt +++ b/ext/standard/tests/math/log1p_basic.phpt @@ -13,23 +13,23 @@ precision=14 echo "*** Testing log1p() : basic functionality ***\n"; $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + null, + true, + false); echo "\n LOG1p tests\n"; foreach($values as $value) { - echo "\n-- log1p $value --\n"; - var_dump(log1p($value)); + echo "\n-- log1p $value --\n"; + var_dump(log1p($value)); }; diff --git a/ext/standard/tests/math/log_basic.phpt b/ext/standard/tests/math/log_basic.phpt index de97ee264bfe..8ff1c88ccfc3 100644 --- a/ext/standard/tests/math/log_basic.phpt +++ b/ext/standard/tests/math/log_basic.phpt @@ -5,28 +5,28 @@ precision=14 --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/mt_rand_basic.phpt b/ext/standard/tests/math/mt_rand_basic.phpt index 3a1e4406ebb1..24050bbc8a99 100644 --- a/ext/standard/tests/math/mt_rand_basic.phpt +++ b/ext/standard/tests/math/mt_rand_basic.phpt @@ -6,77 +6,77 @@ $default_max = mt_getrandmax(); echo "\nmt_rand() tests with default min and max value (i.e 0 thru ", $default_max, ")\n"; for ($i = 0; $i < 100; $i++) { - $res = mt_rand(); + $res = mt_rand(); // By default RAND_MAX is 32768 although no constant is defined for it for user space apps - if (!is_int($res) || $res < 0 || $res > $default_max) { - break; - } + if (!is_int($res) || $res < 0 || $res > $default_max) { + break; + } } if ($i != 100) { - echo "FAILED: res = ", $res, " min = 0 max = ", $default_max, "\n"; + echo "FAILED: res = ", $res, " min = 0 max = ", $default_max, "\n"; } else { - echo "PASSED: range min = 0 max = ", $default_max, "\n"; + echo "PASSED: range min = 0 max = ", $default_max, "\n"; } echo "\nmt_rand() tests with defined min and max value\n"; $min = array(10, - 100, - 10.5, - 10.5e3, - 0x10, - 0400); + 100, + 10.5, + 10.5e3, + 0x10, + 0400); $max = array(100, - 1000, - 19.5, - 10.5e5, - 0x10000, - 0700); + 1000, + 19.5, + 10.5e5, + 0x10000, + 0700); for ($x = 0; $x < count($min); $x++) { - for ($i = 0; $i < 100; $i++) { - $res = mt_rand($min[$x], $max[$x]); + for ($i = 0; $i < 100; $i++) { + $res = mt_rand($min[$x], $max[$x]); - if (!is_int($res) || $res < intval($min[$x]) || $res > intval($max[$x])) { - echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - break; - } - } + if (!is_int($res) || $res < intval($min[$x]) || $res > intval($max[$x])) { + echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; + break; + } + } - if ($i == 100) { - echo "PASSED: range min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - } + if ($i == 100) { + echo "PASSED: range min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; + } } echo "\nNon-numeric cases\n"; $min = array(true, - false, - null, - "10", - "10.5"); + false, + null, + "10", + "10.5"); // Expected numerical equivalent of above non-numerics $minval = array(1, - 0, - 0, - 10, - 10); + 0, + 0, + 10, + 10); for ($x = 0; $x < count($min); $x++) { - for ($i = 0; $i < 100; $i++) { - $res = mt_rand($min[$x], 100); + for ($i = 0; $i < 100; $i++) { + $res = mt_rand($min[$x], 100); - if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { - echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - break; - } - } + if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { + echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; + break; + } + } - if ($i == 100) { - echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; - } + if ($i == 100) { + echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; + } } ?> --EXPECT-- diff --git a/ext/standard/tests/math/number_format_basic.phpt b/ext/standard/tests/math/number_format_basic.phpt index 5a2570126a0f..b82ad5c75388 100644 --- a/ext/standard/tests/math/number_format_basic.phpt +++ b/ext/standard/tests/math/number_format_basic.phpt @@ -3,40 +3,40 @@ Test number_format() - basic function test number_format() --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/number_format_multichar.phpt b/ext/standard/tests/math/number_format_multichar.phpt index b12c81c1a29a..5648257e0313 100644 --- a/ext/standard/tests/math/number_format_multichar.phpt +++ b/ext/standard/tests/math/number_format_multichar.phpt @@ -3,34 +3,34 @@ Test number_format() - multiple character separator support --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/octdec_basic.phpt b/ext/standard/tests/math/octdec_basic.phpt index c31af5567336..1daf9a4338b3 100644 --- a/ext/standard/tests/math/octdec_basic.phpt +++ b/ext/standard/tests/math/octdec_basic.phpt @@ -7,26 +7,26 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/math/octdec_basic_64bit.phpt b/ext/standard/tests/math/octdec_basic_64bit.phpt index 6401fdff3c70..bb8f70085d87 100644 --- a/ext/standard/tests/math/octdec_basic_64bit.phpt +++ b/ext/standard/tests/math/octdec_basic_64bit.phpt @@ -10,26 +10,26 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); echo "*** Testing octdec() : basic functionality ***\n"; $values = array(01234567, - 0567, - 017777777777, - 020000000000, - 0x1234ABC, - 12345, - '01234567', - '0567', - '017777777777', - '020000000000', - '0x1234ABC', - '12345', - 31101.3, - 31.1013e5, - true, - false, - null); + 0567, + 017777777777, + 020000000000, + 0x1234ABC, + 12345, + '01234567', + '0567', + '017777777777', + '020000000000', + '0x1234ABC', + '12345', + 31101.3, + 31.1013e5, + true, + false, + null); for ($i = 0; $i < count($values); $i++) { - $res = octdec($values[$i]); - var_dump($res); + $res = octdec($values[$i]); + var_dump($res); } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/octdec_variation1.phpt b/ext/standard/tests/math/octdec_variation1.phpt index b59b3b71eb2b..48e4faf46616 100644 --- a/ext/standard/tests/math/octdec_variation1.phpt +++ b/ext/standard/tests/math/octdec_variation1.phpt @@ -72,13 +72,13 @@ $inputs = array( // loop through each element of $inputs to check the behaviour of octdec() $iterator = 1; foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - try { - var_dump(octdec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; - } - $iterator++; + echo "\n-- Iteration $iterator --\n"; + try { + var_dump(octdec($input)); + } catch (TypeError $e) { + echo $e->getMessage(), "\n"; + } + $iterator++; }; fclose($fp); ?> diff --git a/ext/standard/tests/math/pow.phpt b/ext/standard/tests/math/pow.phpt index 534ecbd58f03..e8ee73135ef7 100644 --- a/ext/standard/tests/math/pow.phpt +++ b/ext/standard/tests/math/pow.phpt @@ -6,7 +6,7 @@ Various pow() tests define('LONG_MAX', is_int(5000000000)? 9223372036854775807 : 0x7FFFFFFF); define('LONG_MIN', -LONG_MAX - 1); printf("%d,%d,%d,%d\n",is_int(LONG_MIN ),is_int(LONG_MAX ), - is_int(LONG_MIN-1),is_int(LONG_MAX+1)); + is_int(LONG_MIN-1),is_int(LONG_MAX+1)); $tests = << --EXPECT-- diff --git a/ext/standard/tests/math/pow_basic_64bit.phpt b/ext/standard/tests/math/pow_basic_64bit.phpt index 3dc37c477427..95ecd8c487bc 100644 --- a/ext/standard/tests/math/pow_basic_64bit.phpt +++ b/ext/standard/tests/math/pow_basic_64bit.phpt @@ -9,18 +9,18 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); --FILE-- --EXPECT-- diff --git a/ext/standard/tests/math/pow_basiclong_64bit.phpt b/ext/standard/tests/math/pow_basiclong_64bit.phpt index ff661c3a9aa0..d955edfcf33f 100644 --- a/ext/standard/tests/math/pow_basiclong_64bit.phpt +++ b/ext/standard/tests/math/pow_basiclong_64bit.phpt @@ -23,7 +23,7 @@ $otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MIN_32Bit, MAX_64Bit, MIN foreach ($longVals as $longVal) { foreach($otherVals as $otherVal) { - echo "--- testing: $longVal, $otherVal ---\n"; + echo "--- testing: $longVal, $otherVal ---\n"; var_dump(pow($longVal, $otherVal)); } } diff --git a/ext/standard/tests/math/rad2deg_basic.phpt b/ext/standard/tests/math/rad2deg_basic.phpt index d09f37615145..df5f83742242 100644 --- a/ext/standard/tests/math/rad2deg_basic.phpt +++ b/ext/standard/tests/math/rad2deg_basic.phpt @@ -21,37 +21,37 @@ echo "rad2deg $arg_0= "; $r0 = rad2deg($arg_0); var_dump($r0); if (allowed_rounding_error($r0 ,0 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "rad2deg $arg_1 = "; $r1 = rad2deg($arg_1); var_dump($r1); if (allowed_rounding_error($r1 ,90.000000011752)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "rad2deg $arg_2 = "; $r2 = rad2deg($arg_2); var_dump($r2); if (allowed_rounding_error($r2 ,180.0000000235 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "rad2deg $arg_3 = "; $r3 = rad2deg($arg_3); var_dump($r3); if (allowed_rounding_error($r3 ,359.99999998971 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/rad2deg_variation.phpt b/ext/standard/tests/math/rad2deg_variation.phpt index 6ea7d0c8a459..7144f18b6179 100644 --- a/ext/standard/tests/math/rad2deg_variation.phpt +++ b/ext/standard/tests/math/rad2deg_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test rad2deg with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = rad2deg($values[$i]); - var_dump($res); + $res = rad2deg($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/rand_basic.phpt b/ext/standard/tests/math/rand_basic.phpt index fbaab3c9afab..87e9d7cd425d 100644 --- a/ext/standard/tests/math/rand_basic.phpt +++ b/ext/standard/tests/math/rand_basic.phpt @@ -6,77 +6,77 @@ $default_max = getrandmax(); echo "\nrand() tests with default min and max value (i.e 0 thru ", $default_max, ")\n"; for ($i = 0; $i < 100; $i++) { - $res = rand(); + $res = rand(); // By default RAND_MAX is 32768 although no constant is defined for it for user space apps - if (!is_int($res) || $res < 0 || $res > $default_max) { - break; - } + if (!is_int($res) || $res < 0 || $res > $default_max) { + break; + } } if ($i != 100) { - echo "FAILED: res = ", $res, " min = 0 max = ", $default_max, "\n"; + echo "FAILED: res = ", $res, " min = 0 max = ", $default_max, "\n"; } else { - echo "PASSED: range min = 0 max = ", $default_max, "\n"; + echo "PASSED: range min = 0 max = ", $default_max, "\n"; } echo "\nrand() tests with defined min and max value\n"; $min = array(10, - 100, - 10.5, - 10.5e3, - 0x10, - 0400); + 100, + 10.5, + 10.5e3, + 0x10, + 0400); $max = array(100, - 1000, - 19.5, - 10.5e5, - 0x10000, - 0700); + 1000, + 19.5, + 10.5e5, + 0x10000, + 0700); for ($x = 0; $x < count($min); $x++) { - for ($i = 0; $i < 100; $i++) { - $res = rand($min[$x], $max[$x]); + for ($i = 0; $i < 100; $i++) { + $res = rand($min[$x], $max[$x]); - if (!is_int($res) || $res < intval($min[$x]) || $res > intval($max[$x])) { - echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - break; - } - } + if (!is_int($res) || $res < intval($min[$x]) || $res > intval($max[$x])) { + echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; + break; + } + } - if ($i == 100) { - echo "PASSED: range min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - } + if ($i == 100) { + echo "PASSED: range min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; + } } echo "\nNon-numeric cases\n"; $min = array(true, - false, - null, - "10", - "10.5"); + false, + null, + "10", + "10.5"); // Eexepcted numerical equivalent of above non-numerics $minval = array(1, - 0, - 0, - 10, - 10); + 0, + 0, + 10, + 10); for ($x = 0; $x < count($min); $x++) { - for ($i = 0; $i < 100; $i++) { - $res = rand($min[$x], 100); + for ($i = 0; $i < 100; $i++) { + $res = rand($min[$x], 100); - if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { - echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - break; - } - } + if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { + echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; + break; + } + } - if ($i == 100) { - echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; - } + if ($i == 100) { + echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; + } } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/round.phpt b/ext/standard/tests/math/round.phpt index 16255c0a3096..f78d2757c2ff 100644 --- a/ext/standard/tests/math/round.phpt +++ b/ext/standard/tests/math/round.phpt @@ -6,7 +6,7 @@ Simple math tests define('LONG_MAX', is_int(5000000000)? 9223372036854775807 : 0x7FFFFFFF); define('LONG_MIN', -LONG_MAX - 1); printf("%d,%d,%d,%d\n",is_int(LONG_MIN ),is_int(LONG_MAX ), - is_int(LONG_MIN-1),is_int(LONG_MAX+1)); + is_int(LONG_MIN-1),is_int(LONG_MAX+1)); $tests = << "; - var_dump($res); - } + echo "round: $values[$i]\n"; + for ($j = 0; $j < count($precision); $j++) { + $res = round($values[$i], $precision[$j]); + echo "...with precision $precision[$j]-> "; + var_dump($res); + } } ?> --EXPECT-- diff --git a/ext/standard/tests/math/sin_basic.phpt b/ext/standard/tests/math/sin_basic.phpt index f9be13bec902..7c5b787a7af1 100644 --- a/ext/standard/tests/math/sin_basic.phpt +++ b/ext/standard/tests/math/sin_basic.phpt @@ -26,55 +26,55 @@ $threesixty = M_PI * 2.0; echo "sin 30 = "; var_dump(sin($thirty)); if (allowed_rounding_error(sin($thirty),0.5)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sin 60 = "; var_dump(sin($sixty)); if (allowed_rounding_error(sin($sixty),0.86602540378444)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sin 90 = "; var_dump(sin($ninety)); if (allowed_rounding_error(sin($ninety),1.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sin 180 = "; var_dump(sin($oneeighty)); if (allowed_rounding_error(sin($oneeighty),0.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sin 270 = "; var_dump(sin($twoseventy)); if (allowed_rounding_error(sin($twoseventy),-1.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sin 360 = "; var_dump(sin($threesixty)); if (allowed_rounding_error(sin($threesixty),0.0)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/math/sin_variation.phpt b/ext/standard/tests/math/sin_variation.phpt index d044a16b405e..bad70c710db0 100644 --- a/ext/standard/tests/math/sin_variation.phpt +++ b/ext/standard/tests/math/sin_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test sin with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = sin($values[$i]); - var_dump($res); + $res = sin($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/sinh_basic.phpt b/ext/standard/tests/math/sinh_basic.phpt index 8d16e1712e6e..0cdd8f1179ad 100644 --- a/ext/standard/tests/math/sinh_basic.phpt +++ b/ext/standard/tests/math/sinh_basic.phpt @@ -15,37 +15,37 @@ require($file_path."/allowed_rounding_error.inc"); echo "sinh .5 = "; var_dump(sinh(0.5)); if (allowed_rounding_error(sinh(0.5),0.52109530549375)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sinh -0.5 = "; var_dump(sinh(-0.5)); if (allowed_rounding_error(sinh(-0.5), -0.52109530549375)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sinh 3 = "; var_dump(sinh(3.0)); if (allowed_rounding_error(sinh(3.0), 10.01787492741)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "sinh -3 = "; var_dump(sinh(-3.0)); if (allowed_rounding_error(sinh(-3.0), -10.01787492741)){ - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/sinh_variation.phpt b/ext/standard/tests/math/sinh_variation.phpt index 5e576f447f68..5b3a79ca780c 100644 --- a/ext/standard/tests/math/sinh_variation.phpt +++ b/ext/standard/tests/math/sinh_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test sinh with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = sinh($values[$i]); - var_dump($res); + $res = sinh($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/sqrt_variation.phpt b/ext/standard/tests/math/sqrt_variation.phpt index 696596cefa22..75c460db7af4 100644 --- a/ext/standard/tests/math/sqrt_variation.phpt +++ b/ext/standard/tests/math/sqrt_variation.phpt @@ -14,23 +14,23 @@ precision = 14 echo "*** Testing sqrt() : usage variations ***\n"; $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = sqrt($values[$i]); - var_dump($res); + $res = sqrt($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/tan_basic.phpt b/ext/standard/tests/math/tan_basic.phpt index a4d95d77b062..15e7848c488e 100644 --- a/ext/standard/tests/math/tan_basic.phpt +++ b/ext/standard/tests/math/tan_basic.phpt @@ -18,19 +18,19 @@ $thirty = M_PI / 6.0; echo "tan 60 = "; var_dump(tan($sixty)); if (allowed_rounding_error(tan($sixty),1.7320508075689)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "tan 30 = "; var_dump(tan($thirty)); if (allowed_rounding_error(tan($thirty),0.57735026918963)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/tan_variation.phpt b/ext/standard/tests/math/tan_variation.phpt index 2c9ede47387e..1575e2469448 100644 --- a/ext/standard/tests/math/tan_variation.phpt +++ b/ext/standard/tests/math/tan_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test tan with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = tan($values[$i]); - var_dump($res); + $res = tan($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/math/tanh_basic.phpt b/ext/standard/tests/math/tanh_basic.phpt index 472d88b94ed2..d8288843a152 100644 --- a/ext/standard/tests/math/tanh_basic.phpt +++ b/ext/standard/tests/math/tanh_basic.phpt @@ -15,37 +15,37 @@ require($file_path."/allowed_rounding_error.inc"); echo "tanh .5 = "; var_dump(tanh(0.5)); if (allowed_rounding_error(tanh(0.5), 0.46211715726001)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "tanh -0.5 = "; var_dump(tanh(-0.5)); if (allowed_rounding_error(tanh(-0.5), -0.46211715726001)) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "tanh 3 = "; var_dump(tanh(3.0)); if (allowed_rounding_error(tanh(3.0),0.99505475368673 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } echo "tanh -3 = "; var_dump(tanh(-3.0)); if (allowed_rounding_error(tanh(-3.0),-0.99505475368673 )) { - echo "Pass\n"; + echo "Pass\n"; } else { - echo "Fail\n"; + echo "Fail\n"; } ?> diff --git a/ext/standard/tests/math/tanh_variation.phpt b/ext/standard/tests/math/tanh_variation.phpt index 907f802b8a32..502130c5d4a2 100644 --- a/ext/standard/tests/math/tanh_variation.phpt +++ b/ext/standard/tests/math/tanh_variation.phpt @@ -13,23 +13,23 @@ precision = 10 //Test tanh with a different input values $values = array(23, - -23, - 2.345e1, - -2.345e1, - 0x17, - 027, - "23", - "23.45", - "2.345e1", - "1000", - "1000ABC", - null, - true, - false); + -23, + 2.345e1, + -2.345e1, + 0x17, + 027, + "23", + "23.45", + "2.345e1", + "1000", + "1000ABC", + null, + true, + false); for ($i = 0; $i < count($values); $i++) { - $res = tanh($values[$i]); - var_dump($res); + $res = tanh($values[$i]); + var_dump($res); } ?> diff --git a/ext/standard/tests/misc/browsernames.inc b/ext/standard/tests/misc/browsernames.inc index cac8f9a78258..fe4350e22235 100644 --- a/ext/standard/tests/misc/browsernames.inc +++ b/ext/standard/tests/misc/browsernames.inc @@ -4,48 +4,48 @@ * Common browser names. Used with: get_browser() */ return array( - "Opera/7.11 (Windows NT 5.1; U) [en]", - "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]", - "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 4.0) Opera 7.0 [en]", - "Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 6.0 [en]", - "Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 5.0 [en]", - "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) Opera 8.60 [en]", - "Opera/9.00 (Windows NT 5.1; U; en)", - "Opera/9.26 (Macintosh; PPC Mac OS X; U; en)", + "Opera/7.11 (Windows NT 5.1; U) [en]", + "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]", + "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 4.0) Opera 7.0 [en]", + "Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 6.0 [en]", + "Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 5.0 [en]", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) Opera 8.60 [en]", + "Opera/9.00 (Windows NT 5.1; U; en)", + "Opera/9.26 (Macintosh; PPC Mac OS X; U; en)", - "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)", - "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)", - "Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)", - "Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC; e504460WanadooNL)", - "Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30)", - "Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1)", - "Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)", + "Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)", + "Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC; e504460WanadooNL)", + "Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1; .NET CLR 3.0.04506.30)", + "Mozilla/4.0 (Mozilla/4.0; MSIE 7.0; Windows NT 5.1; FDM; SV1)", + "Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)", - "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/74 (KHTML, like Gecko) Safari/74", - "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/51 (like Gecko) Safari/51", - "Mozilla/5.0 (Windows; U; Windows NT 6.0; en) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3", - "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3", - "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3", - "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; ru-ru) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8", - "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.12) Gecko/20080206 Camino/1.5.5", + "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/74 (KHTML, like Gecko) Safari/74", + "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/51 (like Gecko) Safari/51", + "Mozilla/5.0 (Windows; U; Windows NT 6.0; en) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3", + "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3", + "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3", + "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; ru-ru) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18", + "Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/526.9 (KHTML, like Gecko) Version/4.0dp1 Safari/526.8", + "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.12) Gecko/20080206 Camino/1.5.5", - "Mozilla/5.0 (compatible; Konqueror/3.1; Linux; X11; i686)", - "Mozilla/5.0 (compatible; Konqueror/3.1; Linux 2.4.19-32mdkenterprise; X11; i686; ar, en_US)", - "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)", + "Mozilla/5.0 (compatible; Konqueror/3.1; Linux; X11; i686)", + "Mozilla/5.0 (compatible; Konqueror/3.1; Linux 2.4.19-32mdkenterprise; X11; i686; ar, en_US)", + "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4b) Gecko/20030504 Mozilla", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910", - "Mozilla/5.0 (X11; U; Linux 2.4.3-20mdk i586; en-US; rv:0.9.1) Gecko/20010611", - "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.9) Gecko/20050711", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs; rv:1.9) Gecko/2008052906", + "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4b) Gecko/20030504 Mozilla", + "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910", + "Mozilla/5.0 (X11; U; Linux 2.4.3-20mdk i586; en-US; rv:0.9.1) Gecko/20010611", + "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.9) Gecko/20050711", + "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs; rv:1.9) Gecko/2008052906", - "Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5", - "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6", - "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030423 Firebird Browser/0.6", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8", - "Mozilla/5.0 (Windows 98; U; en; rv:1.8.0) Gecko/20060728 Firefox/1.5.0", - "Mozilla/5.0 (Macintosh; PPC Mac OS X; U; en; rv:1.8.0) Gecko/20060728 Firefox/1.5.0", - "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.8.1.12) Gecko/20080210 Firefox/2.0.0.12", - "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.12) Gecko/20080214 Firefox/2.0.0.12", + "Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5", + "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6", + "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030423 Firebird Browser/0.6", + "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8", + "Mozilla/5.0 (Windows 98; U; en; rv:1.8.0) Gecko/20060728 Firefox/1.5.0", + "Mozilla/5.0 (Macintosh; PPC Mac OS X; U; en; rv:1.8.0) Gecko/20060728 Firefox/1.5.0", + "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.8.1.12) Gecko/20080210 Firefox/2.0.0.12", + "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.12) Gecko/20080214 Firefox/2.0.0.12", ); diff --git a/ext/standard/tests/misc/get_browser_basic.phpt b/ext/standard/tests/misc/get_browser_basic.phpt index 81eb9d52e986..85ac8e3493fa 100644 --- a/ext/standard/tests/misc/get_browser_basic.phpt +++ b/ext/standard/tests/misc/get_browser_basic.phpt @@ -18,7 +18,7 @@ $browsers = include __DIR__ . DIRECTORY_SEPARATOR . 'browsernames.inc'; echo "*** Testing get_browser() : basic functionality ***\n"; for( $x = 0; $x < 20; $x++) { - var_dump( get_browser( $browsers[$x], true ) ); + var_dump( get_browser( $browsers[$x], true ) ); } ?> diff --git a/ext/standard/tests/misc/get_browser_variation1.phpt b/ext/standard/tests/misc/get_browser_variation1.phpt index 7c32a722c7cd..58c3a2426783 100644 --- a/ext/standard/tests/misc/get_browser_variation1.phpt +++ b/ext/standard/tests/misc/get_browser_variation1.phpt @@ -19,7 +19,7 @@ echo "*** Testing get_browser() : variation functionality: extra browser names * $count = count( $browsers ); for( $x = 20; $x < $count; $x++) { - var_dump( get_browser( $browsers[$x], true ) ); + var_dump( get_browser( $browsers[$x], true ) ); } ?> diff --git a/ext/standard/tests/network/bug20134.phpt b/ext/standard/tests/network/bug20134.phpt index 260878d4743a..669f5c74ea22 100644 --- a/ext/standard/tests/network/bug20134.phpt +++ b/ext/standard/tests/network/bug20134.phpt @@ -5,17 +5,17 @@ Bug #20134 (UDP reads from invalid ports) $fp = fsockopen("udp://localhost", 65534, $errno, $errstr); if (!$fp) { - /* UDP will never cause a connection error, as it is - * a connection-LESS protocol */ + /* UDP will never cause a connection error, as it is + * a connection-LESS protocol */ echo "ERROR: $errno - $errstr
                  \n"; } else { - /* Likewise, writes will always appear to succeed */ + /* Likewise, writes will always appear to succeed */ $x = fwrite($fp,"\n"); - var_dump($x); - /* But reads should always fail */ + var_dump($x); + /* But reads should always fail */ $content = fread($fp, 40); - var_dump($content); + var_dump($content); fclose($fp); } ?> diff --git a/ext/standard/tests/network/bug64330.phpt b/ext/standard/tests/network/bug64330.phpt index 836709ea4989..311376503a19 100644 --- a/ext/standard/tests/network/bug64330.phpt +++ b/ext/standard/tests/network/bug64330.phpt @@ -11,7 +11,7 @@ echo "Test\n"; $server = stream_socket_server("unix://\x00/MyBindName"); $client = stream_socket_client("unix://\x00/MyBindName"); if ($client) { - echo "ok\n"; + echo "ok\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/network/gethostbyname_basic001.phpt b/ext/standard/tests/network/gethostbyname_basic001.phpt index e917b599207d..d65289ca4155 100644 --- a/ext/standard/tests/network/gethostbyname_basic001.phpt +++ b/ext/standard/tests/network/gethostbyname_basic001.phpt @@ -8,7 +8,7 @@ if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?> --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/network/gethostbyname_error001.phpt b/ext/standard/tests/network/gethostbyname_error001.phpt index f141be8b4e4d..87f4571fd319 100644 --- a/ext/standard/tests/network/gethostbyname_error001.phpt +++ b/ext/standard/tests/network/gethostbyname_error001.phpt @@ -4,7 +4,7 @@ gethostbyname() function - basic type return error test "Sylvain R." --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/network/gethostbyname_error002.phpt b/ext/standard/tests/network/gethostbyname_error002.phpt index 2430a7fcdc55..8f586d02ba8b 100644 --- a/ext/standard/tests/network/gethostbyname_error002.phpt +++ b/ext/standard/tests/network/gethostbyname_error002.phpt @@ -4,7 +4,7 @@ gethostbyname() function - basic type return error test "Sylvain R." --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/network/gethostbyname_error003.phpt b/ext/standard/tests/network/gethostbyname_error003.phpt index 3d4bb7a55e25..ebc8a971cb01 100644 --- a/ext/standard/tests/network/gethostbyname_error003.phpt +++ b/ext/standard/tests/network/gethostbyname_error003.phpt @@ -4,7 +4,7 @@ gethostbyname() function - basic type return error test "Sylvain R." --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/network/gethostbyname_error004.phpt b/ext/standard/tests/network/gethostbyname_error004.phpt index 274301a2368b..25ded4bc24f7 100644 --- a/ext/standard/tests/network/gethostbyname_error004.phpt +++ b/ext/standard/tests/network/gethostbyname_error004.phpt @@ -9,8 +9,8 @@ if (getenv("SKIP_ONLINE_TESTS")) die("skip test requiring internet connection"); ?> --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/network/gethostbyname_error006.phpt b/ext/standard/tests/network/gethostbyname_error006.phpt index 46247a113d0c..156ba0e623c3 100644 --- a/ext/standard/tests/network/gethostbyname_error006.phpt +++ b/ext/standard/tests/network/gethostbyname_error006.phpt @@ -4,7 +4,7 @@ gethostbyname() function - basic invalid parameter test "Sylvain R." --FILE-- --EXPECT-- string(15) ".toto.toto.toto" diff --git a/ext/standard/tests/network/getprotobyname_basic.phpt b/ext/standard/tests/network/getprotobyname_basic.phpt index 37cc26aa2b16..ee5e3961141b 100644 --- a/ext/standard/tests/network/getprotobyname_basic.phpt +++ b/ext/standard/tests/network/getprotobyname_basic.phpt @@ -4,7 +4,7 @@ getprotobyname function basic test edgarsandi - --FILE-- --EXPECT-- int(6) diff --git a/ext/standard/tests/network/getprotobynumber_basic.phpt b/ext/standard/tests/network/getprotobynumber_basic.phpt index 7850e60ffd90..d781ab92b010 100644 --- a/ext/standard/tests/network/getprotobynumber_basic.phpt +++ b/ext/standard/tests/network/getprotobynumber_basic.phpt @@ -4,7 +4,7 @@ getprotobynumber function basic test edgarsandi - --FILE-- --EXPECT-- string(3) "tcp" diff --git a/ext/standard/tests/network/inet.phpt b/ext/standard/tests/network/inet.phpt index 81db0016b57c..29b4aa0e6be9 100644 --- a/ext/standard/tests/network/inet.phpt +++ b/ext/standard/tests/network/inet.phpt @@ -23,14 +23,14 @@ var_dump(inet_pton(-1)); var_dump(inet_pton("abra")); $array = array( - "127.0.0.1", - "66.163.161.116", - "255.255.255.255", - "0.0.0.0", - ); + "127.0.0.1", + "66.163.161.116", + "255.255.255.255", + "0.0.0.0", + ); foreach ($array as $val) { - var_dump(bin2hex($packed = inet_pton($val))); - var_dump(inet_ntop($packed)); + var_dump(bin2hex($packed = inet_pton($val))); + var_dump(inet_ntop($packed)); } echo "Done\n"; diff --git a/ext/standard/tests/network/inet_ipv6.phpt b/ext/standard/tests/network/inet_ipv6.phpt index 55323688decd..f78d4be7cc98 100644 --- a/ext/standard/tests/network/inet_ipv6.phpt +++ b/ext/standard/tests/network/inet_ipv6.phpt @@ -15,20 +15,20 @@ if (stristr(PHP_OS, "darwin") !== false) die("skip MacOS has broken inet_*() fun diff --git a/ext/standard/tests/network/ip2long_variation2_x64.phpt b/ext/standard/tests/network/ip2long_variation2_x64.phpt index 563f579b848a..3ee59c9efb9f 100644 --- a/ext/standard/tests/network/ip2long_variation2_x64.phpt +++ b/ext/standard/tests/network/ip2long_variation2_x64.phpt @@ -19,18 +19,18 @@ if(PHP_INT_SIZE != 8) {die('skip 64 bit only');} */ $ips = array( - "1.1.011.011", - "127.0.0.1", - "1.1.071.071", - "0.0.0.0", - "1.1.081.081", - "192.168.0.0", - "256.0.0.1", - "192.168.0xa.5", + "1.1.011.011", + "127.0.0.1", + "1.1.071.071", + "0.0.0.0", + "1.1.081.081", + "192.168.0.0", + "256.0.0.1", + "192.168.0xa.5", ); foreach($ips as $ip) { - var_dump(ip2long($ip)); + var_dump(ip2long($ip)); } ?> diff --git a/ext/standard/tests/network/ip_x86_64.phpt b/ext/standard/tests/network/ip_x86_64.phpt index 06ed1549a60f..c659eb70fb8a 100644 --- a/ext/standard/tests/network/ip_x86_64.phpt +++ b/ext/standard/tests/network/ip_x86_64.phpt @@ -8,17 +8,17 @@ if (PHP_INT_SIZE == 4) die("skip this test is for >32bit platform only"); $tsp]); setcookie('name', 'value', ['expires' => $tsn, 'path' => '/path/', 'domain' => 'domain.tld', 'secure' => true, 'httponly' => true, 'samesite' => 'Strict']); $expected = array( - 'Set-Cookie: name=deleted; expires='.date('D, d-M-Y H:i:s', 1).' GMT; Max-Age=0', - 'Set-Cookie: name=deleted; expires='.date('D, d-M-Y H:i:s', 1).' GMT; Max-Age=0', - 'Set-Cookie: name=value', - 'Set-Cookie: name=space%20value', - 'Set-Cookie: name=value', - 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsp).' GMT; Max-Age=5', - 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsn).' GMT; Max-Age=0', - 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsc).' GMT; Max-Age=0', - 'Set-Cookie: name=value; path=/path/', - 'Set-Cookie: name=value; domain=domain.tld', - 'Set-Cookie: name=value; secure', - 'Set-Cookie: name=value; HttpOnly', - 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsp).' GMT; Max-Age=5', - 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsn).' GMT; Max-Age=0; path=/path/; domain=domain.tld; secure; HttpOnly; SameSite=Strict' + 'Set-Cookie: name=deleted; expires='.date('D, d-M-Y H:i:s', 1).' GMT; Max-Age=0', + 'Set-Cookie: name=deleted; expires='.date('D, d-M-Y H:i:s', 1).' GMT; Max-Age=0', + 'Set-Cookie: name=value', + 'Set-Cookie: name=space%20value', + 'Set-Cookie: name=value', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsp).' GMT; Max-Age=5', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsn).' GMT; Max-Age=0', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsc).' GMT; Max-Age=0', + 'Set-Cookie: name=value; path=/path/', + 'Set-Cookie: name=value; domain=domain.tld', + 'Set-Cookie: name=value; secure', + 'Set-Cookie: name=value; HttpOnly', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsp).' GMT; Max-Age=5', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsn).' GMT; Max-Age=0; path=/path/; domain=domain.tld; secure; HttpOnly; SameSite=Strict' ); $headers = headers_list(); if (($i = count($expected)) > count($headers)) { - echo "Fewer headers are being sent than expected - aborting"; - return; + echo "Fewer headers are being sent than expected - aborting"; + return; } do { - if (strncmp(current($headers), 'Set-Cookie:', 11) !== 0) - { - continue; - } + if (strncmp(current($headers), 'Set-Cookie:', 11) !== 0) + { + continue; + } - if (current($headers) === current($expected)) - { - $i--; - } - else - { - echo "Header mismatch:\n\tExpected: " - .current($expected) - ."\n\tReceived: ".current($headers)."\n"; - } + if (current($headers) === current($expected)) + { + $i--; + } + else + { + echo "Header mismatch:\n\tExpected: " + .current($expected) + ."\n\tReceived: ".current($headers)."\n"; + } - next($expected); + next($expected); } while (next($headers) !== FALSE); echo ($i === 0) - ? 'OK' - : 'A total of '.$i.' errors found.'; + ? 'OK' + : 'A total of '.$i.' errors found.'; ?> --EXPECTHEADERS-- diff --git a/ext/standard/tests/network/shutdown.phpt b/ext/standard/tests/network/shutdown.phpt index 1e79b059b143..b8655cc1f487 100644 --- a/ext/standard/tests/network/shutdown.phpt +++ b/ext/standard/tests/network/shutdown.phpt @@ -17,56 +17,56 @@ stream_socket_shutdown() test on IPv4 TCP Loopback } if (!$server) { - die('Unable to create AF_INET socket [server]'); - } + die('Unable to create AF_INET socket [server]'); + } - /* Connect and send request 1 */ - $client1 = stream_socket_client("tcp://127.0.0.1:$port"); - if (!$client1) { - die('Unable to create AF_INET socket [client]'); - } - @fwrite($client1, "Client 1\n"); - stream_socket_shutdown($client1, STREAM_SHUT_WR); - @fwrite($client1, "Error 1\n"); + /* Connect and send request 1 */ + $client1 = stream_socket_client("tcp://127.0.0.1:$port"); + if (!$client1) { + die('Unable to create AF_INET socket [client]'); + } + @fwrite($client1, "Client 1\n"); + stream_socket_shutdown($client1, STREAM_SHUT_WR); + @fwrite($client1, "Error 1\n"); - /* Connect and send request 2 */ - $client2 = stream_socket_client("tcp://127.0.0.1:$port"); - if (!$client2) { - die('Unable to create AF_INET socket [client]'); - } - @fwrite($client2, "Client 2\n"); - stream_socket_shutdown($client2, STREAM_SHUT_WR); - @fwrite($client2, "Error 2\n"); + /* Connect and send request 2 */ + $client2 = stream_socket_client("tcp://127.0.0.1:$port"); + if (!$client2) { + die('Unable to create AF_INET socket [client]'); + } + @fwrite($client2, "Client 2\n"); + stream_socket_shutdown($client2, STREAM_SHUT_WR); + @fwrite($client2, "Error 2\n"); - /* Accept connection 1 */ - $socket = stream_socket_accept($server); - if (!$socket) { - die('Unable to accept connection'); - } - @fwrite($socket, fgets($socket)); - @fwrite($socket, fgets($socket)); - fclose($socket); + /* Accept connection 1 */ + $socket = stream_socket_accept($server); + if (!$socket) { + die('Unable to accept connection'); + } + @fwrite($socket, fgets($socket)); + @fwrite($socket, fgets($socket)); + fclose($socket); - /* Read Response 1 */ - echo fgets($client1); - echo fgets($client1); + /* Read Response 1 */ + echo fgets($client1); + echo fgets($client1); - /* Accept connection 2 */ - $socket = stream_socket_accept($server); - if (!$socket) { - die('Unable to accept connection'); - } - @fwrite($socket, fgets($socket)); - @fwrite($socket, fgets($socket)); - fclose($socket); + /* Accept connection 2 */ + $socket = stream_socket_accept($server); + if (!$socket) { + die('Unable to accept connection'); + } + @fwrite($socket, fgets($socket)); + @fwrite($socket, fgets($socket)); + fclose($socket); - /* Read Response 2 */ - echo fgets($client2); - echo fgets($client2); + /* Read Response 2 */ + echo fgets($client2); + echo fgets($client2); - fclose($client1); - fclose($client2); - fclose($server); + fclose($client1); + fclose($client2); + fclose($server); ?> --EXPECT-- Client 1 diff --git a/ext/standard/tests/network/socket_bug74429.phpt b/ext/standard/tests/network/socket_bug74429.phpt index 2c955bb5be8e..f72e9e31d704 100644 --- a/ext/standard/tests/network/socket_bug74429.phpt +++ b/ext/standard/tests/network/socket_bug74429.phpt @@ -4,8 +4,8 @@ Bug #74429 Remote socket URI with unique persistence identifier broken --EXPECT-- string(10) "ABCdef123 diff --git a/ext/standard/tests/network/tcp6loop.phpt b/ext/standard/tests/network/tcp6loop.phpt index c8223633ca14..6f6e418ffccf 100644 --- a/ext/standard/tests/network/tcp6loop.phpt +++ b/ext/standard/tests/network/tcp6loop.phpt @@ -20,30 +20,30 @@ Streams Based IPv6 TCP Loopback test } } - if (!$server) { - die('Unable to create AF_INET6 socket [server]'); - } + if (!$server) { + die('Unable to create AF_INET6 socket [server]'); + } - /* Connect to it */ - $client = stream_socket_client("tcp://[::1]:$port"); - if (!$client) { - die('Unable to create AF_INET6 socket [client]'); - } + /* Connect to it */ + $client = stream_socket_client("tcp://[::1]:$port"); + if (!$client) { + die('Unable to create AF_INET6 socket [client]'); + } - /* Accept that connection */ - $socket = stream_socket_accept($server); - if (!$socket) { - die('Unable to accept connection'); - } + /* Accept that connection */ + $socket = stream_socket_accept($server); + if (!$socket) { + die('Unable to accept connection'); + } - fwrite($client, "ABCdef123\n"); + fwrite($client, "ABCdef123\n"); - $data = fread($socket, 10); - var_dump($data); + $data = fread($socket, 10); + var_dump($data); - fclose($client); - fclose($socket); - fclose($server); + fclose($client); + fclose($socket); + fclose($server); ?> --EXPECT-- string(10) "ABCdef123 diff --git a/ext/standard/tests/network/udgloop.phpt b/ext/standard/tests/network/udgloop.phpt index 47ecaf042e45..3a7e1bf267af 100644 --- a/ext/standard/tests/network/udgloop.phpt +++ b/ext/standard/tests/network/udgloop.phpt @@ -7,30 +7,30 @@ Streams Based Unix Domain Datagram Loopback test ?> --FILE-- --EXPECT-- string(10) "ABCdef123 diff --git a/ext/standard/tests/network/udp4loop.phpt b/ext/standard/tests/network/udp4loop.phpt index 3f78df267ae8..92709233ba19 100644 --- a/ext/standard/tests/network/udp4loop.phpt +++ b/ext/standard/tests/network/udp4loop.phpt @@ -2,29 +2,29 @@ Streams Based IPv4 UDP Loopback test --FILE-- --EXPECT-- string(10) "ABCdef123 diff --git a/ext/standard/tests/network/udp6loop.phpt b/ext/standard/tests/network/udp6loop.phpt index 3b70f43119a8..06d9bf48119e 100644 --- a/ext/standard/tests/network/udp6loop.phpt +++ b/ext/standard/tests/network/udp6loop.phpt @@ -26,23 +26,23 @@ Streams Based IPv6 UDP Loopback test } } - if (!$server) { - die('Unable to create AF_INET6 socket [server]'); - } + if (!$server) { + die('Unable to create AF_INET6 socket [server]'); + } - /* Connect to it */ - $client = stream_socket_client("udp://[::1]:$port"); - if (!$client) { - die('Unable to create AF_INET6 socket [client]'); - } + /* Connect to it */ + $client = stream_socket_client("udp://[::1]:$port"); + if (!$client) { + die('Unable to create AF_INET6 socket [client]'); + } - fwrite($client, "ABCdef123\n"); + fwrite($client, "ABCdef123\n"); - $data = fread($server, 10); - var_dump($data); + $data = fread($server, 10); + var_dump($data); - fclose($client); - fclose($server); + fclose($client); + fclose($server); ?> --EXPECT-- string(10) "ABCdef123 diff --git a/ext/standard/tests/network/unixloop.phpt b/ext/standard/tests/network/unixloop.phpt index 2e95beb9f5de..4b5bde2262fe 100644 --- a/ext/standard/tests/network/unixloop.phpt +++ b/ext/standard/tests/network/unixloop.phpt @@ -7,37 +7,37 @@ Streams Based Unix Domain Loopback test ?> --FILE-- --EXPECT-- string(10) "ABCdef123 diff --git a/ext/standard/tests/password/password_hash_argon2.phpt b/ext/standard/tests/password/password_hash_argon2.phpt index a7612effa972..399c4cd4bc2a 100644 --- a/ext/standard/tests/password/password_hash_argon2.phpt +++ b/ext/standard/tests/password/password_hash_argon2.phpt @@ -10,12 +10,12 @@ if (!defined('PASSWORD_ARGON2ID')) die('skip password_hash not built with Argon2 $password = "the password for testing 12345!"; $algos = [ - PASSWORD_ARGON2I, - 'argon2i', - 2, - PASSWORD_ARGON2ID, - 'argon2id', - 3, + PASSWORD_ARGON2I, + 'argon2i', + 2, + PASSWORD_ARGON2ID, + 'argon2id', + 3, ]; foreach ($algos as $algo) { $hash = password_hash($password, $algo); diff --git a/ext/standard/tests/serialize/001.phpt b/ext/standard/tests/serialize/001.phpt index 5551956e92b7..147c355b08c8 100644 --- a/ext/standard/tests/serialize/001.phpt +++ b/ext/standard/tests/serialize/001.phpt @@ -6,36 +6,36 @@ serialize_precision=100 a = "hallo"; - } + function __construct() + { + $this->a = "hallo"; + } } class s { - public $a; - public $b; - public $c; + public $a; + public $b; + public $c; - function __construct() - { - $this->a = "hallo"; - $this->b = "php"; - $this->c = "world"; - $this->d = "!"; - } + function __construct() + { + $this->a = "hallo"; + $this->b = "php"; + $this->c = "world"; + $this->d = "!"; + } - function __sleep() - { - echo "__sleep called\n"; - return array("a","c"); - } + function __sleep() + { + echo "__sleep called\n"; + return array("a","c"); + } - function __wakeup() - { - echo "__wakeup called\n"; - } + function __wakeup() + { + echo "__wakeup called\n"; + } } diff --git a/ext/standard/tests/serialize/003.phpt b/ext/standard/tests/serialize/003.phpt index 501141280986..cf54f40406ae 100644 --- a/ext/standard/tests/serialize/003.phpt +++ b/ext/standard/tests/serialize/003.phpt @@ -6,9 +6,9 @@ serialize_precision=100 --FILE-- --EXPECTREGEX-- diff --git a/ext/standard/tests/serialize/005.phpt b/ext/standard/tests/serialize/005.phpt index 13ae0501297d..fd9fcaac1859 100644 --- a/ext/standard/tests/serialize/005.phpt +++ b/ext/standard/tests/serialize/005.phpt @@ -7,93 +7,93 @@ serialize()/unserialize() objects function do_autoload($class_name) { - if ($class_name != 'autoload_not_available') - { - require_once(__DIR__ . '/' . strtolower($class_name) . '.inc'); - } - echo __FUNCTION__ . "($class_name)\n"; + if ($class_name != 'autoload_not_available') + { + require_once(__DIR__ . '/' . strtolower($class_name) . '.inc'); + } + echo __FUNCTION__ . "($class_name)\n"; } function unserializer($class_name) { - echo __METHOD__ . "($class_name)\n"; - switch($class_name) - { - case 'TestNAOld': - eval("class TestNAOld extends TestOld {}"); - break; - case 'TestNANew': - eval("class TestNANew extends TestNew {}"); - break; - case 'TestNANew2': - eval("class TestNANew2 extends TestNew {}"); - break; - default: - echo "Try autoloader\n"; - if (!spl_autoload_functions()) { - spl_autoload_register(function ($class_name) { do_autoload($class_name); }); - } - spl_autoload_call($class_name); - break; - } + echo __METHOD__ . "($class_name)\n"; + switch($class_name) + { + case 'TestNAOld': + eval("class TestNAOld extends TestOld {}"); + break; + case 'TestNANew': + eval("class TestNANew extends TestNew {}"); + break; + case 'TestNANew2': + eval("class TestNANew2 extends TestNew {}"); + break; + default: + echo "Try autoloader\n"; + if (!spl_autoload_functions()) { + spl_autoload_register(function ($class_name) { do_autoload($class_name); }); + } + spl_autoload_call($class_name); + break; + } } ini_set('unserialize_callback_func', 'unserializer'); class TestOld { - function serialize() - { - echo __METHOD__ . "()\n"; - } - - function unserialize($serialized) - { - echo __METHOD__ . "()\n"; - } - - function __wakeup() - { - echo __METHOD__ . "()\n"; - } - - function __sleep() - { - echo __METHOD__ . "()\n"; - return array(); - } + function serialize() + { + echo __METHOD__ . "()\n"; + } + + function unserialize($serialized) + { + echo __METHOD__ . "()\n"; + } + + function __wakeup() + { + echo __METHOD__ . "()\n"; + } + + function __sleep() + { + echo __METHOD__ . "()\n"; + return array(); + } } class TestNew implements Serializable { - protected static $check = 0; - - function serialize() - { - echo __METHOD__ . "()\n"; - switch(++self::$check) - { - case 1: - return NULL; - case 2: - return "2"; - } - } - - function unserialize($serialized) - { - echo __METHOD__ . "()\n"; - } - - function __wakeup() - { - echo __METHOD__ . "()\n"; - } - - function __sleep() - { - echo __METHOD__ . "()\n"; - } + protected static $check = 0; + + function serialize() + { + echo __METHOD__ . "()\n"; + switch(++self::$check) + { + case 1: + return NULL; + case 2: + return "2"; + } + } + + function unserialize($serialized) + { + echo __METHOD__ . "()\n"; + } + + function __wakeup() + { + echo __METHOD__ . "()\n"; + } + + function __sleep() + { + echo __METHOD__ . "()\n"; + } } echo "===O1===\n"; diff --git a/ext/standard/tests/serialize/006.phpt b/ext/standard/tests/serialize/006.phpt index 6ba93f4d23bf..24b3cbbe2d7d 100644 --- a/ext/standard/tests/serialize/006.phpt +++ b/ext/standard/tests/serialize/006.phpt @@ -2,19 +2,19 @@ serialize()/unserialize() with exotic letters --FILE-- 'åäöÅÄÖ'); + $åäöÅÄÖ = array('åäöÅÄÖ' => 'åäöÅÄÖ'); - class ÜberKööliäå - { - public $åäöÅÄÖüÜber = 'åäöÅÄÖ'; - } + class ÜberKööliäå + { + public $åäöÅÄÖüÜber = 'åäöÅÄÖ'; + } $foo = new Überkööliäå(); - var_dump(serialize($foo)); - var_dump(unserialize(serialize($foo))); - var_dump(serialize($åäöÅÄÖ)); - var_dump(unserialize(serialize($åäöÅÄÖ))); + var_dump(serialize($foo)); + var_dump(unserialize(serialize($foo))); + var_dump(serialize($åäöÅÄÖ)); + var_dump(unserialize(serialize($åäöÅÄÖ))); ?> --EXPECT-- string(55) "O:11:"ÜberKööliäå":1:{s:11:"åäöÅÄÖüÜber";s:6:"åäöÅÄÖ";}" diff --git a/ext/standard/tests/serialize/autoload_implements.inc b/ext/standard/tests/serialize/autoload_implements.inc index 55fcc3cd9f73..e5f19c06803a 100644 --- a/ext/standard/tests/serialize/autoload_implements.inc +++ b/ext/standard/tests/serialize/autoload_implements.inc @@ -1,10 +1,10 @@ diff --git a/ext/standard/tests/serialize/autoload_interface.inc b/ext/standard/tests/serialize/autoload_interface.inc index e6a416e72177..6e696f36bf00 100644 --- a/ext/standard/tests/serialize/autoload_interface.inc +++ b/ext/standard/tests/serialize/autoload_interface.inc @@ -1,7 +1,7 @@ diff --git a/ext/standard/tests/serialize/bug14293.phpt b/ext/standard/tests/serialize/bug14293.phpt index 73636ba56d51..875f8b2bc81e 100644 --- a/ext/standard/tests/serialize/bug14293.phpt +++ b/ext/standard/tests/serialize/bug14293.phpt @@ -4,16 +4,16 @@ Bug #14293 (serialize() and __sleep()) a = 'hello'; - } + function __construct() + { + $this->a = 'hello'; + } - function __sleep() - { - echo "__sleep called\n"; - return array('a','b'); - } + function __sleep() + { + echo "__sleep called\n"; + return array('a','b'); + } } $t = new t(); diff --git a/ext/standard/tests/serialize/bug21957.phpt b/ext/standard/tests/serialize/bug21957.phpt index 070eda3f4ced..9d761a6699c9 100644 --- a/ext/standard/tests/serialize/bug21957.phpt +++ b/ext/standard/tests/serialize/bug21957.phpt @@ -4,18 +4,18 @@ Bug #21957 (serialize() mangles objects with __sleep) a = 7; - $this->b = 2; - } + function __construct() + { + $this->a = 7; + $this->b = 2; + } - function __sleep() - { - $this->b = 0; - } + function __sleep() + { + $this->b = 0; + } } $t['one'] = 'ABC'; diff --git a/ext/standard/tests/serialize/bug23298.phpt b/ext/standard/tests/serialize/bug23298.phpt index fe56fccc4516..29d09d18e9d4 100644 --- a/ext/standard/tests/serialize/bug23298.phpt +++ b/ext/standard/tests/serialize/bug23298.phpt @@ -4,10 +4,10 @@ Bug #23298 (serialize() and floats/doubles) serialize_precision=100 --FILE-- --EXPECT-- bool(true) diff --git a/ext/standard/tests/serialize/bug24063.phpt b/ext/standard/tests/serialize/bug24063.phpt index 38c9d6ed2473..e3102245f8f7 100644 --- a/ext/standard/tests/serialize/bug24063.phpt +++ b/ext/standard/tests/serialize/bug24063.phpt @@ -7,8 +7,8 @@ precision=12 --EXPECT-- diff --git a/ext/standard/tests/serialize/bug26762.phpt b/ext/standard/tests/serialize/bug26762.phpt index ad6c0e0b4151..d4daf34464c5 100644 --- a/ext/standard/tests/serialize/bug26762.phpt +++ b/ext/standard/tests/serialize/bug26762.phpt @@ -10,15 +10,15 @@ Bug #26762 (unserialize() produces lowercase classnames) ini_set('unserialize_callback_func','check'); function check($name) { - var_dump($name); - throw new exception; + var_dump($name); + throw new exception; } try { - @unserialize('O:3:"FOO":0:{}'); + @unserialize('O:3:"FOO":0:{}'); } catch (Exception $e) { - /* ignore */ + /* ignore */ } ?> diff --git a/ext/standard/tests/serialize/bug28325.phpt b/ext/standard/tests/serialize/bug28325.phpt index ee0e60e1ad1a..cd909dc07d8c 100644 --- a/ext/standard/tests/serialize/bug28325.phpt +++ b/ext/standard/tests/serialize/bug28325.phpt @@ -3,13 +3,13 @@ Bug #28325 (Problem in serialisation of circular references) --FILE-- b = new b(); diff --git a/ext/standard/tests/serialize/bug30234.phpt b/ext/standard/tests/serialize/bug30234.phpt index 4b45d8d1ef84..66e5aa3547fc 100644 --- a/ext/standard/tests/serialize/bug30234.phpt +++ b/ext/standard/tests/serialize/bug30234.phpt @@ -8,8 +8,8 @@ Bug #30234 (__autoload() not invoked for interfaces) e[] = $e; - $e->e = $c->e; - } + for ($i = 0; $i < 4; $i++) + { + $e = new A; + $c->e[] = $e; + $e->e = $c->e; + } - return serialize(array(serialize($c))); - } + return serialize(array(serialize($c))); + } - public function unserialize($str) - { - $r = unserialize($str); - $r = unserialize($r[0]); - } + public function unserialize($str) + { + $r = unserialize($str); + $r = unserialize($r[0]); + } } $token = new Token; diff --git a/ext/standard/tests/serialize/bug65806.phpt b/ext/standard/tests/serialize/bug65806.phpt index cefb923f2314..166b694442b7 100644 --- a/ext/standard/tests/serialize/bug65806.phpt +++ b/ext/standard/tests/serialize/bug65806.phpt @@ -33,8 +33,8 @@ class myList { } public function __wakeup() { - $this->_obj = unserialize($this->_serialized); - } + $this->_obj = unserialize($this->_serialized); + } } echo "SCRIPT START" . PHP_EOL; diff --git a/ext/standard/tests/serialize/bug67072.phpt b/ext/standard/tests/serialize/bug67072.phpt index 951db75a071f..df0593180d56 100644 --- a/ext/standard/tests/serialize/bug67072.phpt +++ b/ext/standard/tests/serialize/bug67072.phpt @@ -2,7 +2,7 @@ Bug #67072 Echoing unserialized "SplFileObject" crash --FILE-- ===DONE== --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug68044.phpt b/ext/standard/tests/serialize/bug68044.phpt index 01ada07ad84f..dc6053c501d4 100644 --- a/ext/standard/tests/serialize/bug68044.phpt +++ b/ext/standard/tests/serialize/bug68044.phpt @@ -2,7 +2,7 @@ Bug #68044 Integer overflow in unserialize() (32-bits only) --FILE-- ===DONE== --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug68594.phpt b/ext/standard/tests/serialize/bug68594.phpt index fbf9310d0b9d..69ff9e2bf4cd 100644 --- a/ext/standard/tests/serialize/bug68594.phpt +++ b/ext/standard/tests/serialize/bug68594.phpt @@ -3,19 +3,19 @@ Bug #68545 Use after free vulnerability in unserialize() --FILE-- aaa = array(1,2,&$u,4,5); - $m->bbb = 1; - $m->ccc = &$u; - $m->ddd = str_repeat("A", $i); + $m->aaa = array(1,2,&$u,4,5); + $m->bbb = 1; + $m->ccc = &$u; + $m->ddd = str_repeat("A", $i); - $z = serialize($m); - $z = str_replace("bbb", "aaa", $z); - $y = unserialize($z); - $z = serialize($y); + $z = serialize($m); + $z = str_replace("bbb", "aaa", $z); + $y = unserialize($z); + $z = serialize($y); } ?> ===DONE=== diff --git a/ext/standard/tests/serialize/bug68976.phpt b/ext/standard/tests/serialize/bug68976.phpt index d9ca33bdf727..514bd8b453fd 100644 --- a/ext/standard/tests/serialize/bug68976.phpt +++ b/ext/standard/tests/serialize/bug68976.phpt @@ -3,10 +3,10 @@ Bug #68976 Use After Free Vulnerability in unserialize() --FILE-- name); - } + public $name; + function __wakeup() { + unset($this->name); + } } $fakezval = pack( diff --git a/ext/standard/tests/serialize/bug69210.phpt b/ext/standard/tests/serialize/bug69210.phpt index c06fe50e0295..610c88f879bf 100644 --- a/ext/standard/tests/serialize/bug69210.phpt +++ b/ext/standard/tests/serialize/bug69210.phpt @@ -4,22 +4,22 @@ serialize() integrity with non string on __sleep ryat = 1; - } + function __wakeup() + { + $this->ryat = 1; + } } $data = unserialize('a:2:{i:0;O:4:"test":1:{s:4:"ryat";R:1;}i:1;i:2;}'); diff --git a/ext/standard/tests/serialize/bug70172.phpt b/ext/standard/tests/serialize/bug70172.phpt index a2359d643453..18bc2fe85da1 100644 --- a/ext/standard/tests/serialize/bug70172.phpt +++ b/ext/standard/tests/serialize/bug70172.phpt @@ -3,13 +3,13 @@ Bug #70172 - Use After Free Vulnerability in unserialize() --FILE-- data); - } - function unserialize($data) { - $this->data = unserialize($data); - } + var $data; + function serialize() { + return serialize($this->data); + } + function unserialize($data) { + $this->data = unserialize($data); + } } $fakezval = ptr2str(1122334455); @@ -25,19 +25,19 @@ $exploit = 'a:2:{i:0;i:1;i:1;C:3:"obj":'.strlen($inner).':{'.$inner.'}}'; $data = unserialize($exploit); for ($i = 0; $i < 5; $i++) { - $v[$i] = $fakezval.$i; + $v[$i] = $fakezval.$i; } var_dump($data); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug70172_2.phpt b/ext/standard/tests/serialize/bug70172_2.phpt index 2b12a78edb5b..771f9ba1d7a8 100644 --- a/ext/standard/tests/serialize/bug70172_2.phpt +++ b/ext/standard/tests/serialize/bug70172_2.phpt @@ -3,20 +3,20 @@ Bug #70172 - Use After Free Vulnerability in unserialize() --FILE-- data); - } - function unserialize($data) { - $this->data = unserialize($data); - } + var $data; + function serialize() { + return serialize($this->data); + } + function unserialize($data) { + $this->data = unserialize($data); + } } class obj2 { - var $ryat; - function __wakeup() { - $this->ryat = 1; - } + var $ryat; + function __wakeup() { + $this->ryat = 1; + } } $fakezval = ptr2str(1122334455); @@ -32,19 +32,19 @@ $exploit = 'a:2:{i:0;O:4:"obj2":1:{s:4:"ryat";C:3:"obj":'.strlen($inner).':{'.$i $data = unserialize($exploit); for ($i = 0; $i < 5; $i++) { - $v[$i] = $fakezval.$i; + $v[$i] = $fakezval.$i; } var_dump($data); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug70213.phpt b/ext/standard/tests/serialize/bug70213.phpt index fd7d4001f886..7129fe45f6cd 100644 --- a/ext/standard/tests/serialize/bug70213.phpt +++ b/ext/standard/tests/serialize/bug70213.phpt @@ -6,7 +6,7 @@ Bug #70213: Unserialize context shared on double class lookup ini_set('unserialize_callback_func', 'evil'); function evil() { - spl_autoload_register(function ($arg) { + spl_autoload_register(function ($arg) { var_dump(unserialize('R:1;')); }); } diff --git a/ext/standard/tests/serialize/bug70436.phpt b/ext/standard/tests/serialize/bug70436.phpt index 1bbf3b98ab56..9cd97a689c00 100644 --- a/ext/standard/tests/serialize/bug70436.phpt +++ b/ext/standard/tests/serialize/bug70436.phpt @@ -5,17 +5,17 @@ Bug #70436: Use After Free Vulnerability in unserialize() class obj implements Serializable { - var $data; + var $data; - function serialize() - { - return serialize($this->data); - } + function serialize() + { + return serialize($this->data); + } - function unserialize($data) - { - $this->data = unserialize($data); - } + function unserialize($data) + { + $this->data = unserialize($data); + } } $fakezval = ptr2str(1122334455); @@ -34,14 +34,14 @@ var_dump($data); function ptr2str($ptr) { - $out = ''; + $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } - return $out; + return $out; } ?> DONE diff --git a/ext/standard/tests/serialize/bug70513.phpt b/ext/standard/tests/serialize/bug70513.phpt index cbdbdb822284..4f228b5b7b04 100644 --- a/ext/standard/tests/serialize/bug70513.phpt +++ b/ext/standard/tests/serialize/bug70513.phpt @@ -7,12 +7,12 @@ Bug #70513: GMP Deserialization Type Confusion Vulnerability class obj { - var $ryat; + var $ryat; - function __wakeup() - { - $this->ryat = 1; - } + function __wakeup() + { + $this->ryat = 1; + } } $obj = new stdClass; diff --git a/ext/standard/tests/serialize/bug71995.phpt b/ext/standard/tests/serialize/bug71995.phpt index 0f7ac9872225..f1c45d25cc9c 100644 --- a/ext/standard/tests/serialize/bug71995.phpt +++ b/ext/standard/tests/serialize/bug71995.phpt @@ -4,13 +4,13 @@ Bug #71995 (Returning the same var twice from __sleep() produces broken serializ b = new StdClass(); - } - public function __sleep() { - return array("b", "b"); - } + public $b; + public function __construct() { + $this->b = new StdClass(); + } + public function __sleep() { + return array("b", "b"); + } } $a = new A(); $s = serialize($a); diff --git a/ext/standard/tests/serialize/bug72731.phpt b/ext/standard/tests/serialize/bug72731.phpt index 020fb3281f37..9489928cfb12 100644 --- a/ext/standard/tests/serialize/bug72731.phpt +++ b/ext/standard/tests/serialize/bug72731.phpt @@ -4,10 +4,10 @@ Bug #72731: Type Confusion in Object Deserialization ryat = 0x1122334455; - } + var $ryat; + function __wakeup() { + $this->ryat = 0x1122334455; + } } $poc = 'O:8:"stdClass":1:{i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}'; diff --git a/ext/standard/tests/serialize/bug73341.phpt b/ext/standard/tests/serialize/bug73341.phpt index 86fd457c6068..2f38949c1ae8 100644 --- a/ext/standard/tests/serialize/bug73341.phpt +++ b/ext/standard/tests/serialize/bug73341.phpt @@ -6,7 +6,7 @@ try { $token = 'a:2:{i:0;O:1:"0":2:0s:1:"0";i:0;s:1:"0";a:1:{i:0;C:11:"ArrayObject":7:{x:i:0;r}'; $obj = unserialize($token); } catch(Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } try { @@ -14,7 +14,7 @@ $inner = 'x:i:1;O:8:"stdClass":1:{};m:a:0:{}'; $exploit = 'C:11:"ArrayObject":'.strlen($inner).':{'.$inner.'}'; unserialize($exploit); } catch(Exception $e) { - echo $e->getMessage()."\n"; + echo $e->getMessage()."\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/serialize/bug76300.phpt b/ext/standard/tests/serialize/bug76300.phpt index 13e50f03322d..156c31a909c8 100644 --- a/ext/standard/tests/serialize/bug76300.phpt +++ b/ext/standard/tests/serialize/bug76300.phpt @@ -3,19 +3,19 @@ Bug #76300: Unserialize of extended protected member broken --FILE-- id = $id; - } + private $id; + public function __construct($id) + { + $this->id = $id; + } } class Derived extends Base { - protected $id; - public function __construct($id) - { - parent::__construct($id + 20); - $this->id = $id; - } + protected $id; + public function __construct($id) + { + parent::__construct($id + 20); + $this->id = $id; + } } $a = new Derived(44); $s = serialize($a); diff --git a/ext/standard/tests/serialize/precision.phpt b/ext/standard/tests/serialize/precision.phpt index 229c514e6993..ec6d8e340830 100644 --- a/ext/standard/tests/serialize/precision.phpt +++ b/ext/standard/tests/serialize/precision.phpt @@ -8,30 +8,30 @@ if (pack('s', 1) != "\x01\x00") $v) { - if (is_array($v)){ - foreach($b[$k] as $sk=>$sv) { - $b[$k][$sk] = "b$k.$sk.changed"; - var_dump($b); - } - } else { - $b[$k] = "b$k.changed"; - var_dump($b); - } - } + // Change each element and dump result. + foreach($b as $k=>$v) { + if (is_array($v)){ + foreach($b[$k] as $sk=>$sv) { + $b[$k][$sk] = "b$k.$sk.changed"; + var_dump($b); + } + } else { + $b[$k] = "b$k.changed"; + var_dump($b); + } + } } echo "\n\n--- Nested array references 1 element in containing array:\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_007.phpt b/ext/standard/tests/serialize/serialization_objects_007.phpt index ff584a091982..5082b7ff0128 100644 --- a/ext/standard/tests/serialize/serialization_objects_007.phpt +++ b/ext/standard/tests/serialize/serialization_objects_007.phpt @@ -14,13 +14,13 @@ Ensure __autoload is called twice if unserialize_callback_func is defined. */ spl_autoload_register(function ($name) { - echo "in autoload($name)\n"; + echo "in autoload($name)\n"; }); ini_set('unserialize_callback_func','check'); function check($name) { - echo "in check($name)\n"; + echo "in check($name)\n"; } $o = unserialize('O:3:"FOO":0:{}'); diff --git a/ext/standard/tests/serialize/serialization_objects_010.phpt b/ext/standard/tests/serialize/serialization_objects_010.phpt index 32205209f7f5..51938710cd93 100644 --- a/ext/standard/tests/serialize/serialization_objects_010.phpt +++ b/ext/standard/tests/serialize/serialization_objects_010.phpt @@ -14,18 +14,18 @@ Serialize() must return a string or NULL */ Class C implements Serializable { - public function serialize() { - return $this; - } + public function serialize() { + return $this; + } - public function unserialize($blah) { - } + public function unserialize($blah) { + } } try { - var_dump(serialize(new C)); + var_dump(serialize(new C)); } catch (Exception $e) { - echo $e->getMessage(). "\n"; + echo $e->getMessage(). "\n"; } echo "Done"; diff --git a/ext/standard/tests/serialize/serialization_objects_011.phpt b/ext/standard/tests/serialize/serialization_objects_011.phpt index a224a13d0c75..9f360c2cb936 100644 --- a/ext/standard/tests/serialize/serialization_objects_011.phpt +++ b/ext/standard/tests/serialize/serialization_objects_011.phpt @@ -14,57 +14,57 @@ Object serialization / unserialization with inherited and hidden properties. */ Class A { - private $APriv = "A.APriv"; - protected $AProt = "A.AProt"; - public $APub = "A.APub"; + private $APriv = "A.APriv"; + protected $AProt = "A.AProt"; + public $APub = "A.APub"; - function audit() { - return isset($this->APriv, $this->AProt, $this->APub); - } + function audit() { + return isset($this->APriv, $this->AProt, $this->APub); + } } Class B extends A { - private $BPriv = "B.BPriv"; - protected $BProt = "B.BProt"; - public $BPub = "B.BPub"; - - function audit() { - return parent::audit() && isset($this->AProt, $this->APub, - $this->BPriv, $this->BProt, $this->BPub); - } + private $BPriv = "B.BPriv"; + protected $BProt = "B.BProt"; + public $BPub = "B.BPub"; + + function audit() { + return parent::audit() && isset($this->AProt, $this->APub, + $this->BPriv, $this->BProt, $this->BPub); + } } Class C extends B { - private $APriv = "C.APriv"; - protected $AProt = "C.AProt"; - public $APub = "C.APub"; - - private $CPriv = "C.CPriv"; - protected $CProt = "C.BProt"; - public $CPub = "C.CPub"; - - function audit() { - return parent::audit() && isset($this->APriv, $this->AProt, $this->APub, - $this->BProt, $this->BPub, - $this->CPriv, $this->CProt, $this->CPub); - } + private $APriv = "C.APriv"; + protected $AProt = "C.AProt"; + public $APub = "C.APub"; + + private $CPriv = "C.CPriv"; + protected $CProt = "C.BProt"; + public $CPub = "C.CPub"; + + function audit() { + return parent::audit() && isset($this->APriv, $this->AProt, $this->APub, + $this->BProt, $this->BPub, + $this->CPriv, $this->CProt, $this->CPub); + } } function prettyPrint($obj) { - echo "\n\nBefore serialization:\n"; - var_dump($obj); + echo "\n\nBefore serialization:\n"; + var_dump($obj); - echo "Serialized form:\n"; - $ser = serialize($obj); - $serPrintable = str_replace("\0", '\0', $ser); - var_dump($serPrintable); + echo "Serialized form:\n"; + $ser = serialize($obj); + $serPrintable = str_replace("\0", '\0', $ser); + var_dump($serPrintable); - echo "Unserialized:\n"; - $uobj = unserialize($ser); - var_dump($uobj); + echo "Unserialized:\n"; + $uobj = unserialize($ser); + var_dump($uobj); - echo "Sanity check: "; - var_dump($uobj->audit()); + echo "Sanity check: "; + var_dump($uobj->audit()); } echo "-- Test instance of A --\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_013.phpt b/ext/standard/tests/serialize/serialization_objects_013.phpt index 3ff2d3cc11e5..547d7f75e897 100644 --- a/ext/standard/tests/serialize/serialization_objects_013.phpt +++ b/ext/standard/tests/serialize/serialization_objects_013.phpt @@ -14,18 +14,18 @@ Object serialization / unserialization: references amongst properties */ function check(&$obj) { - var_dump($obj); - $ser = serialize($obj); - var_dump($ser); + var_dump($obj); + $ser = serialize($obj); + var_dump($ser); - $uobj = unserialize($ser); - var_dump($uobj); - $uobj->a = "obj->a.changed"; - var_dump($uobj); - $uobj->b = "obj->b.changed"; - var_dump($uobj); - $uobj->c = "obj->c.changed"; - var_dump($uobj); + $uobj = unserialize($ser); + var_dump($uobj); + $uobj->a = "obj->a.changed"; + var_dump($uobj); + $uobj->b = "obj->b.changed"; + var_dump($uobj); + $uobj->c = "obj->c.changed"; + var_dump($uobj); } echo "\n\n--- a refs b:\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_014.phpt b/ext/standard/tests/serialize/serialization_objects_014.phpt index fa15a577b018..b8bf6fd3bc94 100644 --- a/ext/standard/tests/serialize/serialization_objects_014.phpt +++ b/ext/standard/tests/serialize/serialization_objects_014.phpt @@ -14,18 +14,18 @@ Object serialization / unserialization: references to external values */ function check(&$obj) { - var_dump($obj); - $ser = serialize($obj); - var_dump($ser); + var_dump($obj); + $ser = serialize($obj); + var_dump($ser); - $uobj = unserialize($ser); - var_dump($uobj); - $uobj->a = "obj->a.changed"; - var_dump($uobj); - $uobj->b = "obj->b.changed"; - var_dump($uobj); - $uobj->c = "obj->c.changed"; - var_dump($uobj); + $uobj = unserialize($ser); + var_dump($uobj); + $uobj->a = "obj->a.changed"; + var_dump($uobj); + $uobj->b = "obj->b.changed"; + var_dump($uobj); + $uobj->c = "obj->c.changed"; + var_dump($uobj); } echo "\n\n--- a refs external:\n"; diff --git a/ext/standard/tests/serialize/serialization_objects_015.phpt b/ext/standard/tests/serialize/serialization_objects_015.phpt index c1a6675db4cc..522450bfc1dc 100644 --- a/ext/standard/tests/serialize/serialization_objects_015.phpt +++ b/ext/standard/tests/serialize/serialization_objects_015.phpt @@ -4,18 +4,18 @@ Object serialization / unserialization: properties reference containing object a = "obj->a.changed"; - var_dump($uobj); - $uobj->b = "obj->b.changed"; - var_dump($uobj); - $uobj->c = "obj->c.changed"; - var_dump($uobj); + $uobj = unserialize($ser); + var_dump($uobj); + $uobj->a = "obj->a.changed"; + var_dump($uobj); + $uobj->b = "obj->b.changed"; + var_dump($uobj); + $uobj->c = "obj->c.changed"; + var_dump($uobj); } echo "\n\n--- a refs container:\n"; diff --git a/ext/standard/tests/serialize/typed_property_refs.phpt b/ext/standard/tests/serialize/typed_property_refs.phpt index 72bad612b0f3..3c8096a3928e 100644 --- a/ext/standard/tests/serialize/typed_property_refs.phpt +++ b/ext/standard/tests/serialize/typed_property_refs.phpt @@ -4,18 +4,18 @@ unserialize with references to typed properties shall skip the references or fai constructorCalled = true; - } - - function stream_open($path, $mode, $options, &$opened_path) - { - echo $this->constructorCalled ? 'yes' : 'no'; - return true; - } - - function url_stat($url, $flags) - { - echo $this->constructorCalled ? 'yes' : 'no'; - return array(); - } - - function unlink($url) - { - echo $this->constructorCalled ? 'yes' : 'no'; - } - - function rename($from, $to) - { - echo $this->constructorCalled ? 'yes' : 'no'; - } - - function mkdir($dir, $mode, $options) - { - echo $this->constructorCalled ? 'yes' : 'no'; - } - - function rmdir($dir, $options) - { - echo $this->constructorCalled ? 'yes' : 'no'; - } - - function dir_opendir($url, $options) - { - echo $this->constructorCalled ? 'yes' : 'no'; - return TRUE; - } - function stream_metadata() - { - echo $this->constructorCalled ? 'yes' : 'no'; - return TRUE; - } + private $constructorCalled = false; + function __construct() { + $this->constructorCalled = true; + } + + function stream_open($path, $mode, $options, &$opened_path) + { + echo $this->constructorCalled ? 'yes' : 'no'; + return true; + } + + function url_stat($url, $flags) + { + echo $this->constructorCalled ? 'yes' : 'no'; + return array(); + } + + function unlink($url) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function rename($from, $to) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function mkdir($dir, $mode, $options) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function rmdir($dir, $options) + { + echo $this->constructorCalled ? 'yes' : 'no'; + } + + function dir_opendir($url, $options) + { + echo $this->constructorCalled ? 'yes' : 'no'; + return TRUE; + } + function stream_metadata() + { + echo $this->constructorCalled ? 'yes' : 'no'; + return TRUE; + } } stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL); diff --git a/ext/standard/tests/streams/bug44818.phpt b/ext/standard/tests/streams/bug44818.phpt index 0446dfd3be72..2fe14bd0f1f5 100644 --- a/ext/standard/tests/streams/bug44818.phpt +++ b/ext/standard/tests/streams/bug44818.phpt @@ -3,11 +3,11 @@ Bug #44818 (php://memory writeable when opened read only) --FILE-- array('pipe', 'r'), 1 => array('pipe', 'w')) - ,$pipes, __DIR__, array(), array() + "$php -n -i" + ,array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')) + ,$pipes, __DIR__, array(), array() ); var_dump($proc); if (!$proc) { - exit(1); + exit(1); } $r = array($pipes[1]); $w = array($pipes[0]); @@ -30,13 +30,13 @@ var_dump($ret === (count($r) + count($w))); foreach($pipes as $pipe) { - fclose($pipe); + fclose($pipe); } proc_terminate($proc); if (defined('SIGKILL')) { - proc_terminate($proc, SIGKILL); + proc_terminate($proc, SIGKILL); } else { - proc_terminate($proc); + proc_terminate($proc); } proc_close($proc); ?> diff --git a/ext/standard/tests/streams/bug53903.phpt b/ext/standard/tests/streams/bug53903.phpt index ca04a5ca149e..d4c3586dd943 100644 --- a/ext/standard/tests/streams/bug53903.phpt +++ b/ext/standard/tests/streams/bug53903.phpt @@ -9,11 +9,11 @@ class sw { return true; } - public function stream_stat() { - return array( + public function stream_stat() { + return array( 'atime' => $this->undefined, ); - } + } } stream_wrapper_register('sx', 'sw') or die('failed'); diff --git a/ext/standard/tests/streams/bug60455_01.phpt b/ext/standard/tests/streams/bug60455_01.phpt index 466998201ac4..453be553c380 100644 --- a/ext/standard/tests/streams/bug60455_01.phpt +++ b/ext/standard/tests/streams/bug60455_01.phpt @@ -8,7 +8,7 @@ Bug #60455: stream_get_line and 1-line noeol input $domain = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? STREAM_PF_INET : STREAM_PF_UNIX); $sockets = stream_socket_pair($domain, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP) - or die("stream_socket_pair"); + or die("stream_socket_pair"); fwrite($sockets[0], "a"); stream_socket_shutdown($sockets[0], STREAM_SHUT_RDWR); diff --git a/ext/standard/tests/streams/bug60455_02.phpt b/ext/standard/tests/streams/bug60455_02.phpt index c68a1a07ab34..632b12085c80 100644 --- a/ext/standard/tests/streams/bug60455_02.phpt +++ b/ext/standard/tests/streams/bug60455_02.phpt @@ -3,19 +3,19 @@ Bug #60455: stream_get_line and 1-line followed by eol input --FILE-- s++ == 0) - return "a\n"; + private $s = 0; + function stream_open($path, $mode, $options, &$opened_path) { + return true; + } + function stream_read($count) { + if ($this->s++ == 0) + return "a\n"; - return ""; - } - function stream_eof() { - return $this->s >= 2; - } + return ""; + } + function stream_eof() { + return $this->s >= 2; + } } diff --git a/ext/standard/tests/streams/bug60455_03.phpt b/ext/standard/tests/streams/bug60455_03.phpt index 4cfc37340844..d0a48ea7804e 100644 --- a/ext/standard/tests/streams/bug60455_03.phpt +++ b/ext/standard/tests/streams/bug60455_03.phpt @@ -3,25 +3,25 @@ Bug #60455: stream_get_line and 2 lines, one possibly empty --FILE-- lines[] = "a\n"; - $this->lines[] = ($path == "test://nonempty2nd" ? "b\n" : "\n"); - if ($path == "test://eofafter2nd") - $this->eofth = 2; - return true; - } - function stream_read($count) { - if (key_exists($this->s++, $this->lines)) - return $this->lines[$this->s - 1]; + private $lines = array(); + private $s = 0; + private $eofth = 3; + function stream_open($path, $mode, $options, &$opened_path) { + $this->lines[] = "a\n"; + $this->lines[] = ($path == "test://nonempty2nd" ? "b\n" : "\n"); + if ($path == "test://eofafter2nd") + $this->eofth = 2; + return true; + } + function stream_read($count) { + if (key_exists($this->s++, $this->lines)) + return $this->lines[$this->s - 1]; - return ""; - } - function stream_eof() { - return $this->s >= $this->eofth; - } + return ""; + } + function stream_eof() { + return $this->s >= $this->eofth; + } } diff --git a/ext/standard/tests/streams/bug60455_04.phpt b/ext/standard/tests/streams/bug60455_04.phpt index 123a8653d31b..73d2aadf5328 100644 --- a/ext/standard/tests/streams/bug60455_04.phpt +++ b/ext/standard/tests/streams/bug60455_04.phpt @@ -4,19 +4,19 @@ read with EOL indication --FILE-- s++ == 0) - return "a\n"; + private $s = 0; + function stream_open($path, $mode, $options, &$opened_path) { + return true; + } + function stream_read($count) { + if ($this->s++ == 0) + return "a\n"; - return ""; - } - function stream_eof() { - return $this->s >= 2; - } + return ""; + } + function stream_eof() { + return $this->s >= 2; + } } diff --git a/ext/standard/tests/streams/bug60602.phpt b/ext/standard/tests/streams/bug60602.phpt index 396695f77287..b97f6f877a42 100644 --- a/ext/standard/tests/streams/bug60602.phpt +++ b/ext/standard/tests/streams/bug60602.phpt @@ -4,9 +4,9 @@ Bug #60602 proc_open() modifies environment if it contains arrays array('pipe', 'r'), // stdin - 1 => array('pipe', 'w'), // stdout - 2 => array('pipe', 'w'), // strerr + 0 => array('pipe', 'r'), // stdin + 1 => array('pipe', 'w'), // stdout + 2 => array('pipe', 'w'), // strerr ); $environment = array('test' => array(1, 2, 3)); @@ -15,35 +15,35 @@ $cmd = (substr(PHP_OS, 0, 3) == 'WIN') ? 'dir' : 'ls'; $p = proc_open($cmd, $descs, $pipes, '.', $environment); if (is_resource($p)) { - $data = ''; + $data = ''; - while (1) { - $w = $e = NULL; - $n = stream_select($pipes, $w, $e, 300); + while (1) { + $w = $e = NULL; + $n = stream_select($pipes, $w, $e, 300); - if ($n === false) { - echo "no streams \n"; - break; - } else if ($n === 0) { - echo "process timed out\n"; - proc_terminate($p, 9); - break; - } else if ($n > 0) { - $line = fread($pipes[1], 8192); - if (strlen($line) == 0) { - /* EOF */ - break; - } - $data .= $line; - } - } - var_dump(strlen($data)); + if ($n === false) { + echo "no streams \n"; + break; + } else if ($n === 0) { + echo "process timed out\n"; + proc_terminate($p, 9); + break; + } else if ($n > 0) { + $line = fread($pipes[1], 8192); + if (strlen($line) == 0) { + /* EOF */ + break; + } + $data .= $line; + } + } + var_dump(strlen($data)); - $ret = proc_close($p); - var_dump($ret); - var_dump(is_array($environment['test'])); + $ret = proc_close($p); + var_dump($ret); + var_dump(is_array($environment['test'])); } else { - echo "no process\n"; + echo "no process\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/streams/bug61019.phpt b/ext/standard/tests/streams/bug61019.phpt index db0bf9d6a562..929de1c2af44 100644 --- a/ext/standard/tests/streams/bug61019.phpt +++ b/ext/standard/tests/streams/bug61019.phpt @@ -6,65 +6,65 @@ Bug #61019 (Out of memory on command stream_get_contents) echo "Test\n"; $descriptorspec = array( - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from - 1 => array("pipe", "w"), // stdout is a pipe that the child will write to - 2 => array("pipe", "w") // stderr is a pipe that the child will write to + 0 => array("pipe", "r"), // stdin is a pipe that the child will read from + 1 => array("pipe", "w"), // stdout is a pipe that the child will write to + 2 => array("pipe", "w") // stderr is a pipe that the child will write to ); $process=proc_open("echo testtext",$descriptorspec,$pipes); if(is_resource($process)) { - stream_set_blocking($pipes[0],false); - stream_set_blocking($pipes[1],false); - stream_set_blocking($pipes[2],false); - stream_set_write_buffer($pipes[0],0); - stream_set_read_buffer($pipes[1],0); - stream_set_read_buffer($pipes[2],0); - $stdin_stream=""; - $stderr_stream=""; + stream_set_blocking($pipes[0],false); + stream_set_blocking($pipes[1],false); + stream_set_blocking($pipes[2],false); + stream_set_write_buffer($pipes[0],0); + stream_set_read_buffer($pipes[1],0); + stream_set_read_buffer($pipes[2],0); + $stdin_stream=""; + $stderr_stream=""; - echo "External command executed\n"; - do - { - $process_state=proc_get_status($process); - $tmp_stdin=stream_get_contents($pipes[1]); - if($tmp_stdin) - { - $stdin_stream=$stdin_stream.$tmp_stdin; - } - $tmp_stderr=stream_get_contents($pipes[2]); - if($tmp_stderr) - { - $stderr_stream=$stderr_stream.$tmp_stderr; - } - } while($process_state['running']); + echo "External command executed\n"; + do + { + $process_state=proc_get_status($process); + $tmp_stdin=stream_get_contents($pipes[1]); + if($tmp_stdin) + { + $stdin_stream=$stdin_stream.$tmp_stdin; + } + $tmp_stderr=stream_get_contents($pipes[2]); + if($tmp_stderr) + { + $stderr_stream=$stderr_stream.$tmp_stderr; + } + } while($process_state['running']); - echo "External command exit: ".$process_state['exitcode']."\n"; + echo "External command exit: ".$process_state['exitcode']."\n"; - //read outstanding data - $tmp_stdin=stream_get_contents($pipes[1]); - if($tmp_stdin) - { - $stdin_stream=$stdin_stream.$tmp_stdin; - } - $tmp_stderr=stream_get_contents($pipes[2]); - if($tmp_stderr) - { - $stderr_stream=$stderr_stream.$tmp_stderr; - } + //read outstanding data + $tmp_stdin=stream_get_contents($pipes[1]); + if($tmp_stdin) + { + $stdin_stream=$stdin_stream.$tmp_stdin; + } + $tmp_stderr=stream_get_contents($pipes[2]); + if($tmp_stderr) + { + $stderr_stream=$stderr_stream.$tmp_stderr; + } - fclose ($pipes[0]); - fclose ($pipes[1]); - fclose ($pipes[2]); + fclose ($pipes[0]); + fclose ($pipes[1]); + fclose ($pipes[2]); - proc_close($process); + proc_close($process); - echo "STDOUT: ".$stdin_stream."\n"; - echo "STDERR: ".$stderr_stream."\n"; + echo "STDOUT: ".$stdin_stream."\n"; + echo "STDERR: ".$stderr_stream."\n"; } else { - echo "Can't start external command\n"; + echo "Can't start external command\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/streams/bug61371-unix.phpt b/ext/standard/tests/streams/bug61371-unix.phpt index 7c64d1d30ff5..20361095f6a1 100644 --- a/ext/standard/tests/streams/bug61371-unix.phpt +++ b/ext/standard/tests/streams/bug61371-unix.phpt @@ -11,21 +11,21 @@ function test($doFclose) { $previous = null; $current = null; for($test=1;$test<=3;$test++) { - $current = memory_get_usage(true); - if (!is_null($previous)) { - var_dump($previous == $current); - } - $previous = $current; - echo 'memory: '.round($current / 1024, 0)."kb\n"; - for($i=0;$i<=100;$i++) { - $context = stream_context_create(array()); - $stream = stream_socket_client('udp://0.0.0.0:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context); - if ($doFclose) fclose($stream); - unset($context); - unset($stream); - unset($errno); - unset($errstr); - } + $current = memory_get_usage(true); + if (!is_null($previous)) { + var_dump($previous == $current); + } + $previous = $current; + echo 'memory: '.round($current / 1024, 0)."kb\n"; + for($i=0;$i<=100;$i++) { + $context = stream_context_create(array()); + $stream = stream_socket_client('udp://0.0.0.0:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context); + if ($doFclose) fclose($stream); + unset($context); + unset($stream); + unset($errno); + unset($errstr); + } } } diff --git a/ext/standard/tests/streams/bug61371.phpt b/ext/standard/tests/streams/bug61371.phpt index 924219f89634..00e6372e85a4 100644 --- a/ext/standard/tests/streams/bug61371.phpt +++ b/ext/standard/tests/streams/bug61371.phpt @@ -6,21 +6,21 @@ function test($doFclose) { $previous = null; $current = null; for($test=1;$test<=3;$test++) { - $current = memory_get_usage(true); - if (!is_null($previous)) { - var_dump($previous == $current); - } - $previous = $current; - echo 'memory: '.round($current / 1024, 0)."kb\n"; - for($i=0;$i<=100;$i++) { - $context = stream_context_create(array()); - $stream = stream_socket_client('udp://127.0.0.1:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context); - if ($doFclose) fclose($stream); - unset($context); - unset($stream); - unset($errno); - unset($errstr); - } + $current = memory_get_usage(true); + if (!is_null($previous)) { + var_dump($previous == $current); + } + $previous = $current; + echo 'memory: '.round($current / 1024, 0)."kb\n"; + for($i=0;$i<=100;$i++) { + $context = stream_context_create(array()); + $stream = stream_socket_client('udp://127.0.0.1:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context); + if ($doFclose) fclose($stream); + unset($context); + unset($stream); + unset($errno); + unset($errstr); + } } } diff --git a/ext/standard/tests/streams/bug64166.phpt b/ext/standard/tests/streams/bug64166.phpt index e725a4b698c5..f03d9c15acc5 100644 --- a/ext/standard/tests/streams/bug64166.phpt +++ b/ext/standard/tests/streams/bug64166.phpt @@ -9,8 +9,8 @@ function test_64166($data) { rewind($fd); $res = stream_filter_append($fd, 'convert.quoted-printable-encode', STREAM_FILTER_READ, array( - 'line-break-chars' => "\n", - 'line-length' => 74 + 'line-break-chars' => "\n", + 'line-length' => 74 )); var_dump(stream_get_contents($fd, -1, 0)); @@ -18,8 +18,8 @@ function test_64166($data) { rewind($fd); stream_filter_append($fd, 'convert.quoted-printable-encode', STREAM_FILTER_READ, array( - 'line-break-chars' => "\n", - 'line-length' => 6 + 'line-break-chars' => "\n", + 'line-length' => 6 )); var_dump(stream_get_contents($fd, -1, 0)); diff --git a/ext/standard/tests/streams/bug64166_2.phpt b/ext/standard/tests/streams/bug64166_2.phpt index b4224662eebf..3321978bba80 100644 --- a/ext/standard/tests/streams/bug64166_2.phpt +++ b/ext/standard/tests/streams/bug64166_2.phpt @@ -9,8 +9,8 @@ function test_64166($data) { rewind($fd); $res = stream_filter_append($fd, 'convert.quoted-printable-encode', STREAM_FILTER_READ, array( - 'line-break-chars' => "\n", - 'line-length' => 74 + 'line-break-chars' => "\n", + 'line-length' => 74 )); $str = ""; while(($c = fread($fd, 1))!= "") $str .= $c; @@ -20,8 +20,8 @@ function test_64166($data) { rewind($fd); stream_filter_append($fd, 'convert.quoted-printable-encode', STREAM_FILTER_READ, array( - 'line-break-chars' => "\n", - 'line-length' => 6 + 'line-break-chars' => "\n", + 'line-length' => 6 )); $str = ""; while(($c = fread($fd, 1))!= "") $str .= $c; diff --git a/ext/standard/tests/streams/bug64166_3.phpt b/ext/standard/tests/streams/bug64166_3.phpt index d896ba800c95..5cc0077f7922 100644 --- a/ext/standard/tests/streams/bug64166_3.phpt +++ b/ext/standard/tests/streams/bug64166_3.phpt @@ -6,8 +6,8 @@ Bug #64166: quoted-printable-encode stream filter incorrectly discarding whitesp function test_64166($data) { $fd = fopen('php://temp', 'w+'); $res = stream_filter_append($fd, 'convert.quoted-printable-encode', STREAM_FILTER_WRITE, array( - 'line-break-chars' => "\n", - 'line-length' => 74 + 'line-break-chars' => "\n", + 'line-length' => 74 )); fwrite($fd, $data); rewind($fd); @@ -18,8 +18,8 @@ function test_64166($data) { rewind($fd); stream_filter_append($fd, 'convert.quoted-printable-encode', STREAM_FILTER_WRITE, array( - 'line-break-chars' => "\n", - 'line-length' => 6 + 'line-break-chars' => "\n", + 'line-length' => 6 )); fwrite($fd, $data); rewind($fd); diff --git a/ext/standard/tests/streams/bug64433.phpt b/ext/standard/tests/streams/bug64433.phpt index bb22edee55f9..d1100c57139f 100644 --- a/ext/standard/tests/streams/bug64433.phpt +++ b/ext/standard/tests/streams/bug64433.phpt @@ -20,7 +20,7 @@ echo file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php"); echo "default\n"; $codes = array(200, 201, 204, 301, 302, 303, 304, 305, 307, 404, 500); foreach($codes as $code) { - echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1"); + echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1"); } echo "follow=0\n"; $arr = array('http'=> @@ -30,7 +30,7 @@ $arr = array('http'=> ); $context = stream_context_create($arr); foreach($codes as $code) { - echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context); + echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context); } echo "follow=1\n"; $arr = array('http'=> @@ -40,7 +40,7 @@ $arr = array('http'=> ); $context = stream_context_create($arr); foreach($codes as $code) { - echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context); + echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context); } --EXPECT-- HELLO! diff --git a/ext/standard/tests/streams/bug64433_srv.inc b/ext/standard/tests/streams/bug64433_srv.inc index dcdb1bcbaaa6..035343369c55 100644 --- a/ext/standard/tests/streams/bug64433_srv.inc +++ b/ext/standard/tests/streams/bug64433_srv.inc @@ -1,14 +1,14 @@ if(!empty($_REQUEST["redir"])) { - echo "REDIRECTED\n"; - return; + echo "REDIRECTED\n"; + return; } if(!empty($_REQUEST["loc"])) { - header("Location: index.php?redir=1"); + header("Location: index.php?redir=1"); } if(!empty($_REQUEST["status"])) { - http_response_code($_REQUEST["status"]); + http_response_code($_REQUEST["status"]); } echo "HELLO!\n"; diff --git a/ext/standard/tests/streams/bug64770.phpt b/ext/standard/tests/streams/bug64770.phpt index df25d3f8ca69..ba39bb5f84f6 100644 --- a/ext/standard/tests/streams/bug64770.phpt +++ b/ext/standard/tests/streams/bug64770.phpt @@ -4,9 +4,9 @@ Bug #64770 stream_select() fails with pipes from proc_open() array('pipe', 'r'), // stdin - 1 => array('pipe', 'w'), // stdout - 2 => array('pipe', 'w'), // strerr + 0 => array('pipe', 'r'), // stdin + 1 => array('pipe', 'w'), // stdout + 2 => array('pipe', 'w'), // strerr ); $other_opts = array('suppress_errors' => false); @@ -15,34 +15,34 @@ $cmd = (substr(PHP_OS, 0, 3) == 'WIN') ? 'dir' : 'ls'; $p = proc_open($cmd, $descs, $pipes, '.', NULL, $other_opts); if (is_resource($p)) { - $data = ''; + $data = ''; - while (1) { - $w = $e = NULL; - $n = stream_select($pipes, $w, $e, 300); + while (1) { + $w = $e = NULL; + $n = stream_select($pipes, $w, $e, 300); - if ($n === false) { - echo "no streams \n"; - break; - } else if ($n === 0) { - echo "process timed out\n"; - proc_terminate($p, 9); - break; - } else if ($n > 0) { - $line = fread($pipes[1], 8192); - if (strlen($line) == 0) { - /* EOF */ - break; - } - $data .= $line; - } - } - var_dump(strlen($data)); + if ($n === false) { + echo "no streams \n"; + break; + } else if ($n === 0) { + echo "process timed out\n"; + proc_terminate($p, 9); + break; + } else if ($n > 0) { + $line = fread($pipes[1], 8192); + if (strlen($line) == 0) { + /* EOF */ + break; + } + $data .= $line; + } + } + var_dump(strlen($data)); - $ret = proc_close($p); - var_dump($ret); + $ret = proc_close($p); + var_dump($ret); } else { - echo "no process\n"; + echo "no process\n"; } ?> --EXPECTF-- diff --git a/ext/standard/tests/streams/bug67626.phpt b/ext/standard/tests/streams/bug67626.phpt index 79aaed55cb94..c251a40b92bf 100644 --- a/ext/standard/tests/streams/bug67626.phpt +++ b/ext/standard/tests/streams/bug67626.phpt @@ -4,24 +4,24 @@ Bug #67626: Exceptions not properly handled in user stream handlers getMessage(); + echo $e->getMessage(); } echo "\n"; try { - fwrite($fp, 'foobar'); + fwrite($fp, 'foobar'); } catch (Exception $e) { - echo $e->getMessage(); + echo $e->getMessage(); } ?> --EXPECT-- diff --git a/ext/standard/tests/streams/bug69521.phpt b/ext/standard/tests/streams/bug69521.phpt index 75e1cdf99da7..9ec244f79963 100644 --- a/ext/standard/tests/streams/bug69521.phpt +++ b/ext/standard/tests/streams/bug69521.phpt @@ -19,15 +19,15 @@ fclose($link); while (!feof($fp)) { - $read = $write = array($fp); + $read = $write = array($fp); - if ($written === strlen($data)) - $write = array(); + if ($written === strlen($data)) + $write = array(); - $changed = stream_select($read, $write, $except, 0, 500000); + $changed = stream_select($read, $write, $except, 0, 500000); - if (!empty($read)) - echo fread($fp, 4); + if (!empty($read)) + echo fread($fp, 4); } ?> --EXPECT-- diff --git a/ext/standard/tests/streams/bug70198.phpt b/ext/standard/tests/streams/bug70198.phpt index 94585db88228..fc9c30f6fe34 100644 --- a/ext/standard/tests/streams/bug70198.phpt +++ b/ext/standard/tests/streams/bug70198.phpt @@ -10,9 +10,9 @@ server [ - 'protocol_version' => '1.1', - 'method' => 'GET', - 'header' => &$headers, - 'follow_location' => 0, - 'max_redirects' => 0, - 'ignore_errors' => true, - 'timeout' => 60, - ], + 'http' => [ + 'protocol_version' => '1.1', + 'method' => 'GET', + 'header' => &$headers, + 'follow_location' => 0, + 'max_redirects' => 0, + 'ignore_errors' => true, + 'timeout' => 60, + ], ]; $context = stream_context_create($httpContext); $headers = ["Host: bad.com"]; diff --git a/ext/standard/tests/streams/bug72853.phpt b/ext/standard/tests/streams/bug72853.phpt index 8de0264ac049..ab06f81e8c8f 100644 --- a/ext/standard/tests/streams/bug72853.phpt +++ b/ext/standard/tests/streams/bug72853.phpt @@ -10,8 +10,8 @@ if(substr(PHP_OS, 0, 3) == 'WIN' ) { array('pipe', 'r'), // stdin - 1 => array('pipe', 'w'), // stdout + 0 => array('pipe', 'r'), // stdin + 1 => array('pipe', 'w'), // stdout ); $p = proc_open("ls", $descs, $pipes, '.', NULL, NULL); diff --git a/ext/standard/tests/streams/bug72857.phpt b/ext/standard/tests/streams/bug72857.phpt index a74dff9c7e7d..f6addb1a63ee 100644 --- a/ext/standard/tests/streams/bug72857.phpt +++ b/ext/standard/tests/streams/bug72857.phpt @@ -2,16 +2,16 @@ Bug #72857 stream_socket_recvfrom read access violation --FILE-- --EXPECT-- bool(false) diff --git a/ext/standard/tests/streams/bug77664.phpt b/ext/standard/tests/streams/bug77664.phpt index ff2e3170261b..01722033b5fc 100644 --- a/ext/standard/tests/streams/bug77664.phpt +++ b/ext/standard/tests/streams/bug77664.phpt @@ -3,8 +3,8 @@ BUG #77664 (Segmentation fault when using undefined constant in custom wrapper) --FILE-- nul"); + // if the bug is not present, it will hang waiting for stdin, + // thus cmd is still running and we should kill it + shell_exec("taskkill /T /F /PID {$pid} 2>nul"); } fclose($pipes[0]); fclose($pipes[1]); diff --git a/ext/standard/tests/streams/proc_open_bug51800.phpt b/ext/standard/tests/streams/proc_open_bug51800.phpt index d54ba002620d..7cf502edd864 100644 --- a/ext/standard/tests/streams/proc_open_bug51800.phpt +++ b/ext/standard/tests/streams/proc_open_bug51800.phpt @@ -47,7 +47,7 @@ exit(0); '); if (!$r) { - die("couldn't create helper script '$callee'"); + die("couldn't create helper script '$callee'"); } $process = proc_open($cmd, $descriptors, $pipes); @@ -56,13 +56,13 @@ if (is_resource($process)) { fclose($pipes[0]); - while (!feof($pipes[1])) - $stdout .= fread($pipes[1], 1024); - fclose($pipes[1]); + while (!feof($pipes[1])) + $stdout .= fread($pipes[1], 1024); + fclose($pipes[1]); - while (!feof($pipes[2])) - $stderr .= fread($pipes[2], 1024); - fclose($pipes[2]); + while (!feof($pipes[2])) + $stderr .= fread($pipes[2], 1024); + fclose($pipes[2]); $status = proc_close($process); } diff --git a/ext/standard/tests/streams/proc_open_bug51800_right.phpt b/ext/standard/tests/streams/proc_open_bug51800_right.phpt index 12871cc1d350..c9e517cc651c 100644 --- a/ext/standard/tests/streams/proc_open_bug51800_right.phpt +++ b/ext/standard/tests/streams/proc_open_bug51800_right.phpt @@ -31,7 +31,7 @@ exit(0); '); if (!$r) { - die("couldn't create helper script '$callee'"); + die("couldn't create helper script '$callee'"); } $process = proc_open($cmd, $descriptors, $pipes); diff --git a/ext/standard/tests/streams/proc_open_bug51800_right2.phpt b/ext/standard/tests/streams/proc_open_bug51800_right2.phpt index 1a2f69adbbde..71b2fcc71a95 100644 --- a/ext/standard/tests/streams/proc_open_bug51800_right2.phpt +++ b/ext/standard/tests/streams/proc_open_bug51800_right2.phpt @@ -27,17 +27,17 @@ $i0 = $i1 = 0; $step = 1024; while ($i0 < strlen($data0) && $i1 < strlen($data1)) { - fwrite(STDOUT, substr($data0, $i0, $step)); - fwrite(STDERR, substr($data1, $i1, $step)); - $i0 += $step; - $i1 += $step; + fwrite(STDOUT, substr($data0, $i0, $step)); + fwrite(STDERR, substr($data1, $i1, $step)); + $i0 += $step; + $i1 += $step; } exit(0); '); if (!$r) { - die("couldn't create helper script '$callee'"); + die("couldn't create helper script '$callee'"); } $process = proc_open($cmd, $descriptors, $pipes); diff --git a/ext/standard/tests/streams/proc_open_bug60120.phpt b/ext/standard/tests/streams/proc_open_bug60120.phpt index 053de2ebe058..9cce5a4c94f1 100644 --- a/ext/standard/tests/streams/proc_open_bug60120.phpt +++ b/ext/standard/tests/streams/proc_open_bug60120.phpt @@ -32,14 +32,14 @@ $process = proc_open( getcwd(), [], [ - 'suppress_errors' => true, + 'suppress_errors' => true, 'bypass_shell' => false ] ); if (!is_resource($process)) { die(sprintf( - "could not open process \"%s\"", + "could not open process \"%s\"", $command)); } diff --git a/ext/standard/tests/streams/proc_open_bug64438.phpt b/ext/standard/tests/streams/proc_open_bug64438.phpt index c310775a4da4..8e4320cae9b9 100644 --- a/ext/standard/tests/streams/proc_open_bug64438.phpt +++ b/ext/standard/tests/streams/proc_open_bug64438.phpt @@ -6,9 +6,9 @@ Bug #64438 proc_open hangs with stdin/out with 4097+ bytes error_reporting(E_ALL); if (substr(PHP_OS, 0, 3) == 'WIN') { - $cmd = PHP_BINARY . ' -n -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"'; + $cmd = PHP_BINARY . ' -n -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"'; } else { - $cmd = PHP_BINARY . ' -n -r \'fwrite(STDOUT, $in = file_get_contents("php://stdin")); fwrite(STDERR, $in);\''; + $cmd = PHP_BINARY . ' -n -r \'fwrite(STDOUT, $in = file_get_contents("php://stdin")); fwrite(STDERR, $in);\''; } $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')); $stdin = str_repeat('*', 4097); diff --git a/ext/standard/tests/streams/proc_open_bug69900.phpt b/ext/standard/tests/streams/proc_open_bug69900.phpt index e4d18b1cf874..de13d1bfdd37 100644 --- a/ext/standard/tests/streams/proc_open_bug69900.phpt +++ b/ext/standard/tests/streams/proc_open_bug69900.phpt @@ -14,7 +14,7 @@ $in = fopen("php://stdin", "rb", false, stream_context_create(array("pipe" => ar while(!feof($in)){ $s = fgets($in); - fwrite(STDOUT, $s); + fwrite(STDOUT, $s); } ?>'; @@ -27,19 +27,19 @@ $process = proc_open(PHP_BINARY.' -n -f ' . $fl, $descriptorspec, $pipes, NULL, $moreThanLimit = 0; for($i = 0; $i < 10; $i++){ - fwrite($pipes[0], "hello$i\r\n"); - fflush($pipes[0]); + fwrite($pipes[0], "hello$i\r\n"); + fflush($pipes[0]); - $t0 = microtime(1); - $s = fgets($pipes[1]); - $t1 = microtime(1); + $t0 = microtime(1); + $s = fgets($pipes[1]); + $t1 = microtime(1); - echo $s; + echo $s; - $dt_ms = ($t1 - $t0)*1000; - if ($dt_ms > $max_ms) { + $dt_ms = ($t1 - $t0)*1000; + if ($dt_ms > $max_ms) { $moreThanLimit++; - } + } } fclose($pipes[0]); diff --git a/ext/standard/tests/streams/stream_context_tcp_nodelay.phpt b/ext/standard/tests/streams/stream_context_tcp_nodelay.phpt index 1e5b7e31d801..7af03726e695 100644 --- a/ext/standard/tests/streams/stream_context_tcp_nodelay.phpt +++ b/ext/standard/tests/streams/stream_context_tcp_nodelay.phpt @@ -8,16 +8,16 @@ if (!extension_loaded("sockets")) die("skip: need sockets"); --FILE-- [ - "tcp_nodelay" => true - ] + "socket" => [ + "tcp_nodelay" => true + ] ]); $stream = stream_socket_client( - "tcp://www.php.net:80", $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $ctxt); + "tcp://www.php.net:80", $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $ctxt); $socket = - socket_import_stream($stream); + socket_import_stream($stream); var_dump(socket_get_option($socket, SOL_TCP, TCP_NODELAY) > 0); ?> diff --git a/ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt b/ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt index 7142dae73b1b..133b7a94babf 100644 --- a/ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt +++ b/ext/standard/tests/streams/stream_context_tcp_nodelay_fopen.phpt @@ -8,18 +8,18 @@ if (!extension_loaded("sockets")) die("skip: need sockets"); --FILE-- [ - "tcp_nodelay" => true - ], - "http" => [ - "follow_location" => 0 - ] + "socket" => [ + "tcp_nodelay" => true + ], + "http" => [ + "follow_location" => 0 + ] ]); $stream = fopen("http://www.php.net", "r", false, $ctxt); $socket = - @socket_import_stream($stream); + @socket_import_stream($stream); var_dump(socket_get_option($socket, STREAM_IPPROTO_TCP, TCP_NODELAY) > 0); ?> diff --git a/ext/standard/tests/streams/stream_context_tcp_nodelay_server.phpt b/ext/standard/tests/streams/stream_context_tcp_nodelay_server.phpt index 420d5ad49026..7d685e16dfc4 100644 --- a/ext/standard/tests/streams/stream_context_tcp_nodelay_server.phpt +++ b/ext/standard/tests/streams/stream_context_tcp_nodelay_server.phpt @@ -6,40 +6,40 @@ stream context tcp_nodelay server [ - "tcp_nodelay" => true - ] - ]); + "socket" => [ + "tcp_nodelay" => true + ] + ]); - $server = stream_socket_server( - "tcp://127.0.0.1:9099", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $ctxt); + $server = stream_socket_server( + "tcp://127.0.0.1:9099", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $ctxt); - $client = stream_socket_accept($server); + $client = stream_socket_accept($server); - var_dump(socket_get_option( - socket_import_stream($server), - SOL_TCP, TCP_NODELAY) > 0); + var_dump(socket_get_option( + socket_import_stream($server), + SOL_TCP, TCP_NODELAY) > 0); - var_dump(socket_get_option( - socket_import_stream($client), - SOL_TCP, TCP_NODELAY) > 0); + var_dump(socket_get_option( + socket_import_stream($client), + SOL_TCP, TCP_NODELAY) > 0); - fclose($client); - fclose($server); + fclose($client); + fclose($server); CODE; $clientCode = <<<'CODE' $test = stream_socket_client( - "tcp://127.0.0.1:9099", $errno, $errstr, 10); + "tcp://127.0.0.1:9099", $errno, $errstr, 10); - sleep(1); + sleep(1); - fclose($test); + fclose($test); CODE; include sprintf( - "%s/../../../openssl/tests/ServerClientTestCase.inc", - __DIR__); + "%s/../../../openssl/tests/ServerClientTestCase.inc", + __DIR__); ServerClientTestCase::getInstance()->run($serverCode, $clientCode); ?> --EXPECT-- diff --git a/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt b/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt index 8cdd5c17795b..79daabd977ab 100644 --- a/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt +++ b/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt @@ -3,19 +3,19 @@ Bug #60455: stream_get_line and \0 as a delimiter --FILE-- s++ == 0) - return "a\0"; + private $s = 0; + function stream_open($path, $mode, $options, &$opened_path) { + return true; + } + function stream_read($count) { + if ($this->s++ == 0) + return "a\0"; - return ""; - } - function stream_eof() { - return $this->s >= 2; - } + return ""; + } + function stream_eof() { + return $this->s >= 2; + } } diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt index f7ccc7783bdb..9627367c72db 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt @@ -15,13 +15,13 @@ fclose($fp); // open file in each access mode and get meta data foreach ($filemodes as $mode) { - if (strncmp($mode, 'x', 1) == 0) { - // x modes require that file does not exist - unlink($filename); - } - $fp = fopen($filename, $mode); - var_dump(stream_get_meta_data($fp)); - fclose($fp); + if (strncmp($mode, 'x', 1) == 0) { + // x modes require that file does not exist + unlink($filename); + } + $fp = fopen($filename, $mode); + var_dump(stream_get_meta_data($fp)); + fclose($fp); } unlink($filename); diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt index 6b3fde203a56..e0ebaab2eed8 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt @@ -10,7 +10,7 @@ $fp = fopen($filename, "w+"); echo "Write some data to the file:\n"; $i = 0; while ($i++ < 20) { - fwrite($fp, "a line of data\n"); + fwrite($fp, "a line of data\n"); } var_dump(stream_get_meta_data($fp)); @@ -30,7 +30,7 @@ var_dump(stream_get_meta_data($fp)); echo "\n\nRead entire file:\n"; while(!feof($fp)) { - fread($fp, 1); + fread($fp, 1); } var_dump(stream_get_meta_data($fp)); diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt index 22fcee4b6f34..202fc7a2ec22 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt @@ -10,7 +10,7 @@ $fp = fopen($filename, "w+"); echo "Write some data to the file:\n"; $i = 0; while ($i++ < 20) { - fwrite($fp, "a line of data\n"); + fwrite($fp, "a line of data\n"); } var_dump(stream_get_meta_data($fp)); @@ -20,7 +20,7 @@ rewind($fp); echo "\n\nRead entire file:\n"; while(!feof($fp)) { - fread($fp, 1); + fread($fp, 1); } var_dump(stream_get_meta_data($fp)); diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt index 1c7f1fd25693..9db45e8c2f58 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt @@ -9,7 +9,7 @@ $server = stream_socket_server('tcp://127.0.0.1:31331'); /* Connect to it */ $client = fsockopen('tcp://127.0.0.1:31331'); if (!$client) { - die("Unable to create socket"); + die("Unable to create socket"); } /* Accept that connection */ @@ -31,7 +31,7 @@ echo "\n\nClose the server side socket and read the remaining data from the clie fclose($socket); fclose($server); while(!feof($client)) { - fread($client, 1); + fread($client, 1); } var_dump(stream_get_meta_data($client)); diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt index cb713c85251a..f6e6504536ee 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt @@ -9,7 +9,7 @@ $server = stream_socket_server('tcp://127.0.0.1:31332'); /* Connect to it */ $client = fsockopen('tcp://127.0.0.1:31332'); if (!$client) { - die("Unable to create socket"); + die("Unable to create socket"); } /* Accept that connection */ diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt index c7f08cbe122e..ef1a22a3a163 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt @@ -9,7 +9,7 @@ $server = stream_socket_server('tcp://127.0.0.1:31333'); /* Connect to it */ $client = fsockopen('tcp://127.0.0.1:31333'); if (!$client) { - die("Unable to create socket"); + die("Unable to create socket"); } /* Accept that connection */ diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt index e37e991f1662..cd83b1342c7b 100644 --- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt @@ -9,7 +9,7 @@ $server = stream_socket_server('tcp://127.0.0.1:31334'); /* Connect to it */ $client = fsockopen('tcp://127.0.0.1:31334'); if (!$client) { - die("Unable to create socket"); + die("Unable to create socket"); } /* Accept that connection */ @@ -27,7 +27,7 @@ echo "\n\nClose the server side socket and read the remaining data from the clie fclose($socket); fclose($server); while(!feof($client)) { - fread($client, 1); + fread($client, 1); } var_dump(stream_get_meta_data($client)); diff --git a/ext/standard/tests/streams/stream_multi_filters_close.phpt b/ext/standard/tests/streams/stream_multi_filters_close.phpt index f1eb18a15cd3..6b955cf1a7ff 100644 --- a/ext/standard/tests/streams/stream_multi_filters_close.phpt +++ b/ext/standard/tests/streams/stream_multi_filters_close.phpt @@ -4,41 +4,41 @@ Check if multiple filters are closed correctly and never called again after clos stream, $bucket->data)); - } - - if ($closing) { - $closed++; - } - - if ($closed > 0) { - var_dump($closed++); - } - return PSFS_PASS_ON; - } + public function filter($in, $out, &$consumed, $closing) { + static $closed = 0; + + while ($bucket = stream_bucket_make_writeable($in)) { + stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data)); + } + + if ($closing) { + $closed++; + } + + if ($closed > 0) { + var_dump($closed++); + } + return PSFS_PASS_ON; + } } class SecondFilter extends php_user_filter { - public function filter($in, $out, &$consumed, $closing) { - static $closed = 0; - - while ($bucket = stream_bucket_make_writeable($in)) { - stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data)); - } - - if ($closing) { - $closed++; - } - - if ($closed > 0) { - var_dump($closed++); - } - return PSFS_PASS_ON; - } + public function filter($in, $out, &$consumed, $closing) { + static $closed = 0; + + while ($bucket = stream_bucket_make_writeable($in)) { + stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data)); + } + + if ($closing) { + $closed++; + } + + if ($closed > 0) { + var_dump($closed++); + } + return PSFS_PASS_ON; + } } $r = fopen("php://stdout", "w+"); diff --git a/ext/standard/tests/streams/stream_set_chunk_size.phpt b/ext/standard/tests/streams/stream_set_chunk_size.phpt index 6b90f86cd0a9..ac50db6867c1 100644 --- a/ext/standard/tests/streams/stream_set_chunk_size.phpt +++ b/ext/standard/tests/streams/stream_set_chunk_size.phpt @@ -3,24 +3,24 @@ stream_set_chunk_size basic tests --FILE-- diff --git a/ext/standard/tests/strings/addslashes_variation2.phpt b/ext/standard/tests/strings/addslashes_variation2.phpt index 4de6c75697de..d4c0257b6e3b 100644 --- a/ext/standard/tests/strings/addslashes_variation2.phpt +++ b/ext/standard/tests/strings/addslashes_variation2.phpt @@ -43,7 +43,7 @@ $str_array = array( "", "\"", '"', - "hello\"", + "hello\"", // string with backslash characters 'Is your name Ram\Krishna?', @@ -65,7 +65,7 @@ $str_array = array( '"c:\php\"'.chr(0)."'", '"hello"'."'world'".chr(0).'//', - // string with hexadecimal number + // string with hexadecimal number "0xABCDEF0123456789", "\x00", '!@#$%&*@$%#&/;:,<>', diff --git a/ext/standard/tests/strings/basename.phpt b/ext/standard/tests/strings/basename.phpt index a39a6f9aebe7..1f69bf4bcee9 100644 Binary files a/ext/standard/tests/strings/basename.phpt and b/ext/standard/tests/strings/basename.phpt differ diff --git a/ext/standard/tests/strings/bin2hex.phpt b/ext/standard/tests/strings/bin2hex.phpt index 42a4f4c59465..dbc440c094b0 100644 --- a/ext/standard/tests/strings/bin2hex.phpt +++ b/ext/standard/tests/strings/bin2hex.phpt @@ -4,7 +4,7 @@ bin2hex() function --EXPECT-- string(581) " boo diff --git a/ext/standard/tests/strings/bug20169.phpt b/ext/standard/tests/strings/bug20169.phpt index c606578677fc..fd5de0ee8819 100644 --- a/ext/standard/tests/strings/bug20169.phpt +++ b/ext/standard/tests/strings/bug20169.phpt @@ -2,12 +2,12 @@ Bug #20169 (implode() clobbers first argument) --FILE-- --EXPECT-- delimiter: | diff --git a/ext/standard/tests/strings/bug21338.phpt b/ext/standard/tests/strings/bug21338.phpt index c84576563ef8..c118ee18de83 100644 --- a/ext/standard/tests/strings/bug21338.phpt +++ b/ext/standard/tests/strings/bug21338.phpt @@ -2,8 +2,8 @@ Bug #20934 (html_entity_decode() crash when "" is passed) --FILE-- --EXPECT-- string(0) "" diff --git a/ext/standard/tests/strings/bug22187.phpt b/ext/standard/tests/strings/bug22187.phpt index dccaccc04dc1..9b77569b47e4 100644 --- a/ext/standard/tests/strings/bug22187.phpt +++ b/ext/standard/tests/strings/bug22187.phpt @@ -2,8 +2,8 @@ Bug #22187 (possible crash in number_format() function) --FILE-- --EXPECT-- string(3) "0.0" diff --git a/ext/standard/tests/strings/bug22207.phpt b/ext/standard/tests/strings/bug22207.phpt index 956acd2103b2..eddfa942e2b8 100644 --- a/ext/standard/tests/strings/bug22207.phpt +++ b/ext/standard/tests/strings/bug22207.phpt @@ -2,8 +2,8 @@ Bug #22207 (missing 0 when using the e notation in *printf functions) --FILE-- --EXPECT-- 1.10000e+0 diff --git a/ext/standard/tests/strings/bug22224.phpt b/ext/standard/tests/strings/bug22224.phpt index 0ab00a6c423f..c9a669eb46ef 100644 --- a/ext/standard/tests/strings/bug22224.phpt +++ b/ext/standard/tests/strings/bug22224.phpt @@ -6,10 +6,10 @@ error_reporting=0 --FILE-- --EXPECT-- array(4) { diff --git a/ext/standard/tests/strings/bug24312.phpt b/ext/standard/tests/strings/bug24312.phpt index 5ec444dd584a..fb1f494b185b 100644 --- a/ext/standard/tests/strings/bug24312.phpt +++ b/ext/standard/tests/strings/bug24312.phpt @@ -4,8 +4,8 @@ Bug #24208 (base64_decode() not skipping 0xF0 - 0xFF) --EXPECT-- diff --git a/ext/standard/tests/strings/bug25671.phpt b/ext/standard/tests/strings/bug25671.phpt index ab26ddf772b1..cd6dec6641e2 100644 --- a/ext/standard/tests/strings/bug25671.phpt +++ b/ext/standard/tests/strings/bug25671.phpt @@ -3,12 +3,12 @@ Bug #25671 (subarrays not copied correctly) --FILE-- bar = 'meuh'; - $this->foo = 'lala'; - $this->test = 'test'; + function foo() + { + $this->bar = 'meuh'; + $this->foo = 'lala'; + $this->test = 'test'; - var_dump(http_build_query($this)); - } + var_dump(http_build_query($this)); + } } $obj = new test(); diff --git a/ext/standard/tests/strings/bug26878.phpt b/ext/standard/tests/strings/bug26878.phpt index 602f710c8370..da6c0a2aa437 100644 --- a/ext/standard/tests/strings/bug26878.phpt +++ b/ext/standard/tests/strings/bug26878.phpt @@ -2,8 +2,8 @@ Bug #26878 (problem with multiple references to the same variable with different types) --FILE-- --EXPECT-- Int: 0 and as string: some string diff --git a/ext/standard/tests/strings/bug27278.phpt b/ext/standard/tests/strings/bug27278.phpt index 1a94692d190e..f3d8eced90ab 100644 --- a/ext/standard/tests/strings/bug27278.phpt +++ b/ext/standard/tests/strings/bug27278.phpt @@ -5,8 +5,8 @@ Bug #27278 (*printf() functions treat arguments as if passed by reference) function foo ($a) { - $a=sprintf("%02d",$a); - var_dump($a); + $a=sprintf("%02d",$a); + var_dump($a); } $x="02"; diff --git a/ext/standard/tests/strings/bug27295.phpt b/ext/standard/tests/strings/bug27295.phpt index d23d27049f67..b8c53e490689 100644 --- a/ext/standard/tests/strings/bug27295.phpt +++ b/ext/standard/tests/strings/bug27295.phpt @@ -5,8 +5,8 @@ Bug #27295 (memory leak inside sscanf()) $strings = array("foo = bar", "bar = foo"); foreach( $strings as $string ) { - sscanf( $string, "%s = %[^[]]", $var, $val ); - echo "$var = $val\n"; + sscanf( $string, "%s = %[^[]]", $var, $val ); + echo "$var = $val\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/strings/bug27457.phpt b/ext/standard/tests/strings/bug27457.phpt index 6f5ec05f79a2..e9ac42e031e6 100644 --- a/ext/standard/tests/strings/bug27457.phpt +++ b/ext/standard/tests/strings/bug27457.phpt @@ -2,16 +2,16 @@ Bug #27457 (Problem with strtr() and translation array) --FILE-- '0')); - echo $test; - $test = strtr($test, array('0' => '.')); - echo $test; - $test = strtr($test, '.', '0'); - echo $test; - $test = strtr($test, '0', '.'); - echo $test; + $test = "Dot in brackets [.]\n"; + echo $test; + $test = strtr($test, array('.' => '0')); + echo $test; + $test = strtr($test, array('0' => '.')); + echo $test; + $test = strtr($test, '.', '0'); + echo $test; + $test = strtr($test, '0', '.'); + echo $test; ?> --EXPECT-- Dot in brackets [.] diff --git a/ext/standard/tests/strings/bug28633.phpt b/ext/standard/tests/strings/bug28633.phpt index 5a1c2567fac5..9dc83a40ad58 100644 --- a/ext/standard/tests/strings/bug28633.phpt +++ b/ext/standard/tests/strings/bug28633.phpt @@ -2,8 +2,8 @@ Bug #28633 (sprintf incorrectly adding padding to floats) --FILE-- --EXPECT-- 00.02 diff --git a/ext/standard/tests/strings/bug29075.phpt b/ext/standard/tests/strings/bug29075.phpt index 7fe7da6c4978..63a4fdb0740d 100644 --- a/ext/standard/tests/strings/bug29075.phpt +++ b/ext/standard/tests/strings/bug29075.phpt @@ -2,11 +2,11 @@ Bug #29075 (strnatcmp() incorrectly handles whitespace) --FILE-- --EXPECT-- int(0) diff --git a/ext/standard/tests/strings/bug29538.phpt b/ext/standard/tests/strings/bug29538.phpt index 6af25fb89a6c..13065a4e1195 100644 --- a/ext/standard/tests/strings/bug29538.phpt +++ b/ext/standard/tests/strings/bug29538.phpt @@ -2,8 +2,8 @@ Bug #29538 (number_format and problem with 0) --FILE-- --EXPECT-- 025 diff --git a/ext/standard/tests/strings/bug36148.phpt b/ext/standard/tests/strings/bug36148.phpt index 06caac333457..2e9a81c5ea89 100644 --- a/ext/standard/tests/strings/bug36148.phpt +++ b/ext/standard/tests/strings/bug36148.phpt @@ -4,10 +4,10 @@ Bug #36148 (unpack("H*hex", $data) is adding an extra character to the end of th --EXPECT-- diff --git a/ext/standard/tests/strings/bug36392.phpt b/ext/standard/tests/strings/bug36392.phpt index 8e4cd16c6704..b98f7e629362 100644 --- a/ext/standard/tests/strings/bug36392.phpt +++ b/ext/standard/tests/strings/bug36392.phpt @@ -2,11 +2,11 @@ Bug #36392 (wrong number of decimal digits with %e specifier in sprintf) --FILE-- --EXPECT-- 1.123457e+0 diff --git a/ext/standard/tests/strings/bug38770.phpt b/ext/standard/tests/strings/bug38770.phpt index 76ec33572b21..a349ebff155a 100644 --- a/ext/standard/tests/strings/bug38770.phpt +++ b/ext/standard/tests/strings/bug38770.phpt @@ -8,7 +8,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); --FILE-- --EXPECT-- 1,234.56 diff --git a/ext/standard/tests/strings/bug45166.phpt b/ext/standard/tests/strings/bug45166.phpt index 0b694518dfe6..2ed07b62f872 100644 --- a/ext/standard/tests/strings/bug45166.phpt +++ b/ext/standard/tests/strings/bug45166.phpt @@ -2,7 +2,7 @@ Bug #45166 (substr() ) --FILE-- --EXPECT-- cd diff --git a/ext/standard/tests/strings/bug48709.phpt b/ext/standard/tests/strings/bug48709.phpt index 6a93b8dae4e2..9e0789a61f24 100644 --- a/ext/standard/tests/strings/bug48709.phpt +++ b/ext/standard/tests/strings/bug48709.phpt @@ -5,18 +5,18 @@ Bug #48709 (metaphone and 'wh') /* Initial letter exceptions */ $exceptions = array( - 'kn', // Drop first letter - 'gn', // ditto - 'pn', // ditto - 'ae', // ditto - 'wr', // ditto - 'x', // s - 'wh', // w - 'wa' // w + 'kn', // Drop first letter + 'gn', // ditto + 'pn', // ditto + 'ae', // ditto + 'wr', // ditto + 'x', // s + 'wh', // w + 'wa' // w ); foreach ($exceptions as $letter) { - printf("%s => %s\n", $letter, metaphone($letter)); + printf("%s => %s\n", $letter, metaphone($letter)); } ?> diff --git a/ext/standard/tests/strings/bug55871.phpt b/ext/standard/tests/strings/bug55871.phpt index 0c8fd4c6e693..60a857ec67a6 100644 --- a/ext/standard/tests/strings/bug55871.phpt +++ b/ext/standard/tests/strings/bug55871.phpt @@ -3,15 +3,15 @@ Bug #55871 (Interruption in substr_replace()) (PHP7) --FILE-- diff --git a/ext/standard/tests/strings/bug65947.phpt b/ext/standard/tests/strings/bug65947.phpt index ff7dbf4b8c6a..3ffecf3cac4f 100644 --- a/ext/standard/tests/strings/bug65947.phpt +++ b/ext/standard/tests/strings/bug65947.phpt @@ -8,8 +8,8 @@ $csv = base64_decode('6Q=='); $adata = str_getcsv($csv,";"); $b2 = basename($filename); if ($filename != $b2) - print "BUG"; + print "BUG"; else - print "OKEY"; + print "OKEY"; --EXPECT-- OKEY diff --git a/ext/standard/tests/strings/bug71969.phpt b/ext/standard/tests/strings/bug71969.phpt index aafceb09ad19..9795186e1527 100644 --- a/ext/standard/tests/strings/bug71969.phpt +++ b/ext/standard/tests/strings/bug71969.phpt @@ -3,13 +3,13 @@ Bug #71969 (str_replace returns an incorrect resulting array after a foreach by --FILE-- array("a"=>"0000", "b"=>"1111")), + array("one" => array("a"=>"0000", "b"=>"1111")), ); //foreach by reference, changing the array value foreach($a as &$record) { - $record["one"]["a"] = "2222"; + $record["one"]["a"] = "2222"; } var_dump(str_replace("2", "3", $a)); ?> diff --git a/ext/standard/tests/strings/bug72663_3.phpt b/ext/standard/tests/strings/bug72663_3.phpt index 3b949b023927..d8be46388704 100644 --- a/ext/standard/tests/strings/bug72663_3.phpt +++ b/ext/standard/tests/strings/bug72663_3.phpt @@ -3,10 +3,10 @@ Bug #72663: Create an Unexpected Object and Don't Invoke __wakeup() in Deseriali --FILE-- ryat = str_repeat('A', 0x112); - } + var $ryat; + function __wakeup() { + $this->ryat = str_repeat('A', 0x112); + } } $poc = 'O:8:"stdClass":1:{i:0;O:3:"obj":1:{s:4:"ryat";R:1;'; diff --git a/ext/standard/tests/strings/bug78612.phpt b/ext/standard/tests/strings/bug78612.phpt index 7dad605e80d0..13fb32405218 100644 --- a/ext/standard/tests/strings/bug78612.phpt +++ b/ext/standard/tests/strings/bug78612.phpt @@ -8,7 +8,7 @@ $_a = 7111222333000001; $_b = 5000001; for ($j=0; $j<10; $j++) { - $find_replace[$_a + $j] = $_b + $j; + $find_replace[$_a + $j] = $_b + $j; } echo strtr('Hello', $find_replace), "\n"; diff --git a/ext/standard/tests/strings/chop_variation3.phpt b/ext/standard/tests/strings/chop_variation3.phpt index 36f81d34c8bf..1a4568dc280b 100644 Binary files a/ext/standard/tests/strings/chop_variation3.phpt and b/ext/standard/tests/strings/chop_variation3.phpt differ diff --git a/ext/standard/tests/strings/chop_variation4.phpt b/ext/standard/tests/strings/chop_variation4.phpt index 628c87cbceed..192e07aa3a79 100644 Binary files a/ext/standard/tests/strings/chop_variation4.phpt and b/ext/standard/tests/strings/chop_variation4.phpt differ diff --git a/ext/standard/tests/strings/chr_variation1.phpt b/ext/standard/tests/strings/chr_variation1.phpt index 7aae1bf90505..fbf8e21f494d 100644 --- a/ext/standard/tests/strings/chr_variation1.phpt +++ b/ext/standard/tests/strings/chr_variation1.phpt @@ -27,31 +27,31 @@ $file_handle = fopen(__FILE__, "r"); // array with different values for $input $inputs = array ( - // integer values + // integer values /*1*/ 0, - 1, - 255, - 256, + 1, + 255, + 256, - // float values + // float values /*5*/ 10.5, - -20.5, - 1.1234e6, + -20.5, + 1.1234e6, - // boolean values + // boolean values /*11*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // null values + // null values /*15*/ NULL, - null, + null, - // undefined variable + // undefined variable /*19*/ @$undefined_var, - // unset variable + // unset variable /*20*/ @$unset_var ); diff --git a/ext/standard/tests/strings/convert_uudecode_basic.phpt b/ext/standard/tests/strings/convert_uudecode_basic.phpt index 7422ac06c05d..0c378bdb2245 100644 --- a/ext/standard/tests/strings/convert_uudecode_basic.phpt +++ b/ext/standard/tests/strings/convert_uudecode_basic.phpt @@ -37,8 +37,8 @@ foreach($strings as $string) { $decode = convert_uudecode($encode); if ($decode != $string) { - var_dump($encode, $decode, $string); - exit("TEST FAILED on iteration $count\n"); + var_dump($encode, $decode, $string); + exit("TEST FAILED on iteration $count\n"); } $count ++; diff --git a/ext/standard/tests/strings/count_chars.phpt b/ext/standard/tests/strings/count_chars.phpt index fe21b656f099..61994611749a 100644 --- a/ext/standard/tests/strings/count_chars.phpt +++ b/ext/standard/tests/strings/count_chars.phpt @@ -4,7 +4,7 @@ count_chars() function --EXPECT-- diff --git a/ext/standard/tests/strings/crc32_variation4.phpt b/ext/standard/tests/strings/crc32_variation4.phpt index f3f11972fbc6..6953994a7422 100644 --- a/ext/standard/tests/strings/crc32_variation4.phpt +++ b/ext/standard/tests/strings/crc32_variation4.phpt @@ -74,7 +74,7 @@ $heredoc_strings = array( $heredoc_with_alphanumerics, $heredoc_with_embedded_nulls, $heredoc_with_hexa_octal, - $heredoc_with_long_string + $heredoc_with_long_string ); // loop to test the function with each heredoc string in the array diff --git a/ext/standard/tests/strings/crypt_blowfish.phpt b/ext/standard/tests/strings/crypt_blowfish.phpt index 3af9cb77eb3e..a8eda72120a8 100644 --- a/ext/standard/tests/strings/crypt_blowfish.phpt +++ b/ext/standard/tests/strings/crypt_blowfish.phpt @@ -4,44 +4,44 @@ Official blowfish tests (http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/ array( - '$5$saltstring', - 'Hello world!', - '$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5' - ), - 2 => array( - '$5$rounds=10000$saltstringsaltstring', - 'Hello world!', - '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA' - ), - 3 => array( - '$5$rounds=10000$saltstringsaltstring', - 'Hello world!', - '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA' - ), - 4 => array( - '$5$rounds=5000$toolongsaltstring', - 'This is just a test', - '$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8mGRcvxa5' - ), - 5 => array( - '$5$rounds=1400$anotherlongsaltstring', - 'a very much longer text to encrypt. This one even stretches over morethan one line.', - '$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12oP84Bnq1' - ), - 6 => array( - '$5$rounds=77777$short', - 'we have a short salt string but not a short password', - '$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/' - ), - 7 => array( - '$5$rounds=123456$asaltof16chars..', - 'a short string', - '$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD' - ), - 8 => array( - '$5$rounds=10$roundstoolow', - 'the minimum number is still observed', - '$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL972bIC' - ) + 1 => array( + '$5$saltstring', + 'Hello world!', + '$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5' + ), + 2 => array( + '$5$rounds=10000$saltstringsaltstring', + 'Hello world!', + '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA' + ), + 3 => array( + '$5$rounds=10000$saltstringsaltstring', + 'Hello world!', + '$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA' + ), + 4 => array( + '$5$rounds=5000$toolongsaltstring', + 'This is just a test', + '$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8mGRcvxa5' + ), + 5 => array( + '$5$rounds=1400$anotherlongsaltstring', + 'a very much longer text to encrypt. This one even stretches over morethan one line.', + '$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12oP84Bnq1' + ), + 6 => array( + '$5$rounds=77777$short', + 'we have a short salt string but not a short password', + '$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/' + ), + 7 => array( + '$5$rounds=123456$asaltof16chars..', + 'a short string', + '$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD' + ), + 8 => array( + '$5$rounds=10$roundstoolow', + 'the minimum number is still observed', + '$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL972bIC' + ) ); foreach ($tests as $iter => $t) { - $res = crypt($t[1], $t[0]); - if ($res != $t[2]) echo "Iteration $iter failed. + $res = crypt($t[1], $t[0]); + if ($res != $t[2]) echo "Iteration $iter failed. Expected: <$t[2]> Got <$res>\n"; } diff --git a/ext/standard/tests/strings/crypt_sha512.phpt b/ext/standard/tests/strings/crypt_sha512.phpt index 408a5a00c7de..589a2622deb2 100644 --- a/ext/standard/tests/strings/crypt_sha512.phpt +++ b/ext/standard/tests/strings/crypt_sha512.phpt @@ -4,51 +4,51 @@ crypt() SHA-512 array( - '$6$saltstring', - 'Hello world!', - '$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1' - ), - 2 => array( - '$6$rounds=10000$saltstringsaltstring', - 'Hello world!', - '$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sbHbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v.' - ), - 3 => array( - '$6$rounds=5000$toolongsaltstring', - 'This is just a test', - '$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQzQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0' - ), - 4 => array( - '$6$rounds=1400$anotherlongsaltstring', - 'a very much longer text to encrypt. This one even stretches over morethan one line.', - '$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wPvMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1' - ), - 5 => array( - '$6$rounds=77777$short', - 'we have a short salt string but not a short password', - '$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0gge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0' - ), - 6 => array( - '$6$rounds=123456$asaltof16chars..', - 'a short string', - '$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwcelCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1' - ), - 7 => array( - '$6$rounds=10$roundstoolow', - 'the minimum number is still observed', - '$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1xhLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX.' - ), - 8 => array( - '$6$$bar$', - 'foo', - '$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.' - ), + 1 => array( + '$6$saltstring', + 'Hello world!', + '$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1' + ), + 2 => array( + '$6$rounds=10000$saltstringsaltstring', + 'Hello world!', + '$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sbHbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v.' + ), + 3 => array( + '$6$rounds=5000$toolongsaltstring', + 'This is just a test', + '$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQzQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0' + ), + 4 => array( + '$6$rounds=1400$anotherlongsaltstring', + 'a very much longer text to encrypt. This one even stretches over morethan one line.', + '$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wPvMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1' + ), + 5 => array( + '$6$rounds=77777$short', + 'we have a short salt string but not a short password', + '$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0gge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0' + ), + 6 => array( + '$6$rounds=123456$asaltof16chars..', + 'a short string', + '$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwcelCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1' + ), + 7 => array( + '$6$rounds=10$roundstoolow', + 'the minimum number is still observed', + '$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1xhLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX.' + ), + 8 => array( + '$6$$bar$', + 'foo', + '$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.' + ), ); foreach ($tests as $iter => $t) { - $res = crypt($t[1], $t[0]); - if ($res != $t[2]) echo "Iteration $iter failed. + $res = crypt($t[1], $t[0]); + if ($res != $t[2]) echo "Iteration $iter failed. Expected: <$t[2]> Got <$res>\n"; } diff --git a/ext/standard/tests/strings/default_charset.phpt b/ext/standard/tests/strings/default_charset.phpt index 366513241388..3a8e2696d1e1 100644 --- a/ext/standard/tests/strings/default_charset.phpt +++ b/ext/standard/tests/strings/default_charset.phpt @@ -9,10 +9,10 @@ output_encoding= getMessage() . "\n"; } diff --git a/ext/standard/tests/strings/explode1.phpt b/ext/standard/tests/strings/explode1.phpt index 7c1fe0fd5eb1..cfc203b42869 100644 --- a/ext/standard/tests/strings/explode1.phpt +++ b/ext/standard/tests/strings/explode1.phpt @@ -40,17 +40,17 @@ foreach($delimiters as $delimiter) { echo $e->getMessage() . "\n"; } try { - var_dump( explode($delimiter, $string, 0) ); + var_dump( explode($delimiter, $string, 0) ); } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { - var_dump( explode($delimiter, $string, 1) ); + var_dump( explode($delimiter, $string, 1) ); } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } try { - var_dump( explode($delimiter, $string, 2) ); + var_dump( explode($delimiter, $string, 2) ); } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } diff --git a/ext/standard/tests/strings/explode_variation6.phpt b/ext/standard/tests/strings/explode_variation6.phpt index 2a823a4a3e84..0dcce23077ed 100644 --- a/ext/standard/tests/strings/explode_variation6.phpt +++ b/ext/standard/tests/strings/explode_variation6.phpt @@ -32,11 +32,11 @@ $e = test_explode("\x00", $str, 100); function test_explode($delim, $string, $limit) { - $e = explode($delim, $string, $limit); - foreach ( $e as $v) - { - var_dump(bin2hex($v)); - } + $e = explode($delim, $string, $limit); + foreach ( $e as $v) + { + var_dump(bin2hex($v)); + } } ?> --EXPECT-- diff --git a/ext/standard/tests/strings/get_meta_tags.phpt b/ext/standard/tests/strings/get_meta_tags.phpt index 406ceb2590a8..8752117aea28 100644 --- a/ext/standard/tests/strings/get_meta_tags.phpt +++ b/ext/standard/tests/strings/get_meta_tags.phpt @@ -47,8 +47,8 @@ DATA; $array = array($data, $data1, $data2, $data3, $data4, "", "<>", " --EXPECT-- diff --git a/ext/standard/tests/strings/htmlentities-utf-3.phpt b/ext/standard/tests/strings/htmlentities-utf-3.phpt index 82693056ef06..56d4cdc2f868 100644 --- a/ext/standard/tests/strings/htmlentities-utf-3.phpt +++ b/ext/standard/tests/strings/htmlentities-utf-3.phpt @@ -6,77 +6,77 @@ Test get_next_char(), used by htmlentities()/htmlspecialchars(): validity of UTF /* conformance to Unicode 5.2, section 3.9, D92 */ $val_ranges = array( - array(array(0x00, 0x7F)), - array(array(0xC2, 0xDF), array(0x80, 0xBF)), - array(array(0xE0, 0xE0), array(0xA0, 0xBF), array(0x80, 0xBF)), - array(array(0xE1, 0xEC), array(0x80, 0xBF), array(0x80, 0xBF)), - array(array(0xED, 0xED), array(0x80, 0x9F), array(0x80, 0xBF)), - array(array(0xEE, 0xEF), array(0x80, 0xBF), array(0x80, 0xBF)), - array(array(0xF0, 0xF0), array(0x90, 0xBF), array(0x80, 0xBF), array(0x80, 0xBF)), - array(array(0xF1, 0xF3), array(0x80, 0xBF), array(0x80, 0xBF), array(0x80, 0xBF)), - array(array(0xF4, 0xF4), array(0x80, 0x8F), array(0x80, 0xBF), array(0x80, 0xBF)), + array(array(0x00, 0x7F)), + array(array(0xC2, 0xDF), array(0x80, 0xBF)), + array(array(0xE0, 0xE0), array(0xA0, 0xBF), array(0x80, 0xBF)), + array(array(0xE1, 0xEC), array(0x80, 0xBF), array(0x80, 0xBF)), + array(array(0xED, 0xED), array(0x80, 0x9F), array(0x80, 0xBF)), + array(array(0xEE, 0xEF), array(0x80, 0xBF), array(0x80, 0xBF)), + array(array(0xF0, 0xF0), array(0x90, 0xBF), array(0x80, 0xBF), array(0x80, 0xBF)), + array(array(0xF1, 0xF3), array(0x80, 0xBF), array(0x80, 0xBF), array(0x80, 0xBF)), + array(array(0xF4, 0xF4), array(0x80, 0x8F), array(0x80, 0xBF), array(0x80, 0xBF)), ); function is_valid($seq) { - global $val_ranges; - $b = ord($seq[0]); - foreach ($val_ranges as $l) { - if ($b >= $l[0][0] && $b <= $l[0][1]) { - if (count($l) != strlen($seq)) { - return false; - } - for ($n = 1; $n < strlen($seq); $n++) { - if (ord($seq[$n]) < $l[$n][0] || ord($seq[$n]) > $l[$n][1]) { - return false; - } - } - return true; - } - } - return false; + global $val_ranges; + $b = ord($seq[0]); + foreach ($val_ranges as $l) { + if ($b >= $l[0][0] && $b <= $l[0][1]) { + if (count($l) != strlen($seq)) { + return false; + } + for ($n = 1; $n < strlen($seq); $n++) { + if (ord($seq[$n]) < $l[$n][0] || ord($seq[$n]) > $l[$n][1]) { + return false; + } + } + return true; + } + } + return false; } function concordance($s) { - $vhe = strlen(htmlspecialchars($s, ENT_QUOTES, "UTF-8")) > 0; - $v = is_valid($s); - return ($vhe === $v); + $vhe = strlen(htmlspecialchars($s, ENT_QUOTES, "UTF-8")) > 0; + $v = is_valid($s); + return ($vhe === $v); } for ($b1 = 0xC0; $b1 < 0xE0; $b1++) { - for ($b2 = 0x80; $b2 < 0xBF; $b2++) { - $s = chr($b1).chr($b2); - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - } + for ($b2 = 0x80; $b2 < 0xBF; $b2++) { + $s = chr($b1).chr($b2); + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + } } for ($b1 = 0xE0; $b1 < 0xEF; $b1++) { - for ($b2 = 0x80; $b2 < 0xBF; $b2++) { - $s = chr($b1).chr($b2)."\x80"; - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - $s = chr($b1).chr($b2)."\xBF"; - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - } + for ($b2 = 0x80; $b2 < 0xBF; $b2++) { + $s = chr($b1).chr($b2)."\x80"; + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + $s = chr($b1).chr($b2)."\xBF"; + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + } } for ($b1 = 0xF0; $b1 < 0xFF; $b1++) { - for ($b2 = 0x80; $b2 < 0xBF; $b2++) { - $s = chr($b1).chr($b2)."\x80\x80"; - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - $s = chr($b1).chr($b2)."\xBF\x80"; - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - $s = chr($b1).chr($b2)."\x80\xBF"; - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - $s = chr($b1).chr($b2)."\xBF\xBF"; - if (!concordance($s)) - echo "Discordance for ".bin2hex($s),"\n"; - } + for ($b2 = 0x80; $b2 < 0xBF; $b2++) { + $s = chr($b1).chr($b2)."\x80\x80"; + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + $s = chr($b1).chr($b2)."\xBF\x80"; + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + $s = chr($b1).chr($b2)."\x80\xBF"; + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + $s = chr($b1).chr($b2)."\xBF\xBF"; + if (!concordance($s)) + echo "Discordance for ".bin2hex($s),"\n"; + } } echo "Done.\n"; --EXPECT-- diff --git a/ext/standard/tests/strings/htmlentities-utf.phpt b/ext/standard/tests/strings/htmlentities-utf.phpt index 215f500c9160..5325378593a6 100644 --- a/ext/standard/tests/strings/htmlentities-utf.phpt +++ b/ext/standard/tests/strings/htmlentities-utf.phpt @@ -6,15 +6,15 @@ output_handler= --EXPECT-- diff --git a/ext/standard/tests/strings/htmlentities01.phpt b/ext/standard/tests/strings/htmlentities01.phpt index 092027a7a46b..269bd467b9e5 100644 --- a/ext/standard/tests/strings/htmlentities01.phpt +++ b/ext/standard/tests/strings/htmlentities01.phpt @@ -5,8 +5,8 @@ output_handler= internal_encoding=pass --FILE-- --EXPECT-- string(28) "‚†™Ÿ" diff --git a/ext/standard/tests/strings/htmlentities02.phpt b/ext/standard/tests/strings/htmlentities02.phpt index ad75766ee6af..6dcc4de48356 100644 --- a/ext/standard/tests/strings/htmlentities02.phpt +++ b/ext/standard/tests/strings/htmlentities02.phpt @@ -13,8 +13,8 @@ default_charset= internal_encoding=pass --FILE-- --EXPECT-- string(20) "ŒœŸ" diff --git a/ext/standard/tests/strings/htmlentities03.phpt b/ext/standard/tests/strings/htmlentities03.phpt index 6b00e8b48c39..b7e07fb3758b 100644 --- a/ext/standard/tests/strings/htmlentities03.phpt +++ b/ext/standard/tests/strings/htmlentities03.phpt @@ -13,8 +13,8 @@ default_charset= internal_encoding=pass --FILE-- --EXPECT-- string(18) "äöü" diff --git a/ext/standard/tests/strings/htmlentities04.phpt b/ext/standard/tests/strings/htmlentities04.phpt index 33f38682da25..7e47d8d4fcf0 100644 --- a/ext/standard/tests/strings/htmlentities04.phpt +++ b/ext/standard/tests/strings/htmlentities04.phpt @@ -13,8 +13,8 @@ default_charset= internal_encoding=pass --FILE-- --EXPECTF-- Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d diff --git a/ext/standard/tests/strings/htmlentities05.phpt b/ext/standard/tests/strings/htmlentities05.phpt index f65a1a435a00..04bf4deb0019 100644 --- a/ext/standard/tests/strings/htmlentities05.phpt +++ b/ext/standard/tests/strings/htmlentities05.phpt @@ -8,9 +8,9 @@ internal_encoding=cp1252 extension_loaded("mbstring") or die("skip mbstring not available\n"); --FILE-- --EXPECT-- Windows-1252 diff --git a/ext/standard/tests/strings/htmlentities06.phpt b/ext/standard/tests/strings/htmlentities06.phpt index 5027c0c19393..487b5d33fffc 100644 --- a/ext/standard/tests/strings/htmlentities06.phpt +++ b/ext/standard/tests/strings/htmlentities06.phpt @@ -8,9 +8,9 @@ internal_encoding=ISO-8859-15 extension_loaded("mbstring") or die("skip mbstring not available\n"); --FILE-- --EXPECT-- ISO-8859-15 diff --git a/ext/standard/tests/strings/htmlentities07.phpt b/ext/standard/tests/strings/htmlentities07.phpt index fe43d32d49f1..04e138e0c79f 100644 --- a/ext/standard/tests/strings/htmlentities07.phpt +++ b/ext/standard/tests/strings/htmlentities07.phpt @@ -8,9 +8,9 @@ internal_encoding=ISO-8859-1 extension_loaded("mbstring") or die("skip mbstring not available\n"); --FILE-- --EXPECT-- ISO-8859-1 diff --git a/ext/standard/tests/strings/htmlentities08.phpt b/ext/standard/tests/strings/htmlentities08.phpt index b44796ec8013..fdba4ede80db 100644 --- a/ext/standard/tests/strings/htmlentities08.phpt +++ b/ext/standard/tests/strings/htmlentities08.phpt @@ -8,9 +8,9 @@ internal_encoding=EUC-JP extension_loaded("mbstring") or die("skip mbstring not available\n"); --FILE-- --EXPECTF-- EUC-JP diff --git a/ext/standard/tests/strings/htmlentities09.phpt b/ext/standard/tests/strings/htmlentities09.phpt index 11493b62a478..6ca0a1e39e67 100644 --- a/ext/standard/tests/strings/htmlentities09.phpt +++ b/ext/standard/tests/strings/htmlentities09.phpt @@ -8,9 +8,9 @@ internal_encoding=Shift_JIS extension_loaded("mbstring") or die("skip mbstring not available\n"); --FILE-- --EXPECTF-- SJIS diff --git a/ext/standard/tests/strings/htmlentities10.phpt b/ext/standard/tests/strings/htmlentities10.phpt index 5f6d8ffc57bb..2f8c42b7e52d 100644 --- a/ext/standard/tests/strings/htmlentities10.phpt +++ b/ext/standard/tests/strings/htmlentities10.phpt @@ -6,9 +6,9 @@ internal_encoding=pass default_charset=cp1252 --FILE-- --EXPECT-- cp1252 diff --git a/ext/standard/tests/strings/htmlentities11.phpt b/ext/standard/tests/strings/htmlentities11.phpt index 0ee1044c135d..c803f76a536a 100644 --- a/ext/standard/tests/strings/htmlentities11.phpt +++ b/ext/standard/tests/strings/htmlentities11.phpt @@ -6,8 +6,8 @@ internal_encoding=pass default_charset=ISO-8859-15 --FILE-- --EXPECT-- ISO-8859-15 diff --git a/ext/standard/tests/strings/htmlentities12.phpt b/ext/standard/tests/strings/htmlentities12.phpt index c3cb7b6440b6..c2963f1c86ff 100644 --- a/ext/standard/tests/strings/htmlentities12.phpt +++ b/ext/standard/tests/strings/htmlentities12.phpt @@ -6,8 +6,8 @@ internal_encoding=pass default_charset=ISO-8859-1 --FILE-- --EXPECT-- ISO-8859-1 diff --git a/ext/standard/tests/strings/htmlentities13.phpt b/ext/standard/tests/strings/htmlentities13.phpt index bdea7a30ee42..ac2c8cd4b000 100644 --- a/ext/standard/tests/strings/htmlentities13.phpt +++ b/ext/standard/tests/strings/htmlentities13.phpt @@ -7,8 +7,8 @@ default_charset=EUC-JP filter.default=unsafe_raw --FILE-- --EXPECTF-- EUC-JP diff --git a/ext/standard/tests/strings/htmlentities14.phpt b/ext/standard/tests/strings/htmlentities14.phpt index e39a0037263e..60226cbe10bc 100644 --- a/ext/standard/tests/strings/htmlentities14.phpt +++ b/ext/standard/tests/strings/htmlentities14.phpt @@ -7,8 +7,8 @@ default_charset=Shift_JIS filter.default=unsafe_raw --FILE-- --EXPECTF-- Shift_JIS diff --git a/ext/standard/tests/strings/htmlentities17.phpt b/ext/standard/tests/strings/htmlentities17.phpt index d9e67a9b8780..5e29de5d8ecb 100644 --- a/ext/standard/tests/strings/htmlentities17.phpt +++ b/ext/standard/tests/strings/htmlentities17.phpt @@ -3,25 +3,25 @@ htmlentities() / html_entity_decode() #8592 - #9002 table test --FILE-- --EXPECT-- diff --git a/ext/standard/tests/strings/htmlentities18.phpt b/ext/standard/tests/strings/htmlentities18.phpt index d7bd2302c165..d9582e7dbc62 100644 --- a/ext/standard/tests/strings/htmlentities18.phpt +++ b/ext/standard/tests/strings/htmlentities18.phpt @@ -3,21 +3,21 @@ htmlentities() / htmlspecialchars() "don't double encode" flag support --FILE-- --EXPECT-- diff --git a/ext/standard/tests/strings/htmlentities19.phpt b/ext/standard/tests/strings/htmlentities19.phpt index a90358c613b1..bc607ad24007 100644 --- a/ext/standard/tests/strings/htmlentities19.phpt +++ b/ext/standard/tests/strings/htmlentities19.phpt @@ -3,16 +3,16 @@ htmlentities() / htmlspecialchars() ENT_SUBSTITUTE --FILE-- --EXPECT-- diff --git a/ext/standard/tests/strings/htmlentities20.phpt b/ext/standard/tests/strings/htmlentities20.phpt index ff52aca07ac8..956ecfc1b9fe 100644 --- a/ext/standard/tests/strings/htmlentities20.phpt +++ b/ext/standard/tests/strings/htmlentities20.phpt @@ -3,25 +3,25 @@ htmlentities() / htmlspecialchars() ENT_DISALLOWED --FILE-- > 6), 0x80 | ($k & 0x3f)); - } else if ($k < 0x10000) { + } else if ($k < 0x10000) { $retval = pack('C3', 0xe0 | ($k >> 12), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } else { + } else { $retval = pack('C4', 0xf0 | ($k >> 18), 0x80 | (($k >> 12) & 0x3f), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } - return $retval; + } + return $retval; } $tests = array( diff --git a/ext/standard/tests/strings/htmlentities23.phpt b/ext/standard/tests/strings/htmlentities23.phpt index 68e6e9439e98..3b33e382e574 100644 --- a/ext/standard/tests/strings/htmlentities23.phpt +++ b/ext/standard/tests/strings/htmlentities23.phpt @@ -20,9 +20,9 @@ $tests = array( foreach ($tests as $test) { $a = htmlentities($test, ENT_QUOTES | ENT_SUBSTITUTE, "EUC-JP"); - var_dump($a, bin2hex($a)); + var_dump($a, bin2hex($a)); $a = htmlspecialchars($test, ENT_QUOTES | ENT_SUBSTITUTE, "EUC-JP"); - var_dump($a, bin2hex($a)); + var_dump($a, bin2hex($a)); echo "\n"; } ?> diff --git a/ext/standard/tests/strings/htmlentities_html4.phpt b/ext/standard/tests/strings/htmlentities_html4.phpt index 5d784c2af541..8e23fbaeca3a 100644 --- a/ext/standard/tests/strings/htmlentities_html4.phpt +++ b/ext/standard/tests/strings/htmlentities_html4.phpt @@ -3,31 +3,31 @@ htmlentities() conformance check (HTML 4) --FILE-- > 6), 0x80 | ($k & 0x3f)); - } else if ($k < 0x10000) { + } else if ($k < 0x10000) { $retval = pack('C3', 0xe0 | ($k >> 12), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } else if ($k < 0x200000) { + } else if ($k < 0x200000) { $retval = pack('C4', 0xf0 | ($k >> 18), 0x80 | (($k >> 12) & 0x3f), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } else if ($k < 0x4000000) { + } else if ($k < 0x4000000) { $retval = pack('C5', 0xf8 | ($k >> 24), 0x80 | (($k >> 18) & 0x3f), 0x80 | (($k >> 12) & 0x3f), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } else { + } else { $retval = pack('C6', 0xfc | ($k >> 30), 0x80 | (($k >> 24) & 0x3f), @@ -35,8 +35,8 @@ function utf32_utf8($k) { 0x80 | (($k >> 12) & 0x3f), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } - return $retval; + } + return $retval; } $table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES, 'UTF-8'); @@ -45,15 +45,15 @@ for ($i = 0; $i < 0x2710; $i++) { if ($i >= 0xd800 && $i < 0xe000) continue; $str = utf32_utf8($i); - if (isset($table[$str])) { - printf("%s\tU+%05X\n", $table[$str], $i); - unset($table[$str]); - } + if (isset($table[$str])) { + printf("%s\tU+%05X\n", $table[$str], $i); + unset($table[$str]); + } } if (!empty($table)) { - echo "Not matched entities: "; - var_dump($table); + echo "Not matched entities: "; + var_dump($table); } ?> diff --git a/ext/standard/tests/strings/htmlentities_html5.phpt b/ext/standard/tests/strings/htmlentities_html5.phpt index 4a91012bd79d..d3e94d5dbaab 100644 --- a/ext/standard/tests/strings/htmlentities_html5.phpt +++ b/ext/standard/tests/strings/htmlentities_html5.phpt @@ -3,25 +3,25 @@ htmlentities() conformance check (HTML 5) --FILE-- > 6), 0x80 | ($k & 0x3f)); - } else if ($k < 0x10000) { + } else if ($k < 0x10000) { $retval = pack('C3', 0xe0 | ($k >> 12), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } else { + } else { $retval = pack('C4', 0xf0 | ($k >> 18), 0x80 | (($k >> 12) & 0x3f), 0x80 | (($k >> 6) & 0x3f), 0x80 | ($k & 0x3f)); - } - return $retval; + } + return $retval; } for ($i = 0; $i < 0x1DFFF; $i++) { diff --git a/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt b/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt index 596a883be246..8a6100ac45f0 100644 Binary files a/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt and b/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt differ diff --git a/ext/standard/tests/strings/lcfirst.phpt b/ext/standard/tests/strings/lcfirst.phpt index ed25d329b2fc..5f754d7b2bb7 100644 Binary files a/ext/standard/tests/strings/lcfirst.phpt and b/ext/standard/tests/strings/lcfirst.phpt differ diff --git a/ext/standard/tests/strings/md5_basic2.phpt b/ext/standard/tests/strings/md5_basic2.phpt index f302753cd3a0..0e2db58e9502 100644 --- a/ext/standard/tests/strings/md5_basic2.phpt +++ b/ext/standard/tests/strings/md5_basic2.phpt @@ -15,10 +15,10 @@ var_dump(bin2hex($md5_raw)); $md5 = md5($str, false); if (strcmp(bin2hex($md5_raw), $md5) == 0 ) { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } else { - echo "TEST FAILED\n"; - var_dump($md5_raw, $md5); + echo "TEST FAILED\n"; + var_dump($md5_raw, $md5); } ?> diff --git a/ext/standard/tests/strings/metaphone.phpt b/ext/standard/tests/strings/metaphone.phpt index c70b4846a127..2bc16b3248db 100644 --- a/ext/standard/tests/strings/metaphone.phpt +++ b/ext/standard/tests/strings/metaphone.phpt @@ -19,7 +19,7 @@ $array = array( ); foreach($array as $str) { - var_dump(metaphone($str)); + var_dump(metaphone($str)); } echo "Done\n"; diff --git a/ext/standard/tests/strings/nl2br.phpt b/ext/standard/tests/strings/nl2br.phpt index 728f3339a002..b2ff9cf0900d 100644 --- a/ext/standard/tests/strings/nl2br.phpt +++ b/ext/standard/tests/strings/nl2br.phpt @@ -2,17 +2,17 @@ nl2br() function --FILE-- --EXPECT-- diff --git a/ext/standard/tests/strings/number_format_basic.phpt b/ext/standard/tests/strings/number_format_basic.phpt index 4eb4d5108693..f06a55cb6368 100644 --- a/ext/standard/tests/strings/number_format_basic.phpt +++ b/ext/standard/tests/strings/number_format_basic.phpt @@ -11,40 +11,40 @@ Test number_format() - basic function test number_format() echo "*** Testing number_format() : basic functionality ***\n"; $values = array(1234.5678, - -1234.5678, - 1234.6578e4, - -1234.56789e4, - 0x1234CDEF, - 02777777777, - "123456789", - "123.456789", - "12.3456789e1", - null, - true, - false); + -1234.5678, + 1234.6578e4, + -1234.56789e4, + 0x1234CDEF, + 02777777777, + "123456789", + "123.456789", + "12.3456789e1", + null, + true, + false); echo "\n-- number_format tests.....default --\n"; for ($i = 0; $i < count($values); $i++) { - $res = number_format($values[$i]); - var_dump($res); + $res = number_format($values[$i]); + var_dump($res); } echo "\n-- number_format tests.....with two dp --\n"; for ($i = 0; $i < count($values); $i++) { - $res = number_format($values[$i], 2); - var_dump($res); + $res = number_format($values[$i], 2); + var_dump($res); } echo "\n-- number_format tests.....English format --\n"; for ($i = 0; $i < count($values); $i++) { - $res = number_format($values[$i], 2, '.', ' '); - var_dump($res); + $res = number_format($values[$i], 2, '.', ' '); + var_dump($res); } echo "\n-- number_format tests.....French format --\n"; for ($i = 0; $i < count($values); $i++) { - $res = number_format($values[$i], 2, ',' , ' '); - var_dump($res); + $res = number_format($values[$i], 2, ',' , ' '); + var_dump($res); } ?> --EXPECT-- diff --git a/ext/standard/tests/strings/ord_basic.phpt b/ext/standard/tests/strings/ord_basic.phpt index a7c93fc6d35a..c7d6891a0967 100644 --- a/ext/standard/tests/strings/ord_basic.phpt +++ b/ext/standard/tests/strings/ord_basic.phpt @@ -24,9 +24,9 @@ var_dump(ord("Hello")); // Make sure all valid ascii chars round trip for ($i = 0; $i < 255; $i++) { - if (ord(chr($i)) != $i) { - exit("TEST FAILED: $i does not round trip\n"); - } + if (ord(chr($i)) != $i) { + exit("TEST FAILED: $i does not round trip\n"); + } } ?> diff --git a/ext/standard/tests/strings/pack_A.phpt b/ext/standard/tests/strings/pack_A.phpt index b5a7b97fc3c9..abc12ac1b1fd 100644 --- a/ext/standard/tests/strings/pack_A.phpt +++ b/ext/standard/tests/strings/pack_A.phpt @@ -3,11 +3,11 @@ pack()/unpack(): "A" modifier --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/strings/pack_Z.phpt b/ext/standard/tests/strings/pack_Z.phpt index 4fd007ae0f6a..5a7c5d95a603 100644 --- a/ext/standard/tests/strings/pack_Z.phpt +++ b/ext/standard/tests/strings/pack_Z.phpt @@ -3,11 +3,11 @@ pack()/unpack(): "Z" format --FILE-- '; diff --git a/ext/standard/tests/strings/print_variation1.phpt b/ext/standard/tests/strings/print_variation1.phpt index f06b83ee8f6d..e5849ecfdf72 100644 --- a/ext/standard/tests/strings/print_variation1.phpt +++ b/ext/standard/tests/strings/print_variation1.phpt @@ -28,43 +28,43 @@ $file_handle = fopen(__FILE__, "r"); // array with different values for $input $inputs = array ( - // integer values + // integer values /*1*/ 0, - 1, - -2, - 2147483647, - -2147483648, + 1, + -2, + 2147483647, + -2147483648, - // float values + // float values /*6*/ 10.5, - -20.5, - 10.1234567e10, + -20.5, + 10.1234567e10, - // array values + // array values /*9*/ array(), - array(0), - array(1, 2), + array(0), + array(1, 2), - // boolean values + // boolean values /*12*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // null values + // null values /*16*/ NULL, - null, + null, - // objects + // objects /*18*/ new sample(), - // resource + // resource /*19*/ $file_handle, - // undefined variable + // undefined variable /*20*/ @$undefined_var, - // unset variable + // unset variable /*21*/ @$unset_var ); diff --git a/ext/standard/tests/strings/printf_variation1.phpt b/ext/standard/tests/strings/printf_variation1.phpt index 4ec032f9ce61..d6fad7e97a81 100644 --- a/ext/standard/tests/strings/printf_variation1.phpt +++ b/ext/standard/tests/strings/printf_variation1.phpt @@ -35,50 +35,50 @@ $file_handle = fopen(__FILE__, 'r'); //array of values to iterate over $values = array( - // int data + // int data /*1*/ 0, - 1, - 12345, - -2345, + 1, + 12345, + -2345, - // float data + // float data /*5*/ 10.5, - -10.5, - 10.1234567e10, - 10.7654321E-10, - .5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, - // array data + // array data /*10*/ array(), - array(0), - array(1), - array(1, 2), - array('color' => 'red', 'item' => 'pen'), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), - // null data + // null data /*15*/ NULL, - null, + null, - // boolean data + // boolean data /*17*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*21*/ "", - '', + '', - // object data + // object data /*23*/ new sample(), - // undefined data + // undefined data /*24*/ @$undefined_var, - // unset data + // unset data /*25*/ @$unset_var, - // resource data + // resource data /*26*/ $file_handle ); diff --git a/ext/standard/tests/strings/printf_variation2.phpt b/ext/standard/tests/strings/printf_variation2.phpt index 3c3d92cbe340..d0335b455e10 100644 --- a/ext/standard/tests/strings/printf_variation2.phpt +++ b/ext/standard/tests/strings/printf_variation2.phpt @@ -31,54 +31,54 @@ $file_handle = fopen(__FILE__, 'r'); //array of values to iterate over $values = array( - // int data + // int data /*1*/ 0, - 1, - 12345, - -2345, + 1, + 12345, + -2345, - // float data + // float data /*5*/ 10.5, - -10.5, - 10.1234567e10, - 10.7654321E-10, - .5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, - // array data + // array data /*10*/ array(), - array(0), - array(1), - array(1, 2), - array('color' => 'red', 'item' => 'pen'), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), - // null data + // null data /*15*/ NULL, - null, + null, - // boolean data + // boolean data /*17*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*21*/ "", - '', + '', - // string data + // string data /*23*/ "string", - 'string', + 'string', - // object data + // object data /*25*/ new sample(), - // undefined data + // undefined data /*26*/ @$undefined_var, - // unset data + // unset data /*27*/ @$unset_var, - // resource data + // resource data /*28*/ $file_handle ); diff --git a/ext/standard/tests/strings/quoted_printable_decode_basic.phpt b/ext/standard/tests/strings/quoted_printable_decode_basic.phpt index 09bcd343d038..b40080cdf3da 100644 --- a/ext/standard/tests/strings/quoted_printable_decode_basic.phpt +++ b/ext/standard/tests/strings/quoted_printable_decode_basic.phpt @@ -9,9 +9,9 @@ Test quoted_printable_decode() function : basic functionality echo "*** Testing quoted_printable_decode() : basic functionality ***\n"; -$str = "=FAwow-factor=C1=d0=D5=DD=C5=CE=CE=D9=C5=0A= -=20=D4=cf=D2=C7=CF=D7=D9=C5= -=20= +$str = "=FAwow-factor=C1=d0=D5=DD=C5=CE=CE=D9=C5=0A= +=20=D4=cf=D2=C7=CF=D7=D9=C5= +=20= =D0= =D2=CF=C5=CB=D4=D9"; diff --git a/ext/standard/tests/strings/quoted_printable_encode_002.phpt b/ext/standard/tests/strings/quoted_printable_encode_002.phpt index aaf5608f3334..b01b6957c902 100644 Binary files a/ext/standard/tests/strings/quoted_printable_encode_002.phpt and b/ext/standard/tests/strings/quoted_printable_encode_002.phpt differ diff --git a/ext/standard/tests/strings/setlocale_variation2.phpt b/ext/standard/tests/strings/setlocale_variation2.phpt index fad3298cc7a9..41a706c8bf46 100644 --- a/ext/standard/tests/strings/setlocale_variation2.phpt +++ b/ext/standard/tests/strings/setlocale_variation2.phpt @@ -22,7 +22,7 @@ function good_locale($locale) { /** * Note: no_NO is a bogus locale and should not be used, see https://bugzilla.redhat.com/971416 **/ - return $locale !== 'tt_RU@iqtelif.UTF-8' && $locale !== 'no_NO.ISO-8859-1'; + return $locale !== 'tt_RU@iqtelif.UTF-8' && $locale !== 'no_NO.ISO-8859-1'; } /* Prototype : array list_system_locales( void ) diff --git a/ext/standard/tests/strings/sha1.phpt b/ext/standard/tests/strings/sha1.phpt index 4473598d06c2..1fea3566b5f8 100644 --- a/ext/standard/tests/strings/sha1.phpt +++ b/ext/standard/tests/strings/sha1.phpt @@ -5,18 +5,18 @@ sha1() with ASCII output $filename = __DIR__."/sha1.dat"; $a = array( - "abc", - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "a", - "0123456701234567012345670123456701234567012345670123456701234567", - "" + "abc", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "a", + "0123456701234567012345670123456701234567012345670123456701234567", + "" ); foreach ($a as $str) { - var_dump($val1 = sha1($str)); - file_put_contents($filename, $str); - var_dump($val2 = sha1_file($filename)); - var_dump($val1 === $val2); + var_dump($val1 = sha1($str)); + file_put_contents($filename, $str); + var_dump($val2 = sha1_file($filename)); + var_dump($val1 === $val2); } var_dump(sha1($str, true)); diff --git a/ext/standard/tests/strings/soundex.phpt b/ext/standard/tests/strings/soundex.phpt index 744f71c17a2b..ef61ac495ead 100644 --- a/ext/standard/tests/strings/soundex.phpt +++ b/ext/standard/tests/strings/soundex.phpt @@ -25,7 +25,7 @@ $array = array( ); foreach ($array as $str) { - var_dump(soundex($str)); + var_dump(soundex($str)); } echo "Done\n"; diff --git a/ext/standard/tests/strings/str_pad_variation2.phpt b/ext/standard/tests/strings/str_pad_variation2.phpt index 1ebf1b2825bd..0bf8ad3ad80a 100644 --- a/ext/standard/tests/strings/str_pad_variation2.phpt +++ b/ext/standard/tests/strings/str_pad_variation2.phpt @@ -11,7 +11,7 @@ $string = chr(0).chr(255).chr(128).chr(234).chr(143); /* different pad_lengths */ $pad_lengths = [ -PHP_INT_MAX, // huge negative value - -1, // negative value + -1, // negative value 0, // pad_length < sizeof(input_string) 9, // pad_length <= sizeof(input_string) 10, // pad_length > sizeof(input_string) diff --git a/ext/standard/tests/strings/str_replace_variation3.phpt b/ext/standard/tests/strings/str_replace_variation3.phpt index d52c0676c989..f1bbf89b9fdc 100644 --- a/ext/standard/tests/strings/str_replace_variation3.phpt +++ b/ext/standard/tests/strings/str_replace_variation3.phpt @@ -16,10 +16,10 @@ echo "\n*** Testing Miscellaneous input data ***\n"; /* If replace has fewer values than search, then an empty string is used for the rest of replacement values */ var_dump( str_replace(array("a", "a", "b"), - array("q", "q"), - "aaabb", $count - ) - ); + array("q", "q"), + "aaabb", $count + ) + ); var_dump($count); var_dump( str_replace(array("a", "a", "b"), array("q", "q"), diff --git a/ext/standard/tests/strings/str_rot13_basic.phpt b/ext/standard/tests/strings/str_rot13_basic.phpt index b90e86fd4f53..bc071be2b4f5 100644 --- a/ext/standard/tests/strings/str_rot13_basic.phpt +++ b/ext/standard/tests/strings/str_rot13_basic.phpt @@ -14,16 +14,16 @@ var_dump(str_rot13("abcdefghijklmnopqrstuvwxyz")); echo "\nEnsure numeric characters are left untouched\n"; if (strcmp(str_rot13("0123456789"), "0123456789") == 0) { - echo "Strings equal : TEST PASSED\n"; + echo "Strings equal : TEST PASSED\n"; } else { - echo "Strings unequal : TEST FAILED\n"; + echo "Strings unequal : TEST FAILED\n"; } echo "\nEnsure non-alphabetic characters are left untouched\n"; if (strcmp(str_rot13("!%^&*()_-+={}[]:;@~#<,>.?"), "!%^&*()_-+={}[]:;@~#<,>.?")) { - echo "Strings equal : TEST PASSED\n"; + echo "Strings equal : TEST PASSED\n"; } else { - echo "Strings unequal : TEST FAILED\n"; + echo "Strings unequal : TEST FAILED\n"; } echo "\nEnsure strings round trip\n"; @@ -31,9 +31,9 @@ $str = "str_rot13() tests starting"; $encode = str_rot13($str); $decode = str_rot13($encode); if (strcmp($str, $decode) == 0) { - echo "Strings equal : TEST PASSED\n"; + echo "Strings equal : TEST PASSED\n"; } else { - echo "Strings unequal : TEST FAILED\n"; + echo "Strings unequal : TEST FAILED\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/strings/str_shuffle_basic.phpt b/ext/standard/tests/strings/str_shuffle_basic.phpt index 037d65ac0eb4..8e857ff4ec24 100644 --- a/ext/standard/tests/strings/str_shuffle_basic.phpt +++ b/ext/standard/tests/strings/str_shuffle_basic.phpt @@ -29,13 +29,13 @@ for ($i = 0; $i < $trys; $i++) { $op = str_shuffle($ip); if (!is_string($op) || strlen($op) != $len_ip) { - echo "TEST FAILED\n"; + echo "TEST FAILED\n"; } // Combination already hit ? if (empty($a[$op])) { - // No first time init - $a[$op] = 0; + // No first time init + $a[$op] = 0; } // Increment count for this combination @@ -45,9 +45,9 @@ for ($i = 0; $i < $trys; $i++) { $combinations = count($a); if ($combinations != 24) { - echo "TEST FAILED.. Only $combinations out of a possible 24 combinations used\n"; + echo "TEST FAILED.. Only $combinations out of a possible 24 combinations used\n"; } else { - echo "TEST PASSED\n"; + echo "TEST PASSED\n"; } ?> diff --git a/ext/standard/tests/strings/str_split_variation6.phpt b/ext/standard/tests/strings/str_split_variation6.phpt index 2d73a06d100a..270fcad05a0e 100644 --- a/ext/standard/tests/strings/str_split_variation6.phpt +++ b/ext/standard/tests/strings/str_split_variation6.phpt @@ -38,7 +38,7 @@ for($count = 0; $count < count($values); $count++) { echo "-- Iteration ".($count + 1)." --\n"; try { - var_dump( str_split($str, $values[$count]) ); + var_dump( str_split($str, $values[$count]) ); } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } diff --git a/ext/standard/tests/strings/str_split_variation7.phpt b/ext/standard/tests/strings/str_split_variation7.phpt index 4d28b765acc8..097607bf8b85 100644 --- a/ext/standard/tests/strings/str_split_variation7.phpt +++ b/ext/standard/tests/strings/str_split_variation7.phpt @@ -40,7 +40,7 @@ for($count = 0; $count < count($values); $count++) { echo "-- Iteration ".($count + 1)." --\n"; try { - var_dump( str_split($str, $values[$count]) ); + var_dump( str_split($str, $values[$count]) ); } catch (\ValueError $e) { echo $e->getMessage() . "\n"; } diff --git a/ext/standard/tests/strings/strcasecmp.phpt b/ext/standard/tests/strings/strcasecmp.phpt index 7c4fe920adc0..4258f11ee3eb 100644 Binary files a/ext/standard/tests/strings/strcasecmp.phpt and b/ext/standard/tests/strings/strcasecmp.phpt differ diff --git a/ext/standard/tests/strings/strcmp.phpt b/ext/standard/tests/strings/strcmp.phpt index e18a8542448c..d4110601afbd 100644 Binary files a/ext/standard/tests/strings/strcmp.phpt and b/ext/standard/tests/strings/strcmp.phpt differ diff --git a/ext/standard/tests/strings/strcoll.phpt b/ext/standard/tests/strings/strcoll.phpt index 37fe251b667e..d1d3df11fc18 100644 --- a/ext/standard/tests/strings/strcoll.phpt +++ b/ext/standard/tests/strings/strcoll.phpt @@ -13,7 +13,7 @@ Testfest 2009 Munich setlocale (LC_COLLATE, 'C'); $result = strcoll($a, $b); if($result > 0) { - echo "Pass\n"; + echo "Pass\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/strings/strcspn_variation10.phpt b/ext/standard/tests/strings/strcspn_variation10.phpt index 1ad369f5dd38..0b933b8049db 100644 --- a/ext/standard/tests/strings/strcspn_variation10.phpt +++ b/ext/standard/tests/strings/strcspn_variation10.phpt @@ -18,35 +18,35 @@ echo "*** Testing strcspn() : with different mask strings and default start and // initialing required variables $strings = array( "", - '', - "\n", - '\n', - "hello\tworld\nhello\nworld\n", - 'hello\tworld\nhello\nworld\n', - "1234hello45world\t123", - '1234hello45world\t123', - "hello\0world\012", - 'hello\0world\012', - chr(0).chr(0), - chr(0)."hello\0world".chr(0), - chr(0).'hello\0world'.chr(0), - "hello".chr(0)."world", - 'hello'.chr(0).'world', - "hello\0\100\xaaaworld", - 'hello\0\100\xaaaworld' + '', + "\n", + '\n', + "hello\tworld\nhello\nworld\n", + 'hello\tworld\nhello\nworld\n', + "1234hello45world\t123", + '1234hello45world\t123', + "hello\0world\012", + 'hello\0world\012', + chr(0).chr(0), + chr(0)."hello\0world".chr(0), + chr(0).'hello\0world'.chr(0), + "hello".chr(0)."world", + 'hello'.chr(0).'world', + "hello\0\100\xaaaworld", + 'hello\0\100\xaaaworld' ); // defining array of mask strings $mask_array = array( - "", - '', - "\n\trsti \l", - '\n\trsti \l', - "\t", - "t\ ", - '\t', - "\t\ ", - " \t", + "", + '', + "\n\trsti \l", + '\n\trsti \l', + "\t", + "t\ ", + '\t', + "\t\ ", + " \t", "\t\i\100\xa" ); diff --git a/ext/standard/tests/strings/strcspn_variation12.phpt b/ext/standard/tests/strings/strcspn_variation12.phpt index 4495e7c26dea..83530aee719b 100644 --- a/ext/standard/tests/strings/strcspn_variation12.phpt +++ b/ext/standard/tests/strings/strcspn_variation12.phpt @@ -43,22 +43,22 @@ $mask_array = array( //defining array of start values $start_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648 // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648 // min negative integer ); //defining array of len values $len_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648 // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648 // min negative integer ); diff --git a/ext/standard/tests/strings/strcspn_variation6.phpt b/ext/standard/tests/strings/strcspn_variation6.phpt index 4d6c81d0fb42..dc8ceb6ddf46 100644 --- a/ext/standard/tests/strings/strcspn_variation6.phpt +++ b/ext/standard/tests/strings/strcspn_variation6.phpt @@ -62,15 +62,15 @@ $heredoc_strings = array( // defining array of mask strings $mask_array = array( - "", - '', - "\n\trsti \l", - '\n\trsti \l', - "\t", - "t\ ", - '\t', - "\t\ ", - " \t", + "", + '', + "\n\trsti \l", + '\n\trsti \l', + "\t", + "t\ ", + '\t', + "\t\ ", + " \t", "\t\i\100\xaa" ); diff --git a/ext/standard/tests/strings/strcspn_variation7.phpt b/ext/standard/tests/strings/strcspn_variation7.phpt index 1f53e20d6f53..6c88b45f28f4 100644 --- a/ext/standard/tests/strings/strcspn_variation7.phpt +++ b/ext/standard/tests/strings/strcspn_variation7.phpt @@ -57,34 +57,34 @@ $heredoc_strings = array( $heredoc_with_newline_and_tabs, $heredoc_with_alphanumerics, $heredoc_with_embedded_nulls, - $heredoc_with_hexa_octal - ); + $heredoc_with_hexa_octal + ); // defining array of mask strings $mask_array = array( - "", - '', - "\n\trsti \l", - '\n\trsti \l', - "\t", - "t\ ", - '\t', - "\t\ ", - " \t", + "", + '', + "\n\trsti \l", + '\n\trsti \l', + "\t", + "t\ ", + '\t', + "\t\ ", + " \t", "\t\i\100\xaa" ); // definig array of start values $start_array = array( - 0, - 1, - 2, - -1, - -2, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + -2, + 2147483647, // max positive integer + -2147483648, // min negative integer ); diff --git a/ext/standard/tests/strings/strcspn_variation8.phpt b/ext/standard/tests/strings/strcspn_variation8.phpt index 10c42731e708..388d9156a58d 100644 --- a/ext/standard/tests/strings/strcspn_variation8.phpt +++ b/ext/standard/tests/strings/strcspn_variation8.phpt @@ -57,38 +57,38 @@ $heredoc_strings = array( $heredoc_with_newline_and_tabs, $heredoc_with_alphanumerics, $heredoc_with_embedded_nulls, - $heredoc_with_hexa_octal - ); + $heredoc_with_hexa_octal + ); // defining array of mask strings $mask_array = array( - "", - '', - "\n\trsti \l", - "\t", - "t\ ", - " \t", + "", + '', + "\n\trsti \l", + "\t", + "t\ ", + " \t", "\t\i\100\xaa" ); // definig array of start values $start_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648, // min negative integer ); // defining array of len values $len_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648, // min negative integer ); diff --git a/ext/standard/tests/strings/strcspn_variation9.phpt b/ext/standard/tests/strings/strcspn_variation9.phpt index 632aaa4b5de3..6fd70827a52d 100644 Binary files a/ext/standard/tests/strings/strcspn_variation9.phpt and b/ext/standard/tests/strings/strcspn_variation9.phpt differ diff --git a/ext/standard/tests/strings/strip_tags.phpt b/ext/standard/tests/strings/strip_tags.phpt index 7beebf1b0cee..e594e1793cf5 100644 --- a/ext/standard/tests/strings/strip_tags.phpt +++ b/ext/standard/tests/strings/strip_tags.phpt @@ -2,20 +2,20 @@ strip_tags() function --FILE-- STUFF'); - echo "\n"; - echo strip_tags('NEAT blah ?> STUFF'); - echo "\n"; - echo strip_tags('NEAT STUFF'); - echo "\n"; - echo strip_tags('NEAT STUFF'); - echo "\n"; - echo strip_tags('NEAT STUFF'); - echo "\n"; - echo strip_tags('NEAT STUFF'); - echo "\n"; - echo strip_tags('TESTS ?!!?!?!!!?!!'); - echo "\n"; + echo strip_tags('NEAT STUFF'); + echo "\n"; + echo strip_tags('NEAT blah ?> STUFF'); + echo "\n"; + echo strip_tags('NEAT STUFF'); + echo "\n"; + echo strip_tags('NEAT STUFF'); + echo "\n"; + echo strip_tags('NEAT STUFF'); + echo "\n"; + echo strip_tags('NEAT STUFF'); + echo "\n"; + echo strip_tags('TESTS ?!!?!?!!!?!!'); + echo "\n"; ?> --EXPECT-- NEAT STUFF diff --git a/ext/standard/tests/strings/stripos.phpt b/ext/standard/tests/strings/stripos.phpt index bc2a7bc8e5e8..f56d38d3de7b 100644 --- a/ext/standard/tests/strings/stripos.phpt +++ b/ext/standard/tests/strings/stripos.phpt @@ -2,29 +2,29 @@ stripos() function test --FILE-- DONE diff --git a/ext/standard/tests/strings/stripslashes_variation2.phpt b/ext/standard/tests/strings/stripslashes_variation2.phpt index 5bfe5ce1fdb3..fdca660c4df3 100644 Binary files a/ext/standard/tests/strings/stripslashes_variation2.phpt and b/ext/standard/tests/strings/stripslashes_variation2.phpt differ diff --git a/ext/standard/tests/strings/stripslashes_variation3.phpt b/ext/standard/tests/strings/stripslashes_variation3.phpt index 61af9db8368f..54a8b3d02e6b 100644 --- a/ext/standard/tests/strings/stripslashes_variation3.phpt +++ b/ext/standard/tests/strings/stripslashes_variation3.phpt @@ -28,22 +28,22 @@ EOT; $str_array = array( // string with newline character "\n", - "\\n", + "\\n", "Hello \nworld", "Hello \\nworld", '\n', - '\\n', + '\\n', 'Hello \nworld', 'Hello \\nworld', $heredoc_string_with_newline, // string with tab character - "\t", - "\\t", + "\t", + "\\t", "Hello \tworld", "Hello \\tworld", - '\t', - '\\t', + '\t', + '\\t', 'Hello \tworld', 'Hello \\tworld', $heredoc_string_with_tab diff --git a/ext/standard/tests/strings/stristr.phpt b/ext/standard/tests/strings/stristr.phpt index 0d47e80bcbcc..7b1b5312a1ab 100644 --- a/ext/standard/tests/strings/stristr.phpt +++ b/ext/standard/tests/strings/stristr.phpt @@ -2,17 +2,17 @@ stristr() function --FILE-- --EXPECTF-- string(11) "tEsT sTrInG" diff --git a/ext/standard/tests/strings/stristr_variation2.phpt b/ext/standard/tests/strings/stristr_variation2.phpt index 553c46209721..8448292802c9 100644 --- a/ext/standard/tests/strings/stristr_variation2.phpt +++ b/ext/standard/tests/strings/stristr_variation2.phpt @@ -26,42 +26,42 @@ $file_handle = fopen(__FILE__, "r"); // array with different values for $input $inputs = array ( - // integer values + // integer values /*1*/ 0, - 1, - -2, - -PHP_INT_MAX, + 1, + -2, + -PHP_INT_MAX, - // float values + // float values /*5*/ 10.5, - -20.5, - 10.1234567e10, + -20.5, + 10.1234567e10, - // array values + // array values /*8*/ array(), - array(0), - array(1, 2), + array(0), + array(1, 2), - // boolean values + // boolean values /*11*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // null values + // null values /*15*/ NULL, - null, + null, - // objects + // objects /*17*/ new sample(), - // resource + // resource /*18*/ $file_handle, - // undefined variable + // undefined variable /*19*/ @$undefined_var, - // unset variable + // unset variable /*20*/ @$unset_var ); diff --git a/ext/standard/tests/strings/strlen.phpt b/ext/standard/tests/strings/strlen.phpt index 14aa687a1ad6..6be163d8fe12 100644 Binary files a/ext/standard/tests/strings/strlen.phpt and b/ext/standard/tests/strings/strlen.phpt differ diff --git a/ext/standard/tests/strings/strnatcasecmp_basic.phpt b/ext/standard/tests/strings/strnatcasecmp_basic.phpt index 043ad43d37bf..5968980642df 100644 --- a/ext/standard/tests/strings/strnatcasecmp_basic.phpt +++ b/ext/standard/tests/strings/strnatcasecmp_basic.phpt @@ -11,7 +11,7 @@ Felix De Vliegher */ function str_dump($one, $two) { - var_dump(strnatcasecmp($one, $two)); + var_dump(strnatcasecmp($one, $two)); } echo "*** Testing strnatcasecmp() : basic functionality ***\n"; diff --git a/ext/standard/tests/strings/strnatcasecmp_variation1.phpt b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt index 7f6d4579c3f8..44d2a09c5a23 100644 --- a/ext/standard/tests/strings/strnatcasecmp_variation1.phpt +++ b/ext/standard/tests/strings/strnatcasecmp_variation1.phpt @@ -13,25 +13,25 @@ Felix De Vliegher /* Preparation */ class a { - function __toString() - { - return "Hello WORLD"; - } + function __toString() + { + return "Hello WORLD"; + } } class b { - function __toString() - { - return "HELLO world"; - } + function __toString() + { + return "HELLO world"; + } } $a = new a(); $b = new b(); function str_dump($a, $b) { - var_dump(strnatcasecmp($a, $b)); + var_dump(strnatcasecmp($a, $b)); } echo "*** Testing strnatcasecmp() : variation ***\n"; diff --git a/ext/standard/tests/strings/strrev.phpt b/ext/standard/tests/strings/strrev.phpt index 92c66817d951..6303fccc20a0 100644 --- a/ext/standard/tests/strings/strrev.phpt +++ b/ext/standard/tests/strings/strrev.phpt @@ -2,16 +2,16 @@ strrev() function --FILE-- --EXPECT-- string(32) "ec6df70f2569891eae50321a9179eb82" diff --git a/ext/standard/tests/strings/strripos.phpt b/ext/standard/tests/strings/strripos.phpt index c343e92731f3..81881c379699 100644 --- a/ext/standard/tests/strings/strripos.phpt +++ b/ext/standard/tests/strings/strripos.phpt @@ -2,19 +2,19 @@ strripos() function --FILE-- --EXPECT-- int(5) diff --git a/ext/standard/tests/strings/strripos_variation1.phpt b/ext/standard/tests/strings/strripos_variation1.phpt index 5c143d256445..d8188bdd8753 100644 --- a/ext/standard/tests/strings/strripos_variation1.phpt +++ b/ext/standard/tests/strings/strripos_variation1.phpt @@ -12,54 +12,54 @@ Test strripos() function : usage variations - double quoted strings for 'haystac echo "*** Testing strripos() function: with double quoted strings ***\n"; $haystack = "Hello,\t\n\0\n $&!#%()*<=>?@hello123456he \x234 \101 "; $needles = array( - //regular strings + //regular strings /*1*/ "l", - "L", - "HELLO", - "hEllo", + "L", + "HELLO", + "hEllo", - //escape characters + //escape characters /*5*/ "\t", - "\T", //invalid input - " ", - "\n", - "\N", //invalid input - " + "\T", //invalid input + " ", + "\n", + "\N", //invalid input + " ", //new line - //nulls + //nulls /*11*/ "\0", - NULL, - null, + NULL, + null, - //boolean false + //boolean false /*14*/ FALSE, - false, + false, - //empty string + //empty string /*16*/ "", - //special chars + //special chars /*17*/ " ", - "$", - " $", - "&", - "!#", - "()", - "<=>", - ">", - "=>", - "?", - "@", - "@hEllo", + "$", + " $", + "&", + "!#", + "()", + "<=>", + ">", + "=>", + "?", + "@", + "@hEllo", /*29*/ "12345", //decimal numeric string - "\x23", //hexadecimal numeric string - "#", //respective ASCII char of \x23 - "\101", //octal numeric string - "A", //respective ASCII char of \101 - "456HEE", //numerics + chars - $haystack //haystack as needle + "\x23", //hexadecimal numeric string + "#", //respective ASCII char of \x23 + "\101", //octal numeric string + "A", //respective ASCII char of \101 + "456HEE", //numerics + chars + $haystack //haystack as needle ); /* loop through to get the position of the needle in haystack string */ diff --git a/ext/standard/tests/strings/strripos_variation2.phpt b/ext/standard/tests/strings/strripos_variation2.phpt index 273215b6166f..55753c5c9b23 100644 --- a/ext/standard/tests/strings/strripos_variation2.phpt +++ b/ext/standard/tests/strings/strripos_variation2.phpt @@ -12,55 +12,55 @@ Test strripos() function : usage variations - single quoted strings for 'haystac echo "*** Testing strripos() function: with single quoted strings ***\n"; $haystack = 'Hello,\t\n\0\n $&!#%()*<=>?@hello123456he \x234 \101 '; $needles = array( - //regular strings + //regular strings /*1*/ 'l', - 'L', - 'HELLO', - 'hEllo', + 'L', + 'HELLO', + 'hEllo', - //escape characters + //escape characters /*5*/ '\t', - '\T', - ' ', - '\n', - '\N', - ' - ', //new line + '\T', + ' ', + '\n', + '\N', + ' + ', //new line - //nulls + //nulls /*11*/ '\0', - NULL, - null, + NULL, + null, - //boolean false + //boolean false /*14*/ FALSE, - false, + false, - //empty string + //empty string /*16*/ '', - //special chars + //special chars /*17*/ ' ', - '$', - ' $', - '&', - '!#', - '()', - '<=>', - '>', - '=>', - '?', - '@', - '@hEllo', + '$', + ' $', + '&', + '!#', + '()', + '<=>', + '>', + '=>', + '?', + '@', + '@hEllo', /*29*/ '12345', //decimal numeric string - '\x23', //hexadecimal numeric string - '#', //respective ASCII char of \x23 - '\101', //octal numeric string - 'A', // respective ASCII char for \101 - '456HEE', //numerics + chars - 42, //needle as int(ASCII value of '*') - $haystack //haystack as needle + '\x23', //hexadecimal numeric string + '#', //respective ASCII char of \x23 + '\101', //octal numeric string + 'A', // respective ASCII char for \101 + '456HEE', //numerics + chars + 42, //needle as int(ASCII value of '*') + $haystack //haystack as needle ); /* loop through to get the position of the needle in haystack string */ diff --git a/ext/standard/tests/strings/strrpos.phpt b/ext/standard/tests/strings/strrpos.phpt index f672d93a2a2c..d374175b5abc 100644 --- a/ext/standard/tests/strings/strrpos.phpt +++ b/ext/standard/tests/strings/strrpos.phpt @@ -2,19 +2,19 @@ strrpos() function --FILE-- --EXPECT-- int(5) diff --git a/ext/standard/tests/strings/strrpos_negative_offset.phpt b/ext/standard/tests/strings/strrpos_negative_offset.phpt index 17560f18f7fd..41b2b16b5691 100644 --- a/ext/standard/tests/strings/strrpos_negative_offset.phpt +++ b/ext/standard/tests/strings/strrpos_negative_offset.phpt @@ -2,28 +2,28 @@ strr[i]pos() function with negative offset --FILE-- getMessage() . "\n"; - } - var_dump(strripos("HAYSTHACk", 'ha', -9)); - var_dump(strripos("HAYSTACK", 'h', -8)); - var_dump(strripos("HAYSTACK", 'k', -1)); - var_dump(strripos("HAYSTACK", "ka", -1)); - var_dump(strripos("HAYSTACK", 'a', -3)); - var_dump(strripos("HAYSTACK", 'a', -4)); - try { - strripos("HAYSTACK", 'h', -9); - } catch (ValueError $exception) { + var_dump(strrpos("haysthack", 'ha', -9)); + var_dump(strrpos("haystack", 'h', -8)); + var_dump(strrpos("haystack", 'k', -1)); + var_dump(strrpos("haystack", "ka", -1)); + var_dump(strrpos("haystack", 'a', -3)); + var_dump(strrpos("haystack", 'a', -4)); + try { + strrpos("haystack", 'h', -9); + } catch (ValueError $exception) { echo $exception->getMessage() . "\n"; - } + } + var_dump(strripos("HAYSTHACk", 'ha', -9)); + var_dump(strripos("HAYSTACK", 'h', -8)); + var_dump(strripos("HAYSTACK", 'k', -1)); + var_dump(strripos("HAYSTACK", "ka", -1)); + var_dump(strripos("HAYSTACK", 'a', -3)); + var_dump(strripos("HAYSTACK", 'a', -4)); + try { + strripos("HAYSTACK", 'h', -9); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } ?> --EXPECT-- int(0) diff --git a/ext/standard/tests/strings/strspn_variation10.phpt b/ext/standard/tests/strings/strspn_variation10.phpt index d8eb52aa6f47..952110880f1c 100644 --- a/ext/standard/tests/strings/strspn_variation10.phpt +++ b/ext/standard/tests/strings/strspn_variation10.phpt @@ -19,35 +19,35 @@ echo "*** Testing strspn() : with different mask strings and default start and l // defining different strings $strings = array( "", - '', - "\n", - '\n', - "hello\tworld\nhello\nworld\n", - 'hello\tworld\nhello\nworld\n', - "1234hello45world\t123", - '1234hello45world\t123', - "hello\0world\012", - 'hello\0world\012', - chr(0).chr(0), - chr(0)."hello\0world".chr(0), - chr(0).'hello\0world'.chr(0), - "hello".chr(0)."world", - 'hello'.chr(0).'world', - "hello\0\100\xaaaworld", - 'hello\0\100\xaaaworld' + '', + "\n", + '\n', + "hello\tworld\nhello\nworld\n", + 'hello\tworld\nhello\nworld\n', + "1234hello45world\t123", + '1234hello45world\t123', + "hello\0world\012", + 'hello\0world\012', + chr(0).chr(0), + chr(0)."hello\0world".chr(0), + chr(0).'hello\0world'.chr(0), + "hello".chr(0)."world", + 'hello'.chr(0).'world', + "hello\0\100\xaaaworld", + 'hello\0\100\xaaaworld' ); // define the array of mask strings $mask_array = array( - "", - '', - "f\n\trelshti \l", - 'f\n\trelsthi \l', - "\telh", - "t\ ", - '\telh', - "felh\t\ ", - " \t", + "", + '', + "f\n\trelshti \l", + 'f\n\trelsthi \l', + "\telh", + "t\ ", + '\telh', + "felh\t\ ", + " \t", "fhel\t\i\100\xa" ); diff --git a/ext/standard/tests/strings/strspn_variation11.phpt b/ext/standard/tests/strings/strspn_variation11.phpt index ecbe6a4967a6..1737155a7ace 100644 --- a/ext/standard/tests/strings/strspn_variation11.phpt +++ b/ext/standard/tests/strings/strspn_variation11.phpt @@ -19,47 +19,47 @@ echo "*** Testing strspn() : with different start and default len values ***\n"; // defining different strings $strings = array( "", - '', - "\n", - '\n', - "hello\tworld\nhello\nworld\n", - 'hello\tworld\nhello\nworld\n', - "1234hello45world\t123", - '1234hello45world\t123', - "hello\0world\012", - 'hello\0world\012', - chr(0).chr(0), - chr(0)."hello\0world".chr(0), - chr(0).'hello\0world'.chr(0), - "hello".chr(0)."world", - 'hello'.chr(0).'world', - "hello\0\100\xaaaworld", - 'hello\0\100\xaaaworld' + '', + "\n", + '\n', + "hello\tworld\nhello\nworld\n", + 'hello\tworld\nhello\nworld\n', + "1234hello45world\t123", + '1234hello45world\t123', + "hello\0world\012", + 'hello\0world\012', + chr(0).chr(0), + chr(0)."hello\0world".chr(0), + chr(0).'hello\0world'.chr(0), + "hello".chr(0)."world", + 'hello'.chr(0).'world', + "hello\0\100\xaaaworld", + 'hello\0\100\xaaaworld' ); // define the array of mask strings $mask_array = array( - "", - '', - "f\n\trelshti \l", - 'f\n\trelsthi \l', - "\telh", - "t\ ", - '\telh', - "felh\t\ ", - " \t", + "", + '', + "f\n\trelshti \l", + 'f\n\trelsthi \l', + "\telh", + "t\ ", + '\telh', + "felh\t\ ", + " \t", "fhel\t\i\100\xa" ); // defining the array for start values $start_array = array( - 0, - 1, + 0, + 1, 2, - -1, - -2, - 2147483647, // max positive integer - -2147483648, // min negative integer + -1, + -2, + 2147483647, // max positive integer + -2147483648, // min negative integer ); diff --git a/ext/standard/tests/strings/strspn_variation12.phpt b/ext/standard/tests/strings/strspn_variation12.phpt index 1c404c191408..e5615c9532b2 100644 --- a/ext/standard/tests/strings/strspn_variation12.phpt +++ b/ext/standard/tests/strings/strspn_variation12.phpt @@ -19,47 +19,47 @@ echo "*** Testing strspn() : with different start and len values ***\n"; // defining different strings $strings = array( "", - '', - "\n", - '\n', - "hello\tworld\nhello\nworld\n", - "1234hello45world\t123", - "hello\0world\012", - chr(0).chr(0), - chr(0)."hello\0world".chr(0), - "hello".chr(0)."world", - "hello\0\100\xaaaworld", + '', + "\n", + '\n', + "hello\tworld\nhello\nworld\n", + "1234hello45world\t123", + "hello\0world\012", + chr(0).chr(0), + chr(0)."hello\0world".chr(0), + "hello".chr(0)."world", + "hello\0\100\xaaaworld", ); // define the array of mask strings $mask_array = array( - "", - '', - "f\n\trelshti \l", - 'f\n\trelsthi \l', - "\telh", - "felh\t\ ", + "", + '', + "f\n\trelshti \l", + 'f\n\trelsthi \l', + "\telh", + "felh\t\ ", "fhel\t\i\100\xa" ); // defining the array for start values $start_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648, // min negative integer ); // defining an array of len values $len_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648, // min negative integer ); diff --git a/ext/standard/tests/strings/strspn_variation6.phpt b/ext/standard/tests/strings/strspn_variation6.phpt index b202bb82344d..8c75e89775b8 100644 --- a/ext/standard/tests/strings/strspn_variation6.phpt +++ b/ext/standard/tests/strings/strspn_variation6.phpt @@ -63,15 +63,15 @@ $heredoc_strings = array( // defining array of different mask strings $mask_array = array( - "", - '', - "fh\ne\trlsti \l", - 'fieh\n\trlsti \l', - "\t", - "lt\ ", - 'l\t', - "fl\t\eh ", - "l \te", + "", + '', + "fh\ne\trlsti \l", + 'fieh\n\trlsti \l', + "\t", + "lt\ ", + 'l\t', + "fl\t\eh ", + "l \te", "lf\the\i\100\xaa" ); diff --git a/ext/standard/tests/strings/strspn_variation7.phpt b/ext/standard/tests/strings/strspn_variation7.phpt index bbfe5d486800..962c180c406d 100644 --- a/ext/standard/tests/strings/strspn_variation7.phpt +++ b/ext/standard/tests/strings/strspn_variation7.phpt @@ -63,27 +63,27 @@ $heredoc_strings = array( // defining array of different mask strings $mask_array = array( - "", - '', - "f\nh\trstie \l", - 'f\n\thrstei \l', - "\t", - "t\ e", - '\t', - "f\te\h ", - " \t", + "", + '', + "f\nh\trstie \l", + 'f\n\thrstei \l', + "\t", + "t\ e", + '\t', + "f\te\h ", + " \t", "f\t\ih\100e\xa" ); // defining array of different start values $start_array = array( - 0, - 1, - 2, - -1, - -2, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + -2, + 2147483647, // max positive integer + -2147483648, // min negative integer ); diff --git a/ext/standard/tests/strings/strspn_variation8.phpt b/ext/standard/tests/strings/strspn_variation8.phpt index 0ff0000132a4..a3486908b76d 100644 --- a/ext/standard/tests/strings/strspn_variation8.phpt +++ b/ext/standard/tests/strings/strspn_variation8.phpt @@ -63,33 +63,33 @@ $heredoc_strings = array( // defining array of different mask strings $mask_array = array( - "", - '', - "f\n\\0htersti \l", - "\t", - "het\ ", - "fel\th\ ", + "", + '', + "f\n\\0htersti \l", + "\t", + "het\ ", + "fel\th\ ", "f\t\hiel\100\xaa" ); // defining array of different start values $start_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648, // min negative integer ); // defining array of different len values $len_array = array( - 0, - 1, - 2, - -1, - 2147483647, // max positive integer - -2147483648, // min negative integer + 0, + 1, + 2, + -1, + 2147483647, // max positive integer + -2147483648, // min negative integer ); diff --git a/ext/standard/tests/strings/strspn_variation9.phpt b/ext/standard/tests/strings/strspn_variation9.phpt index 0835047ff59e..49d590bee84f 100644 Binary files a/ext/standard/tests/strings/strspn_variation9.phpt and b/ext/standard/tests/strings/strspn_variation9.phpt differ diff --git a/ext/standard/tests/strings/strtok_variation4.phpt b/ext/standard/tests/strings/strtok_variation4.phpt index 5db1d3965062..fb34639f4841 100644 --- a/ext/standard/tests/strings/strtok_variation4.phpt +++ b/ext/standard/tests/strings/strtok_variation4.phpt @@ -15,8 +15,8 @@ echo "*** Testing strtok() : with embedded nulls in the strings ***\n"; // defining varous strings with embedded nulls $strings_with_nulls = array( - "\0", - '\0', + "\0", + '\0', "hello\0world", "\0hel\0lo", "hello\0", diff --git a/ext/standard/tests/strings/strtok_variation5.phpt b/ext/standard/tests/strings/strtok_variation5.phpt index a99d13eb7a2a..e844f97eef55 100644 --- a/ext/standard/tests/strings/strtok_variation5.phpt +++ b/ext/standard/tests/strings/strtok_variation5.phpt @@ -15,31 +15,31 @@ echo "*** Testing strtok() : with miscellaneous inputs ***\n"; // defining arrays for input strings and tokens $string_array = array( - "HELLO WORLD", - "hello world", - "_HELLO_WORLD_", - "/thello/t/wor/ttld", - "hel/lo/t/world", + "HELLO WORLD", + "hello world", + "_HELLO_WORLD_", + "/thello/t/wor/ttld", + "hel/lo/t/world", "one:$:two:!:three:#:four", - "\rhello/r/wor\rrld", - chr(0), + "\rhello/r/wor\rrld", + chr(0), chr(0).chr(0), chr(0).'hello'.chr(0), 'hello'.chr(0).'world' - ); + ); $token_array = array( - "wr", - "hello world", - "__", + "wr", + "hello world", + "__", "t/", - '/t', - ":", - "\r", - "\0", - "\0", - "\0", - "\0", - ); + '/t', + ":", + "\r", + "\0", + "\0", + "\0", + "\0", + ); // loop through each element of the array and check the working of strtok() // when supplied with different string and token values diff --git a/ext/standard/tests/strings/strtok_variation6.phpt b/ext/standard/tests/strings/strtok_variation6.phpt index cd7f3b3041d3..4d435dcef487 100644 --- a/ext/standard/tests/strings/strtok_variation6.phpt +++ b/ext/standard/tests/strings/strtok_variation6.phpt @@ -15,18 +15,18 @@ echo "*** Testing strtok() : with invalid escape sequences in token ***\n"; // defining arrays for input strings and tokens $string_array = array( - "khellok worldk", - "\khello\k world\k", - "/khello\k world/k", - "/hellok/ world" - ); + "khellok worldk", + "\khello\k world\k", + "/khello\k world/k", + "/hellok/ world" + ); $token_array = array( - "k", - "/ ", - "/k", - "\k", - "\\\\\\\k\h\\e\l\o\w\r\l\d" - ); + "k", + "/ ", + "/k", + "\k", + "\\\\\\\k\h\\e\l\o\w\r\l\d" + ); // loop through each element of the array and check the working of strtok() // when supplied with different string and token values diff --git a/ext/standard/tests/strings/strtr_variation6.phpt b/ext/standard/tests/strings/strtr_variation6.phpt index e0c2458edeea..9956acaca86f 100644 --- a/ext/standard/tests/strings/strtr_variation6.phpt +++ b/ext/standard/tests/strings/strtr_variation6.phpt @@ -34,41 +34,41 @@ $str = "012atm"; // array of values for 'from' $from_arr = array ( - // integer values + // integer values /*1*/ 0, - 1, - -2, + 1, + -2, - // float values + // float values /*4*/ 10.5, - -20.5, - 10.1234567e10, + -20.5, + 10.1234567e10, - // array values + // array values /*7*/ array(), - array(0), - array(1, 2), + array(0), + array(1, 2), - // boolean values + // boolean values /*10*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // null values + // null values /*14*/ NULL, - null, + null, - // objects + // objects /*16*/ new sample(), - // resource + // resource /*17*/ $file_handle, - // undefined variable + // undefined variable /*18*/ @$undefined_var, - // unset variable + // unset variable /*19*/ @$unset_var ); diff --git a/ext/standard/tests/strings/strval_basic.phpt b/ext/standard/tests/strings/strval_basic.phpt index ac89554527ff..9e26446c4c65 100644 --- a/ext/standard/tests/strings/strval_basic.phpt +++ b/ext/standard/tests/strings/strval_basic.phpt @@ -18,23 +18,23 @@ EOT; //array of values to iterate over $values = array( - // Simple strings + // Simple strings /*1*/ "Hello World", - 'Hello World', + 'Hello World', - // String with control chars + // String with control chars /*3*/ "String\nwith\ncontrol\ncharacters\r\n", - // String with quotes + // String with quotes /*4*/ "String with \"quotes\"", - //Numeric String + //Numeric String /*5*/ "123456", - // Hexadecimal string + // Hexadecimal string /*6*/ "0xABC", - //Heredoc String + //Heredoc String /*7*/ $simple_heredoc ); diff --git a/ext/standard/tests/strings/strval_error.phpt b/ext/standard/tests/strings/strval_error.phpt index 18d502eb2b28..a363e26f243f 100644 --- a/ext/standard/tests/strings/strval_error.phpt +++ b/ext/standard/tests/strings/strval_error.phpt @@ -13,7 +13,7 @@ error_reporting(E_ALL ^ E_NOTICE); class MyClass { - // no toString() method defined + // no toString() method defined } // Testing strval with a object which has no toString() method diff --git a/ext/standard/tests/strings/strval_variation1.phpt b/ext/standard/tests/strings/strval_variation1.phpt index 068e1e2649ac..d64a7c4ab096 100644 --- a/ext/standard/tests/strings/strval_variation1.phpt +++ b/ext/standard/tests/strings/strval_variation1.phpt @@ -25,59 +25,59 @@ class MyClass //array of values to iterate over $values = array( - //Decimal values + //Decimal values /*1*/ 0, - 1, - 12345, - -12345, + 1, + 12345, + -12345, - //Octal values + //Octal values /*5*/ 02, - 010, - 030071, - -030071, + 010, + 030071, + -030071, - //Hexadecimal values + //Hexadecimal values /*9*/ 0x0, - 0x1, - 0xABCD, - -0xABCD, + 0x1, + 0xABCD, + -0xABCD, - // float data + // float data /*13*/ 100.5, - -100.5, - 100.1234567e10, - 100.7654321E-10, - .5, + -100.5, + 100.1234567e10, + 100.7654321E-10, + .5, - // array data + // array data /*18*/ array(), - array('color' => 'red', 'item' => 'pen'), + array('color' => 'red', 'item' => 'pen'), - // null data + // null data /*20*/ NULL, - null, + null, - // boolean data + // boolean data /*22*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*26*/ "", - '', + '', - // object data + // object data /*28*/ new MyClass(), - // resource + // resource /*29*/ $file_handle, - // undefined data + // undefined data /*30*/ @$undefined_var, - // unset data + // unset data /*31*/ @$unset_var, ); diff --git a/ext/standard/tests/strings/ucfirst.phpt b/ext/standard/tests/strings/ucfirst.phpt index c5c7ce3c87bf..e7c0373a3cbd 100644 Binary files a/ext/standard/tests/strings/ucfirst.phpt and b/ext/standard/tests/strings/ucfirst.phpt differ diff --git a/ext/standard/tests/strings/unpack.phpt b/ext/standard/tests/strings/unpack.phpt index 3a6068be7179..435361cca54a 100644 --- a/ext/standard/tests/strings/unpack.phpt +++ b/ext/standard/tests/strings/unpack.phpt @@ -2,8 +2,8 @@ Invalid format type validation --FILE-- --EXPECTF-- Warning: unpack(): Invalid format type - in %sunpack.php on line %d diff --git a/ext/standard/tests/strings/unpack_offset.phpt b/ext/standard/tests/strings/unpack_offset.phpt index 64cb089bc3d0..451dd367246b 100644 --- a/ext/standard/tests/strings/unpack_offset.phpt +++ b/ext/standard/tests/strings/unpack_offset.phpt @@ -8,8 +8,8 @@ $a = unpack("l2", $data, 3); printf("0x%08x 0x%08x\n", $a[1], $a[2]); printf("0x%08x 0x%08x\n", - unpack("l", $data, 3)[1], - unpack("@4/l", $data, 3)[1]); + unpack("l", $data, 3)[1], + unpack("@4/l", $data, 3)[1]); ?> --EXPECT-- 0x01020304 0x05060708 diff --git a/ext/standard/tests/strings/url_t.phpt b/ext/standard/tests/strings/url_t.phpt index 1ff7baff90e3..caa93cb9cf01 100644 --- a/ext/standard/tests/strings/url_t.phpt +++ b/ext/standard/tests/strings/url_t.phpt @@ -81,7 +81,7 @@ $sample_urls = array ( $url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123'; foreach (array(PHP_URL_SCHEME,PHP_URL_HOST,PHP_URL_PORT,PHP_URL_USER,PHP_URL_PASS,PHP_URL_PATH,PHP_URL_QUERY,PHP_URL_FRAGMENT) as $v) { - var_dump(parse_url($url, $v)); + var_dump(parse_url($url, $v)); } ?> --EXPECT-- diff --git a/ext/standard/tests/strings/vfprintf_basic.phpt b/ext/standard/tests/strings/vfprintf_basic.phpt index 16a0014425db..321937159436 100644 --- a/ext/standard/tests/strings/vfprintf_basic.phpt +++ b/ext/standard/tests/strings/vfprintf_basic.phpt @@ -14,12 +14,12 @@ precision=14 function writeAndDump($fp, $format, $args) { - ftruncate( $fp, 0 ); - $length = vfprintf( $fp, $format, $args ); - rewind( $fp ); - $content = stream_get_contents( $fp ); - var_dump( $content ); - var_dump( $length ); + ftruncate( $fp, 0 ); + $length = vfprintf( $fp, $format, $args ); + rewind( $fp ); + $content = stream_get_contents( $fp ); + var_dump( $content ); + var_dump( $length ); } echo "*** Testing vfprintf() : basic functionality ***\n"; diff --git a/ext/standard/tests/strings/vfprintf_variation1.phpt b/ext/standard/tests/strings/vfprintf_variation1.phpt index 744d9e2fd85b..d7120e41c09e 100644 --- a/ext/standard/tests/strings/vfprintf_variation1.phpt +++ b/ext/standard/tests/strings/vfprintf_variation1.phpt @@ -23,21 +23,21 @@ unset( $funset ); class FooClass { - public function __toString() - { - return "Object"; - } + public function __toString() + { + return "Object"; + } } // Output facilitating function function writeAndDump($fp, $format, $args) { - ftruncate( $fp, 0 ); - $length = vfprintf( $fp, $format, $args ); - rewind( $fp ); - $content = stream_get_contents( $fp ); - var_dump( $content ); - var_dump( $length ); + ftruncate( $fp, 0 ); + $length = vfprintf( $fp, $format, $args ); + rewind( $fp ); + $content = stream_get_contents( $fp ); + var_dump( $content ); + var_dump( $length ); } // Test vfprintf() diff --git a/ext/standard/tests/strings/vfprintf_variation20.phpt b/ext/standard/tests/strings/vfprintf_variation20.phpt index 17426c7af75c..95477f6c25c5 100644 --- a/ext/standard/tests/strings/vfprintf_variation20.phpt +++ b/ext/standard/tests/strings/vfprintf_variation20.phpt @@ -36,50 +36,50 @@ $file_handle = fopen(__FILE__, 'r'); //array of values to iterate over $values = array( - // int data + // int data /*1*/ 0, - 1, - 12345, - -2345, + 1, + 12345, + -2345, - // float data + // float data /*5*/ 10.5, - -10.5, - 10.1234567e10, - 10.7654321E-10, - .5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, - // array data + // array data /*10*/ array(), - array(0), - array(1), - array(1,2), - array('color' => 'red', 'item' => 'pen'), + array(0), + array(1), + array(1,2), + array('color' => 'red', 'item' => 'pen'), - // null data + // null data /*15*/ NULL, - null, + null, - // boolean data + // boolean data /*17*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*21*/ "", - '', + '', - // object data + // object data /*23*/ new sample(), - // undefined data + // undefined data /*24*/ @$undefined_var, - // unset data + // unset data /*25*/ @$unset_var, - // resource data + // resource data /*26*/ $file_handle ); diff --git a/ext/standard/tests/strings/vfprintf_variation21.phpt b/ext/standard/tests/strings/vfprintf_variation21.phpt index 9b9c3c12ae08..f44cc36a2c7f 100644 --- a/ext/standard/tests/strings/vfprintf_variation21.phpt +++ b/ext/standard/tests/strings/vfprintf_variation21.phpt @@ -36,47 +36,47 @@ $file_handle = fopen(__FILE__, 'r'); //array of values to iterate over $values = array( - // int data + // int data /*1*/ 0, - 1, - 12345, - -2345, + 1, + 12345, + -2345, - // float data + // float data /*5*/ 10.5, - -10.5, - 10.1234567e10, - 10.7654321E-10, - .5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, - // null data + // null data /*10*/ NULL, - null, + null, - // boolean data + // boolean data /*12*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*16*/ "", - '', + '', - // string data + // string data /*18*/ "string", - 'string', + 'string', - // object data + // object data /*20*/ new sample(), - // undefined data + // undefined data /*21*/ @$undefined_var, - // unset data + // unset data /*22*/ @$unset_var, - // resource data + // resource data /*23*/ $file_handle ); @@ -91,9 +91,9 @@ $counter = 1; foreach( $values as $value ) { fprintf($fp, "\n-- Iteration %d --\n",$counter); try { - vfprintf($fp, $format, $value); + vfprintf($fp, $format, $value); } catch (\ValueError $e) { - fwrite($fp, $e->getMessage() . "\n"); + fwrite($fp, $e->getMessage() . "\n"); } $counter++; } diff --git a/ext/standard/tests/strings/vprintf_variation1.phpt b/ext/standard/tests/strings/vprintf_variation1.phpt index 0fb8ed8a03d0..fd479274ef75 100644 --- a/ext/standard/tests/strings/vprintf_variation1.phpt +++ b/ext/standard/tests/strings/vprintf_variation1.phpt @@ -36,50 +36,50 @@ $file_handle = fopen(__FILE__, 'r'); //array of values to iterate over $values = array( - // int data + // int data /*1*/ 0, - 1, - 12345, - -2345, + 1, + 12345, + -2345, - // float data + // float data /*5*/ 10.5, - -10.5, - 10.1234567e10, - 10.7654321E-10, - .5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, - // array data + // array data /*10*/ array(), - array(0), - array(1), - array(1,2), - array('color' => 'red', 'item' => 'pen'), + array(0), + array(1), + array(1,2), + array('color' => 'red', 'item' => 'pen'), - // null data + // null data /*15*/ NULL, - null, + null, - // boolean data + // boolean data /*17*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*21*/ "", - '', + '', - // object data + // object data /*23*/ new sample(), - // undefined data + // undefined data /*24*/ @$undefined_var, - // unset data + // unset data /*25*/ @$unset_var, - // resource data + // resource data /*26*/ $file_handle ); diff --git a/ext/standard/tests/strings/vprintf_variation2.phpt b/ext/standard/tests/strings/vprintf_variation2.phpt index 4b59a5046de8..12ffb6dd1f76 100644 --- a/ext/standard/tests/strings/vprintf_variation2.phpt +++ b/ext/standard/tests/strings/vprintf_variation2.phpt @@ -36,47 +36,47 @@ $file_handle = fopen(__FILE__, 'r'); //array of values to iterate over $values = array( - // int data + // int data /*1*/ 0, - 1, - 12345, - -2345, + 1, + 12345, + -2345, - // float data + // float data /*5*/ 10.5, - -10.5, - 10.1234567e10, - 10.7654321E-10, - .5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, - // null data + // null data /*10*/ NULL, - null, + null, - // boolean data + // boolean data /*12*/ true, - false, - TRUE, - FALSE, + false, + TRUE, + FALSE, - // empty data + // empty data /*16*/ "", - '', + '', - // string data + // string data /*18*/ "string", - 'string', + 'string', - // object data + // object data /*20*/ new sample(), - // undefined data + // undefined data /*21*/ @$undefined_var, - // unset data + // unset data /*22*/ @$unset_var, - // resource data + // resource data /*23*/ $file_handle ); @@ -85,11 +85,11 @@ $counter = 1; foreach($values as $value) { echo "\n-- Iteration $counter --\n"; try { - $result = vprintf($format,$value); - echo "\n"; - var_dump($result); + $result = vprintf($format,$value); + echo "\n"; + var_dump($result); } catch (\ValueError $e) { - echo $e->getMessage(), "\n"; + echo $e->getMessage(), "\n"; } $counter++; }; diff --git a/ext/standard/tests/time/001.phpt b/ext/standard/tests/time/001.phpt index b8498850f135..34b87157f224 100644 --- a/ext/standard/tests/time/001.phpt +++ b/ext/standard/tests/time/001.phpt @@ -15,14 +15,14 @@ $result = ''; set_time_limit(0); for ($i=1;$i<=100000;$i++) { - list($micro,$time)=explode(" ",microtime()); - if ($time > $last_t || ($time == $last_t && $micro >= $last_m)) { - $passed++; - } else if ($failed++ <=10) { - $result .= sprintf('%06d', $i).": $time $micro < $last_t $last_m\n"; - } - $last_m = $micro; - $last_t = $time; + list($micro,$time)=explode(" ",microtime()); + if ($time > $last_t || ($time == $last_t && $micro >= $last_m)) { + $passed++; + } else if ($failed++ <=10) { + $result .= sprintf('%06d', $i).": $time $micro < $last_t $last_m\n"; + } + $last_m = $micro; + $last_t = $time; } echo "Passed: $passed\n"; echo "Failed: $failed\n"; diff --git a/ext/standard/tests/time/bug38524.phpt b/ext/standard/tests/time/bug38524.phpt index 3def28e0825c..22ff9e4d76ab 100644 --- a/ext/standard/tests/time/bug38524.phpt +++ b/ext/standard/tests/time/bug38524.phpt @@ -4,7 +4,7 @@ Bug #38524 (strptime() does not initialize the internal date storage structure) --FILE-- --EXPECTF-- array(9) { diff --git a/ext/standard/tests/time/bug60222.phpt b/ext/standard/tests/time/bug60222.phpt index 7ea65ce54ce3..c74d27d53bc5 100644 --- a/ext/standard/tests/time/bug60222.phpt +++ b/ext/standard/tests/time/bug60222.phpt @@ -3,7 +3,7 @@ Bug #60222 (time_nanosleep() does validate input params) --FILE-- getMessage() . "\n"; } diff --git a/ext/standard/tests/time/idate.phpt b/ext/standard/tests/time/idate.phpt index 0b544054992f..1a06070b45e3 100644 --- a/ext/standard/tests/time/idate.phpt +++ b/ext/standard/tests/time/idate.phpt @@ -5,7 +5,7 @@ idate() function date_default_timezone_set('GMT0'); $tmp = "UYzymndjHGhgistwLBIW"; for($a = 0;$a < strlen($tmp); $a++){ - echo $tmp[$a], ': ', idate($tmp[$a], 1043324459)."\n"; + echo $tmp[$a], ': ', idate($tmp[$a], 1043324459)."\n"; } ?> --EXPECT-- diff --git a/ext/standard/tests/url/base64_decode_basic_002.phpt b/ext/standard/tests/url/base64_decode_basic_002.phpt index c538d159979b..647fbd3b5c4d 100644 --- a/ext/standard/tests/url/base64_decode_basic_002.phpt +++ b/ext/standard/tests/url/base64_decode_basic_002.phpt @@ -16,7 +16,7 @@ var_dump(base64_decode($noWhiteSpace, true)); echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n"; $withWhiteSpace = "a GVs bG8gd2 - 9ybGQh"; + 9ybGQh"; var_dump(base64_decode($withWhiteSpace)); var_dump(base64_decode($withWhiteSpace, false)); var_dump(base64_decode($withWhiteSpace, true)); diff --git a/ext/standard/tests/url/base64_decode_basic_003.phpt b/ext/standard/tests/url/base64_decode_basic_003.phpt index 3bcd51e19284..13c0f449d81b 100644 --- a/ext/standard/tests/url/base64_decode_basic_003.phpt +++ b/ext/standard/tests/url/base64_decode_basic_003.phpt @@ -12,29 +12,29 @@ Test base64_decode() function : basic functionality - padding and whitespace echo "Test base64_decode (output as JSON):\n"; $data = [ - "", "=", "==", "===", "====", - "V", "V=", "V==", "V===", "V====", - "VV", "VV=", "VV==", "VV===", "VV====", - "VVV", "VVV=", "VVV==", "VVV===", "VVV====", - "VVVV", "VVVV=", "VVVV==", "VVVV===", "VVVV====", - "=V", "=VV", "=VVV", - "==V", "==VV", "==VVV", - "===V", "===VV", "===VVV", - "====V", "====VV", "====VVV", - "=VVV", "V=VV", "VV=V", "VVV=", - "=VVVV", "V=VVV", "VV=VV", "VVV=V", "VVVV=", - "=VVV=", "V=VV=", "VV=V=", "VVV==", - "\nVV", "V\nV", "VV\n", - "\nVV==", "V\nV==", "VV\n==", "VV=\n=", "VV==\n", - "*VV", "V*V", "VV*", - "*VV==", "V*V==", "VV*==", "VV=*=", "VV==*", - "\0VV==", "V\0V==", "VV\0==", "VV=\0=", "VV==\0", - "\0VVV==", "V\0VV==", "VV\0V==", "VVV\0==", "VVV=\0=", "VVV==\0", + "", "=", "==", "===", "====", + "V", "V=", "V==", "V===", "V====", + "VV", "VV=", "VV==", "VV===", "VV====", + "VVV", "VVV=", "VVV==", "VVV===", "VVV====", + "VVVV", "VVVV=", "VVVV==", "VVVV===", "VVVV====", + "=V", "=VV", "=VVV", + "==V", "==VV", "==VVV", + "===V", "===VV", "===VVV", + "====V", "====VV", "====VVV", + "=VVV", "V=VV", "VV=V", "VVV=", + "=VVVV", "V=VVV", "VV=VV", "VVV=V", "VVVV=", + "=VVV=", "V=VV=", "VV=V=", "VVV==", + "\nVV", "V\nV", "VV\n", + "\nVV==", "V\nV==", "VV\n==", "VV=\n=", "VV==\n", + "*VV", "V*V", "VV*", + "*VV==", "V*V==", "VV*==", "VV=*=", "VV==*", + "\0VV==", "V\0V==", "VV\0==", "VV=\0=", "VV==\0", + "\0VVV==", "V\0VV==", "VV\0V==", "VVV\0==", "VVV=\0=", "VVV==\0", ]; foreach ($data as $a) { - $b = base64_decode($a, false); - $c = base64_decode($a, true); - printf("base64 %-16s non-strict %-8s strict %s\n", json_encode($a), json_encode($b), json_encode($c)); + $b = base64_decode($a, false); + $c = base64_decode($a, true); + printf("base64 %-16s non-strict %-8s strict %s\n", json_encode($a), json_encode($b), json_encode($c)); } echo "Done\n"; ?> diff --git a/ext/standard/tests/url/base64_encode_basic_001.phpt b/ext/standard/tests/url/base64_encode_basic_001.phpt index 764e15f37700..ff8c20e1b5af 100644 --- a/ext/standard/tests/url/base64_encode_basic_001.phpt +++ b/ext/standard/tests/url/base64_encode_basic_001.phpt @@ -15,9 +15,9 @@ Test base64_encode() function : basic functionality echo "*** Testing base64_encode() : basic functionality ***\n"; for ($i=0; $i<256; $i++) { - $str = pack("c", $i); - $enc = base64_encode($str); - printf("0x%X: %s\n", $i, $enc); + $str = pack("c", $i); + $enc = base64_encode($str); + printf("0x%X: %s\n", $i, $enc); } echo "Done"; diff --git a/ext/standard/tests/url/base64_encode_basic_002.phpt b/ext/standard/tests/url/base64_encode_basic_002.phpt index 15bd9380b103..94af3c93bde1 100644 --- a/ext/standard/tests/url/base64_encode_basic_002.phpt +++ b/ext/standard/tests/url/base64_encode_basic_002.phpt @@ -15,29 +15,29 @@ Test base64_encode() function : basic functionality - check algorithm round trip echo "*** Testing base64_encode() : basic functionality ***\n"; $values = array( - "Hello World", - "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]", - "\n\t Line with control characters\r\n", - "\xC1\xC2\xC3\xC4\xC5\xC6", - "\75\76\77\78\79\80" + "Hello World", + "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]", + "\n\t Line with control characters\r\n", + "\xC1\xC2\xC3\xC4\xC5\xC6", + "\75\76\77\78\79\80" ); echo "\n--- Testing base64_encode() with binary string input ---\n"; $counter = 1; foreach($values as $str) { - echo "-- Iteration $counter --\n"; + echo "-- Iteration $counter --\n"; - $enc = base64_encode($str); - $dec = base64_decode($enc); + $enc = base64_encode($str); + $dec = base64_decode($enc); - if ($dec != $str) { - echo "TEST FAILED\n"; - } else { - echo "TEST PASSED\n"; - } + if ($dec != $str) { + echo "TEST FAILED\n"; + } else { + echo "TEST PASSED\n"; + } - $counter ++; + $counter ++; } ?> diff --git a/ext/standard/tests/url/bug52327.phpt b/ext/standard/tests/url/bug52327.phpt index fb2e0fa25bd6..3450abcc4bcd 100644 --- a/ext/standard/tests/url/bug52327.phpt +++ b/ext/standard/tests/url/bug52327.phpt @@ -3,8 +3,8 @@ Bug #52327 (base64_decode() improper handling of leading padding) --FILE-- --EXPECT-- diff --git a/ext/standard/tests/url/bug55273.phpt b/ext/standard/tests/url/bug55273.phpt index 1408506b4270..e5c8fca70c7e 100644 --- a/ext/standard/tests/url/bug55273.phpt +++ b/ext/standard/tests/url/bug55273.phpt @@ -3,9 +3,9 @@ Bug #55273 (base64_decode() with strict rejects whitespace after pad) --FILE-- $url: "; - var_dump(parse_url($url)); + echo "\n--> $url: "; + var_dump(parse_url($url)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_002.phpt b/ext/standard/tests/url/parse_url_basic_002.phpt index c8b94dec1c71..9616278fc639 100644 --- a/ext/standard/tests/url/parse_url_basic_002.phpt +++ b/ext/standard/tests/url/parse_url_basic_002.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_SCHEM include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_SCHEME)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_SCHEME)); } diff --git a/ext/standard/tests/url/parse_url_basic_003.phpt b/ext/standard/tests/url/parse_url_basic_003.phpt index f917b77b97f2..668ee5aab23a 100644 --- a/ext/standard/tests/url/parse_url_basic_003.phpt +++ b/ext/standard/tests/url/parse_url_basic_003.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_HOST include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_HOST)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_HOST)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_004.phpt b/ext/standard/tests/url/parse_url_basic_004.phpt index 29d465524354..464ed20d4232 100644 --- a/ext/standard/tests/url/parse_url_basic_004.phpt +++ b/ext/standard/tests/url/parse_url_basic_004.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PORT include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_PORT)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_PORT)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_005.phpt b/ext/standard/tests/url/parse_url_basic_005.phpt index 716d8d1dfac4..f77618198781 100644 --- a/ext/standard/tests/url/parse_url_basic_005.phpt +++ b/ext/standard/tests/url/parse_url_basic_005.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_USER include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_USER)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_USER)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_006.phpt b/ext/standard/tests/url/parse_url_basic_006.phpt index 3ae94ca626f0..fc6378106b2c 100644 --- a/ext/standard/tests/url/parse_url_basic_006.phpt +++ b/ext/standard/tests/url/parse_url_basic_006.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PASS include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_PASS)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_PASS)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_007.phpt b/ext/standard/tests/url/parse_url_basic_007.phpt index 8cad27e958b6..ebcd968879f9 100644 --- a/ext/standard/tests/url/parse_url_basic_007.phpt +++ b/ext/standard/tests/url/parse_url_basic_007.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PATH include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_PATH)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_PATH)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_008.phpt b/ext/standard/tests/url/parse_url_basic_008.phpt index 142da3d56180..033a4489d0f3 100644 --- a/ext/standard/tests/url/parse_url_basic_008.phpt +++ b/ext/standard/tests/url/parse_url_basic_008.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_QUERY include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_QUERY)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_QUERY)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_009.phpt b/ext/standard/tests/url/parse_url_basic_009.phpt index 3634046de26c..539d05bbd70f 100644 --- a/ext/standard/tests/url/parse_url_basic_009.phpt +++ b/ext/standard/tests/url/parse_url_basic_009.phpt @@ -14,8 +14,8 @@ Test parse_url() function: Parse a load of URLs without specifying PHP_URL_FRAGM include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "--> $url : "; - var_dump(parse_url($url, PHP_URL_FRAGMENT)); + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_FRAGMENT)); } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_basic_010.phpt b/ext/standard/tests/url/parse_url_basic_010.phpt index 8fecb9d8ebae..bf1835fbf8d7 100644 --- a/ext/standard/tests/url/parse_url_basic_010.phpt +++ b/ext/standard/tests/url/parse_url_basic_010.phpt @@ -12,9 +12,9 @@ Test parse_url() function : check values of URL related constants * check values of URL related constants */ foreach(get_defined_constants() as $constantName => $constantValue) { - if (strpos($constantName, 'PHP_URL')===0) { - echo "$constantName: $constantValue \n"; - } + if (strpos($constantName, 'PHP_URL')===0) { + echo "$constantName: $constantValue \n"; + } } echo "Done"; diff --git a/ext/standard/tests/url/parse_url_unterminated.phpt b/ext/standard/tests/url/parse_url_unterminated.phpt index 7a0cba8ada98..f7d5cca8965c 100644 --- a/ext/standard/tests/url/parse_url_unterminated.phpt +++ b/ext/standard/tests/url/parse_url_unterminated.phpt @@ -14,9 +14,9 @@ if (!function_exists('zend_create_unterminated_string')) die('skip ext/test requ include_once(__DIR__ . '/urls.inc'); foreach ($urls as $url) { - echo "\n--> $url: "; - $str = zend_create_unterminated_string($url); - var_dump(parse_url($str)); + echo "\n--> $url: "; + $str = zend_create_unterminated_string($url); + var_dump(parse_url($str)); zend_terminate_string($str); } diff --git a/ext/standard/tests/versioning/version_compare.phpt b/ext/standard/tests/versioning/version_compare.phpt index 17574e97370a..07550dd410f4 100644 --- a/ext/standard/tests/versioning/version_compare.phpt +++ b/ext/standard/tests/versioning/version_compare.phpt @@ -19,7 +19,7 @@ test("1.0", "1.1"); test("1.2", "1.0.1"); foreach ($special_forms as $f1) { foreach ($special_forms as $f2) { - test("1.0$f1", "1.0$f2"); + test("1.0$f1", "1.0$f2"); } } print "TESTING OPERATORS\n"; @@ -37,16 +37,16 @@ foreach ($special_forms as $f1) { function test($v1, $v2) { $compare = version_compare($v1, $v2); switch ($compare) { - case -1: - print "$v1 < $v2\n"; - break; - case 1: - print "$v1 > $v2\n"; - break; - case 0: - default: - print "$v1 = $v2\n"; - break; + case -1: + print "$v1 < $v2\n"; + break; + case 1: + print "$v1 > $v2\n"; + break; + case 0: + default: + print "$v1 = $v2\n"; + break; } } diff --git a/ext/sysvmsg/tests/001.phpt b/ext/sysvmsg/tests/001.phpt index 1e53f38f2050..3dc95f00b314 100644 --- a/ext/sysvmsg/tests/001.phpt +++ b/ext/sysvmsg/tests/001.phpt @@ -10,11 +10,11 @@ $q = msg_get_queue($key); msg_send($q, 1, "hello") or print "FAIL\n"; $type = null; if (msg_receive($q, 0, $type, 1024, $message)) { - echo "TYPE: $type\n"; - echo "DATA: $message\n"; + echo "TYPE: $type\n"; + echo "DATA: $message\n"; } if (!msg_remove_queue($q)) { - echo "BAD: queue removal failed\n"; + echo "BAD: queue removal failed\n"; } ?> --EXPECT-- diff --git a/ext/sysvmsg/tests/002.phpt b/ext/sysvmsg/tests/002.phpt index 82233a4755b2..ae85b4431a4d 100644 --- a/ext/sysvmsg/tests/002.phpt +++ b/ext/sysvmsg/tests/002.phpt @@ -7,12 +7,12 @@ msg_receive() should return false when unserialize() failed $queue = msg_get_queue (ftok(__FILE__, 'r'), 0600); if (!msg_send ($queue, 1, 'Hi', false /* ! no_ser*/, true/*block*/, $msg_err)) { - die("error\n"); + die("error\n"); } var_dump($res = msg_receive ($queue, 1, $msg_type, 16384, $msg, true, 0, $msg_error)); if (!msg_remove_queue($queue)) { - echo "BAD: queue removal failed\n"; + echo "BAD: queue removal failed\n"; } echo "Done\n"; diff --git a/ext/sysvmsg/tests/005.phpt b/ext/sysvmsg/tests/005.phpt index 506e383ba0d4..68323e9a308a 100644 --- a/ext/sysvmsg/tests/005.phpt +++ b/ext/sysvmsg/tests/005.phpt @@ -10,12 +10,12 @@ $tests = array(null, 'foo'); foreach ($tests as $q) { if ($q === null) { - do { - $id = ftok(__FILE__, chr(mt_rand(0, 255))); } while (msg_queue_exists($id)); + do { + $id = ftok(__FILE__, chr(mt_rand(0, 255))); } while (msg_queue_exists($id)); } - $q = msg_get_queue($id) or die("Failed to create queue"); - msg_remove_queue($q) or die("Failed to close queue"); + $q = msg_get_queue($id) or die("Failed to create queue"); + msg_remove_queue($q) or die("Failed to close queue"); echo "Using '$q' as queue resource:\n"; diff --git a/ext/sysvmsg/tests/006.phpt b/ext/sysvmsg/tests/006.phpt index 6982572640d0..fffb684221e4 100644 --- a/ext/sysvmsg/tests/006.phpt +++ b/ext/sysvmsg/tests/006.phpt @@ -21,7 +21,7 @@ foreach ($tests as $elem) { } if (!msg_remove_queue($queue)) { - echo "BAD: queue removal failed\n"; + echo "BAD: queue removal failed\n"; } echo "Done\n"; diff --git a/ext/sysvsem/tests/nowait.phpt b/ext/sysvsem/tests/nowait.phpt index 13f965ee216c..147b8da335f5 100644 --- a/ext/sysvsem/tests/nowait.phpt +++ b/ext/sysvsem/tests/nowait.phpt @@ -18,8 +18,8 @@ pcntl_signal(SIGCHLD, SIG_IGN); // Get semaphore for parent $p_sem_id = sem_get($P_SEMKEY, 1); if ($p_sem_id === FALSE) { - echo "P: failed to parent get semaphore\n"; - exit; + echo "P: failed to parent get semaphore\n"; + exit; } echo "P: got semaphore $p_sem_id.\n"; @@ -27,24 +27,24 @@ echo "P: got semaphore $p_sem_id.\n"; // Get semaphore for child $c_sem_id = sem_get($C_SEMKEY, 1); if ($c_sem_id === FALSE) { - echo "P: failed to child get semaphore\n"; - exit; + echo "P: failed to child get semaphore\n"; + exit; } // Acquire semaphore for parent if (!sem_acquire($p_sem_id)) { - echo "P: fail to acquire semaphore $p_sem_id.\n"; - sem_remove($p_sem_id); - exit; + echo "P: fail to acquire semaphore $p_sem_id.\n"; + sem_remove($p_sem_id); + exit; } echo "P: acquired semaphore $p_sem_id.\n"; // Acquire semaphore for child if (!sem_acquire($c_sem_id)) { - echo "P: fail to acquire semaphore $c_sem_id.\n"; - sem_remove($c_sem_id); - exit; + echo "P: fail to acquire semaphore $c_sem_id.\n"; + sem_remove($c_sem_id); + exit; } echo "P: acquired semaphore $c_sem_id\n"; // Fork process @@ -52,69 +52,69 @@ $pid = pcntl_fork(); if ($pid) { - register_shutdown_function(function () use ($p_sem_id) { - echo "P: removing semaphore $p_sem_id.\n"; - sem_remove($p_sem_id); - }); + register_shutdown_function(function () use ($p_sem_id) { + echo "P: removing semaphore $p_sem_id.\n"; + sem_remove($p_sem_id); + }); - // Release semaphore after 50ms - usleep(50000); + // Release semaphore after 50ms + usleep(50000); - /* Wait for the child semaphore to be released to - to release the parent semaphore */ - if (!sem_acquire($c_sem_id)) { - echo "P: failed to acquire semaphore $c_sem_id.\n"; - exit; - } + /* Wait for the child semaphore to be released to + to release the parent semaphore */ + if (!sem_acquire($c_sem_id)) { + echo "P: failed to acquire semaphore $c_sem_id.\n"; + exit; + } - /* Release the child semahpore before releasing - the releasing the parent semaphore and letting - the child continue execution */ - sem_release($c_sem_id); + /* Release the child semahpore before releasing + the releasing the parent semaphore and letting + the child continue execution */ + sem_release($c_sem_id); - echo "P: releasing semaphore $p_sem_id.\n"; - if (!sem_release($p_sem_id)) { - echo "P: failed to release semaphore\n"; - } + echo "P: releasing semaphore $p_sem_id.\n"; + if (!sem_release($p_sem_id)) { + echo "P: failed to release semaphore\n"; + } - $status = null; - pcntl_waitpid($pid, $status); + $status = null; + pcntl_waitpid($pid, $status); } else { - register_shutdown_function(function () use ($c_sem_id) { - echo "C: removing semaphore $c_sem_id.\n"; - sem_remove($c_sem_id); - }); + register_shutdown_function(function () use ($c_sem_id) { + echo "C: removing semaphore $c_sem_id.\n"; + sem_remove($c_sem_id); + }); - echo "C: child process running.\n"; + echo "C: child process running.\n"; - // Have the semaphore after process forked - echo "C: got semaphore $p_sem_id and $c_sem_id.\n"; + // Have the semaphore after process forked + echo "C: got semaphore $p_sem_id and $c_sem_id.\n"; - // This should fail to get to the semaphore and not wait - if (sem_acquire($p_sem_id, true)) { - echo "C: test failed, Child was able to acquire semaphore $p_sem_id.\n"; - exit; - } + // This should fail to get to the semaphore and not wait + if (sem_acquire($p_sem_id, true)) { + echo "C: test failed, Child was able to acquire semaphore $p_sem_id.\n"; + exit; + } - // The child process did not wait to acquire the semaphore - echo "C: failed to acquire semaphore $p_sem_id.\n"; + // The child process did not wait to acquire the semaphore + echo "C: failed to acquire semaphore $p_sem_id.\n"; - echo "C: releasing semaphore $c_sem_id\n"; - if (!sem_release($c_sem_id)) { - echo "C: Failed to release semaphore\n"; - } + echo "C: releasing semaphore $c_sem_id\n"; + if (!sem_release($c_sem_id)) { + echo "C: Failed to release semaphore\n"; + } - // Acquire semaphore with waiting - if (!sem_acquire($p_sem_id)) { - echo "C: fail to acquire semaphore $p_sem_id.\n"; - exit; - } - echo "C: success acquired semaphore $p_sem_id.\n"; + // Acquire semaphore with waiting + if (!sem_acquire($p_sem_id)) { + echo "C: fail to acquire semaphore $p_sem_id.\n"; + exit; + } + echo "C: success acquired semaphore $p_sem_id.\n"; - echo "C: releasing semaphore $p_sem_id.\n"; - sem_release($p_sem_id); + echo "C: releasing semaphore $p_sem_id.\n"; + sem_release($p_sem_id); } ?> diff --git a/ext/sysvsem/tests/sysv.phpt b/ext/sysvsem/tests/sysv.phpt index 3f485e2c0864..08cb63f83909 100644 --- a/ext/sysvsem/tests/sysv.phpt +++ b/ext/sysvsem/tests/sysv.phpt @@ -16,79 +16,79 @@ echo "Start.\n"; // Get semaphore $sem_id = sem_get($SEMKEY, 1); if ($sem_id === FALSE) { - echo "Fail to get semaphore"; - exit; + echo "Fail to get semaphore"; + exit; } echo "Got semaphore $sem_id.\n"; // Accuire semaphore if (! sem_acquire($sem_id)) { - echo "Fail to acquire semaphore $sem_id.\n"; - sem_remove($sem_id); - exit; + echo "Fail to acquire semaphore $sem_id.\n"; + sem_remove($sem_id); + exit; } echo "Success acquire semaphore $sem_id.\n"; $shm_id = shm_attach($SHMKEY, $MEMSIZE); if ($shm_id === FALSE) { - echo "Fail to attach shared memory.\n"; - sem_remove($sem_id); - exit; + echo "Fail to attach shared memory.\n"; + sem_remove($sem_id); + exit; } echo "Success to attach shared memory : $shm_id.\n"; // Write variable 1 if (!shm_put_var($shm_id, 1, "Variable 1")) { - echo "Fail to put var 1 on shared memory $shm_id.\n"; - sem_remove($sem_id); - shm_remove ($shm_id); - exit; + echo "Fail to put var 1 on shared memory $shm_id.\n"; + sem_remove($sem_id); + shm_remove ($shm_id); + exit; } echo "Write var1 to shared memory.\n"; // Write variable 2 if (!shm_put_var($shm_id, 2, "Variable 2")) { - echo "Fail to put var 2 on shared memory $shm_id.\n"; - sem_remove($sem_id); - shm_remove ($shm_id); - exit; + echo "Fail to put var 2 on shared memory $shm_id.\n"; + sem_remove($sem_id); + shm_remove ($shm_id); + exit; } echo "Write var2 to shared memory.\n"; // Read variable 1 $var1 = shm_get_var ($shm_id, 1); if ($var1 === FALSE) { - echo "Fail to retrieve Var 1 from Shared memory $shm_id, return value=$var1.\n"; + echo "Fail to retrieve Var 1 from Shared memory $shm_id, return value=$var1.\n"; } else { - echo "Read var1=$var1.\n"; + echo "Read var1=$var1.\n"; } // Read variable 1 $var2 = shm_get_var ($shm_id, 2); if ($var1 === FALSE) { - echo "Fail to retrieve Var 2 from Shared memory $shm_id, return value=$var2.\n"; + echo "Fail to retrieve Var 2 from Shared memory $shm_id, return value=$var2.\n"; } else { - echo "Read var2=$var2.\n"; + echo "Read var2=$var2.\n"; } // Release semaphore if (!sem_release($sem_id)) { - echo "Fail to release $sem_id semaphore.\n"; + echo "Fail to release $sem_id semaphore.\n"; } else { - echo "Semaphore $sem_id released.\n"; + echo "Semaphore $sem_id released.\n"; } // remove shared memory segmant from SysV if (shm_remove ($shm_id)) { - echo "Shared memory successfully removed from SysV.\n"; + echo "Shared memory successfully removed from SysV.\n"; } else { - echo "Fail to remove $shm_id shared memory from SysV.\n"; + echo "Fail to remove $shm_id shared memory from SysV.\n"; } // Remove semaphore if (sem_remove($sem_id)) { - echo "semaphore removed successfully from SysV.\n"; + echo "semaphore removed successfully from SysV.\n"; } else { - echo "Fail to remove $sem_id semaphore from SysV.\n"; + echo "Fail to remove $sem_id semaphore from SysV.\n"; } echo "End.\n"; /* NOTE: assigned semids differ depending on the kernel, since diff --git a/ext/tidy/tests/002.phpt b/ext/tidy/tests/002.phpt index c6092c7b9401..d276cfabed3a 100644 --- a/ext/tidy/tests/002.phpt +++ b/ext/tidy/tests/002.phpt @@ -4,8 +4,8 @@ tidy_parse_string() --FILE-- "); - echo tidy_get_output($a); + $a = tidy_parse_string(""); + echo tidy_get_output($a); ?> --EXPECT-- diff --git a/ext/tidy/tests/003.phpt b/ext/tidy/tests/003.phpt index df4cd18f5f60..43bd6729d779 100644 --- a/ext/tidy/tests/003.phpt +++ b/ext/tidy/tests/003.phpt @@ -5,9 +5,9 @@ tidy_clean_repair() --FILE-- "); - tidy_clean_repair($a); - echo tidy_get_output($a); + $a = tidy_parse_string(""); + tidy_clean_repair($a); + echo tidy_get_output($a); ?> --EXPECTF-- diff --git a/ext/tidy/tests/005-mb.phpt b/ext/tidy/tests/005-mb.phpt index c7b8e20676df..7fc43d9f27b9 100644 --- a/ext/tidy/tests/005-mb.phpt +++ b/ext/tidy/tests/005-mb.phpt @@ -4,8 +4,8 @@ tidy_parse_file() --FILE-- --EXPECT-- diff --git a/ext/tidy/tests/005.phpt b/ext/tidy/tests/005.phpt index 49b0a2ad4dd1..88d906e8962b 100644 --- a/ext/tidy/tests/005.phpt +++ b/ext/tidy/tests/005.phpt @@ -4,8 +4,8 @@ tidy_parse_file() --FILE-- --EXPECT-- diff --git a/ext/tidy/tests/006.phpt b/ext/tidy/tests/006.phpt index a36006f3462f..5ca856075dff 100644 --- a/ext/tidy/tests/006.phpt +++ b/ext/tidy/tests/006.phpt @@ -4,8 +4,8 @@ Verbose tidy_get_error_buffer() --FILE-- "); - echo tidy_get_error_buffer($a); + $a = tidy_parse_string(""); + echo tidy_get_error_buffer($a); ?> --EXPECT-- diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt index bae8918625a7..127dcdf4724d 100644 --- a/ext/tidy/tests/007.phpt +++ b/ext/tidy/tests/007.phpt @@ -6,16 +6,16 @@ Verbose tidy_getopt() tidy.default_config= --FILE-- getopt("tidy-mark")); - echo "Current Value of 'error-file': "; - var_dump($a->getopt("error-file")); - echo "Current Value of 'tab-size': "; - var_dump($a->getopt("tab-size")); + $a = new tidy(__DIR__."/007.html"); + echo "Current Value of 'tidy-mark': "; + var_dump($a->getopt("tidy-mark")); + echo "Current Value of 'error-file': "; + var_dump($a->getopt("error-file")); + echo "Current Value of 'tab-size': "; + var_dump($a->getopt("tab-size")); - var_dump($a->getopt('bogus-opt')); - var_dump(tidy_getopt($a, 'non-ASCII string àáç')); + var_dump($a->getopt('bogus-opt')); + var_dump(tidy_getopt($a, 'non-ASCII string àáç')); ?> --EXPECTF-- Current Value of 'tidy-mark': bool(false) diff --git a/ext/tidy/tests/008.phpt b/ext/tidy/tests/008.phpt index 303a2f9d8a4c..f98f79954e4f 100644 --- a/ext/tidy/tests/008.phpt +++ b/ext/tidy/tests/008.phpt @@ -4,8 +4,8 @@ Accessing the error buffer via $obj->error_buf... --FILE-- "); - echo $a->errorBuffer; + $a = tidy_parse_string(""); + echo $a->errorBuffer; ?> --EXPECT-- line 1 column 1 - Warning: missing declaration diff --git a/ext/tidy/tests/009.phpt b/ext/tidy/tests/009.phpt index c2bbfb9760d8..b3e04d805fe4 100644 --- a/ext/tidy/tests/009.phpt +++ b/ext/tidy/tests/009.phpt @@ -6,7 +6,7 @@ tidy_doc object overloading "); - echo $a; + echo $a; ?> --EXPECT-- diff --git a/ext/tidy/tests/011.phpt b/ext/tidy/tests/011.phpt index 56cb0aa89378..f664f69ebf5f 100644 --- a/ext/tidy/tests/011.phpt +++ b/ext/tidy/tests/011.phpt @@ -4,7 +4,7 @@ Accessing attributes of a node --FILE-- "); + $a = tidy_parse_string(""); $body = $a->body(); var_dump($body->attribute); foreach($body->attribute as $key=>$val) { diff --git a/ext/tidy/tests/012.phpt b/ext/tidy/tests/012.phpt index eae6eca44c97..0cfa3ef8c6c0 100644 --- a/ext/tidy/tests/012.phpt +++ b/ext/tidy/tests/012.phpt @@ -25,7 +25,7 @@ Accessing children nodes } - $a = tidy_parse_string("HiByeTest", array('newline' => 'LF')); + $a = tidy_parse_string("HiByeTest", array('newline' => 'LF')); $html = $a->html(); dump_nodes($html); diff --git a/ext/tidy/tests/014.phpt b/ext/tidy/tests/014.phpt index fd0d55b1fbe6..70f85eae379d 100644 --- a/ext/tidy/tests/014.phpt +++ b/ext/tidy/tests/014.phpt @@ -5,9 +5,9 @@ Passing configuration options through tidy_parse_string(). --FILE-- testing"; - $tidy = tidy_parse_string($text, array('show-body-only'=>true)); - tidy_clean_repair($tidy); - echo tidy_get_output($tidy); + $tidy = tidy_parse_string($text, array('show-body-only'=>true)); + tidy_clean_repair($tidy); + echo tidy_get_output($tidy); ?> --EXPECT-- diff --git a/ext/tidy/tests/015.phpt b/ext/tidy/tests/015.phpt index c5bc1dc4d360..ca00b5cb4de8 100644 --- a/ext/tidy/tests/015.phpt +++ b/ext/tidy/tests/015.phpt @@ -5,8 +5,8 @@ Passing configuration options through tidy_parse_file(). --FILE-- true)); - tidy_clean_repair($tidy); - echo tidy_get_output($tidy); + tidy_clean_repair($tidy); + echo tidy_get_output($tidy); ?> --EXPECT-- diff --git a/ext/tidy/tests/018.phpt b/ext/tidy/tests/018.phpt index d2f1d1e0f3f6..761257e72094 100644 --- a/ext/tidy/tests/018.phpt +++ b/ext/tidy/tests/018.phpt @@ -5,10 +5,10 @@ binary safety --FILE-- abra\0cadabra

                  ", - array( 'show-body-only' => true, - 'clean' => false, - 'newline' => "\n") - ); + array( 'show-body-only' => true, + 'clean' => false, + 'newline' => "\n") + ); var_dump($x); ?> --EXPECT-- diff --git a/ext/tidy/tests/029.phpt b/ext/tidy/tests/029.phpt index e46181f005ba..f28f52fba871 100644 --- a/ext/tidy/tests/029.phpt +++ b/ext/tidy/tests/029.phpt @@ -8,16 +8,16 @@ tidy_get_body() crash // bug report taken from http://news.php.net/php.notes/130628 $inputs = array( - ' ', - ' ', + ' cleanRepair(); - var_dump(tidy_get_body($t)); + $t = tidy_parse_string($input); + $t->cleanRepair(); + var_dump(tidy_get_body($t)); } echo "Done\n"; diff --git a/ext/tokenizer/tests/002.phpt b/ext/tokenizer/tests/002.phpt index 11b6d9f78eae..e711023eeffd 100644 --- a/ext/tokenizer/tests/002.phpt +++ b/ext/tokenizer/tests/002.phpt @@ -6,15 +6,15 @@ token_get_all() ', - '', - '', - /* feel free to add more yourself */ - 'wrong syntax here' + '', + '', + '', + /* feel free to add more yourself */ + 'wrong syntax here' ); foreach ($strings as $s) { - var_dump(token_get_all($s)); + var_dump(token_get_all($s)); } echo "Done\n"; diff --git a/ext/tokenizer/tests/bug54089.phpt b/ext/tokenizer/tests/bug54089.phpt index ff461ecb788f..d3dc834616ac 100644 --- a/ext/tokenizer/tests/bug54089.phpt +++ b/ext/tokenizer/tests/bug54089.phpt @@ -5,23 +5,23 @@ Bug #54089 (token_get_all() does not stop after __halt_compiler) --FILE-- diff --git a/ext/tokenizer/tests/token_get_all_variation19.phpt b/ext/tokenizer/tests/token_get_all_variation19.phpt index a853dd2e2fc5..3190b3fd16e2 100644 --- a/ext/tokenizer/tests/token_get_all_variation19.phpt +++ b/ext/tokenizer/tests/token_get_all_variation19.phpt @@ -35,17 +35,17 @@ $token_array = token_get_all($phpstr); $script = ""; // reconstruct a script (without open/close tags) from the token array foreach ($token_array as $token) { - if (is_array($token)) { - if (strncmp($token[1], '', 2) == 0) { - continue; - } - $script .= $token[1]; - } else { - $script .= $token; - } + if (is_array($token)) { + if (strncmp($token[1], '', 2) == 0) { + continue; + } + $script .= $token[1]; + } else { + $script .= $token; + } } var_dump($script); diff --git a/ext/xml/tests/bug25666.phpt b/ext/xml/tests/bug25666.phpt index e162d5a2bd58..ca4b15f405dd 100644 --- a/ext/xml/tests/bug25666.phpt +++ b/ext/xml/tests/bug25666.phpt @@ -8,7 +8,7 @@ if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is n --FILE-- + xmlns:baz="http://example.com/baz"> diff --git a/ext/xml/tests/bug26528.phpt b/ext/xml/tests/bug26528.phpt index 96da841004cb..152a18540d9d 100644 --- a/ext/xml/tests/bug26528.phpt +++ b/ext/xml/tests/bug26528.phpt @@ -6,11 +6,11 @@ require_once("skipif.inc"); ?> --FILE-- "; - $parser = xml_parser_create(); - $res = xml_parse_into_struct($parser,$sample,$vals,$index); - xml_parser_free($parser); - var_dump($vals); + $sample = ""; + $parser = xml_parser_create(); + $res = xml_parse_into_struct($parser,$sample,$vals,$index); + xml_parser_free($parser); + var_dump($vals); ?> --EXPECT-- array(1) { diff --git a/ext/xml/tests/bug26614.phpt b/ext/xml/tests/bug26614.phpt index c95997a8a6c7..ed42bc1fbf3b 100644 --- a/ext/xml/tests/bug26614.phpt +++ b/ext/xml/tests/bug26614.phpt @@ -25,7 +25,7 @@ $xmls["CDATA"] =' @@ -36,7 +36,7 @@ $xmls["Comment"] =' @@ -47,7 +47,7 @@ $xmls["Text"] =' -!-- ATA[ multi -line +line CDATA block --- @@ -55,16 +55,16 @@ block function startElement($parser, $name, $attrs) { printf("<$name> at line %d, col %d (byte %d)\n", - xml_get_current_line_number($parser), - xml_get_current_column_number($parser), - xml_get_current_byte_index($parser)); + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); } function endElement($parser, $name) { printf(" at line %d, col %d (byte %d)\n", - xml_get_current_line_number($parser), - xml_get_current_column_number($parser), - xml_get_current_byte_index($parser)); + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); } function characterData($parser, $data) { @@ -73,12 +73,12 @@ function characterData($parser, $data) { foreach ($xmls as $desc => $xml) { echo "$desc\n"; - $xml_parser = xml_parser_create(); - xml_set_element_handler($xml_parser, "startElement", "endElement"); - xml_set_character_data_handler($xml_parser, "characterData"); - if (!xml_parse($xml_parser, $xml, true)) - echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; - xml_parser_free($xml_parser); + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + if (!xml_parse($xml_parser, $xml, true)) + echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; + xml_parser_free($xml_parser); } ?> --EXPECT-- diff --git a/ext/xml/tests/bug26614_libxml.phpt b/ext/xml/tests/bug26614_libxml.phpt index e479699a8f86..b6c0b875818b 100644 --- a/ext/xml/tests/bug26614_libxml.phpt +++ b/ext/xml/tests/bug26614_libxml.phpt @@ -55,16 +55,16 @@ block function startElement($parser, $name, $attrs) { printf("<$name> at line %d, col %d (byte %d)\n", - xml_get_current_line_number($parser), - xml_get_current_column_number($parser), - xml_get_current_byte_index($parser)); + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); } function endElement($parser, $name) { printf(" at line %d, col %d (byte %d)\n", - xml_get_current_line_number($parser), - xml_get_current_column_number($parser), - xml_get_current_byte_index($parser)); + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); } function characterData($parser, $data) { @@ -73,12 +73,12 @@ function characterData($parser, $data) { foreach ($xmls as $desc => $xml) { echo "$desc\n"; - $xml_parser = xml_parser_create(); - xml_set_element_handler($xml_parser, "startElement", "endElement"); - xml_set_character_data_handler($xml_parser, "characterData"); - if (!xml_parse($xml_parser, $xml, true)) - echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; - xml_parser_free($xml_parser); + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + if (!xml_parse($xml_parser, $xml, true)) + echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; + xml_parser_free($xml_parser); } ?> --EXPECTF-- diff --git a/ext/xml/tests/bug30266.phpt b/ext/xml/tests/bug30266.phpt index 2cf0a68cde98..a7fe7592fe8b 100644 --- a/ext/xml/tests/bug30266.phpt +++ b/ext/xml/tests/bug30266.phpt @@ -33,7 +33,7 @@ class XML_Parser function startHandler($XmlParser, $tag, $attr) { $this->dummy = "b"; - throw new Exception("ex"); + throw new Exception("ex"); } function endHandler($XmlParser, $tag) @@ -45,7 +45,7 @@ $p1 = new Xml_Parser(); try { $p1->parse(''); } catch (Exception $e) { - echo "OK\n"; + echo "OK\n"; } ?> --EXPECT-- diff --git a/ext/xml/tests/bug32001.phpt b/ext/xml/tests/bug32001.phpt index 2e2f4643d550..5ced12894020 100644 --- a/ext/xml/tests/bug32001.phpt +++ b/ext/xml/tests/bug32001.phpt @@ -10,146 +10,146 @@ if (ICONV_IMPL == 'glibc' && version_compare(ICONV_VERSION, '2.12', '<=')) --FILE-- encoding = $enc; - $this->chunk_size = $chunk_size; - $this->bom = $bom; - $this->prologue = !$omit_prologue; - $this->tags = array(); - } + function __construct($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) { + $this->encoding = $enc; + $this->chunk_size = $chunk_size; + $this->bom = $bom; + $this->prologue = !$omit_prologue; + $this->tags = array(); + } - function start_element($parser, $name, $attrs) { - $attrs = array_map('bin2hex', $attrs); - $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); - } + function start_element($parser, $name, $attrs) { + $attrs = array_map('bin2hex', $attrs); + $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); + } - function end_element($parser, $name) { - } + function end_element($parser, $name) { + } - function run() { - $data = ''; + function run() { + $data = ''; - if ($this->prologue) { - $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); - $data .= "\n"; - } + if ($this->prologue) { + $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); + $data .= "\n"; + } - $data .= << <テスト:テスト2 テスト="テスト"> - <テスト:テスト3> - test! - + <テスト:テスト3> + test! + HERE; - $data = iconv("UTF-8", $this->encoding, $data); + $data = iconv("UTF-8", $this->encoding, $data); - if ($this->bom) { - switch (strtoupper($this->encoding)) { - case 'UTF-8': - case 'UTF8': - $data = "\xef\xbb\xbf".$data; - break; + if ($this->bom) { + switch (strtoupper($this->encoding)) { + case 'UTF-8': + case 'UTF8': + $data = "\xef\xbb\xbf".$data; + break; - case 'UTF-16': - case 'UTF16': - case 'UTF-16BE': - case 'UTF16BE': - case 'UCS-2': - case 'UCS2': - case 'UCS-2BE': - case 'UCS2BE': - $data = "\xfe\xff".$data; - break; + case 'UTF-16': + case 'UTF16': + case 'UTF-16BE': + case 'UTF16BE': + case 'UCS-2': + case 'UCS2': + case 'UCS-2BE': + case 'UCS2BE': + $data = "\xfe\xff".$data; + break; - case 'UTF-16LE': - case 'UTF16LE': - case 'UCS-2LE': - case 'UCS2LE': - $data = "\xff\xfe".$data; - break; + case 'UTF-16LE': + case 'UTF16LE': + case 'UCS-2LE': + case 'UCS2LE': + $data = "\xff\xfe".$data; + break; - case 'UTF-32': - case 'UTF32': - case 'UTF-32BE': - case 'UTF32BE': - case 'UCS-4': - case 'UCS4': - case 'UCS-4BE': - case 'UCS4BE': - $data = "\x00\x00\xfe\xff".$data; - break; + case 'UTF-32': + case 'UTF32': + case 'UTF-32BE': + case 'UTF32BE': + case 'UCS-4': + case 'UCS4': + case 'UCS-4BE': + case 'UCS4BE': + $data = "\x00\x00\xfe\xff".$data; + break; - case 'UTF-32LE': - case 'UTF32LE': - case 'UCS-4LE': - case 'UCS4LE': - $data = "\xff\xfe\x00\x00".$data; - break; - } - } + case 'UTF-32LE': + case 'UTF32LE': + case 'UCS-4LE': + case 'UCS4LE': + $data = "\xff\xfe\x00\x00".$data; + break; + } + } - $parser = xml_parser_create(NULL); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_element_handler($parser, "start_element", "end_element"); - xml_set_object($parser, $this); + $parser = xml_parser_create(NULL); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_set_object($parser, $this); - if ($this->chunk_size == 0) { - $success = @xml_parse($parser, $data, true); - } else { - for ($offset = 0; $offset < strlen($data); - $offset += $this->chunk_size) { - $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); - if (!$success) { - break; - } - } - if ($success) { - $success = @xml_parse($parser, "", true); - } - } + if ($this->chunk_size == 0) { + $success = @xml_parse($parser, $data, true); + } else { + for ($offset = 0; $offset < strlen($data); + $offset += $this->chunk_size) { + $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); + if (!$success) { + break; + } + } + if ($success) { + $success = @xml_parse($parser, "", true); + } + } - echo "Encoding: $this->encoding\n"; - echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; - echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); - echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; + echo "Encoding: $this->encoding\n"; + echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; + echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); + echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; - if ($success) { - var_dump($this->tags); - } else { - echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; - } - } + if ($success) { + var_dump($this->tags); + } else { + echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; + } + } } $suite = array( - new testcase("UTF-8", 0, 0, 0), - new testcase("UTF-8", 0, 0, 1), - new testcase("UTF-8", 0, 1, 0), - new testcase("UTF-8", 0, 1, 1), - new testcase("UTF-16BE", 0, 0, 0), - new testcase("UTF-16BE", 0, 1, 0), - new testcase("UTF-16BE", 0, 1, 1), - new testcase("UTF-16LE", 0, 0, 0), - new testcase("UTF-16LE", 0, 1, 0), - new testcase("UTF-16LE", 0, 1, 1), - new testcase("UTF-8", 1, 0, 0), - new testcase("UTF-8", 1, 0, 1), - new testcase("UTF-8", 1, 1, 0), - new testcase("UTF-8", 1, 1, 1), - new testcase("UTF-16BE", 1, 0, 0), - new testcase("UTF-16BE", 1, 1, 0), - new testcase("UTF-16BE", 1, 1, 1), - new testcase("UTF-16LE", 1, 0, 0), - new testcase("UTF-16LE", 1, 1, 0), - new testcase("UTF-16LE", 1, 1, 1), + new testcase("UTF-8", 0, 0, 0), + new testcase("UTF-8", 0, 0, 1), + new testcase("UTF-8", 0, 1, 0), + new testcase("UTF-8", 0, 1, 1), + new testcase("UTF-16BE", 0, 0, 0), + new testcase("UTF-16BE", 0, 1, 0), + new testcase("UTF-16BE", 0, 1, 1), + new testcase("UTF-16LE", 0, 0, 0), + new testcase("UTF-16LE", 0, 1, 0), + new testcase("UTF-16LE", 0, 1, 1), + new testcase("UTF-8", 1, 0, 0), + new testcase("UTF-8", 1, 0, 1), + new testcase("UTF-8", 1, 1, 0), + new testcase("UTF-8", 1, 1, 1), + new testcase("UTF-16BE", 1, 0, 0), + new testcase("UTF-16BE", 1, 1, 0), + new testcase("UTF-16BE", 1, 1, 1), + new testcase("UTF-16LE", 1, 0, 0), + new testcase("UTF-16LE", 1, 1, 0), + new testcase("UTF-16LE", 1, 1, 1), ); if (XML_SAX_IMPL == 'libxml') { @@ -159,7 +159,7 @@ if (XML_SAX_IMPL == 'libxml') { } foreach ($suite as $testcase) { - $testcase->run(); + $testcase->run(); } ?> diff --git a/ext/xml/tests/bug32001b.phpt b/ext/xml/tests/bug32001b.phpt index 3a3c11a3ba86..a7762fffca90 100644 --- a/ext/xml/tests/bug32001b.phpt +++ b/ext/xml/tests/bug32001b.phpt @@ -11,87 +11,87 @@ foreach(array('EUC-JP', 'Shift_JISP', 'GB2312') as $encoding) { --FILE-- encoding = $enc; - $this->chunk_size = $chunk_size; - $this->bom = $bom; - $this->prologue = !$omit_prologue; - $this->tags = array(); - } + function testcase($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) { + $this->encoding = $enc; + $this->chunk_size = $chunk_size; + $this->bom = $bom; + $this->prologue = !$omit_prologue; + $this->tags = array(); + } - function start_element($parser, $name, $attrs) { - $attrs = array_map('bin2hex', $attrs); - $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); - } + function start_element($parser, $name, $attrs) { + $attrs = array_map('bin2hex', $attrs); + $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); + } - function end_element($parser, $name) { - } + function end_element($parser, $name) { + } - function run() { - $data = ''; + function run() { + $data = ''; - if ($this->prologue) { - $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); - $data .= "\n"; - } + if ($this->prologue) { + $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); + $data .= "\n"; + } - $data .= << <テスト:テスト2 テスト="テスト"> - <テスト:テスト3> - test! - + <テスト:テスト3> + test! + HERE; - $data = iconv("UTF-8", $this->encoding, $data); + $data = iconv("UTF-8", $this->encoding, $data); - $parser = xml_parser_create(NULL); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_element_handler($parser, "start_element", "end_element"); - xml_set_object($parser, $this); + $parser = xml_parser_create(NULL); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_set_object($parser, $this); - if ($this->chunk_size == 0) { - $success = @xml_parse($parser, $data, true); - } else { - for ($offset = 0; $offset < strlen($data); - $offset += $this->chunk_size) { - $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); - if (!$success) { - break; - } - } - if ($success) { - $success = @xml_parse($parser, "", true); - } - } + if ($this->chunk_size == 0) { + $success = @xml_parse($parser, $data, true); + } else { + for ($offset = 0; $offset < strlen($data); + $offset += $this->chunk_size) { + $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); + if (!$success) { + break; + } + } + if ($success) { + $success = @xml_parse($parser, "", true); + } + } - echo "Encoding: $this->encoding\n"; - echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; - echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); - echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; + echo "Encoding: $this->encoding\n"; + echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; + echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); + echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; - if ($success) { - var_dump($this->tags); - } else { - echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; - } - } + if ($success) { + var_dump($this->tags); + } else { + echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; + } + } } $suite = array( - new testcase("EUC-JP" , 0), - new testcase("EUC-JP" , 1), - new testcase("Shift_JIS", 0), - new testcase("Shift_JIS", 1), - new testcase("GB2312", 0), - new testcase("GB2312", 1), + new testcase("EUC-JP" , 0), + new testcase("EUC-JP" , 1), + new testcase("Shift_JIS", 0), + new testcase("Shift_JIS", 1), + new testcase("GB2312", 0), + new testcase("GB2312", 1), ); if (XML_SAX_IMPL == 'libxml') { @@ -101,7 +101,7 @@ if (XML_SAX_IMPL == 'libxml') { } foreach ($suite as $testcase) { - $testcase->run(); + $testcase->run(); } ?> diff --git a/ext/xml/tests/bug76874.phpt b/ext/xml/tests/bug76874.phpt index c4377f0b8824..ec0caae706ad 100644 --- a/ext/xml/tests/bug76874.phpt +++ b/ext/xml/tests/bug76874.phpt @@ -7,19 +7,19 @@ Bug #76874: xml_parser_free() should never leak memory class c { - private $xml; - private $test; + private $xml; + private $test; - public function test() - { - $this->xml = xml_parser_create(); - xml_set_character_data_handler($this->xml, array(&$this, 'handle_cdata')); - xml_parser_free($this->xml); - } + public function test() + { + $this->xml = xml_parser_create(); + xml_set_character_data_handler($this->xml, array(&$this, 'handle_cdata')); + xml_parser_free($this->xml); + } - public function handle_cdata(&$parser, $data) - { - } + public function handle_cdata(&$parser, $data) + { + } } $object = new c(); diff --git a/ext/xml/tests/xml001.phpt b/ext/xml/tests/xml001.phpt index e859a4bbcbd7..2d8fe54041e8 100644 --- a/ext/xml/tests/xml001.phpt +++ b/ext/xml/tests/xml001.phpt @@ -22,54 +22,54 @@ if (!($fp = @fopen("xmltest.xml", "r"))) { } while ($data = fread($fp, 4096)) { - if (!xml_parse($xml_parser, $data, feof($fp))) { - die(sprintf("XML error: %s at line %d\n", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser))); - } + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } } print "parse complete\n"; xml_parser_free($xml_parser); function startElement($parser, $name, $attribs) { - print '{'.$name; - if (sizeof($attribs)) { + print '{'.$name; + if (sizeof($attribs)) { foreach ($attribs as $k => $v) { - print " $k=\"$v\""; - } - } - print '}'; + print " $k=\"$v\""; + } + } + print '}'; } function endElement($parser, $name) { - print '{/'.$name.'}'; + print '{/'.$name.'}'; } function characterData($parser, $data) { - print '{CDATA['.$data.']}'; + print '{CDATA['.$data.']}'; } function PIHandler($parser, $target, $data) { - print '{PI['.$target.','.$data.']}'; + print '{PI['.$target.','.$data.']}'; } function defaultHandler($parser, $data) { - if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - print '{ENTREF['.$data.']}'; - } else { - print '{?['.$data.']}'; - } + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + print '{ENTREF['.$data.']}'; + } else { + print '{?['.$data.']}'; + } } function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) { - print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; - return true; + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; + return true; } ?> diff --git a/ext/xml/tests/xml002.phpt b/ext/xml/tests/xml002.phpt index e183fa4ae35f..27a920cedd84 100644 --- a/ext/xml/tests/xml002.phpt +++ b/ext/xml/tests/xml002.phpt @@ -11,41 +11,41 @@ chdir(__DIR__); class myclass { - function startElement($parser, $name, $attribs) - { - print '{'.$name; - if (sizeof($attribs)) { + function startElement($parser, $name, $attribs) + { + print '{'.$name; + if (sizeof($attribs)) { foreach ($attribs as $k => $v) { - print " $k=\"$v\""; - } - } - print '}'; - } - function endElement($parser, $name) - { - print '{/'.$name.'}'; - } - function characterData($parser, $data) - { - print '{CDATA['.$data.']}'; - } - function PIHandler($parser, $target, $data) - { - print '{PI['.$target.','.$data.']}'; - } - function defaultHandler($parser, $data) - { - if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - print '{ENTREF['.$data.']}'; - } else { - print '{?['.$data.']}'; - } - } - function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) - { - print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; - return true; - } + print " $k=\"$v\""; + } + } + print '}'; + } + function endElement($parser, $name) + { + print '{/'.$name.'}'; + } + function characterData($parser, $data) + { + print '{CDATA['.$data.']}'; + } + function PIHandler($parser, $target, $data) + { + print '{PI['.$target.','.$data.']}'; + } + function defaultHandler($parser, $data) + { + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + print '{ENTREF['.$data.']}'; + } else { + print '{?['.$data.']}'; + } + } + function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) + { + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; + return true; + } } $xml_parser = xml_parser_create(); @@ -60,15 +60,15 @@ xml_set_external_entity_ref_handler($xml_parser, array($obj, "externalEntityRefHandler")); if (!($fp = @fopen("xmltest.xml", "r"))) { - die("could not open XML input"); + die("could not open XML input"); } while ($data = fread($fp, 4096)) { - if (!xml_parse($xml_parser, $data, feof($fp))) { - die(sprintf("XML error: %s at line %d\n", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser))); - } + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } } print "parse complete\n"; xml_parser_free($xml_parser); diff --git a/ext/xml/tests/xml003.phpt b/ext/xml/tests/xml003.phpt index fb4cbbd29e77..08db287c18bd 100644 --- a/ext/xml/tests/xml003.phpt +++ b/ext/xml/tests/xml003.phpt @@ -11,41 +11,41 @@ chdir(__DIR__); class myclass { - function startElement($parser, $name, $attribs) - { - print '{'.$name; - if (sizeof($attribs)) { + function startElement($parser, $name, $attribs) + { + print '{'.$name; + if (sizeof($attribs)) { foreach ($attribs as $k => $v) { - print " $k=\"$v\""; - } - } - print '}'; - } - function endElement($parser, $name) - { - print '{/'.$name.'}'; - } - function characterData($parser, $data) - { - print '{CDATA['.$data.']}'; - } - function PIHandler($parser, $target, $data) - { - print '{PI['.$target.','.$data.']}'; - } - function defaultHandler($parser, $data) - { - if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - print '{ENTREF['.$data.']}'; - } else { - print '{?['.$data.']}'; - } - } - function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) - { - print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; - return true; - } + print " $k=\"$v\""; + } + } + print '}'; + } + function endElement($parser, $name) + { + print '{/'.$name.'}'; + } + function characterData($parser, $data) + { + print '{CDATA['.$data.']}'; + } + function PIHandler($parser, $target, $data) + { + print '{PI['.$target.','.$data.']}'; + } + function defaultHandler($parser, $data) + { + if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { + print '{ENTREF['.$data.']}'; + } else { + print '{?['.$data.']}'; + } + } + function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) + { + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; + return true; + } } $xml_parser = xml_parser_create(); @@ -59,15 +59,15 @@ xml_set_default_handler($xml_parser, "defaultHandler"); xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler"); if (!($fp = @fopen("xmltest.xml", "r"))) { - die("could not open XML input"); + die("could not open XML input"); } while ($data = fread($fp, 4096)) { - if (!xml_parse($xml_parser, $data, feof($fp))) { - die(sprintf("XML error: %s at line %d\n", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser))); - } + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } } print "parse complete\n"; xml_parser_free($xml_parser); diff --git a/ext/xml/tests/xml004.phpt b/ext/xml/tests/xml004.phpt index 1e545db2a1be..3d5adaa56b7a 100644 --- a/ext/xml/tests/xml004.phpt +++ b/ext/xml/tests/xml004.phpt @@ -11,7 +11,7 @@ xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler($xp, "start_element", "end_element"); $fp = fopen("xmltest.xml", "r"); while ($data = fread($fp, 4096)) { - xml_parse($xp, $data, feof($fp)); + xml_parse($xp, $data, feof($fp)); } xml_parser_free($xp); $xp = xml_parser_create(); @@ -19,24 +19,24 @@ xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($xp, "start_element", "end_element"); $fp = fopen("xmltest.xml", "r"); while ($data = fread($fp, 4096)) { - xml_parse($xp, $data, feof($fp)); + xml_parse($xp, $data, feof($fp)); } xml_parser_free($xp); function start_element($xp, $elem, $attribs) { - print "<$elem"; - if (sizeof($attribs)) { + print "<$elem"; + if (sizeof($attribs)) { foreach ($attribs as $k => $v) { - print " $k=\"$v\""; - } - } - print ">\n"; + print " $k=\"$v\""; + } + } + print ">\n"; } function end_element($xp, $elem) { - print "\n"; + print "\n"; } ?> --EXPECT-- diff --git a/ext/xml/tests/xml007.phpt b/ext/xml/tests/xml007.phpt index f19f0389b685..5b76dfc848c1 100644 --- a/ext/xml/tests/xml007.phpt +++ b/ext/xml/tests/xml007.phpt @@ -12,12 +12,12 @@ if(strtoupper(" <äöü üäß="Üäß">ÄÖÜ'; diff --git a/ext/xml/tests/xml009.phpt b/ext/xml/tests/xml009.phpt index 7143a9faf71f..8a33a4e715a7 100644 --- a/ext/xml/tests/xml009.phpt +++ b/ext/xml/tests/xml009.phpt @@ -8,7 +8,7 @@ if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is n --FILE-- + xmlns:baz="http://example.com/baz"> diff --git a/ext/xml/tests/xml010.phpt b/ext/xml/tests/xml010.phpt index e4b4dd652020..69e8469fa66b 100644 --- a/ext/xml/tests/xml010.phpt +++ b/ext/xml/tests/xml010.phpt @@ -8,7 +8,7 @@ if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is n --FILE-- $value) { print "$key = $value "; diff --git a/ext/xml/tests/xml_closures_001.phpt b/ext/xml/tests/xml_closures_001.phpt index da9d849da545..c1f91d50d532 100644 --- a/ext/xml/tests/xml_closures_001.phpt +++ b/ext/xml/tests/xml_closures_001.phpt @@ -8,18 +8,18 @@ chdir(__DIR__); $start_element = function ($xp, $elem, $attribs) { - print "<$elem"; - if (sizeof($attribs)) { + print "<$elem"; + if (sizeof($attribs)) { foreach ($attribs as $k => $v) { - print " $k=\"$v\""; - } - } - print ">\n"; + print " $k=\"$v\""; + } + } + print ">\n"; }; $end_element = function ($xp, $elem) { - print "\n"; + print "\n"; }; $xp = xml_parser_create(); @@ -27,7 +27,7 @@ xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler($xp, $start_element, $end_element); $fp = fopen("xmltest.xml", "r"); while ($data = fread($fp, 4096)) { - xml_parse($xp, $data, feof($fp)); + xml_parse($xp, $data, feof($fp)); } xml_parser_free($xp); diff --git a/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt b/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt index a4ea86375e79..c7b8b0904902 100644 --- a/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt +++ b/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt @@ -18,23 +18,23 @@ class XML_Parser { function unparsed_entity_decl_handler($parser, $entity_name, $base, $system_ID, $public_ID, $notation_name) - { - echo "unparsed_entity_decl_handler called\n"; - echo "...Entity name=" . $entity_name . "\n"; - echo "...Base=" . $base . "\n"; - echo "...System ID=" . $system_ID . "\n"; - echo "...Public ID=" . $public_ID . "\n"; - echo "...Notation name=" . $notation_name . "\n"; - } + { + echo "unparsed_entity_decl_handler called\n"; + echo "...Entity name=" . $entity_name . "\n"; + echo "...Base=" . $base . "\n"; + echo "...System ID=" . $system_ID . "\n"; + echo "...Public ID=" . $public_ID . "\n"; + echo "...Notation name=" . $notation_name . "\n"; + } - function notation_decl_handler($parser, $name, $base, $system_ID,$public_ID) - { - echo "notation_decl_handler called\n"; - echo "...Name=" . $name . "\n"; - echo "...Base=" . $base . "\n"; - echo "...System ID=" . $system_ID . "\n"; - echo "...Public ID=" . $public_ID . "\n"; - } + function notation_decl_handler($parser, $name, $base, $system_ID,$public_ID) + { + echo "notation_decl_handler called\n"; + echo "...Name=" . $name . "\n"; + echo "...Base=" . $base . "\n"; + echo "...System ID=" . $system_ID . "\n"; + echo "...Public ID=" . $public_ID . "\n"; + } function parse($data) { @@ -54,8 +54,8 @@ $xml = << - - ]> + + ]> ]> HERE; diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt index cd5dda7763b0..f13c52517f40 100644 --- a/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt +++ b/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt @@ -18,10 +18,10 @@ class XML_Parser { function PIHandler($parser, $target, $data) - { - echo "Target: " . $target. "\n"; - echo "Data: " . $data . "\n"; - } + { + echo "Target: " . $target. "\n"; + echo "Data: " . $data . "\n"; + } function parse($data) { diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt index 8ee12e77cde5..8d75d2099c1a 100644 --- a/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt +++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt @@ -34,14 +34,14 @@ xml_parser_free( $parser ); echo "Done\n"; function Namespace_Start_Handler( $parser, $prefix, $uri ) { - echo "Namespace_Start_Handler called\n"; - echo "...Prefix: ". $prefix . "\n"; - echo "...Uri: ". $uri . "\n"; + echo "Namespace_Start_Handler called\n"; + echo "...Prefix: ". $prefix . "\n"; + echo "...Uri: ". $uri . "\n"; } function Namespace_End_Handler($parser, $prefix) { - echo "Namespace_End_Handler called\n"; - echo "...Prefix: ". $prefix . "\n\n"; + echo "Namespace_End_Handler called\n"; + echo "...Prefix: ". $prefix . "\n\n"; } function DefaultHandler( $parser, $data ) { diff --git a/ext/xmlreader/tests/001.phpt b/ext/xmlreader/tests/001.phpt index 6541c7e3b59b..c10c1a51635a 100644 --- a/ext/xmlreader/tests/001.phpt +++ b/ext/xmlreader/tests/001.phpt @@ -13,7 +13,7 @@ $reader->XML($xmlstring); // Only go through while ($reader->read()) { - echo $reader->name."\n"; + echo $reader->name."\n"; } $xmlstring = ''; $reader = new XMLReader(); diff --git a/ext/xmlreader/tests/002.phpt b/ext/xmlreader/tests/002.phpt index 9092740f150c..6d12f0220475 100644 --- a/ext/xmlreader/tests/002.phpt +++ b/ext/xmlreader/tests/002.phpt @@ -14,13 +14,13 @@ if ($reader->open('')) exit(); $reader = new XMLReader(); if (!$reader->open($filename)) { - $reader->close(); - exit(); + $reader->close(); + exit(); } // Only go through while ($reader->read()) { - echo $reader->name."\n"; + echo $reader->name."\n"; } $reader->close(); unlink($filename); diff --git a/ext/xmlreader/tests/003-mb.phpt b/ext/xmlreader/tests/003-mb.phpt index 18c522201b11..5d0ec4de46a3 100644 --- a/ext/xmlreader/tests/003-mb.phpt +++ b/ext/xmlreader/tests/003-mb.phpt @@ -12,62 +12,62 @@ file_put_contents($filename, $xmlstring); $reader = new XMLReader(); if (!$reader->open($filename)) { - exit(); + exit(); } // Only go through while ($reader->read()) { - if ($reader->nodeType != XMLREADER::END_ELEMENT) { - if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { - $attr = $reader->moveToFirstAttribute(); - echo $reader->name . ": "; - echo $reader->value . "\n"; + if ($reader->nodeType != XMLREADER::END_ELEMENT) { + if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { + $attr = $reader->moveToFirstAttribute(); + echo $reader->name . ": "; + echo $reader->value . "\n"; - if ($reader->getAttribute($reader->name) == $reader->value) { - echo "1st attr (num) failed\n"; - } + if ($reader->getAttribute($reader->name) == $reader->value) { + echo "1st attr (num) failed\n"; + } - $attr = $reader->moveToNextAttribute(); - echo $reader->name . ": "; - echo $reader->value . "\n"; + $attr = $reader->moveToNextAttribute(); + echo $reader->name . ": "; + echo $reader->value . "\n"; - if ($reader->getAttribute($reader->name) == $reader->value) { - echo "2nd attr (idx) failed\n"; - } + if ($reader->getAttribute($reader->name) == $reader->value) { + echo "2nd attr (idx) failed\n"; + } - // Named attribute - $attr = $reader->moveToAttribute('num'); - echo $reader->name . ": "; - echo $reader->value . "\n"; + // Named attribute + $attr = $reader->moveToAttribute('num'); + echo $reader->name . ": "; + echo $reader->value . "\n"; - if ($reader->getAttribute('num') == $reader->value) { - echo "attr num failed\n"; - } + if ($reader->getAttribute('num') == $reader->value) { + echo "attr num failed\n"; + } - $attr = $reader->moveToAttribute('idx'); - echo $reader->name . ": "; - echo $reader->value . "\n"; + $attr = $reader->moveToAttribute('idx'); + echo $reader->name . ": "; + echo $reader->value . "\n"; - if ($reader->getAttribute('idx') == $reader->value) { - echo "attr idx failed\n"; - } + if ($reader->getAttribute('idx') == $reader->value) { + echo "attr idx failed\n"; + } - // Numeric positions of attributes - $attr = $reader->moveToAttributeNo(0); - echo $reader->name . ": "; - echo $reader->value . "\n"; + // Numeric positions of attributes + $attr = $reader->moveToAttributeNo(0); + echo $reader->name . ": "; + echo $reader->value . "\n"; - if ($reader->getAttributeNo(0) == $reader->value) { - echo "attr 0 failed\n"; - } + if ($reader->getAttributeNo(0) == $reader->value) { + echo "attr 0 failed\n"; + } - $attr = $reader->moveToAttributeNo(1); - echo $reader->name . ": "; - echo $reader->value . "\n"; + $attr = $reader->moveToAttributeNo(1); + echo $reader->name . ": "; + echo $reader->value . "\n"; - } - } + } + } } $reader->close(); unlink($filename); diff --git a/ext/xmlreader/tests/003.phpt b/ext/xmlreader/tests/003.phpt index 394f95cab578..c52c932c974a 100644 --- a/ext/xmlreader/tests/003.phpt +++ b/ext/xmlreader/tests/003.phpt @@ -12,65 +12,65 @@ file_put_contents($filename, $xmlstring); $reader = new XMLReader(); if (!$reader->open($filename)) { - exit(); + exit(); } // Only go through while ($reader->read()) { - if ($reader->nodeType != XMLREADER::END_ELEMENT) { - if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { - $attr = $reader->moveToFirstAttribute(); - echo $reader->name . ": "; - echo $reader->value . "\n"; - - if ($reader->getAttribute($reader->name) == $reader->value) { - echo "1st attr (num) failed\n"; - } - - - $attr = $reader->moveToNextAttribute(); - echo $reader->name . ": "; - echo $reader->value . "\n"; - - if ($reader->getAttribute($reader->name) == $reader->value) { - echo "2nd attr (idx) failed\n"; - } - - // Named attribute - $attr = $reader->moveToAttribute('num'); - echo $reader->name . ": "; - echo $reader->value . "\n"; - - if ($reader->getAttribute('num') == $reader->value) { - echo "attr num failed\n"; - } - - $attr = $reader->moveToAttribute('idx'); - echo $reader->name . ": "; - echo $reader->value . "\n"; - - if ($reader->getAttribute('idx') == $reader->value) { - echo "attr idx failed\n"; - } - - // Numeric positions of attributes - $attr = $reader->moveToAttributeNo(0); - echo $reader->name . ": "; - echo $reader->value . "\n"; - - if ($reader->getAttributeNo(0) == $reader->value) { - echo "attr 0 failed\n"; - } - - $attr = $reader->moveToAttributeNo(1); - echo $reader->name . ": "; - echo $reader->value . "\n"; - - var_dump($reader->moveToAttributeNo(20)); - var_dump($reader->moveToAttribute('missing-attribute')); - var_dump($reader->moveToAttribute('')); - } - } + if ($reader->nodeType != XMLREADER::END_ELEMENT) { + if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { + $attr = $reader->moveToFirstAttribute(); + echo $reader->name . ": "; + echo $reader->value . "\n"; + + if ($reader->getAttribute($reader->name) == $reader->value) { + echo "1st attr (num) failed\n"; + } + + + $attr = $reader->moveToNextAttribute(); + echo $reader->name . ": "; + echo $reader->value . "\n"; + + if ($reader->getAttribute($reader->name) == $reader->value) { + echo "2nd attr (idx) failed\n"; + } + + // Named attribute + $attr = $reader->moveToAttribute('num'); + echo $reader->name . ": "; + echo $reader->value . "\n"; + + if ($reader->getAttribute('num') == $reader->value) { + echo "attr num failed\n"; + } + + $attr = $reader->moveToAttribute('idx'); + echo $reader->name . ": "; + echo $reader->value . "\n"; + + if ($reader->getAttribute('idx') == $reader->value) { + echo "attr idx failed\n"; + } + + // Numeric positions of attributes + $attr = $reader->moveToAttributeNo(0); + echo $reader->name . ": "; + echo $reader->value . "\n"; + + if ($reader->getAttributeNo(0) == $reader->value) { + echo "attr 0 failed\n"; + } + + $attr = $reader->moveToAttributeNo(1); + echo $reader->name . ": "; + echo $reader->value . "\n"; + + var_dump($reader->moveToAttributeNo(20)); + var_dump($reader->moveToAttribute('missing-attribute')); + var_dump($reader->moveToAttribute('')); + } + } } $reader->close(); unlink($filename); diff --git a/ext/xmlreader/tests/004.phpt b/ext/xmlreader/tests/004.phpt index c13dc1c0e88d..9362c2b1a19a 100644 --- a/ext/xmlreader/tests/004.phpt +++ b/ext/xmlreader/tests/004.phpt @@ -12,21 +12,21 @@ file_put_contents($filename, $xmlstring); $reader = new XMLReader(); if (!$reader->open($filename)) { - exit(); + exit(); } while ($reader->read()) { - if ($reader->nodeType != XMLREADER::END_ELEMENT) { - echo $reader->name."\n"; - if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { - $attr = $reader->moveToFirstAttribute(); - while ($attr) { - echo " Attribute Name: ".$reader->name."\n"; - echo " Attribute Value: ".$reader->value."\n"; - $attr = $reader->moveToNextAttribute(); - } - } - } + if ($reader->nodeType != XMLREADER::END_ELEMENT) { + echo $reader->name."\n"; + if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { + $attr = $reader->moveToFirstAttribute(); + while ($attr) { + echo " Attribute Name: ".$reader->name."\n"; + echo " Attribute Value: ".$reader->value."\n"; + $attr = $reader->moveToNextAttribute(); + } + } + } } $reader->close(); unlink($filename); diff --git a/ext/xmlreader/tests/005.phpt b/ext/xmlreader/tests/005.phpt index 82a64bff5db4..e50b840ef56e 100644 --- a/ext/xmlreader/tests/005.phpt +++ b/ext/xmlreader/tests/005.phpt @@ -17,14 +17,14 @@ $a = $reader->setParserProperty(XMLReader::LOADDTD, false); $b = $reader->getParserProperty(XMLReader::LOADDTD); if (!$a && !$b) { - echo "ok\n"; + echo "ok\n"; } $a = $reader->setParserProperty(XMLReader::SUBST_ENTITIES, true); $b = $reader->getParserProperty(XMLReader::SUBST_ENTITIES); if ($a && $b) { - echo "ok\n"; + echo "ok\n"; } // Only go through while ($reader->read()); diff --git a/ext/xmlreader/tests/006.phpt b/ext/xmlreader/tests/006.phpt index 5bdfc46b8d58..9702e282705e 100644 --- a/ext/xmlreader/tests/006.phpt +++ b/ext/xmlreader/tests/006.phpt @@ -17,14 +17,14 @@ $reader->read(); $reader->read(); if ($reader->nodeType != XMLREADER::END_ELEMENT) { - if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { - $attr = $reader->moveToFirstAttribute(); - if ($reader->moveToElement()) { - if ($reader->name == 'book') { - echo "ok\n"; - } - } - } + if ($reader->nodeType == XMLREADER::ELEMENT && $reader->hasAttributes) { + $attr = $reader->moveToFirstAttribute(); + if ($reader->moveToElement()) { + if ($reader->name == 'book') { + echo "ok\n"; + } + } + } } $reader->close(); diff --git a/ext/xmlreader/tests/007.phpt b/ext/xmlreader/tests/007.phpt index d6247b9ca940..796b9fa05c9d 100644 --- a/ext/xmlreader/tests/007.phpt +++ b/ext/xmlreader/tests/007.phpt @@ -43,7 +43,7 @@ $reader = new XMLReader(); $reader->XML($xmlstring); if ($reader->setRelaxNGSchema('')) { - echo 'failed'; + echo 'failed'; } $reader->close(); ?> diff --git a/ext/xmlreader/tests/008.phpt b/ext/xmlreader/tests/008.phpt index c5f7a760ca25..12361a0efc4a 100644 --- a/ext/xmlreader/tests/008.phpt +++ b/ext/xmlreader/tests/008.phpt @@ -32,7 +32,7 @@ $reader->setParserProperty(XMLREADER::LOADDTD, TRUE); $reader->setParserProperty(XMLREADER::VALIDATE, TRUE); while($reader->read()); if ($reader->isValid()) { - echo "file DTD: ok\n"; + echo "file DTD: ok\n"; } $reader->close(); unlink($file); @@ -60,7 +60,7 @@ $reader->setParserProperty(XMLREADER::LOADDTD, TRUE); $reader->setParserProperty(XMLREADER::VALIDATE, TRUE); while($reader->read()); if ($reader->isValid()) { - echo "string DTD: ok\n"; + echo "string DTD: ok\n"; } ?> --EXPECT-- diff --git a/ext/xmlreader/tests/012.phpt b/ext/xmlreader/tests/012.phpt index 558b58491217..20d26eaa4b5b 100644 --- a/ext/xmlreader/tests/012.phpt +++ b/ext/xmlreader/tests/012.phpt @@ -25,7 +25,7 @@ EOF; $xmlstring = str_replace('012.dtd', __DIR__.'/012.dtd', $xmlstring); if (DIRECTORY_SEPARATOR == '\\') { - $xmlstring = str_replace('\\',"/", $xmlstring); + $xmlstring = str_replace('\\',"/", $xmlstring); } $reader = new XMLReader(); $reader->XML($xmlstring); @@ -39,7 +39,7 @@ echo "\nUsing URI:\n"; $reader = new XMLReader(); $file = __DIR__ . '/012.xml'; if (DIRECTORY_SEPARATOR == '\\') { - $file = str_replace('\\',"/", $file); + $file = str_replace('\\',"/", $file); } $reader->open($file); diff --git a/ext/xmlreader/tests/013.phpt b/ext/xmlreader/tests/013.phpt index 0abf4c9aa0e7..1396485e9ae4 100644 --- a/ext/xmlreader/tests/013.phpt +++ b/ext/xmlreader/tests/013.phpt @@ -18,10 +18,10 @@ $reader = new XMLReader(); $reader->XML($xml); $reader->setSchema(__DIR__ . '/013.xsd'); while($reader->read()) { - if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'item') { - $reader->read(); - var_dump($reader->value); - } + if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'item') { + $reader->read(); + var_dump($reader->value); + } } $reader->close(); diff --git a/ext/xmlreader/tests/bug64230.phpt b/ext/xmlreader/tests/bug64230.phpt index fb1ab4932fd8..b584d8f7cf43 100644 --- a/ext/xmlreader/tests/bug64230.phpt +++ b/ext/xmlreader/tests/bug64230.phpt @@ -9,10 +9,10 @@ extension_loaded("xmlreader") or die("skip requires xmlreader"); echo "Test\n"; function show_internal_errors() { - foreach (libxml_get_errors() as $error) { - printf("Internal: %s\n", $error->message); - } - libxml_clear_errors(); + foreach (libxml_get_errors() as $error) { + printf("Internal: %s\n", $error->message); + } + libxml_clear_errors(); } echo "Internal errors TRUE\n"; diff --git a/ext/xmlreader/tests/bug71805.phpt b/ext/xmlreader/tests/bug71805.phpt index a1de3ec8f622..9fc66ea2a4cf 100644 --- a/ext/xmlreader/tests/bug71805.phpt +++ b/ext/xmlreader/tests/bug71805.phpt @@ -9,27 +9,27 @@ TestXML(__DIR__ . DIRECTORY_SEPARATOR . 'XMLReaderGood_bug71805.xml'); TestXML(__DIR__ . DIRECTORY_SEPARATOR . 'XMLReaderBad_bug71805.xml'); function TestXML($file) { - $XR = new XMLReader; - $XR->open($file, null, LIBXML_NOBLANKS); + $XR = new XMLReader; + $XR->open($file, null, LIBXML_NOBLANKS); - while (($lastRead = $XR->read()) && ($XR->name !== 'records')); - while (($lastRead = $XR->read()) && ($XR->name !== 'record')); - while ($lastRead) { - $xml = $XR->readOuterXML(); - if ($xml === '') { - $err = ''; - if ($e = libxml_get_last_error()) { $err = $e->message.' (line: '.$e->line.')'; } - $XR->close(); - echo $file.' : Problem with file'.($err ? ' — '.$err : '').'.'; - echo "\n"; - return; - } - while (($lastRead = $XR->next()) && ($XR->name !== 'record')); - } - $XR->close(); - echo $file.' : Good!'; - echo "\n"; - return; + while (($lastRead = $XR->read()) && ($XR->name !== 'records')); + while (($lastRead = $XR->read()) && ($XR->name !== 'record')); + while ($lastRead) { + $xml = $XR->readOuterXML(); + if ($xml === '') { + $err = ''; + if ($e = libxml_get_last_error()) { $err = $e->message.' (line: '.$e->line.')'; } + $XR->close(); + echo $file.' : Problem with file'.($err ? ' — '.$err : '').'.'; + echo "\n"; + return; + } + while (($lastRead = $XR->next()) && ($XR->name !== 'record')); + } + $XR->close(); + echo $file.' : Good!'; + echo "\n"; + return; } ?> --EXPECTF-- diff --git a/ext/xmlreader/tests/static.phpt b/ext/xmlreader/tests/static.phpt index 0218efd5fc2e..1c6cb5b8709f 100644 --- a/ext/xmlreader/tests/static.phpt +++ b/ext/xmlreader/tests/static.phpt @@ -14,12 +14,12 @@ file_put_contents($filename, $xmlstring); $reader = XMLReader::open($filename); while ($reader->read()) { - echo $reader->name, "\n"; + echo $reader->name, "\n"; } $reader = XMLReader::XML($xmlstring); while ($reader->read()) { - echo $reader->name, "\n"; + echo $reader->name, "\n"; } ?> --EXPECTF-- diff --git a/ext/xmlrpc/tests/003.phpt b/ext/xmlrpc/tests/003.phpt index 1125ff2b9ca1..f164a377da31 100644 --- a/ext/xmlrpc/tests/003.phpt +++ b/ext/xmlrpc/tests/003.phpt @@ -6,27 +6,27 @@ xmlrpc_encode() Simple test encode array "red", - "two" => "blue", - "three" => "green" + "one" => "red", + "two" => "blue", + "three" => "green" ); $response = xmlrpc_encode($params); echo $response; $params = array( - "red", - "blue", - "green" + "red", + "blue", + "green" ); $response = xmlrpc_encode($params); echo $response; $params = array( - 0 => "red", - 1 => "blue", - 3 => "green" + 0 => "red", + 1 => "blue", + 3 => "green" ); $response = xmlrpc_encode($params); diff --git a/ext/xmlrpc/tests/bug42736.phpt b/ext/xmlrpc/tests/bug42736.phpt index 9ab2818169cd..bb6b787295ef 100644 --- a/ext/xmlrpc/tests/bug42736.phpt +++ b/ext/xmlrpc/tests/bug42736.phpt @@ -6,9 +6,9 @@ Bug #42736 (xmlrpc_server_call_method() crashes) add($id); - } + public function get($id){ + return $this->add($id); + } } $xml = xmlrpc_server_create(); @@ -16,9 +16,9 @@ $xml = xmlrpc_server_create(); $Myrequest = 'GetProducts20060922T14:26:19'; class MyClass { - function GetProducts($dummy, $time){ - return array('faultString' => $time); - } + function GetProducts($dummy, $time){ + return array('faultString' => $time); + } } $myclass = new MyClass(); xmlrpc_server_register_method($xml, 'GetProducts', array($myclass, 'GetProducts')); diff --git a/ext/xmlrpc/tests/bug45556.phpt b/ext/xmlrpc/tests/bug45556.phpt index 29d689dc6d90..485f2c12de84 100644 --- a/ext/xmlrpc/tests/bug45556.phpt +++ b/ext/xmlrpc/tests/bug45556.phpt @@ -13,9 +13,9 @@ $server = xmlrpc_server_create (); function foo() { return 11111; } class bar { - static public function test() { - return 'foo'; - } + static public function test() { + return 'foo'; + } } xmlrpc_server_register_introspection_callback($server, 'foobar'); diff --git a/ext/xmlrpc/tests/bug72155.phpt b/ext/xmlrpc/tests/bug72155.phpt index 40c6c56237f7..6e05a5113c9f 100644 --- a/ext/xmlrpc/tests/bug72155.phpt +++ b/ext/xmlrpc/tests/bug72155.phpt @@ -7,9 +7,9 @@ if (!extension_loaded("xmlrpc")) print "skip"; --FILE-- unset($xw); unlink($doc_dest); if ($md5_out != $md5_res) { - echo "failed: $md5_res != $md5_out\n"; + echo "failed: $md5_res != $md5_out\n"; } else { - echo "ok.\n"; + echo "ok.\n"; } ?> --EXPECT-- diff --git a/ext/xmlwriter/tests/OO_003.phpt b/ext/xmlwriter/tests/OO_003.phpt index b2e551f32a96..ba1e7e177d73 100644 --- a/ext/xmlwriter/tests/OO_003.phpt +++ b/ext/xmlwriter/tests/OO_003.phpt @@ -21,8 +21,8 @@ $xw->endAttribute(); $xw->text("Test text for tag1"); $res = $xw->startElement('tag2'); if ($res < 1) { - echo "StartElement context validation failed\n"; - exit(); + echo "StartElement context validation failed\n"; + exit(); } $xw->endDocument(); diff --git a/ext/xmlwriter/tests/OO_004.phpt b/ext/xmlwriter/tests/OO_004.phpt index 50eacfb9089e..17dbee9d28e9 100644 --- a/ext/xmlwriter/tests/OO_004.phpt +++ b/ext/xmlwriter/tests/OO_004.phpt @@ -25,9 +25,9 @@ $md5_res = md5(' unset($xw); unlink($doc_dest); if ($md5_out != $md5_res) { - echo "failed: $md5_res != $md5_out\n"; + echo "failed: $md5_res != $md5_out\n"; } else { - echo "ok.\n"; + echo "ok.\n"; } ?> --EXPECT-- diff --git a/ext/xmlwriter/tests/xmlwriter_set_indent_string_basic_001.phpt b/ext/xmlwriter/tests/xmlwriter_set_indent_string_basic_001.phpt index d88700825683..26f243dfef07 100644 --- a/ext/xmlwriter/tests/xmlwriter_set_indent_string_basic_001.phpt +++ b/ext/xmlwriter/tests/xmlwriter_set_indent_string_basic_001.phpt @@ -5,9 +5,9 @@ xmlwriter_set_indent_string passing xmlwriter resource --FILE-- diff --git a/ext/xsl/tests/bug49634.phpt b/ext/xsl/tests/bug49634.phpt index edf53ba60085..86c11b18847d 100644 --- a/ext/xsl/tests/bug49634.phpt +++ b/ext/xsl/tests/bug49634.phpt @@ -10,7 +10,7 @@ extension_loaded("xsl") or die("skip need ext/xsl"); $sXml = << - test + test XML; @@ -21,16 +21,16 @@ $sXsl = << - - - - + + + + XSL; function testFunction($a) { - throw new Exception('Test exception.'); + throw new Exception('Test exception.'); } $domXml = new DOMDocument; @@ -40,14 +40,14 @@ $domXsl->loadXML($sXsl); for ($i = 0; $i < 10; $i++) { - $xsltProcessor = new XSLTProcessor(); - $xsltProcessor->registerPHPFunctions(array('testFunction')); - $xsltProcessor->importStyleSheet($domXsl); - try { - @$xsltProcessor->transformToDoc($domXml); - } catch (Exception $e) { - echo $e,"\n"; - } + $xsltProcessor = new XSLTProcessor(); + $xsltProcessor->registerPHPFunctions(array('testFunction')); + $xsltProcessor->importStyleSheet($domXsl); + try { + @$xsltProcessor->transformToDoc($domXml); + } catch (Exception $e) { + echo $e,"\n"; + } } ?> --EXPECTF-- diff --git a/ext/xsl/tests/bug54446.phpt b/ext/xsl/tests/bug54446.phpt index b9af5581eb1f..1e518f497721 100644 --- a/ext/xsl/tests/bug54446.phpt +++ b/ext/xsl/tests/bug54446.phpt @@ -15,15 +15,15 @@ if (file_exists($outputfile)) { $sXsl = << - - - - - - + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:sax="http://icl.com/saxon" + extension-element-prefixes="sax"> + + + + + + EOT; diff --git a/ext/xsl/tests/bug54446_with_ini.phpt b/ext/xsl/tests/bug54446_with_ini.phpt index 5327d6d3978e..9232295358c1 100644 --- a/ext/xsl/tests/bug54446_with_ini.phpt +++ b/ext/xsl/tests/bug54446_with_ini.phpt @@ -15,15 +15,15 @@ if (file_exists($outputfile)) { $sXsl = << - - - - - - + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:sax="http://icl.com/saxon" + extension-element-prefixes="sax"> + + + + + + EOT; diff --git a/ext/xsl/tests/bug71540.phpt b/ext/xsl/tests/bug71540.phpt index efde4bb77da1..367ba49c15a5 100644 --- a/ext/xsl/tests/bug71540.phpt +++ b/ext/xsl/tests/bug71540.phpt @@ -16,7 +16,7 @@ $xml = << - diff --git a/ext/xsl/tests/xslt012.phpt b/ext/xsl/tests/xslt012.phpt index a24a0d2a7fd0..737512bbe9ff 100644 --- a/ext/xsl/tests/xslt012.phpt +++ b/ext/xsl/tests/xslt012.phpt @@ -30,9 +30,9 @@ if(!$proc) { $proc->importStylesheet($xsl); $parameters = Array( - 'foo' => 'barbar', - 'foo1' => 'test', - ); + 'foo' => 'barbar', + 'foo1' => 'test', + ); $proc->setParameter( "", $parameters); diff --git a/ext/zip/tests/bug14962.phpt b/ext/zip/tests/bug14962.phpt index 06a2ce5e6a62..fbebfc72751a 100644 --- a/ext/zip/tests/bug14962.phpt +++ b/ext/zip/tests/bug14962.phpt @@ -16,7 +16,7 @@ $za->addFromString($file, '1234'); $za->close(); if (!is_file($dir . "/__14962.zip")) { - die('failed to create the archive'); + die('failed to create the archive'); } $za = new ZipArchive; $za->open($dir . '/__14962.zip'); @@ -24,8 +24,8 @@ $za->extractTo($dir, NULL); $za->close(); if (is_file($fullpath)) { - unlink($fullpath); - echo "Ok"; + unlink($fullpath); + echo "Ok"; } unlink($dir . '/' . '__14962.zip'); ?> diff --git a/ext/zip/tests/bug38943.inc b/ext/zip/tests/bug38943.inc index b439939e64d2..b04049a1724d 100644 --- a/ext/zip/tests/bug38943.inc +++ b/ext/zip/tests/bug38943.inc @@ -1,13 +1,13 @@ testarray[] = 1; - var_dump($this->testarray); - } + public function __construct() { + $this->testarray[] = 1; + var_dump($this->testarray); + } } $z = new myZip; diff --git a/ext/zip/tests/bug38943.phpt b/ext/zip/tests/bug38943.phpt index c5e22847192f..ffd0f8dc1649 100644 --- a/ext/zip/tests/bug38943.phpt +++ b/ext/zip/tests/bug38943.phpt @@ -7,14 +7,14 @@ if(!extension_loaded('zip')) die('skip'); --FILE-- testarray[] = 1; - var_dump($this->testarray); - } + public function __construct() { + $this->testarray[] = 1; + var_dump($this->testarray); + } } $z = new myZip; diff --git a/ext/zip/tests/bug40228-mb.phpt b/ext/zip/tests/bug40228-mb.phpt index b7095dda6873..fddfb65f2963 100644 --- a/ext/zip/tests/bug40228-mb.phpt +++ b/ext/zip/tests/bug40228-mb.phpt @@ -10,11 +10,11 @@ $zip = new ZipArchive; $zip->open($arc_name, ZIPARCHIVE::CREATE); $zip->extractTo($dest); if (is_dir($dest . '/test/empty')) { - echo "Ok\n"; - rmdir($dest . '/test/empty'); - rmdir($dest . '/test'); + echo "Ok\n"; + rmdir($dest . '/test/empty'); + rmdir($dest . '/test'); } else { - echo "Failed.\n"; + echo "Failed.\n"; } echo "Done\n"; ?> diff --git a/ext/zip/tests/bug40228.phpt b/ext/zip/tests/bug40228.phpt index ce5f1e6afe20..49e202c576ba 100644 --- a/ext/zip/tests/bug40228.phpt +++ b/ext/zip/tests/bug40228.phpt @@ -10,11 +10,11 @@ $zip = new ZipArchive; $zip->open($arc_name, ZIPARCHIVE::CREATE); $zip->extractTo($dest); if (is_dir($dest . '/test/empty')) { - echo "Ok\n"; - rmdir($dest . '/test/empty'); - rmdir($dest . '/test'); + echo "Ok\n"; + rmdir($dest . '/test/empty'); + rmdir($dest . '/test'); } else { - echo "Failed.\n"; + echo "Failed.\n"; } echo "Done\n"; ?> diff --git a/ext/zip/tests/bug47667.phpt b/ext/zip/tests/bug47667.phpt index 085fb1b87fe5..ab9320280178 100644 --- a/ext/zip/tests/bug47667.phpt +++ b/ext/zip/tests/bug47667.phpt @@ -11,24 +11,24 @@ $filename = $thisdir . "/bug47667.zip"; $zip = new ZipArchive(); if ($zip->open($filename, ZipArchive::CREATE) !== true) { - exit("Unable to open the zip file"); + exit("Unable to open the zip file"); } else { - $zip->addFromString('foo.txt', 'foo bar foobar'); - $zip->close(); + $zip->addFromString('foo.txt', 'foo bar foobar'); + $zip->close(); } for ($i = 0; $i < 10; $i++) { - $zip = new ZipArchive(); - if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) { - exit("Unable to open the zip file"); - } - $zip->addFromString("foo_{$i}.txt", 'foo bar foobar'); - $zip->close(); + $zip = new ZipArchive(); + if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) { + exit("Unable to open the zip file"); + } + $zip->addFromString("foo_{$i}.txt", 'foo bar foobar'); + $zip->close(); } $zip = new ZipArchive(); if ($zip->open($filename, ZipArchive::CREATE) !== true) { - exit("Unable to open the zip file"); + exit("Unable to open the zip file"); } echo "files: " , $zip->numFiles; diff --git a/ext/zip/tests/bug49072.phpt b/ext/zip/tests/bug49072.phpt index b918fba01b87..dfe593d01b6e 100644 --- a/ext/zip/tests/bug49072.phpt +++ b/ext/zip/tests/bug49072.phpt @@ -9,13 +9,13 @@ if(!extension_loaded('zip')) die('skip'); $f = __DIR__ . '/bug49072.zip'; $o = new ZipArchive(); if (! $o->open($f, ZipArchive::CHECKCONS)) { - exit ('error can\'t open'); + exit ('error can\'t open'); } $r = $o->getStream('file1'); // this file has a wrong crc if (!$r)die('failed to open a stream for file1'); $s = ''; while (! feof($r)) { - $s .= fread($r,1024); + $s .= fread($r,1024); } ?> --EXPECTF-- diff --git a/ext/zip/tests/bug51353.phpt b/ext/zip/tests/bug51353.phpt index d84de38f5b01..896375dda394 100644 --- a/ext/zip/tests/bug51353.phpt +++ b/ext/zip/tests/bug51353.phpt @@ -13,28 +13,28 @@ set_time_limit(0); $base_path = __DIR__; /* Either we ship a file with 100000 entries which would be >12M big, - or create it dynamically. */ + or create it dynamically. */ $zip = new ZipArchive; $r = $zip->open("$base_path/51353.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); if ($r) { - for ($i = 0; $i < 100000; $i++) { - $zip->addFromString("$i.txt", '1'); - } - $zip->close(); + for ($i = 0; $i < 100000; $i++) { + $zip->addFromString("$i.txt", '1'); + } + $zip->close(); } else { - die("failed"); + die("failed"); } $zip = new ZipArchive; $r = $zip->open("$base_path/51353.zip"); if ($r) { - $zip->extractTo("$base_path/51353_unpack"); - $zip->close(); + $zip->extractTo("$base_path/51353_unpack"); + $zip->close(); - $a = glob("$base_path/51353_unpack/*.txt"); - echo count($a) . "\n"; + $a = glob("$base_path/51353_unpack/*.txt"); + echo count($a) . "\n"; } else { - die("failed"); + die("failed"); } echo "OK"; diff --git a/ext/zip/tests/bug53579.phpt b/ext/zip/tests/bug53579.phpt index 371dc31e4fa5..d0ec350824f9 100644 --- a/ext/zip/tests/bug53579.phpt +++ b/ext/zip/tests/bug53579.phpt @@ -11,7 +11,7 @@ $file = $dirname . 'test_with_comment.zip'; include $dirname . 'utils.inc'; $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } $fp = $zip->getStream('foo'); diff --git a/ext/zip/tests/bug53603.phpt b/ext/zip/tests/bug53603.phpt index eb8b169f036c..1d1703d5905f 100644 --- a/ext/zip/tests/bug53603.phpt +++ b/ext/zip/tests/bug53603.phpt @@ -8,11 +8,11 @@ if(!extension_loaded('zip')) die('skip'); open($file) !== TRUE) { - echo "open failed.\n"; - exit('failed'); + echo "open failed.\n"; + exit('failed'); } $a = $zip->extractTo('teststream://test'); diff --git a/ext/zip/tests/bug64342_0.phpt b/ext/zip/tests/bug64342_0.phpt index 96e9667dda57..f9cde3afedee 100644 --- a/ext/zip/tests/bug64342_0.phpt +++ b/ext/zip/tests/bug64342_0.phpt @@ -10,22 +10,22 @@ Bug #64342 ZipArchive::addFile() has to check file existence (variation 1) $zip = new ZipArchive; $res = $zip->open(__DIR__ . '/bug64342.zip', ZipArchive::CREATE); if ($res === TRUE) { - $f = md5(uniqid()) . '.txt'; - echo "$f\n"; - $res = $zip->addFile($f); - if (true == $res) { - echo "add ok\n"; - } else { - echo "add failed\n"; - } - $res = $zip->close(); - if (true == $res) { - echo "close ok\n"; - } else { - echo "close failed\n"; - } + $f = md5(uniqid()) . '.txt'; + echo "$f\n"; + $res = $zip->addFile($f); + if (true == $res) { + echo "add ok\n"; + } else { + echo "add failed\n"; + } + $res = $zip->close(); + if (true == $res) { + echo "close ok\n"; + } else { + echo "close failed\n"; + } } else { - echo "open failed\n"; + echo "open failed\n"; } diff --git a/ext/zip/tests/bug64342_1-mb.phpt b/ext/zip/tests/bug64342_1-mb.phpt index 6b14c7fb5dc0..4884c9fe5f39 100644 --- a/ext/zip/tests/bug64342_1-mb.phpt +++ b/ext/zip/tests/bug64342_1-mb.phpt @@ -15,25 +15,25 @@ copy($dirname . 'test.zip', $file); $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) { - echo "failed\n"; + echo "failed\n"; } if ($zip->status == ZIPARCHIVE::ER_OK) { - if (!verify_entries($zip, [ - "bar", - "foobar/", - "foobar/baz", - "entry1.txt" - ])) { - echo "failed\n"; - } else { - echo "OK"; - } - $zip->close(); + if (!verify_entries($zip, [ + "bar", + "foobar/", + "foobar/baz", + "entry1.txt" + ])) { + echo "failed\n"; + } else { + echo "OK"; + } + $zip->close(); } else { - echo "failed\n"; + echo "failed\n"; } @unlink($file); ?> diff --git a/ext/zip/tests/bug64342_1.phpt b/ext/zip/tests/bug64342_1.phpt index 13d8a6d38852..6b923d3ef1ab 100644 --- a/ext/zip/tests/bug64342_1.phpt +++ b/ext/zip/tests/bug64342_1.phpt @@ -15,25 +15,25 @@ copy($dirname . 'test.zip', $file); $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) { - echo "failed\n"; + echo "failed\n"; } if ($zip->status == ZIPARCHIVE::ER_OK) { - if (!verify_entries($zip, [ - "bar", - "foobar/", - "foobar/baz", - "entry1.txt" - ])) { - echo "failed\n"; - } else { - echo "OK"; - } - $zip->close(); + if (!verify_entries($zip, [ + "bar", + "foobar/", + "foobar/baz", + "entry1.txt" + ])) { + echo "failed\n"; + } else { + echo "OK"; + } + $zip->close(); } else { - echo "failed\n"; + echo "failed\n"; } @unlink($file); ?> diff --git a/ext/zip/tests/bug7214.phpt b/ext/zip/tests/bug7214.phpt index d36f0f4b42ea..b36bb2759f4f 100644 --- a/ext/zip/tests/bug7214.phpt +++ b/ext/zip/tests/bug7214.phpt @@ -12,9 +12,9 @@ $entries = 0; $entry = zip_read($zip); $contents = zip_entry_read($entry, zip_entry_filesize($entry)); if (strlen($contents) == zip_entry_filesize($entry)) { - echo "Ok"; + echo "Ok"; } else { - echo "failed"; + echo "failed"; } ?> diff --git a/ext/zip/tests/bug72258.phpt b/ext/zip/tests/bug72258.phpt index 208a810c339f..4612cc26f08f 100644 --- a/ext/zip/tests/bug72258.phpt +++ b/ext/zip/tests/bug72258.phpt @@ -12,13 +12,13 @@ $fn = __DIR__ . DIRECTORY_SEPARATOR . "bug72258.zip"; $zip = new \ZipArchive(); $res = $zip->open($fn); if ($res !== true) { - echo 'Error opening: ' . $res; - die(); + echo 'Error opening: ' . $res; + die(); } for ($i = 0; $i < $zip->numFiles; $i++) { - $fnInArc = $zip->getNameIndex($i, ZipArchive::FL_ENC_RAW); - var_dump($fnInArc); + $fnInArc = $zip->getNameIndex($i, ZipArchive::FL_ENC_RAW); + var_dump($fnInArc); } ?> --EXPECT-- diff --git a/ext/zip/tests/bug76524.phpt b/ext/zip/tests/bug76524.phpt index e087015c3c2a..5fd66c153537 100644 --- a/ext/zip/tests/bug76524.phpt +++ b/ext/zip/tests/bug76524.phpt @@ -9,7 +9,7 @@ if(!extension_loaded('zip')) die('skip'); $i = 0; do { - $filename = __DIR__ . "/nonexistent" . ($i++) . ".zip"; + $filename = __DIR__ . "/nonexistent" . ($i++) . ".zip"; } while (file_exists($filename)); $zip = new ZipArchive(); diff --git a/ext/zip/tests/bug7658.phpt b/ext/zip/tests/bug7658.phpt index 9253b01c3f31..e2a70aac14e4 100644 --- a/ext/zip/tests/bug7658.phpt +++ b/ext/zip/tests/bug7658.phpt @@ -7,21 +7,21 @@ if(!extension_loaded('zip')) die('skip'); --FILE-- open($file)) { - echo 'failed'; + echo 'failed'; } @@ -40,8 +40,8 @@ echo "\n"; $zip->open($file); for($i=0; $i < $zip->numFiles; $i++) { - $sb = $zip->statIndex($i); - $found[] = $sb['name']; + $sb = $zip->statIndex($i); + $found[] = $sb['name']; } $ar = array_diff($found, $expect); diff --git a/ext/zip/tests/bug8700.phpt b/ext/zip/tests/bug8700.phpt index 67bd265f9a74..ad5d91b7c249 100644 --- a/ext/zip/tests/bug8700.phpt +++ b/ext/zip/tests/bug8700.phpt @@ -17,8 +17,8 @@ if ($zip->open($filename) === FALSE) { $contents_from_idx = $zip->getFromIndex(0); $contents_from_name = $zip->getFromName('1.txt'); if ($contents_from_idx != $contents_from_name) { - echo "failed:"; - var_dump($content_from_idx, $content_from_name); + echo "failed:"; + var_dump($content_from_idx, $content_from_name); } $zip->close(); diff --git a/ext/zip/tests/doubleclose.phpt b/ext/zip/tests/doubleclose.phpt index eb0ed7a829c7..905dc60f0c0c 100644 --- a/ext/zip/tests/doubleclose.phpt +++ b/ext/zip/tests/doubleclose.phpt @@ -10,7 +10,7 @@ if(!extension_loaded('zip')) die('skip'); echo "Procedural\n"; $zip = zip_open(__DIR__ . '/test.zip'); if (!is_resource($zip)) { - die("Failure"); + die("Failure"); } var_dump(zip_close($zip)); try { @@ -22,17 +22,17 @@ try { echo "Object\n"; $zip = new ZipArchive(); if (!$zip->open(__DIR__ . '/test.zip')) { - die('Failure'); + die('Failure'); } if ($zip->status == ZIPARCHIVE::ER_OK) { - var_dump($zip->close()); - try { - $zip->close(); - } catch (ValueError $err) { - echo $err->getMessage(), PHP_EOL; - } + var_dump($zip->close()); + try { + $zip->close(); + } catch (ValueError $err) { + echo $err->getMessage(), PHP_EOL; + } } else { - die("Failure"); + die("Failure"); } ?> diff --git a/ext/zip/tests/oo_addemptydir.phpt b/ext/zip/tests/oo_addemptydir.phpt index 4ad424ce19d7..1a95662b15cf 100644 --- a/ext/zip/tests/oo_addemptydir.phpt +++ b/ext/zip/tests/oo_addemptydir.phpt @@ -15,25 +15,25 @@ copy($dirname . 'test.zip', $file); $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } $zip->addEmptyDir('emptydir'); if ($zip->status == ZIPARCHIVE::ER_OK) { - if (!verify_entries($zip, [ - "bar", - "foobar/", - "foobar/baz", - "entry1.txt", - "emptydir/" - ])) { - echo "failed\n"; - } else { - echo "OK"; - } - $zip->close(); + if (!verify_entries($zip, [ + "bar", + "foobar/", + "foobar/baz", + "entry1.txt", + "emptydir/" + ])) { + echo "failed\n"; + } else { + echo "OK"; + } + $zip->close(); } else { - echo "failed3\n"; + echo "failed3\n"; } @unlink($file); ?> diff --git a/ext/zip/tests/oo_addemptydir_error.phpt b/ext/zip/tests/oo_addemptydir_error.phpt index a1b083ca50de..92c220066fdb 100644 --- a/ext/zip/tests/oo_addemptydir_error.phpt +++ b/ext/zip/tests/oo_addemptydir_error.phpt @@ -12,16 +12,16 @@ include __DIR__ . '/utils.inc'; $zip = new ZipArchive; if (!$zip->open(__DIR__ . '/test.zip', ZipArchive::RDONLY)) { - exit('failed'); + exit('failed'); } var_dump($zip->addEmptyDir('emptydir')); if ($zip->status == ZipArchive::ER_RDONLY) { - echo "OK\n"; + echo "OK\n"; } else if ($zip->status == ZipArchive::ER_OK) { - dump_entries_name($zip); + dump_entries_name($zip); } else { - echo "Lost\n"; + echo "Lost\n"; } $zip->close(); ?> diff --git a/ext/zip/tests/oo_addfile.phpt b/ext/zip/tests/oo_addfile.phpt index 254f2b762073..5dd99faa0b28 100644 --- a/ext/zip/tests/oo_addfile.phpt +++ b/ext/zip/tests/oo_addfile.phpt @@ -15,26 +15,26 @@ copy($dirname . 'test.zip', $file); $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) { - echo "failed\n"; + echo "failed\n"; } if ($zip->status == ZIPARCHIVE::ER_OK) { - if (!verify_entries($zip, [ - "bar", - "foobar/", - "foobar/baz", - "entry1.txt", - "test.php" - ])) { - echo "failed\n"; - } else { - echo "OK"; - } - $zip->close(); + if (!verify_entries($zip, [ + "bar", + "foobar/", + "foobar/baz", + "entry1.txt", + "test.php" + ])) { + echo "failed\n"; + } else { + echo "OK"; + } + $zip->close(); } else { - echo "failed\n"; + echo "failed\n"; } @unlink($file); ?> diff --git a/ext/zip/tests/oo_cancel.phpt b/ext/zip/tests/oo_cancel.phpt index c8653ec52ee8..4c487072c038 100644 --- a/ext/zip/tests/oo_cancel.phpt +++ b/ext/zip/tests/oo_cancel.phpt @@ -17,12 +17,12 @@ $file = $dirname . '__tmp_oo_progress.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } var_dump($zip->registerCancelCallback(function () { - // Always cancel - return -1; + // Always cancel + return -1; })); var_dump($zip->addFromString(PHP_BINARY, 'entry #1')); diff --git a/ext/zip/tests/oo_close.phpt b/ext/zip/tests/oo_close.phpt index 60a7f364d13f..962ce183e769 100644 --- a/ext/zip/tests/oo_close.phpt +++ b/ext/zip/tests/oo_close.phpt @@ -10,14 +10,14 @@ if(!extension_loaded('zip')) die('skip'); $dirname = __DIR__ . '/'; $zip = new ZipArchive; if (!$zip->open($dirname . 'test.zip')) { - exit('failed'); + exit('failed'); } if ($zip->status == ZIPARCHIVE::ER_OK) { - $zip->close(); - echo "ok\n"; + $zip->close(); + echo "ok\n"; } else { - echo "failed\n"; + echo "failed\n"; } ?> --EXPECT-- diff --git a/ext/zip/tests/oo_count.phpt b/ext/zip/tests/oo_count.phpt index a5771fa29852..426d456a291d 100644 --- a/ext/zip/tests/oo_count.phpt +++ b/ext/zip/tests/oo_count.phpt @@ -12,7 +12,7 @@ $file = $dirname . 'test.zip'; $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } var_dump($zip->numFiles, count($zip), $zip->numFiles == count($zip)); diff --git a/ext/zip/tests/oo_delete.phpt b/ext/zip/tests/oo_delete.phpt index 385b943893c1..033662be3e31 100644 --- a/ext/zip/tests/oo_delete.phpt +++ b/ext/zip/tests/oo_delete.phpt @@ -9,50 +9,50 @@ if(!extension_loaded('zip')) die('skip'); $dirname = __DIR__ . '/'; $file = $dirname . 'oo_delete.zip'; if (file_exists($file)) { - unlink($file); + unlink($file); } $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('entry1.txt', 'entry #1'); $zip->addFromString('entry2.txt', 'entry #2'); $zip->addFromString('dir/entry2.txt', 'entry #2'); if ($zip->status == ZIPARCHIVE::ER_OK) { - $zip->close(); - echo "ok\n"; + $zip->close(); + echo "ok\n"; } else { - var_dump($zip); - echo "failed\n"; + var_dump($zip); + echo "failed\n"; } if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } if ($zip->deleteIndex(0)) { - echo "ok\n"; + echo "ok\n"; } if ($zip->deleteName('entry2.txt')) { - echo "ok\n"; + echo "ok\n"; } else { - echo "failed 3\n"; + echo "failed 3\n"; } if ($zip->deleteName('dir/entry2.txt')) { - echo "ok\n"; + echo "ok\n"; } else { - echo "failed 3\n"; + echo "failed 3\n"; } if (!$zip->deleteIndex(123)) { - echo "ok\n"; + echo "ok\n"; } else { - print_r($zip); - echo "failed\n"; + print_r($zip); + echo "failed\n"; } @@ -67,7 +67,7 @@ var_dump($sb); unset($zip); if (file_exists($file)) { - unlink($file); + unlink($file); } ?> --EXPECT-- diff --git a/ext/zip/tests/oo_ext_zip.phpt b/ext/zip/tests/oo_ext_zip.phpt index d35094daeb04..70c595a03ac0 100644 --- a/ext/zip/tests/oo_ext_zip.phpt +++ b/ext/zip/tests/oo_ext_zip.phpt @@ -7,14 +7,14 @@ if(!extension_loaded('zip')) die('skip'); --FILE-- testarray[] = 1; - var_dump($this->testarray); - } + public function __construct() { + $this->testarray[] = 1; + var_dump($this->testarray); + } } $z = new myZip; diff --git a/ext/zip/tests/oo_extract.phpt b/ext/zip/tests/oo_extract.phpt index d2ae2b5a439a..f654ea8c9550 100644 --- a/ext/zip/tests/oo_extract.phpt +++ b/ext/zip/tests/oo_extract.phpt @@ -11,57 +11,57 @@ $file = $dirname . 'test_with_comment.zip'; include $dirname . 'utils.inc'; $zip = new ZipArchive; if ($zip->open($file) !== TRUE) { - echo "open failed.\n"; - exit('failed'); + echo "open failed.\n"; + exit('failed'); } $zip->extractTo($dirname . '__oo_extract_tmp'); if (!is_dir($dirname . '__oo_extract_tmp')) { - echo "failed. mkdir\n"; + echo "failed. mkdir\n"; } if (!is_dir($dirname .'__oo_extract_tmp/foobar')) { - echo "failed. mkdir foobar\n"; + echo "failed. mkdir foobar\n"; } if (!file_exists($dirname . '__oo_extract_tmp/foobar/baz')) { - echo "failed. extract foobar/baz\n"; + echo "failed. extract foobar/baz\n"; } else { - echo file_get_contents($dirname . '__oo_extract_tmp/foobar/baz') . "\n"; + echo file_get_contents($dirname . '__oo_extract_tmp/foobar/baz') . "\n"; } if (!file_exists($dirname . '__oo_extract_tmp/bar')) { - echo "failed. bar file\n"; + echo "failed. bar file\n"; } else { - echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; + echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; } if (!file_exists($dirname . '__oo_extract_tmp/foo')) { - echo "failed. foo file\n"; + echo "failed. foo file\n"; } else { - echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; + echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; } /* extract one file */ $zip->extractTo($dirname . '__oo_extract_tmp', 'bar'); if (!file_exists($dirname . '__oo_extract_tmp/bar')) { - echo "failed. extract bar file\n"; + echo "failed. extract bar file\n"; } else { - echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; + echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; } /* extract two files */ $zip->extractTo($dirname . '__oo_extract_tmp', array('bar','foo')); if (!file_exists($dirname . '__oo_extract_tmp/bar')) { - echo "failed. extract bar file\n"; + echo "failed. extract bar file\n"; } else { - echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; + echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n"; } if (!file_exists($dirname . '__oo_extract_tmp/foo')) { - echo "failed. extract foo file\n"; + echo "failed. extract foo file\n"; } else { - echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; + echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n"; } rmdir_rf($dirname . '__oo_extract_tmp'); diff --git a/ext/zip/tests/oo_getcomment.phpt b/ext/zip/tests/oo_getcomment.phpt index 333dfa96bbde..6f54105cc88d 100644 --- a/ext/zip/tests/oo_getcomment.phpt +++ b/ext/zip/tests/oo_getcomment.phpt @@ -11,7 +11,7 @@ $file = $dirname . 'test_with_comment.zip'; include $dirname . 'utils.inc'; $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } echo $zip->getArchiveComment() . "\n"; diff --git a/ext/zip/tests/oo_getnameindex.phpt b/ext/zip/tests/oo_getnameindex.phpt index 838a5a91b145..0ed563f44731 100644 --- a/ext/zip/tests/oo_getnameindex.phpt +++ b/ext/zip/tests/oo_getnameindex.phpt @@ -14,7 +14,7 @@ $file = $dirname . 'oo_getnameindex.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('entry1.txt', 'entry #1'); @@ -22,12 +22,12 @@ $zip->addFromString('entry2.txt', 'entry #2'); $zip->addFromString('dir/entry2d.txt', 'entry #2'); if (!$zip->status == ZIPARCHIVE::ER_OK) { - echo "failed to write zip\n"; + echo "failed to write zip\n"; } $zip->close(); if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } diff --git a/ext/zip/tests/oo_namelocate.phpt b/ext/zip/tests/oo_namelocate.phpt index f6c837ac20a3..5b4c6dbf89b4 100644 --- a/ext/zip/tests/oo_namelocate.phpt +++ b/ext/zip/tests/oo_namelocate.phpt @@ -14,7 +14,7 @@ $file = $dirname . 'oo_namelocate.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('entry1.txt', 'entry #1'); @@ -22,12 +22,12 @@ $zip->addFromString('entry2.txt', 'entry #2'); $zip->addFromString('dir/entry2d.txt', 'entry #2'); if (!$zip->status == ZIPARCHIVE::ER_OK) { - echo "failed to write zip\n"; + echo "failed to write zip\n"; } $zip->close(); if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } diff --git a/ext/zip/tests/oo_open.phpt b/ext/zip/tests/oo_open.phpt index 10ebad944122..2dffdc0d889f 100644 --- a/ext/zip/tests/oo_open.phpt +++ b/ext/zip/tests/oo_open.phpt @@ -11,16 +11,16 @@ $dirname = __DIR__ . '/'; $zip = new ZipArchive; $r = $zip->open($dirname . 'nofile'); if ($r !== TRUE) { - echo "ER_OPEN: ok\n"; + echo "ER_OPEN: ok\n"; } else { - echo "ER_OPEN: FAILED\n"; + echo "ER_OPEN: FAILED\n"; } $r = $zip->open($dirname . 'nofile', ZIPARCHIVE::CREATE); if (!$r) { - echo "create: failed\n"; + echo "create: failed\n"; } else { - echo "create: ok\n"; + echo "create: ok\n"; } @unlink($dirname . 'nofile'); @@ -28,13 +28,13 @@ $zip = new ZipArchive; $zip->open(''); if (!$zip->open($dirname . 'test.zip')) { - exit("failed 1\n"); + exit("failed 1\n"); } if ($zip->status == ZIPARCHIVE::ER_OK) { - echo "OK\n"; + echo "OK\n"; } else { - echo "failed\n"; + echo "failed\n"; } ?> --EXPECTF-- diff --git a/ext/zip/tests/oo_progress.phpt b/ext/zip/tests/oo_progress.phpt index 480510d862e4..c4641653ed7e 100644 --- a/ext/zip/tests/oo_progress.phpt +++ b/ext/zip/tests/oo_progress.phpt @@ -17,13 +17,13 @@ $file = $dirname . '__tmp_oo_progress.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } var_dump($zip->registerProgressCallback(0.5, function ($r) { - // Only check start/end as intermediate is not reliable - if ($r == 0.0) echo "start\n"; - if ($r == 1.0) echo "end\n"; + // Only check start/end as intermediate is not reliable + if ($r == 0.0) echo "start\n"; + if ($r == 1.0) echo "end\n"; })); var_dump($zip->addFromString('foo', 'entry #1')); diff --git a/ext/zip/tests/oo_properties.phpt b/ext/zip/tests/oo_properties.phpt index 108a85e29bb9..13482f3541e6 100644 --- a/ext/zip/tests/oo_properties.phpt +++ b/ext/zip/tests/oo_properties.phpt @@ -14,7 +14,7 @@ copy($dirname . 'test_with_comment.zip', $file); $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } printf("zip->status (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->status, empty($zip->status), isset($zip->status)); diff --git a/ext/zip/tests/oo_rename.phpt b/ext/zip/tests/oo_rename.phpt index cdac4890848f..9cd9341406ef 100644 --- a/ext/zip/tests/oo_rename.phpt +++ b/ext/zip/tests/oo_rename.phpt @@ -14,7 +14,7 @@ $file = $dirname . 'oo_rename.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('entry1.txt', 'entry #1'); @@ -22,42 +22,42 @@ $zip->addFromString('entry2.txt', 'entry #2'); $zip->addFromString('dir/entry2.txt', 'entry #2'); if (!$zip->status == ZIPARCHIVE::ER_OK) { - var_dump($zip); - echo "failed2\n"; + var_dump($zip); + echo "failed2\n"; } $zip->close(); if (!$zip->open($file)) { - exit('failed3'); + exit('failed3'); } if (!verify_entries($zip, [ - "entry1.txt", + "entry1.txt", "entry2.txt", "dir/entry2.txt" ])) { - exit("failed4"); + exit("failed4"); } else { - echo "OK\n"; + echo "OK\n"; } if (!$zip->renameIndex(0, 'ren_entry1.txt')) { - echo "failed index 0\n"; + echo "failed index 0\n"; } if (!$zip->renameName('dir/entry2.txt', 'dir3/ren_entry2.txt')) { - echo "failed name dir/entry2.txt\n"; + echo "failed name dir/entry2.txt\n"; } if (!verify_entries($zip, [ - "ren_entry1.txt", + "ren_entry1.txt", "entry2.txt", "dir3/ren_entry2.txt" ])) { - exit("failed5"); + exit("failed5"); } else { - echo "OK\n"; + echo "OK\n"; } $zip->close(); diff --git a/ext/zip/tests/oo_setcomment.phpt b/ext/zip/tests/oo_setcomment.phpt index a4e10bfce592..4518e6864731 100644 --- a/ext/zip/tests/oo_setcomment.phpt +++ b/ext/zip/tests/oo_setcomment.phpt @@ -14,7 +14,7 @@ $file = $dirname . 'oo_setcomment.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('entry1.txt', 'entry #1'); @@ -34,13 +34,13 @@ var_dump($zip->setCommentIndex(4, 'entry5.txt')); var_dump($zip->setArchiveComment('archive')); if (!$zip->status == ZIPARCHIVE::ER_OK) { - echo "failed to write zip\n"; + echo "failed to write zip\n"; } $zip->close(); if (!$zip->open($file)) { - @unlink($file); - exit('failed'); + @unlink($file); + exit('failed'); } var_dump($zip->getCommentIndex(0)); diff --git a/ext/zip/tests/oo_setcomment_error.phpt b/ext/zip/tests/oo_setcomment_error.phpt index a4301154c813..78d8d3dc3560 100644 --- a/ext/zip/tests/oo_setcomment_error.phpt +++ b/ext/zip/tests/oo_setcomment_error.phpt @@ -12,7 +12,7 @@ $file = __DIR__ . '/__tmp_oo_set_comment_error.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('entry1.txt', 'entry #1'); diff --git a/ext/zip/tests/oo_setcompression.phpt b/ext/zip/tests/oo_setcompression.phpt index 0cdcd791b875..b8519b68349b 100644 --- a/ext/zip/tests/oo_setcompression.phpt +++ b/ext/zip/tests/oo_setcompression.phpt @@ -9,13 +9,13 @@ if (!extension_loaded('zip')) die('skip'); $tmpfile = __DIR__ . '/oo_setcompression.zip'; if (file_exists($tmpfile)) { - unlink($tmpfile); + unlink($tmpfile); } // generate the ZIP file $zip = new ZipArchive; if ($zip->open($tmpfile, ZipArchive::CREATE) !== TRUE) { - exit('failed'); + exit('failed'); } $txt = file_get_contents(__FILE__); $zip->addFromString('entry1.txt', $txt); @@ -35,18 +35,18 @@ var_dump($zip->setCompressionIndex(5, ZipArchive::CM_DEFLATE)); var_dump($zip->setCompressionIndex(6, ZipArchive::CM_DEFAULT)); if (!$zip->close()) { - exit('failed'); + exit('failed'); } // check the ZIP file $zip = zip_open($tmpfile); if (!is_resource($zip)) { - exit('failed'); + exit('failed'); } while ($e = zip_read($zip)) { - echo zip_entry_name($e) . ': ' . zip_entry_compressionmethod($e) . "\n"; + echo zip_entry_name($e) . ': ' . zip_entry_compressionmethod($e) . "\n"; } zip_close($zip); ?> diff --git a/ext/zip/tests/oo_setmtime.phpt b/ext/zip/tests/oo_setmtime.phpt index aa1ceb56bb7b..628f5ac8bbcc 100644 --- a/ext/zip/tests/oo_setmtime.phpt +++ b/ext/zip/tests/oo_setmtime.phpt @@ -18,7 +18,7 @@ $file = $dirname . '__tmp_oo_set_mtime.zip'; $zip = new ZipArchive; if (!$zip->open($file, ZIPARCHIVE::CREATE)) { - exit('failed'); + exit('failed'); } $zip->addFromString('foo', 'entry #1'); @@ -42,13 +42,13 @@ $s = $zip->statIndex(1); // ONLY with 1.6.0 - var_dump($s['mtime'] == $t2); if (!$zip->status == ZIPARCHIVE::ER_OK) { - echo "failed to write zip\n"; + echo "failed to write zip\n"; } $zip->close(); if (!$zip->open($file)) { - @unlink($file); - exit('failed'); + @unlink($file); + exit('failed'); } echo "Get 1\n"; diff --git a/ext/zip/tests/oo_stream.phpt b/ext/zip/tests/oo_stream.phpt index 89a2711666d4..d5e58a49a00d 100644 --- a/ext/zip/tests/oo_stream.phpt +++ b/ext/zip/tests/oo_stream.phpt @@ -11,7 +11,7 @@ $file = $dirname . 'test_with_comment.zip'; include $dirname . 'utils.inc'; $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } $fp = $zip->getStream('foo'); @@ -19,7 +19,7 @@ var_dump($fp); if(!$fp) exit("\n"); $contents = ''; while (!feof($fp)) { - $contents .= fread($fp, 255); + $contents .= fread($fp, 255); } fclose($fp); diff --git a/ext/zip/tests/pecl12414.phpt b/ext/zip/tests/pecl12414.phpt index 1b728c0ebc0b..738ed6dd10b9 100644 --- a/ext/zip/tests/pecl12414.phpt +++ b/ext/zip/tests/pecl12414.phpt @@ -12,24 +12,24 @@ $zipname = __DIR__ . "/pecl12414.zip"; $za = new ZipArchive(); $res =$za->open($zipname); if ($res === TRUE) { - $finfo=$za->statName($filename); - $file_size=$finfo['size']; + $finfo=$za->statName($filename); + $file_size=$finfo['size']; - if($file_size>0) { - $contents=$za->getFromName($filename); + if($file_size>0) { + $contents=$za->getFromName($filename); - echo "ZIP contents size: " . strlen($contents) . "\n"; - if(strlen($contents)!=$file_size) { - echo "zip_readfile recorded data does not match unpacked size: " . $zipname . " : " . $filename; - } - } else { - $contents=false; - echo "zip_readfile could not open stream from zero length file " . $zipname . " : " .$filename; - } + echo "ZIP contents size: " . strlen($contents) . "\n"; + if(strlen($contents)!=$file_size) { + echo "zip_readfile recorded data does not match unpacked size: " . $zipname . " : " . $filename; + } + } else { + $contents=false; + echo "zip_readfile could not open stream from zero length file " . $zipname . " : " .$filename; + } - $za->close(); + $za->close(); } else { - echo "zip_readfile could not read from " . $zipname . " : " . $filename; + echo "zip_readfile could not read from " . $zipname . " : " . $filename; } ?> diff --git a/ext/zip/tests/stream_meta_data.phpt b/ext/zip/tests/stream_meta_data.phpt index 26453af134f4..735a2e0d7b59 100644 --- a/ext/zip/tests/stream_meta_data.phpt +++ b/ext/zip/tests/stream_meta_data.phpt @@ -11,7 +11,7 @@ $file = $dirname . 'test_with_comment.zip'; include $dirname . 'utils.inc'; $zip = new ZipArchive; if (!$zip->open($file)) { - exit('failed'); + exit('failed'); } $fp = $zip->getStream('foo'); diff --git a/ext/zip/tests/utils.inc b/ext/zip/tests/utils.inc index f44ab3af32c8..6d5049e558fe 100644 --- a/ext/zip/tests/utils.inc +++ b/ext/zip/tests/utils.inc @@ -9,7 +9,7 @@ function verify_entries($zip, $entries = []) { if (!in_array($stat["name"], $entries)) { $verified = false; } - + $found[] = $stat["name"]; } @@ -22,17 +22,17 @@ function verify_entries($zip, $entries = []) { /* recursively remove a directoryy */ function rmdir_rf($dir) { - if ($handle = opendir($dir)) { - while (false !== ($item = readdir($handle))) { - if ($item != "." && $item != "..") { - if (is_dir($dir . '/' . $item)) { - rmdir_rf($dir . '/' . $item); - } else { - unlink($dir . '/' . $item); - } - } - } - closedir($handle); - rmdir($dir); - } + if ($handle = opendir($dir)) { + while (false !== ($item = readdir($handle))) { + if ($item != "." && $item != "..") { + if (is_dir($dir . '/' . $item)) { + rmdir_rf($dir . '/' . $item); + } else { + unlink($dir . '/' . $item); + } + } + } + closedir($handle); + rmdir($dir); + } } diff --git a/ext/zlib/tests/bug60761.phpt b/ext/zlib/tests/bug60761.phpt index 04763be50460..37191c2739ff 100644 --- a/ext/zlib/tests/bug60761.phpt +++ b/ext/zlib/tests/bug60761.phpt @@ -19,14 +19,14 @@ $lens = array(); for ( $i=0 ; $i < 100 ; $i++ ) { - // can't use ob_gzhandler with zlib.output_compression - ob_start();//"ob_gzhandler"); - phpinfo(); - $html = ob_get_clean(); + // can't use ob_gzhandler with zlib.output_compression + ob_start();//"ob_gzhandler"); + phpinfo(); + $html = ob_get_clean(); - $len = strlen($html); + $len = strlen($html); - $lens[$len] = $len; + $lens[$len] = $len; } $lens = array_values($lens); diff --git a/ext/zlib/tests/bug67724.phpt b/ext/zlib/tests/bug67724.phpt index 1e5026f650a2..3edbb2ba2ccc 100644 --- a/ext/zlib/tests/bug67724.phpt +++ b/ext/zlib/tests/bug67724.phpt @@ -9,11 +9,11 @@ extension_loaded("zlib") or die("skip need ext/zlib"); echo "Test\n"; $f = fopen(__DIR__."/bug67724.gz.gz", "rb") - or die(current(error_get_last())); + or die(current(error_get_last())); stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]); stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]); for ($i = 0; !feof($f); $i += strlen(fread($f, 0x1000))) - ; + ; fclose($f); var_dump($i); diff --git a/ext/zlib/tests/bug71417.phpt b/ext/zlib/tests/bug71417.phpt index ae1390134e29..cadd1e67359a 100644 --- a/ext/zlib/tests/bug71417.phpt +++ b/ext/zlib/tests/bug71417.phpt @@ -6,10 +6,10 @@ Bug #71417: fread() does not detect decoding errors from filter zlib.inflate gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ... - echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; - file_put_contents($fn, $compressed); - - $r = fopen($fn, "r"); - stream_filter_append($r, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16)); - while (!feof($r)) { - $s = fread($r, 100); - echo "read: "; var_dump($s); - } - fclose($r); - unlink($fn); + // The gzdecode() function applied to the corrupted compressed data always + // detects the error: + // --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ... + echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n"; + + file_put_contents($fn, $compressed); + + $r = fopen($fn, "r"); + stream_filter_append($r, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16)); + while (!feof($r)) { + $s = fread($r, 100); + echo "read: "; var_dump($s); + } + fclose($r); + unlink($fn); } test(1); diff --git a/ext/zlib/tests/bug75273.phpt b/ext/zlib/tests/bug75273.phpt index 66ec81edff39..f3309546bdd0 100644 --- a/ext/zlib/tests/bug75273.phpt +++ b/ext/zlib/tests/bug75273.phpt @@ -7,22 +7,22 @@ if (!extension_loaded('zlib')) die('skip zlib extension not available'); --FILE-- 16 + 15]); - rewind($stream); - fwrite($stream, $in_data); - stream_filter_remove($deflate_filter); + $deflate_filter = stream_filter_append($stream, 'zlib.deflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); + rewind($stream); + fwrite($stream, $in_data); + stream_filter_remove($deflate_filter); - rewind($stream); - $out_data = stream_get_contents($stream); - $out_data_len = strlen($out_data); + rewind($stream); + $out_data = stream_get_contents($stream); + $out_data_len = strlen($out_data); - $inflate_filter = stream_filter_prepend($stream, 'zlib.inflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); - rewind($stream); - $fwrite_len = fwrite($stream, $out_data); - stream_filter_remove($inflate_filter); + $inflate_filter = stream_filter_prepend($stream, 'zlib.inflate', STREAM_FILTER_WRITE, ['window' => 16 + 15]); + rewind($stream); + $fwrite_len = fwrite($stream, $out_data); + stream_filter_remove($inflate_filter); - if ($out_data_len !== $fwrite_len) { - echo "bug i=$i out_data_len=$out_data_len fwrite_len=$fwrite_len\n"; - } + if ($out_data_len !== $fwrite_len) { + echo "bug i=$i out_data_len=$out_data_len fwrite_len=$fwrite_len\n"; + } } fclose($stream); diff --git a/ext/zlib/tests/bug_34821.phpt b/ext/zlib/tests/bug_34821.phpt index 53ef4d229e9c..8095bab23a9b 100644 --- a/ext/zlib/tests/bug_34821.phpt +++ b/ext/zlib/tests/bug_34821.phpt @@ -7,10 +7,10 @@ Bug #34821 (zlib encoders fail on widely varying binary data) // test 50 bytes to 50k $b = array( - 50, - 500, - 5000, - 50000, + 50, + 500, + 5000, + 50000, // 1000000, // works, but test would take too long ); @@ -18,12 +18,12 @@ $s = ''; $i = 0; foreach ($b as $size) { - do { - $s .= chr(rand(0,255)); - } while (++$i < $size); - var_dump($s === gzinflate(gzdeflate($s))); - var_dump($s === gzuncompress(gzcompress($s))); - var_dump($s === gzinflate(substr(gzencode($s), 10, -8))); + do { + $s .= chr(rand(0,255)); + } while (++$i < $size); + var_dump($s === gzinflate(gzdeflate($s))); + var_dump($s === gzuncompress(gzcompress($s))); + var_dump($s === gzinflate(substr(gzencode($s), 10, -8))); } ?> --EXPECT-- diff --git a/ext/zlib/tests/func.inc b/ext/zlib/tests/func.inc index 7556f81e6a5a..73cfc4e06ffc 100644 --- a/ext/zlib/tests/func.inc +++ b/ext/zlib/tests/func.inc @@ -2,17 +2,17 @@ function get_zlib_version() { - $version = NULL; + $version = NULL; - ob_start(); - phpinfo(); - $info = ob_get_contents(); - ob_end_clean(); - //if (preg_match(',zlib.*Compiled Version => (\d+\.\d+\.\d+),s', $info, $match)) { - // $version = $match[1]; - if (preg_match(',zlib(?!.*libXML).*Compiled Version (=> | (\d+\.\d+\.\d+),s', $info, $match)) { + // $version = $match[1]; + if (preg_match(',zlib(?!.*libXML).*Compiled Version (=> | diff --git a/ext/zlib/tests/gzopen_include_path.inc b/ext/zlib/tests/gzopen_include_path.inc index add04f74de84..ca3da434892a 100644 --- a/ext/zlib/tests/gzopen_include_path.inc +++ b/ext/zlib/tests/gzopen_include_path.inc @@ -11,82 +11,82 @@ $newdirs = array($dir1, $dir2, $dir3); $reldirs = array("dir1", "dir2", "dir3"); function generate_next_rel_path() { - global $reldirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($reldirs as $newdir) { - $newIncludePath .= $newdir.$pathSep; - } - return "dir4".$pathSep . $newIncludePath; + global $reldirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($reldirs as $newdir) { + $newIncludePath .= $newdir.$pathSep; + } + return "dir4".$pathSep . $newIncludePath; } function generate_next_path() { - global $newdirs, $dir4; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($newdirs as $newdir) { - $newIncludePath .= $newdir.$pathSep; - } - return $dir4.$pathSep . $newIncludePath; + global $newdirs, $dir4; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($newdirs as $newdir) { + $newIncludePath .= $newdir.$pathSep; + } + return $dir4.$pathSep . $newIncludePath; } function create_include_path() { - global $newdirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($newdirs as $newdir) { - mkdir($newdir); - $newIncludePath .= $newdir.$pathSep; - } - return $newIncludePath; + global $newdirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($newdirs as $newdir) { + mkdir($newdir); + $newIncludePath .= $newdir.$pathSep; + } + return $newIncludePath; } function relative_include_path() { - global $reldirs; - //create the include directory structure - $pathSep = ":"; - $newIncludePath = ""; - if(substr(PHP_OS, 0, 3) == 'WIN' ) { - $pathSep = ";"; - } - foreach($reldirs as $newdir) { - mkdir($newdir); - $newIncludePath .= $newdir.$pathSep; - } - return $newIncludePath; + global $reldirs; + //create the include directory structure + $pathSep = ":"; + $newIncludePath = ""; + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + $pathSep = ";"; + } + foreach($reldirs as $newdir) { + mkdir($newdir); + $newIncludePath .= $newdir.$pathSep; + } + return $newIncludePath; } function teardown_include_path() { - global $newdirs; - // remove the directory structure - foreach($newdirs as $newdir) { - rmdir($newdir); - } + global $newdirs; + // remove the directory structure + foreach($newdirs as $newdir) { + rmdir($newdir); + } } function teardown_relative_path() { - global $reldirs; - // remove the directory structure - foreach($reldirs as $newdir) { - rmdir($newdir); - } + global $reldirs; + // remove the directory structure + foreach($reldirs as $newdir) { + rmdir($newdir); + } } ?> diff --git a/ext/zlib/tests/gzopen_variation5.phpt b/ext/zlib/tests/gzopen_variation5.phpt index 825c42700798..661ffe8759a0 100644 --- a/ext/zlib/tests/gzopen_variation5.phpt +++ b/ext/zlib/tests/gzopen_variation5.phpt @@ -33,31 +33,31 @@ chdir(".."); rmdir($thisTestDir); function runtest() { - $tmpfile = 'gzopen_variation5.tmp'; - $h = gzopen($tmpfile, "w", true); - fwrite($h, "This is the test file"); - fclose($h); + $tmpfile = 'gzopen_variation5.tmp'; + $h = gzopen($tmpfile, "w", true); + fwrite($h, "This is the test file"); + fclose($h); - $h = @gzopen($tmpfile, "r"); - if ($h === false) { - echo "Not created in working dir\n"; - } - else { - echo "created in working dir\n"; - gzclose($h); - unlink($tmpfile); - } + $h = @gzopen($tmpfile, "r"); + if ($h === false) { + echo "Not created in working dir\n"; + } + else { + echo "created in working dir\n"; + gzclose($h); + unlink($tmpfile); + } - $h = @gzopen('dir1/'.$tmpfile, "r"); - if ($h === false) { - echo "Not created in dir1\n"; - } - else { - echo "created in dir1\n"; - gzclose($h); - unlink('dir1/'.$tmpfile); - } + $h = @gzopen('dir1/'.$tmpfile, "r"); + if ($h === false) { + echo "Not created in dir1\n"; + } + else { + echo "created in dir1\n"; + gzclose($h); + unlink('dir1/'.$tmpfile); + } } ?> --EXPECT-- diff --git a/ext/zlib/tests/gzreadgzwrite.phpt b/ext/zlib/tests/gzreadgzwrite.phpt index 87b55e673ffb..f2f2370f36c8 100644 --- a/ext/zlib/tests/gzreadgzwrite.phpt +++ b/ext/zlib/tests/gzreadgzwrite.phpt @@ -18,14 +18,14 @@ $fp = gzopen($filename, "rb"); $data = ''; while ($buf = gzread($fp, 8092)) { - $data .= $buf; + $data .= $buf; } if ($data == $original) { - echo "Strings are equal\n"; + echo "Strings are equal\n"; } else { - echo "Strings are not equal\n"; - var_dump($data); + echo "Strings are not equal\n"; + var_dump($data); } gzclose($fp); unlink($filename); diff --git a/ext/zlib/tests/gzreadgzwriteplain.phpt b/ext/zlib/tests/gzreadgzwriteplain.phpt index 0d73f022aa74..8898cebb93e3 100644 --- a/ext/zlib/tests/gzreadgzwriteplain.phpt +++ b/ext/zlib/tests/gzreadgzwriteplain.phpt @@ -18,29 +18,29 @@ $fp = gzopen($filename, "rb"); $data = ''; while ($buf = gzread($fp, 8192)) { - $data .= $buf; + $data .= $buf; } if ($data == $original) { - echo "Strings are equal\n"; + echo "Strings are equal\n"; } else { - echo "Strings are not equal\n"; - var_dump($data); + echo "Strings are not equal\n"; + var_dump($data); } gzseek($fp, strlen($original) / 2); $data = ''; while ($buf = gzread($fp, 8192)) { - $data .= $buf; + $data .= $buf; } var_dump(strlen($data)); if ($data == substr($original, strlen($original) / 2)) { - echo "Strings are equal\n"; + echo "Strings are equal\n"; } else { - echo "Strings are not equal\n"; - var_dump($data); + echo "Strings are not equal\n"; + var_dump($data); } gzclose($fp); diff --git a/ext/zlib/tests/ob_gzhandler_legacy_002.phpt b/ext/zlib/tests/ob_gzhandler_legacy_002.phpt index 217a0d2e35bf..5e940b618718 100644 --- a/ext/zlib/tests/ob_gzhandler_legacy_002.phpt +++ b/ext/zlib/tests/ob_gzhandler_legacy_002.phpt @@ -14,8 +14,8 @@ dummy=42 --FILE-- diff --git a/sapi/cgi/tests/003.phpt b/sapi/cgi/tests/003.phpt index 4b4d29267d98..00c59c72784a 100644 --- a/sapi/cgi/tests/003.phpt +++ b/sapi/cgi/tests/003.phpt @@ -23,12 +23,12 @@ $code =' /* some test script */ class test { /* {{{ */ - public $var = "test"; //test var -#perl style comment - private $pri; /* private attr */ + public $var = "test"; //test var +#perl style comment + private $pri; /* private attr */ - function foo(/* void */) { - } + function foo(/* void */) { + } } /* }}} */ diff --git a/sapi/cgi/tests/004.phpt b/sapi/cgi/tests/004.phpt index b46dce70526d..1de856e34672 100644 --- a/sapi/cgi/tests/004.phpt +++ b/sapi/cgi/tests/004.phpt @@ -17,7 +17,7 @@ $code =' /dev/null`); + var_dump(`$php -n -f "$filename" 2>/dev/null`); } var_dump(`$php -n -f "wrong"`); diff --git a/sapi/cgi/tests/006.phpt b/sapi/cgi/tests/006.phpt index c78229880c63..479d4a9441f2 100644 --- a/sapi/cgi/tests/006.phpt +++ b/sapi/cgi/tests/006.phpt @@ -19,7 +19,7 @@ $code = ' $test = "var"; class test { - private $var; + private $var; } echo test::$var; @@ -35,8 +35,8 @@ var_dump(`"$php" -n -l some.unknown`); $code = ' @@ -45,9 +45,9 @@ class test file_put_contents($filename, $code); if (defined("PHP_WINDOWS_VERSION_MAJOR")) { - var_dump(`"$php" -n -l "$filename"`); + var_dump(`"$php" -n -l "$filename"`); } else { - var_dump(`"$php" -n -l "$filename" 2>/dev/null`); + var_dump(`"$php" -n -l "$filename" 2>/dev/null`); } @unlink($filename); diff --git a/sapi/cgi/tests/008.phpt b/sapi/cgi/tests/008.phpt index be2fd578e7e6..05d9d8c190e8 100644 --- a/sapi/cgi/tests/008.phpt +++ b/sapi/cgi/tests/008.phpt @@ -16,12 +16,12 @@ $code = ' $test = "var"; //var /* test class */ class test { - private $var = array(); + private $var = array(); - public static function foo(Test $arg) { - echo "hello"; - var_dump($this); - } + public static function foo(Test $arg) { + echo "hello"; + var_dump($this); + } } $o = new test; diff --git a/sapi/cgi/tests/011.phpt b/sapi/cgi/tests/011.phpt index 6d4a6ed7f90d..263c2e61ef81 100644 --- a/sapi/cgi/tests/011.phpt +++ b/sapi/cgi/tests/011.phpt @@ -13,13 +13,13 @@ reset_env_vars(); $f = tempnam(sys_get_temp_dir(), 'cgitest'); function test($script) { - file_put_contents($GLOBALS['f'], $script); - $cmd = escapeshellcmd($GLOBALS['php']); - $cmd .= ' -n -dreport_zend_debug=0 -dhtml_errors=0 ' . escapeshellarg($GLOBALS['f']); - echo "----------\n"; - echo rtrim($script) . "\n"; - echo "----------\n"; - passthru($cmd); + file_put_contents($GLOBALS['f'], $script); + $cmd = escapeshellcmd($GLOBALS['php']); + $cmd .= ' -n -dreport_zend_debug=0 -dhtml_errors=0 ' . escapeshellarg($GLOBALS['f']); + echo "----------\n"; + echo rtrim($script) . "\n"; + echo "----------\n"; + passthru($cmd); } test(''); diff --git a/sapi/cgi/tests/apache_request_headers.phpt b/sapi/cgi/tests/apache_request_headers.phpt index bda9ef8b70f2..647508a64ad1 100644 --- a/sapi/cgi/tests/apache_request_headers.phpt +++ b/sapi/cgi/tests/apache_request_headers.phpt @@ -21,9 +21,9 @@ passthru("$php -n $file"); $names = array('HTTP_X_TEST', 'HTTP_X__TEST', 'HTTP_X_'); foreach ($names as $name) { - putenv($name."=".str_repeat("A", 256)); - passthru("$php -n -q $file"); - putenv($name); + putenv($name."=".str_repeat("A", 256)); + passthru("$php -n -q $file"); + putenv($name); } unlink($file); diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc index 61b339e49f76..cd9236f11603 100644 --- a/sapi/cgi/tests/include.inc +++ b/sapi/cgi/tests/include.inc @@ -2,64 +2,64 @@ function get_cgi_path() /* {{{ */ { - $php = getenv("TEST_PHP_EXECUTABLE"); + $php = getenv("TEST_PHP_EXECUTABLE"); - $cli = false; - $cgi = false; + $cli = false; + $cgi = false; - if (file_exists($php) && is_executable($php)) { - $version = `$php -n -v`; - if (strstr($version, "(cli)")) { - /* that's cli */ - $cli = true; - } else if (strpos($version, "(cgi")) { - /* that's cgi */ - return $php; - } - } + if (file_exists($php) && is_executable($php)) { + $version = `$php -n -v`; + if (strstr($version, "(cli)")) { + /* that's cli */ + $cli = true; + } else if (strpos($version, "(cgi")) { + /* that's cgi */ + return $php; + } + } - if ($cli) { - /* trying to guess ... */ - $php_path = $php; - if (defined("PHP_WINDOWS_VERSION_MAJOR")) { - /* On Windows it should be in the same dir as php.exe in most of the cases. */ - $php_path = dirname($php); + if ($cli) { + /* trying to guess ... */ + $php_path = $php; + if (defined("PHP_WINDOWS_VERSION_MAJOR")) { + /* On Windows it should be in the same dir as php.exe in most of the cases. */ + $php_path = dirname($php); - if (is_dir($php_path) && file_exists("$php_path/php-cgi.exe") && is_executable("$php_path/php-cgi.exe")) { - return "$php_path/php-cgi.exe"; - } - } else { - for ($i = 0; $i < 2; $i++) { - $slash_pos = strrpos($php_path, "/"); - if ($slash_pos) { - $php_path = substr($php_path, 0, $slash_pos); - } else { - return FALSE; - } - } + if (is_dir($php_path) && file_exists("$php_path/php-cgi.exe") && is_executable("$php_path/php-cgi.exe")) { + return "$php_path/php-cgi.exe"; + } + } else { + for ($i = 0; $i < 2; $i++) { + $slash_pos = strrpos($php_path, "/"); + if ($slash_pos) { + $php_path = substr($php_path, 0, $slash_pos); + } else { + return FALSE; + } + } - if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) { - /* gotcha */ - return $php_path."/cgi/php-cgi"; - } - } - return false; - } - /* uhm? what's that then? */ - return false; + if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) { + /* gotcha */ + return $php_path."/cgi/php-cgi"; + } + } + return false; + } + /* uhm? what's that then? */ + return false; } /* }}} */ function reset_env_vars() /* {{{ */ { - putenv("REDIRECT_STATUS"); - putenv("QUERY_STRING"); - putenv("PATH_TRANSLATED"); - putenv("SCRIPT_FILENAME"); - putenv("SERVER_SOFTWARE"); - putenv("SERVER_NAME"); - putenv("GATEWAY_INTERFACE"); - putenv("REQUEST_METHOD"); + putenv("REDIRECT_STATUS"); + putenv("QUERY_STRING"); + putenv("PATH_TRANSLATED"); + putenv("SCRIPT_FILENAME"); + putenv("SERVER_SOFTWARE"); + putenv("SERVER_NAME"); + putenv("GATEWAY_INTERFACE"); + putenv("REQUEST_METHOD"); } /* }}} */ diff --git a/sapi/cgi/tests/skipif.inc b/sapi/cgi/tests/skipif.inc index d2cef235895e..2145a9e4104f 100644 --- a/sapi/cgi/tests/skipif.inc +++ b/sapi/cgi/tests/skipif.inc @@ -1,13 +1,13 @@ diff --git a/sapi/cli/tests/007.phpt b/sapi/cli/tests/007.phpt index 51858bae4869..94ea6fd24745 100644 --- a/sapi/cli/tests/007.phpt +++ b/sapi/cli/tests/007.phpt @@ -18,12 +18,12 @@ $code =' /* some test script */ class test { /* {{{ */ - public $var = "test"; //test var -#perl style comment - private $pri; /* private attr */ + public $var = "test"; //test var +#perl style comment + private $pri; /* private attr */ - function foo(/* void */) { - } + function foo(/* void */) { + } } /* }}} */ diff --git a/sapi/cli/tests/008.phpt b/sapi/cli/tests/008.phpt index fb8518535afd..c96170d4979b 100644 --- a/sapi/cli/tests/008.phpt +++ b/sapi/cli/tests/008.phpt @@ -17,7 +17,7 @@ $code =' diff --git a/sapi/cli/tests/014.phpt b/sapi/cli/tests/014.phpt index 1ee72e05f6ac..4a458d2ae79a 100644 --- a/sapi/cli/tests/014.phpt +++ b/sapi/cli/tests/014.phpt @@ -13,12 +13,12 @@ $code = ' $test = "var"; //var /* test class */ class test { - private $var = array(); + private $var = array(); - public static function foo(Test $arg) { - echo "hello"; - var_dump($this); - } + public static function foo(Test $arg) { + echo "hello"; + var_dump($this); + } } $o = new test; diff --git a/sapi/cli/tests/016.phpt b/sapi/cli/tests/016.phpt index ea735d8d6e21..bbba579ec2b2 100644 --- a/sapi/cli/tests/016.phpt +++ b/sapi/cli/tests/016.phpt @@ -52,9 +52,9 @@ a_function_w ); EOT; foreach ($codes as $key => $code) { - echo "\n--------------\nSnippet no. $key:\n--------------\n"; - $code = escapeshellarg($code); - echo `echo $code | "$php" -a`, "\n"; + echo "\n--------------\nSnippet no. $key:\n--------------\n"; + $code = escapeshellarg($code); + echo `echo $code | "$php" -a`, "\n"; } echo "\nDone\n"; diff --git a/sapi/cli/tests/017.phpt b/sapi/cli/tests/017.phpt index 684e41691e3b..4cc80a4b0aee 100644 --- a/sapi/cli/tests/017.phpt +++ b/sapi/cli/tests/017.phpt @@ -52,9 +52,9 @@ a_function_w ); EOT; foreach ($codes as $key => $code) { - echo "\n--------------\nSnippet no. $key:\n--------------\n"; - $code = escapeshellarg($code); - echo `echo $code | "$php" -a`, "\n"; + echo "\n--------------\nSnippet no. $key:\n--------------\n"; + $code = escapeshellarg($code); + echo `echo $code | "$php" -a`, "\n"; } echo "\nDone\n"; diff --git a/sapi/cli/tests/022.phpt b/sapi/cli/tests/022.phpt index 3b97016b58b3..40c226535184 100644 --- a/sapi/cli/tests/022.phpt +++ b/sapi/cli/tests/022.phpt @@ -11,23 +11,23 @@ $php = getenv("TEST_PHP_EXECUTABLE"); $socket_file = tempnam(sys_get_temp_dir(), pathinfo(__FILE__, PATHINFO_FILENAME) . '.sock'); $test_file = __DIR__ . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc'; if (file_exists($socket_file)) { - unlink($socket_file); + unlink($socket_file); } $socket = stream_socket_server('unix://' . $socket_file); var_dump($socket); if (!$socket) { - exit(1); + exit(1); } $desc = array( - 0 => $socket, - 1 => STDOUT, - 2 => STDERR, + 0 => $socket, + 1 => STDOUT, + 2 => STDERR, ); $pipes = array(); $proc = proc_open("$php -n " . escapeshellarg($test_file), $desc, $pipes); var_dump($proc); if (!$proc) { - exit(1); + exit(1); } $client_socket = stream_socket_client('unix://' . $socket_file); diff --git a/sapi/cli/tests/023.phpt b/sapi/cli/tests/023.phpt index 09b256a9af0e..4f827ff3871f 100644 --- a/sapi/cli/tests/023.phpt +++ b/sapi/cli/tests/023.phpt @@ -22,14 +22,14 @@ memory_limit = 70M INI ); $desc = array( - 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w"), + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w"), ); $pipes = array(); $proc = proc_open("$php -c $ini_file -r 'echo ini_get(\"memory_limit\");'", $desc, $pipes); if (!$proc) { - exit(1); + exit(1); } var_dump(stream_get_contents($pipes[1])); var_dump(stream_get_contents($pipes[2])); diff --git a/sapi/cli/tests/bug43177.phpt b/sapi/cli/tests/bug43177.phpt index 87dc8927ff10..f36019ba6bf4 100644 --- a/sapi/cli/tests/bug43177.phpt +++ b/sapi/cli/tests/bug43177.phpt @@ -8,30 +8,30 @@ include "skipif.inc"; diff --git a/sapi/cli/tests/bug64529.phpt b/sapi/cli/tests/bug64529.phpt index 7331b8303ecd..ff3e3029e63d 100644 --- a/sapi/cli/tests/bug64529.phpt +++ b/sapi/cli/tests/bug64529.phpt @@ -20,7 +20,7 @@ $php_executable = getenv('TEST_PHP_EXECUTABLE'); $script = __DIR__ . "/expect.sh"; if (extension_loaded("readline")) { - $expect_script = <<