Proposal for extended coding style guide

86 views
Skip to first unread message

Anton Okolelov

unread,
Oct 23, 2017, 2:56:35 AM10/23/17
to PHP Framework Interoperability Group
Hello

Could you please add typecasting space issue in https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md ?

$intValue = (int)$stringValue;

or 

$intValue = (int) $stringValue;

Thank you

Alessandro Lai

unread,
Oct 23, 2017, 5:28:17 AM10/23/17
to PHP Framework Interoperability Group
This is an interesting topic. I've always found inconsistencies on this topic, since some formatters use the first case, others the latter.

I'm inclined for the first case, since it's normally applied just to the symbol at the immediate right of it...

Alexander Makarov

unread,
Oct 23, 2017, 5:47:17 AM10/23/17
to PHP Framework Interoperability Group
Same here. Using 1st case.

Woody Gilk

unread,
Oct 23, 2017, 7:45:27 AM10/23/17
to php...@googlegroups.com

I've always used the second case. The first feels really cramped IMO.


--
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 php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/3b645b2e-1daa-42a5-8664-f4645d143346%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Rivera, John

unread,
Oct 23, 2017, 10:23:29 AM10/23/17
to php...@googlegroups.com
I’ve always used the first case. Consider another similar situation: calling a callable that’s also a property of self. You’d have to call it with parentheses — that is, ($callback)(); with no spaces. I feel like the first case is more consistent when taking into account the rest of the language.

Woody Gilk

unread,
Oct 23, 2017, 10:45:17 AM10/23/17
to PHP Framework Interoperability Group
Type casting and syntax "hacks" (eg: to call a closure assigned as a property) are very different and not comparable, IMO.

My personal preference would be:

$foo = (int) $foo;

and

return ($this->callback)(); // or return call_user_func($this->callback);
On Mon, Oct 23, 2017 at 9:23 AM, Rivera, John <riv...@buffalo.edu> wrote:
I’ve always used the first case. Consider another similar situation: calling a callable that’s also a property of self. You’d have to call it with parentheses — that is, ($callback)(); with no spaces. I feel like the first case is more consistent when taking into account the rest of the language.
On Oct 23, 2017, at 7:45 AM, Woody Gilk <woody...@gmail.com> wrote:

I've always used the second case. The first feels really cramped IMO.


On Mon, Oct 23, 2017, 04:47 'Alexander Makarov' via PHP Framework Interoperability Group <php...@googlegroups.com> wrote:
Same here. Using 1st case.


On Monday, October 23, 2017 at 12:28:17 PM UTC+3, Alessandro Lai wrote:
This is an interesting topic. I've always found inconsistencies on this topic, since some formatters use the first case, others the latter.

I'm inclined for the first case, since it's normally applied just to the symbol at the immediate right of it...

Il giorno lunedì 23 ottobre 2017 08:56:35 UTC+2, Anton Okolelov ha scritto:
Hello

Could you please add typecasting space issue in https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md ?

$intValue = (int)$stringValue;

or 

$intValue = (int) $stringValue;

Thank you

--
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 php-fig+unsubscribe@googlegroups.com.

To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/3b645b2e-1daa-42a5-8664-f4645d143346%40googlegroups.com.
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 php-fig+unsubscribe@googlegroups.com.

--
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 php-fig+unsubscribe@googlegroups.com.

To post to this group, send email to php...@googlegroups.com.

Rivera, John

unread,
Oct 23, 2017, 10:51:44 AM10/23/17
to php...@googlegroups.com
call_user_func() needs to die a fiery death.

But I digress.

There’s also (new Thing())->doThing();, with no spaces. But I admit I do not have a particularly strong opinion on this — if someone says the standard is to have a space in-between then I won’t argue too much :).

To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.

To post to this group, send email to php...@googlegroups.com.

Adrien Crivelli

unread,
Oct 23, 2017, 11:35:10 PM10/23/17
to PHP Framework Interoperability Group
I also use the second case.

Should we open a poll for that ? Or was it covered in the survey that were done a long time ago ? and by the way were that survey result ever published ?

Alexander Makarov

unread,
Oct 24, 2017, 12:11:38 PM10/24/17
to PHP Framework Interoperability Group
Results are in the meta doc. As far as I remember, type casting was not in the survey.
Reply all
Reply to author
Forward
0 new messages