-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
Testing multiples 'default:' in switch | ||
--FILE-- | ||
<?php | ||
|
||
switch (1) { | ||
case 2: | ||
print 'foo'; | ||
break; | ||
case 3: | ||
print 'bar'; | ||
break; | ||
default: | ||
print 1; | ||
break; | ||
default: | ||
print 2; | ||
break; | ||
default: | ||
print 3; | ||
break; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--TEST-- | ||
Using clone statement on non-object | ||
--FILE-- | ||
<?php | ||
|
||
$a = clone array(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: __clone method called on non-object in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Testing multiple clone statements | ||
--FILE-- | ||
<?php | ||
|
||
$a = clone clone $b = new stdClass; | ||
var_dump($a == $b); | ||
|
||
|
||
$c = clone clone clone $b = new stdClass; | ||
var_dump($a == $b, $b == $c); | ||
|
||
class foo { } | ||
|
||
$d = clone $a = $b = new foo; | ||
var_dump($a == $d, $b == $d, $c == $a); | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
Using clone statement on undefined variable | ||
--FILE-- | ||
<?php | ||
|
||
$a = clone $b; | ||
|
||
?> | ||
--EXPECTF-- | ||
Notice: Undefined variable: b in %s on line %d | ||
|
||
Fatal error: __clone method called on non-object in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Testing usage of object as array on clone statement | ||
--FILE-- | ||
<?php | ||
|
||
error_reporting(E_ALL|E_STRICT); | ||
|
||
class foo { | ||
public function __get($a) { | ||
return new $this; | ||
} | ||
} | ||
|
||
$c = new foo; | ||
|
||
$a = clone $c->b[1]; | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Cannot use object of type foo as array in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
Throwing exception using a class that isn't derived from the Exception base class | ||
--FILE-- | ||
<?php | ||
|
||
error_reporting(E_ALL|E_STRICT); | ||
|
||
class Foo { } | ||
|
||
try { | ||
throw new Foo(); | ||
} catch (Foo $e) { | ||
var_dump($e); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Exceptions must be valid objects derived from the Exception base class in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
Trying declare interface with repeated name of inherited method | ||
--FILE-- | ||
<?php | ||
|
||
interface a { | ||
function b(); | ||
} | ||
|
||
interface b { | ||
function b(); | ||
} | ||
|
||
interface c extends a, b { | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Can't inherit abstract function b::b() (previously declared abstract in a) in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--TEST-- | ||
Testing direct assigning for property of object returned by function | ||
--FILE-- | ||
<?php | ||
|
||
class foo { | ||
static $bar = array(); | ||
|
||
public function __set($a, $b) { | ||
self::$bar[] = $b; | ||
} | ||
|
||
public function __get($a) { | ||
/* last */ | ||
return self::$bar[count(self::$bar)-1]; | ||
} | ||
} | ||
|
||
function test() { | ||
return new foo; | ||
} | ||
|
||
$a = test()->bar = 1; | ||
var_dump($a, count(foo::$bar), test()->whatever); | ||
|
||
print "\n"; | ||
|
||
$a = test()->bar = NULL; | ||
var_dump($a, count(foo::$bar), test()->whatever); | ||
|
||
print "\n"; | ||
|
||
$a = test()->bar = test(); | ||
var_dump($a, count(foo::$bar), test()->whatever); | ||
|
||
print "\n"; | ||
|
||
?> | ||
--EXPECTF-- | ||
int(1) | ||
int(1) | ||
int(1) | ||
|
||
NULL | ||
int(2) | ||
NULL | ||
|
||
object(foo)#%d (0) { | ||
} | ||
int(3) | ||
object(foo)#%d (0) { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
Testing invalid method names with __call and __callstatic | ||
--FILE-- | ||
<?php | ||
|
||
class foo { | ||
public function __call($a, $b) { | ||
print "non-static - ok\n"; | ||
} | ||
|
||
public static function __callstatic($a, $b) { | ||
print "static - ok\n"; | ||
} | ||
} | ||
|
||
$a = new foo; | ||
$a->foooo(); | ||
$a::foooo(); | ||
|
||
$b = 'aaaaa1'; | ||
$a->$b(); | ||
$a::$b(); | ||
|
||
$b = ' '; | ||
$a->$b(); | ||
$a::$b(); | ||
|
||
$b = str_repeat('a', 10000); | ||
$a->$b(); | ||
$a::$b(); | ||
|
||
$b = NULL; | ||
$a->$b(); | ||
|
||
?> | ||
--EXPECTF-- | ||
non-static - ok | ||
static - ok | ||
non-static - ok | ||
static - ok | ||
non-static - ok | ||
static - ok | ||
non-static - ok | ||
static - ok | ||
|
||
Fatal error: Method name must be a string in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--TEST-- | ||
Using $this when out of context | ||
--FILE-- | ||
<?php | ||
|
||
try { | ||
$this->a = 1; | ||
} catch (Exception $e) { | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Using $this when not in object context in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
Testing 'new static;' calling parent method | ||
--FILE-- | ||
<?php | ||
|
||
class bar { | ||
public function show() { | ||
var_dump(new static); | ||
} | ||
} | ||
|
||
class foo extends bar { | ||
public function test() { | ||
parent::show(); | ||
} | ||
} | ||
|
||
$foo = new foo; | ||
$foo->test(); | ||
$foo::test(); | ||
|
||
call_user_func(array($foo, 'test')); | ||
call_user_func(array('foo', 'test')); | ||
|
||
?> | ||
--EXPECTF-- | ||
object(foo)#%d (0) { | ||
} | ||
|
||
Strict Standards: Non-static method foo::test() should not be called statically in %s on line %d | ||
|
||
Strict Standards: Non-static method bar::show() should not be called statically in %s on line %d | ||
object(bar)#%d (0) { | ||
} | ||
object(foo)#%d (0) { | ||
} | ||
|
||
Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method foo::test() should not be called statically in %s on line %d | ||
|
||
Strict Standards: Non-static method foo::test() should not be called statically in %s on line %d | ||
|
||
Strict Standards: Non-static method bar::show() should not be called statically in %s on line %d | ||
object(bar)#%d (0) { | ||
} | ||
|
||
|