Closed thekid closed 6 years ago
This definitely is one of the harder parts to get right with PHP: While it seems quite straight-forward in the beginning, it actually means that during compilation, we most probably cannot verify the class yet. Instead we need to execute the source until class becomes available (which happens inside the include()
statement), the go back to the verification phase. Beware: Not all other classes / interfaces / traits etc. may be available yet, so we might need to wait for them, too.
An idea might be to defer the verification until the first time the class actually gets used / in the above example, that's the new
statement.
Define a class inside an include to see this happen: