Skip to content

Incorrect Behaviour of DisallowedEmptyRuleFixerRector #8009

@mkrauser

Description

@mkrauser

Bug Report

Subject Details
Rector version 0.17.1

if empty(...) is called for an string-element of an array, the resulting code does not check if the array-key actually exists.

Minimal PHP Code Causing Issue

$parts = parse_url($url);

if (!empty($parts['host'])) {
// is replaced with 
if ($parts['host'] !== '') {

// but the host-key might not be set

https://getrector.com/demo/5df3320d-26b9-47a6-a4ee-7910f747bb9c

Expected Behaviour

I guess adding an additional isset(...)-check would fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions