Skip to content

Fixed more ternary concatenation bugs#9462

Merged
mbien merged 1 commit into
apache:masterfrom
mbien:ternary-concat-fix
Jun 23, 2026
Merged

Fixed more ternary concatenation bugs#9462
mbien merged 1 commit into
apache:masterfrom
mbien:ternary-concat-fix

Conversation

@mbien

@mbien mbien commented Jun 22, 2026

Copy link
Copy Markdown
Member

inspired by #9459

I ran:

"possible bug: ambiguous ternary concatenation":
$pre + $nullable != null ? $a : $b =>
$pre + ($nullable != null ? $a : $b)
;;

"possible bug: ambiguous ternary concatenation":
$pre + $nullable == null ? $a : $b =>
$pre + ($nullable == null ? $a : $b)
;;

Eval order is from left to right which can lead to undesired effects when the right side has a ternary operator.

This puts the ternary operation in braces (or avoids the situation by other means)

Eval order is from left to right which can lead to undesired effects
when the right side has a ternary operator.

This puts the ternary operation in braces (or avoids the situation
by other means)
@mbien mbien added this to the NB31 milestone Jun 22, 2026
@mbien mbien requested review from matthiasblaesing and tmysik June 22, 2026 21:58
@mbien mbien added Code cleanup Label for cleanup done on the Netbeans IDE PHP [ci] enable extra PHP tests (php/php.editor) CSS [ci] enable web job Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Platform [ci] enable platform tests (platform/*) enterprise [ci] enable enterprise job Ant [ci] enable "build tools" tests labels Jun 22, 2026

@tmysik tmysik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, thank you

@neilcsmith-net neilcsmith-net left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks. A nasty hidden one this. Hopefully nothing is relying on the wrong behaviour! 😆

@matthiasblaesing matthiasblaesing left a comment

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.

Looks good to me.

Side question: Would you mind elaborating how "I ran" works in practice?

@mbien

mbien commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

Side question: Would you mind elaborating how "I ran" works in practice?

of course! you can simply put the above mentioned rules it into a hint file (e.g foo.hint) and run it via single-file run action (e.g right click menu) (#3171).

But I like to put reuseable rules into [nb_config]/config/rules which is picked up by the editor automatically on save. There is also UI for that but it is a bit hidden. (example hint files)

Running a hint file will open the "inspect and transform" refactoring dialog and ask you about the scope. I have a project group with all NB modules, so i selected "all opened projects" and ran it. (warning: can take little while since its a lot of modules)

@mbien mbien merged commit 862bef2 into apache:master Jun 23, 2026
75 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ant [ci] enable "build tools" tests Code cleanup Label for cleanup done on the Netbeans IDE CSS [ci] enable web job enterprise [ci] enable enterprise job Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) PHP [ci] enable extra PHP tests (php/php.editor) Platform [ci] enable platform tests (platform/*)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants