0 votes

It is not a big deal, but I used to define constants and used them to define discriminator in ORM mapping of inheritance discriminator map.

/**
 * @ORM\Entity(repositoryClass="RecordRepository")
 * @ORM\Table(name="record")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 * @ORM\DiscriminatorMap({
 *     Record::RECORD_TYPE_OFFER:"Offer",
 *     Record::RECORD_TYPE_ORDER:"Order",
 *     Record::RECORD_TYPE_INVOICE:"Invoice"
 * })
 * @ORM\HasLifecycleCallbacks
 */
abstract class Record implements Commentable, Editable, Deletable, DetailPath, Loggable
{
    use LoggedEntity, CommentedEntity;

    const RECORD_TYPE_INVOICE = 'INVOICE';
    const RECORD_TYPE_OFFER = 'OFFER';
    const RECORD_TYPE_ORDER = 'ORDER';

Skipper changes those constants after export to strings. It would be nice, if skipper detects these constant by having two colons in name and not putting those quotes in annotation.

in Feature Request by (220 points)

1 Answer

0 votes

Thanks for the suggestion.

I'm not sure if we can use :: as 100% rule for not putting the string into quotation marks.

Maybe this can be done in a combination of some global settings which turned such option on. I'm afraid to not broke existing models if someone is using :: in strings.

by Skipper developer (141k points)

I agree. As I said - it is not a big deal, I replaced my constants to strings and it works, but the purpose for those constants is to have the discriminator name defined once.

I completely understand your motivation and agree that constants would be nice.