]> git.mxchange.org Git - friendica.git/blob - util/typo.php
Merge pull request #4552 from tobiasd/20180305-messagespo
[friendica.git] / util / typo.php
1 #!/usr/bin/env php
2 <?php
3
4 // Tired of chasing typos and finding them after a commit.
5 // Run this from cmdline in basedir and quickly see if we've
6 // got any parse errors in our application files.
7
8 use Friendica\App;
9
10 error_reporting(E_ERROR | E_WARNING | E_PARSE);
11 ini_set('display_errors', '1');
12 ini_set('log_errors', '0');
13
14 include 'boot.php';
15
16 if (empty($a)) {
17         $a = new App(dirname(__DIR__));
18 }
19
20 if (x($a->config, 'php_path')) {
21         $phpath = $a->config['php_path'];
22 } else {
23         $phpath = 'php';
24 }
25
26 echo 'Directory: src' . PHP_EOL;
27 $Iterator = new RecursiveDirectoryIterator('src');
28
29 foreach (new RecursiveIteratorIterator($Iterator) as $file) {
30         if (substr($file, -4) === '.php') {
31                 passthru("$phpath -l $file", $ret);
32                 $ret === 0 || die();
33         }
34 }
35
36 echo "Directory: mod\n";
37 $files = glob('mod/*.php');
38 foreach ($files as $file) {
39         passthru("$phpath -l $file", $ret);
40         $ret === 0 || die();
41 }
42
43 echo "Directory: include\n";
44 $files = glob('include/*.php');
45 foreach ($files as $file) {
46         passthru("$phpath -l $file", $ret);
47         $ret === 0 || die();
48 }
49
50 echo "Directory: object\n";
51 $files = glob('object/*.php');
52 foreach ($files as $file) {
53         passthru("$phpath -l $file", $ret);
54         $ret === 0 || die();
55 }
56
57 echo "Directory: addon\n";
58 $dirs = glob('addon/*');
59
60 foreach ($dirs as $dir) {
61         $addon = basename($dir);
62         $files = glob($dir . '/' . $addon . '.php');
63         foreach ($files as $file) {
64                 passthru("$phpath -l $file", $ret);
65                 $ret === 0 || die();
66         }
67 }
68
69 echo "String files\n";
70
71 echo 'util/strings.php' . "\n";
72 passthru("$phpath -l util/strings.php", $ret);
73 $ret === 0 || die();
74
75 $files = glob('view/lang/*/strings.php');
76 foreach ($files as $file) {
77         passthru("$phpath -l $file", $ret);
78         $ret === 0 || die();
79 }