Extract dependency from Util::getSupportedDatatypes()
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
a15c6d6a47
commit
0a8974668e
@ -13143,7 +13143,7 @@ parameters:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 5
|
||||
count: 4
|
||||
path: src/Util.php
|
||||
|
||||
-
|
||||
|
||||
@ -8530,7 +8530,6 @@
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$array]]></code>
|
||||
|
||||
@ -358,7 +358,7 @@ class Routines
|
||||
$retval['item_param_name'] = $_POST['item_param_name'];
|
||||
$retval['item_param_type'] = $_POST['item_param_type'];
|
||||
foreach ($retval['item_param_type'] as $key => $value) {
|
||||
if (in_array($value, Util::getSupportedDatatypes(), true)) {
|
||||
if (in_array($value, Util::getSupportedDatatypes($this->dbi), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -380,7 +380,7 @@ class Routines
|
||||
$retval['item_returntype'] = '';
|
||||
if (
|
||||
isset($_POST['item_returntype'])
|
||||
&& in_array($_POST['item_returntype'], Util::getSupportedDatatypes(), true)
|
||||
&& in_array($_POST['item_returntype'], Util::getSupportedDatatypes($this->dbi), true)
|
||||
) {
|
||||
$retval['item_returntype'] = $_POST['item_returntype'];
|
||||
}
|
||||
@ -726,7 +726,7 @@ class Routines
|
||||
): string {
|
||||
$itemReturnType = $_POST['item_returntype'] ?? null;
|
||||
|
||||
if ($itemReturnType !== '' && in_array($itemReturnType, Util::getSupportedDatatypes(), true)) {
|
||||
if ($itemReturnType !== '' && in_array($itemReturnType, Util::getSupportedDatatypes($this->dbi), true)) {
|
||||
$query .= 'RETURNS ' . $itemReturnType;
|
||||
} else {
|
||||
$this->errors[] = __('You must provide a valid return type for the routine.');
|
||||
|
||||
@ -1162,10 +1162,10 @@ class Util
|
||||
*
|
||||
* @return string[] An array of datatypes.
|
||||
*/
|
||||
public static function getSupportedDatatypes(): array
|
||||
public static function getSupportedDatatypes(DatabaseInterface $dbi): array
|
||||
{
|
||||
$retval = [];
|
||||
foreach (DatabaseInterface::getInstance()->types->getColumns() as $value) {
|
||||
foreach ($dbi->types->getColumns() as $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $subvalue) {
|
||||
if ($subvalue === '-') {
|
||||
|
||||
@ -1367,8 +1367,6 @@ SQL;
|
||||
|
||||
public function testGetSupportedDatatypes(): void
|
||||
{
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface($dbiDummy);
|
||||
$expected = [
|
||||
'INT',
|
||||
'VARCHAR',
|
||||
@ -1415,7 +1413,7 @@ SQL;
|
||||
'GEOMETRYCOLLECTION',
|
||||
'JSON',
|
||||
];
|
||||
self::assertSame($expected, Util::getSupportedDatatypes());
|
||||
self::assertSame($expected, Util::getSupportedDatatypes($this->createDatabaseInterface()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user