Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
97 lines
2.8 KiB
PHP
97 lines
2.8 KiB
PHP
<?php declare(strict_types=1);
|
||
|
||
/**
|
||
* This file is part of the Nette Framework (https://nette.org)
|
||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||
*/
|
||
|
||
namespace Nette\Schema;
|
||
|
||
use function array_key_exists, implode, preg_replace_callback;
|
||
|
||
|
||
/**
|
||
* Represents a single validation error or warning with a message template, error code, path, and variables.
|
||
*/
|
||
final class Message
|
||
{
|
||
/** variables: {value: mixed, expected: string} */
|
||
public const TypeMismatch = 'schema.typeMismatch';
|
||
|
||
/** variables: {value: mixed, expected: string} */
|
||
public const ValueOutOfRange = 'schema.valueOutOfRange';
|
||
|
||
/** variables: {value: mixed, length: int, expected: string} */
|
||
public const LengthOutOfRange = 'schema.lengthOutOfRange';
|
||
|
||
/** variables: {value: string, pattern: string} */
|
||
public const PatternMismatch = 'schema.patternMismatch';
|
||
|
||
/** variables: {value: mixed, assertion: string} */
|
||
public const FailedAssertion = 'schema.failedAssertion';
|
||
|
||
/** no variables */
|
||
public const MissingItem = 'schema.missingItem';
|
||
|
||
/** variables: {hint: string} */
|
||
public const UnexpectedItem = 'schema.unexpectedItem';
|
||
|
||
/** no variables */
|
||
public const Deprecated = 'schema.deprecated';
|
||
|
||
/** @deprecated use Message::TypeMismatch */
|
||
public const TYPE_MISMATCH = self::TypeMismatch;
|
||
|
||
/** @deprecated use Message::ValueOutOfRange */
|
||
public const VALUE_OUT_OF_RANGE = self::ValueOutOfRange;
|
||
|
||
/** @deprecated use Message::LengthOutOfRange */
|
||
public const LENGTH_OUT_OF_RANGE = self::LengthOutOfRange;
|
||
|
||
/** @deprecated use Message::PatternMismatch */
|
||
public const PATTERN_MISMATCH = self::PatternMismatch;
|
||
|
||
/** @deprecated use Message::FailedAssertion */
|
||
public const FAILED_ASSERTION = self::FailedAssertion;
|
||
|
||
/** @deprecated use Message::MissingItem */
|
||
public const MISSING_ITEM = self::MissingItem;
|
||
|
||
/** @deprecated use Message::UnexpectedItem */
|
||
public const UNEXPECTED_ITEM = self::UnexpectedItem;
|
||
|
||
/** @deprecated use Message::Deprecated */
|
||
public const DEPRECATED = self::Deprecated;
|
||
|
||
|
||
public function __construct(
|
||
public string $message,
|
||
public string $code,
|
||
/** @var list<int|string> */
|
||
public array $path,
|
||
/** @var array<string, mixed> */
|
||
public array $variables = [],
|
||
) {
|
||
}
|
||
|
||
|
||
/**
|
||
* Formats the message template by substituting %variable% placeholders with their values.
|
||
*/
|
||
public function toString(): string
|
||
{
|
||
$vars = $this->variables;
|
||
$vars['label'] = empty($vars['isKey']) ? 'item' : 'key of item';
|
||
$vars['path'] = $this->path
|
||
? "'" . implode("\u{a0}›\u{a0}", $this->path) . "'"
|
||
: null;
|
||
$vars['value'] = Helpers::formatValue($vars['value'] ?? null);
|
||
|
||
return preg_replace_callback('~( ?)%(\w+)%~', function ($m) use ($vars) {
|
||
[, $space, $key] = $m;
|
||
return array_key_exists($key, $vars)
|
||
? ($vars[$key] === null ? '' : $space . $vars[$key])
|
||
: $m[0];
|
||
}, $this->message);
|
||
}
|
||
}
|