Automatic PHP extern class creation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatic PHP extern class creation

basvanmeurs
Hi, I'm working on a Haxe/php project. I need to use some existing (large) php classes and would like to get an 'extern' version of it. Php offers a lot of reflection functionality (http://www.php.net/manual/en/book.reflection.php). I think enough functionality to be able to generate basic Haxe extern classes automatically. I am thinking about building a little tool for this unless somebody else has already done this. So has someone already built something like it or tried using this technique?

Regards,
Bas
Reply | Threaded
Open this post in threaded view
|

Re: Automatic PHP extern class creation

clemos
Hi

I've been working a few hours, during week end, on an extern class
generator that uses php docbook xmls, but it's really just a very
small thing.
I had also been working on a similar tool to generate Java/haXe extern
classes to use with Rhino, based on javadoc generated xmls.

As you may know, PHP is very weakly typed. AFAIK, the most precise
type information you can define in PHP is called Type Hinting
(http://fr2.php.net/manual/en/language.oop5.typehinting.php) and only
works for function / method parameters. This is very few informations
in comparison to haXe's typing system, so even if Reflection looks
interresting, it certainly won't provide enough information to
generate properly typed extern classes.
ITOH, most PHP classes (at least those documented on php.net) are
typed through documentation, so parsing docbook xmls give more
informations for the purpose of converting them to extern classes.
There are still a few problems though, one of the biggest being that
an "array" in PHP can either be converted to an Array, a Hash or a
typedef/Dynamic depending on the context.

++++++
Clément

On Tue, Jun 15, 2010 at 2:57 PM, basvanmeurs <[hidden email]> wrote:

>
> Hi, I'm working on a Haxe/php project. I need to use some existing (large)
> php classes and would like to get an 'extern' version of it. Php offers a
> lot of reflection functionality
> (http://www.php.net/manual/en/book.reflection.php). I think enough
> functionality to be able to generate basic Haxe extern classes
> automatically. I am thinking about building a little tool for this unless
> somebody else has already done this. So has someone already built something
> like it or tried using this technique?
>
> Regards,
> Bas
> --
> View this message in context: http://haxe.1354130.n2.nabble.com/Automatic-PHP-extern-class-creation-tp5181780p5181780.html
> Sent from the Haxe mailing list archive at Nabble.com.
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Automatic PHP extern class creation

Niel Drummond-3
On Tue, Jun 15, 2010 at 03:48:38PM +0200, clemos wrote:
> ITOH, most PHP classes (at least those documented on php.net) are
> typed through documentation, so parsing docbook xmls give more
> informations for the purpose of converting them to extern classes.
> There are still a few problems though, one of the biggest being that
> an "array" in PHP can either be converted to an Array, a Hash or a
> typedef/Dynamic depending on the context.

>From personal experience parsing an haXe AST in PHP is very slow. I did it with the Dojo library a few years ago - they have a PHP-based documentation generator. It took more than a minute for the entire tree.

The more performant option is to take the XML generated in the PHP documentation project which is used to parse the docbook xmls, and use XSLT. I've used this technique for Google's O3D plugin, and it works very quickly (about 1 second for several MB of XML and dozens of classes).

- Niel

>
> ++++++
> Cl?ment
>
> On Tue, Jun 15, 2010 at 2:57 PM, basvanmeurs <[hidden email]> wrote:
> >
> > Hi, I'm working on a Haxe/php project. I need to use some existing (large)
> > php classes and would like to get an 'extern' version of it. Php offers a
> > lot of reflection functionality
> > (http://www.php.net/manual/en/book.reflection.php). I think enough
> > functionality to be able to generate basic Haxe extern classes
> > automatically. I am thinking about building a little tool for this unless
> > somebody else has already done this. So has someone already built something
> > like it or tried using this technique?
> >
> > Regards,
> > Bas
> > --
> > View this message in context: http://haxe.1354130.n2.nabble.com/Automatic-PHP-extern-class-creation-tp5181780p5181780.html
> > Sent from the Haxe mailing list archive at Nabble.com.
> >
> > --
> > haXe - an open source web programming language
> > http://haxe.org
> >
>
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org