Skip to content

Commit fa82b32

Browse files
committed
Merge branch 'hotfix/4.0.1'
2 parents 4d85332 + c2270a5 commit fa82b32

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## 4.0.1 - 2021/02/04
4+
- Add back `getMainElement` method to `AbstractComponent`
5+
36
## 4.0.0 - 2021/02/04
47
- issue #11 - Allow class property to be typed
58
- Clear, refactor and review code

src/Component/AbstractComponent.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public function setMainElement(AbstractElement $element): self
3939
return $this;
4040
}
4141

42+
/**
43+
* @return PhpClassElement|PhpFileElement
44+
*/
45+
public function getMainElement()
46+
{
47+
return $this->mainElement;
48+
}
49+
4250
public function addConstantElement(PhpConstantElement $constant): self
4351
{
4452
if (!$constant->getClass() instanceof PhpClassElement && $this->mainElement instanceof PhpClassElement) {

tests/Component/PhpClassTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use WsdlToPhp\PhpGenerator\Component\PhpClass as PhpClassComponent;
88
use WsdlToPhp\PhpGenerator\Element\PhpAnnotation as PhpAnnotationElement;
9+
use WsdlToPhp\PhpGenerator\Element\PhpClass;
910
use WsdlToPhp\PhpGenerator\Element\PhpFunctionParameter as PhpFunctionParameterElement;
1011
use WsdlToPhp\PhpGenerator\Element\PhpProperty;
1112
use WsdlToPhp\PhpGenerator\Element\PhpProperty as PhpPropertyElement;
@@ -16,6 +17,13 @@
1617
*/
1718
class PhpClassTest extends AbstractComponent
1819
{
20+
public function testGetMainElementMustBeOfPhpClassElement()
21+
{
22+
$class = new PhpClassComponent('Foo', true, 'stdClass');
23+
24+
$this->assertInstanceOf(PhpClass::class, $class->getMainElement());
25+
}
26+
1927
public function testSimpleToString()
2028
{
2129
$class = new PhpClassComponent('Foo', true, 'stdClass');

tests/Component/PhpFileTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use WsdlToPhp\PhpGenerator\Component\PhpInterface as PhpInterfaceComponent;
1111
use WsdlToPhp\PhpGenerator\Element\PhpAnnotation as PhpAnnotationElement;
1212
use WsdlToPhp\PhpGenerator\Element\PhpDeclare;
13+
use WsdlToPhp\PhpGenerator\Element\PhpFile;
1314
use WsdlToPhp\PhpGenerator\Element\PhpFunctionParameter as PhpFunctionParameterElement;
1415
use WsdlToPhp\PhpGenerator\Element\PhpProperty;
1516
use WsdlToPhp\PhpGenerator\Element\PhpProperty as PhpPropertyElement;
@@ -20,6 +21,13 @@
2021
*/
2122
class PhpFileTest extends AbstractComponent
2223
{
24+
public function testGetMainElementMustBeOfPhpFileElement()
25+
{
26+
$class = new PhpFileComponent('Foo', true, 'stdClass');
27+
28+
$this->assertInstanceOf(PhpFile::class, $class->getMainElement());
29+
}
30+
2331
public function testSimpleClassToString()
2432
{
2533
$file = new PhpFileComponent('Foo');

0 commit comments

Comments
 (0)