Re: Use PSR coding guidelines in php.net docs (instead of PEAR-CS)

Tymoteusz Motylewski <[email protected]>
Newsgroups gmane.comp.php.documentation.general
Message-ID <CABphOUecUBjpmTEtrCE8pr90Y4k82rKknpDSZRouRKn1YSrC_w@mail.gmail.com>
Hi,
See my answers below.


> > - has a broad acceptance in the PHP industry
> > - doesn't have an alternative thus became the one standard in the
> industry
> > - its adopted by many tools and framework from the PHP community
>
> While these are solid arguments in their own right, it doesn't
> necessarily mean that these merits also apply to the PHP project. Like
> mentioned in the bug report, the PHP project must remain neutral. The
> moment we adopt the X standard, then it will be seen as favoritism,
> "Why does the PHP project use this standard when Y is clearly better?
> I better bring my case up for using Y over X". If the PHP project were
> to pick X coding standard then possibility for any widespread adoption
> for anything else is next to nothing. Userland is free to create
> whatever organizations you would wish to and support their course, or
> not, in the same way that the PHP project strives to be neutral.
>

Surely, userland is free to create and use PHP as one wishes.
PHP setting or using some standard is not limiting userland to do whatever
people please.
Every decision PHP makes can be criticised (and often is) but it doesn't
mean PHP should not evolve.

> I agree, and I would love PHP to either set standards, or to endorse
> existing standards. Because right now you can read this argument that PHP
> is endorsing obsolete PEAR-CS, which I hope is not true ;)
>
> I think while we base the idea on PEAR, I think the style has slowly
> evolved into our own with roots there of. I'm sure some examples out
> there in the manual may be compatible with X, Y or Z PHP coding
> standards, sometimes not. It is not really the end of the world if
> some examples use K&R / Allman indentation style and others use OTBS.
>

Sure, its not the end of the world. I'm just asking questions to be able
to bring a little bit of consistency to the area which is no
inconsistent/messy.

The whole topic was brought to my attention when I did a code review
of the code of the junior dev, and saw he is using uppercase TRUE, NULL etc.
When I asked him about it, he said its' written like that in the official
docs,
which was quite surprising to me.
He was right. In most places in docs these constants are written uppercase
even despite the fact that according to PEAR-CS it should be lowercase.


> The moment we however open up and decide to invent a new coding
> standard, it will have many challenges, such as:
>  - Everyone would want to take apart of it, because it is the PHP
> project and there seems to be a certain prestige in having had a say
> in something that involves the PHP project
>  - There is the chance that someone will adapt that and what do we do
> then, maintain it or? What if someone forks it and it becomes
> widespread, do we then adopt that and break that neutral stance?
>

It didn't happen with PEAR-CS, so I don't see there is a risk of that.
I think you're overrating the impact of the statement that "examples in the
 docs shoudl be written according to XXX coding standard." on the docs page.
You could also state that "PHP doesn't enforce or encourage any code style
on userland code, so feel free to use any you want. For the sake of
consistency
however we had to use one"

You could also not mentione PSR style by name, but just use the rules which
are there.
To avoid the politics.

The thought of the political process of tabs v spaces, which
> indentation style, and naming, would have to be redone. While I don't
> speak for everyone, I can't stay that I know of anyone that would be
> interested in such, nor do we have the infrastructure for something
> like that to happen.
>

This is why I do not suggest creating a new code style, but using something
with wide adoption. I imagine there could be a vote among maintainers
"1. do we want to have defined coding standard for docs? 2. should we use
the rules
similar to PSR-12?"


> We even have a CODING_STANDARDS.md file in php-src, which is not
> respected to the slightest, perhaps because it has not been updated
> our "recent" switch to C99, but it is very common to have commits
> break the C++ comment style rule for one.
>

Not following coding standard (and not having a CI for checking that in
php-src)
is not an argument for me to not follow coding standard somewhere else.


>
> > In general I would like to see more PSR being mentioned in PHP docs,
> e.g. PSR-4 in https://www.php.net/manual/en/language.oop5.autoload.php
>
> We cannot do this because it creates favoritism, the moment we endorse
> X, then Y wants some too and Z, and it will continue like that. That
> is why it is very important for the PHP.net project to remain neutral.
>

I understand the drive to stay neutral. However I don't consider that
mentioning existing standards as examples creating favoritism,
especially if there are no alternatives e.g. for composer in the PHP world.
But after all It's not my call here, I'm just the language user.

regards
Tymoteusz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.