Bug #54074 [Opn->Nab]: SoapClient classmap ignores currently set namespace

From: Date: Fri, 23 Mar 2018 11:51:31 +0000
Subject: Bug #54074 [Opn->Nab]: SoapClient classmap ignores currently set namespace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214452@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54074&edit=1 ID: 54074 Updated by: nikic@php.net Reported by: php at jcald dot com Summary: SoapClient classmap ignores currently set namespace -Status: Open +Status: Not a bug Type: Bug Package: SOAP related Operating System: Linux 2.6.18-194 (Centos 5.5) PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Class names inside strings are *always* fully qualified. As of PHP 5.5 the ::class syntax can be used to retrieve the canonical class name, that is in your case using session::class and foo::class gives 'Other\session' and 'Other\foo'. Previous Comments: ------------------------------------------------------------------------ [2015-01-23 19:49:06] info at cyclical dot ca This issue is still present in php 5.5 and is confirmed. The workaround is to always specify a full namespace starting from the root \. Unfortunately this can get pretty verbose. ------------------------------------------------------------------------ [2012-04-12 00:55:06] me at jacobt dot com You need to define the namespace in the classmap.. eg. private static $classmap = array( 'foo' => 'Other\foo', 'bar' => 'Other\bar' ); ------------------------------------------------------------------------ [2011-02-22 19:43:23] php at jcald dot com Description: ------------ When a class extending SoapClient is defined in a namespace, the classmap ignores the current namespace and maps classes directly to the global namespace. In order for it to function correctly, the classmap must include the "fully qualified" namespace\classname as the target. Currently, I'm using a wrapper class for SoapClient that prepends __NAMESPACE__ onto the classmap entries to get around this issue. Test script: --------------- // This is NOT a fully complete test script, since it requires testing against an actual SOAP server to function. Plus I couldn't fit that in 20 lines. //Does not work: namespace Other; class OtherService extends \SoapClient { private static $classmap = array( 'session' => 'session', 'foo' => 'foo' ); // etc etc } //Works: namespace Other; class OtherService extends \SoapClient { private static $classmap = array( 'session' => 'Other\session', 'foo' => 'Other\foo' ); // etc etc } Expected result: ---------------- The classmap would obey the current namespace. Actual result: -------------- PHP Fatal error: Class 'session' not found in test.php on line XX ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54074&edit=1

« previous php.bugs (#214452) next »