Skip to content

Bogus warning "A scalar of type 'bool' used as an array" #969

Closed

Description

@php4fan

Code that reproduces:

<?php

class Foo {
     public function doFoo() {
          $a = [
               'foo' => false
          ];
          $a['foo'] = ['lalala' => 123];
          
          
          return $a;
     }
}

class Bar {
     function doBar() {
          $foo = new Foo();
          $a = $foo->doFoo();
               
          echo $a['foo']['lalala']; //////// <<<<< BOGUS WARNING HERE
     }
}

Expected behavior: no warning.

Observed behavior: bogus warning "A scalar of type 'bool' used as an array".

Activity

  1. php4fan commented on Dec 16, 2025

    @php4fan
    Author

    Much simpler code that still reproduces:

    <?php
    
    $a = [
         'foo' => false
    ];
    $a['foo'] = ['lalala' => 123];
    
    echo $a['foo']['lalala'];
    

    (I was initially under the wrong impression that this didn't)

  2. self-assigned this
    on Dec 19, 2025
  3. jakubmisek commented on Dec 20, 2025

    @jakubmisek
    Member

    thank you for the test case! fixed in the next update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions