Commit f1fe0de2 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Problèmes signalés par PHPStorm

parent f382fe43
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@

namespace Application;

use \UnicaenDbImport\Entity\Db\Source;
use UnicaenDbImport\Entity\Db\Source;

return [
    'import' => [
+2 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ abstract class LogTableHelper extends Helper
     */
    public function generateSQLForLogTableCreation(string $logTableName): string
    {
        $varchar = $this->platform->getVarcharTypeDeclarationSQL(['length' => 128]);
        $varchar = $this->platform->getStringTypeDeclarationSQL(['length' => 128]);
        $boolean = $this->platform->getBooleanTypeDeclarationSQL([]);
        $text = $this->platform->getClobTypeDeclarationSQL([]);
        try {
@@ -91,8 +91,7 @@ EOT;
            throw new HelperException("Erreur lors de la génération du hash !", null, $e);
        }

        $sql = '';
        $sql .= "INSERT INTO $logTableName (type, name, success, has_problems, log, started_on, ended_on, import_hash) ";
        $sql = "INSERT INTO $logTableName (type, name, success, has_problems, log, started_on, ended_on, import_hash) ";
        $sql .= sprintf("VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
            $this->platform->quoteStringLiteral($type),
            $this->platform->quoteStringLiteral($name),
+6 −3
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@

namespace UnicaenDbImport\CodeGenerator\Helper;

use DateTime;
use DateTimeZone;
use stdClass;
use UnicaenApp\Exception\RuntimeException;
use UnicaenDbImport\CodeGenerator\Helper;
use UnicaenDbImport\Domain\Operation;
@@ -477,9 +480,9 @@ EOT;
            return 'NULL';
        }

        if ($value instanceof \stdClass) {
        if ($value instanceof stdClass) {
            if (isset($value->date)) {
                $tz = isset($value->timezone) ? new \DateTimeZone($value->timezone) : NULL;
                $tz = isset($value->timezone) ? new DateTimeZone($value->timezone) : NULL;
                $d = date_create($value->date, $tz);

                return $this->formatDateTimeForInsert($d);
@@ -497,7 +500,7 @@ EOT;
     * @param \DateTime $value
     * @return string
     */
    protected function formatDateTimeForInsert(\DateTime $value): string
    protected function formatDateTimeForInsert(DateTime $value): string
    {
        $value = $value->format('c');

+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ EOT;
        }

        $integer = $this->platform->getBigIntTypeDeclarationSQL([]);
        $varchar = $this->platform->getVarcharTypeDeclarationSQL(['length' => 100]);
        $varchar = $this->platform->getStringTypeDeclarationSQL(['length' => 100]);

        $message = "Assurez-vous que les colonnes suivantes sont présentes dans la table '$tableName' : " . PHP_EOL;
        $message .= <<<EOT
+3 −8
Original line number Diff line number Diff line
@@ -45,10 +45,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper
     */
    public function generateSQLForDiffViewCreation(string $diffSourceTableName, string $destinationTable, string $sourceCodeColumn, array $columns): string
    {
        $res = '';
        $res .= $this->generateDiffViewCreationSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns) . PHP_EOL;

        return $res;
        return $this->generateDiffViewCreationSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns) . PHP_EOL;
    }

    /**
@@ -62,8 +59,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper
    {
        $name = $this->generateDiffViewName($destinationTable);

        $res = '';
        $res .= "CREATE OR REPLACE VIEW $name AS " . PHP_EOL;
        $res = "CREATE OR REPLACE VIEW $name AS " . PHP_EOL;
        $res .= $this->indent(4, $this->generateDiffViewBodySelectSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns)) . PHP_EOL;

        return $res;
@@ -122,8 +118,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper
        $where = "diff.operation = '$operation' AND d.$sourceCodeColumn = diff.$sourceCodeColumn";

        // instruction de mise à jour de la table destination
        $markup = '';
        $markup .= "MERGE INTO $destinationTable d USING (SELECT * FROM $diffViewName) diff " . PHP_EOL;
        $markup = "MERGE INTO $destinationTable d USING (SELECT * FROM $diffViewName) diff " . PHP_EOL;
        $markup .= "ON ($where) " . PHP_EOL;
        $markup .= "WHEN MATCHED THEN UPDATE SET " . PHP_EOL;
        $markup .= $setters;
Loading