Move code that prefixes the API class with the current namespace so that getCompatibleClassVersion() gets the unprefixed name.

Alternative fix for the problem described in #396.
This commit is contained in:
Yahnis Elsts 2020-10-14 19:13:02 +03:00
parent 4778dd3eb4
commit 4bd0a820d1

View file

@ -114,9 +114,6 @@ if ( !class_exists('Puc_v4p10_Factory', false) ):
//Add the current namespace to the class name(s).
if ( version_compare(PHP_VERSION, '5.3', '>=') ) {
$checkerClass = __NAMESPACE__ . '\\' . $checkerClass;
if ( isset($apiClass) ) {
$apiClass = __NAMESPACE__ . '\\' . $apiClass;
}
}

if ( !isset($apiClass) ) {
@ -134,6 +131,10 @@ if ( !class_exists('Puc_v4p10_Factory', false) ):
return null;
}

if ( version_compare(PHP_VERSION, '5.3', '>=') && (strpos($apiClass, '\\') === false) ) {
$apiClass = __NAMESPACE__ . '\\' . $apiClass;
}

return new $checkerClass(
new $apiClass($metadataUrl),
$id,