dpxyfa4718
dpxyfa4718
2010-12-01 17:18

如何生成显示多个类之间关系的数组?

I want a PHP script that scans PHP classes files in given directory(sub directories too) and generate relation ship between them in array form. suppose a folder that contains files and subdirectories( two subfolders).

| | |-class1.php
| | \-class2.php
| |-subdir1
| | |-class11.php
| | \-class22.php
| |-subdir2
| | \-class33.php

it contains total 5 files.

scanning files in directory is not big issue...but how can i deliver a class relationship between them.

i want array in this form.

array([0]=>classname=>class1,extends=>class2,implements=>[0]class11[1]class22,[1]=>classname=>class2,extends=>class33,implements=>NULL)

HINT: it can be done through reflection class.

can anyone help me?i need this script.. thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duan1979768678 duan1979768678 11年前

    Extract from all the files parts of code that look like class<something but not }>{<something perhaps containing nested {}>} and eval all of those pieces of code.

    I guess you will have to determine specific order in which to eval them (you might take a note which files include which to determine this order, or take a look at extends and implements)

    Then use reflection.

    点赞 评论 复制链接分享