11<?php
22
3+ declare (strict_types=1 );
4+
35namespace WsdlToPhp \PhpGenerator \Component ;
46
57use WsdlToPhp \PhpGenerator \Element \AbstractElement ;
810use WsdlToPhp \PhpGenerator \Element \PhpConstant as PhpConstantElement ;
911use WsdlToPhp \PhpGenerator \Element \PhpAnnotationBlock as PhpAnnotationBlockElement ;
1012
11- abstract class AbstractComponent implements GenerableInterface
13+ abstract class AbstractComponent implements GenerateableInterface
1214{
1315 /**
1416 * @var PhpFileElement|PhpClassElement
1517 */
1618 protected $ mainElement ;
1719 /**
18- * @see \WsdlToPhp\PhpGenerator\Component\GenerableInterface ::toString()
20+ * @see \WsdlToPhp\PhpGenerator\Component\GenerateableInterface ::toString()
1921 * @return string
2022 */
21- public function toString ()
23+ public function toString (): string
2224 {
23- $ content = array () ;
25+ $ content = [] ;
2426 foreach ($ this ->getElements () as $ element ) {
2527 $ content [] = $ this ->getElementString ($ element );
2628 }
@@ -29,13 +31,13 @@ public function toString()
2931 /**
3032 * @return AbstractElement[]|string[]
3133 */
32- abstract public function getElements ();
34+ abstract public function getElements (): array ;
3335 /**
3436 * @throws \InvalidArgumentException
3537 * @param AbstractElement $element
36- * @return \WsdlToPhp\PhpGenerator\Component\ AbstractComponent
38+ * @return AbstractComponent
3739 */
38- public function setMainElement (AbstractElement $ element )
40+ public function setMainElement (AbstractElement $ element ): AbstractComponent
3941 {
4042 if ($ element instanceof PhpFileElement || $ element instanceof PhpClassElement) {
4143 $ this ->mainElement = $ element ;
@@ -47,7 +49,7 @@ public function setMainElement(AbstractElement $element)
4749 /**
4850 * @return PhpFileElement|PhpClassElement
4951 */
50- public function getMainElement ()
52+ public function getMainElement (): AbstractElement
5153 {
5254 return $ this ->mainElement ;
5355 }
@@ -56,7 +58,7 @@ public function getMainElement()
5658 * @param string|AbstractElement $element
5759 * @return string
5860 */
59- protected function getElementString ($ element )
61+ protected function getElementString ($ element ): string
6062 {
6163 $ string = '' ;
6264 if (is_scalar ($ element )) {
@@ -70,7 +72,7 @@ protected function getElementString($element)
7072 * @param PhpConstantElement $constant
7173 * @return AbstractComponent
7274 */
73- public function addConstantElement (PhpConstantElement $ constant )
75+ public function addConstantElement (PhpConstantElement $ constant ): AbstractComponent
7476 {
7577 if (!$ constant ->getClass () instanceof PhpClassElement && $ this ->mainElement instanceof PhpClassElement) {
7678 $ constant ->setClass ($ this ->mainElement );
@@ -85,15 +87,15 @@ public function addConstantElement(PhpConstantElement $constant)
8587 * @param PhpClassElement $class
8688 * @return AbstractComponent
8789 */
88- public function addConstant ($ name , $ value = null , PhpClassElement $ class = null )
90+ public function addConstant ($ name , $ value = null , PhpClassElement $ class = null ): AbstractComponent
8991 {
9092 return $ this ->addConstantElement (new PhpConstantElement ($ name , $ value , $ class ));
9193 }
9294 /**
9395 * @param PhpAnnotationBlockElement $annotationBlock
9496 * @return AbstractComponent
9597 */
96- public function addAnnotationBlockElement (PhpAnnotationBlockElement $ annotationBlock )
98+ public function addAnnotationBlockElement (PhpAnnotationBlockElement $ annotationBlock ): AbstractComponent
9799 {
98100 $ this ->mainElement ->addChild ($ annotationBlock );
99101 return $ this ;
@@ -103,10 +105,10 @@ public function addAnnotationBlockElement(PhpAnnotationBlockElement $annotationB
103105 * @param array|string|PhpAnnotationElement $annotations
104106 * @return AbstractComponent
105107 */
106- public function addAnnotationBlock ($ annotations )
108+ public function addAnnotationBlock ($ annotations ): AbstractComponent
107109 {
108- return $ this ->addAnnotationBlockElement (new PhpAnnotationBlockElement (is_array ($ annotations ) ? $ annotations : array (
110+ return $ this ->addAnnotationBlockElement (new PhpAnnotationBlockElement (is_array ($ annotations ) ? $ annotations : [
109111 $ annotations ,
110- ) ));
112+ ] ));
111113 }
112114}
0 commit comments