diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:39:08 -0400 |
| commit | 993e1866df547532a05ab6db76c9ff5aefc9a3df (patch) | |
| tree | 169d3bde0974235d3cde164786ef6f381a4749a7 /tests | |
| parent | 1f589a2bd44ba835ad1b009a5d83abd453724829 (diff) | |
| download | php-upstream/5.2.6.tar.gz | |
Imported Upstream version 5.2.6upstream/5.2.6
Diffstat (limited to 'tests')
101 files changed, 2568 insertions, 29 deletions
diff --git a/tests/basic/026.phpt b/tests/basic/026.phpt index 3d0d9df1e..ec93ae5d4 100644 --- a/tests/basic/026.phpt +++ b/tests/basic/026.phpt @@ -15,5 +15,4 @@ var_dump($_POST, $HTTP_RAW_POST_DATA); --EXPECT-- array(0) { } -string(10) "a=1&b=ZYX -"
\ No newline at end of file +string(9) "a=1&b=ZYX" diff --git a/tests/classes/__call_003.phpt b/tests/classes/__call_003.phpt new file mode 100644 index 000000000..c7aa95cb0 --- /dev/null +++ b/tests/classes/__call_003.phpt @@ -0,0 +1,33 @@ +--TEST-- +Force pass-by-reference to __call +--FILE-- +<?php + class C + { + function __call($name, $values) + { + $values[0][0] = 'changed'; + } + } + + $a = array('original'); + + $b = array('original'); + $hack =& $b[0]; + + $c = new C; + $c->f($a); + $c->f($b); + + var_dump($a, $b); +?> +--EXPECTF-- +array(1) { + [0]=> + string(8) "original" +} +array(1) { + [0]=> + &string(7) "changed" +} + diff --git a/tests/classes/__call_004.phpt b/tests/classes/__call_004.phpt new file mode 100644 index 000000000..2072112a0 --- /dev/null +++ b/tests/classes/__call_004.phpt @@ -0,0 +1,41 @@ +--TEST-- +When __call() is invoked via ::, ensure current scope's __call() is favoured over the specified class's __call(). +--FILE-- +<?php +class A { + function __call($strMethod, $arrArgs) { + echo "In " . __METHOD__ . "($strMethod, array(" . implode(',',$arrArgs) . "))\n"; + var_dump($this); + } +} + +class B extends A { + function __call($strMethod, $arrArgs) { + echo "In " . __METHOD__ . "($strMethod, array(" . implode(',',$arrArgs) . "))\n"; + var_dump($this); + } + + function test() { + A::test1(1,'a'); + B::test2(1,'a'); + self::test3(1,'a'); + parent::test4(1,'a'); + } +} + +$b = new B(); +$b->test(); +?> +--EXPECTF-- +In B::__call(test1, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test2, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test3, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test4, array(1,a)) +object(B)#1 (0) { +}
\ No newline at end of file diff --git a/tests/classes/__call_005.phpt b/tests/classes/__call_005.phpt new file mode 100644 index 000000000..c82a853f7 --- /dev/null +++ b/tests/classes/__call_005.phpt @@ -0,0 +1,36 @@ +--TEST-- +When __call() is invoked via ::, ensure private implementation of __call() in superclass is accessed without error. +--FILE-- +<?php +class A { + private function __call($strMethod, $arrArgs) { + echo "In " . __METHOD__ . "($strMethod, array(" . implode(',',$arrArgs) . "))\n"; + var_dump($this); + } +} + +class B extends A { + function test() { + A::test1(1,'a'); + B::test2(1,'a'); + self::test3(1,'a'); + parent::test4(1,'a'); + } +} + +$b = new B(); +$b->test(); +?> +--EXPECTF-- +In A::__call(test1, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test2, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test3, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test4, array(1,a)) +object(B)#1 (0) { +}
\ No newline at end of file diff --git a/tests/classes/array_access_009.phpt b/tests/classes/array_access_009.phpt index 32573f5a4..b1382a639 100755 --- a/tests/classes/array_access_009.phpt +++ b/tests/classes/array_access_009.phpt @@ -129,9 +129,9 @@ string(6) "FooBar" string(9) "FooBarBaz" ===ArrayOverloading=== ArrayProxy::__construct(0) -object(ArrayProxy)#1 (2) { +object(ArrayProxy)#%d (2) { ["object:private"]=> - object(Peoples)#2 (1) { + object(Peoples)#%d (1) { ["person"]=> array(1) { [0]=> @@ -166,9 +166,9 @@ string(12) "FooBarBarBaz" ArrayProxy::__construct(0) ArrayProxy::offsetUnset(0, name) ArrayProxy::__construct(0) -object(ArrayProxy)#1 (2) { +object(ArrayProxy)#%d (2) { ["object:private"]=> - object(Peoples)#2 (1) { + object(Peoples)#%d (1) { ["person"]=> array(1) { [0]=> diff --git a/tests/classes/array_access_010.phpt b/tests/classes/array_access_010.phpt index 05a169b2f..9cb883d98 100755 --- a/tests/classes/array_access_010.phpt +++ b/tests/classes/array_access_010.phpt @@ -103,9 +103,9 @@ string(6) "FooBar" string(9) "FooBarBaz" ===ArrayOverloading=== ArrayReferenceProxy::__construct(Array) -object(ArrayReferenceProxy)#1 (2) { +object(ArrayReferenceProxy)#%d (2) { ["object:private"]=> - object(Peoples)#2 (1) { + object(Peoples)#%d (1) { ["person"]=> array(1) { [0]=> @@ -143,9 +143,9 @@ string(12) "FooBarBarBaz" ArrayReferenceProxy::__construct(Array) ArrayReferenceProxy::offsetUnset(Array, name) ArrayReferenceProxy::__construct(Array) -object(ArrayReferenceProxy)#1 (2) { +object(ArrayReferenceProxy)#%d (2) { ["object:private"]=> - object(Peoples)#2 (1) { + object(Peoples)#%d (1) { ["person"]=> array(1) { [0]=> diff --git a/tests/classes/array_access_011.phpt b/tests/classes/array_access_011.phpt index 20d39568b..a6bb3d1ca 100755 --- a/tests/classes/array_access_011.phpt +++ b/tests/classes/array_access_011.phpt @@ -112,9 +112,9 @@ string(6) "FooBar" string(9) "FooBarBaz" ===ArrayOverloading=== ArrayAccessReferenceProxy::__construct(0) -object(ArrayAccessReferenceProxy)#1 (3) { +object(ArrayAccessReferenceProxy)#%d (3) { ["object:private"]=> - object(Peoples)#2 (1) { + object(Peoples)#%d (1) { ["person"]=> &array(1) { [0]=> @@ -157,9 +157,9 @@ string(12) "FooBarBarBaz" ArrayAccessReferenceProxy::__construct(0) ArrayAccessReferenceProxy::offsetUnset(0, name) ArrayAccessReferenceProxy::__construct(0) -object(ArrayAccessReferenceProxy)#1 (3) { +object(ArrayAccessReferenceProxy)#%d (3) { ["object:private"]=> - object(Peoples)#2 (1) { + object(Peoples)#%d (1) { ["person"]=> &array(1) { [0]=> diff --git a/tests/classes/assign_op_property_001.phpt b/tests/classes/assign_op_property_001.phpt index 54e519e8f..21e131cfa 100644 --- a/tests/classes/assign_op_property_001.phpt +++ b/tests/classes/assign_op_property_001.phpt @@ -7,13 +7,13 @@ class Test { private $real_a = 2; function __set($property, $value) { - if ($property = "a") { + if ($property == "a") { $this->real_a = $value; } } function __get($property) { - if ($property = "a") { + if ($property == "a") { return $this->real_a; } } diff --git a/tests/classes/autoload_007.phpt b/tests/classes/autoload_007.phpt new file mode 100644 index 000000000..5652c120c --- /dev/null +++ b/tests/classes/autoload_007.phpt @@ -0,0 +1,15 @@ +--TEST-- +Ensure instanceof does not trigger autoload. +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + $a = new stdClass; + var_dump($a instanceof UndefC); +?> +--EXPECTF-- +bool(false) diff --git a/tests/classes/autoload_008.phpt b/tests/classes/autoload_008.phpt new file mode 100644 index 000000000..75a9cd052 --- /dev/null +++ b/tests/classes/autoload_008.phpt @@ -0,0 +1,26 @@ +--TEST-- +Ensure catch blocks for unknown exception types do not trigger autoload. +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + function f() + { + throw new Exception(); + } + try { + f(); + } + catch (UndefC $u) { + echo "In UndefClass catch block.\n"; + } + catch (Exception $e) { + echo "In Exception catch block. Autoload should not have been triggered.\n"; + } +?> +--EXPECTF-- +In Exception catch block. Autoload should not have been triggered. diff --git a/tests/classes/autoload_009.phpt b/tests/classes/autoload_009.phpt new file mode 100644 index 000000000..46f6055fe --- /dev/null +++ b/tests/classes/autoload_009.phpt @@ -0,0 +1,20 @@ +--TEST-- +Ensure type hints for unknown types do not trigger autoload. +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + function f(UndefClass $x) + { + } + f(new stdClass); +?> +--EXPECTF-- + +Catchable fatal error: Argument 1 passed to f() must be an instance of UndefClass, instance of stdClass given, called in %s + + diff --git a/tests/classes/autoload_010.phpt b/tests/classes/autoload_010.phpt new file mode 100644 index 000000000..104f6888c --- /dev/null +++ b/tests/classes/autoload_010.phpt @@ -0,0 +1,18 @@ +--TEST-- +Ensure implements does trigger autoload. +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + class C implements UndefI + { + } +?> +--EXPECTF-- +In autoload: string(6) "UndefI" + +Fatal error: Interface 'UndefI' not found in %s on line %d diff --git a/tests/classes/autoload_011.phpt b/tests/classes/autoload_011.phpt new file mode 100644 index 000000000..86858d5f1 --- /dev/null +++ b/tests/classes/autoload_011.phpt @@ -0,0 +1,18 @@ +--TEST-- +Ensure extends does trigger autoload. +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + class C extends UndefBase + { + } +?> +--EXPECTF-- +In autoload: string(9) "UndefBase" + +Fatal error: Class 'UndefBase' not found in %s on line %d diff --git a/tests/classes/autoload_012.phpt b/tests/classes/autoload_012.phpt new file mode 100644 index 000000000..1f516cb4b --- /dev/null +++ b/tests/classes/autoload_012.phpt @@ -0,0 +1,16 @@ +--TEST-- +Ensure callback methods in unknown classes trigger autoload. +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + call_user_func("UndefC::test"); +?> +--EXPECTF-- +In autoload: string(6) "UndefC" + +Warning: call_user_func(UndefC::test): First argument is expected to be a valid callback in %s on line %d + diff --git a/tests/classes/autoload_013.phpt b/tests/classes/autoload_013.phpt new file mode 100644 index 000000000..4309cea17 --- /dev/null +++ b/tests/classes/autoload_013.phpt @@ -0,0 +1,22 @@ +--TEST-- +Ensure the ReflectionClass constructor triggers autoload. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + try { + new ReflectionClass("UndefC"); + } + catch (ReflectionException $e) { + echo $e->getMessage(); + } +?> +--EXPECTF-- +In autoload: string(6) "UndefC" +Class UndefC does not exist diff --git a/tests/classes/autoload_014.phpt b/tests/classes/autoload_014.phpt new file mode 100644 index 000000000..a3f04b7b5 --- /dev/null +++ b/tests/classes/autoload_014.phpt @@ -0,0 +1,22 @@ +--TEST-- +Ensure the ReflectionMethod constructor triggers autoload. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + try { + new ReflectionMethod("UndefC::test"); + } + catch (ReflectionException $e) { + echo $e->getMessage(); + } +?> +--EXPECTF-- +In autoload: string(6) "UndefC" +Class UndefC does not exist diff --git a/tests/classes/autoload_015.phpt b/tests/classes/autoload_015.phpt new file mode 100644 index 000000000..2b14a0de0 --- /dev/null +++ b/tests/classes/autoload_015.phpt @@ -0,0 +1,22 @@ +--TEST-- +Ensure the ReflectionProperty constructor triggers autoload. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + try { + new ReflectionProperty('UndefC', 'p'); + } + catch (ReflectionException $e) { + echo $e->getMessage(); + } +?> +--EXPECTF-- +In autoload: string(6) "UndefC" +Class UndefC does not exist diff --git a/tests/classes/autoload_016.phpt b/tests/classes/autoload_016.phpt new file mode 100644 index 000000000..60263ba95 --- /dev/null +++ b/tests/classes/autoload_016.phpt @@ -0,0 +1,23 @@ +--TEST-- +Ensure ReflectionClass::getProperty() triggers autoload +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + $rc = new ReflectionClass("stdClass"); + + try { + $rc->getProperty("UndefC::p"); + } catch (ReflectionException $e) { + echo $e->getMessage(); + } +?> +--EXPECTF-- +In autoload: string(6) "undefc" +Class undefc does not exist diff --git a/tests/classes/autoload_017.phpt b/tests/classes/autoload_017.phpt new file mode 100644 index 000000000..26de9fd3a --- /dev/null +++ b/tests/classes/autoload_017.phpt @@ -0,0 +1,23 @@ +--TEST-- +Ensure ReflectionClass::implementsInterface triggers autoload. +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + function __autoload($name) + { + echo "In autoload: "; + var_dump($name); + } + + $rc = new ReflectionClass("stdClass"); + + try { + $rc->implementsInterface("UndefI"); + } catch (ReflectionException $e) { + echo $e->getMessage(); + } +?> +--EXPECTF-- +In autoload: string(6) "UndefI" +Interface UndefI does not exist
\ No newline at end of file diff --git a/tests/classes/autoload_018.phpt b/tests/classes/autoload_018.phpt new file mode 100644 index 000000000..59e20e2a6 --- /dev/null +++ b/tests/classes/autoload_018.phpt @@ -0,0 +1,48 @@ +--TEST-- +Ensure __autoload() allows for recursive calls if the class name differs. +--FILE-- +<?php + function __autoload($name) + { + echo "IN: " . __METHOD__ . "($name)\n"; + + static $i = 0; + if ($i++ > 10) { + echo "-> Recursion detected - as expected.\n"; + return; + } + + class_exists('UndefinedClass' . $i); + + echo "OUT: " . __METHOD__ . "($name)\n"; + } + + var_dump(class_exists('UndefinedClass0')); +?> +--EXPECTF-- +IN: __autoload(UndefinedClass0) +IN: __autoload(UndefinedClass1) +IN: __autoload(UndefinedClass2) +IN: __autoload(UndefinedClass3) +IN: __autoload(UndefinedClass4) +IN: __autoload(UndefinedClass5) +IN: __autoload(UndefinedClass6) +IN: __autoload(UndefinedClass7) +IN: __autoload(UndefinedClass8) +IN: __autoload(UndefinedClass9) +IN: __autoload(UndefinedClass10) +IN: __autoload(UndefinedClass11) +-> Recursion detected - as expected. +OUT: __autoload(UndefinedClass10) +OUT: __autoload(UndefinedClass9) +OUT: __autoload(UndefinedClass8) +OUT: __autoload(UndefinedClass7) +OUT: __autoload(UndefinedClass6) +OUT: __autoload(UndefinedClass5) +OUT: __autoload(UndefinedClass4) +OUT: __autoload(UndefinedClass3) +OUT: __autoload(UndefinedClass2) +OUT: __autoload(UndefinedClass1) +OUT: __autoload(UndefinedClass0) +bool(false) + diff --git a/tests/classes/autoload_019.phpt b/tests/classes/autoload_019.phpt new file mode 100644 index 000000000..783632013 --- /dev/null +++ b/tests/classes/autoload_019.phpt @@ -0,0 +1,14 @@ +--TEST-- +Ensure __autoload() recursion is guarded for multiple lookups of same class using difference case. +--FILE-- +<?php + function __autoload($name) + { + echo __FUNCTION__ . " $name\n"; + class_exists("undefinedCLASS"); + } + + class_exists("unDefinedClass"); +?> +--EXPECTF-- +__autoload unDefinedClass diff --git a/tests/classes/autoload_020.phpt b/tests/classes/autoload_020.phpt new file mode 100644 index 000000000..a88e56123 --- /dev/null +++ b/tests/classes/autoload_020.phpt @@ -0,0 +1,17 @@ +--TEST-- +Ensure __autoload() is triggered during unserialization. +--FILE-- +<?php + function __autoload($name) + { + echo "in autoload: $name\n"; + } + + var_dump(unserialize('O:1:"C":0:{}')); +?> +--EXPECTF-- +in autoload: C +object(__PHP_Incomplete_Class)#%d (1) { + ["__PHP_Incomplete_Class_Name"]=> + string(1) "C" +} diff --git a/tests/classes/bug27468.phpt b/tests/classes/bug27468.phpt index f7ec8b688..58a7b6cb1 100644 --- a/tests/classes/bug27468.phpt +++ b/tests/classes/bug27468.phpt @@ -11,7 +11,7 @@ new foo(); echo 'OK'; ?> --EXPECTF-- -Notice: Undefined property: foo::$x in %sbug27468.php on line 4 +Notice: Undefined property: foo::$x in %sbug27468.php on line 4 Warning: Invalid argument supplied for foreach() in %sbug27468.php on line 4 OK diff --git a/tests/classes/constants_basic_001.phpt b/tests/classes/constants_basic_001.phpt new file mode 100644 index 000000000..74b0fcdf4 --- /dev/null +++ b/tests/classes/constants_basic_001.phpt @@ -0,0 +1,89 @@ +--TEST-- +Class constant declarations +--FILE-- +<?php + define('DEFINED', 1234); + $def = 456; + define('DEFINED_TO_VAR', $def); + define('DEFINED_TO_UNDEF_VAR', $undef); + + class C + { + const c0 = UNDEFINED; + + const c1 = 1, c2 = 1.5; + const c3 = + 1, c4 = + 1.5; + const c5 = -1, c6 = -1.5; + + const c7 = __LINE__; + const c8 = __FILE__; + const c9 = __CLASS__; + const c10 = __METHOD__; + const c11 = __FUNCTION__; + + const c12 = DEFINED; + const c13 = DEFINED_TO_VAR; + const c14 = DEFINED_TO_UNDEF_VAR; + + const c15 = "hello1"; + const c16 = 'hello2'; + const c17 = C::c16; + const c18 = self::c17; + } + + echo "\nAttempt to access various kinds of class constants:\n"; + var_dump(C::c0); + var_dump(C::c1); + var_dump(C::c2); + var_dump(C::c3); + var_dump(C::c4); + var_dump(C::c5); + var_dump(C::c6); + var_dump(C::c7); + var_dump(C::c8); + var_dump(C::c9); + var_dump(C::c10); + var_dump(C::c11); + var_dump(C::c12); + var_dump(C::c13); + var_dump(C::c14); + var_dump(C::c15); + var_dump(C::c16); + var_dump(C::c17); + var_dump(C::c18); + + echo "\nExpecting fatal error:\n"; + var_dump(C::c19); + + echo "\nYou should not see this."; +?> +--EXPECTF-- + +Notice: Undefined variable: undef in %s on line 5 + +Attempt to access various kinds of class constants: + +Notice: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' in %s on line %d +string(9) "UNDEFINED" +int(1) +float(1.5) +int(1) +float(1.5) +int(-1) +float(-1.5) +int(15) +string(%d) "%s" +string(1) "C" +string(1) "C" +string(0) "" +int(1234) +int(456) +NULL +string(6) "hello1" +string(6) "hello2" +string(6) "hello2" +string(6) "hello2" + +Expecting fatal error: + +Fatal error: Undefined class constant 'c19' in %s on line 53 diff --git a/tests/classes/constants_basic_002.phpt b/tests/classes/constants_basic_002.phpt new file mode 100644 index 000000000..0e53ca97c --- /dev/null +++ b/tests/classes/constants_basic_002.phpt @@ -0,0 +1,32 @@ +--TEST-- +Basic class support - defining and reading a class constant. +--FILE-- +<?php + class aclass + { + const myConst = "hello"; + } + + echo "\nRead class constant.\n"; + var_dump(aclass::myConst); + + echo "\nFail to read class constant from instance.\n"; + $myInstance = new aclass(); + var_dump($myInstance->myConst); + + echo "\nClass constant not visible in object var_dump.\n"; + var_dump($myInstance) +?> +--EXPECTF-- + +Read class constant. +string(5) "hello" + +Fail to read class constant from instance. + +Notice: Undefined property: aclass::$myConst in %s on line 12 +NULL + +Class constant not visible in object var_dump. +object(aclass)#%d (0) { +} diff --git a/tests/classes/constants_basic_003.inc b/tests/classes/constants_basic_003.inc new file mode 100644 index 000000000..be193e64f --- /dev/null +++ b/tests/classes/constants_basic_003.inc @@ -0,0 +1,5 @@ +<?php +class A { + const MY_CONST = "hello from A"; +} +?>
\ No newline at end of file diff --git a/tests/classes/constants_basic_003.phpt b/tests/classes/constants_basic_003.phpt new file mode 100644 index 000000000..052af8573 --- /dev/null +++ b/tests/classes/constants_basic_003.phpt @@ -0,0 +1,28 @@ +--TEST-- +Ensure class properties and constants can be defined in terms of constants that are not known at compile time. +--FILE-- +<?php + include 'constants_basic_003.inc'; + class B + { + public static $a = A::MY_CONST; + public static $c = C::MY_CONST; + const ca = A::MY_CONST; + const cc = C::MY_CONST; + } + + class C + { + const MY_CONST = "hello from C"; + } + + var_dump(B::$a); + var_dump(B::$c); + var_dump(B::ca); + var_dump(B::cc); +?> +--EXPECTF-- +string(12) "hello from A" +string(12) "hello from C" +string(12) "hello from A" +string(12) "hello from C" diff --git a/tests/classes/constants_basic_004.phpt b/tests/classes/constants_basic_004.phpt new file mode 100644 index 000000000..cade66844 --- /dev/null +++ b/tests/classes/constants_basic_004.phpt @@ -0,0 +1,99 @@ +--TEST-- +Test properties with array default values using class constants as keys and values. +--FILE-- +<?php + class X + { + // Static and instance array using class constants + public static $sa_x = array(B::KEY => B::VALUE); + public $a_x = array(B::KEY => B::VALUE); + } + + class B + { + const KEY = "key"; + const VALUE = "value"; + + // Static and instance array using class constants with self + public static $sa_b = array(self::KEY => self::VALUE); + public $a_b = array(self::KEY => self::VALUE); + } + + class C extends B + { + // Static and instance array using class constants with parent + public static $sa_c_parent = array(parent::KEY => parent::VALUE); + public $a_c_parent = array(parent::KEY => parent::VALUE); + + // Static and instance array using class constants with self (constants should be inherited) + public static $sa_c_self = array(self::KEY => self::VALUE); + public $a_c_self = array(self::KEY => self::VALUE); + + // Should also include inherited properties from B. + } + + echo "\nStatic properties:\n"; + var_dump(X::$sa_x, B::$sa_b, C::$sa_b, C::$sa_c_parent, C::$sa_c_self); + + echo "\nInstance properties:\n"; + $x = new x; + $b = new B; + $c = new C; + var_dump($x, $b, $c); +?> +--EXPECTF-- + +Static properties: +array(1) { + ["key"]=> + string(5) "value" +} +array(1) { + ["key"]=> + string(5) "value" +} +array(1) { + ["key"]=> + string(5) "value" +} +array(1) { + ["key"]=> + string(5) "value" +} +array(1) { + ["key"]=> + string(5) "value" +} + +Instance properties: +object(X)#%d (1) { + ["a_x"]=> + array(1) { + ["key"]=> + string(5) "value" + } +} +object(B)#%d (1) { + ["a_b"]=> + array(1) { + ["key"]=> + string(5) "value" + } +} +object(C)#%d (3) { + ["a_c_parent"]=> + array(1) { + ["key"]=> + string(5) "value" + } + ["a_c_self"]=> + array(1) { + ["key"]=> + string(5) "value" + } + ["a_b"]=> + array(1) { + ["key"]=> + string(5) "value" + } +} diff --git a/tests/classes/constants_basic_005.phpt b/tests/classes/constants_basic_005.phpt new file mode 100644 index 000000000..c840f5385 --- /dev/null +++ b/tests/classes/constants_basic_005.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test constants with default values based on other constants. +--FILE-- +<?php + class C + { + const CONST_2 = self::CONST_1; + const CONST_1 = self::BASE_CONST; + const BASE_CONST = 'hello'; + } + var_dump(C::CONST_1, C::CONST_2); +?> +--EXPECTF-- +string(5) "hello" +string(5) "hello" + diff --git a/tests/classes/constants_basic_006.phpt b/tests/classes/constants_basic_006.phpt new file mode 100644 index 000000000..73cf0ef3a --- /dev/null +++ b/tests/classes/constants_basic_006.phpt @@ -0,0 +1,43 @@ +--TEST-- +Ensure class constants are not evaluated when a class is looked up to resolve inheritance during runtime. +--FILE-- +<?php + class C + { + const X = E::A; + public static $a = array(K => D::V, E::A => K); + } + + eval('class D extends C { const V = \'test\'; }'); + + class E extends D + { + const A = "hello"; + } + + define('K', "nasty"); + + var_dump(C::X, C::$a, D::X, D::$a, E::X, E::$a); +?> +--EXPECTF-- +string(5) "hello" +array(2) { + ["nasty"]=> + string(4) "test" + ["hello"]=> + string(5) "nasty" +} +string(5) "hello" +array(2) { + ["nasty"]=> + string(4) "test" + ["hello"]=> + string(5) "nasty" +} +string(5) "hello" +array(2) { + ["nasty"]=> + string(4) "test" + ["hello"]=> + string(5) "nasty" +} diff --git a/tests/classes/constants_error_001.phpt b/tests/classes/constants_error_001.phpt new file mode 100644 index 000000000..9bb5533d7 --- /dev/null +++ b/tests/classes/constants_error_001.phpt @@ -0,0 +1,13 @@ +--TEST-- +Error case: duplicate class constant definition +--FILE-- +<?php + class myclass + { + const myConst = "hello"; + const myConst = "hello again"; + } +?> +--EXPECTF-- + +Fatal error: Cannot redefine class constant myclass::myConst in %s on line 5 diff --git a/tests/classes/constants_error_002.phpt b/tests/classes/constants_error_002.phpt new file mode 100644 index 000000000..be27971b8 --- /dev/null +++ b/tests/classes/constants_error_002.phpt @@ -0,0 +1,12 @@ +--TEST-- +Error case: class constant as an array +--FILE-- +<?php + class myclass + { + const myConst = array(); + } +?> +--EXPECTF-- + +Fatal error: Arrays are not allowed in class constants in %s on line 4 diff --git a/tests/classes/constants_error_003.phpt b/tests/classes/constants_error_003.phpt new file mode 100644 index 000000000..c67768c80 --- /dev/null +++ b/tests/classes/constants_error_003.phpt @@ -0,0 +1,20 @@ +--TEST-- +Basic class support - attempting to pass a class constant by reference. +--FILE-- +<?php + class aclass + { + const myConst = "hello"; + } + + function f(&$a) + { + $a = "changed"; + } + + f(aclass::myConst); + var_dump(aclass::myConst); +?> +--EXPECTF-- + +Fatal error: Only variables can be passed by reference in %s on line 12 diff --git a/tests/classes/constants_error_004.phpt b/tests/classes/constants_error_004.phpt new file mode 100644 index 000000000..03e67258a --- /dev/null +++ b/tests/classes/constants_error_004.phpt @@ -0,0 +1,13 @@ +--TEST-- +Class constant whose initial value refereces a non-existent class +--FILE-- +<?php + class C + { + const c1 = D::hello; + } + + $a = new C(); +?> +--EXPECTF-- +Fatal error: Class 'D' not found in %s on line %d diff --git a/tests/classes/constants_error_005.phpt b/tests/classes/constants_error_005.phpt new file mode 100644 index 000000000..1283783de --- /dev/null +++ b/tests/classes/constants_error_005.phpt @@ -0,0 +1,12 @@ +--TEST-- +Error case: class constant as an encapsed containing a variable +--FILE-- +<?php + class myclass + { + const myConst = "$myVar"; + } +?> +--EXPECTF-- + +Parse error: %s in %s on line %d diff --git a/tests/classes/constants_error_006.phpt b/tests/classes/constants_error_006.phpt new file mode 100644 index 000000000..f3f14b867 --- /dev/null +++ b/tests/classes/constants_error_006.phpt @@ -0,0 +1,16 @@ +--TEST-- +Basic class support - attempting to modify a class constant by assignment +--FILE-- +<?php + class aclass + { + const myConst = "hello"; + } + + echo "\nTrying to modify a class constant directly - should be parse error.\n"; + aclass::myConst = "no!!"; + var_dump(aclass::myConst); +?> +--EXPECTF-- + +Parse error: %s in %s on line %d diff --git a/tests/classes/constants_error_007.phpt b/tests/classes/constants_error_007.phpt new file mode 100644 index 000000000..4be8d885f --- /dev/null +++ b/tests/classes/constants_error_007.phpt @@ -0,0 +1,15 @@ +--TEST-- +Basic class support - attempting to create a reference to a class constant +--FILE-- +<?php + class aclass + { + const myConst = "hello"; + } + + echo "\nAttempting to create a reference to a class constant - should be parse error.\n"; + $a = &aclass::myConst; +?> +--EXPECTF-- + +Parse error: %s in %s on line %d diff --git a/tests/classes/final_ctor3.phpt b/tests/classes/final_ctor3.phpt new file mode 100644 index 000000000..d37e864e2 --- /dev/null +++ b/tests/classes/final_ctor3.phpt @@ -0,0 +1,15 @@ +--TEST-- +Ensure implicit final inherited old-style constructor cannot be overridden. +--FILE-- +<?php + class A { + final function A() { } + } + class B extends A { + } + class C extends B { + function B() { } + } +?> +--EXPECTF-- +Fatal error: Cannot override final method A::B() in %s on line 9 diff --git a/tests/classes/incdec_property_001.phpt b/tests/classes/incdec_property_001.phpt index 39bf06f65..97a24d30b 100644 --- a/tests/classes/incdec_property_001.phpt +++ b/tests/classes/incdec_property_001.phpt @@ -7,13 +7,13 @@ class Test { private $real_a = 2; function __set($property, $value) { - if ($property = "a") { + if ($property == "a") { $this->real_a = $value; } } function __get($property) { - if ($property = "a") { + if ($property == "a") { return $this->real_a; } } diff --git a/tests/classes/incdec_property_002.phpt b/tests/classes/incdec_property_002.phpt index fe08625ea..c1d7dded3 100644 --- a/tests/classes/incdec_property_002.phpt +++ b/tests/classes/incdec_property_002.phpt @@ -7,13 +7,13 @@ class Test { private $real_a = 2; function __set($property, $value) { - if ($property = "a") { + if ($property == "a") { $this->real_a = $value; } } function __get($property) { - if ($property = "a") { + if ($property == "a") { return $this->real_a; } } diff --git a/tests/classes/incdec_property_003.phpt b/tests/classes/incdec_property_003.phpt index d26277ab8..1a923849f 100644 --- a/tests/classes/incdec_property_003.phpt +++ b/tests/classes/incdec_property_003.phpt @@ -7,13 +7,13 @@ class Test { private $real_a = 2; function __set($property, $value) { - if ($property = "a") { + if ($property == "a") { $this->real_a = $value; } } function __get($property) { - if ($property = "a") { + if ($property == "a") { return $this->real_a; } } diff --git a/tests/classes/incdec_property_004.phpt b/tests/classes/incdec_property_004.phpt index 5ccad190b..05e3b445a 100644 --- a/tests/classes/incdec_property_004.phpt +++ b/tests/classes/incdec_property_004.phpt @@ -7,13 +7,13 @@ class Test { private $real_a = 2; function __set($property, $value) { - if ($property = "a") { + if ($property == "a") { $this->real_a = $value; } } function __get($property) { - if ($property = "a") { + if ($property == "a") { return $this->real_a; } } diff --git a/tests/classes/inheritance_005.phpt b/tests/classes/inheritance_005.phpt new file mode 100644 index 000000000..b6f47b2a6 --- /dev/null +++ b/tests/classes/inheritance_005.phpt @@ -0,0 +1,42 @@ +--TEST-- +Check for inherited old-style constructor. +--FILE-- +<?php + class A + { + function A() + { + echo "In " . __METHOD__ . "\n"; + } + } + + class B extends A + { + } + + class C extends B + { + } + + + echo "About to construct new B: "; + $b = new B; + echo "About to invoke implicit B::B(): "; + $b->B(); + + echo "\nAbout to construct new C: "; + $c = new C; + echo "About to invoke implicit C::B(): "; + $c->B(); + echo "About to invoke implicit C::C(): "; + $c->C(); +?> +--EXPECTF-- +About to construct new B: In A::A +About to invoke implicit B::B(): In A::A + +About to construct new C: In A::A +About to invoke implicit C::B(): In A::A +About to invoke implicit C::C(): In A::A + + diff --git a/tests/classes/interface_constant_inheritance_001.phpt b/tests/classes/interface_constant_inheritance_001.phpt new file mode 100644 index 000000000..ae3e71e7a --- /dev/null +++ b/tests/classes/interface_constant_inheritance_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +Ensure an interface may not shadow an inherited constant. +--FILE-- +<?php +interface I1 { + const FOO = 10; +} + +interface I2 extends I1 { + const FOO = 10; +} + +echo "Done\n"; +?> +--EXPECTF-- + +Fatal error: Cannot inherit previously-inherited constant FOO from interface I1 in %s on line 6
\ No newline at end of file diff --git a/tests/classes/interface_constant_inheritance_002.phpt b/tests/classes/interface_constant_inheritance_002.phpt new file mode 100644 index 000000000..d5001baa3 --- /dev/null +++ b/tests/classes/interface_constant_inheritance_002.phpt @@ -0,0 +1,17 @@ +--TEST-- +Ensure a class may not shadow a constant inherited from an interface. +--FILE-- +<?php +interface I { + const FOO = 10; +} + +class C implements I { + const FOO = 10; +} + +echo "Done\n"; +?> +--EXPECTF-- + +Fatal error: Cannot inherit previously-inherited constant FOO from interface I in %s on line 6
\ No newline at end of file diff --git a/tests/classes/interface_constant_inheritance_003.phpt b/tests/classes/interface_constant_inheritance_003.phpt new file mode 100644 index 000000000..a3ba815ed --- /dev/null +++ b/tests/classes/interface_constant_inheritance_003.phpt @@ -0,0 +1,20 @@ +--TEST-- +Ensure a class may not inherit two constants with the same name from two separate interfaces. +--FILE-- +<?php +interface I1 { + const FOO = 10; +} + +interface I2 { + const FOO = 10; +} + +class C implements I1,I2 { +} + +echo "Done\n"; +?> +--EXPECTF-- + +Fatal error: Cannot inherit previously-inherited constant FOO from interface I2 in %s on line 10 diff --git a/tests/classes/interface_constant_inheritance_004.phpt b/tests/classes/interface_constant_inheritance_004.phpt new file mode 100644 index 000000000..05b897236 --- /dev/null +++ b/tests/classes/interface_constant_inheritance_004.phpt @@ -0,0 +1,18 @@ +--TEST-- +Ensure a class may implement two interfaces which include the same constant due to inheritance. +--FILE-- +<?php +interface IA { + const FOO = 10; +} + +interface IB extends IA { +} + +class C implements IA, IB { +} + +echo "Done\n"; +?> +--EXPECTF-- +Done diff --git a/tests/classes/interface_optional_arg_002.phpt b/tests/classes/interface_optional_arg_002.phpt new file mode 100644 index 000000000..92980f65b --- /dev/null +++ b/tests/classes/interface_optional_arg_002.phpt @@ -0,0 +1,24 @@ +--TEST-- +default argument value in interface implementation +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> +--FILE-- +<?php + +interface test { + public function bar(); +} + +class foo implements test { + + public function bar($arg = 2) { + var_dump($arg); + } +} + +$foo = new foo; +$foo->bar(); + +?> +--EXPECT-- +int(2)
\ No newline at end of file diff --git a/tests/classes/method_call_variation_001.phpt b/tests/classes/method_call_variation_001.phpt new file mode 100644 index 000000000..dd43cfd1c --- /dev/null +++ b/tests/classes/method_call_variation_001.phpt @@ -0,0 +1,37 @@ +--TEST-- +In $a->$b[Y](), $b[Y] represents a method name on $a. But in $a->X[Y](), $a->X[Y] represents a global function name. +--FILE-- +<?php + class C + { + function foo($a, $b) + { + echo "Called C::foo($a, $b)\n"; + } + } + + $c = new C; + + $functions[0] = 'foo'; + $functions[1][2][3][4] = 'foo'; + + $c->$functions[0](1, 2); + $c->$functions[1][2][3][4](3, 4); + + + function foo($a, $b) + { + echo "Called global foo($a, $b)\n"; + } + + $c->functions[0] = 'foo'; + $c->functions[1][2][3][4] = 'foo'; + + $c->functions[0](5, 6); + $c->functions[1][2][3][4](7, 8); +?> +--EXPECTF-- +Called C::foo(1, 2) +Called C::foo(3, 4) +Called global foo(5, 6) +Called global foo(7, 8) diff --git a/tests/classes/method_override_optional_arg_001.phpt b/tests/classes/method_override_optional_arg_001.phpt new file mode 100644 index 000000000..53272fff7 --- /dev/null +++ b/tests/classes/method_override_optional_arg_001.phpt @@ -0,0 +1,33 @@ +--TEST-- +Method override allows optional default argument +--SKIPIF-- +<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> +--FILE-- +<?php + +class A { + function foo($arg1 = 1) { + } +} + +class B extends A { + function foo($arg1 = 2, $arg2 = 3) { + var_dump($arg1); + var_dump($arg2); + } +} + +class C extends A { + function foo() { + } +} + +$b = new B(); + +$b->foo(1); + +?> +--EXPECTF-- +Strict Standards: Declaration of C::foo() should be compatible with that of A::foo() in %s on line %d +int(1) +int(3) diff --git a/tests/classes/method_override_optional_arg_002.phpt b/tests/classes/method_override_optional_arg_002.phpt new file mode 100644 index 000000000..c212b8260 --- /dev/null +++ b/tests/classes/method_override_optional_arg_002.phpt @@ -0,0 +1,22 @@ +--TEST-- +Omitting optional arg in method inherited from abstract class +--FILE-- +<?php + +abstract class A { + function foo($arg = 1) {} +} + +class B extends A { + function foo() { + echo "foo\n"; + } +} + +$b = new B(); +$b->foo(); + +?> +--EXPECTF-- +Strict Standards: Declaration of B::foo() should be compatible with that of A::foo() in %s on line %d +foo diff --git a/tests/classes/new_001.phpt b/tests/classes/new_001.phpt new file mode 100644 index 000000000..8ef8a71e0 --- /dev/null +++ b/tests/classes/new_001.phpt @@ -0,0 +1,46 @@ +--TEST-- +Confirm difference between assigning new directly and by reference. +--FILE-- +<?php + echo "Compile-time strict error message should precede this.\n"; + + class Inc + { + private static $counter = 0; + function __construct() + { + $this->id = ++Inc::$counter; + } + } + + $f = new Inc(); + $k =& $f; + echo "\$f initially points to the first object:\n"; + var_dump($f); + + echo "Assigning new object directly to \$k affects \$f:\n"; + $k = new Inc(); + var_dump($f); + + echo "Assigning new object by ref to \$k removes it from \$f's reference set, so \$f is unchanged:\n"; + $k =& new Inc(); + var_dump($f); +?> +--EXPECTF-- +Strict Standards: Assigning the return value of new by reference is deprecated in %s on line 23 +Compile-time strict error message should precede this. +$f initially points to the first object: +object(Inc)#%d (1) { + ["id"]=> + int(1) +} +Assigning new object directly to $k affects $f: +object(Inc)#%d (1) { + ["id"]=> + int(2) +} +Assigning new object by ref to $k removes it from $f's reference set, so $f is unchanged: +object(Inc)#%d (1) { + ["id"]=> + int(2) +} diff --git a/tests/classes/property_override_privateStatic_private.phpt b/tests/classes/property_override_privateStatic_private.phpt new file mode 100644 index 000000000..ddd2e5d1a --- /dev/null +++ b/tests/classes/property_override_privateStatic_private.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited private static property as private. +--FILE-- +<?php + class A + { + private static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + private $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p diff --git a/tests/classes/property_override_privateStatic_privateStatic.phpt b/tests/classes/property_override_privateStatic_privateStatic.phpt new file mode 100644 index 000000000..d7d645fd0 --- /dev/null +++ b/tests/classes/property_override_privateStatic_privateStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited private static property as private static. +--FILE-- +<?php + class A + { + private static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + private static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p (static) diff --git a/tests/classes/property_override_privateStatic_protected.phpt b/tests/classes/property_override_privateStatic_protected.phpt new file mode 100644 index 000000000..d4732166c --- /dev/null +++ b/tests/classes/property_override_privateStatic_protected.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited private static property as protected. +--FILE-- +<?php + class A + { + private static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + protected $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p diff --git a/tests/classes/property_override_privateStatic_protectedStatic.phpt b/tests/classes/property_override_privateStatic_protectedStatic.phpt new file mode 100644 index 000000000..169ff9a37 --- /dev/null +++ b/tests/classes/property_override_privateStatic_protectedStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited private static property as protected static. +--FILE-- +<?php + class A + { + private static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + protected static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p (static) diff --git a/tests/classes/property_override_privateStatic_public.phpt b/tests/classes/property_override_privateStatic_public.phpt new file mode 100644 index 000000000..033eb7523 --- /dev/null +++ b/tests/classes/property_override_privateStatic_public.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited private static property as public. +--FILE-- +<?php + class A + { + private static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + public $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p diff --git a/tests/classes/property_override_privateStatic_publicStatic.phpt b/tests/classes/property_override_privateStatic_publicStatic.phpt new file mode 100644 index 000000000..5f2b6bf4a --- /dev/null +++ b/tests/classes/property_override_privateStatic_publicStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited private static property as public static. +--FILE-- +<?php + class A + { + private static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + public static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p (static) diff --git a/tests/classes/property_override_private_private.phpt b/tests/classes/property_override_private_private.phpt new file mode 100644 index 000000000..2b263eeb6 --- /dev/null +++ b/tests/classes/property_override_private_private.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited private property as private. +--FILE-- +<?php + class A + { + private $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + private $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p +A::p +B::p diff --git a/tests/classes/property_override_private_privateStatic.phpt b/tests/classes/property_override_private_privateStatic.phpt new file mode 100644 index 000000000..606ed21d0 --- /dev/null +++ b/tests/classes/property_override_private_privateStatic.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited private property as private static. +--FILE-- +<?php + class A + { + private $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + private static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- +A::p +A::p +B::p (static) diff --git a/tests/classes/property_override_private_protected.phpt b/tests/classes/property_override_private_protected.phpt new file mode 100644 index 000000000..b84ed6787 --- /dev/null +++ b/tests/classes/property_override_private_protected.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited private property as protected. +--FILE-- +<?php + class A + { + private $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + protected $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p +A::p +B::p diff --git a/tests/classes/property_override_private_protectedStatic.phpt b/tests/classes/property_override_private_protectedStatic.phpt new file mode 100644 index 000000000..1bb303dab --- /dev/null +++ b/tests/classes/property_override_private_protectedStatic.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited private property as protected static. +--FILE-- +<?php + class A + { + private $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + protected static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- +A::p +A::p +B::p (static) diff --git a/tests/classes/property_override_private_public.phpt b/tests/classes/property_override_private_public.phpt new file mode 100644 index 000000000..badbe91d5 --- /dev/null +++ b/tests/classes/property_override_private_public.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited private property as public. +--FILE-- +<?php + class A + { + private $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + public $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p +A::p +B::p diff --git a/tests/classes/property_override_private_publicStatic.phpt b/tests/classes/property_override_private_publicStatic.phpt new file mode 100644 index 000000000..9fc58ece4 --- /dev/null +++ b/tests/classes/property_override_private_publicStatic.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited private property as public static. +--FILE-- +<?php + class A + { + private $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + public static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- +A::p +A::p +B::p (static) diff --git a/tests/classes/property_override_protectedStatic_private.phpt b/tests/classes/property_override_protectedStatic_private.phpt new file mode 100644 index 000000000..18e9c78a1 --- /dev/null +++ b/tests/classes/property_override_protectedStatic_private.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited protected static property as private. +--FILE-- +<?php + class A + { + protected static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + private $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare static A::$p as non static B::$p in %s on line 18 + diff --git a/tests/classes/property_override_protectedStatic_privateStatic.phpt b/tests/classes/property_override_protectedStatic_privateStatic.phpt new file mode 100644 index 000000000..688621077 --- /dev/null +++ b/tests/classes/property_override_protectedStatic_privateStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited protected static property as private static. +--FILE-- +<?php + class A + { + protected static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + private static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Access level to B::$p must be protected (as in class A) or weaker in %s on line 18 + diff --git a/tests/classes/property_override_protectedStatic_protected.phpt b/tests/classes/property_override_protectedStatic_protected.phpt new file mode 100644 index 000000000..0e5fdd301 --- /dev/null +++ b/tests/classes/property_override_protectedStatic_protected.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited protected static property as protected. +--FILE-- +<?php + class A + { + protected static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + protected $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare static A::$p as non static B::$p in %s on line 18 + diff --git a/tests/classes/property_override_protectedStatic_protectedStatic.phpt b/tests/classes/property_override_protectedStatic_protectedStatic.phpt new file mode 100644 index 000000000..16f110094 --- /dev/null +++ b/tests/classes/property_override_protectedStatic_protectedStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited protected static property as protected static. +--FILE-- +<?php + class A + { + protected static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + protected static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p (static) diff --git a/tests/classes/property_override_protectedStatic_public.phpt b/tests/classes/property_override_protectedStatic_public.phpt new file mode 100644 index 000000000..630332559 --- /dev/null +++ b/tests/classes/property_override_protectedStatic_public.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited protected static property as public. +--FILE-- +<?php + class A + { + protected static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + public $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare static A::$p as non static B::$p in %s on line 18 + diff --git a/tests/classes/property_override_protectedStatic_publicStatic.phpt b/tests/classes/property_override_protectedStatic_publicStatic.phpt new file mode 100644 index 000000000..7e1955dd9 --- /dev/null +++ b/tests/classes/property_override_protectedStatic_publicStatic.phpt @@ -0,0 +1,31 @@ +--TEST-- +Redeclare inherited protected static property as public static. +--FILE-- +<?php + class A + { + protected static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + public static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot change initial value of property static protected A::$p in class B in %s on line 18 diff --git a/tests/classes/property_override_protected_private.phpt b/tests/classes/property_override_protected_private.phpt new file mode 100644 index 000000000..93f0d23eb --- /dev/null +++ b/tests/classes/property_override_protected_private.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited protected property as private. +Included for completeness (duplicates test Zend/tests/errmsg_023.phpt). +--FILE-- +<?php + class A + { + protected $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + private $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Access level to B::$p must be protected (as in class A) or weaker in %s on line 18 diff --git a/tests/classes/property_override_protected_privateStatic.phpt b/tests/classes/property_override_protected_privateStatic.phpt new file mode 100644 index 000000000..fb7102cb3 --- /dev/null +++ b/tests/classes/property_override_protected_privateStatic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited protected property as private static. +--FILE-- +<?php + class A + { + protected $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + private static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare non static A::$p as static B::$p in %s on line 18 diff --git a/tests/classes/property_override_protected_protected.phpt b/tests/classes/property_override_protected_protected.phpt new file mode 100644 index 000000000..c4b0d438c --- /dev/null +++ b/tests/classes/property_override_protected_protected.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited protected property as protected. +--FILE-- +<?php + class A + { + protected $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + protected $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p +B::p +B::p diff --git a/tests/classes/property_override_protected_protectedStatic.phpt b/tests/classes/property_override_protected_protectedStatic.phpt new file mode 100644 index 000000000..1ce413026 --- /dev/null +++ b/tests/classes/property_override_protected_protectedStatic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited protected property as protected static. +--FILE-- +<?php + class A + { + protected $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + protected static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare non static A::$p as static B::$p in %s on line 18 diff --git a/tests/classes/property_override_protected_public.phpt b/tests/classes/property_override_protected_public.phpt new file mode 100644 index 000000000..4702f9a0c --- /dev/null +++ b/tests/classes/property_override_protected_public.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited protected property as public. +--FILE-- +<?php + class A + { + protected $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + public $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p +B::p +B::p diff --git a/tests/classes/property_override_protected_publicStatic.phpt b/tests/classes/property_override_protected_publicStatic.phpt new file mode 100644 index 000000000..8efdf5f6f --- /dev/null +++ b/tests/classes/property_override_protected_publicStatic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited protected property as public static. +--FILE-- +<?php + class A + { + protected $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + public static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare non static A::$p as static B::$p in %s on line 18 diff --git a/tests/classes/property_override_publicStatic_private.phpt b/tests/classes/property_override_publicStatic_private.phpt new file mode 100644 index 000000000..7abe92c9f --- /dev/null +++ b/tests/classes/property_override_publicStatic_private.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited public static property as private. +--FILE-- +<?php + class A + { + public static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + private $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare static A::$p as non static B::$p in %s on line 18 + diff --git a/tests/classes/property_override_publicStatic_privateStatic.phpt b/tests/classes/property_override_publicStatic_privateStatic.phpt new file mode 100644 index 000000000..d41db6da3 --- /dev/null +++ b/tests/classes/property_override_publicStatic_privateStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited public static property as private static. +--FILE-- +<?php + class A + { + public static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + private static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Access level to B::$p must be public (as in class A) in %s on line 18 + diff --git a/tests/classes/property_override_publicStatic_protected.phpt b/tests/classes/property_override_publicStatic_protected.phpt new file mode 100644 index 000000000..884159f97 --- /dev/null +++ b/tests/classes/property_override_publicStatic_protected.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited public static property as protected. +--FILE-- +<?php + class A + { + public static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + protected $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare static A::$p as non static B::$p in %s on line 18 + diff --git a/tests/classes/property_override_publicStatic_protectedStatic.phpt b/tests/classes/property_override_publicStatic_protectedStatic.phpt new file mode 100644 index 000000000..b022ef804 --- /dev/null +++ b/tests/classes/property_override_publicStatic_protectedStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited public static property as protected static. +--FILE-- +<?php + class A + { + public static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + protected static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Access level to B::$p must be public (as in class A) in %s on line 18 + diff --git a/tests/classes/property_override_publicStatic_public.phpt b/tests/classes/property_override_publicStatic_public.phpt new file mode 100644 index 000000000..d099da047 --- /dev/null +++ b/tests/classes/property_override_publicStatic_public.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited public static property as public. +--FILE-- +<?php + class A + { + public static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + public $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + A::showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare static A::$p as non static B::$p in %s on line 18 + diff --git a/tests/classes/property_override_publicStatic_publicStatic.phpt b/tests/classes/property_override_publicStatic_publicStatic.phpt new file mode 100644 index 000000000..9a8686704 --- /dev/null +++ b/tests/classes/property_override_publicStatic_publicStatic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Redeclare inherited public static property as public static. +--FILE-- +<?php + class A + { + public static $p = "A::p (static)"; + static function showA() + { + echo self::$p . "\n"; + } + } + + class B extends A + { + public static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + A::showA(); + + B::showA(); + B::showB(); +?> +--EXPECTF-- +A::p (static) +A::p (static) +B::p (static) diff --git a/tests/classes/property_override_public_private.phpt b/tests/classes/property_override_public_private.phpt new file mode 100644 index 000000000..c0f37ad95 --- /dev/null +++ b/tests/classes/property_override_public_private.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited public property as private. +--FILE-- +<?php + class A + { + public $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + private $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Access level to B::$p must be public (as in class A) in %s on line 18 + diff --git a/tests/classes/property_override_public_privateStatic.phpt b/tests/classes/property_override_public_privateStatic.phpt new file mode 100644 index 000000000..36223fd34 --- /dev/null +++ b/tests/classes/property_override_public_privateStatic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited public property as private static. +--FILE-- +<?php + class A + { + public $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + private static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare non static A::$p as static B::$p in %s on line 18 diff --git a/tests/classes/property_override_public_protected.phpt b/tests/classes/property_override_public_protected.phpt new file mode 100644 index 000000000..68fdf8286 --- /dev/null +++ b/tests/classes/property_override_public_protected.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited public property as protected. +--FILE-- +<?php + class A + { + public $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + protected $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- + +Fatal error: Access level to B::$p must be public (as in class A) in %s on line 18 + diff --git a/tests/classes/property_override_public_protectedStatic.phpt b/tests/classes/property_override_public_protectedStatic.phpt new file mode 100644 index 000000000..77e7ebf1f --- /dev/null +++ b/tests/classes/property_override_public_protectedStatic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited public property as protected static. +--FILE-- +<?php + class A + { + public $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + protected static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare non static A::$p as static B::$p in %s on line 18 diff --git a/tests/classes/property_override_public_public.phpt b/tests/classes/property_override_public_public.phpt new file mode 100644 index 000000000..893fe5d04 --- /dev/null +++ b/tests/classes/property_override_public_public.phpt @@ -0,0 +1,34 @@ +--TEST-- +Redeclare inherited public property as public. +--FILE-- +<?php + class A + { + public $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + public $p = "B::p"; + function showB() + { + echo $this->p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + $b->showB(); +?> +--EXPECTF-- +A::p +B::p +B::p diff --git a/tests/classes/property_override_public_publicStatic.phpt b/tests/classes/property_override_public_publicStatic.phpt new file mode 100644 index 000000000..725e947a0 --- /dev/null +++ b/tests/classes/property_override_public_publicStatic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Redeclare inherited public property as public static. +--FILE-- +<?php + class A + { + public $p = "A::p"; + function showA() + { + echo $this->p . "\n"; + } + } + + class B extends A + { + public static $p = "B::p (static)"; + static function showB() + { + echo self::$p . "\n"; + } + } + + + $a = new A; + $a->showA(); + + $b = new B; + $b->showA(); + B::showB(); +?> +--EXPECTF-- + +Fatal error: Cannot redeclare non static A::$p as static B::$p in %s on line 18 diff --git a/tests/classes/tostring_004.phpt b/tests/classes/tostring_004.phpt new file mode 100644 index 000000000..de0283e8e --- /dev/null +++ b/tests/classes/tostring_004.phpt @@ -0,0 +1,56 @@ +--TEST-- +Object to string conversion: error cases and behaviour variations. +--FILE-- +<?php +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg\n"; +} +set_error_handler('test_error_handler'); +error_reporting(8191); + + +echo "Object with no __toString():\n"; +$obj = new stdClass; +echo "Try 1:\n"; +printf($obj); +printf("\n"); + +echo "\nTry 2:\n"; +printf($obj . "\n"); + + +echo "\n\nObject with bad __toString():\n"; +class badToString { + function __toString() { + return 0; + } +} +$obj = new badToString; +echo "Try 1:\n"; +printf($obj); +printf("\n"); + +echo "\nTry 2:\n"; +printf($obj . "\n"); + +?> +--EXPECTF-- +Object with no __toString(): +Try 1: +Error: 4096 - Object of class stdClass could not be converted to string +Error: 8 - Object of class stdClass to string conversion +Object + +Try 2: +Error: 4096 - Object of class stdClass could not be converted to string + + + +Object with bad __toString(): +Try 1: +Error: 4096 - Method badToString::__toString() must return a string value + + +Try 2: +Error: 4096 - Method badToString::__toString() must return a string value + diff --git a/tests/classes/type_hinting_004.phpt b/tests/classes/type_hinting_004.phpt new file mode 100644 index 000000000..9068909a8 --- /dev/null +++ b/tests/classes/type_hinting_004.phpt @@ -0,0 +1,109 @@ +--TEST-- +Ensure type hints are enforced for functions invoked as callbacks. +--FILE-- +<?php + set_error_handler('myErrorHandler', E_RECOVERABLE_ERROR); + function myErrorHandler($errno, $errstr, $errfile, $errline) { + echo "$errno: $errstr - $errfile($errline)\n"; + return true; + } + + echo "---> Type hints with callback function:\n"; + class A { } + function f1(A $a) { + echo "in f1;\n"; + } + function f2(A $a = null) { + echo "in f2;\n"; + } + call_user_func('f1', 1); + call_user_func('f1', new A); + call_user_func('f2', 1); + call_user_func('f2'); + call_user_func('f2', new A); + call_user_func('f2', null); + + + echo "\n\n---> Type hints with callback static method:\n"; + class C { + static function f1(A $a) { + if (isset($this)) { + echo "in C::f1 (instance);\n"; + } else { + echo "in C::f1 (static);\n"; + } + } + static function f2(A $a = null) { + if (isset($this)) { + echo "in C::f2 (instance);\n"; + } else { + echo "in C::f2 (static);\n"; + } + } + } + call_user_func(array('C', 'f1'), 1); + call_user_func(array('C', 'f1'), new A); + call_user_func(array('C', 'f2'), 1); + call_user_func(array('C', 'f2')); + call_user_func(array('C', 'f2'), new A); + call_user_func(array('C', 'f2'), null); + + + echo "\n\n---> Type hints with callback instance method:\n"; + class D { + function f1(A $a) { + if (isset($this)) { + echo "in C::f1 (instance);\n"; + } else { + echo "in C::f1 (static);\n"; + } + } + function f2(A $a = null) { + if (isset($this)) { + echo "in C::f2 (instance);\n"; + } else { + echo "in C::f2 (static);\n"; + } + } + } + $d = new D; + call_user_func(array($d, 'f1'), 1); + call_user_func(array($d, 'f1'), new A); + call_user_func(array($d, 'f2'), 1); + call_user_func(array($d, 'f2')); + call_user_func(array($d, 'f2'), new A); + call_user_func(array($d, 'f2'), null); + +?> +--EXPECTF-- +---> Type hints with callback function: +4096: Argument 1 passed to f1() must be an instance of A, integer given%s(10) +in f1; +in f1; +4096: Argument 1 passed to f2() must be an instance of A, integer given%s(13) +in f2; +in f2; +in f2; +in f2; + + +---> Type hints with callback static method: +4096: Argument 1 passed to C::f1() must be an instance of A, integer given%s(26) +in C::f1 (static); +in C::f1 (static); +4096: Argument 1 passed to C::f2() must be an instance of A, integer given%s(33) +in C::f2 (static); +in C::f2 (static); +in C::f2 (static); +in C::f2 (static); + + +---> Type hints with callback instance method: +4096: Argument 1 passed to D::f1() must be an instance of A, integer given%s(51) +in C::f1 (instance); +in C::f1 (instance); +4096: Argument 1 passed to D::f2() must be an instance of A, integer given%s(58) +in C::f2 (instance); +in C::f2 (instance); +in C::f2 (instance); +in C::f2 (instance); diff --git a/tests/lang/bug22592.phpt b/tests/lang/bug22592.phpt index 351ea08b9..270584185 100644 --- a/tests/lang/bug22592.phpt +++ b/tests/lang/bug22592.phpt @@ -46,8 +46,8 @@ string(8) "4-4s4s*0" string(9) "4-4s4s505" string(9) "454s4s505" string(1) "-" -string(6) "string" -int(4) -int(5) +string(1) "s" +string(1) "4" +string(1) "5" string(1) "5" [Illegal string offset: -1] diff --git a/tests/lang/bug27439.phpt b/tests/lang/bug27439.phpt index b12fd1ec6..5b7d875d3 100755 --- a/tests/lang/bug27439.phpt +++ b/tests/lang/bug27439.phpt @@ -65,7 +65,7 @@ echo "===DONE==="; ?>
--EXPECTF--
123
-Notice: Undefined property: test::$foobar in %s on line %d
+Notice: Undefined property: test::$foobar in %s on line %d
Warning: Invalid argument supplied for foreach() in %s on line %d
diff --git a/tests/lang/empty_variation.phpt b/tests/lang/empty_variation.phpt new file mode 100644 index 000000000..8e940dae5 --- /dev/null +++ b/tests/lang/empty_variation.phpt @@ -0,0 +1,14 @@ +--TEST-- +empty() on array elements +--FILE-- +<?php +$a=array('0','empty'=>'0'); +var_dump(empty($a['empty'])); +var_dump(empty($a[0])); +$b='0'; +var_dump(empty($b)); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/tests/lang/inc_throw.inc b/tests/lang/inc_throw.inc new file mode 100644 index 000000000..1f032f7e7 --- /dev/null +++ b/tests/lang/inc_throw.inc @@ -0,0 +1,5 @@ +<?php + +throw new Exception(); + +?> diff --git a/tests/lang/include_files/echo.inc b/tests/lang/include_files/echo.inc new file mode 100644 index 000000000..60714f6e4 --- /dev/null +++ b/tests/lang/include_files/echo.inc @@ -0,0 +1,3 @@ +<?php +echo "Included!\n"; +?>
\ No newline at end of file diff --git a/tests/lang/include_files/eval.inc b/tests/lang/include_files/eval.inc new file mode 100644 index 000000000..16da86295 --- /dev/null +++ b/tests/lang/include_files/eval.inc @@ -0,0 +1,3 @@ +<?php +eval("require_once 'echo.inc';"); +?>
\ No newline at end of file diff --git a/tests/lang/include_files/function.inc b/tests/lang/include_files/function.inc new file mode 100644 index 000000000..528f46c56 --- /dev/null +++ b/tests/lang/include_files/function.inc @@ -0,0 +1,3 @@ +<?php +function test() { require_once 'echo.inc'; } +?> diff --git a/tests/lang/include_variation1.phpt b/tests/lang/include_variation1.phpt new file mode 100644 index 000000000..cf99ba9d3 --- /dev/null +++ b/tests/lang/include_variation1.phpt @@ -0,0 +1,8 @@ +--TEST-- +include() a file from the current script directory +--FILE-- +<?php +include("inc.inc"); +?> +--EXPECT-- +Included! diff --git a/tests/lang/include_variation2.phpt b/tests/lang/include_variation2.phpt new file mode 100644 index 000000000..051ed7157 --- /dev/null +++ b/tests/lang/include_variation2.phpt @@ -0,0 +1,9 @@ +--TEST-- +Including a file in the current script directory from an included function +--FILE-- +<?php +require_once 'include_files/function.inc'; +test(); +?> +--EXPECT-- +Included! diff --git a/tests/lang/include_variation3.phpt b/tests/lang/include_variation3.phpt new file mode 100644 index 000000000..1fa80c5ab --- /dev/null +++ b/tests/lang/include_variation3.phpt @@ -0,0 +1,8 @@ +--TEST-- +Including a file in the current script directory from eval'd code +--FILE-- +<?php +require_once 'include_files/eval.inc'; +?> +--EXPECT-- +Included!
\ No newline at end of file diff --git a/tests/lang/throw_variation_001.phpt b/tests/lang/throw_variation_001.phpt new file mode 100644 index 000000000..d942a8793 --- /dev/null +++ b/tests/lang/throw_variation_001.phpt @@ -0,0 +1,14 @@ +--TEST-- +Catching an exception thrown from an included file +--FILE-- +<?php + +try { + include "inc_throw.inc"; +} catch (Exception $e) { + echo "caught exception\n"; +} + +?> +--EXPECT-- +caught exception |
