Process/Php7.php
[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     
41     function scan($route = array()) 
42     {
43         $dir = $this->rootDir . "/" . implode("/", $route);
44         
45         echo "Looking for {$dir}\n";
46         
47         foreach (scandir($dir) as $d) {
48             
49             if (!strlen($d) || $d[0] == '.') {
50                 continue;
51             }
52             
53             if (is_dir($d)) {
54                 $this->scan(array_merge($route, array($d)));
55                 continue;
56             }
57             
58             if (!preg_match('/\.php$/', $d)) {
59                 continue;
60             }
61             
62             try {
63                 
64                 if(!empty($route)){
65                     require_once implode('/', $route) . "/" . $d;
66                     continue;
67                 }
68                 
69                 require_once $d;
70                 
71             } catch (ErrorException $ex) {
72                 echo $ex->getMessage() . "\n";
73             }
74             
75         }
76         
77     }
78
79 //    function scan($p, $pr, $path = false) 
80 //    {
81 //        $full_path = array($p, $pr);
82 //        $class_path = array();
83 //        if ($path !== false) {
84 //            $full_path = array_merge($full_path, $path);
85 //            $class_path = array_merge($class_path, $path);
86 //        }
87 //        //print_r("CHKDIR:    ". implode('/', $full_path)."\n");
88 //
89 //        foreach (scandir(implode('/', $full_path)) as $d) {
90 //
91 //            if (!strlen($d) || $d[0] == '.') {
92 //                continue;
93 //            }
94 //            $chk = $full_path;
95 //            $chk[] = $d;
96 //
97 //            $clp = $class_path;
98 //
99 //
100 //
101 //            //print_r("CHK:          " . implode('/', $chk)."\n");
102 //            // is it a file.. and .PHP...
103 //            if (!is_dir(implode('/', $chk))) {
104 //                if (!preg_match('/\.php$/', $d)) {
105 //                    continue;
106 //                }
107 //                $clp[] = preg_replace('/\.php$/', '', $d);
108 //
109 //                //print_r("CLP:          " . implode('/', $clp)."\n");
110 //                require_once "Pman/" . implode('/', $clp) . '.php';
111 //                continue;
112 //            }
113 //            $clp[] = $d;
114 //            // otherwise recurse...
115 //            //print_r("RECURSE:        " . implode('/', $clp)."\n");
116 //
117 //            $this->scan($p, $pr, $clp);
118 //        }
119 //    }
120
121     function output() 
122     {
123         die("DONE");
124     }
125
126 }