Skip to content

Commit

Permalink
SCA with Php Inspections (EA Extended): bug-fixes, language level mig…
Browse files Browse the repository at this point in the history
…ration, suspicious assignments (#731)
  • Loading branch information
kalessil authored and mrook committed Jun 19, 2017
1 parent a1f01e3 commit 3f494f2
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 37 deletions.
6 changes: 3 additions & 3 deletions classes/phing/filters/TranslateGettext.php
Expand Up @@ -234,12 +234,12 @@ public function read($len = null)
// also match gettext() -- same as above

$buffer = preg_replace_callback(
'/([^\w]|^)_\("((\\\"|[^"])*)"\)/',
'/(\W|^)_\("((\\\"|[^"])*)"\)/',
[$this, 'xlateStringCallback'],
$buffer
);
$buffer = preg_replace_callback(
'/([^\w]|^)gettext\("((\\\"|[^"])*)"\)/',
'/(\W|^)gettext\("((\\\"|[^"])*)"\)/',
[$this, 'xlateStringCallback'],
$buffer
);
Expand All @@ -249,7 +249,7 @@ public function read($len = null)
// Check to see if there are any unmatched gettext() calls -- and flag an error

$matches = [];
if (preg_match('/([^\w]|^)(gettext\([^\)]+\))/', $buffer, $matches)) {
if (preg_match('/(\W|^)(gettext\([^\)]+\))/', $buffer, $matches)) {
$this->log("Unable to perform translation on: " . $matches[2], Project::MSG_WARN);
}

Expand Down
5 changes: 2 additions & 3 deletions classes/phing/listener/NoBannerLogger.php
Expand Up @@ -55,9 +55,8 @@ public function targetFinished(BuildEvent $event)
*/
public function messageLogged(BuildEvent $event)
{
if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() || trim(
$event->getMessage() === ""
)
if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() ||
trim($event->getMessage()) === ''
) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/phing/tasks/ext/ComposerTask.php
Expand Up @@ -149,7 +149,7 @@ private function prepareCommandLine()
//We are un-shifting arguments to the beginning of the command line because arguments should be at the end
$this->commandLine->createArgument(true)->setValue($this->getCommand());
$this->commandLine->createArgument(true)->setValue($this->getComposer());
$commandLine = strval($this->commandLine);
$commandLine = (string)$this->commandLine;
//Creating new Commandline instance. It allows to handle subsequent calls correctly
$this->commandLine = new Commandline();

Expand Down
2 changes: 1 addition & 1 deletion classes/phing/tasks/ext/coverage/CoverageSetupTask.php
Expand Up @@ -113,7 +113,7 @@ private function getFilenames()
try {
$list = $fl->getFiles($this->project);
foreach ($list as $file) {
$fs = new PhingFile(strval($fl->getDir($this->project)), $file);
$fs = new PhingFile((string)$fl->getDir($this->project), $file);
$files[] = ['key' => strtolower($fs->getAbsolutePath()), 'fullname' => $fs->getAbsolutePath()];
}
} catch (BuildException $be) {
Expand Down
2 changes: 1 addition & 1 deletion classes/phing/tasks/ext/dbdeploy/DbDeployTask.php
Expand Up @@ -310,7 +310,7 @@ protected function getDeltasFilesArray()
$fileChangeNumberPrefix = '';
while (($file = readdir($dh)) !== false) {
if (preg_match('[\d+]', $file, $fileChangeNumberPrefix)) {
$files[intval($fileChangeNumberPrefix[0])] = $file;
$files[(int)$fileChangeNumberPrefix[0]] = $file;
}
}

Expand Down
2 changes: 1 addition & 1 deletion classes/phing/tasks/ext/inifile/IniFileTask.php
Expand Up @@ -26,7 +26,7 @@
* @license LGPL (see http://www.gnu.org/licenses/lgpl.html)
* @link InifileTask.php
*/
class InifileTask extends Task
class IniFileTask extends Task
{
/**
* Source file
Expand Down
7 changes: 1 addition & 6 deletions classes/phing/tasks/ext/liquibase/LiquibaseRollbackTask.php
Expand Up @@ -48,12 +48,7 @@ protected function checkParams()
parent::checkParams();

if (null === $this->rollbackTag) {
throw new BuildException(
sprintf(
'Please specify the tag to rollback to!',
$this->rollbackTag
)
);
throw new BuildException('Please specify the tag to rollback to!');
}
}

Expand Down
7 changes: 1 addition & 6 deletions classes/phing/tasks/ext/liquibase/LiquibaseTagTask.php
Expand Up @@ -51,12 +51,7 @@ protected function checkParams()
parent::checkParams();

if (null === $this->tag) {
throw new BuildException(
sprintf(
'Please specify the tag!',
$this->tag
)
);
throw new BuildException('Please specify the tag!');
}
}

Expand Down
1 change: 0 additions & 1 deletion classes/phing/tasks/ext/property/PropertySelector.php
Expand Up @@ -88,7 +88,6 @@ public function main()
for ($i = 0; $i < $sz; $i++) {
$s = $groups[$i];

$result = null;
$result = new RegularExpression();
$result->setPattern("\\\\" . $i);
$sregex = $result->getRegexp($this->project);
Expand Down
4 changes: 0 additions & 4 deletions classes/phing/tasks/system/ApplyTask.php
Expand Up @@ -829,10 +829,6 @@ private function cleanup()
*/
public function getFilePath($filename, $basedir, $relative)
{

// Var(s)
$files = [];

// Validating the 'file' information
$files = (is_array($filename)) ? $filename : [$filename];

Expand Down
4 changes: 1 addition & 3 deletions classes/phing/tasks/system/AttribTask.php
Expand Up @@ -195,9 +195,7 @@ public function setParallel($parallel)

protected function validateOS()
{
return $this->os === null && $this->osvariant === null
? $this->os === null && $this->osvariant === null
: parent::validateOS();
return $this->os === null && $this->osvariant === null ?: parent::validateOS();
}

private static function getSignString($attr)
Expand Down
1 change: 0 additions & 1 deletion classes/phing/types/AbstractFileSet.php
Expand Up @@ -104,7 +104,6 @@ public function __construct($fileset = null)
{
if ($fileset !== null && ($fileset instanceof FileSet)) {
$this->dir = $fileset->dir;
$this->defaultPatterns = $fileset->defaultPatterns;
$this->additionalPatterns = $fileset->additionalPatterns;
$this->useDefaultExcludes = $fileset->useDefaultExcludes;
$this->isCaseSensitive = $fileset->isCaseSensitive;
Expand Down
2 changes: 0 additions & 2 deletions classes/phing/util/DirectoryScanner.php
Expand Up @@ -333,7 +333,6 @@ public function setIncludes($_includes = [])
$this->includes = null;
} else {
for ($i = 0; $i < count($_includes); $i++) {
$pattern = null;
$pattern = str_replace('\\', DIRECTORY_SEPARATOR, $_includes[$i]);
$pattern = str_replace('/', DIRECTORY_SEPARATOR, $pattern);
if (StringHelper::endsWith(DIRECTORY_SEPARATOR, $pattern)) {
Expand All @@ -359,7 +358,6 @@ public function setExcludes($_excludes = [])
$this->excludes = null;
} else {
for ($i = 0; $i < count($_excludes); $i++) {
$pattern = null;
$pattern = str_replace('\\', DIRECTORY_SEPARATOR, $_excludes[$i]);
$pattern = str_replace('/', DIRECTORY_SEPARATOR, $pattern);
if (StringHelper::endsWith(DIRECTORY_SEPARATOR, $pattern)) {
Expand Down
6 changes: 2 additions & 4 deletions classes/phing/util/SourceFileScanner.php
Expand Up @@ -120,7 +120,7 @@ public function restrict(&$files, $srcDir, $destDir, $mapper, $force = false)

if (!$dest->exists()) {
$this->task->log(
($files[$i] ? $files[$i] : ".") . " added as " . $dest->__toString() . " doesn't exist.",
($files[$i] ?: ".") . " added as " . $dest->__toString() . " doesn't exist.",
Project::MSG_VERBOSE
);
$v[] = $files[$i];
Expand Down Expand Up @@ -156,10 +156,8 @@ public function restrict(&$files, $srcDir, $destDir, $mapper, $force = false)
);
}
}
$result = [];
$result = $v;

return $result;
return $v;
}

/**
Expand Down

0 comments on commit 3f494f2

Please sign in to comment.