Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match expressions doesn't need always to be terminated by a semicolon #4402

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

driade
Copy link
Contributor

@driade driade commented Jan 17, 2025

I'm not sure if this PR is important for the documentation, but "match" doesn't always need to be terminated by a semicolon.

I've learned this today :)

@driade
Copy link
Contributor Author

driade commented Jan 17, 2025

@kamil-tekiela
Copy link
Member

Some expressions can be considered as statements. In this case, a statement has the form of 'expr ;' that is, an expression followed by a semicolon. In $b = $a = 5;, $a = 5 is a valid expression, but it's not a statement by itself. $b = $a = 5;, however, is a valid statement.

https://www.php.net/manual/en/language.expressions.php

I'm not sure why we repeat that information on the match page. Perhaps it should be removed instead of expanded.

Comment on lines 91 to 92
A <literal>match</literal> expression <emphasis>must</emphasis> be
terminated by a semicolon <literal>;</literal>.
Copy link
Member

Choose a reason for hiding this comment

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

I think just rephrasing the existing note to

When a match expression is used as a standalone expression it must be terminated by a semicolon.

Covers the nuance just fine without needing to add examples.

You could use a match expression as a function argument, and you don't need a semi colon there either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we go then!

@driade driade force-pushed the feature/improve_match_description branch from 2f3f696 to 1600ba8 Compare January 29, 2025 09:49
Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
@Girgias Girgias merged commit e50047b into php:master Jan 30, 2025
2 checks passed
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.

3 participants