Skip to content

unkown_member false positive on extended Exception #87

@mtorromeo

Description

@mtorromeo

PHPantom version

0.7.0

Installation method

Pre-built binary from GitHub Releases

Operating system

Linux x86_64

Editor

Zed

Bug description

phpantom seems to get confused with inheritance of classes with the same name but different namespaces and ends up wrongly reporting missing methods that are present in the parent class.

Steps to reproduce

  1. Create this file which is working fine
<?php

namespace Test;

class MyException extends \Exception {}

try {
  throw new MyException("foobards");
} catch (MyException $e) {
  echo $e->getMessage();
}
  1. Add a declaration for a class Test\Exception that should not matter in the rest of the code
<?php

namespace Test;

// add this
class Exception extends \Exception {}

class MyException extends \Exception {}

try {
  throw new MyException("foobards");
} catch (MyException $e) {
  echo $e->getMessage(); // Method 'getMessage' not found on class 'Test\MyException'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions