4ceefd6f795281ca54ac03c05b7075995a2425bd
[Pman.Core] / Process / Php7.php
1 <?php
2
3 /**
4  *
5  * PHP7 produces all sorts of pointless warnings... this attempts to just include all the files,
6  * so that you can view them..??
7  *
8  * would be nice to write the code to fix them.
9  *
10  */
11 require_once 'Pman.php';
12
13 class Pman_Core_Process_Php7 extends Pman 
14 {
15
16     static $cli_desc = "Tests for PHP compatibilty, by including files...";
17     static $cli_opts = array();
18
19     function getAuth() 
20     {
21         if (empty($this->bootLoader->cli)) {
22             die("CLI only");
23         }
24     }
25     
26     function get($base, $opts = array()) 
27     {
28         set_error_handler(function ($errno, $errstr, $errfile, $errline ){
29 //            throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
30             print_r(array(
31                 $errno,
32                 $errstr,
33                 $errfile,
34                 $errline
35             ));
36         });
37         
38         $this->scan();
39         
40         exit;
41     }
42     
43     function scan($route = array()) 
44     {
45         $dir = $this->rootDir . "/" . implode("/", $route);
46         
47         echo "Looking for {$dir}\n";
48         
49         foreach (scandir($dir) as $d) {
50             
51             if (!strlen($d) || $d[0] == '.') {
52                 continue;
53             }
54             
55             if (is_dir($d)) {
56                 $this->scan(array_merge($route, array($d)));
57                 continue;
58             }
59             
60             if (!preg_match('/\.php$/', $d)) {
61                 continue;
62             }
63             
64             try {
65                 
66                 $cls = $d;
67                 var_dump($d);
68                 if(!empty($route)){
69                     $cls = implode('/', $route) . "/" . $d;
70                 }
71                 
72                 require_once $cls;
73                 
74             } catch (ErrorException $ex) {
75                 echo $ex->getMessage() . "\n";
76             }
77             
78         }
79         
80     }
81
82 //    function scan($p, $pr, $path = false) 
83 //    {
84 //        $full_path = array($p, $pr);
85 //        $class_path = array();
86 //        if ($path !== false) {
87 //            $full_path = array_merge($full_path, $path);
88 //            $class_path = array_merge($class_path, $path);
89 //        }
90 //        //print_r("CHKDIR:    ". implode('/', $full_path)."\n");
91 //
92 //        foreach (scandir(implode('/', $full_path)) as $d) {
93 //
94 //            if (!strlen($d) || $d[0] == '.') {
95 //                continue;
96 //            }
97 //            $chk = $full_path;
98 //            $chk[] = $d;
99 //
100 //            $clp = $class_path;
101 //
102 //
103 //
104 //            //print_r("CHK:          " . implode('/', $chk)."\n");
105 //            // is it a file.. and .PHP...
106 //            if (!is_dir(implode('/', $chk))) {
107 //                if (!preg_match('/\.php$/', $d)) {
108 //                    continue;
109 //                }
110 //                $clp[] = preg_replace('/\.php$/', '', $d);
111 //
112 //                //print_r("CLP:          " . implode('/', $clp)."\n");
113 //                require_once "Pman/" . implode('/', $clp) . '.php';
114 //                continue;
115 //            }
116 //            $clp[] = $d;
117 //            // otherwise recurse...
118 //            //print_r("RECURSE:        " . implode('/', $clp)."\n");
119 //
120 //            $this->scan($p, $pr, $clp);
121 //        }
122 //    }
123
124     function output() 
125     {
126         die("DONE");
127     }
128
129 }