1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 18:48:03 +01:00
psalm/docs/running_psalm/issues/DuplicateClass.md
2020-03-21 10:13:11 -04:00

542 B
Raw Blame History

DuplicateClass

Emitted when a class is defined twice

<?php

class A {}
class A {}

Why this is bad

The above code wont compile.

PHP does allow you to define a class conditionally:

<?php

if (rand(0, 1)) {
    class A {
        public function __construct(string $s) {}
    }
} else {
    class A {
        public function __construct(object $o) {}
    }
}

But Psalm really doesn't want you to use this pattern it's impossible for Psalm to know (without using reflection) which class is getting used.