|
Posted by elmosik on 10/01/80 12:00
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.
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
Navigation:
[Reply to this message]
|