Skip to content

Commit d596078

Browse files
use CodeGenerator from ZF 2.4
1 parent a2c4e7a commit d596078

File tree

3 files changed

+4
-98
lines changed

3 files changed

+4
-98
lines changed

lib/internal/Magento/Framework/Code/Generator/ClassGenerator.php

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,6 @@ class ClassGenerator extends \Zend\Code\Generator\ClassGenerator implements
6161
'passedByReference' => 'setPassedByReference',
6262
];
6363

64-
/**
65-
* @var array Array of string names
66-
*/
67-
protected $traits = array();
68-
69-
public function setTraits(array $traits)
70-
{
71-
$this->traits = $traits;
72-
return $this;
73-
}
74-
75-
/**
76-
* Returns the "traits" classes
77-
*
78-
* @return array
79-
*/
80-
public function getTraits()
81-
{
82-
return $this->traits;
83-
}
84-
8564
/**
8665
* @param object $object
8766
* @param array $data
@@ -230,77 +209,4 @@ public function getNamespaceName()
230209
{
231210
return ltrim(parent::getNamespaceName(), '\\');
232211
}
233-
234-
/**
235-
* @return string
236-
*/
237-
public function generate()
238-
{
239-
if (!$this->isSourceDirty()) {
240-
$output = $this->getSourceContent();
241-
if (!empty($output)) {
242-
return $output;
243-
}
244-
}
245-
246-
$output = '';
247-
248-
if (null !== ($namespace = $this->getNamespaceName())) {
249-
$output .= 'namespace ' . $namespace . ';' . self::LINE_FEED . self::LINE_FEED;
250-
}
251-
252-
$uses = $this->getUses();
253-
if (!empty($uses)) {
254-
foreach ($uses as $use) {
255-
$output .= 'use ' . $use . ';' . self::LINE_FEED;
256-
}
257-
$output .= self::LINE_FEED;
258-
}
259-
260-
if (null !== ($docBlock = $this->getDocBlock())) {
261-
$docBlock->setIndentation('');
262-
$output .= $docBlock->generate();
263-
}
264-
265-
if ($this->isAbstract()) {
266-
$output .= 'abstract ';
267-
}
268-
269-
$output .= 'class ' . $this->getName();
270-
271-
if (!empty($this->extendedClass)) {
272-
$output .= ' extends ' . $this->extendedClass;
273-
}
274-
275-
$implemented = $this->getImplementedInterfaces();
276-
if (!empty($implemented)) {
277-
$output .= ' implements ' . implode(', ', $implemented);
278-
}
279-
280-
$output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED;
281-
282-
$traits = $this->getTraits();
283-
if (!empty($traits)) {
284-
$output .= self::LINE_FEED . $this->indentation
285-
. 'use ' . (implode(', ', $traits)) . ';' . self::LINE_FEED . self::LINE_FEED;
286-
}
287-
288-
$properties = $this->getProperties();
289-
if (!empty($properties)) {
290-
foreach ($properties as $property) {
291-
$output .= $property->generate() . self::LINE_FEED . self::LINE_FEED;
292-
}
293-
}
294-
295-
$methods = $this->getMethods();
296-
if (!empty($methods)) {
297-
foreach ($methods as $method) {
298-
$output .= $method->generate() . self::LINE_FEED;
299-
}
300-
}
301-
302-
$output .= self::LINE_FEED . '}' . self::LINE_FEED;
303-
304-
return $output;
305-
}
306212
}

lib/internal/Magento/Framework/Code/Generator/CodeGeneratorInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function setExtendedClass($extendedClass);
5656
public function setImplementedInterfaces(array $interfaces);
5757

5858
/**
59-
* Set a list of traits.
59+
* Add a trait to the class.
6060
*
61-
* @param array $traits
61+
* @param $trait
6262
* @return $this
6363
*/
64-
public function setTraits(array $traits);
64+
public function addTrait($trait);
6565
}

lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected function _generateCode()
161161
} else {
162162
$this->_classGenerator->setExtendedClass($typeName);
163163
}
164-
$this->_classGenerator->setTraits(['\Magento\Framework\Interception\Interceptor']);
164+
$this->_classGenerator->addTrait('\Magento\Framework\Interception\Interceptor');
165165
return parent::_generateCode();
166166
}
167167

0 commit comments

Comments
 (0)