/** * @param string $content * @param ClassManager $item * @param ReflectionClass $reflectionClass * @return ClassConstructorManager */ protected function resolveConstructorToRender($content, ClassManager $item, ReflectionClass $reflectionClass) { $constructor = $item->getConstructor(); $constructorFromFile = $reflectionClass->getConstructor(); $source = Tools::explodeTemplateStringToArray($content); $constructorBody = implode("", array_slice($source, $constructorFromFile->getStartLine(), $constructorFromFile->getEndLine() - $constructorFromFile->getStartLine())); $matches = []; preg_match_all("/this->[\\S]+/", $constructorBody, $matches); $initPropertiesFromConstructor = []; if (count($matches) > 0) { foreach ($matches[0] as $match) { $initPropertiesFromConstructor[] = str_replace("this->", "", trim($match)); } } $newInitProperties = new ArrayCollection(); foreach ($constructor->getInitProperties() as $initProperty) { if (in_array($initProperty->getProperty()->getPreparedName(), $initPropertiesFromConstructor)) { continue; } $newInitProperties->add($initProperty); } $constructor->setInitProperties($newInitProperties); $item->setConstructor($constructor); return $constructor; }