Skip to content

Fix #124 Require parenthesis around clone()#137

Open
mbeccati wants to merge 1 commit intophp-fig:masterfrom
mbeccati:add-clone
Open

Fix #124 Require parenthesis around clone()#137
mbeccati wants to merge 1 commit intophp-fig:masterfrom
mbeccati:add-clone

Conversation

@mbeccati
Copy link
Copy Markdown

@mbeccati mbeccati commented May 5, 2026

Per request from @Crell on Discord ;-)

Resolves #124

Comment thread spec.md Outdated
Copy link
Copy Markdown
Collaborator

@Crell Crell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this. Waiting a few days for other WG members to comment if desired.

Comment thread spec.md Outdated
@mbeccati
Copy link
Copy Markdown
Author

mbeccati commented May 6, 2026

@jrfnl I'm not a native speaker, but to me it feels used would be more appropriate than called when referring to a language construct (vs function). Thoughts?

@jrfnl
Copy link
Copy Markdown
Contributor

jrfnl commented May 6, 2026

@jrfnl I'm not a native speaker, but to me it feels used would be more appropriate than called when referring to a language construct (vs function). Thoughts?

@mbeccati I agree, used reads better.

@jrfnl
Copy link
Copy Markdown
Contributor

jrfnl commented May 6, 2026

Question for the interpretation by tooling:

The examples have no spacing between the keyword and the open parenthesis and on the inside of the parentheses.

Can we conclude that the rule about this for function/method calls (line 781 - 785) also applies to these language constructs ?

When making a method or function call, there MUST NOT be a space between the
method or function name and the opening parenthesis, there MUST NOT be a space
after the opening parenthesis, and there MUST NOT be a space before the
closing parenthesis. In the argument list, there MUST NOT be a space before
each comma, and there MUST be one space after each comma.

Comment thread spec.md
```

The `clone` language construct MUST always be used with parenthesis, even when the optional `$withProperties` argument is
not provided. For example:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrfnl How about something along the lines of

Suggested change
not provided. For example:
not provided. As such, it follows the same rules as function calls. For example:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it needs to be spelled out as this paragraph is within the "function and method call" section anyway, but I just wanted to clarify to avoid ending up with discussions about this in the PHPCS repo later on.

@Crell
Copy link
Copy Markdown
Collaborator

Crell commented May 6, 2026

Agreed with @jrfnl about the spacing. Pseudo-function language constructs should always be formatted like functions, without a space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP 8.5: Always require parentheses around clone()

3 participants