mirror of
https://github.com/php/php-src.git
synced 2024-12-15 21:05:51 +08:00
No more namespaces
This commit is contained in:
parent
344737c24e
commit
0137868171
@ -1,62 +0,0 @@
|
||||
--TEST--
|
||||
Serialize and namespaces
|
||||
--FILE--
|
||||
<?php
|
||||
function autoload($fqcn) {
|
||||
list($namespace, $class)= explode('::', $fqcn);
|
||||
if ('power' == $namespace) {
|
||||
eval('namespace '.$namespace.' { class '.$class.' {}}');
|
||||
}
|
||||
}
|
||||
|
||||
namespace Foo:Baz {
|
||||
class Bar { }
|
||||
}
|
||||
|
||||
class Baz { }
|
||||
|
||||
echo "#### 1 ####\n";
|
||||
$bar= new Foo:Baz::Bar();
|
||||
var_dump($bar, serialize($bar), unserialize(serialize($bar)));
|
||||
|
||||
echo "#### 2 ####\n";
|
||||
$baz= new Baz();
|
||||
var_dump(serialize($baz), unserialize(serialize($baz)));
|
||||
|
||||
echo "#### 3 ####\n";
|
||||
var_dump(unserialize('O:7:"Binford":0:{}'));
|
||||
|
||||
echo "#### 4 ####\n";
|
||||
ini_set('unserialize_callback_func', 'autoload');
|
||||
var_dump(unserialize('O:14:"Power::Binford":0:{}'));
|
||||
echo "#### 5 ####\n";
|
||||
var_dump(unserialize('O:14:"Idiot::Binford":0:{}'));
|
||||
?>
|
||||
--EXPECTF--
|
||||
#### 1 ####
|
||||
object(foo:baz::bar)#1 (0) {
|
||||
}
|
||||
string(14) "O:3:"bar":0:{}"
|
||||
object(__PHP_Incomplete_Class)#2 (1) {
|
||||
["__PHP_Incomplete_Class_Name"]=>
|
||||
string(3) "bar"
|
||||
}
|
||||
#### 2 ####
|
||||
string(14) "O:3:"baz":0:{}"
|
||||
object(baz)#3 (0) {
|
||||
}
|
||||
#### 3 ####
|
||||
object(__PHP_Incomplete_Class)#3 (1) {
|
||||
["__PHP_Incomplete_Class_Name"]=>
|
||||
string(7) "binford"
|
||||
}
|
||||
#### 4 ####
|
||||
object(power::binford)#3 (0) {
|
||||
}
|
||||
#### 5 ####
|
||||
|
||||
Warning: unserialize(): Function autoload() hasn't defined the class it was called for in %s on line %d
|
||||
object(__PHP_Incomplete_Class)#3 (1) {
|
||||
["__PHP_Incomplete_Class_Name"]=>
|
||||
string(14) "idiot::binford"
|
||||
}
|
Loading…
Reference in New Issue
Block a user