Skip to content
Permalink
Browse files

interfaces can't have PHP4 constructors

Summary:
Don't raise errors for them

fixes #8121

Reviewed By: markw65

Differential Revision: D7418115
  • Loading branch information...
fredemmott committed Mar 28, 2018
1 parent aeb5357 commit 305fa864ac6ad012bed1ab80d1854c371c0dbb06
@@ -1466,7 +1466,7 @@ void Class::setSpecial() {
return;
}

if (!(attrs() & AttrTrait)) {
if (!(attrs() & (AttrTrait | AttrInterface))) {
// Look for Foo::Foo() (old style constructor) declared in this class
// and deprecate warning if we are in PHP 7 mode
if (matchedClassOrIsTrait(m_preClass->name())) {
@@ -0,0 +1,28 @@
<?php
error_reporting(E_ALL | E_STRICT | E_DEPRECATED);
// No PHP4 constructor
interface foo {
public function foo();
}
// No PHP4 constructor
class bar implements foo {
public function foo() {}
}
// No PHP4 constructor
trait herp {
public function derp() {}
}
// PHP4 constructor via trait
class derp {
use herp;
}
// direct PHP4 constructor
class MyClass {
public function MyClass() {}
}
@@ -0,0 +1,3 @@
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; MyClass has a deprecated constructor in %s/test/slow/php7_bcbreak/php4-constructors.php on line 26

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; derp has a deprecated constructor in %s/test/slow/php7_bcbreak/php4-constructors.php on line 21
@@ -0,0 +1 @@
hhvm.php7.all=1

0 comments on commit 305fa86

Please sign in to comment.
You can’t perform that action at this time.