|  | Posted by Jerry Stuckle on 06/13/82 12:00 
elmosik@gmail.com wrote:> On 17 Sty, 05:24, Jerry Stuckle <jstuck...@attglobal.net> wrote:
 >
 >> You should only be calling the constructor of the parent class in your
 >> constructor.
 >
 > Yes it's normal when you create new instance of included class,
 > constructor is called automatically ('new Class()'). Remember that in
 > constructor I can have also 'include/require' directives and it's the
 > main problem of that.
 >
 
 Normally you do not include/require something within a constructor.  And
 you do have to call the parent class' constructor manually if you have
 one in the derived class.
 
 > I had it coded in the second way that I described before (regexp) and
 > it work correctly, the main problem was how to choose valid regular
 > expressions to classes, functions, comments etc.
 >
 > It's basicly to do in 3 steps:
 >
 > 1. Remove comments from file, they can consists faked classes and
 > functions e.g.
 > - /* class MyClass extends XXX */
 > - # public function test()
 > - // class MyClass extends XXX
 >
 > 2. Match with regexp class context:
 > - class .... { ..... }
 > - get class context and match functions pattern
 >
 > 3. Remove sweepings and here you go
 >
 > My patterns (PHP preg_), they work for me now but I don't know in 100%
 > that they are valid - I need to test them more precisely.
 >
 > Comments
 > ------------------------
 > Multi line comments:
 > '@/\*.*?\*/@ims'
 >
 > Hashed lines:
 > '@^[\s|\t]+#.*?$@ims'
 >
 > Double slashed lines:
 > '@^[\s|\t]+//.*?$@ims'
 >
 >
 > Classes, functions
 > -------------------------
 > From one 'class' directive to other or to '?>':
 > '@^[\s|\t]+class[\s|\t]+([A-Z0-9_]+)([^{]+)?.*?(?:class|\?\>)@ism'
 >
 > Probably not working for code like that (divided into few <?php ?>
 > directives):
 >
 > ------------ sample code
 > class MyClass extends XXX
 > {
 > }
 > ?>
 >
 > <?php
 > class MySecondClass...
 > ?>
 > ------------------------
 >
 > Check if class extends XXX:
 > '@extends[\s|\t]+XXX@ism'
 >
 > Look only for public methods:
 > '@^[\s|\t]+(?:function|public[\s\t]+function)[\s|\t]+([A-Z0-9_]+)@ims'
 >
 > If you saw dramatic mistakes in my patterns say that :) I correct
 > them.
 >
 > --
 > Thanks and see you
 >
 
 I'm not an expert on regexs, so I won't comment on them specifically.
 But unless you're going to build a complete PHP parser, someone will
 find a way around almost anything you do.
 
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |