auto-fix "Only booleans are allowed in a ternary operator condition"

Open
#317 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the reported PHPStan error and the linked PHPStan playground example, then compare the related issue #316 for the intended auto-fix behavior. Done means simple ternary conditions with a single falsy value can be automatically fixed without changing other cases.

Written by the indexing model from the issue text.

Description

Feature request

I think we can auto-fix

Only booleans are allowed in a ternary operator condition, PHPStan\Reflection\ClassReflection|null given.

in case of simple conditions which only can contain a single falsy-value

https://phpstan.org/r/488fe4b8-a3fe-4f53-996f-0692a8c5b9d8

similar to https://github.com/phpstan/phpstan-strict-rules/issues/316

Did PHPStan help you today? Did it make you happy in any way?

No response

Dominant language
PHP
Stars
709
Forks
62
Avg merge
5d 19h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

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 phpstan/phpstan-strict-rules

All issues in phpstan/phpstan-strict-rules

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.