mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Finish PHP 4 constructor deprecation
This commit is contained in:
parent
db76b708cf
commit
6ef9216269
@ -3,13 +3,13 @@ Bug #31177 (memory corruption because of incorrect refcounting)
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
class foo {
|
class foo {
|
||||||
function foo($n=0) {
|
function __construct($n=0) {
|
||||||
if($n) throw new Exception("new");
|
if($n) throw new Exception("new");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$x = new foo();
|
$x = new foo();
|
||||||
try {
|
try {
|
||||||
$y=$x->foo(1);
|
$y=$x->__construct(1);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
var_dump($x);
|
var_dump($x);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ class bar extends foo {
|
|||||||
}
|
}
|
||||||
print_r(get_class_methods("bar"));
|
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
|
Array
|
||||||
(
|
(
|
||||||
[0] => foo
|
[0] => foo
|
||||||
|
@ -14,6 +14,7 @@ var_dump(is_callable(array($b,"__construct")));
|
|||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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"
|
string(13) "a::a() called"
|
||||||
bool(true)
|
bool(true)
|
||||||
bool(false)
|
bool(false)
|
||||||
|
@ -19,6 +19,7 @@ $b = new B;
|
|||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
||||||
I'm A
|
I'm A
|
||||||
Done
|
Done
|
||||||
|
@ -9,4 +9,6 @@ abstract class bar {
|
|||||||
class foo extends bar {
|
class foo extends bar {
|
||||||
}
|
}
|
||||||
--EXPECTF--
|
--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
|
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
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
--TEST--
|
--TEST--
|
||||||
Bug #46381 (wrong $this passed to internal methods causes segfault)
|
Bug #46381 (wrong $this passed to internal methods causes segfault)
|
||||||
--SKIPIF--
|
|
||||||
<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?>
|
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class test {
|
class test {
|
||||||
public function test() {
|
public function method() {
|
||||||
return ArrayIterator::current();
|
return ArrayIterator::current();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$test = new test();
|
$test = new test();
|
||||||
$test->test();
|
$test->method();
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
|
@ -20,7 +20,7 @@ class A
|
|||||||
|
|
||||||
class B
|
class B
|
||||||
{
|
{
|
||||||
public function B($A)
|
public function __construct($A)
|
||||||
{
|
{
|
||||||
$this->A = $A;
|
$this->A = $A;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ class a {
|
|||||||
}
|
}
|
||||||
class b extends a {}
|
class b extends a {}
|
||||||
class c extends b {
|
class c extends b {
|
||||||
function C() {
|
function __construct() {
|
||||||
b::b();
|
b::b();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,8 @@ class testClass2 extends testClass {
|
|||||||
new testClass2;
|
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 (1)
|
||||||
testClass::testClass (2)
|
testClass::testClass (2)
|
||||||
testClass::testClass (3)
|
testClass::testClass (3)
|
||||||
|
@ -22,6 +22,13 @@ class C extends B {
|
|||||||
new C();
|
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
|
foo
|
||||||
bar
|
bar
|
||||||
|
@ -29,6 +29,6 @@ class baz {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
Fatal error: Constructor baz::baz() cannot be static in %s on line %d
|
||||||
|
@ -14,4 +14,6 @@ $a::$a();
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
Fatal error: Non-static method foo::foo() cannot be called statically in %s on line %d
|
||||||
|
@ -3,30 +3,30 @@ get_class_methods(): Testing scope
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class A {
|
abstract class X {
|
||||||
public function a() { }
|
public function a() { }
|
||||||
private function b() { }
|
private function b() { }
|
||||||
protected function c() { }
|
protected function c() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
class B extends A {
|
class Y extends X {
|
||||||
private function bb() { }
|
private function bb() { }
|
||||||
|
|
||||||
static public function test() {
|
static public function test() {
|
||||||
var_dump(get_class_methods('A'));
|
var_dump(get_class_methods('X'));
|
||||||
var_dump(get_class_methods('B'));
|
var_dump(get_class_methods('Y'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var_dump(get_class_methods('A'));
|
var_dump(get_class_methods('X'));
|
||||||
var_dump(get_class_methods('B'));
|
var_dump(get_class_methods('Y'));
|
||||||
|
|
||||||
|
|
||||||
B::test();
|
Y::test();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
array(1) {
|
array(1) {
|
||||||
[0]=>
|
[0]=>
|
||||||
string(1) "a"
|
string(1) "a"
|
||||||
|
@ -3,13 +3,13 @@ get_class_methods(): Testing scope
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
interface A {
|
interface I {
|
||||||
function aa();
|
function aa();
|
||||||
function bb();
|
function bb();
|
||||||
static function cc();
|
static function cc();
|
||||||
}
|
}
|
||||||
|
|
||||||
class C {
|
class X {
|
||||||
public function a() { }
|
public function a() { }
|
||||||
protected function b() { }
|
protected function b() { }
|
||||||
private function c() { }
|
private function c() { }
|
||||||
@ -19,22 +19,22 @@ class C {
|
|||||||
static private function static_c() { }
|
static private function static_c() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
class B extends C implements A {
|
class Y extends X implements I {
|
||||||
public function aa() { }
|
public function aa() { }
|
||||||
public function bb() { }
|
public function bb() { }
|
||||||
|
|
||||||
static function cc() { }
|
static function cc() { }
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
var_dump(get_class_methods('A'));
|
var_dump(get_class_methods('I'));
|
||||||
var_dump(get_class_methods('B'));
|
var_dump(get_class_methods('Y'));
|
||||||
var_dump(get_class_methods('C'));
|
var_dump(get_class_methods('X'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct() { }
|
public function __destruct() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
new B;
|
new Y;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
--TEST--
|
--TEST--
|
||||||
redefining constructor (__construct second)
|
redefining constructor (__construct second)
|
||||||
--INI--
|
|
||||||
error_reporting=8191
|
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@ -15,5 +13,4 @@ class test {
|
|||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Strict Standards: Redefining already defined constructor for class test in %s on line %d
|
|
||||||
Done
|
Done
|
||||||
|
@ -9,4 +9,6 @@ class Foo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--EXPECTF--
|
--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
|
Fatal error: Constructor %s::%s() cannot declare a return type in %s on line %s
|
||||||
|
@ -50,6 +50,8 @@ $o = new ReportCollision;
|
|||||||
|
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
OverridingIsSilent1 __construct
|
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
|
OverridingIsSilent2 OverridingIsSilent2
|
||||||
|
|
||||||
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
Fatal error: ReportCollision has colliding constructor definitions coming from traits in %s on line %d
|
||||||
|
@ -22,7 +22,8 @@ var_dump($rbarfoo->isConstructor());
|
|||||||
$rbarbar = new ReflectionMethod('Bar::Bar');
|
$rbarbar = new ReflectionMethod('Bar::Bar');
|
||||||
var_dump($rbarbar->isConstructor());
|
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(false)
|
bool(false)
|
||||||
bool(true)
|
bool(true)
|
||||||
|
@ -4947,6 +4947,11 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
|
|||||||
|
|
||||||
zend_compile_stmt(stmt_ast);
|
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) {
|
if (ce->constructor) {
|
||||||
ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
|
ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
|
||||||
if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) {
|
if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) {
|
||||||
|
@ -45,7 +45,7 @@ class tc
|
|||||||
public $s1 = '日本語EUC-JPの文字列';
|
public $s1 = '日本語EUC-JPの文字列';
|
||||||
public $s2 = 'English Text';
|
public $s2 = 'English Text';
|
||||||
|
|
||||||
function tc()
|
function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ require_once('skipifconnectfailure.inc');
|
|||||||
private $id;
|
private $id;
|
||||||
public $id_ref;
|
public $id_ref;
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::construct();
|
parent::__construct();
|
||||||
$this->id_ref = &$this->id;
|
$this->id_ref = &$this->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,14 @@ $st = $db->query('SELECT * FROM testing');
|
|||||||
var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
|
var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
|
||||||
|
|
||||||
class foo {
|
class foo {
|
||||||
public function foo($x) {
|
public function method($x) {
|
||||||
return "--- $x ---";
|
return "--- $x ---";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class bar extends foo {
|
class bar extends foo {
|
||||||
public function __construct($db) {
|
public function __construct($db) {
|
||||||
$st = $db->query('SELECT * FROM testing');
|
$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) {
|
static public function test($x, $y) {
|
||||||
|
@ -36,7 +36,8 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo "===DONE===\n";?>
|
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()
|
Non-object passed to Invoke()
|
||||||
Given object is not an instance of the class this method was declared in
|
Given object is not an instance of the class this method was declared in
|
||||||
===DONE===
|
===DONE===
|
||||||
|
@ -64,7 +64,11 @@ foreach ($classes as $class) {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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 NewCtor: __construct
|
||||||
Constructor of ExtendsNewCtor: __construct
|
Constructor of ExtendsNewCtor: __construct
|
||||||
Constructor of OldCtor: OldCtor
|
Constructor of OldCtor: OldCtor
|
||||||
|
@ -12,6 +12,8 @@ var_dump($reflectionClass->IsInstantiable(0, null));
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
|
@ -41,6 +41,11 @@ foreach($classes as $class ) {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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 noCtor instantiable? bool(true)
|
||||||
Is publicCtorNew instantiable? bool(true)
|
Is publicCtorNew instantiable? bool(true)
|
||||||
Is protectedCtorNew instantiable? bool(false)
|
Is protectedCtorNew instantiable? bool(false)
|
||||||
|
@ -71,6 +71,7 @@ try {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
||||||
In constructor of class A
|
In constructor of class A
|
||||||
object(A)#%d (0) {
|
object(A)#%d (0) {
|
||||||
@ -95,4 +96,4 @@ Access to non-public constructor of class C
|
|||||||
Access to non-public constructor of class D
|
Access to non-public constructor of class D
|
||||||
object(E)#%d (0) {
|
object(E)#%d (0) {
|
||||||
}
|
}
|
||||||
Class E does not have a constructor, so you cannot pass any constructor arguments
|
Class E does not have a constructor, so you cannot pass any constructor arguments
|
||||||
|
@ -71,6 +71,7 @@ try {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
||||||
In constructor of class A
|
In constructor of class A
|
||||||
object(A)#%d (0) {
|
object(A)#%d (0) {
|
||||||
@ -95,4 +96,4 @@ Access to non-public constructor of class C
|
|||||||
Access to non-public constructor of class D
|
Access to non-public constructor of class D
|
||||||
object(E)#%d (0) {
|
object(E)#%d (0) {
|
||||||
}
|
}
|
||||||
Class E does not have a constructor, so you cannot pass any constructor arguments
|
Class E does not have a constructor, so you cannot pass any constructor arguments
|
||||||
|
@ -85,7 +85,7 @@ var_dump($methodInfo->isConstructor());
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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:
|
New-style constructor:
|
||||||
bool(true)
|
bool(true)
|
||||||
|
|
||||||
|
@ -64,7 +64,11 @@ foreach ($classes as $class) {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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 NewCtor: __construct
|
||||||
Constructor of ExtendsNewCtor: __construct
|
Constructor of ExtendsNewCtor: __construct
|
||||||
Constructor of OldCtor: OldCtor
|
Constructor of OldCtor: OldCtor
|
||||||
|
@ -15,6 +15,8 @@ var_dump($reflectionObject->IsInstantiable(0, null));
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
Warning: ReflectionClass::isInstantiable() expects exactly 0 parameters, 1 given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
|
@ -69,6 +69,11 @@ foreach($reflectionObjects as $reflectionObject ) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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 noCtor instantiable? bool(true)
|
||||||
Is publicCtorNew instantiable? bool(true)
|
Is publicCtorNew instantiable? bool(true)
|
||||||
Is protectedCtorNew instantiable? bool(false)
|
Is protectedCtorNew instantiable? bool(false)
|
||||||
|
@ -26,7 +26,8 @@ var_dump($d->isConstructor());
|
|||||||
var_dump($e->isConstructor());
|
var_dump($e->isConstructor());
|
||||||
?>
|
?>
|
||||||
===DONE===
|
===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(true)
|
||||||
bool(false)
|
bool(false)
|
||||||
bool(true)
|
bool(true)
|
||||||
|
@ -4,16 +4,16 @@ Reflection Bug #36434 (Properties from parent class fail to indetify their true
|
|||||||
<?php
|
<?php
|
||||||
class ancester
|
class ancester
|
||||||
{
|
{
|
||||||
public $ancester = 0;
|
public $ancester = 0;
|
||||||
function ancester()
|
function __construct()
|
||||||
{
|
{
|
||||||
return $this->ancester;
|
return $this->ancester;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class foo extends ancester
|
class foo extends ancester
|
||||||
{
|
{
|
||||||
public $bar = "1";
|
public $bar = "1";
|
||||||
function foo()
|
function __construct()
|
||||||
{
|
{
|
||||||
return $this->bar;
|
return $this->bar;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ class bar extends foo {
|
|||||||
ReflectionClass::export("bar");
|
ReflectionClass::export("bar");
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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 ] {
|
Class [ <user> class bar extends foo ] {
|
||||||
@@ %sbug38942.php 6-7
|
@@ %sbug38942.php 6-7
|
||||||
|
|
||||||
|
@ -23,7 +23,10 @@ $m = $R->getMethods();
|
|||||||
print_r($m);
|
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
|
Array
|
||||||
(
|
(
|
||||||
[0] => ReflectionMethod Object
|
[0] => ReflectionMethod Object
|
||||||
|
@ -3,13 +3,15 @@ ReflectionParameter::getClass(), getDeclaringClass(), getDeclaringFunction()
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?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
|
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")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,7 +19,8 @@ class test
|
|||||||
function check_params_decl_func($r, $f)
|
function check_params_decl_func($r, $f)
|
||||||
{
|
{
|
||||||
$c = $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)
|
function check_params_decl_class($r, $f)
|
||||||
@ -66,7 +69,7 @@ function check_params($r)
|
|||||||
|
|
||||||
check_params(new ReflectionFunction('test'));
|
check_params(new ReflectionFunction('test'));
|
||||||
|
|
||||||
check_params(new ReflectionMethod('test::test'));
|
check_params(new ReflectionMethod('test::method'));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
===DONE===
|
===DONE===
|
||||||
@ -138,7 +141,7 @@ allowsNull: bool(true)
|
|||||||
isOptional: bool(true)
|
isOptional: bool(true)
|
||||||
isDefaultValueAvailable: bool(true)
|
isDefaultValueAvailable: bool(true)
|
||||||
getDefaultValue: string(6) "FooBar"
|
getDefaultValue: string(6) "FooBar"
|
||||||
#####test::test()#####
|
#####test::method()#####
|
||||||
===0===
|
===0===
|
||||||
getName: string(3) "nix"
|
getName: string(3) "nix"
|
||||||
isPassedByReference: bool(false)
|
isPassedByReference: bool(false)
|
||||||
|
@ -13,7 +13,7 @@ session.save_handler=files
|
|||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
class Kill {
|
class Kill {
|
||||||
function Kill() {
|
function __construct() {
|
||||||
global $HTTP_SESSION_VARS;
|
global $HTTP_SESSION_VARS;
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ precision=14
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
class SOAPStruct {
|
class SOAPStruct {
|
||||||
function SOAPStruct($s, $i, $f) {
|
function __construct($s, $i, $f) {
|
||||||
$this->varString = $s;
|
$this->varString = $s;
|
||||||
$this->varInt = $i;
|
$this->varInt = $i;
|
||||||
$this->varFloat = $f;
|
$this->varFloat = $f;
|
||||||
|
@ -7,7 +7,7 @@ soap.wsdl_cache_enabled=0
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
class SOAPList {
|
class SOAPList {
|
||||||
function SOAPList($s, $i, $c) {
|
function __construct($s, $i, $c) {
|
||||||
$this->varString = $s;
|
$this->varString = $s;
|
||||||
$this->varInt = $i;
|
$this->varInt = $i;
|
||||||
$this->child = $c;
|
$this->child = $c;
|
||||||
|
@ -7,7 +7,7 @@ SOAP Server 6: setclass with constructor
|
|||||||
class Foo {
|
class Foo {
|
||||||
private $str = "";
|
private $str = "";
|
||||||
|
|
||||||
function Foo($str) {
|
function __construct($str) {
|
||||||
$this->str = $str . " World";
|
$this->str = $str . " World";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ SOAP Server 8: setclass and getfunctions
|
|||||||
<?php
|
<?php
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|
||||||
function Foo() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
@ -22,7 +22,7 @@ echo "ok\n";
|
|||||||
--EXPECT--
|
--EXPECT--
|
||||||
array(2) {
|
array(2) {
|
||||||
[0]=>
|
[0]=>
|
||||||
string(3) "Foo"
|
string(11) "__construct"
|
||||||
[1]=>
|
[1]=>
|
||||||
string(4) "test"
|
string(4) "test"
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ SOAP Server 27: setObject and getFunctions
|
|||||||
<?php
|
<?php
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|
||||||
function Foo() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
@ -23,7 +23,7 @@ echo "ok\n";
|
|||||||
--EXPECT--
|
--EXPECT--
|
||||||
array(2) {
|
array(2) {
|
||||||
[0]=>
|
[0]=>
|
||||||
string(3) "Foo"
|
string(11) "__construct"
|
||||||
[1]=>
|
[1]=>
|
||||||
string(4) "test"
|
string(4) "test"
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ stream filter - reading
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
echo "-TEST\n";
|
echo "-TEST\n";
|
||||||
class filter extends php_user_filter {
|
class strtoupper_filter extends php_user_filter {
|
||||||
function filter($in, $out, &$consumed, $closing)
|
function filter($in, $out, &$consumed, $closing)
|
||||||
{
|
{
|
||||||
$output = 0;
|
$output = 0;
|
||||||
@ -21,7 +21,7 @@ class filter extends php_user_filter {
|
|||||||
return $output ? PSFS_PASS_ON : PSFS_FEED_ME;
|
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");
|
or die("Failed to register filter");
|
||||||
|
|
||||||
if ($f = fopen(__FILE__, "rb")) {
|
if ($f = fopen(__FILE__, "rb")) {
|
||||||
@ -37,7 +37,7 @@ echo "Done\n";
|
|||||||
%sTEST
|
%sTEST
|
||||||
<?PHP
|
<?PHP
|
||||||
ECHO "-TEST\N";
|
ECHO "-TEST\N";
|
||||||
CLASS FILTER EXTENDS PHP_USER_FILTER {
|
CLASS STRTOUPPER_FILTER EXTENDS PHP_USER_FILTER {
|
||||||
FUNCTION FILTER($IN, $OUT, &$CONSUMED, $CLOSING)
|
FUNCTION FILTER($IN, $OUT, &$CONSUMED, $CLOSING)
|
||||||
{
|
{
|
||||||
$OUTPUT = 0;
|
$OUTPUT = 0;
|
||||||
@ -55,7 +55,7 @@ CLASS FILTER EXTENDS PHP_USER_FILTER {
|
|||||||
RETURN $OUTPUT ? PSFS_PASS_ON : PSFS_FEED_ME;
|
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");
|
OR DIE("FAILED TO REGISTER FILTER");
|
||||||
|
|
||||||
IF ($F = FOPEN(__FILE__, "RB")) {
|
IF ($F = FOPEN(__FILE__, "RB")) {
|
||||||
|
@ -6,7 +6,7 @@ Test 11: php:function Support
|
|||||||
<?php
|
<?php
|
||||||
print "Test 11: php:function Support\n";
|
print "Test 11: php:function Support\n";
|
||||||
Class foo {
|
Class foo {
|
||||||
function foo() {}
|
function __construct() {}
|
||||||
function __toString() { return "not a DomNode object";}
|
function __toString() { return "not a DomNode object";}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,5 +18,6 @@ $obj = new derived();
|
|||||||
$obj->base();
|
$obj->base();
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
base::base
|
||||||
derived::base
|
derived::base
|
||||||
|
@ -25,5 +25,6 @@ ReflectionClass::export('Extended');
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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 Base::__construct() with Extended::Extended() in %sfinal_ctor1.php on line %d
|
||||||
|
@ -25,5 +25,6 @@ ReflectionClass::export('Extended');
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
Fatal error: Cannot override final Base::Base() with Extended::__construct() in %sfinal_ctor2.php on line %d
|
||||||
|
@ -10,4 +10,6 @@ Ensure implicit final inherited old-style constructor cannot be overridden.
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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
|
Fatal error: Cannot override final method A::A() in %s on line %d
|
||||||
|
@ -17,13 +17,13 @@ class Child_php4 extends Base_php4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Base_php7 {
|
class Base_php5 {
|
||||||
function __construct() {
|
function __construct() {
|
||||||
var_dump('Base constructor');
|
var_dump('Base constructor');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Child_php7 extends Base_php7 {
|
class Child_php5 extends Base_php5 {
|
||||||
function __construct() {
|
function __construct() {
|
||||||
var_dump('Child constructor');
|
var_dump('Child constructor');
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@ -37,7 +37,7 @@ class Child_mx1 extends Base_php4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Child_mx2 extends Base_php7 {
|
class Child_mx2 extends Base_php5 {
|
||||||
function Child_mx2() {
|
function Child_mx2() {
|
||||||
var_dump('Child constructor');
|
var_dump('Child constructor');
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@ -47,8 +47,8 @@ class Child_mx2 extends Base_php7 {
|
|||||||
echo "### PHP 4 style\n";
|
echo "### PHP 4 style\n";
|
||||||
$c4= new Child_php4();
|
$c4= new Child_php4();
|
||||||
|
|
||||||
echo "### PHP 7 style\n";
|
echo "### PHP 5 style\n";
|
||||||
$c5= new Child_php7();
|
$c5= new Child_php5();
|
||||||
|
|
||||||
echo "### Mixed style 1\n";
|
echo "### Mixed style 1\n";
|
||||||
$cm= new Child_mx1();
|
$cm= new Child_mx1();
|
||||||
@ -56,11 +56,16 @@ $cm= new Child_mx1();
|
|||||||
echo "### Mixed style 2\n";
|
echo "### Mixed style 2\n";
|
||||||
$cm= new Child_mx2();
|
$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
|
### PHP 4 style
|
||||||
string(17) "Child constructor"
|
string(17) "Child constructor"
|
||||||
string(16) "Base constructor"
|
string(16) "Base constructor"
|
||||||
### PHP 7 style
|
### PHP 5 style
|
||||||
string(17) "Child constructor"
|
string(17) "Child constructor"
|
||||||
string(16) "Base constructor"
|
string(16) "Base constructor"
|
||||||
### Mixed style 1
|
### Mixed style 1
|
||||||
|
@ -41,6 +41,7 @@ Check for inherited old-style constructor.
|
|||||||
var_dump(is_callable(array($c, "C")));
|
var_dump(is_callable(array($c, "C")));
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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:
|
About to construct new B:
|
||||||
In A::A
|
In A::A
|
||||||
Is B::B() callable?
|
Is B::B() callable?
|
||||||
|
@ -18,6 +18,7 @@ $b->b();
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--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) {
|
array(2) {
|
||||||
[0]=>
|
[0]=>
|
||||||
object(ReflectionMethod)#%d (2) {
|
object(ReflectionMethod)#%d (2) {
|
||||||
|
@ -12,7 +12,7 @@ class Class2
|
|||||||
{
|
{
|
||||||
public $storage = '';
|
public $storage = '';
|
||||||
|
|
||||||
function Class2()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->storage = new Class1();
|
$this->storage = new Class1();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user