Skip to content

Commit caf7cfa

Browse files
committed
Fix punctuation issue.
1 parent 570f335 commit caf7cfa

8 files changed

+275
-279
lines changed

src/Backend/MySqlRoutineLoaderWorker.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,24 +397,6 @@ private function gatherPlaceholdersConstants(): void
397397
OutputFormatter::escape($reflection->getFileName())));
398398
}
399399

400-
//--------------------------------------------------------------------------------------------------------------------
401-
/**
402-
* Gathers metadata of all columns types off all tables in the database.
403-
*
404-
* @return array[]
405-
* @throws MySqlQueryErrorException
406-
*/
407-
private function gatherTableColumns(): array
408-
{
409-
$columns = $this->dl->allTableColumns();
410-
foreach ($columns as $index => $column)
411-
{
412-
$columns[$index]['column_type'] = str_replace(',', ', ', $column['column_type']);
413-
}
414-
415-
return $columns;
416-
}
417-
418400
//--------------------------------------------------------------------------------------------------------------------
419401
/**
420402
* Gathers type hints based on exact column types.
@@ -446,7 +428,7 @@ private function gatherTypeHintsColumnTypesExact(array $columns): void
446428
*/
447429
private function gatherTypeHintsPlaceholdersColumnTypes(): void
448430
{
449-
$columns = $this->gatherTableColumns();
431+
$columns = $this->dl->allTableColumns();
450432
$this->gatherPlaceholdersColumnTypesExact($columns);
451433
$this->gatherPlaceholdersColumnTypesMaxLength($columns);
452434
$this->gatherTypeHintsColumnTypesExact($columns);

src/Helper/RoutineLoaderHelper.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -965,29 +965,29 @@ private function updateSourceTypeHints(): void
965965
throw new RoutineLoaderException("Unknown type hint '%s' found at line %d.", $hint, $index + 1);
966966
}
967967

968-
switch (true)
968+
if (preg_match('/(?<punctuation>\s*[;,]\s*)$/', $matches['datatype'], $other))
969969
{
970-
case (str_ends_with($matches['datatype'], ';')):
971-
$punctuation = ';';
972-
break;
973-
974-
case (str_ends_with($matches['datatype'], ',')):
975-
$punctuation = ',';
976-
break;
977-
978-
default:
979-
$punctuation = '';
970+
$punctuation = $other['punctuation'];
971+
}
972+
else
973+
{
974+
$punctuation = '';
980975
}
981976

982-
$actualType = $this->typeHintPool[$hint];
983-
$this->routineSourceCodeLines[$index] = sprintf('%s%s%s%s%s%s',
984-
mb_substr($line, 0, -mb_strlen($matches[0])),
985-
$matches['whitespace'],
986-
$actualType, // <== the real replacement
987-
$matches['nullable'],
988-
$punctuation,
989-
$matches['hint']);
990-
$this->typeHints[$hint] = $actualType;
977+
$actualType = $this->typeHintPool[$hint];
978+
$newLine = sprintf('%s%s%s%s%s%s',
979+
mb_substr($line, 0, -mb_strlen($matches[0])),
980+
$matches['whitespace'],
981+
$actualType, // <== the real replacement
982+
$matches['nullable'],
983+
$punctuation,
984+
$matches['hint']);
985+
$this->typeHints[$hint] = $actualType;
986+
987+
if (str_replace(' ', '', $line)!==str_replace(' ', '', $newLine))
988+
{
989+
$this->routineSourceCodeLines[$index] = $newLine;
990+
}
991991
}
992992
}
993993

test/TestMySqlDataLayer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ public function tstOracleHelloWorld(): string
281281
* @param string|null $pParam33 Data type longtext.
282282
* longtext character set utf8mb4 collation utf8mb4_general_ci
283283
* @param string|null $pParam34 Data type enum('a','b').
284-
* enum('a','b') character set utf8mb4 collation utf8mb4_general_ci
284+
* enum('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
285285
* @param string|null $pParam35 Data type set('a','b').
286-
* set('a','b') character set utf8mb4 collation utf8mb4_general_ci
286+
* set('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
287287
*
288288
* @return int
289289
*
@@ -1738,9 +1738,9 @@ public function tstTestTable(): int
17381738
* @param string|null $pTstVarbinary Parameter of type varbinary.
17391739
* varbinary(10)
17401740
* @param string|null $pTstEnum Parameter of type enum.
1741-
* enum('a','b') character set utf8mb4 collation utf8mb4_general_ci
1741+
* enum('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
17421742
* @param string|null $pTstSet Parameter of type set.
1743-
* set('a','b') character set utf8mb4 collation utf8mb4_general_ci
1743+
* set('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
17441744
*
17451745
* @return int
17461746
*
@@ -1823,9 +1823,9 @@ public function tstTestTypeHintVariable(): int
18231823
* @param string|null $pTstLongtext Parameter of type longtext.
18241824
* longtext character set utf8mb4 collation utf8mb4_general_ci
18251825
* @param string|null $pTstEnum Parameter of type enum.
1826-
* enum('a','b') character set utf8mb4 collation utf8mb4_general_ci
1826+
* enum('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
18271827
* @param string|null $pTstSet Parameter of type set.
1828-
* set('a','b') character set utf8mb4 collation utf8mb4_general_ci
1828+
* set('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
18291829
*
18301830
* @return int
18311831
*
@@ -1939,9 +1939,9 @@ public function tstTestTypeHintWithBlobs(?int $pTstInt, ?int $pTstSmallint, ?int
19391939
* @param string|null $pTstVarbinary Parameter of type varbinary.
19401940
* varbinary(10)
19411941
* @param string|null $pTstEnum Parameter of type enum.
1942-
* enum('a','b') character set utf8mb4 collation utf8mb4_general_ci
1942+
* enum('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
19431943
* @param string|null $pTstSet Parameter of type set.
1944-
* set('a','b') character set utf8mb4 collation utf8mb4_general_ci
1944+
* set('a','b','c') character set utf8mb4 collation utf8mb4_general_ci
19451945
*
19461946
* @return int
19471947
*

0 commit comments

Comments
 (0)