Edit report at https://bugs.php.net/bug.php?id=64554&edit=1

 ID:                 64554
 Updated by:         larue...@php.net
 Reported by:        cornelius dot howl at gmail dot com
 Summary:            var_export does not export absolute namespace for
                     classname
 Status:             Assigned
 Type:               Bug
 Package:            *General Issues
 Operating System:   Any
 PHP Version:        5.4.13
-Assigned To:        laruence
+Assigned To:        
 Block user comment: N
 Private report:     N

 New Comment:

change to doc bug, see: http://marc.info/?l=php-internals&m=136599465400822&w=2


Previous Comments:
------------------------------------------------------------------------
[2013-03-31 12:19:54] larue...@php.net

I think similar issue also exists in serialize...

------------------------------------------------------------------------
[2013-03-31 09:48:23] larue...@php.net

hmm, I feel this probably make sense, simply add a lead '\\' solve the problem:


diff --git a/ext/standard/var.c b/ext/standard/var.c
index f76a14c..67a0a72 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -485,6 +485,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, 
smart_str *buf TSRMLS_DC)
                }
                Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, 
&class_name_len, 0 TSRMLS_CC);

+               smart_str_appendc(buf, '\\');
                smart_str_appendl(buf, class_name, class_name_len);
                smart_str_appendl(buf, "::__set_state(array(\n", 21);


but not sure the side-affect, need more testing

------------------------------------------------------------------------
[2013-03-31 05:55:28] cornelius dot howl at gmail dot com

Description:
------------
---
>From manual page: http://www.php.net/function.var-export#refsect1-function.var-
export-description
---

If I defined a class "Foo\Bar\C" that implements __set_state method, then use 
var_export to export the php code, and put this exported code to another 
namespace, it will causes "class not found".

because the exported class name is "Foo\Bar\C" not "\Foo\Bar\C", the class can 
not 
be found without the root namespace.  :(

var_export should always export the root namespace.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64554&edit=1

Reply via email to