-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected: 4.3.2
Description
Using camelCase, with an attribute $aFooBar
, naming the getter/setter getAFooBar()
/setAFooBar()
returns the property name as AFooBar
instead of aFooBar
.
I'm not sure if this is a bug or intended behavior, but it seems weird that the second character's case dictates the first character case, as:
getAFooBar
returns the property name asAFooBar
(1&2 uppercase => 1&2 uppercase)getAfooBar
returns the property name asafooBar
(1 uppercase & 2 lowercase => 1&2 lowercase)
Found it out the hard way through api-platform/core#2941
Generating the getter with make:entity
from the attribute $aFooBar
generates getAFooBar()
which in turn gives the property name AFooBar
.
How to reproduce
Create an entity such as the one below and get its properties.
// ./src/Entity/UDemandeur.php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
/**
* @ApiResource()
* @ORM\Entity(repositoryClass="App\Repository\UDemandeurRepository")
* @ORM\Table(name="U_DEMANDEUR")
*/
class UDemandeur {
/**
* @ApiProperty(identifier=true)
* @ORM\Id()
* @ORM\Column(type="string", name="U_DEMANDEURID", unique=true, length=255)
*/
private $uDemandeurId;
public function getUDemandeurId(): ?string
{
return $this->uDemandeurId;
}
}