diff options
Diffstat (limited to 'tests/classes')
-rw-r--r-- | tests/classes/abstract_user_call.phpt | 11 | ||||
-rw-r--r-- | tests/classes/autoload_012.phpt | 15 | ||||
-rw-r--r-- | tests/classes/bug27504.phpt | 41 | ||||
-rw-r--r-- | tests/classes/constants_basic_001.phpt | 12 | ||||
-rw-r--r-- | tests/classes/constants_scope_001.phpt | 5 | ||||
-rw-r--r-- | tests/classes/ctor_name_clash.phpt | 23 | ||||
-rw-r--r-- | tests/classes/final_ctor1.phpt | 8 | ||||
-rw-r--r-- | tests/classes/final_ctor2.phpt | 30 | ||||
-rw-r--r-- | tests/classes/final_ctor3.phpt | 15 | ||||
-rw-r--r-- | tests/classes/inheritance_002.phpt | 74 | ||||
-rw-r--r-- | tests/classes/inheritance_005.phpt | 58 | ||||
-rw-r--r-- | tests/classes/inheritance_007.phpt | 40 | ||||
-rw-r--r-- | tests/classes/tostring_004.phpt | 2 |
13 files changed, 45 insertions, 289 deletions
diff --git a/tests/classes/abstract_user_call.phpt b/tests/classes/abstract_user_call.phpt index 6ce810c836..c69eaa458c 100644 --- a/tests/classes/abstract_user_call.phpt +++ b/tests/classes/abstract_user_call.phpt @@ -20,12 +20,15 @@ $o = new test; $o->func(); -call_user_func(array($o, 'test_base::func')); +try { + call_user_func(array($o, 'test_base::func')); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ===DONE=== ---EXPECTF-- +--EXPECT-- test::func() - -Warning: call_user_func() expects parameter 1 to be a valid callback, cannot call abstract method test_base::func() in %s on line %d +call_user_func() expects parameter 1 to be a valid callback, cannot call abstract method test_base::func() ===DONE=== diff --git a/tests/classes/autoload_012.phpt b/tests/classes/autoload_012.phpt index 4fc41c85f5..c5b32debae 100644 --- a/tests/classes/autoload_012.phpt +++ b/tests/classes/autoload_012.phpt @@ -3,12 +3,15 @@ Ensure callback methods in unknown classes trigger autoload. --FILE-- <?php spl_autoload_register(function ($name) { - echo "In autoload: "; - var_dump($name); + echo "In autoload: "; + var_dump($name); }); -call_user_func("UndefC::test"); +try { + call_user_func("UndefC::test"); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- +--EXPECT-- In autoload: string(6) "UndefC" - -Warning: call_user_func() expects parameter 1 to be a valid callback, class 'UndefC' not found in %s on line %d +call_user_func() expects parameter 1 to be a valid callback, class 'UndefC' not found diff --git a/tests/classes/bug27504.phpt b/tests/classes/bug27504.phpt index ba44806bfe..4e227a1075 100644 --- a/tests/classes/bug27504.phpt +++ b/tests/classes/bug27504.phpt @@ -2,27 +2,30 @@ Bug #27504 (call_user_func_array allows calling of private/protected methods) --FILE-- <?php - class foo { - function __construct () { - $this->bar('1'); - } - private function bar ( $param ) { - echo 'Called function foo:bar('.$param.')'."\n"; - } - } +class foo { + function __construct () { + $this->bar('1'); + } + private function bar ( $param ) { + echo 'Called function foo:bar('.$param.')'."\n"; + } +} - $foo = new foo(); +$foo = new foo(); - call_user_func_array( array( $foo , 'bar' ) , array( '2' ) ); +try { + call_user_func_array( array( $foo , 'bar' ) , array( '2' ) ); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + $foo->bar('3'); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} - $foo->bar('3'); ?> ---EXPECTF-- +--EXPECT-- Called function foo:bar(1) - -Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method foo::bar() in %s on line %d - -Fatal error: Uncaught Error: Call to private method foo::bar() from context '' in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d +call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method foo::bar() +Call to private method foo::bar() from context '' diff --git a/tests/classes/constants_basic_001.phpt b/tests/classes/constants_basic_001.phpt index 6a281e7d32..38da2dfde0 100644 --- a/tests/classes/constants_basic_001.phpt +++ b/tests/classes/constants_basic_001.phpt @@ -9,8 +9,6 @@ Class constant declarations class C { - const c0 = UNDEFINED; - const c1 = 1, c2 = 1.5; const c3 = + 1, c4 = + 1.5; const c5 = -1, c6 = -1.5; @@ -32,7 +30,6 @@ Class constant declarations } 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); @@ -61,16 +58,13 @@ Class constant declarations Notice: Undefined variable: undef in %s on line 5 Attempt to access various kinds of class constants: - -Warning: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' (this will throw an Error in a future version of PHP) 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) +int(13) string(%d) "%s" string(1) "C" string(0) "" @@ -85,7 +79,7 @@ string(6) "hello2" Expecting fatal error: -Fatal error: Uncaught Error: Undefined class constant 'c19' in %s:53 +Fatal error: Uncaught Error: Undefined class constant 'c19' in %s:%d Stack trace: #0 {main} - thrown in %s on line 53 + thrown in %s on line %d diff --git a/tests/classes/constants_scope_001.phpt b/tests/classes/constants_scope_001.phpt index 7adf3f8681..e9635d8d23 100644 --- a/tests/classes/constants_scope_001.phpt +++ b/tests/classes/constants_scope_001.phpt @@ -9,7 +9,6 @@ class ErrorCodes { const INFO = "Informational message\n"; static function print_fatal_error_codes() { - echo "FATAL = " . FATAL . "\n"; echo "self::FATAL = " . self::FATAL; } } @@ -27,9 +26,7 @@ ErrorCodes::print_fatal_error_codes(); ErrorCodesDerived::print_fatal_error_codes(); ?> ---EXPECTF-- -Warning: Use of undefined constant FATAL - assumed 'FATAL' (this will throw an Error in a future version of PHP) in %sconstants_scope_001.php on line %d -FATAL = FATAL +--EXPECT-- self::FATAL = Fatal error self::FATAL = Worst error parent::FATAL = Fatal error diff --git a/tests/classes/ctor_name_clash.phpt b/tests/classes/ctor_name_clash.phpt deleted file mode 100644 index e6518775ff..0000000000 --- a/tests/classes/ctor_name_clash.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -ZE2 The child class can re-use the parent class name for a function member ---FILE-- -<?php -class base { - function base() { - echo __CLASS__."::".__FUNCTION__."\n"; - } -} - -class derived extends base { - function base() { - echo __CLASS__."::".__FUNCTION__."\n"; - } -} - -$obj = new derived(); -$obj->base(); -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; base has a deprecated constructor in %s on line %d -base::base -derived::base diff --git a/tests/classes/final_ctor1.phpt b/tests/classes/final_ctor1.phpt index acf20918fd..33fcbe6bd8 100644 --- a/tests/classes/final_ctor1.phpt +++ b/tests/classes/final_ctor1.phpt @@ -16,15 +16,11 @@ class Works extends Base class Extended extends Base { - public function Extended() + public function __construct() { } } -ReflectionClass::export('Extended'); - ?> --EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Extended has a deprecated constructor in %s on line %d - -Fatal error: Cannot override final Base::__construct() with Extended::Extended() in %sfinal_ctor1.php on line %d +Fatal error: Cannot override final method Base::__construct() in %s on line %d diff --git a/tests/classes/final_ctor2.phpt b/tests/classes/final_ctor2.phpt deleted file mode 100644 index 37fcac29a9..0000000000 --- a/tests/classes/final_ctor2.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -ZE2 cannot override final old style ctor ---FILE-- -<?php - -class Base -{ - public final function Base() - { - } -} - -class Works extends Base -{ -} - -class Extended extends Base -{ - public function __construct() - { - } -} - -ReflectionClass::export('Extended'); - -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Base has a deprecated constructor in %s on line %d - -Fatal error: Cannot override final Base::Base() with Extended::__construct() in %sfinal_ctor2.php on line %d diff --git a/tests/classes/final_ctor3.phpt b/tests/classes/final_ctor3.phpt deleted file mode 100644 index b34996c979..0000000000 --- a/tests/classes/final_ctor3.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Ensure implicit final inherited old-style constructor cannot be overridden. ---FILE-- -<?php - class A { - final function A() { } - } - class B extends A { - function A() { } - } -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d - -Fatal error: Cannot override final method A::A() in %s on line %d diff --git a/tests/classes/inheritance_002.phpt b/tests/classes/inheritance_002.phpt deleted file mode 100644 index f88c0996bd..0000000000 --- a/tests/classes/inheritance_002.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -ZE2 Constructor precedence ---FILE-- -<?php -class Base_php4 { - function Base_php4() { - var_dump('Base constructor'); - } -} - -class Child_php4 extends Base_php4 { - function Child_php4() { - var_dump('Child constructor'); - parent::Base_php4(); - } -} - -class Base_php5 { - function __construct() { - var_dump('Base constructor'); - } - } - -class Child_php5 extends Base_php5 { - function __construct() { - var_dump('Child constructor'); - parent::__construct(); - } - } - -class Child_mx1 extends Base_php4 { - function __construct() { - var_dump('Child constructor'); - parent::Base_php4(); - } -} - -class Child_mx2 extends Base_php5 { - function Child_mx2() { - var_dump('Child constructor'); - parent::__construct(); - } -} - -echo "### PHP 4 style\n"; -$c4= new Child_php4(); - -echo "### PHP 5 style\n"; -$c5= new Child_php5(); - -echo "### Mixed style 1\n"; -$cm= new Child_mx1(); - -echo "### Mixed style 2\n"; -$cm= new Child_mx2(); -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Base_php4 has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Child_php4 has a deprecated constructor in %s on line %d - -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Child_mx2 has a deprecated constructor in %s on line %d -### PHP 4 style -string(17) "Child constructor" -string(16) "Base constructor" -### PHP 5 style -string(17) "Child constructor" -string(16) "Base constructor" -### Mixed style 1 -string(17) "Child constructor" -string(16) "Base constructor" -### Mixed style 2 -string(17) "Child constructor" -string(16) "Base constructor" diff --git a/tests/classes/inheritance_005.phpt b/tests/classes/inheritance_005.phpt deleted file mode 100644 index 8c5167f4bf..0000000000 --- a/tests/classes/inheritance_005.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---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: \n"; - $b = new B; - - echo "Is B::B() callable?\n"; - var_dump(is_callable(array($b, "B"))); - - echo "Is B::A() callable?\n"; - var_dump(is_callable(array($b, "A"))); - - echo "About to construct new C: \n"; - $c = new C; - - echo "Is C::A() callable?\n"; - var_dump(is_callable(array($c, "A"))); - - echo "Is C::B() callable?\n"; - var_dump(is_callable(array($c, "B"))); - - echo "Is C::C() callable?\n"; - var_dump(is_callable(array($c, "C"))); -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -About to construct new B: -In A::A -Is B::B() callable? -bool(false) -Is B::A() callable? -bool(true) -About to construct new C: -In A::A -Is C::A() callable? -bool(true) -Is C::B() callable? -bool(false) -Is C::C() callable? -bool(false) diff --git a/tests/classes/inheritance_007.phpt b/tests/classes/inheritance_007.phpt deleted file mode 100644 index c87fbde344..0000000000 --- a/tests/classes/inheritance_007.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Ensure inherited old-style constructor doesn't block other methods ---FILE-- -<?php -class A { - public function B () { echo "In " . __METHOD__ . "\n"; } - public function A () { echo "In " . __METHOD__ . "\n"; } -} -class B extends A { } - -$rc = new ReflectionClass('B'); -var_dump($rc->getMethods()); - - -$b = new B(); -$b->a(); -$b->b(); - -?> ---EXPECTF-- -Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d -array(2) { - [0]=> - object(ReflectionMethod)#%d (2) { - ["name"]=> - string(1) "B" - ["class"]=> - string(1) "A" - } - [1]=> - object(ReflectionMethod)#%d (2) { - ["name"]=> - string(1) "A" - ["class"]=> - string(1) "A" - } -} -In A::A -In A::A -In A::B diff --git a/tests/classes/tostring_004.phpt b/tests/classes/tostring_004.phpt index 907f7bc306..6029938f32 100644 --- a/tests/classes/tostring_004.phpt +++ b/tests/classes/tostring_004.phpt @@ -2,7 +2,7 @@ Object to string conversion: error cases and behaviour variations. --FILE-- <?php -function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { +function test_error_handler($err_no, $err_msg, $filename, $linenum) { echo "Error: $err_no - $err_msg\n"; } set_error_handler('test_error_handler'); |