Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move pdo tasks and path-as-package task to system scope #1521

Merged
merged 5 commits into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions etc/default.tasks.properties
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ propertyselector=Phing\Task\System\Property\PropertySelector
urlencode=Phing\Task\System\Property\URLEncodeTask
var=Phing\Task\System\Property\Variable
sortlist=Phing\Task\System\Property\SortList
pdo=Phing\Task\System\Pdo\PDOSQLExecTask
pdosqlexec=Phing\Task\System\Pdo\PDOSQLExecTask
pharpackage=Phing\Task\System\PharPackageTask
phardata=Phing\Task\System\PharDataTask
xmlproperty=Phing\Task\System\XmlPropertyTask
package-as-path=Phing\Task\System\PackageAsPathTask

; "ext" tasks
pdo=phing.tasks.ext.pdo.PDOSQLExecTask
pdosqlexec=phing.tasks.ext.pdo.PDOSQLExecTask
package-as-path=phing.tasks.ext.PackageAsPathTask
mail=phing.tasks.ext.MailTask
phpunit=phing.tasks.ext.phpunit.PHPUnitTask
phpunitreport=phing.tasks.ext.phpunit.PHPUnitReportTask
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Task/System/Condition/ConditionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Phing\Task\System\Condition;

use IteratorAggregate;
use PDOSQLExecTask;
use Phing\Task\System\Pdo\PDOSQLExecTask;
use Phing\Exception\BuildException;
use Phing\Parser\CustomChildCreator;
use Phing\Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* <http://phing.info>.
*/

namespace Phing\Task\System;

use Phing\Task;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @package phing.tasks.ext.pdo
*/

namespace Phing\Task\System\Pdo;

use Phing\Io\Reader;
use Phing\Util\StringHelper;

Expand Down Expand Up @@ -90,7 +92,7 @@ public function nextQuery()

if (
strlen($line) > 4
&& strtoupper(substr($line, 0, 4)) == "REM "
&& strtoupper(substr($line, 0, 4)) === "REM "
) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @package phing.tasks.ext.pdo
*/

namespace Phing\Task\System\Pdo;

use Phing\Util\StringHelper;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @package phing.tasks.ext.pdo
*/

namespace Phing\Task\System\Pdo;

use Phing\Io\BufferedReader;
use Phing\Io\Reader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use Phing\Io\Writer;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use Phing\Exception\BuildException;
use Phing\Io\FileWriter;
use Phing\Io\LogWriter;
Expand Down Expand Up @@ -222,9 +224,9 @@ public function prepare(Location $location)
public function setType($type)
{
$this->type = $type;
if ($this->type == "xml") {
if ($this->type === "xml") {
$this->formatter = new XMLPDOResultFormatter();
} elseif ($this->type == "plain") {
} elseif ($this->type === "plain") {
$this->formatter = new PlainPDOResultFormatter();
} else {
throw new BuildException("Formatter '" . $this->type . "' not implemented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use Exception;
use PDO;
use PDOException;
use PDOStatement;
use Phing\Exception\BuildException;
use Phing\Io\IOException;
use Phing\Io\LogWriter;
Expand Down Expand Up @@ -420,7 +426,7 @@ public function main()
throw $e;
}
} catch (IOException $e) {
if (!$this->isAutocommit() && $this->conn !== null && $this->onError == "abort") {
if (!$this->isAutocommit() && $this->conn !== null && $this->onError === "abort") {
try {
$this->conn->rollback();
} catch (PDOException $ex) {
Expand All @@ -429,7 +435,7 @@ public function main()
$this->closeConnection();
throw new BuildException($e->getMessage(), $this->getLocation());
} catch (PDOException $e) {
if (!$this->isAutocommit() && $this->conn !== null && $this->onError == "abort") {
if (!$this->isAutocommit() && $this->conn !== null && $this->onError === "abort") {
try {
$this->conn->rollback();
} catch (PDOException $ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use Phing\Io\FileReader;
use Phing\Io\IOException;
use Phing\Io\File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use Exception;
use PDO;
use PDOException;
use Phing\Exception\BuildException;
use Phing\Project;
use Phing\Task;
Expand Down Expand Up @@ -116,7 +121,8 @@ public function setAutocommit($autocommit)
* The calling method is responsible for closing the connection.
*
* @return PDO the newly created connection.
* @throws BuildException if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load.
* @throws BuildException if the UserId/Password/Url is not set or there is no suitable driver
* or the driver fails to load.
*/
protected function getConnection()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @package phing.tasks.ext.pdo
*/

namespace Phing\Task\System\Pdo;

/**
* Splits PostgreSQL's dialect of SQL into separate queries
*
Expand Down Expand Up @@ -125,12 +127,12 @@ public function ungetc()
protected function checkDollarQuote()
{
$ch = $this->getc();
if ('$' == $ch) {
if ('$' === $ch) {
// empty tag
return '';
}

if (!ctype_alpha($ch) && '_' != $ch) {
if (!ctype_alpha($ch) && '_' !== $ch) {
// not a delimiter
$this->ungetc();

Expand All @@ -139,11 +141,11 @@ protected function checkDollarQuote()

$tag = $ch;
while (false !== ($ch = $this->getc())) {
if ('$' == $ch) {
if ('$' === $ch) {
return $tag;
}

if (ctype_alnum($ch) || '_' == $ch) {
if (ctype_alnum($ch) || '_' === $ch) {
$tag .= $ch;
} else {
for ($i = 0, $tagLength = strlen($tag); $i < $tagLength; $i++) {
Expand Down Expand Up @@ -182,7 +184,7 @@ public function nextQuery()
$this->state = self::STATE_SINGLE_QUOTED;
break;
case '/':
if ('*' == $this->getc()) {
if ('*' === $this->getc()) {
$this->state = self::STATE_COMMENT_MULTILINE;
$this->commentDepth = 1;
} else {
Expand All @@ -207,7 +209,7 @@ public function nextQuery()
case $delimiter[0]:
// special case to allow "create rule" statements
// http://www.postgresql.org/docs/current/interactive/sql-createrule.html
if (';' == $delimiter && 0 < $openParens) {
if (';' === $delimiter && 0 < $openParens) {
break;
}
$hasQuery = true;
Expand All @@ -227,7 +229,7 @@ public function nextQuery()
break;

case self::STATE_COMMENT_LINEEND:
if ("\n" == $ch) {
if ("\n" === $ch) {
$this->state = self::STATE_NORMAL;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use Phing\Io\File;
use Phing\Util\StringHelper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* <http://phing.info>.
*/

namespace Phing\Task\System\Pdo;

use DOMDocument;
use DOMElement;
use Phing\Io\File;

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Phing/Task/Optional/PDODelimitersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace Phing\Task\Optional;

use PDOSQLExecTask;
use Phing\Task\System\Pdo\PDOSQLExecTask;
use Phing\Io\File;
use Phing\Support\BuildFileTest;

Expand All @@ -38,7 +38,7 @@ public function setUp(): void
$this->configureProject(PHING_TEST_BASE . "/etc/tasks/ext/pdo/empty.xml");
$this->queries = [];

$this->mockTask = $this->getMockBuilder('PDOSQLExecTask')
$this->mockTask = $this->getMockBuilder(PDOSQLExecTask::class)
->setMethods(['getConnection', 'execSQL'])
->getMock();
$this->mockTask->setProject($this->project);
Expand Down