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