Skip to content

Commit

Permalink
Merge pull request #34 from onmoon/fix-underscore-props
Browse files Browse the repository at this point in the history
Fix underscore props
  • Loading branch information
DimanKuskov authored Mar 1, 2020
2 parents cf2e714 + 12c648c commit 10931fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/CodeGenerator/Dto/PhpParserDtoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,19 +588,22 @@ private function generateMethodParameter(MethodParameterDefinition $definition)
{
return $this
->factory
->param($definition->name())
->param($this->namingStrategy->stringToMethodName($definition->name()))
->setType($definition->iterableType() !== null ? 'array' : $definition->type());
}

private function getAssignmentDefinition(string $name) : Assign
{
return new Assign(new Variable('this->' . $name), new Variable($name));
return new Assign(
new Variable('this->' . $name),
new Variable($this->namingStrategy->stringToMethodName($name))
);
}

private function generateGetter(GetterMethodDefinition $definition) : Method
{
$method = $this->factory
->method('get' . ucfirst($definition->name()))
->method('get' . ucfirst($this->namingStrategy->stringToMethodName($definition->name())))
->makePublic()
->setReturnType(
($definition->isNullable() && $definition->defaultValue() === null ? '?' : '') .
Expand All @@ -626,7 +629,7 @@ private function generateSetter(SetterMethodDefinition $definition) : Method
$methodParameterDefinition = new MethodParameterDefinition($definition->name(), $definition->type());
$methodParameterDefinition->setIterableType($definition->iterableType());
$method = $this->factory
->method('set' . ucfirst($definition->name()))
->method('set' . ucfirst($this->namingStrategy->stringToMethodName($definition->name())))
->makePublic()
->setReturnType('self')
->addParam($this->generateMethodParameter($methodParameterDefinition))
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGenerator/Naming/DefaultNamingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function buildPath(string ...$parts) : string
private function prepareTextForPhp(string $text) : string
{
/** @var string $filteredText */
$filteredText = preg_replace('/[^\w]/', ' ', $text);
$filteredText = preg_replace('/[^A-Z0-9]/i', ' ', $text);

return str_replace(' ', '', ucwords($filteredText));
}
Expand Down

0 comments on commit 10931fd

Please sign in to comment.