Add native param types
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
cff126e7dd
commit
2b922018f7
@ -35,7 +35,7 @@ abstract class Bool2TextTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Bool2Text']);
|
||||
|
||||
@ -25,7 +25,7 @@ abstract class CodeMirrorEditorTransformationPlugin extends IOTransformationsPlu
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
@ -55,9 +55,8 @@ abstract class DateFormatTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$buffer = (string) $buffer;
|
||||
// possibly use a global transform and feed it with special options
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['DateFormat']);
|
||||
|
||||
@ -41,7 +41,7 @@ abstract class DownloadTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$GLOBALS['row'] ??= null;
|
||||
$GLOBALS['fields_meta'] ??= null;
|
||||
|
||||
@ -77,7 +77,7 @@ abstract class ExternalTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ abstract class FormattedTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return '<iframe srcdoc="'
|
||||
. strtr($buffer, '"', '\'')
|
||||
|
||||
@ -39,7 +39,7 @@ abstract class HexTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
|
||||
@ -34,7 +34,7 @@ abstract class ImageLinkTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
// must disable the page loader, see
|
||||
// https://wiki.phpmyadmin.net/pma/Page_loader#Bypassing_the_page_loader
|
||||
|
||||
@ -39,7 +39,7 @@ abstract class ImageUploadTransformationsPlugin extends IOTransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ abstract class InlineTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Inline']);
|
||||
|
||||
@ -37,7 +37,7 @@ abstract class LongToIPv4TransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return htmlspecialchars(FormatConverter::longToIp($buffer));
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ abstract class PreApPendTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['PreApPend']);
|
||||
|
||||
@ -40,7 +40,7 @@ abstract class RegexValidationTransformationsPlugin extends IOTransformationsPlu
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
// reset properties of object
|
||||
$this->reset();
|
||||
|
||||
@ -33,7 +33,7 @@ abstract class SQLTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return Generator::formatSql($buffer);
|
||||
}
|
||||
|
||||
@ -41,9 +41,8 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$buffer = (string) $buffer;
|
||||
// possibly use a global transform and feed it with special options
|
||||
|
||||
// further operations on $buffer using the $options[] array.
|
||||
|
||||
@ -34,7 +34,7 @@ abstract class TextFileUploadTransformationsPlugin extends IOTransformationsPlug
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ abstract class TextImageLinkTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['TextImageLink']);
|
||||
|
||||
@ -38,7 +38,7 @@ abstract class TextLinkTransformationsPlugin extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['TextLink']);
|
||||
|
||||
@ -41,7 +41,7 @@ class Text_Plain_Iptobinary extends IOTransformationsPlugin
|
||||
*
|
||||
* @return string IP address
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return FormatConverter::ipToBinary($buffer);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class Text_Plain_Iptolong extends IOTransformationsPlugin
|
||||
*
|
||||
* @return string IP address
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return (string) FormatConverter::ipToLong($buffer);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ class Text_Plain_Binarytoip extends TransformationsPlugin
|
||||
*
|
||||
* @return string IP address
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
$isBinary = ($meta !== null && $meta->isBinary);
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ class Text_Plain_Json extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return '<code class="json"><pre>' . "\n"
|
||||
. htmlspecialchars($buffer) . "\n"
|
||||
|
||||
@ -49,7 +49,7 @@ class Text_Plain_Xml extends TransformationsPlugin
|
||||
* @param array $options transformation options
|
||||
* @param FieldMetadata|null $meta meta information
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
public function applyTransformation(string $buffer, array $options = [], FieldMetadata|null $meta = null): string
|
||||
{
|
||||
return '<code class="xml"><pre>' . "\n"
|
||||
. htmlspecialchars($buffer) . "\n"
|
||||
|
||||
@ -35,7 +35,7 @@ abstract class TransformationsPlugin implements TransformationsInterface
|
||||
* @return string the transformed text
|
||||
*/
|
||||
abstract public function applyTransformation(
|
||||
$buffer,
|
||||
string $buffer,
|
||||
array $options = [],
|
||||
FieldMetadata|null $meta = null,
|
||||
): string;
|
||||
|
||||
@ -77,14 +77,16 @@ class FormatConverter
|
||||
/**
|
||||
* Transforms a long to an IP
|
||||
*
|
||||
* @param mixed $buffer Data to transform
|
||||
* @param string $buffer Data to transform
|
||||
*/
|
||||
public static function longToIp(mixed $buffer): string
|
||||
public static function longToIp(string $buffer): string
|
||||
{
|
||||
if (! Util::isInteger($buffer) || $buffer < 0 || $buffer > 4294967295) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
return (string) long2ip((int) $buffer);
|
||||
$bufferAsFloat = (float) $buffer;
|
||||
|
||||
return (string) long2ip((int) $bufferAsFloat);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6780,11 +6780,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
|
||||
|
||||
-
|
||||
message: "#^Casting to string something that's already string\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Transformations/Abs/DateFormatTransformationsPlugin.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Transformations\\\\Abs\\\\DateFormatTransformationsPlugin\\:\\:applyTransformation\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -6900,11 +6895,6 @@ parameters:
|
||||
count: 2
|
||||
path: libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php
|
||||
|
||||
-
|
||||
message: "#^Casting to string something that's already string\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Plugins/Transformations/Abs/SubstringTransformationsPlugin.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Transformations\\\\Abs\\\\SubstringTransformationsPlugin\\:\\:applyTransformation\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -8895,11 +8885,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Util.php
|
||||
|
||||
-
|
||||
message: "#^Cannot cast mixed to int\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Utils/FormatConverter.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Utils\\\\FormatConverter\\:\\:binaryToIp\\(\\) should return string\\|false but returns mixed\\.$#"
|
||||
count: 2
|
||||
@ -8910,11 +8895,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Utils/FormatConverter.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Utils\\\\FormatConverter\\:\\:longToIp\\(\\) should return string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Utils/FormatConverter.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$haystack of function strpos expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
@ -11035,11 +11015,6 @@ parameters:
|
||||
count: 1
|
||||
path: test/classes/Utils/FormatConverterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tests\\\\Utils\\\\FormatConverterTest\\:\\:providerLongToIp\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: test/classes/Utils/FormatConverterTest.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Tests\\\\Utils\\\\GisTest\\:\\:providerConvertToWellKnownText\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -11680,9 +11680,6 @@
|
||||
<code>$options[1]</code>
|
||||
<code>$options[2]</code>
|
||||
</MixedArgument>
|
||||
<RedundantCastGivenDocblockType>
|
||||
<code>(string) $buffer</code>
|
||||
</RedundantCastGivenDocblockType>
|
||||
</file>
|
||||
<file src="libraries/classes/Plugins/Transformations/Abs/DownloadTransformationsPlugin.php">
|
||||
<InvalidArrayOffset>
|
||||
@ -11769,9 +11766,6 @@
|
||||
<code>$options[2]</code>
|
||||
<code>$options[2]</code>
|
||||
</MixedOperand>
|
||||
<RedundantCastGivenDocblockType>
|
||||
<code>(string) $buffer</code>
|
||||
</RedundantCastGivenDocblockType>
|
||||
</file>
|
||||
<file src="libraries/classes/Plugins/Transformations/Abs/TextImageLinkTransformationsPlugin.php">
|
||||
<MixedOperand>
|
||||
@ -14088,16 +14082,14 @@
|
||||
<MixedInferredReturnType>
|
||||
<code>false|string</code>
|
||||
<code>string</code>
|
||||
<code>string</code>
|
||||
</MixedInferredReturnType>
|
||||
<MixedReturnStatement>
|
||||
<code>$buffer</code>
|
||||
<code>$buffer</code>
|
||||
<code>$isBinary ? bin2hex($buffer) : $buffer</code>
|
||||
<code>$isBinary ? bin2hex($buffer) : $buffer</code>
|
||||
</MixedReturnStatement>
|
||||
<RedundantCast>
|
||||
<code>(string) long2ip((int) $buffer)</code>
|
||||
<code>(string) long2ip((int) $bufferAsFloat)</code>
|
||||
</RedundantCast>
|
||||
</file>
|
||||
<file src="libraries/classes/Utils/Gis.php">
|
||||
@ -15900,7 +15892,6 @@
|
||||
<code>array</code>
|
||||
<code>array</code>
|
||||
<code>array</code>
|
||||
<code>array</code>
|
||||
</MixedInferredReturnType>
|
||||
</file>
|
||||
<file src="test/classes/Utils/GisTest.php">
|
||||
|
||||
@ -23,6 +23,7 @@ use PhpMyAdmin\Plugins\Transformations\Text_Plain_Link;
|
||||
use PhpMyAdmin\Plugins\Transformations\Text_Plain_Longtoipv4;
|
||||
use PhpMyAdmin\Plugins\Transformations\Text_Plain_PreApPend;
|
||||
use PhpMyAdmin\Plugins\Transformations\Text_Plain_Substring;
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use ReflectionMethod;
|
||||
|
||||
@ -437,17 +438,17 @@ class TransformationPluginsTest extends AbstractTestCase
|
||||
],
|
||||
[
|
||||
new Text_Plain_Dateformat(),
|
||||
[12345, [0], new FieldMetadata(MYSQLI_TYPE_TINY, 0, (object) [])],
|
||||
['12345', [0], new FieldMetadata(MYSQLI_TYPE_TINY, 0, (object) [])],
|
||||
'<dfn onclick="alert("12345");" title="12345">Jan 01, 1970 at 03:25 AM</dfn>',
|
||||
],
|
||||
[
|
||||
new Text_Plain_Dateformat(),
|
||||
[12345678, [0], new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) [])],
|
||||
['12345678', [0], new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) [])],
|
||||
'<dfn onclick="alert("12345678");" title="12345678">May 23, 1970 at 09:21 PM</dfn>',
|
||||
],
|
||||
[
|
||||
new Text_Plain_Dateformat(),
|
||||
[123456789, [0], new FieldMetadata(-1, 0, (object) [])],
|
||||
['123456789', [0], new FieldMetadata(-1, 0, (object) [])],
|
||||
'<dfn onclick="alert("123456789");" title="123456789">Nov 29, 1973 at 09:33 PM</dfn>',
|
||||
],
|
||||
[
|
||||
@ -531,8 +532,8 @@ class TransformationPluginsTest extends AbstractTestCase
|
||||
. ' target="_blank" rel="noopener noreferrer">https://example.com/PMA_TXT_LINK</a>',
|
||||
],
|
||||
[new Text_Plain_Link(), ['PMA_TXT_LINK', ['./php/', 'text_name']], './php/PMA_TXT_LINK'],
|
||||
[new Text_Plain_Longtoipv4(), [42949672, ['option1', 'option2']], '2.143.92.40'],
|
||||
[new Text_Plain_Longtoipv4(), [4294967295, ['option1', 'option2']], '255.255.255.255'],
|
||||
[new Text_Plain_Longtoipv4(), ['42949672', []], '2.143.92.40'],
|
||||
[new Text_Plain_Longtoipv4(), ['4294967295', ['option1', 'option2']], '255.255.255.255'],
|
||||
[new Text_Plain_PreApPend(), ['My', ['php', 'Admin']], 'phpMyAdmin'],
|
||||
[new Text_Plain_Substring(), ['PMA_BUFFER', [1, 3, 'suffix']], 'suffixMA_suffix'],
|
||||
[new Text_Plain_Substring(), ['PMA_BUFFER', ['1', '3', 'suffix']], 'suffixMA_suffix'],
|
||||
@ -544,8 +545,7 @@ class TransformationPluginsTest extends AbstractTestCase
|
||||
[new Text_Plain_Substring(), ['PMA_BUFFER', ['-1']], '…R…'],
|
||||
[new Text_Plain_Substring(), ['PMA_BUFFER', [0, 2]], 'PM…'],
|
||||
[new Text_Plain_Substring(), ['PMA_BUFFER', ['0', '2']], 'PM…'],
|
||||
[new Text_Plain_Substring(), [2, []], '2'],
|
||||
[new Text_Plain_Longtoipv4(), [168496141], '10.11.12.13'],
|
||||
[new Text_Plain_Substring(), ['2', []], '2'],
|
||||
[new Text_Plain_Longtoipv4(), ['168496141'], '10.11.12.13'],
|
||||
[new Text_Plain_Longtoipv4(), ['my ip'], 'my ip'],
|
||||
[new Text_Plain_Longtoipv4(), ['<my ip>'], '<my ip>'],
|
||||
@ -596,27 +596,25 @@ class TransformationPluginsTest extends AbstractTestCase
|
||||
/**
|
||||
* Tests for applyTransformation, isSuccess, getError
|
||||
*
|
||||
* @param object $object instance of the plugin
|
||||
* @param array $applyArgs arguments for applyTransformation
|
||||
* @param string|int $transformed the expected output of applyTransformation
|
||||
* @param bool $success the expected output of isSuccess
|
||||
* @param string $error the expected output of getError
|
||||
* @param TransformationsPlugin $object instance of the plugin
|
||||
* @param array $applyArgs arguments for applyTransformation
|
||||
* @param string|int $transformed the expected output of applyTransformation
|
||||
* @param bool $success the expected output of isSuccess
|
||||
* @param string $error the expected output of getError
|
||||
* @psalm-param array{string, array, FieldMetadata|null} $applyArgs
|
||||
*
|
||||
* @dataProvider transformationDataProvider
|
||||
* @group medium
|
||||
*/
|
||||
public function testTransformation(
|
||||
object $object,
|
||||
TransformationsPlugin $object,
|
||||
array $applyArgs,
|
||||
string|int $transformed,
|
||||
bool $success = true,
|
||||
string $error = '',
|
||||
): void {
|
||||
$reflectionMethod = new ReflectionMethod($object, 'applyTransformation');
|
||||
$this->assertEquals(
|
||||
$transformed,
|
||||
$reflectionMethod->invokeArgs($object, $applyArgs),
|
||||
);
|
||||
$actual = $object->applyTransformation(...$applyArgs);
|
||||
$this->assertEquals($transformed, $actual);
|
||||
|
||||
// For output transformation plugins, this method may not exist
|
||||
if (method_exists($object, 'isSuccess')) {
|
||||
|
||||
@ -114,10 +114,19 @@ class FormatConverterTest extends AbstractTestCase
|
||||
/**
|
||||
* Data provider for longToIp
|
||||
*
|
||||
* @return array
|
||||
* @return array<array{string, string}>
|
||||
*/
|
||||
public static function providerLongToIp(): array
|
||||
{
|
||||
return [['10.11.12.13', '168496141'], ['my ip', 'my ip']];
|
||||
return [
|
||||
['my ip', 'my ip'],
|
||||
['10.11.12.13', '168496141'],
|
||||
['-1', '-1'],
|
||||
['0.0.0.0', '0'],
|
||||
['127.255.255.255', '2147483647'],
|
||||
['128.0.0.0', '2147483648'],
|
||||
['255.255.255.255', '4294967295'],
|
||||
['4294967296', '4294967296'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user