Proposal use `logical_operators`

Open
#48 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
tooling

Research direction

Start with the linked logical_operators rule documentation and the PHP operator-precedence reference. Determine whether this belongs in the coding-standard rule set or should instead be a Psalm rule, then review the repository's existing rule configuration and tests. Done means the chosen approach consistently addresses uses of and and or without introducing precedence-related breakage.

Written by the indexing model from the issue text.

Description

question

Forbid using and and or operators in favor of && and ||.
The reason is that and and or have non obvious different precedence, which also makes this rule risky thus we might need to discuss if we instead need to create a psalm rule for it.
See also https://www.php.net/manual/en/language.operators.precedence.php

- if ($foo and $bar)
+ if ($foo && bar)

cc @nickvergessen @provokateurin @ChristophWurst

Dominant language
PHP
Stars
14
Forks
2
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextcloud/coding-standard

All issues in nextcloud/coding-standard

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.