modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2025-04-02 22:21:16 +04:00
parent c4e02d5bcf
commit d844bd03ad
11 changed files with 141 additions and 158 deletions

View File

@ -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

View File

@ -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 {

View File

@ -1,13 +1,11 @@
<?php
namespace nur\sery\wip\schema;
use nulib\ref\schema\ref_schema;
use nur\sery\wip\schema\input\Input;
use nur\sery\wip\schema\types\IType;
class WrapperContext {
const DEFAULT_ANALYZE = true;
const DEFAULT_NORMALIZE = true;
const DEFAULT_THROW = true;
function __construct(Schema $schema, ?Input $input, $valueKey, ?array $params) {
$this->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 */

View File

@ -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);

View File

@ -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 {

View File

@ -1,17 +1,12 @@
<?php
namespace nur\sery\wip\schema\_assoc;
use nulib\ref\schema\ref_schema;
use nur\sery\wip\schema\_scalar\ScalarWrapper;
use nur\sery\wip\schema\input\Input;
use nur\sery\wip\schema\Schema;
use nur\sery\wip\schema\Wrapper;
use nur\sery\wip\schema\WrapperContext;
class AssocWrapperContext extends WrapperContext {
const DEFAULT_ENSURE_ARRAY = false;
const DEFAULT_ENSURE_ASSOC = true;
const DEFAULT_ENSURE_KEYS = true;
const DEFAULT_ENSURE_ORDER = true;
public bool $ensureArray;
public bool $ensureAssoc;
@ -20,10 +15,10 @@ class AssocWrapperContext extends WrapperContext {
public function resetParams(?array $params): void {
parent::resetParams($params);
$this->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;

View File

@ -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[] */

View File

@ -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;
}

View File

@ -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);

View File

@ -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");

View File

@ -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);
}
}