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--
|
||||
<?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);
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ class bar extends foo {
|
||||
}
|
||||
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
|
||||
|
@ -14,6 +14,7 @@ var_dump(is_callable(array($b,"__construct")));
|
||||
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)
|
||||
|
@ -19,6 +19,7 @@ $b = new B;
|
||||
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
|
||||
|
@ -9,4 +9,6 @@ abstract class bar {
|
||||
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
|
||||
|
@ -1,17 +1,15 @@
|
||||
--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";
|
||||
?>
|
||||
|
@ -20,7 +20,7 @@ class A
|
||||
|
||||
class B
|
||||
{
|
||||
public function B($A)
|
||||
public function __construct($A)
|
||||
{
|
||||
$this->A = $A;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class a {
|
||||
}
|
||||
class b extends a {}
|
||||
class c extends b {
|
||||
function C() {
|
||||
function __construct() {
|
||||
b::b();
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ class testClass2 extends testClass {
|
||||
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)
|
||||
|
@ -22,6 +22,13 @@ class C extends B {
|
||||
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
|
||||
|
@ -29,6 +29,6 @@ class baz {
|
||||
|
||||
?>
|
||||
--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
|
||||
|
@ -14,4 +14,6 @@ $a::$a();
|
||||
|
||||
?>
|
||||
--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
|
||||
|
@ -3,30 +3,30 @@ get_class_methods(): Testing scope
|
||||
--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"
|
||||
|
@ -3,13 +3,13 @@ get_class_methods(): Testing scope
|
||||
--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() { }
|
||||
@ -19,22 +19,22 @@ class 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--
|
||||
|
@ -1,7 +1,5 @@
|
||||
--TEST--
|
||||
redefining constructor (__construct second)
|
||||
--INI--
|
||||
error_reporting=8191
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
@ -15,5 +13,4 @@ class test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Redefining already defined constructor for class test in %s on line %d
|
||||
Done
|
||||
|
@ -9,4 +9,6 @@ class Foo {
|
||||
}
|
||||
|
||||
--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
|
||||
|
@ -50,6 +50,8 @@ $o = new ReportCollision;
|
||||
|
||||
--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
|
||||
|
@ -22,7 +22,8 @@ var_dump($rbarfoo->isConstructor());
|
||||
$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)
|
||||
|
@ -4947,6 +4947,11 @@ void zend_compile_class_decl(zend_ast *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) {
|
||||
ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
|
||||
if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) {
|
||||
|
@ -45,7 +45,7 @@ class tc
|
||||
public $s1 = '日本語EUC-JPの文字列';
|
||||
public $s2 = 'English Text';
|
||||
|
||||
function tc()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ require_once('skipifconnectfailure.inc');
|
||||
private $id;
|
||||
public $id_ref;
|
||||
public function __construct() {
|
||||
parent::construct();
|
||||
parent::__construct();
|
||||
$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')));
|
||||
|
||||
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) {
|
||||
|
@ -36,7 +36,8 @@ try {
|
||||
}
|
||||
|
||||
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===
|
||||
|
@ -64,7 +64,11 @@ foreach ($classes as $class) {
|
||||
|
||||
?>
|
||||
--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
|
||||
|
@ -12,6 +12,8 @@ var_dump($reflectionClass->IsInstantiable(0, null));
|
||||
|
||||
?>
|
||||
--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
|
||||
|
||||
|
@ -41,6 +41,11 @@ foreach($classes as $class ) {
|
||||
|
||||
?>
|
||||
--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)
|
||||
|
@ -71,6 +71,7 @@ try {
|
||||
}
|
||||
?>
|
||||
--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) {
|
||||
|
@ -71,6 +71,7 @@ try {
|
||||
}
|
||||
?>
|
||||
--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) {
|
||||
|
@ -85,7 +85,7 @@ var_dump($methodInfo->isConstructor());
|
||||
|
||||
?>
|
||||
--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)
|
||||
|
||||
|
@ -64,7 +64,11 @@ foreach ($classes as $class) {
|
||||
|
||||
?>
|
||||
--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
|
||||
|
@ -15,6 +15,8 @@ var_dump($reflectionObject->IsInstantiable(0, null));
|
||||
|
||||
?>
|
||||
--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
|
||||
|
||||
|
@ -69,6 +69,11 @@ foreach($reflectionObjects as $reflectionObject ) {
|
||||
}
|
||||
?>
|
||||
--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)
|
||||
|
@ -26,7 +26,8 @@ var_dump($d->isConstructor());
|
||||
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)
|
||||
|
@ -5,7 +5,7 @@ Reflection Bug #36434 (Properties from parent class fail to indetify their true
|
||||
class ancester
|
||||
{
|
||||
public $ancester = 0;
|
||||
function ancester()
|
||||
function __construct()
|
||||
{
|
||||
return $this->ancester;
|
||||
}
|
||||
@ -13,7 +13,7 @@ public $ancester = 0;
|
||||
class foo extends ancester
|
||||
{
|
||||
public $bar = "1";
|
||||
function foo()
|
||||
function __construct()
|
||||
{
|
||||
return $this->bar;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class bar extends foo {
|
||||
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
|
||||
|
||||
|
@ -23,7 +23,10 @@ $m = $R->getMethods();
|
||||
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
|
||||
|
@ -3,13 +3,15 @@ ReflectionParameter::getClass(), getDeclaringClass(), getDeclaringFunction()
|
||||
--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")
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -17,7 +19,8 @@ class test
|
||||
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)
|
||||
@ -66,7 +69,7 @@ function check_params($r)
|
||||
|
||||
check_params(new ReflectionFunction('test'));
|
||||
|
||||
check_params(new ReflectionMethod('test::test'));
|
||||
check_params(new ReflectionMethod('test::method'));
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
@ -138,7 +141,7 @@ allowsNull: bool(true)
|
||||
isOptional: bool(true)
|
||||
isDefaultValueAvailable: bool(true)
|
||||
getDefaultValue: string(6) "FooBar"
|
||||
#####test::test()#####
|
||||
#####test::method()#####
|
||||
===0===
|
||||
getName: string(3) "nix"
|
||||
isPassedByReference: bool(false)
|
||||
|
@ -13,7 +13,7 @@ session.save_handler=files
|
||||
error_reporting(E_ALL);
|
||||
|
||||
class Kill {
|
||||
function Kill() {
|
||||
function __construct() {
|
||||
global $HTTP_SESSION_VARS;
|
||||
session_start();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ precision=14
|
||||
--FILE--
|
||||
<?php
|
||||
class SOAPStruct {
|
||||
function SOAPStruct($s, $i, $f) {
|
||||
function __construct($s, $i, $f) {
|
||||
$this->varString = $s;
|
||||
$this->varInt = $i;
|
||||
$this->varFloat = $f;
|
||||
|
@ -7,7 +7,7 @@ soap.wsdl_cache_enabled=0
|
||||
--FILE--
|
||||
<?php
|
||||
class SOAPList {
|
||||
function SOAPList($s, $i, $c) {
|
||||
function __construct($s, $i, $c) {
|
||||
$this->varString = $s;
|
||||
$this->varInt = $i;
|
||||
$this->child = $c;
|
||||
|
@ -7,7 +7,7 @@ SOAP Server 6: setclass with constructor
|
||||
class Foo {
|
||||
private $str = "";
|
||||
|
||||
function Foo($str) {
|
||||
function __construct($str) {
|
||||
$this->str = $str . " World";
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ SOAP Server 8: setclass and getfunctions
|
||||
<?php
|
||||
class Foo {
|
||||
|
||||
function Foo() {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function test() {
|
||||
@ -22,7 +22,7 @@ echo "ok\n";
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "Foo"
|
||||
string(11) "__construct"
|
||||
[1]=>
|
||||
string(4) "test"
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ SOAP Server 27: setObject and getFunctions
|
||||
<?php
|
||||
class Foo {
|
||||
|
||||
function Foo() {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function test() {
|
||||
@ -23,7 +23,7 @@ echo "ok\n";
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "Foo"
|
||||
string(11) "__construct"
|
||||
[1]=>
|
||||
string(4) "test"
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ stream filter - reading
|
||||
--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;
|
||||
@ -21,7 +21,7 @@ class filter extends php_user_filter {
|
||||
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")) {
|
||||
@ -37,7 +37,7 @@ echo "Done\n";
|
||||
%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;
|
||||
@ -55,7 +55,7 @@ CLASS FILTER EXTENDS PHP_USER_FILTER {
|
||||
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")) {
|
||||
|
@ -6,7 +6,7 @@ Test 11: php:function Support
|
||||
<?php
|
||||
print "Test 11: php:function Support\n";
|
||||
Class foo {
|
||||
function foo() {}
|
||||
function __construct() {}
|
||||
function __toString() { return "not a DomNode object";}
|
||||
}
|
||||
|
||||
|
@ -18,5 +18,6 @@ $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
|
||||
|
@ -25,5 +25,6 @@ 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
|
||||
|
@ -25,5 +25,6 @@ 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
|
||||
|
@ -10,4 +10,6 @@ Ensure implicit final inherited old-style constructor cannot be overridden.
|
||||
}
|
||||
?>
|
||||
--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
|
||||
|
@ -17,13 +17,13 @@ class Child_php4 extends Base_php4 {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@ -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() {
|
||||
var_dump('Child constructor');
|
||||
parent::__construct();
|
||||
@ -47,8 +47,8 @@ class Child_mx2 extends Base_php7 {
|
||||
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();
|
||||
@ -56,11 +56,16 @@ $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
|
||||
|
@ -41,6 +41,7 @@ Check for inherited old-style constructor.
|
||||
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?
|
||||
|
@ -18,6 +18,7 @@ $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) {
|
||||
|
@ -12,7 +12,7 @@ class Class2
|
||||
{
|
||||
public $storage = '';
|
||||
|
||||
function Class2()
|
||||
function __construct()
|
||||
{
|
||||
$this->storage = new Class1();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user