thecodingmachine/tdbm

Syntax error when generating Bean for columns starting with a number

ThibBal opened this issue · 2 comments

Process: I've added a column "4d_external_id" using a migration. Then I've generated the DAO/Beans using tdbm:generate command. No error from the command.

But the new generate Abstract file has now a syntax error because of a new getter/setter

set4dExternalId(?int $4d_external_data): Unexpected integer.

Potential fix: when generating the files, if the column start with an integer, add an underscore (_) before the name of the variable.

Rather than adding an underscore (that is not PSR2 compliant I think), we could spell out the number if it is at the beginning of the word ($fourd_external_data).

We can do this with:

$f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
echo $f->format(1432);

Closed by #192
Thanks @homersimpsons