php compilation problem/bug?

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

php compilation problem/bug?

Julien CASTETS
Hi,

It seems that there is a problem somewhere in the php target.
To be clear enough, here is the code that compiles (as expected) but fails at runtime with the message: Fatal error: Cannot make non static method php_db_Object::Insert() static in class GameDao
I removed all packaging/namespacing for clarity.


class Game
{
public var id:Int;

public function new(){}
}

class GameDao extends Object
{
public var id:Int;
static var TABLE_NAME = "tgame";
static var manager = new php.db.Manager<GameDao>(GameDao);
public function new() 
{
super();
}
public static function Insert(_Game:Game)
{
var l_New = new GameDao();
l_New.insert();
_Game.id = l_New.id;
}
}

class System 
{
static function main() 
{
var l_Db = new Database();
l_Db.Connect('localhost', 3306, 'root', '', 'test');
Manager.cnx = l_Db.connection;
var l_New = new Game();
GameDao.Insert(l_New);

l_Db.Close();
}
}

There is a conflict between the insert  method of php.db.Object and the Insert static method of GameDao
If I replace 
public static function Insert(_Game:Game) 
by 
public static function InsertInto(_Game:Game) then this will not fail.

Maybe it's a problem of case due to PHP ?

Generated code looks good

static function Insert($_Game) {
$GLOBALS['%s']->push("GameDao::Insert");
$»spos = $GLOBALS['%s']->length;
$l_New = new GameDao();
$l_New->insert();
$_Game->id = $l_New->id;
$GLOBALS['%s']->pop();
unset($»spos,$l_New);
}

Cheers
Julien

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

Re: php compilation problem/bug?

clemos
Hi,

I think this is because PHP is (the only?) case insensitive target,
thus "Insert" is the same as "insert".
If so, maybe it should have thrown an error at compile time ?

Cheers,
Clément

On Tue, Sep 21, 2010 at 3:50 PM, Julien CASTETS <[hidden email]> wrote:

> Hi,
> It seems that there is a problem somewhere in the php target.
> To be clear enough, here is the code that compiles (as expected) but fails
> at runtime with the message: Fatal error: Cannot make non static method
> php_db_Object::Insert() static in class GameDao
> I removed all packaging/namespacing for clarity.
>
> class Game
> {
> public var id:Int;
> public function new(){}
> }
> class GameDao extends Object
> {
> public var id:Int;
> static var TABLE_NAME = "tgame";
> static var manager = new php.db.Manager<GameDao>(GameDao);
> public function new()
> {
> super();
> }
> public static function Insert(_Game:Game)
> {
> var l_New = new GameDao();
> l_New.insert();
> _Game.id = l_New.id;
> }
> }
> class System
> {
> static function main()
> {
> var l_Db = new Database();
> l_Db.Connect('localhost', 3306, 'root', '', 'test');
> Manager.cnx = l_Db.connection;
> var l_New = new Game();
> GameDao.Insert(l_New);
> l_Db.Close();
> }
> }
> There is a conflict between the insert  method of php.db.Object and the
> Insert static method of GameDao
> If I replace
> public static function Insert(_Game:Game)
> by
> public static function InsertInto(_Game:Game) then this will not fail.
> Maybe it's a problem of case due to PHP ?
> Generated code looks good
> static function Insert($_Game) {
> $GLOBALS['%s']->push("GameDao::Insert");
> $»spos = $GLOBALS['%s']->length;
> $l_New = new GameDao();
> $l_New->insert();
> $_Game->id = $l_New->id;
> $GLOBALS['%s']->pop();
> unset($»spos,$l_New);
> }
> Cheers
> Julien
> --
> 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: php compilation problem/bug?

Julien CASTETS
I thought that PHP was case sensitive :) If not then +1 for haXe ;)
Could be nice if the compiler tells me about that :)

Julien

2010/9/21 clemos <[hidden email]>
Hi,

I think this is because PHP is (the only?) case insensitive target,
thus "Insert" is the same as "insert".
If so, maybe it should have thrown an error at compile time ?

Cheers,
Clément

On Tue, Sep 21, 2010 at 3:50 PM, Julien CASTETS <[hidden email]> wrote:
> Hi,
> It seems that there is a problem somewhere in the php target.
> To be clear enough, here is the code that compiles (as expected) but fails
> at runtime with the message: Fatal error: Cannot make non static method
> php_db_Object::Insert() static in class GameDao
> I removed all packaging/namespacing for clarity.
>
> class Game
> {
> public var id:Int;
> public function new(){}
> }
> class GameDao extends Object
> {
> public var id:Int;
> static var TABLE_NAME = "tgame";
> static var manager = new php.db.Manager<GameDao>(GameDao);
> public function new()
> {
> super();
> }
> public static function Insert(_Game:Game)
> {
> var l_New = new GameDao();
> l_New.insert();
> _Game.id = l_New.id;
> }
> }
> class System
> {
> static function main()
> {
> var l_Db = new Database();
> l_Db.Connect('localhost', 3306, 'root', '', 'test');
> Manager.cnx = l_Db.connection;
> var l_New = new Game();
> GameDao.Insert(l_New);
> l_Db.Close();
> }
> }
> There is a conflict between the insert  method of php.db.Object and the
> Insert static method of GameDao
> If I replace
> public static function Insert(_Game:Game)
> by
> public static function InsertInto(_Game:Game) then this will not fail.
> Maybe it's a problem of case due to PHP ?
> Generated code looks good
> static function Insert($_Game) {
> $GLOBALS['%s']->push("GameDao::Insert");
> $»spos = $GLOBALS['%s']->length;
> $l_New = new GameDao();
> $l_New->insert();
> $_Game->id = $l_New->id;
> $GLOBALS['%s']->pop();
> unset($»spos,$l_New);
> }
> Cheers
> Julien
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: php compilation problem/bug?

Franco Ponticelli
Yes, PHP is case insensitive and yes the compiler should warn about that. Can you report an issue so that it will not be forgotten?

Thank you,

Franco

On Tue, Sep 21, 2010 at 3:06 PM, Julien CASTETS <[hidden email]> wrote:
I thought that PHP was case sensitive :) If not then +1 for haXe ;)
Could be nice if the compiler tells me about that :)

Julien

2010/9/21 clemos <[hidden email]>

Hi,

I think this is because PHP is (the only?) case insensitive target,
thus "Insert" is the same as "insert".
If so, maybe it should have thrown an error at compile time ?

Cheers,
Clément

On Tue, Sep 21, 2010 at 3:50 PM, Julien CASTETS <[hidden email]> wrote:
> Hi,
> It seems that there is a problem somewhere in the php target.
> To be clear enough, here is the code that compiles (as expected) but fails
> at runtime with the message: Fatal error: Cannot make non static method
> php_db_Object::Insert() static in class GameDao
> I removed all packaging/namespacing for clarity.
>
> class Game
> {
> public var id:Int;
> public function new(){}
> }
> class GameDao extends Object
> {
> public var id:Int;
> static var TABLE_NAME = "tgame";
> static var manager = new php.db.Manager<GameDao>(GameDao);
> public function new()
> {
> super();
> }
> public static function Insert(_Game:Game)
> {
> var l_New = new GameDao();
> l_New.insert();
> _Game.id = l_New.id;
> }
> }
> class System
> {
> static function main()
> {
> var l_Db = new Database();
> l_Db.Connect('localhost', 3306, 'root', '', 'test');
> Manager.cnx = l_Db.connection;
> var l_New = new Game();
> GameDao.Insert(l_New);
> l_Db.Close();
> }
> }
> There is a conflict between the insert  method of php.db.Object and the
> Insert static method of GameDao
> If I replace
> public static function Insert(_Game:Game)
> by
> public static function InsertInto(_Game:Game) then this will not fail.
> Maybe it's a problem of case due to PHP ?
> Generated code looks good
> static function Insert($_Game) {
> $GLOBALS['%s']->push("GameDao::Insert");
> $»spos = $GLOBALS['%s']->length;
> $l_New = new GameDao();
> $l_New->insert();
> $_Game->id = $l_New->id;
> $GLOBALS['%s']->pop();
> unset($»spos,$l_New);
> }
> Cheers
> Julien
> --
> 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


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

Re: php compilation problem/bug?

Julien CASTETS
Done.
Thank you.

Cheers
Julien

2010/9/22 Franco Ponticelli <[hidden email]>
Yes, PHP is case insensitive and yes the compiler should warn about that. Can you report an issue so that it will not be forgotten?

Thank you,

Franco


On Tue, Sep 21, 2010 at 3:06 PM, Julien CASTETS <[hidden email]> wrote:
I thought that PHP was case sensitive :) If not then +1 for haXe ;)
Could be nice if the compiler tells me about that :)

Julien

2010/9/21 clemos <[hidden email]>

Hi,

I think this is because PHP is (the only?) case insensitive target,
thus "Insert" is the same as "insert".
If so, maybe it should have thrown an error at compile time ?

Cheers,
Clément

On Tue, Sep 21, 2010 at 3:50 PM, Julien CASTETS <[hidden email]> wrote:
> Hi,
> It seems that there is a problem somewhere in the php target.
> To be clear enough, here is the code that compiles (as expected) but fails
> at runtime with the message: Fatal error: Cannot make non static method
> php_db_Object::Insert() static in class GameDao
> I removed all packaging/namespacing for clarity.
>
> class Game
> {
> public var id:Int;
> public function new(){}
> }
> class GameDao extends Object
> {
> public var id:Int;
> static var TABLE_NAME = "tgame";
> static var manager = new php.db.Manager<GameDao>(GameDao);
> public function new()
> {
> super();
> }
> public static function Insert(_Game:Game)
> {
> var l_New = new GameDao();
> l_New.insert();
> _Game.id = l_New.id;
> }
> }
> class System
> {
> static function main()
> {
> var l_Db = new Database();
> l_Db.Connect('localhost', 3306, 'root', '', 'test');
> Manager.cnx = l_Db.connection;
> var l_New = new Game();
> GameDao.Insert(l_New);
> l_Db.Close();
> }
> }
> There is a conflict between the insert  method of php.db.Object and the
> Insert static method of GameDao
> If I replace
> public static function Insert(_Game:Game)
> by
> public static function InsertInto(_Game:Game) then this will not fail.
> Maybe it's a problem of case due to PHP ?
> Generated code looks good
> static function Insert($_Game) {
> $GLOBALS['%s']->push("GameDao::Insert");
> $»spos = $GLOBALS['%s']->length;
> $l_New = new GameDao();
> $l_New->insert();
> $_Game->id = $l_New->id;
> $GLOBALS['%s']->pop();
> unset($»spos,$l_New);
> }
> Cheers
> Julien
> --
> 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


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


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