-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_funcs.php
More file actions
51 lines (48 loc) · 1.05 KB
/
test_funcs.php
File metadata and controls
51 lines (48 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Test_Funcs;
/**
* Lint a script and assert that it uses valid syntax
*
* @param string $script The PHP script to lint
* @return void
*/
function lint_script($script)
{
$clean_syntax = php_check_syntax($script, $syntax_errors);
assert($clean_syntax, $syntax_errors . __FILE__);
}
/**
* Get all of the sub-directories withing a directory
*
* @param string $dir The directory to scan
* @return void
*/
function get_dirs($dir = __DIR__)
{
return glob("{$dir}/*", GLOB_ONLYDIR);
}
/**
* Scan a directory for "*.php"
*
* @param string $dir The directory to scan
* @return void
*/
function get_scripts($dir = __DIR__)
{
return glob("{$dir}/*.php");
}
/**
* Recursively lint the PHP scripts in a directory
*
* @param string $dir Directory to scan recursively
* @return void
*/
function lint_scripts_recursive($dir = __DIR__)
{
static $funcs;
if (is_null($funcs)) {
$funcs = \shgysk8zer0\Core\NamespacedFunction::load(__NAMESPACE__);
}
array_map($funcs->lint_script, get_scripts($dir));
array_map(__FUNCTION__, get_dirs($dir));
}