php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54074 SoapClient classmap ignores currently set namespace
Submitted: 2011-02-22 19:43 UTC Modified: 2018-03-23 11:51 UTC
Votes:5
Avg. Score:3.8 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: php at jcald dot com Assigned:
Status: Not a bug Package: SOAP related
PHP Version: 5.3.5 OS: Linux 2.6.18-194 (Centos 5.5)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at jcald dot com
New email:
PHP Version: OS:

 

 [2011-02-22 19:43 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-12 00:55 UTC] 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'
);
 [2015-01-23 19:49 UTC] 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.
 [2018-03-23 11:51 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2018-03-23 11:51 UTC] nikic@php.net
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'.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC