--FILE--
<?php
class foo {
- function foo($n=0) {
+ function __construct($n=0) {
if($n) throw new Exception("new");
}
}
$x = new foo();
try {
- $y=$x->foo(1);
+ $y=$x->__construct(1);
} catch (Exception $e) {
var_dump($x);
}
}
print_r(get_class_methods("bar"));
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d
Array
(
[0] => foo
echo "Done\n";
?>
--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
string(13) "a::a() called"
bool(true)
bool(false)
echo "Done\n";
?>
--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
I'm A
I'm A
Done
class foo extends bar {
}
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; bar has a deprecated constructor in %s on line %d
+
Fatal error: Class foo contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (bar::bar) in %sbug43323.php on line 7
--TEST--
Bug #46381 (wrong $this passed to internal methods causes segfault)
---SKIPIF--
-<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?>
--FILE--
<?php
class test {
- public function test() {
+ public function method() {
return ArrayIterator::current();
}
}
$test = new test();
-$test->test();
+$test->method();
echo "Done\n";
?>
class B
{
- public function B($A)
+ public function __construct($A)
{
$this->A = $A;
}
}
class b extends a {}
class c extends b {
- function C() {
+ function __construct() {
b::b();
}
}
new testClass2;
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; testClass has a deprecated constructor in %s on line %d
testClass::testClass (1)
testClass::testClass (2)
testClass::testClass (3)
new C();
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; AA 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; CC 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; A 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; C has a deprecated constructor in %s on line %d
foo
bar
?>
--EXPECTF--
-Strict Standards: Redefining already defined constructor for class foo in %s on line %d
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; baz has a deprecated constructor in %s on line %d
Fatal error: Constructor baz::baz() cannot be static in %s on line %d
?>
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d
+
Fatal error: Non-static method foo::foo() cannot be called statically in %s on line %d
--FILE--
<?php
-abstract class A {
+abstract class X {
public function a() { }
private function b() { }
protected function c() { }
}
-class B extends A {
+class Y extends X {
private function bb() { }
static public function test() {
- var_dump(get_class_methods('A'));
- var_dump(get_class_methods('B'));
+ var_dump(get_class_methods('X'));
+ var_dump(get_class_methods('Y'));
}
}
-var_dump(get_class_methods('A'));
-var_dump(get_class_methods('B'));
+var_dump(get_class_methods('X'));
+var_dump(get_class_methods('Y'));
-B::test();
+Y::test();
?>
---EXPECT--
+--EXPECTF--
array(1) {
[0]=>
string(1) "a"
--FILE--
<?php
-interface A {
+interface I {
function aa();
function bb();
static function cc();
}
-class C {
+class X {
public function a() { }
protected function b() { }
private function c() { }
static private function static_c() { }
}
-class B extends C implements A {
+class Y extends X implements I {
public function aa() { }
public function bb() { }
static function cc() { }
public function __construct() {
- var_dump(get_class_methods('A'));
- var_dump(get_class_methods('B'));
- var_dump(get_class_methods('C'));
+ var_dump(get_class_methods('I'));
+ var_dump(get_class_methods('Y'));
+ var_dump(get_class_methods('X'));
}
public function __destruct() { }
}
-new B;
+new Y;
?>
--EXPECT--
--TEST--
redefining constructor (__construct second)
---INI--
-error_reporting=8191
--FILE--
<?php
echo "Done\n";
?>
--EXPECTF--
-Strict Standards: Redefining already defined constructor for class test in %s on line %d
Done
}
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor in %s on line %d
+
Fatal error: Constructor %s::%s() cannot declare a return type in %s on line %s
--EXPECTF--
OverridingIsSilent1 __construct
+
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OverridingIsSilent2 has a deprecated constructor in %s on line %d
OverridingIsSilent2 OverridingIsSilent2
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
$rbarbar = new ReflectionMethod('Bar::Bar');
var_dump($rbarbar->isConstructor());
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Bar has a deprecated constructor in %s on line %d
bool(false)
bool(false)
bool(true)
zend_compile_stmt(stmt_ast);
+ if (ce->num_traits == 0) {
+ /* For traits this check is delayed until after trait binding */
+ zend_check_deprecated_constructor(ce);
+ }
+
if (ce->constructor) {
ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) {
public $s1 = 'ÆüËܸìEUC-JP¤Îʸ»úÎó';
public $s2 = 'English Text';
- function tc()
+ function __construct()
{
}
}
private $id;
public $id_ref;
public function __construct() {
- parent::construct();
+ parent::__construct();
$this->id_ref = &$this->id;
}
}
var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
class foo {
- public function foo($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::foo')));
+ var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::method')));
}
static public function test($x, $y) {
}
echo "===DONE===\n";?>
---EXPECT--
+--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
Non-object passed to Invoke()
Given object is not an instance of the class this method was declared in
===DONE===
?>
--EXPECTF--
-Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor 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; B 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; C has a deprecated constructor in %s on line %d
Constructor of NewCtor: __construct
Constructor of ExtendsNewCtor: __construct
Constructor of OldCtor: OldCtor
?>
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d
+
Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d
NULL
?>
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld 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; protectedCtorOld 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; privateCtorOld has a deprecated constructor in %s on line %d
Is noCtor instantiable? bool(true)
Is publicCtorNew instantiable? bool(true)
Is protectedCtorNew instantiable? bool(false)
}
?>
--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
In constructor of class A
In constructor of class A
object(A)#%d (0) {
Access to non-public constructor of class D
object(E)#%d (0) {
}
-Class E does not have a constructor, so you cannot pass any constructor arguments
\ No newline at end of file
+Class E does not have a constructor, so you cannot pass any constructor arguments
}
?>
--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
In constructor of class A
In constructor of class A
object(A)#%d (0) {
Access to non-public constructor of class D
object(E)#%d (0) {
}
-Class E does not have a constructor, so you cannot pass any constructor arguments
\ No newline at end of file
+Class E does not have a constructor, so you cannot pass any constructor arguments
?>
--EXPECTF--
-Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor has a deprecated constructor in %s on line %d
New-style constructor:
bool(true)
?>
--EXPECTF--
-Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; OldCtor 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; B 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; C has a deprecated constructor in %s on line %d
Constructor of NewCtor: __construct
Constructor of ExtendsNewCtor: __construct
Constructor of OldCtor: OldCtor
?>
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d
+
Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d
NULL
}
?>
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld 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; protectedCtorOld 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; privateCtorOld has a deprecated constructor in %s on line %d
Is noCtor instantiable? bool(true)
Is publicCtorNew instantiable? bool(true)
Is protectedCtorNew instantiable? bool(false)
var_dump($e->isConstructor());
?>
===DONE===
---EXPECT--
+--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Root has a deprecated constructor in %s on line %d
bool(true)
bool(false)
bool(true)
<?php
class ancester
{
-public $ancester = 0;
- function ancester()
+ public $ancester = 0;
+ function __construct()
{
return $this->ancester;
}
}
class foo extends ancester
{
-public $bar = "1";
- function foo()
+ public $bar = "1";
+ function __construct()
{
return $this->bar;
}
ReflectionClass::export("bar");
?>
--EXPECTF--
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in %s on line %d
Class [ <user> class bar extends foo ] {
@@ %sbug38942.php 6-7
print_r($m);
?>
---EXPECT--
+--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
+
+Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; B has a deprecated constructor in %s on line %d
Array
(
[0] => ReflectionMethod Object
--FILE--
<?php
-function test($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass &$opt = NULL, $def = "FooBar")
+function test($nix, Array $ar, &$ref, stdClass $std,
+ NonExistingClass $na, stdClass &$opt = NULL, $def = "FooBar")
{
}
class test
{
- function test($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass $opt = NULL, $def = "FooBar")
+ 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();
- echo $f . ': ' . ($c ? ($c instanceof ReflectionMethod ? $c->class . '::' : '') . $c->name : 'NULL') . "()\n";
+ $sep = $c instanceof ReflectionMethod ? $c->class . '::' : '';
+ echo $f . ': ' . ($c ? $sep . $c->name : 'NULL') . "()\n";
}
function check_params_decl_class($r, $f)
check_params(new ReflectionFunction('test'));
-check_params(new ReflectionMethod('test::test'));
+check_params(new ReflectionMethod('test::method'));
?>
===DONE===
isOptional: bool(true)
isDefaultValueAvailable: bool(true)
getDefaultValue: string(6) "FooBar"
-#####test::test()#####
+#####test::method()#####
===0===
getName: string(3) "nix"
isPassedByReference: bool(false)
error_reporting(E_ALL);
class Kill {
- function Kill() {
+ function __construct() {
global $HTTP_SESSION_VARS;
session_start();
}
--FILE--
<?php
class SOAPStruct {
- function SOAPStruct($s, $i, $f) {
+ function __construct($s, $i, $f) {
$this->varString = $s;
$this->varInt = $i;
$this->varFloat = $f;
--FILE--
<?php
class SOAPList {
- function SOAPList($s, $i, $c) {
+ function __construct($s, $i, $c) {
$this->varString = $s;
$this->varInt = $i;
$this->child = $c;
class Foo {
private $str = "";
- function Foo($str) {
+ function __construct($str) {
$this->str = $str . " World";
}
<?php
class Foo {
- function Foo() {
+ function __construct() {
}
function test() {
--EXPECT--
array(2) {
[0]=>
- string(3) "Foo"
+ string(11) "__construct"
[1]=>
string(4) "test"
}
<?php
class Foo {
- function Foo() {
+ function __construct() {
}
function test() {
--EXPECT--
array(2) {
[0]=>
- string(3) "Foo"
+ string(11) "__construct"
[1]=>
string(4) "test"
}
--FILE--
<?php
echo "-TEST\n";
-class filter extends php_user_filter {
+class strtoupper_filter extends php_user_filter {
function filter($in, $out, &$consumed, $closing)
{
$output = 0;
return $output ? PSFS_PASS_ON : PSFS_FEED_ME;
}
}
-stream_filter_register("strtoupper", "filter")
+stream_filter_register("strtoupper", "strtoupper_filter")
or die("Failed to register filter");
if ($f = fopen(__FILE__, "rb")) {
%sTEST
<?PHP
ECHO "-TEST\N";
-CLASS FILTER EXTENDS PHP_USER_FILTER {
+CLASS STRTOUPPER_FILTER EXTENDS PHP_USER_FILTER {
FUNCTION FILTER($IN, $OUT, &$CONSUMED, $CLOSING)
{
$OUTPUT = 0;
RETURN $OUTPUT ? PSFS_PASS_ON : PSFS_FEED_ME;
}
}
-STREAM_FILTER_REGISTER("STRTOUPPER", "FILTER")
+STREAM_FILTER_REGISTER("STRTOUPPER", "STRTOUPPER_FILTER")
OR DIE("FAILED TO REGISTER FILTER");
IF ($F = FOPEN(__FILE__, "RB")) {
<?php
print "Test 11: php:function Support\n";
Class foo {
- function foo() {}
+ function __construct() {}
function __toString() { return "not a DomNode object";}
}
$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
?>
--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
?>
--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
}
?>
--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
}
}
-class Base_php7 {
+class Base_php5 {
function __construct() {
var_dump('Base constructor');
}
}
-class Child_php7 extends Base_php7 {
+class Child_php5 extends Base_php5 {
function __construct() {
var_dump('Child constructor');
parent::__construct();
}
}
-class Child_mx2 extends Base_php7 {
+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 7 style\n";
-$c5= new Child_php7();
+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();
?>
---EXPECT--
+--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 7 style
+### PHP 5 style
string(17) "Child constructor"
string(16) "Base constructor"
### Mixed style 1
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?
?>
--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) {
{
public $storage = '';
- function Class2()
+ function __construct()
{
$this->storage = new Class1();