Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit c527213

Browse files
committed
Merge branch 'hotfix/75'
Close #75 Fixes #74 Fixes #80 Fixes #81
2 parents 1eadc83 + 8a66385 commit c527213

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 3.0.4 - TBD
5+
## 3.0.4 - 2016-06-30
66

77
### Added
88

@@ -20,6 +20,9 @@ All notable changes to this project will be documented in this file, in reverse
2020

2121
- [#59](https://github.com/zendframework/zend-code/pull/59) fixes an issue with
2222
detection of multiple trait `use` statements.
23+
- [#75](https://github.com/zendframework/zend-code/pull/75) provides a patch to
24+
ensure that `extends` statements qualify the parent class based on the current
25+
namespace and/or import statements.
2326

2427
## 3.0.3 - 2016-06-27
2528

src/Generator/ClassGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ private function validateConstantValue($value)
10181018
*/
10191019
private function generateShortOrCompleteClassname($fqnClassName)
10201020
{
1021+
$fqnClassName = ltrim($fqnClassName, '\\');
10211022
$parts = explode('\\', $fqnClassName);
10221023
$className = array_pop($parts);
10231024
$classNamespace = implode('\\', $parts);

test/Generator/ClassGeneratorTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,19 +1094,48 @@ public function testCorrectExtendNames()
10941094
$classGenerator->addUse('Zend\Code\NameInformation');
10951095
$classGenerator->setExtendedClass('Zend\Code\NameInformation');
10961096
$this->assertContains('class ClassName extends NameInformation', $classGenerator->generate());
1097+
}
10971098

1099+
/**
1100+
* @group 75
1101+
*/
1102+
public function testCorrectlyExtendsFullyQualifiedParentClass()
1103+
{
10981104
$classGenerator = new ClassGenerator();
10991105
$classGenerator->setName('ClassName');
11001106
$classGenerator->setNamespaceName('SomeNamespace');
11011107
$classGenerator->setExtendedClass('DateTime');
11021108
$this->assertContains('class ClassName extends \DateTime', $classGenerator->generate());
1109+
}
11031110

1111+
/**
1112+
* @group 75
1113+
*/
1114+
public function testCorrectlyExtendsRelativeParentClass()
1115+
{
11041116
$classGenerator = new ClassGenerator();
11051117
$classGenerator->setName('ClassName');
11061118
$classGenerator->setExtendedClass('DateTime');
11071119
$this->assertContains('class ClassName extends DateTime', $classGenerator->generate());
11081120
}
11091121

1122+
/**
1123+
* @group 75
1124+
*/
1125+
public function testCorrectExtendNamesFromGlobalNamespace()
1126+
{
1127+
$classGenerator = new ClassGenerator();
1128+
$classGenerator->setName('ClassName');
1129+
$classGenerator->setNamespaceName('SomeNamespace');
1130+
$classGenerator->setExtendedClass('\DateTime');
1131+
$this->assertContains('class ClassName extends \DateTime', $classGenerator->generate());
1132+
1133+
$classGenerator = new ClassGenerator();
1134+
$classGenerator->setName('ClassName');
1135+
$classGenerator->setExtendedClass('\DateTime');
1136+
$this->assertContains('class ClassName extends DateTime', $classGenerator->generate());
1137+
}
1138+
11101139
public function testCorrectImplementNames()
11111140
{
11121141
$classGenerator = new ClassGenerator();

0 commit comments

Comments
 (0)