protected function createSetMethod(PropertyDefinition $property) { $methodName = new PhpVariableName('set' . $property->getName()->toUpperCamelCase()); $parameter = new ParameterDefinition($property->getType(), $property->getName()); $method = new MethodDefinition($methodName, [$parameter]); $method->setVisibility(Visibility::PUBLIC_VISIBILITY())->addLine(sprintf('$this->%1$s = $%1$s;', $property->getName()->toLowerCamelCase())); return $method; }
private function buildGlobalNode() { $globalNode = new ArrayNodeDefinition('global'); $globalNode->info('global parameters for generation')->addDefaultsIfNotSet()->children()->scalarNode('author')->info('The value of the phpDoc\'s @author annotation')->example('Lucifer <*****@*****.**>')->defaultNull()->end()->scalarNode('header')->info('A license or any text to use as header of generated files')->example('// (c) Lucifer <*****@*****.**>')->defaultNull()->end()->arrayNode('namespaces')->addDefaultsIfNotSet()->info('PHP namespaces')->children()->scalarNode('root')->info('The root namespace prefix for all others')->isRequired()->example('Acme\\DemoBundle')->end()->scalarNode('entity')->info('The namespace of the generated entities')->defaultValue('Entity')->end()->scalarNode('enum')->info('The namespace of the generated enumerator')->defaultValue('Reference')->end()->scalarNode('interface')->info('The namespace of the generated interface')->defaultValue('Interface')->end()->scalarNode('repository')->info('The namespace of the generated repository')->defaultValue('Repository')->end()->end()->end()->enumNode('fieldVisibility')->info('Visibility of entities fields')->values(Visibility::toArray())->defaultValue(Visibility::PRIVATE_VISIBILITY)->cannotBeEmpty()->end()->booleanNode('forceScalarHiting')->info('if true, all scalar value is cast on "set" action and "get" action (get only if not private)')->defaultFalse()->end()->booleanNode('php7Syntax')->info('use php7 syntax with scalar hiting')->defaultFalse()->end()->end()->end(); return $globalNode; }