Skip to content

Commit

Permalink
Fixed PSR12 related errors by phpcbf (#1152)
Browse files Browse the repository at this point in the history
* Fixed PSR12 related errors
  • Loading branch information
siad007 committed Oct 6, 2019
1 parent 20b0ec2 commit 0fa80a3
Show file tree
Hide file tree
Showing 42 changed files with 207 additions and 125 deletions.
8 changes: 6 additions & 2 deletions classes/phing/IntrospectionHelper.php
Expand Up @@ -137,8 +137,12 @@ public function __construct($class)
// but should actually just be skipped. (Note: this means you can't ever
// have an attribute named "location" or "tasktype" or a nested element container
// named "task" [TaskContainer::addTask(Task)].)
if ($name === "setlocation" || $name === "settasktype"
|| ('addtask' === $name && $this->isContainer() && count($method->getParameters()) === 1
if (
$name === "setlocation"
|| $name === "settasktype"
|| ('addtask' === $name
&& $this->isContainer()
&& count($method->getParameters()) === 1
&& Task::class === $method->getParameters()[0])
) {
continue;
Expand Down
18 changes: 11 additions & 7 deletions classes/phing/Phing.php
Expand Up @@ -414,17 +414,20 @@ public function execute($args)
// 2) Next pull out stand-alone args.
// Note: The order in which these are executed is important (if multiple of these options are specified)

if (false !== ($key = array_search('-quiet', $args, true)) || false !== ($key = array_search(
'-q',
$args,
true
))
if (
false !== ($key = array_search('-quiet', $args, true)) ||
false !== ($key = array_search(
'-q',
$args,
true
))
) {
self::$msgOutputLevel = Project::MSG_WARN;
unset($args[$key]);
}

if (false !== ($key = array_search('-emacs', $args, true))
if (
false !== ($key = array_search('-emacs', $args, true))
|| false !== ($key = array_search('-e', $args, true))
) {
$this->emacsMode = true;
Expand All @@ -441,7 +444,8 @@ public function execute($args)
unset($args[$key]);
}

if (false !== ($key = array_search('-silent', $args, true))
if (
false !== ($key = array_search('-silent', $args, true))
|| false !== ($key = array_search('-S', $args, true))
) {
$this->silent = true;
Expand Down
3 changes: 2 additions & 1 deletion classes/phing/listener/DefaultLogger.php
Expand Up @@ -224,7 +224,8 @@ protected function getBuildSuccessfulMessage()
*/
public function targetStarted(BuildEvent $event)
{
if (Project::MSG_INFO <= $this->msgOutputLevel
if (
Project::MSG_INFO <= $this->msgOutputLevel
&& $event->getTarget()->getName() != ''
) {
$showLongTargets = $event->getProject()->getProperty("phing.showlongtargets");
Expand Down
4 changes: 3 additions & 1 deletion classes/phing/listener/NoBannerLogger.php
Expand Up @@ -50,7 +50,9 @@ public function targetFinished(BuildEvent $event)
*/
public function messageLogged(BuildEvent $event)
{
if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage()
if (
$event->getPriority() > $this->msgOutputLevel
|| null === $event->getMessage()
|| trim($event->getMessage()) === ''
) {
return;
Expand Down
6 changes: 4 additions & 2 deletions classes/phing/mappers/GlobMapper.php
Expand Up @@ -112,9 +112,11 @@ public function setCaseSensitive($caseSensitive)
public function main($sourceFileName)
{
$modName = $this->modifyName($sourceFileName);
if ($this->fromPrefix === null
if (
$this->fromPrefix === null
|| (strlen($sourceFileName) < ($this->prefixLength + $this->postfixLength)
|| (!$this->fromContainsStar && !$modName === $this->modifyName($this->fromPrefix)))
|| (!$this->fromContainsStar
&& !$modName === $this->modifyName($this->fromPrefix)))
|| ($this->fromContainsStar
&& (!StringHelper::startsWith($this->modifyName($this->fromPrefix), $modName)
|| !StringHelper::endsWith($this->modifyName($this->fromPostfix), $modName)))
Expand Down
2 changes: 1 addition & 1 deletion classes/phing/parser/PhingXMLContext.php
Expand Up @@ -171,4 +171,4 @@ public function setCurrentTargets(array $currentTargets)
{
$this->currentTargets = $currentTargets;
}
} //end PhingXMLContext
}
3 changes: 2 additions & 1 deletion classes/phing/parser/TargetHandler.php
Expand Up @@ -166,7 +166,8 @@ public function init($tag, $attrs)
// check to see if target with same name is already defined
$projectTargets = $project->getTargets();
if (isset($projectTargets[$name])) {
if ($this->configurator->isIgnoringProjectTag()
if (
$this->configurator->isIgnoringProjectTag()
&& $this->configurator->getCurrentProjectName() != null
&& strlen($this->configurator->getCurrentProjectName()) != 0
) {
Expand Down
6 changes: 4 additions & 2 deletions classes/phing/system/io/WindowsFileSystem.php
Expand Up @@ -113,7 +113,8 @@ public function normalizePrefix($strPath, $len, &$sb)
$src++;
}
$c = "";
if (($len - $src >= 2)
if (
($len - $src >= 2)
&& $this->isLetter($c = $strPath[$src])
&& $strPath[$src + 1] === ':'
) {
Expand All @@ -126,7 +127,8 @@ public function normalizePrefix($strPath, $len, &$sb)
$src += 2;
} else {
$src = 0;
if (($len >= 2)
if (
($len >= 2)
&& $this->isSlash($strPath[0])
&& $this->isSlash($strPath[1])
) {
Expand Down
3 changes: 2 additions & 1 deletion classes/phing/tasks/ext/ExtractBaseTask.php
Expand Up @@ -171,7 +171,8 @@ protected function isDestinationUpToDate(PhingFile $compressedArchiveFile)
}
$compressArchivePath = new PhingFile($this->todir, $compressArchiveFilename);

if (!$compressArchivePath->exists()
if (
!$compressArchivePath->exists()
|| $fileSystem->compareMTimes(
$compressedArchiveFile->getCanonicalPath(),
$compressArchivePath->getCanonicalPath()
Expand Down
6 changes: 4 additions & 2 deletions classes/phing/tasks/ext/FileHashTask.php
Expand Up @@ -142,7 +142,8 @@ public function main()
private function checkFile()
{
// check File
if ($this->file === null
if (
$this->file === null
|| strlen($this->file) == 0
) {
throw new BuildException('[FileHash] You must specify an input file.', $this->file);
Expand All @@ -166,7 +167,8 @@ private function checkFile()
*/
private function checkPropertyName()
{
if (null === $this->propertyName
if (
null === $this->propertyName
|| strlen($this->propertyName) === 0
) {
throw new BuildException('Property name for publishing hashvalue is not set');
Expand Down
6 changes: 4 additions & 2 deletions classes/phing/tasks/ext/FileSizeTask.php
Expand Up @@ -93,7 +93,8 @@ public function main()
private function checkFile()
{
// check File
if ($this->file === null
if (
$this->file === null
|| strlen($this->file) == 0
) {
throw new BuildException('[FileSize] You must specify an input file.', $this->file);
Expand All @@ -117,7 +118,8 @@ private function checkFile()
*/
private function checkPropertyName()
{
if (null === $this->propertyName
if (
null === $this->propertyName
|| strlen($this->propertyName) === 0
) {
throw new BuildException('[FileSize] Property name for publishing file size is not set');
Expand Down
4 changes: 3 additions & 1 deletion classes/phing/tasks/ext/HttpGetTask.php
Expand Up @@ -115,7 +115,9 @@ protected function processResponse(HTTP_Request2_Response $response)

if ($this->filename) {
$filename = $this->filename;
} elseif ($disposition && 0 == strpos($disposition, 'attachment')
} elseif (
$disposition
&& 0 == strpos($disposition, 'attachment')
&& preg_match('/filename="([^"]+)"/', $disposition, $m)
) {
$filename = basename($m[1]);
Expand Down
5 changes: 2 additions & 3 deletions classes/phing/tasks/ext/PhpCodeSnifferTask.php
Expand Up @@ -17,7 +17,6 @@
* <http://phing.info>.
*/


/**
* A PHP code sniffer task. Checking the style of one or more PHP source files.
*
Expand All @@ -33,7 +32,7 @@ class PhpCodeSnifferTask extends Task
*
* @var PhingFile
*/
protected $file; // the source file (from xml attribute)
protected $file;

// parameters for php code sniffer
protected $standards = ['Generic'];
Expand Down Expand Up @@ -724,4 +723,4 @@ protected function outputCustomFormatMessages($messages, $type)
}
}
}
} //end phpCodeSnifferTask //end FormatterElement
}
8 changes: 4 additions & 4 deletions classes/phing/tasks/ext/PhpLintTask.php
Expand Up @@ -235,10 +235,10 @@ protected function lint($file)
continue;
}

if ((!preg_match('/^(.*)Deprecated:/', $message) || $this->deprecatedAsError) && !preg_match(
'/^No syntax errors detected/',
$message
)
if (
(!preg_match('/^(.*)Deprecated:/', $message) ||
$this->deprecatedAsError) &&
!preg_match('/^No syntax errors detected/', $message)
) {
$this->log($message, Project::MSG_ERR);

Expand Down
7 changes: 5 additions & 2 deletions classes/phing/tasks/ext/RSTTask.php
Expand Up @@ -236,7 +236,9 @@ protected function render($tool, $source, $targetFile)
*/
protected function renderFile($tool, $source, $targetFile)
{
if ($this->uptodate && file_exists($targetFile)
if (
$this->uptodate
&& file_exists($targetFile)
&& filemtime($source) <= filemtime($targetFile)
) {
//target is up to date
Expand Down Expand Up @@ -307,7 +309,8 @@ protected function getToolPath($format)
*/
public function getTargetFile($file, $destination = null)
{
if ($destination != ''
if (
$destination != ''
&& substr($destination, -1) !== '/'
&& substr($destination, -1) !== '\\'
) {
Expand Down
12 changes: 8 additions & 4 deletions classes/phing/tasks/ext/coverage/CoverageThresholdTask.php
Expand Up @@ -196,7 +196,8 @@ protected function calculateCoverageThreshold($filename, $coverageInformation)

// Strange PHP5 reflection bug, classes without parent class
// or implemented interfaces seem to start one line off
if ($reflection->getParentClass() === null
if (
$reflection->getParentClass() === null
&& count($reflection->getInterfaces()) === 0
) {
unset($coverageInformation[$classStartLine + 1]);
Expand All @@ -220,7 +221,8 @@ protected function calculateCoverageThreshold($filename, $coverageInformation)
$excludedMethods = $this->excludes->getExcludedMethods();

if (isset($excludedMethods[$className])) {
if (in_array($method->getName(), $excludedMethods[$className])
if (
in_array($method->getName(), $excludedMethods[$className])
|| in_array($method->getName() . '()', $excludedMethods[$className])
) {
continue;
Expand Down Expand Up @@ -284,7 +286,8 @@ protected function calculateCoverageThreshold($filename, $coverageInformation)
);
}

if ($methodCoverage < $this->perMethod
if (
$methodCoverage < $this->perMethod
&& $method->isAbstract()
&& $this->verbose === true
) {
Expand Down Expand Up @@ -328,7 +331,8 @@ protected function calculateCoverageThreshold($filename, $coverageInformation)
);
}

if ($classCoverage < $this->perClass
if (
$classCoverage < $this->perClass
&& $reflection->isAbstract()
&& $this->verbose === true
) {
Expand Down
3 changes: 2 additions & 1 deletion classes/phing/tasks/ext/hg/HgAddTask.php
Expand Up @@ -143,7 +143,8 @@ public function fileIsIgnored($file)
$line = $this->ignoreFile[0];
$mode = 'regexp';
$ignored = false;
if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)
if (
preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)
|| $matches[1] === 'glob'
) {
$mode = 'glob';
Expand Down
3 changes: 2 additions & 1 deletion classes/phing/tasks/ext/inifile/IniFileConfig.php
Expand Up @@ -156,7 +156,8 @@ public function remove($section, $key)
}
} else {
foreach ($this->lines as $linenum => $line) {
if (($line['section'] == $section)
if (
($line['section'] == $section)
&& (isset($line['key']))
&& ($line['key'] == $key)
) {
Expand Down
7 changes: 5 additions & 2 deletions classes/phing/tasks/ext/pdo/DefaultPDOQuerySplitter.php
Expand Up @@ -76,14 +76,17 @@ public function nextQuery()
$project = $this->parent->getOwningTarget()->getProject();
$line = $project->replaceProperties(trim($line));

if (($line != $delimiter) && (StringHelper::startsWith("//", $line)
if (
($line != $delimiter)
&& (StringHelper::startsWith("//", $line)
|| StringHelper::startsWith("--", $line)
|| StringHelper::startsWith("#", $line))
) {
continue;
}

if (strlen($line) > 4
if (
strlen($line) > 4
&& strtoupper(substr($line, 0, 4)) == "REM "
) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion classes/phing/tasks/ext/pdo/DummyPDOQuerySplitter.php
Expand Up @@ -42,7 +42,9 @@ public function nextQuery()
$project = $this->parent->getOwningTarget()->getProject();
$line = $project->replaceProperties(trim($line));

if (($line != $delimiter) && (StringHelper::startsWith("//", $line)
if (
($line != $delimiter)
&& (StringHelper::startsWith("//", $line)
|| StringHelper::startsWith("--", $line)
|| StringHelper::startsWith("#", $line))
) {
Expand Down
7 changes: 5 additions & 2 deletions classes/phing/tasks/ext/pdo/PDOSQLExecTask.php
Expand Up @@ -335,8 +335,11 @@ public function main()
$this->sqlCommand = trim($this->sqlCommand);

try {
if ($this->srcFile === null && $this->sqlCommand === ""
&& empty($this->filesets) && empty($this->filelists)
if (
$this->srcFile === null
&& $this->sqlCommand === ""
&& empty($this->filesets)
&& empty($this->filelists)
&& count($this->transactions) === 0
) {
throw new BuildException(
Expand Down
10 changes: 7 additions & 3 deletions classes/phing/tasks/ext/phpcpd/PHPCPDTask.php
@@ -1,4 +1,8 @@
<?php

use SebastianBergmann\PHPCPD\Detector\Strategy\DefaultStrategy;
use Composer\Autoload\ClassLoader;

/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Expand Down Expand Up @@ -225,9 +229,9 @@ public function run() {}
}
}

if (class_exists('Composer\\Autoload\\ClassLoader', false) && class_exists(
'\\SebastianBergmann\\PHPCPD\\Detector\\Strategy\\DefaultStrategy'
)
if (
class_exists(ClassLoader::class, false) &&
class_exists(DefaultStrategy::class)
) {
return;
}
Expand Down
@@ -1,4 +1,5 @@
<?php

/**
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Expand Down

0 comments on commit 0fa80a3

Please sign in to comment.