From d844bd03ad4ee97f26a277748a34f137a1b3efbe Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 2 Apr 2025 22:21:16 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- src/schema/TODO.md | 10 +- src/schema/Wrapper.php | 2 + src/schema/WrapperContext.php | 10 +- src/schema/_assoc/AssocSchema.php | 8 +- src/schema/_assoc/AssocWrapper.php | 4 +- src/schema/_assoc/AssocWrapperContext.php | 15 +- src/schema/_list/ListResult.php | 2 - src/schema/_scalar/ScalarResult.php | 2 - src/schema/_scalar/ScalarSchema.php | 8 +- tests/wip/schema/_assoc/AssocSchemaTest.php | 16 +- .../wip/schema/_scalar/ScalarWrapperTest.php | 222 +++++++++--------- 11 files changed, 141 insertions(+), 158 deletions(-) diff --git a/src/schema/TODO.md b/src/schema/TODO.md index 8cdcee8..bdc7e45 100644 --- a/src/schema/TODO.md +++ b/src/schema/TODO.md @@ -1,9 +1,5 @@ # nulib\schema -* ensureKeys() et orderKeys() se fait au niveau de access (ou input?) - * access/input ne pouvant pas connaître les valeurs appropriées, c'est le - schéma qui les génère. ensureKeys($values) - * méthode ensureAssoc() transforme les clés séquentielles en clés associatives * l'ordre est `ensureAssoc [--> ensureKeys] [--> orderKeys]` * si false, supprimer la clé du tableau sauf si ensureKeys @@ -12,9 +8,6 @@ * null pour un résultat aggrégé * "" pour le résultat du tableau * $key pour le résultat de la clé correspondante -* si possible, ne pas utiliser les méthodes isScalar(), isAssoc(), etc. - --> vérifier s'il suffit d'utiliser instanceof ScalarXxx, AssocXxx, etc. pour - les actions courantes * rajouter l'attribut "size" pour spécifier la taille maximale des valeurs * cela pourrait servir pour générer automatiquement des tables SQL @@ -30,7 +23,8 @@ * fonction getter_func, setter_func, deleter_func pour les propriétés de type computed * tdate et tdatetime. qu'en est-il des autres classes (delay, etc.) - * possibilité de spécifier le format de la date à analyser + * parse_format pour spécifier le format d'analyse au lieu de l'auto-détecter + * ScalarSchema::from_property() * l'argument $format de AssocWrapper::format() est un tableau associatif diff --git a/src/schema/Wrapper.php b/src/schema/Wrapper.php index 3dfc06b..7ab80dd 100644 --- a/src/schema/Wrapper.php +++ b/src/schema/Wrapper.php @@ -23,10 +23,12 @@ abstract class Wrapper implements ArrayAccess, IteratorAggregate { $context = $this->context; $type = $context->schema->type; if (is_array($type)) $type = $type[0]; + if (is_string($type)) $type = types::get($context->schema->nullable, $type); $context->type = $type; $context->result->reset(); $context->analyzed = false; $context->normalized = false; + if ($resetSelectedKey) $context->selectedKey = null; } protected function afterModify(?array $params, $resetSelectedKey=false): void { diff --git a/src/schema/WrapperContext.php b/src/schema/WrapperContext.php index d22a81f..8199b52 100644 --- a/src/schema/WrapperContext.php +++ b/src/schema/WrapperContext.php @@ -1,13 +1,11 @@ resetParams($params); @@ -23,9 +21,9 @@ class WrapperContext { function resetParams(?array $params): void { $this->params = $params; - $this->analyze = $params["analyze"] ?? self::DEFAULT_ANALYZE; - $this->normalize = $params["normalize"] ?? self::DEFAULT_NORMALIZE; - $this->throw = $params["throw"] ?? self::DEFAULT_THROW; + $this->analyze = $params["analyze"] ?? ref_schema::PARAMS_SCHEMA["analyze"][1]; + $this->normalize = $params["normalize"] ?? ref_schema::PARAMS_SCHEMA["normalize"][1]; + $this->throw = $params["throw"] ?? ref_schema::PARAMS_SCHEMA["throw"][1]; } /** schéma de la valeur */ diff --git a/src/schema/_assoc/AssocSchema.php b/src/schema/_assoc/AssocSchema.php index 6c0156b..2183922 100644 --- a/src/schema/_assoc/AssocSchema.php +++ b/src/schema/_assoc/AssocSchema.php @@ -83,11 +83,11 @@ class AssocSchema extends Schema { $dontAnalyze = $value === null && $wrapper === null; if (!($wrapper instanceof AssocWrapper)) $wrapper = $this->newWrapper(); - # le schéma peut contenir des paramètres par défaut + # la nature du schéma peut contenir des paramètres par défaut $nature = $this->definition[""]; - foreach (array_keys(ref_schema::ASSOC_PARAMS_SCHEMA) as $key) { - $value = $nature[$key] ?? null; - if ($value !== null) $params[$key] = $value; + foreach (array_keys(ref_schema::ASSOC_PARAMS_SCHEMA) as $paramKey) { + $paramValue = $nature[$paramKey] ?? null; + if ($paramValue !== null) $params[$paramKey] = $paramValue; } if ($params !== null) $wrapper->resetParams($params); diff --git a/src/schema/_assoc/AssocWrapper.php b/src/schema/_assoc/AssocWrapper.php index 1c8f179..9e10bd7 100644 --- a/src/schema/_assoc/AssocWrapper.php +++ b/src/schema/_assoc/AssocWrapper.php @@ -41,14 +41,12 @@ class AssocWrapper extends Wrapper { protected WrapperContext $context; protected function resetContext($resetSelectedKey): void { + parent::resetContext($resetSelectedKey); $context = $this->context; $context->arrayWrapper->getResult()->reset(); foreach ($context->keyWrappers as $wrapper) { $wrapper->getResult()->reset(); } - $context->analyzed = false; - $context->normalized = false; - if ($resetSelectedKey) $context->selectedKey = null; } function reset(&$value, $valueKey=null, ?array $params=null): Wrapper { diff --git a/src/schema/_assoc/AssocWrapperContext.php b/src/schema/_assoc/AssocWrapperContext.php index 8512635..7536c5d 100644 --- a/src/schema/_assoc/AssocWrapperContext.php +++ b/src/schema/_assoc/AssocWrapperContext.php @@ -1,17 +1,12 @@ ensureArray = $params["ensure_array"] ?? self::DEFAULT_ENSURE_ARRAY; - $this->ensureAssoc = $params["ensure_assoc"] ?? self::DEFAULT_ENSURE_ASSOC; - $this->ensureKeys = $params["ensure_keys"] ?? self::DEFAULT_ENSURE_KEYS; - $this->ensureOrder = $params["ensure_order"] ?? self::DEFAULT_ENSURE_ORDER; + $this->ensureArray = $params["ensure_array"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_array"][1]; + $this->ensureAssoc = $params["ensure_assoc"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_assoc"][1]; + $this->ensureKeys = $params["ensure_keys"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_keys"][1]; + $this->ensureOrder = $params["ensure_order"] ?? ref_schema::ASSOC_PARAMS_SCHEMA["ensure_order"][1]; } public ?ScalarWrapper $arrayWrapper = null; diff --git a/src/schema/_list/ListResult.php b/src/schema/_list/ListResult.php index b40aadb..d05e464 100644 --- a/src/schema/_list/ListResult.php +++ b/src/schema/_list/ListResult.php @@ -12,8 +12,6 @@ class ListResult extends Result { parent::__construct(); } - function isList(?ListResult &$result=null): bool { $result = $this; return true;} - protected Result $arrayResult; /** @var Result[] */ diff --git a/src/schema/_scalar/ScalarResult.php b/src/schema/_scalar/ScalarResult.php index 59453eb..82714cd 100644 --- a/src/schema/_scalar/ScalarResult.php +++ b/src/schema/_scalar/ScalarResult.php @@ -14,8 +14,6 @@ use Throwable; * Class ScalarResult: résultat de l'analyse ou de la normalisation d'une valeur */ class ScalarResult extends Result { - function isScalar(?ScalarResult &$result=null): bool { $result = $this; return true; } - function getKeys(): array { return ScalarSchema::KEYS; } diff --git a/src/schema/_scalar/ScalarSchema.php b/src/schema/_scalar/ScalarSchema.php index 1a5dd8e..ec261bc 100644 --- a/src/schema/_scalar/ScalarSchema.php +++ b/src/schema/_scalar/ScalarSchema.php @@ -85,11 +85,11 @@ class ScalarSchema extends Schema { $dontAnalyze = $value === null && $wrapper === null; if (!($wrapper instanceof ScalarWrapper)) $wrapper = $this->newWrapper(); - # le schéma peut contenir des paramètres par défaut + # la nature du schéma peut contenir des paramètres par défaut $nature = $this->definition[""]; - foreach (array_keys(ref_schema::SCALAR_PARAMS_SCHEMA) as $key) { - $value = $nature[$key] ?? null; - if ($value !== null) $params[$key] = $value; + foreach (array_keys(ref_schema::SCALAR_PARAMS_SCHEMA) as $paramKey) { + $paramValue = $nature[$paramKey] ?? null; + if ($paramValue !== null) $params[$paramKey] = $paramValue; } if ($params !== null) $wrapper->resetParams($params); diff --git a/tests/wip/schema/_assoc/AssocSchemaTest.php b/tests/wip/schema/_assoc/AssocSchemaTest.php index cf5e9d4..d8552a7 100644 --- a/tests/wip/schema/_assoc/AssocSchemaTest.php +++ b/tests/wip/schema/_assoc/AssocSchemaTest.php @@ -203,7 +203,7 @@ class AssocSchemaTest extends TestCase { $array = self::STRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::STRINGS, $array); + self::assertSame(["s" => "string", "f" => false, "m" => ""], $array); $result = $wrapper->getResult("s"); self::assertTrue($result->normalized); $result = $wrapper->getResult("f"); @@ -219,7 +219,7 @@ class AssocSchemaTest extends TestCase { $array = self::NSTRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::NSTRINGS, $array); + self::assertSame(["s" => null, "f" => null, "m" => ""], $array); $result = $wrapper->getResult("s"); self::assertFalse($result->valid); self::assertSame("null", $result->messageKey); @@ -241,7 +241,7 @@ class AssocSchemaTest extends TestCase { $array = self::STRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::STRINGS, $array); + self::assertSame(["s" => "string", "f" => false, "m" => null], $array); $result = $wrapper->getResult("s"); self::assertTrue($result->normalized); $result = $wrapper->getResult("f"); @@ -257,7 +257,7 @@ class AssocSchemaTest extends TestCase { $array = self::NSTRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::NSTRINGS, $array); + self::assertSame(["s" => null, "f" => null, "m" => null], $array); $result = $wrapper->getResult("s"); self::assertTrue($result->normalized); $result = $wrapper->getResult("f"); @@ -277,7 +277,7 @@ class AssocSchemaTest extends TestCase { $array = self::STRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::STRINGS, $array); + self::assertSame(["s" => "string", "f" => false, "m" => ""], $array); $result = $wrapper->getResult("s"); self::assertTrue($result->normalized); $result = $wrapper->getResult("f"); @@ -295,7 +295,7 @@ class AssocSchemaTest extends TestCase { $array = self::NSTRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::NSTRINGS, $array); + self::assertSame(["s" => null, "f" => null, "m" => ""], $array); $result = $wrapper->getResult("s"); self::assertFalse($result->valid); self::assertSame("null", $result->messageKey); @@ -318,7 +318,7 @@ class AssocSchemaTest extends TestCase { $array = self::STRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::STRINGS, $array); + self::assertSame(["s" => "string", "f" => false, "m" => null], $array); $result = $wrapper->getResult("s"); self::assertTrue($result->normalized); $result = $wrapper->getResult("f"); @@ -336,7 +336,7 @@ class AssocSchemaTest extends TestCase { $array = self::NSTRINGS; $wrapper = $schema->getWrapper($array, null, ["throw" => false]); - self::assertSame(self::NSTRINGS, $array); + self::assertSame(["s" => null, "f" => null, "m" => null], $array); $result = $wrapper->getResult("s"); self::assertTrue($result->normalized); $result = $wrapper->getResult("f"); diff --git a/tests/wip/schema/_scalar/ScalarWrapperTest.php b/tests/wip/schema/_scalar/ScalarWrapperTest.php index a78e548..cc03952 100644 --- a/tests/wip/schema/_scalar/ScalarWrapperTest.php +++ b/tests/wip/schema/_scalar/ScalarWrapperTest.php @@ -15,7 +15,7 @@ class ScalarWrapperTest extends TestCase { self::assertSame($normalized, $wrapper->isNormalized(), "normalized"); } - function checkVerifix(ScalarSchema $schema, $orig, bool $normalize, $value, bool $present, bool $available, bool $valid, bool $normalized, ?array $inputParams=null): void { + function checkNormalize(ScalarSchema $schema, $orig, bool $normalize, $value, bool $present, bool $available, bool $valid, bool $normalized, ?array $inputParams=null): void { $wrapper = $schema->getWrapper(); $wrapper->resetParams(["normalize" => $normalize]); if ($inputParams !== null) $input = new Input($orig, $inputParams); @@ -36,261 +36,261 @@ class ScalarWrapperTest extends TestCase { function testRaw() { $schema = new ScalarSchema(); - $this->checkVerifix($schema, false, false, false, true, true, true, true); - $this->checkVerifix($schema, false, true, false, true, true, true, true); + $this->checkNormalize($schema, false, false, false, true, true, true, true); + $this->checkNormalize($schema, false, true, false, true, true, true, true); - $this->checkVerifix($schema, null, false, null, true, true, true, true); - $this->checkVerifix($schema, null, true, null, true, true, true, true); + $this->checkNormalize($schema, null, false, null, true, true, true, true); + $this->checkNormalize($schema, null, true, null, true, true, true, true); $obj = new stdClass(); - $this->checkVerifix($schema, $obj, false, $obj, true, true, true, true); - $this->checkVerifix($schema, $obj, true, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, false, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, true, $obj, true, true, true, true); $schema = new ScalarSchema("raw"); - $this->checkVerifix($schema, false, false, false, true, true, true, true); - $this->checkVerifix($schema, false, true, false, true, true, true, true); + $this->checkNormalize($schema, false, false, false, true, true, true, true); + $this->checkNormalize($schema, false, true, false, true, true, true, true); - $this->checkVerifix($schema, null, false, null, true, true, true, true); - $this->checkVerifix($schema, null, true, null, true, true, true, true); + $this->checkNormalize($schema, null, false, null, true, true, true, true); + $this->checkNormalize($schema, null, true, null, true, true, true, true); $obj = new stdClass(); - $this->checkVerifix($schema, $obj, false, $obj, true, true, true, true); - $this->checkVerifix($schema, $obj, true, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, false, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, true, $obj, true, true, true, true); } function testMixed() { $schema = new ScalarSchema("mixed"); - $this->checkVerifix($schema, false, false, false, true, true, true, true); - $this->checkVerifix($schema, false, true, false, true, true, true, true); + $this->checkNormalize($schema, false, false, false, true, true, true, true); + $this->checkNormalize($schema, false, true, false, true, true, true, true); - $this->checkVerifix($schema, null, false, null, true, true, false, false); + $this->checkNormalize($schema, null, false, null, true, true, false, false); $this->checkException($schema, null, true, ValueException::class); $obj = new stdClass(); - $this->checkVerifix($schema, $obj, false, $obj, true, true, true, true); - $this->checkVerifix($schema, $obj, true, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, false, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, true, $obj, true, true, true, true); $schema = new ScalarSchema("?mixed"); - $this->checkVerifix($schema, false, false, false, true, true, true, true); - $this->checkVerifix($schema, false, true, false, true, true, true, true); + $this->checkNormalize($schema, false, false, false, true, true, true, true); + $this->checkNormalize($schema, false, true, false, true, true, true, true); - $this->checkVerifix($schema, null, false, null, true, true, true, true); - $this->checkVerifix($schema, null, true, null, true, true, true, true); + $this->checkNormalize($schema, null, false, null, true, true, true, true); + $this->checkNormalize($schema, null, true, null, true, true, true, true); $obj = new stdClass(); - $this->checkVerifix($schema, $obj, false, $obj, true, true, true, true); - $this->checkVerifix($schema, $obj, true, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, false, $obj, true, true, true, true); + $this->checkNormalize($schema, $obj, true, $obj, true, true, true, true); } function testRawstring() { $schema = new ScalarSchema("rawstring"); - $this->checkVerifix($schema, false, false, null, true, false, true, true); - $this->checkVerifix($schema, false, true, null, true, false, true, true); + $this->checkNormalize($schema, false, false, null, true, false, true, true); + $this->checkNormalize($schema, false, true, null, true, false, true, true); - $this->checkVerifix($schema, null, false, null, true, true, false, false); + $this->checkNormalize($schema, null, false, null, true, true, false, false); $this->checkException($schema, null, true, ValueException::class); - $this->checkVerifix($schema, "", false, "", true, true, true, true); - $this->checkVerifix($schema, "", true, "", true, true, true, true); + $this->checkNormalize($schema, "", false, "", true, true, true, true); + $this->checkNormalize($schema, "", true, "", true, true, true, true); - $this->checkVerifix($schema, " ", false, " ", true, true, true, true); - $this->checkVerifix($schema, " ", true, " ", true, true, true, true); + $this->checkNormalize($schema, " ", false, " ", true, true, true, true); + $this->checkNormalize($schema, " ", true, " ", true, true, true, true); - $this->checkVerifix($schema, "text", false, "text", true, true, true, true); - $this->checkVerifix($schema, "text", true, "text", true, true, true, true); + $this->checkNormalize($schema, "text", false, "text", true, true, true, true); + $this->checkNormalize($schema, "text", true, "text", true, true, true, true); - $this->checkVerifix($schema, " text ", false, " text ", true, true, true, true); - $this->checkVerifix($schema, " text ", true, " text ", true, true, true, true); + $this->checkNormalize($schema, " text ", false, " text ", true, true, true, true); + $this->checkNormalize($schema, " text ", true, " text ", true, true, true, true); - $this->checkVerifix($schema, true, false, true, true, true, true, false); - $this->checkVerifix($schema, true, true, "1", true, true, true, false); + $this->checkNormalize($schema, true, false, true, true, true, true, false); + $this->checkNormalize($schema, true, true, "1", true, true, true, false); - $this->checkVerifix($schema, 42, false, 42, true, true, true, false); - $this->checkVerifix($schema, 42, true, "42", true, true, true, false); + $this->checkNormalize($schema, 42, false, 42, true, true, true, false); + $this->checkNormalize($schema, 42, true, "42", true, true, true, false); - $this->checkVerifix($schema, [], false, [], true, true, false, false); + $this->checkNormalize($schema, [], false, [], true, true, false, false); $this->checkException($schema, [], true, ValueException::class); ## Tester valeur par défaut $schema = new ScalarSchema(["rawstring", null]); - $this->checkVerifix($schema, false, false, null, true, false, true, true); - $this->checkVerifix($schema, false, true, null, true, false, true, true); + $this->checkNormalize($schema, false, false, null, true, false, true, true); + $this->checkNormalize($schema, false, true, null, true, false, true, true); - $this->checkVerifix($schema, null, false, null, true, true, false, false); + $this->checkNormalize($schema, null, false, null, true, true, false, false); $this->checkException($schema, null, true, ValueException::class); $schema = new ScalarSchema(["rawstring", "default"]); - $this->checkVerifix($schema, false, false, "default", true, true, true, true); - $this->checkVerifix($schema, false, true, "default", true, true, true, true); + $this->checkNormalize($schema, false, false, "default", true, true, true, true); + $this->checkNormalize($schema, false, true, "default", true, true, true, true); - $this->checkVerifix($schema, null, false, null, true, true, false, false); + $this->checkNormalize($schema, null, false, null, true, true, false, false); $this->checkException($schema, null, true, ValueException::class); ## Tester nullable $schema = new ScalarSchema("?rawstring"); - $this->checkVerifix($schema, null, false, null, true, true, true, true); - $this->checkVerifix($schema, null, true, null, true, true, true, true); + $this->checkNormalize($schema, null, false, null, true, true, true, true); + $this->checkNormalize($schema, null, true, null, true, true, true, true); ## Tester required $schema = new ScalarSchema(["rawstring", "required" => true]); - $this->checkVerifix($schema, false, false, null, true, false, false, false); + $this->checkNormalize($schema, false, false, null, true, false, false, false); $this->checkException($schema, false, true, ValueException::class); ## Tester allow_empty === false $inputParams = ["allow_empty" => false]; $schema = new ScalarSchema("rawstring"); - $this->checkVerifix($schema, null, false, null, true, true, false, false, $inputParams); + $this->checkNormalize($schema, null, false, null, true, true, false, false, $inputParams); $this->checkException($schema, null, true, ValueException::class, $inputParams); - $this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams); - $this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams); $schema = new ScalarSchema("?rawstring"); - $this->checkVerifix($schema, null, false, null, true, true, true, true, $inputParams); - $this->checkVerifix($schema, null, true, null, true, true, true, true, $inputParams); + $this->checkNormalize($schema, null, false, null, true, true, true, true, $inputParams); + $this->checkNormalize($schema, null, true, null, true, true, true, true, $inputParams); - $this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams); - $this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams); } function testString() { $schema = new ScalarSchema("string"); - $this->checkVerifix($schema, false, false, null, true, false, true, true); - $this->checkVerifix($schema, false, true, null, true, false, true, true); + $this->checkNormalize($schema, false, false, null, true, false, true, true); + $this->checkNormalize($schema, false, true, null, true, false, true, true); - $this->checkVerifix($schema, null, false, null, true, true, false, false); + $this->checkNormalize($schema, null, false, null, true, true, false, false); $this->checkException($schema, null, true, ValueException::class); - $this->checkVerifix($schema, "", false, "", true, true, true, true); - $this->checkVerifix($schema, "", true, "", true, true, true, true); + $this->checkNormalize($schema, "", false, "", true, true, true, true); + $this->checkNormalize($schema, "", true, "", true, true, true, true); - $this->checkVerifix($schema, " ", false, "", true, true, true, false); - $this->checkVerifix($schema, " ", true, "", true, true, true, false); + $this->checkNormalize($schema, " ", false, "", true, true, true, false); + $this->checkNormalize($schema, " ", true, "", true, true, true, false); - $this->checkVerifix($schema, "text", false, "text", true, true, true, true); - $this->checkVerifix($schema, "text", true, "text", true, true, true, true); + $this->checkNormalize($schema, "text", false, "text", true, true, true, true); + $this->checkNormalize($schema, "text", true, "text", true, true, true, true); - $this->checkVerifix($schema, " text ", false, "text", true, true, true, false); - $this->checkVerifix($schema, " text ", true, "text", true, true, true, false); + $this->checkNormalize($schema, " text ", false, "text", true, true, true, false); + $this->checkNormalize($schema, " text ", true, "text", true, true, true, false); - $this->checkVerifix($schema, true, false, true, true, true, true, false); - $this->checkVerifix($schema, true, true, "1", true, true, true, false); + $this->checkNormalize($schema, true, false, true, true, true, true, false); + $this->checkNormalize($schema, true, true, "1", true, true, true, false); - $this->checkVerifix($schema, 42, false, 42, true, true, true, false); - $this->checkVerifix($schema, 42, true, "42", true, true, true, false); + $this->checkNormalize($schema, 42, false, 42, true, true, true, false); + $this->checkNormalize($schema, 42, true, "42", true, true, true, false); - $this->checkVerifix($schema, [], false, [], true, true, false, false); + $this->checkNormalize($schema, [], false, [], true, true, false, false); $this->checkException($schema, [], true, ValueException::class); ## Tester nullable $schema = new ScalarSchema("?string"); - $this->checkVerifix($schema, null, false, null, true, true, true, true); - $this->checkVerifix($schema, null, true, null, true, true, true, true); + $this->checkNormalize($schema, null, false, null, true, true, true, true); + $this->checkNormalize($schema, null, true, null, true, true, true, true); ## Tester required $schema = new ScalarSchema(["string", "required" => true]); - $this->checkVerifix($schema, false, false, null, true, false, false, false); + $this->checkNormalize($schema, false, false, null, true, false, false, false); $this->checkException($schema, false, true, ValueException::class); ## Tester allow_empty === false $inputParams = ["allow_empty" => false]; $schema = new ScalarSchema("string"); - $this->checkVerifix($schema, null, false, null, true, true, false, false, $inputParams); + $this->checkNormalize($schema, null, false, null, true, true, false, false, $inputParams); $this->checkException($schema, null, true, ValueException::class, $inputParams); - $this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams); - $this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams); $schema = new ScalarSchema("?string"); - $this->checkVerifix($schema, null, false, null, true, true, true, true, $inputParams); - $this->checkVerifix($schema, null, true, null, true, true, true, true, $inputParams); + $this->checkNormalize($schema, null, false, null, true, true, true, true, $inputParams); + $this->checkNormalize($schema, null, true, null, true, true, true, true, $inputParams); - $this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams); - $this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams); } function testInt() { $schema = new ScalarSchema("int"); - $this->checkVerifix($schema, false, false, null, true, false, true, true); - $this->checkVerifix($schema, false, true, null, true, false, true, true); + $this->checkNormalize($schema, false, false, null, true, false, true, true); + $this->checkNormalize($schema, false, true, null, true, false, true, true); - $this->checkVerifix($schema, null, false, null, true, true, false, false); + $this->checkNormalize($schema, null, false, null, true, true, false, false); $this->checkException($schema, null, true, ValueException::class); - $this->checkVerifix($schema, 42, false, 42, true, true, true, true); - $this->checkVerifix($schema, 42, true, 42, true, true, true, true); + $this->checkNormalize($schema, 42, false, 42, true, true, true, true); + $this->checkNormalize($schema, 42, true, 42, true, true, true, true); - $this->checkVerifix($schema, "42", false, "42", true, true, true, false); - $this->checkVerifix($schema, "42", true, 42, true, true, true, false); + $this->checkNormalize($schema, "42", false, "42", true, true, true, false); + $this->checkNormalize($schema, "42", true, 42, true, true, true, false); - $this->checkVerifix($schema, "42.5", false, "42.5", true, true, true, false); - $this->checkVerifix($schema, "42.5", true, 42, true, true, true, false); + $this->checkNormalize($schema, "42.5", false, "42.5", true, true, true, false); + $this->checkNormalize($schema, "42.5", true, 42, true, true, true, false); - $this->checkVerifix($schema, "42,5", false, "42,5", true, true, true, false); - $this->checkVerifix($schema, "42,5", true, 42, true, true, true, false); + $this->checkNormalize($schema, "42,5", false, "42,5", true, true, true, false); + $this->checkNormalize($schema, "42,5", true, 42, true, true, true, false); - $this->checkVerifix($schema, " 42 ", false, "42", true, true, true, false); - $this->checkVerifix($schema, " 42 ", true, 42, true, true, true, false); + $this->checkNormalize($schema, " 42 ", false, "42", true, true, true, false); + $this->checkNormalize($schema, " 42 ", true, 42, true, true, true, false); - $this->checkVerifix($schema, "", false, "", true, true, false, false); + $this->checkNormalize($schema, "", false, "", true, true, false, false); $this->checkException($schema, "", true, ValueException::class); - $this->checkVerifix($schema, " ", false, " ", true, true, false, false); + $this->checkNormalize($schema, " ", false, " ", true, true, false, false); $this->checkException($schema, " ", true, ValueException::class); - $this->checkVerifix($schema, "text", false, "text", true, true, false, false); + $this->checkNormalize($schema, "text", false, "text", true, true, false, false); $this->checkException($schema, "text", true, ValueException::class); - $this->checkVerifix($schema, true, false, true, true, true, true, false); - $this->checkVerifix($schema, true, true, 1, true, true, true, false); + $this->checkNormalize($schema, true, false, true, true, true, true, false); + $this->checkNormalize($schema, true, true, 1, true, true, true, false); - $this->checkVerifix($schema, [], false, [], true, true, false, false); + $this->checkNormalize($schema, [], false, [], true, true, false, false); $this->checkException($schema, [], true, ValueException::class); ## Tester nullable $schema = new ScalarSchema("?int"); - $this->checkVerifix($schema, null, false, null, true, true, true, true); - $this->checkVerifix($schema, null, true, null, true, true, true, true); + $this->checkNormalize($schema, null, false, null, true, true, true, true); + $this->checkNormalize($schema, null, true, null, true, true, true, true); ## Tester required $schema = new ScalarSchema(["int", "required" => true]); - $this->checkVerifix($schema, false, false, null, true, false, false, false); + $this->checkNormalize($schema, false, false, null, true, false, false, false); $this->checkException($schema, false, true, ValueException::class); ## Tester allow_empty === false $inputParams = ["allow_empty" => false]; $schema = new ScalarSchema("int"); - $this->checkVerifix($schema, null, false, null, true, true, false, false, $inputParams); + $this->checkNormalize($schema, null, false, null, true, true, false, false, $inputParams); $this->checkException($schema, null, true, ValueException::class, $inputParams); - $this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams); - $this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams); $schema = new ScalarSchema("?int"); - $this->checkVerifix($schema, null, false, null, true, true, true, true, $inputParams); - $this->checkVerifix($schema, null, true, null, true, true, true, true, $inputParams); + $this->checkNormalize($schema, null, false, null, true, true, true, true, $inputParams); + $this->checkNormalize($schema, null, true, null, true, true, true, true, $inputParams); - $this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams); - $this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams); + $this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams); } }