Book a Demo

Author Topic: Changing the class declaration for PHP  (Read 3544 times)

temp

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Changing the class declaration for PHP
« on: July 25, 2005, 03:01:12 am »
Hi all!

I tried to change the generated classnames in PHP to the PEAR class-hierarchy notation (http://pear.php.net/manual/en/standards.naming.php), to work around the missing packages in PHP.

I changed the Class Declaration for PHP to this:

Code: [Select]
...

$pp=""
%if packagePath != ""%
$pp=%REPLACE(packagePath, ".", "_")%+"_"
%endIf%

class $pp%className%$bases


I had to make some changed to the File template and Namespace template, which is stated in several posts here in the forum to get packagePath working like it should (with Namespace it only returns the first level of package-hierarchy).

Everything works fine, classes are now generated like this, for a class RequestAction in package Request:

Code: [Select]
class Request_RequestAction {
...
}


So far, no problems ;-)

But when I re-generate the code, all classes are appended, existing aren't overwritten.

So after I generate the classes 3 times to the same place I have 3 class Request_RequestAction {} in my file!

Seems like the class isn't recognized anymore. Is there a way to change the pattern after which the classname is identified? I thought that the parsing uses the same classnames that are generated through the templates, but this doesn't seem to be the case.

Any hints?

Stephan

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Changing the class declaration for PHP
« Reply #1 on: July 25, 2005, 04:34:15 pm »
I can tell you what's happening, but at the moment I can't tell you how to fix it.

When you re-generate your class, EA parses the file and looks for the class you are generating.  But it doesn't find a class by the name of RequestAction.  Only one (or two or three ... )with the name of Request_ReqestAction.

As a result it generates the class and adds it to the end of the file.

That still leaves the resolution of the problem, but I'll go away and hopefully come back with an answer to that.

Simon

temp

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Changing the class declaration for PHP
« Reply #2 on: July 25, 2005, 11:52:23 pm »
Yea, that's just what I thought.

Maybe in general it would be a good idea to let the user change the parsing-templates as well?