Class used before declaration

David Nolden zwabel at googlemail.com
Fri Jan 9 18:09:48 UTC 2009


Am Friday 09 January 2009 17:02:53 schrieb Niko Sams:
> Hi,
>
> I have another problem with Php support, in Php the following is possible:
> $a = new Foo;
> class Foo {}
>
> But in the TypeBuilder I can't find Foo - as its type and declaration
> not yet created.
>
> A second DeclarationBuilder run would work - but that is not very efficent.
>
> Any better ideas?
>
> Niko
How does the real php-interpreter deal with it? The most logical approach 
would probably be multiple passes: One for building types, and one for doing 
the rest.

However if you want to cater this special case without having to do that, you 
could think about creating a forward-declaration of "class Foo" on "new Foo;" 
when Foo is not found.

Then you would have to deal with forward-declarations during search though.

Greetings, David




More information about the KDevelop-devel mailing list