🌐 AI搜索 & 代理 主页
Skip to content

ArrayKeyExistsNullToEmptyStringRector forces me to cast to string when it is not necessary #9560

@MaxencePaulin

Description

@MaxencePaulin

Bug Report

Hello, I am in the process of upgrading to PHP 8.5, and new Rector rules have appeared via the PHP 8.5 set. One of these rules is “ArrayKeyExistsNullToEmptyStringRector.” The presentation of this rule on the website is great, especially since PHP 8.5 has deprecated passing potentially null as the first parameter of array_key_exists.

Except that it occurs even when the value is not necessarily null, for int|string for example.

Is this normal?

Subject Details
Rector version 2.2.14
PHP version 8.5

Minimal PHP Code Causing Issue

https://getrector.com/demo/50d047e9-daab-4e97-8805-33c2ec9bd3b7

Expected Behaviour

I don't think it's necessary to cast to string when the input value is typed as int or string or int|string, only when it is nullable. Please let me know if I'm on the wrong track somewhere!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions