orklah/psalm-elvis-begone
Composer 安装命令:
composer require orklah/psalm-elvis-begone
包简介
Replace Elvis operator (?:) by null coalesce operator (??) when applicable
README 文档
README
A Psalm plugin to replace Elvis operator (?:) by null coalesce operator (??) when applicable
Installation:
$ composer require --dev orklah/psalm-elvis-begone $ vendor/bin/psalm-plugin enable orklah/psalm-elvis-begone
Usage:
Run Psalter command:
$ vendor/bin/psalm --alter --plugin=vendor/orklah/psalm-elvis-begone/src/Plugin.php
Explanation:
The short ternary operator (or Elvis operator ?: ) is used to evaluate return its condition if it's true or the second operand if it's not.
When the type is known and the only falsy value is null, we can actually replace it with the null coalesce operator (??) for strictness and clarity.
It will prevent future values to be evaluated to false when it was not the intention
统计信息
- 总下载量: 10.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-13