From 696667b7ad828e5231da9bcf0f4339ecf843053b Mon Sep 17 00:00:00 2001 From: Jared Hancock <gravydish@gmail.com> Date: Mon, 4 Feb 2019 19:30:12 -0600 Subject: [PATCH] i18n: Fixup PHP 7 issues for i18n compiliation This fixes PHP issues compiling language packs with PHP after version 7. --- include/cli/modules/i18n.php | 2 +- setup/test/tests/class.test.php | 6 +++--- setup/test/tests/test.extra-whitespace.php | 2 +- setup/test/tests/test.git-conflicts.php | 2 +- setup/test/tests/test.jslint.php | 2 +- setup/test/tests/test.shortopentags.php | 2 +- setup/test/tests/test.signals.php | 2 +- setup/test/tests/test.syntax.php | 4 ++-- setup/test/tests/test.undefinedmethods.php | 4 ++-- setup/test/tests/test.unitialized.php | 2 +- setup/test/tests/test.var-dump.php | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/cli/modules/i18n.php b/include/cli/modules/i18n.php index 2adb14a90..44ce45897 100644 --- a/include/cli/modules/i18n.php +++ b/include/cli/modules/i18n.php @@ -637,7 +637,7 @@ class i18n_Compiler extends Module { ); $root = realpath($options['root'] ?: ROOT_DIR); $domain = $options['domain'] ? '('.$options['domain'].')/' : ''; - $files = Test::getAllScripts(true, $root); + $files = Test::getAllScripts("*.php", $root); $strings = array(); foreach ($files as $f) { $F = str_replace($root.'/', $domain, $f); diff --git a/setup/test/tests/class.test.php b/setup/test/tests/class.test.php index 1c4f1b525..8eec8a753 100644 --- a/setup/test/tests/class.test.php +++ b/setup/test/tests/class.test.php @@ -31,13 +31,13 @@ class Test { function teardown() { } - function ignore3rdparty() { + static function ignore3rdparty() { return true; } - function getAllScripts($pattern='*.php', $root=false, $excludes=true) { + static function getAllScripts($pattern='*.php', $root=false, $excludes=true) { $root = $root ?: get_osticket_root_path(); - $excludes = $excludes ?: $this->ignore3rdparty(); + $excludes = $excludes ?: static::ignore3rdparty(); $scripts = array(); foreach (glob_recursive("$root/$pattern") as $s) { $found = false; diff --git a/setup/test/tests/test.extra-whitespace.php b/setup/test/tests/test.extra-whitespace.php index ff3fc7be0..2565de681 100644 --- a/setup/test/tests/test.extra-whitespace.php +++ b/setup/test/tests/test.extra-whitespace.php @@ -5,7 +5,7 @@ class ExtraWhitespace extends Test { var $name = "PHP Leading and Trailing Whitespace"; function testFindWhitespace() { - foreach ($this->getAllScripts() as $s) { + foreach (static::getAllScripts() as $s) { $matches = array(); $content = file_get_contents($s); if (preg_match_all('/^\s+<\?php|\?>\n\s+$/s', diff --git a/setup/test/tests/test.git-conflicts.php b/setup/test/tests/test.git-conflicts.php index 5aa27bfb9..dde0621e3 100644 --- a/setup/test/tests/test.git-conflicts.php +++ b/setup/test/tests/test.git-conflicts.php @@ -6,7 +6,7 @@ class GitConflicts extends Test { function testFindGitConflicts() { $regex = '/^[\t ]*?<{3,} ?HEAD[\t ]*?|^[\t ]*?>{3,}[\t ]*?/m'; - foreach ($this->getAllScripts('*') as $s) { + foreach (static::getAllScripts('*') as $s) { $matches = array(); $content = file_get_contents($s); if (preg_match_all($regex, diff --git a/setup/test/tests/test.jslint.php b/setup/test/tests/test.jslint.php index e916715c6..038a9109f 100644 --- a/setup/test/tests/test.jslint.php +++ b/setup/test/tests/test.jslint.php @@ -6,7 +6,7 @@ class JsSyntaxTest extends Test { function testLintErrors() { $exit = 0; - foreach ($this->getAllScripts('*.js') as $s) { + foreach (static::getAllScripts('*.js') as $s) { ob_start(); system("jsl -process $s", $exit); $line = ob_get_contents(); diff --git a/setup/test/tests/test.shortopentags.php b/setup/test/tests/test.shortopentags.php index ec5b8669e..9aacbd94c 100644 --- a/setup/test/tests/test.shortopentags.php +++ b/setup/test/tests/test.shortopentags.php @@ -5,7 +5,7 @@ class ShortOpenTag extends Test { var $name = "PHP Short Open Checks"; function testFindShortOpens() { - foreach ($this->getAllScripts() as $s) { + foreach (static::getAllScripts() as $s) { $matches = array(); $content = file_get_contents($s); if (preg_match_all('/<\?\s*(?!php|xml).*$/m', diff --git a/setup/test/tests/test.signals.php b/setup/test/tests/test.signals.php index 0f6287a0a..0176bf0cc 100644 --- a/setup/test/tests/test.signals.php +++ b/setup/test/tests/test.signals.php @@ -8,7 +8,7 @@ class SignalsTest extends Test { * Ensures that each signal subscribed to has a sender somewhere else */ function testFindSignalPublisher() { - $scripts = $this->getAllScripts(); + $scripts = static::getAllScripts(); $matches = $published_signals = array(); foreach ($scripts as $s) if (preg_match_all("/^ *Signal::send\('([^']+)'/m", diff --git a/setup/test/tests/test.syntax.php b/setup/test/tests/test.syntax.php index cc528f52f..38bb5acca 100644 --- a/setup/test/tests/test.syntax.php +++ b/setup/test/tests/test.syntax.php @@ -4,13 +4,13 @@ require_once "class.test.php"; class SyntaxTest extends Test { var $name = "PHP Syntax Checks"; - function ignore3rdparty() { + static function ignore3rdparty() { return false; } function testCompileErrors() { $exit = 0; - foreach ($this->getAllScripts() as $s) { + foreach (static::getAllScripts() as $s) { ob_start(); system("php -l $s", $exit); $line = ob_get_contents(); diff --git a/setup/test/tests/test.undefinedmethods.php b/setup/test/tests/test.undefinedmethods.php index 16f4e76e1..aaba66340 100644 --- a/setup/test/tests/test.undefinedmethods.php +++ b/setup/test/tests/test.undefinedmethods.php @@ -4,12 +4,12 @@ require_once "class.test.php"; class UndefinedMethods extends Test { var $name = "Access to undefined object methods"; - function ignore3rdparty() { + static function ignore3rdparty() { return false; } function testUndefinedMethods() { - $scripts = $this->getAllScripts(); + $scripts = static::getAllScripts(); $function_defs = array(); foreach ($scripts as $s) { $matches = array(); diff --git a/setup/test/tests/test.unitialized.php b/setup/test/tests/test.unitialized.php index 47978fdb2..dc10af0fb 100644 --- a/setup/test/tests/test.unitialized.php +++ b/setup/test/tests/test.unitialized.php @@ -6,7 +6,7 @@ class UnitializedVars extends Test { var $name = "Access to unitialized variables"; function testUnitializedUsage() { - $scripts = $this->getAllScripts(); + $scripts = static::getAllScripts(); $matches = array(); foreach ($scripts as $s) { $a = new SourceAnalyzer($s); diff --git a/setup/test/tests/test.var-dump.php b/setup/test/tests/test.var-dump.php index 1244ec7b5..d87f393e5 100644 --- a/setup/test/tests/test.var-dump.php +++ b/setup/test/tests/test.var-dump.php @@ -6,7 +6,7 @@ class VarDump extends Test { function testFindShortOpens() { $re = '/^(([\t ]*?)var_dump\(.*[\)|,|;])((?!nolint).)*$/m'; - foreach ($this->getAllScripts() as $s) { + foreach (static::getAllScripts() as $s) { $matches = array(); $content = file_get_contents($s); if (preg_match_all($re, -- GitLab