PER Coding Style 2.0 - 4.7 Method chaining ambiguity

91 views
Skip to first unread message

Rik van der Heijden

unread,
Jul 22, 2024, 2:46:57 AM7/22/24
to PHP Framework Interoperability Group
Hi all,

I'm currently working on implementing PER Coding Style 2.0 for PHP CodeSniffer, and I'm facing some ambiguity in the specification.

There is a section on method chaining. But what if the first called method is a static call to a class. It is not outlined if the static call should be indented or not.

Like this:

MyClass::getInstance()
    ->foo()
    ->bar();

Or this:

MyClass
    ::getInstance()
    ->foo()
    ->bar();

This is ambigious in the specification currently since it does not outline whether a static call is considered 'part of the chain' or not.

Also, hello, my name is Rik and I'm new here. I'm in the PHP 'world' for +- 20y. I might have more questions/suggestions as I'm plowing through it.

Kind regards,

Rik

Alex Makarov

unread,
Jul 22, 2024, 5:24:49 AM7/22/24
to php...@googlegroups.com
I'd keep it not intended. Static call isn't considered "part of the chain".

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/4651e1cc-2789-4d78-b602-2fe44895e123n%40googlegroups.com.

Larry Garfield

unread,
Jul 22, 2024, 9:36:47 AM7/22/24
to PHP-FIG
Welcome!

I would also say that :: is not part of the call chain, and should be on the same line as the class.

Please open an Issue on the PER-CS repository (https://github.com/php-fig/per-coding-style). We'll see if we can get this clarified in the 2.1 release. (We still have to discuss how to handle the new syntax in 8.4, but haven't gotten there yet.)

--Larry Garfield
Reply all
Reply to author
Forward
0 new messages