Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Only try to remove the namespace from a classname if there is a names…
Browse files Browse the repository at this point in the history
…pace and add backslash for non namespace classes

For non-namespace classes this substr/strlen algorithm removed the first character of the classname.
The slash is needed when generating namespace classes, which use non-namespace classes.
  • Loading branch information
danez authored and Daniel Tschinder committed Aug 21, 2013
1 parent b81c8ad commit 29dbe1a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions library/Zend/Code/Generator/ParameterGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ public static function fromReflection(ParameterReflection $reflectionParameter)
$parameterType = $typeClass->getName();
$currentNamespace = $reflectionParameter->getDeclaringClass()->getNamespaceName();

if (substr($parameterType, 0, strlen($currentNamespace)) == $currentNamespace) {
$parameterType = substr($parameterType, strlen($currentNamespace)+1);
if (!empty($currentNamespace)) {
if (substr($parameterType, 0, strlen($currentNamespace)) == $currentNamespace) {
$parameterType = substr($parameterType, strlen($currentNamespace) + 1);
}
} else {
$parameterType = '\\' . trim($parameterType, '\\');
}

$param->setType($parameterType);
Expand Down

0 comments on commit 29dbe1a

Please sign in to comment.