<?php
namespace nur\sery\wip\schema\types;

use nur\sery\wip\schema\_scalar\ScalarResult;
use nur\sery\wip\schema\_scalar\ScalarSchema;
use nur\sery\wip\schema\input\Input;
use nur\sery\wip\schema\Result;
use nur\sery\wip\schema\Schema;

class tmixed extends _tsimple {
  const NAME = "mixed";

  function getClass(): string {
    return "mixed";
  }

  function isAvailable(Input $input, $valueKey): bool {
    return $input->isAvailable($valueKey);
  }

  public function isNull($value): bool {
    return $value === null;
  }

  function isValid($value, ?bool &$normalized=null): bool {
    $normalized = true;
    return true;
  }

  function parse(string $value) {
    return $value;
  }

  /**
   * @var ScalarResult $result
   * @var ScalarSchema $schema
   */
  function verifix(&$value, Result $result, Schema $schema): bool {
    $result->setNormalized();
    return false;
  }

  function format($value, $format=null): string {
    return var_export($value, true);
  }
}
