Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] Consistent indentation for test files

Posted by Nikita Popov 
Nikita Popov
[PHP-DEV] Consistent indentation for test files
October 28, 2017 02:10PM
Hi internals,

Right now we do not have a consistent standard for the indentation of PHPT
files. Some people create space-indented files, others create tab-indented
files. Over time, indentation invariably starts to mix, because developers
with different indentation settings work on one file.

Here are the current statistics for code in .phpt files:

total: 15515
prefer tabs: 4273 (27.5%)
prefer spaces: 6307 (40.7%)
draw: 77 (0.5%)
no indentation: 4858 (31.3%)

There are 1824 (11.8%) files that contain mixed tab and space indentation.
The indentation was determined based on the first character of a line.

I would like to propose that we establish a common standard by
a) using space indentation for all future tests (as they currently form the
majority), and
b) reindenting existing test files to use space indentation.

Thanks,
Nikita

PS: Motivated by https://github.com/php/php-src/pull/2879. PRs regularly
have WS issues.
Christoph M. Becker
[PHP-DEV] Re: Consistent indentation for test files
October 28, 2017 02:50PM
On 28.10.2017 at 13:59, Nikita Popov wrote:

> Right now we do not have a consistent standard for the indentation of PHPT
> files. Some people create space-indented files, others create tab-indented
> files. Over time, indentation invariably starts to mix, because developers
> with different indentation settings work on one file.
>
> Here are the current statistics for code in .phpt files:
>
> total: 15515
> prefer tabs: 4273 (27.5%)
> prefer spaces: 6307 (40.7%)
> draw: 77 (0.5%)
> no indentation: 4858 (31.3%)
>
> There are 1824 (11.8%) files that contain mixed tab and space indentation.
> The indentation was determined based on the first character of a line.

Thanks for bringing this up!

> I would like to propose that we establish a common standard by
> a) using space indentation for all future tests (as they currently form the
> majority), and
> b) reindenting existing test files to use space indentation.

+1

I'm rather baffled that http://qa.php.net/write-test.php doesn't
address this issue at all.

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Jakub Zelenka
Re: [PHP-DEV] Consistent indentation for test files
October 29, 2017 07:50PM
On Sat, Oct 28, 2017 at 12:59 PM, Nikita Popov <[email protected]> wrote:

> Hi internals,
>
> Right now we do not have a consistent standard for the indentation of PHPT
> files. Some people create space-indented files, others create tab-indented
> files. Over time, indentation invariably starts to mix, because developers
> with different indentation settings work on one file.
>
> Here are the current statistics for code in .phpt files:
>
> total: 15515
> prefer tabs: 4273 (27.5%)
> prefer spaces: 6307 (40.7%)
> draw: 77 (0.5%)
> no indentation: 4858 (31.3%)
>
> There are 1824 (11.8%) files that contain mixed tab and space indentation.
> The indentation was determined based on the first character of a line.
>
> I would like to propose that we establish a common standard by
> a) using space indentation for all future tests (as they currently form the
> majority), and
>

I usually use tabs for phpt as it's a bit simpler with my IDE that I use
for PHP core dev (QtCreator) and mostly the core exts that I work with had
tabs. That said I wouldn't be against making it the same and use spaces
everywhere if we also start using PSR-2 for tests - it's not just an
indentation that is a mess...


> b) reindenting existing test files to use space indentation.
>
>
+1 but it needs to be done in the lowest active branch otherwise it will
result in conflicts when changing existing tests (it is sometimes useful
for extending tests)...

Cheers

Jakub
Anatol Belski
RE: [PHP-DEV] Consistent indentation for test files
October 29, 2017 10:40PM
Hi,

> -----Original Message-----
> From: jakub.php@gmail.com [mailto:[email protected]] On Behalf Of Jakub
> Zelenka
> Sent: Sunday, October 29, 2017 7:41 PM
> To: Nikita Popov <[email protected]>
> Cc: PHP internals <[email protected]>
> Subject: Re: [PHP-DEV] Consistent indentation for test files
>
> On Sat, Oct 28, 2017 at 12:59 PM, Nikita Popov <[email protected]> wrote:
>
> > Hi internals,
> >
> > Right now we do not have a consistent standard for the indentation of
> > PHPT files. Some people create space-indented files, others create
> > tab-indented files. Over time, indentation invariably starts to mix,
> > because developers with different indentation settings work on one file.
> >
> > Here are the current statistics for code in .phpt files:
> >
> > total: 15515
> > prefer tabs: 4273 (27.5%)
> > prefer spaces: 6307 (40.7%)
> > draw: 77 (0.5%)
> > no indentation: 4858 (31.3%)
> >
> > There are 1824 (11.8%) files that contain mixed tab and space indentation.
> > The indentation was determined based on the first character of a line.
> >
> > I would like to propose that we establish a common standard by
> > a) using space indentation for all future tests (as they currently
> > form the majority), and
> >
>
> I usually use tabs for phpt as it's a bit simpler with my IDE that I use for PHP core
> dev (QtCreator) and mostly the core exts that I work with had tabs. That said I
> wouldn't be against making it the same and use spaces everywhere if we also
> start using PSR-2 for tests - it's not just an indentation that is a mess...
>
>
> > b) reindenting existing test files to use space indentation.
> >
> >
> +1 but it needs to be done in the lowest active branch otherwise it will
> result in conflicts when changing existing tests (it is sometimes useful for
> extending tests)...
>
Whichever way would be chosen, implementing a pre commit hook would make sense to be done. To mention, tabs were easier for me, too, but not a big deal anyway.

Regards

Anatol
Kalle Sommer Nielsen
Re: [PHP-DEV] Consistent indentation for test files
October 30, 2017 06:10AM
2017-10-29 22:30 GMT+01:00 Anatol Belski <[email protected]>:
> Whichever way would be chosen, implementing a pre commit hook would make sense to be done. To mention, tabs were easier for me, too, but not a big deal anyway.

I'm on the same boat as Anatol here, whatever is choosen is fine with
me, tho I generally tend to use tabs unless the test I copy/pasted had
spaces, I would follow that.



--
regards,

Kalle Sommer Nielsen
kalle@php.net

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Kris Craig
Re: [PHP-DEV] Re: Consistent indentation for test files
October 30, 2017 09:50AM
On Sat, Oct 28, 2017 at 5:42 AM, Christoph M. Becker <[email protected]>
wrote:

> On 28.10.2017 at 13:59, Nikita Popov wrote:
>
> > Right now we do not have a consistent standard for the indentation of
> PHPT
> > files. Some people create space-indented files, others create
> tab-indented
> > files. Over time, indentation invariably starts to mix, because
> developers
> > with different indentation settings work on one file.
> >
> > Here are the current statistics for code in .phpt files:
> >
> > total: 15515
> > prefer tabs: 4273 (27.5%)
> > prefer spaces: 6307 (40.7%)
> > draw: 77 (0.5%)
> > no indentation: 4858 (31.3%)
> >
> > There are 1824 (11.8%) files that contain mixed tab and space
> indentation.
> > The indentation was determined based on the first character of a line.
>
> Thanks for bringing this up!
>
> > I would like to propose that we establish a common standard by
> > a) using space indentation for all future tests (as they currently form
> the
> > majority), and
> > b) reindenting existing test files to use space indentation.
>
> +1
>
> I'm rather baffled that http://qa.php.net/write-test.php doesn't
> address this issue at all.
>
> --
> Christoph M. Becker
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Those stats can be a bit misleading, though, as I've observed that many (if
not most) IDEs are configured to automatically convert tab characters to
spaces. Therefore, it stands to reason that at least some of the "prefer
spaces" category would actually fall under "prefer tabs". I suspect the
tabs and spaces groups are much closer together, though it's impossible to
say how much since there's no way to control for that variable. Still, I
would caution people not to read too much into those statistics.

A common standard would be nice, but I fear it might discourage some from
contributing tests. Also, how would we actually enforce this? Would we
reject any tests that don't conform to this or fix them, ourselves? Either
way, it would require someone to actually do the work. Another possible
option would be to use some kind of automated conversion process. But I
personally think these solutions are more trouble than they're worth. So
long as the spacing is consistent within each file, I can live with it.

--Kris
Derick Rethans
Re: [PHP-DEV] Consistent indentation for test files
October 30, 2017 06:50PM
On Sun, 29 Oct 2017, Jakub Zelenka wrote:

> On Sat, Oct 28, 2017 at 12:59 PM, Nikita Popov <[email protected]> wrote:

<snip>

> > Here are the current statistics for code in .phpt files:
> >
> > total: 15515
> > prefer tabs: 4273 (27.5%)
> > prefer spaces: 6307 (40.7%)
> > draw: 77 (0.5%)
> > no indentation: 4858 (31.3%)
> >
> > There are 1824 (11.8%) files that contain mixed tab and space indentation.
> > The indentation was determined based on the first character of a line.
> >
> > I would like to propose that we establish a common standard by
> > a) using space indentation for all future tests (as they currently form the
> > majority), and
>
> I usually use tabs for phpt as it's a bit simpler with my IDE that I use
> for PHP core dev (QtCreator) and mostly the core exts that I work with had
> tabs. That said I wouldn't be against making it the same and use spaces
> everywhere if we also start using PSR-2 for tests - it's not just an
> indentation that is a mess...
>
> > b) reindenting existing test files to use space indentation.
> >
> +1 but it needs to be done in the lowest active branch otherwise it will
> result in conflicts when changing existing tests (it is sometimes useful
> for extending tests)...

I'm -1 on the whole exercise, but this comment by Jakub is what worries
me most.

cheers,
Derick

--
https://derickrethans.nl | https://xdebug.org | https://dram.io
Like Xdebug? Consider a donation: https://xdebug.org/donate.php
twitter: @derickr and @xdebug

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sara Golemon
Re: [PHP-DEV] Consistent indentation for test files
October 30, 2017 08:10PM
On Sat, Oct 28, 2017 at 7:59 AM, Nikita Popov <[email protected]> wrote:
> Right now we do not have a consistent standard for the indentation of
> PHPT files.
>
> I would like to propose that we establish a common standard
>
Not for nothin', but PSR-2 exists. If we adopt *any* standard, I
think it should be this one* (which is a spiritual successor to PEAR's
CS fwiw).

> +1 but it needs to be done in the lowest active branch
> otherwise it will result in conflicts when changing
> existing tests (it is sometimes useful for extending tests)...
>
I'm not convinced that test files are in such an active state of churn
that this would net us much benefit for the cost.

-Sara

* PSR-12 is in the works as an update to PSR-2, but the items it
addresses are largely orthogonal to the kind of code you find in PHPT
files.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login