Hi Marco,

On Fri, Mar 10, 2017 at 9:25 AM, Marco Perone <[email protected]> wrote:

> Hi Paul, thanks for your answer,
>
> I know that the final underscore is not passing the PSR-1 codesniffer
> test. That's where I started from (https://github.com/squizlabs/
> PHP_CodeSniffer/issues/1382). I was more wondering if that is the correct
> approach.
>

The correct approach is to stick to StudlyCaps for class name. If it
deviates from that then it's considered "not compliant".


>
> I agree it should be generally avoided to name classes after language
> constructs, but there are cases (see the PHP parser library I linked) where
> that seems exactly the most reasonable thing to do, and I am asking how
> these cases should be handled.
>

Indeed projects like this aimed to emulate the tokens of the language will
find themselves falling outside of PSR-1. There's nothing wrong with that
really.

A personal suggestion, so you're sticking to StudlyCaps, is you could do
something like TokenEcho TokenEmpty for class names, if PSR-1 is important
to you.


>
> 2017-03-10 9:49 GMT+01:00 Paul Dragoonis <[email protected]>:
>
>> Hi Marco,
>>
>> Comments inline.
>>
>> On Thu, Mar 9, 2017 at 10:40 PM, Marco Perone <[email protected]> wrote:
>>
>>> As per PSR-1 specifications, class names must be in StudlyCaps.
>>>
>>>
>>> However, if I want to define a class named Echo (or any other Php
>>> keyword), I am not able to do that beacuse if I do so I obtain a parse
>>> error.
>>>
>>>
>>> It seems that the standard solution to this issue is to add an _ at the
>>> end of the class, as in Echo_.
>>>
>>
>> No, this is not the standard solution.
>>
>>
>>> For example, look in https://github.com/nikic/PH
>>> P-Parser/tree/3.x/lib/PhpParser/Node/Stmt.
>>>
>>
>> This would not pass PSR-1 codesniffer tests.
>>
>>>
>>> Should this be counted as a violation of PSR-1?
>>>
>>> Could it be the case to state this explicitely in PSR-12, allowing the
>>> presence of a final underscore in a class name, maybe only when the class
>>> name in a reserved keyword?
>>>
>>>
>>> Where possible you should avoid naming your classes after language
>> constructs and tokens.
>>
>>
>>> More broadly, could it be the case to provice a precise definition of
>>> what StudlyCaps mean? (If it's not present elsewhere and I'm missing it...)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "PHP Framework Interoperability Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/php-fig/e07dbe3c-2488-4630-8850-bdb04ccae52b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/php-fig/e07dbe3c-2488-4630-8850-bdb04ccae52b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "PHP Framework Interoperability Group" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/php-fig/0yEk60y2RVE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/php-fig/CAKxcST_xhaRhpnn8jV8jVDRQXMO4c98%2BN3HsV3d3mJ-
>> Zyri%2BhQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/php-fig/CAKxcST_xhaRhpnn8jV8jVDRQXMO4c98%2BN3HsV3d3mJ-Zyri%2BhQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Marco Perone
>
> @marcoshuttle <https://twitter.com/marcoshuttle>
> https://github.com/marcosh
> http://marcosh.github.io/
>
> --
> You received this message because you are subscribed to the Google Groups
> "PHP Framework Interoperability Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/php-fig/CAARDrK-W5SarhO4p3YaUGOdL9ScO%2BKwyNDm0gukZYGymkduezw%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/php-fig/CAARDrK-W5SarhO4p3YaUGOdL9ScO%2BKwyNDm0gukZYGymkduezw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/CAKxcST82JVk-gneqF5gtTQL1Ojtnj3VOu2Pr0VhgExLSbS_pOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to