From 374f18f4d6e24eb1e3003b73e080fcd54c9e93de Mon Sep 17 00:00:00 2001 From: siad007 Date: Sun, 31 Jan 2021 02:01:41 +0100 Subject: [PATCH 1/5] Moved PDO related tasks to system tasks. --- etc/default.tasks.properties | 4 ++-- .../Task/System/Pdo}/DefaultPDOQuerySplitter.php | 4 +++- .../Task/System/Pdo}/DummyPDOQuerySplitter.php | 2 ++ .../Phing/Task/System/Pdo}/PDOQuerySplitter.php | 2 ++ .../Task/System/Pdo}/PDOResultFormatter.php | 2 ++ .../System/Pdo}/PDOSQLExecFormatterElement.php | 6 ++++-- .../Phing/Task/System/Pdo}/PDOSQLExecTask.php | 10 ++++++++-- .../Task/System/Pdo}/PDOSQLExecTransaction.php | 2 ++ .../Phing/Task/System/Pdo}/PDOTask.php | 8 +++++++- .../Task/System/Pdo}/PgsqlPDOQuerySplitter.php | 16 +++++++++------- .../Task/System/Pdo}/PlainPDOResultFormatter.php | 2 ++ .../Task/System/Pdo}/XMLPDOResultFormatter.php | 4 ++++ 12 files changed, 47 insertions(+), 15 deletions(-) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/DefaultPDOQuerySplitter.php (98%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/DummyPDOQuerySplitter.php (98%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PDOQuerySplitter.php (98%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PDOResultFormatter.php (98%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PDOSQLExecFormatterElement.php (98%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PDOSQLExecTask.php (99%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PDOSQLExecTransaction.php (98%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PDOTask.php (96%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PgsqlPDOQuerySplitter.php (96%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/PlainPDOResultFormatter.php (99%) rename {classes/phing/tasks/ext/pdo => src/Phing/Task/System/Pdo}/XMLPDOResultFormatter.php (98%) diff --git a/etc/default.tasks.properties b/etc/default.tasks.properties index 8f13a8492e..b6b4a53225 100644 --- a/etc/default.tasks.properties +++ b/etc/default.tasks.properties @@ -81,13 +81,13 @@ 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 ; "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 diff --git a/classes/phing/tasks/ext/pdo/DefaultPDOQuerySplitter.php b/src/Phing/Task/System/Pdo/DefaultPDOQuerySplitter.php similarity index 98% rename from classes/phing/tasks/ext/pdo/DefaultPDOQuerySplitter.php rename to src/Phing/Task/System/Pdo/DefaultPDOQuerySplitter.php index d7031a7ffe..4e3ae02450 100644 --- a/classes/phing/tasks/ext/pdo/DefaultPDOQuerySplitter.php +++ b/src/Phing/Task/System/Pdo/DefaultPDOQuerySplitter.php @@ -19,6 +19,8 @@ * @package phing.tasks.ext.pdo */ +namespace Phing\Task\System\Pdo; + use Phing\Io\Reader; use Phing\Util\StringHelper; @@ -90,7 +92,7 @@ public function nextQuery() if ( strlen($line) > 4 - && strtoupper(substr($line, 0, 4)) == "REM " + && strtoupper(substr($line, 0, 4)) === "REM " ) { continue; } diff --git a/classes/phing/tasks/ext/pdo/DummyPDOQuerySplitter.php b/src/Phing/Task/System/Pdo/DummyPDOQuerySplitter.php similarity index 98% rename from classes/phing/tasks/ext/pdo/DummyPDOQuerySplitter.php rename to src/Phing/Task/System/Pdo/DummyPDOQuerySplitter.php index 32a2dfb0bb..cb03ecbe1b 100644 --- a/classes/phing/tasks/ext/pdo/DummyPDOQuerySplitter.php +++ b/src/Phing/Task/System/Pdo/DummyPDOQuerySplitter.php @@ -19,6 +19,8 @@ * @package phing.tasks.ext.pdo */ +namespace Phing\Task\System\Pdo; + use Phing\Util\StringHelper; /** diff --git a/classes/phing/tasks/ext/pdo/PDOQuerySplitter.php b/src/Phing/Task/System/Pdo/PDOQuerySplitter.php similarity index 98% rename from classes/phing/tasks/ext/pdo/PDOQuerySplitter.php rename to src/Phing/Task/System/Pdo/PDOQuerySplitter.php index 9fe7e7ad9e..05ed0cf9fc 100644 --- a/classes/phing/tasks/ext/pdo/PDOQuerySplitter.php +++ b/src/Phing/Task/System/Pdo/PDOQuerySplitter.php @@ -19,6 +19,8 @@ * @package phing.tasks.ext.pdo */ +namespace Phing\Task\System\Pdo; + use Phing\Io\BufferedReader; use Phing\Io\Reader; diff --git a/classes/phing/tasks/ext/pdo/PDOResultFormatter.php b/src/Phing/Task/System/Pdo/PDOResultFormatter.php similarity index 98% rename from classes/phing/tasks/ext/pdo/PDOResultFormatter.php rename to src/Phing/Task/System/Pdo/PDOResultFormatter.php index 0933354e18..a4a3128984 100644 --- a/classes/phing/tasks/ext/pdo/PDOResultFormatter.php +++ b/src/Phing/Task/System/Pdo/PDOResultFormatter.php @@ -17,6 +17,8 @@ * . */ +namespace Phing\Task\System\Pdo; + use Phing\Io\Writer; /** diff --git a/classes/phing/tasks/ext/pdo/PDOSQLExecFormatterElement.php b/src/Phing/Task/System/Pdo/PDOSQLExecFormatterElement.php similarity index 98% rename from classes/phing/tasks/ext/pdo/PDOSQLExecFormatterElement.php rename to src/Phing/Task/System/Pdo/PDOSQLExecFormatterElement.php index ef2a06820d..1c8c3f51f1 100644 --- a/classes/phing/tasks/ext/pdo/PDOSQLExecFormatterElement.php +++ b/src/Phing/Task/System/Pdo/PDOSQLExecFormatterElement.php @@ -17,6 +17,8 @@ * . */ +namespace Phing\Task\System\Pdo; + use Phing\Exception\BuildException; use Phing\Io\FileWriter; use Phing\Io\LogWriter; @@ -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"); diff --git a/classes/phing/tasks/ext/pdo/PDOSQLExecTask.php b/src/Phing/Task/System/Pdo/PDOSQLExecTask.php similarity index 99% rename from classes/phing/tasks/ext/pdo/PDOSQLExecTask.php rename to src/Phing/Task/System/Pdo/PDOSQLExecTask.php index e2dabe777a..f727eb2421 100644 --- a/classes/phing/tasks/ext/pdo/PDOSQLExecTask.php +++ b/src/Phing/Task/System/Pdo/PDOSQLExecTask.php @@ -17,6 +17,12 @@ * . */ +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; @@ -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) { @@ -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) { diff --git a/classes/phing/tasks/ext/pdo/PDOSQLExecTransaction.php b/src/Phing/Task/System/Pdo/PDOSQLExecTransaction.php similarity index 98% rename from classes/phing/tasks/ext/pdo/PDOSQLExecTransaction.php rename to src/Phing/Task/System/Pdo/PDOSQLExecTransaction.php index c28fb818e2..594925b4c8 100644 --- a/classes/phing/tasks/ext/pdo/PDOSQLExecTransaction.php +++ b/src/Phing/Task/System/Pdo/PDOSQLExecTransaction.php @@ -17,6 +17,8 @@ * . */ +namespace Phing\Task\System\Pdo; + use Phing\Io\FileReader; use Phing\Io\IOException; use Phing\Io\File; diff --git a/classes/phing/tasks/ext/pdo/PDOTask.php b/src/Phing/Task/System/Pdo/PDOTask.php similarity index 96% rename from classes/phing/tasks/ext/pdo/PDOTask.php rename to src/Phing/Task/System/Pdo/PDOTask.php index f7272791c6..6fb7aeb6eb 100644 --- a/classes/phing/tasks/ext/pdo/PDOTask.php +++ b/src/Phing/Task/System/Pdo/PDOTask.php @@ -17,6 +17,11 @@ * . */ +namespace Phing\Task\System\Pdo; + +use Exception; +use PDO; +use PDOException; use Phing\Exception\BuildException; use Phing\Project; use Phing\Task; @@ -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() { diff --git a/classes/phing/tasks/ext/pdo/PgsqlPDOQuerySplitter.php b/src/Phing/Task/System/Pdo/PgsqlPDOQuerySplitter.php similarity index 96% rename from classes/phing/tasks/ext/pdo/PgsqlPDOQuerySplitter.php rename to src/Phing/Task/System/Pdo/PgsqlPDOQuerySplitter.php index 4c87c53858..8edaacc2a8 100644 --- a/classes/phing/tasks/ext/pdo/PgsqlPDOQuerySplitter.php +++ b/src/Phing/Task/System/Pdo/PgsqlPDOQuerySplitter.php @@ -19,6 +19,8 @@ * @package phing.tasks.ext.pdo */ +namespace Phing\Task\System\Pdo; + /** * Splits PostgreSQL's dialect of SQL into separate queries * @@ -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(); @@ -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++) { @@ -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 { @@ -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; @@ -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; diff --git a/classes/phing/tasks/ext/pdo/PlainPDOResultFormatter.php b/src/Phing/Task/System/Pdo/PlainPDOResultFormatter.php similarity index 99% rename from classes/phing/tasks/ext/pdo/PlainPDOResultFormatter.php rename to src/Phing/Task/System/Pdo/PlainPDOResultFormatter.php index 523806e524..f6720599fe 100644 --- a/classes/phing/tasks/ext/pdo/PlainPDOResultFormatter.php +++ b/src/Phing/Task/System/Pdo/PlainPDOResultFormatter.php @@ -17,6 +17,8 @@ * . */ +namespace Phing\Task\System\Pdo; + use Phing\Io\File; use Phing\Util\StringHelper; diff --git a/classes/phing/tasks/ext/pdo/XMLPDOResultFormatter.php b/src/Phing/Task/System/Pdo/XMLPDOResultFormatter.php similarity index 98% rename from classes/phing/tasks/ext/pdo/XMLPDOResultFormatter.php rename to src/Phing/Task/System/Pdo/XMLPDOResultFormatter.php index 85301d7b9d..545151b19d 100644 --- a/classes/phing/tasks/ext/pdo/XMLPDOResultFormatter.php +++ b/src/Phing/Task/System/Pdo/XMLPDOResultFormatter.php @@ -17,6 +17,10 @@ * . */ +namespace Phing\Task\System\Pdo; + +use DOMDocument; +use DOMElement; use Phing\Io\File; /** From d2495f2cf98cfb0ff2548aeb10a7342d6ac62637 Mon Sep 17 00:00:00 2001 From: siad007 Date: Sun, 31 Jan 2021 02:05:30 +0100 Subject: [PATCH 2/5] Moved PackageAsPathTask to system tasks. --- etc/default.tasks.properties | 2 +- .../tasks/ext => src/Phing/Task/System}/PackageAsPathTask.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename {classes/phing/tasks/ext => src/Phing/Task/System}/PackageAsPathTask.php (98%) diff --git a/etc/default.tasks.properties b/etc/default.tasks.properties index b6b4a53225..79df9a12ca 100644 --- a/etc/default.tasks.properties +++ b/etc/default.tasks.properties @@ -86,9 +86,9 @@ 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 -package-as-path=phing.tasks.ext.PackageAsPathTask mail=phing.tasks.ext.MailTask phpunit=phing.tasks.ext.phpunit.PHPUnitTask phpunitreport=phing.tasks.ext.phpunit.PHPUnitReportTask diff --git a/classes/phing/tasks/ext/PackageAsPathTask.php b/src/Phing/Task/System/PackageAsPathTask.php similarity index 98% rename from classes/phing/tasks/ext/PackageAsPathTask.php rename to src/Phing/Task/System/PackageAsPathTask.php index 5a17f4288c..467ddf7cc3 100644 --- a/classes/phing/tasks/ext/PackageAsPathTask.php +++ b/src/Phing/Task/System/PackageAsPathTask.php @@ -17,6 +17,8 @@ * . */ +namespace Phing\Task\System; + use Phing\Task; /** From ca09e6223a8d2ac66001fd890981f9ee1b94b11f Mon Sep 17 00:00:00 2001 From: siad007 Date: Sun, 31 Jan 2021 02:14:57 +0100 Subject: [PATCH 3/5] Fixed NS --- src/Phing/Task/System/Condition/ConditionBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Phing/Task/System/Condition/ConditionBase.php b/src/Phing/Task/System/Condition/ConditionBase.php index a6197dba55..a420214c4c 100644 --- a/src/Phing/Task/System/Condition/ConditionBase.php +++ b/src/Phing/Task/System/Condition/ConditionBase.php @@ -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; From 169cb8713fb598ded77b0f61c7ad745addd0167b Mon Sep 17 00:00:00 2001 From: siad007 Date: Sun, 31 Jan 2021 02:18:54 +0100 Subject: [PATCH 4/5] Fixed NS --- tests/Phing/Task/Optional/PDODelimitersTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Phing/Task/Optional/PDODelimitersTest.php b/tests/Phing/Task/Optional/PDODelimitersTest.php index a12cf831e2..eb49bb41f1 100644 --- a/tests/Phing/Task/Optional/PDODelimitersTest.php +++ b/tests/Phing/Task/Optional/PDODelimitersTest.php @@ -20,7 +20,7 @@ namespace Phing\Task\Optional; -use PDOSQLExecTask; +use Phing\Task\System\Pdo\PDOSQLExecTask; use Phing\Io\File; use Phing\Support\BuildFileTest; From 992e56c6adc369cd19d005fa8bff63c5b6023581 Mon Sep 17 00:00:00 2001 From: siad007 Date: Sun, 31 Jan 2021 02:23:04 +0100 Subject: [PATCH 5/5] Fixed NS --- tests/Phing/Task/Optional/PDODelimitersTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Phing/Task/Optional/PDODelimitersTest.php b/tests/Phing/Task/Optional/PDODelimitersTest.php index eb49bb41f1..3d4268aa15 100644 --- a/tests/Phing/Task/Optional/PDODelimitersTest.php +++ b/tests/Phing/Task/Optional/PDODelimitersTest.php @@ -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);