From ba11827340cc8a9362d9d163917fdf21bcaaccb2 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Thu, 8 Mar 2018 10:31:31 +0700 Subject: [PATCH] Code style fixes (DIRECTORY_SEPARATOR -> '/'). --- src/Controller/BuildController.php | 2 +- src/Helper/CommandExecutor.php | 8 ++++---- src/Helper/Lang.php | 6 +++--- src/Model/Build.php | 2 +- src/Plugin/Atoum.php | 4 ++-- src/Plugin/Composer.php | 4 ++-- src/Plugin/Grunt.php | 8 ++++---- src/Plugin/Gulp.php | 8 ++++---- src/Plugin/Lint.php | 8 ++++++-- src/Plugin/Pdepend.php | 6 +++--- src/Plugin/Phar.php | 4 ++-- src/Plugin/Phing.php | 4 ++-- src/Plugin/PhpCpd.php | 4 ++-- src/Plugin/PhpLoc.php | 6 +++--- src/Plugin/PhpTalLint.php | 10 +++++----- src/Plugin/SecurityChecker.php | 4 ++-- src/Plugin/Xmpp.php | 8 ++++---- 17 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/Controller/BuildController.php b/src/Controller/BuildController.php index de6ed610..20176c38 100644 --- a/src/Controller/BuildController.php +++ b/src/Controller/BuildController.php @@ -146,7 +146,7 @@ class BuildController extends Controller protected function getUiPlugins() { $rtn = []; - $path = PUBLIC_DIR . 'assets' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'build-plugins' . DIRECTORY_SEPARATOR; + $path = PUBLIC_DIR . 'assets/js/build-plugins/'; $dir = opendir($path); while ($item = readdir($dir)) { diff --git a/src/Helper/CommandExecutor.php b/src/Helper/CommandExecutor.php index 597b2055..cbbd4243 100644 --- a/src/Helper/CommandExecutor.php +++ b/src/Helper/CommandExecutor.php @@ -335,14 +335,14 @@ class CommandExecutor implements CommandExecutorInterface public function getComposerBinDir($path) { if (is_dir($path)) { - $composer = $path . DIRECTORY_SEPARATOR . 'composer.json'; + $composer = $path . '/composer.json'; if (is_file($composer)) { $json = json_decode(file_get_contents($composer)); if (isset($json->config->{"bin-dir"})) { - return $path . DIRECTORY_SEPARATOR . $json->config->{"bin-dir"}; - } elseif (is_dir($path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin')) { - return $path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin'; + return $path . '/' . $json->config->{"bin-dir"}; + } elseif (is_dir($path . '/vendor/bin')) { + return $path . '/vendor/bin'; } } } diff --git a/src/Helper/Lang.php b/src/Helper/Lang.php index 63bd7d24..57964d85 100644 --- a/src/Helper/Lang.php +++ b/src/Helper/Lang.php @@ -101,7 +101,7 @@ class Lang { $languages = []; foreach (self::$languages as $language) { - $strings = include(SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.' . $language . '.php'); + $strings = include(SRC_DIR . 'Languages/lang.' . $language . '.php'); $languages[$language] = !empty($strings['language_name']) ? $strings['language_name'] . ' (' . $language . ')' : $language; @@ -169,7 +169,7 @@ class Lang ? $language : self::$language; - $langFile = SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.' . $language . '.php'; + $langFile = SRC_DIR . 'Languages/lang.' . $language . '.php'; if (!file_exists($langFile)) { return null; @@ -189,7 +189,7 @@ class Lang protected static function loadAvailableLanguages() { $matches = []; - foreach (glob(SRC_DIR . 'Languages' . DIRECTORY_SEPARATOR . 'lang.*.php') as $file) { + foreach (glob(SRC_DIR . 'Languages/lang.*.php') as $file) { if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) { self::$languages[] = $matches[1]; } diff --git a/src/Model/Build.php b/src/Model/Build.php index 6551668e..21e5dc95 100644 --- a/src/Model/Build.php +++ b/src/Model/Build.php @@ -790,7 +790,7 @@ class Build extends Model */ protected function getZeroConfigPlugins(Builder $builder) { - $pluginDir = SRC_DIR . 'Plugin' . DIRECTORY_SEPARATOR; + $pluginDir = SRC_DIR . 'Plugin/'; $dir = new \DirectoryIterator($pluginDir); $config = [ diff --git a/src/Plugin/Atoum.php b/src/Plugin/Atoum.php index f62424b4..cd6a7b30 100644 --- a/src/Plugin/Atoum.php +++ b/src/Plugin/Atoum.php @@ -47,7 +47,7 @@ class Atoum extends Plugin parent::__construct($builder, $build, $options); if (isset($options['executable'])) { - $this->executable = $this->builder->buildPath . DIRECTORY_SEPARATOR.$options['executable']; + $this->executable = $this->builder->buildPath . '/' . $options['executable']; } else { $this->executable = $this->findBinary('atoum'); } @@ -83,7 +83,7 @@ class Atoum extends Plugin } if ($this->directory !== null) { - $dirPath = $this->builder->buildPath . DIRECTORY_SEPARATOR . $this->directory; + $dirPath = $this->builder->buildPath . '/' . $this->directory; $cmd .= " -d '{$dirPath}'"; } diff --git a/src/Plugin/Composer.php b/src/Plugin/Composer.php index aa68f87f..093ca94c 100644 --- a/src/Plugin/Composer.php +++ b/src/Plugin/Composer.php @@ -46,7 +46,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface $this->ignorePlatformReqs = false; if (array_key_exists('directory', $options)) { - $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; + $this->directory = $path . '/' . $options['directory']; } if (array_key_exists('action', $options)) { @@ -80,7 +80,7 @@ class Composer extends Plugin implements ZeroConfigPluginInterface */ public static function canExecute($stage, Builder $builder, Build $build) { - $path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json'; + $path = $builder->buildPath . '/composer.json'; if (file_exists($path) && $stage == Build::STAGE_SETUP) { return true; diff --git a/src/Plugin/Grunt.php b/src/Plugin/Grunt.php index e5db5e24..cb6afb0e 100644 --- a/src/Plugin/Grunt.php +++ b/src/Plugin/Grunt.php @@ -8,7 +8,7 @@ use PHPCensor\Plugin; /** * Grunt Plugin - Provides access to grunt functionality. - * + * * @author Tobias Tom */ class Grunt extends Plugin @@ -26,14 +26,14 @@ class Grunt extends Plugin { return 'grunt'; } - + /** * {@inheritdoc} */ public function __construct(Builder $builder, Build $build, array $options = []) { parent::__construct($builder, $build, $options); - + $path = $this->builder->buildPath; $this->directory = $path; $this->task = null; @@ -42,7 +42,7 @@ class Grunt extends Plugin // Handle options: if (isset($options['directory'])) { - $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; + $this->directory = $path . '/' . $options['directory']; } if (isset($options['task'])) { diff --git a/src/Plugin/Gulp.php b/src/Plugin/Gulp.php index 6c28cea9..3d65433b 100644 --- a/src/Plugin/Gulp.php +++ b/src/Plugin/Gulp.php @@ -8,7 +8,7 @@ use PHPCensor\Plugin; /** * Gulp Plugin - Provides access to gulp functionality. - * + * * @author Dirk Heilig */ class Gulp extends Plugin @@ -26,14 +26,14 @@ class Gulp extends Plugin { return 'gulp'; } - + /** * {@inheritdoc} */ public function __construct(Builder $builder, Build $build, array $options = []) { parent::__construct($builder, $build, $options); - + $path = $this->builder->buildPath; $this->directory = $path; $this->task = null; @@ -42,7 +42,7 @@ class Gulp extends Plugin // Handle options: if (isset($options['directory'])) { - $this->directory = $path . DIRECTORY_SEPARATOR . $options['directory']; + $this->directory = $path . '/' . $options['directory']; } if (isset($options['task'])) { diff --git a/src/Plugin/Lint.php b/src/Plugin/Lint.php index 9ef07967..35623383 100644 --- a/src/Plugin/Lint.php +++ b/src/Plugin/Lint.php @@ -9,7 +9,7 @@ use PHPCensor\Plugin; /** * PHP Lint Plugin - Provides access to PHP lint functionality. - * + * * @author Dan Cryer */ class Lint extends Plugin @@ -83,7 +83,11 @@ class Lint extends Plugin if ($item->isFile() && $item->getExtension() == 'php' && !$this->lintFile($php, $itemPath)) { $success = false; - } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($php, $itemPath . DIRECTORY_SEPARATOR)) { + } elseif ( + $item->isDir() && + $this->recursive && + !$this->lintDirectory($php, ($itemPath . '/')) + ) { $success = false; } diff --git a/src/Plugin/Pdepend.php b/src/Plugin/Pdepend.php index 39445e47..c4ce4f5a 100644 --- a/src/Plugin/Pdepend.php +++ b/src/Plugin/Pdepend.php @@ -122,9 +122,9 @@ class Pdepend extends Plugin $success = $this->builder->executeCommand( $cmd, - $this->buildLocation . DIRECTORY_SEPARATOR . $this->summary, - $this->buildLocation . DIRECTORY_SEPARATOR . $this->chart, - $this->buildLocation . DIRECTORY_SEPARATOR . $this->pyramid, + $this->buildLocation . '/' . $this->summary, + $this->buildLocation . '/' . $this->chart, + $this->buildLocation . '/' . $this->pyramid, $ignore, $this->directory ); diff --git a/src/Plugin/Phar.php b/src/Plugin/Phar.php index b43b95ec..0b39d477 100644 --- a/src/Plugin/Phar.php +++ b/src/Plugin/Phar.php @@ -178,7 +178,7 @@ class Phar extends Plugin $content = ''; $filename = $this->getStub(); if ($filename) { - $content = file_get_contents($this->builder->buildPath . DIRECTORY_SEPARATOR . $this->getStub()); + $content = file_get_contents($this->builder->buildPath . '/' . $this->getStub()); } return $content; } @@ -192,7 +192,7 @@ class Phar extends Plugin $success = false; try { - $file = $this->getDirectory() . DIRECTORY_SEPARATOR . $this->getFilename(); + $file = $this->getDirectory() . '/' . $this->getFilename(); $phar = new PHPPhar($file, 0, $this->getFilename()); $phar->buildFromDirectory($this->builder->buildPath, $this->getRegExp()); diff --git a/src/Plugin/Phing.php b/src/Plugin/Phing.php index 5edda716..aac615d3 100644 --- a/src/Plugin/Phing.php +++ b/src/Plugin/Phing.php @@ -38,7 +38,7 @@ class Phing extends Plugin * Set working directory */ if (isset($options['directory'])) { - $directory = $this->builder->buildPath . DIRECTORY_SEPARATOR . $options['directory']; + $directory = $this->builder->buildPath . '/' . $options['directory']; } else { $directory = $this->builder->buildPath; } @@ -228,7 +228,7 @@ class Phing extends Plugin */ public function setPropertyFile($propertyFile) { - if (!file_exists($this->getDirectory() . DIRECTORY_SEPARATOR . $propertyFile)) { + if (!file_exists($this->getDirectory() . '/' . $propertyFile)) { throw new \Exception('Specified property file does not exist.'); } diff --git a/src/Plugin/PhpCpd.php b/src/Plugin/PhpCpd.php index 4094d164..e4189856 100644 --- a/src/Plugin/PhpCpd.php +++ b/src/Plugin/PhpCpd.php @@ -83,8 +83,8 @@ class PhpCpd extends Plugin implements ZeroConfigPluginInterface $namesExclude = ' --names-exclude '; foreach ($this->ignore as $item) { - $item = rtrim($item, DIRECTORY_SEPARATOR); - if (is_file(rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item)) { + $item = rtrim($item, '/'); + if (is_file(rtrim($this->path, '/') . '/' . $item)) { $ignoredFile = explode('/', $item); $filesToIgnore[] = array_pop($ignoredFile); } else { diff --git a/src/Plugin/PhpLoc.php b/src/Plugin/PhpLoc.php index 597514a8..6ff7898f 100644 --- a/src/Plugin/PhpLoc.php +++ b/src/Plugin/PhpLoc.php @@ -10,7 +10,7 @@ use PHPCensor\ZeroConfigPluginInterface; /** * PHP Loc - Allows PHP Copy / Lines of Code testing. - * + * * @author Johan van der Heide */ class PhpLoc extends Plugin implements ZeroConfigPluginInterface @@ -27,7 +27,7 @@ class PhpLoc extends Plugin implements ZeroConfigPluginInterface { return 'php_loc'; } - + /** * Check if this plugin can be executed. * @param $stage @@ -67,7 +67,7 @@ class PhpLoc extends Plugin implements ZeroConfigPluginInterface if (count($this->builder->ignore)) { $map = function ($item) { - return ' --exclude ' . rtrim($item, DIRECTORY_SEPARATOR); + return ' --exclude ' . rtrim($item, '/'); }; $ignore = array_map($map, $this->builder->ignore); diff --git a/src/Plugin/PhpTalLint.php b/src/Plugin/PhpTalLint.php index 1f2c784d..cc77b056 100644 --- a/src/Plugin/PhpTalLint.php +++ b/src/Plugin/PhpTalLint.php @@ -127,7 +127,7 @@ class PhpTalLint extends Plugin if (!$this->lintFile($itemPath)) { $success = false; } - } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($itemPath . DIRECTORY_SEPARATOR)) { + } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($itemPath . '/')) { $success = false; } @@ -174,10 +174,10 @@ class PhpTalLint extends Plugin list($suffixes, $tales) = $this->getFlags(); - $lint = __DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; - $lint .= 'vendor' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR; - $lint .= 'tools' . DIRECTORY_SEPARATOR . 'phptal_lint.php'; - $cmd = '/usr/bin/env php ' . $lint . ' %s %s "%s"'; + $lint = __DIR__ . '/'; + $lint .= 'vendor/phptal/phptal/'; + $lint .= 'tools/phptal_lint.php'; + $cmd = 'php ' . $lint . ' %s %s "%s"'; $this->builder->executeCommand($cmd, $suffixes, $tales, $this->builder->buildPath . $path); diff --git a/src/Plugin/SecurityChecker.php b/src/Plugin/SecurityChecker.php index ba665f87..9634531d 100644 --- a/src/Plugin/SecurityChecker.php +++ b/src/Plugin/SecurityChecker.php @@ -59,7 +59,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface */ public static function canExecute($stage, Builder $builder, Build $build) { - $path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.lock'; + $path = $builder->buildPath . '/composer.lock'; if (file_exists($path) && $stage == Build::STAGE_TEST) { return true; @@ -72,7 +72,7 @@ class SecurityChecker extends Plugin implements ZeroConfigPluginInterface { $success = true; $checker = new BaseSecurityChecker(); - $warnings = $checker->check($this->builder->buildPath . DIRECTORY_SEPARATOR . 'composer.lock'); + $warnings = $checker->check($this->builder->buildPath . '/composer.lock'); if ($warnings) { foreach ($warnings as $library => $warning) { diff --git a/src/Plugin/Xmpp.php b/src/Plugin/Xmpp.php index 4c6aa8cd..8d6c62b0 100644 --- a/src/Plugin/Xmpp.php +++ b/src/Plugin/Xmpp.php @@ -111,8 +111,8 @@ class XMPP extends Plugin */ public function findConfigFile() { - if (file_exists($this->builder->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) { - if (md5(file_get_contents($this->builder->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) + if (file_exists($this->builder->buildPath . '/.sendxmpprc')) { + if (md5(file_get_contents($this->builder->buildPath . '/.sendxmpprc')) !== md5($this->getConfigFormat())) { return null; } @@ -140,7 +140,7 @@ class XMPP extends Plugin /* * Try to build conf file */ - $config_file = $this->builder->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc'; + $config_file = $this->builder->buildPath . '/.sendxmpprc'; if (is_null($this->findConfigFile())) { file_put_contents($config_file, $this->getConfigFormat()); chmod($config_file, 0600); @@ -154,7 +154,7 @@ class XMPP extends Plugin $tls = ' -t'; } - $message_file = $this->builder->buildPath . DIRECTORY_SEPARATOR . uniqid('xmppmessage'); + $message_file = $this->builder->buildPath . '/' . uniqid('xmppmessage'); if ($this->buildMessage($message_file) === false) { return false; }