compat php8.2

This commit is contained in:
Jephté Clain 2024-10-04 14:22:43 +04:00
parent c88277a6d6
commit a03de2a099
21 changed files with 30 additions and 30 deletions

View File

@ -49,7 +49,7 @@ class c {
* s'assurer que la valeur est une chaine si elle n'est pas nulle et que ce * s'assurer que la valeur est une chaine si elle n'est pas nulle et que ce
* n'est pas déjà une instance de {@link IPrintable} ou {@link IContent} * n'est pas déjà une instance de {@link IPrintable} ou {@link IContent}
*/ */
private static final function _strval($value) { private static function _strval($value) {
if ($value === null) { #NOP if ($value === null) { #NOP
} elseif ($value instanceof IPrintable) { #NOP } elseif ($value instanceof IPrintable) { #NOP
} elseif ($value instanceof IContent) { #NOP } elseif ($value instanceof IContent) { #NOP
@ -58,7 +58,7 @@ class c {
} }
/** fusionner deux valeurs */ /** fusionner deux valeurs */
private static final function _merge($pvalue, $value) { private static function _merge($pvalue, $value) {
if (!$pvalue) { if (!$pvalue) {
# prendre $value # prendre $value
if (!is_iterable($value)) $value = self::_strval($value); if (!is_iterable($value)) $value = self::_strval($value);

View File

@ -45,7 +45,7 @@ class EnvConfig extends DynConfig {
protected $config; protected $config;
/** analyser $name et retourner [$pkey, $profile] */ /** analyser $name et retourner [$pkey, $profile] */
private static final function parse_pkey_profile($name): array { private static function parse_pkey_profile($name): array {
$i = strpos($name, "_"); $i = strpos($name, "_");
if ($i === false) return [false, false]; if ($i === false) return [false, false];
$profile = substr($name, 0, $i); $profile = substr($name, 0, $i);
@ -55,7 +55,7 @@ class EnvConfig extends DynConfig {
return [$pkey, $profile]; return [$pkey, $profile];
} }
private static final function invalid_json_data(string $pkey, string $profile, ?string $prefix, ?Throwable $e): ConfigException { private static function invalid_json_data(string $pkey, string $profile, ?string $prefix, ?Throwable $e): ConfigException {
if ($prefix !== null) $prefix = "$prefix: "; if ($prefix !== null) $prefix = "$prefix: ";
return new ConfigException("${prefix}invalid json data for $profile:$pkey", 0, $e); return new ConfigException("${prefix}invalid json data for $profile:$pkey", 0, $e);
} }

View File

@ -45,7 +45,7 @@ class InterpTemplate extends SimpleContext implements ITemplate {
* - si $quote===false ou null, ne pas la mettre en échappement * - si $quote===false ou null, ne pas la mettre en échappement
* - sinon, ce doit être une fonction qui met la valeur en échappement * - sinon, ce doit être une fonction qui met la valeur en échappement
*/ */
private static final function quote($value, $quote) { private static function quote($value, $quote) {
if (A::is_array($value)) $value = print_r(A::with($value), true); if (A::is_array($value)) $value = print_r(A::with($value), true);
elseif (!is_string($value)) $value = strval($value); elseif (!is_string($value)) $value = strval($value);
if ($quote === true) return htmlspecialchars($value); if ($quote === true) return htmlspecialchars($value);
@ -61,7 +61,7 @@ class InterpTemplate extends SimpleContext implements ITemplate {
* décider comment traiter la valeur et sa valeur par défaut est true. * décider comment traiter la valeur et sa valeur par défaut est true.
* - Sinon prendre la valeur $quote telle quelle * - Sinon prendre la valeur $quote telle quelle
*/ */
private static final function quote_nv(string $name, $value, $quote) { private static function quote_nv(string $name, $value, $quote) {
if (is_array($quote)) { if (is_array($quote)) {
if (isset($quote[$name])) { if (isset($quote[$name])) {
$value = self::quote($value, $quote[$name]); $value = self::quote($value, $quote[$name]);

View File

@ -271,7 +271,7 @@ class func {
const METHOD_PS = ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_STATIC; const METHOD_PS = ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_STATIC;
const METHOD_P = ReflectionMethod::IS_PUBLIC; const METHOD_P = ReflectionMethod::IS_PUBLIC;
private static final function matches(string $name, array $includes, array $excludes): bool { private static function matches(string $name, array $includes, array $excludes): bool {
if ($includes) { if ($includes) {
$matches = false; $matches = false;
foreach ($includes as $include) { foreach ($includes as $include) {

View File

@ -10,7 +10,7 @@ class interp {
/** @var InterpTemplate */ /** @var InterpTemplate */
private static $t; private static $t;
private static final function t(): InterpTemplate { private static function t(): InterpTemplate {
if (self::$t === null) self::$t = new InterpTemplate(); if (self::$t === null) self::$t = new InterpTemplate();
return self::$t; return self::$t;
} }

View File

@ -8,7 +8,7 @@ use nur\str;
* Class Assoc2CsvHelper: outils pour écrire un flux au format CSV * Class Assoc2CsvHelper: outils pour écrire un flux au format CSV
*/ */
class Assoc2CsvHelper { class Assoc2CsvHelper {
private static final function is_different(array $h1, array $h2): bool { private static function is_different(array $h1, array $h2): bool {
sort($h1); sort($h1);
sort($h2); sort($h2);
return $h1 != $h2; return $h1 != $h2;

View File

@ -18,7 +18,7 @@ use Traversable;
* Class iter: gestion des itérateurs * Class iter: gestion des itérateurs
*/ */
class iter { class iter {
private static final function unexpected_type($object): ValueException { private static function unexpected_type($object): ValueException {
return ValueException::unexpected_type("iterable", $object); return ValueException::unexpected_type("iterable", $object);
} }

View File

@ -34,7 +34,7 @@ class Assoc2CsvMapper extends AbstractCsvMapper {
/** @var bool faut-il afficher les en-têtes en sortie? */ /** @var bool faut-il afficher les en-têtes en sortie? */
protected $ppOutputHeaders = true; protected $ppOutputHeaders = true;
private static final function is_different(array $h1, array $h2): bool { private static function is_different(array $h1, array $h2): bool {
sort($h1); sort($h1);
sort($h2); sort($h2);
return $h1 != $h2; return $h1 != $h2;

View File

@ -40,7 +40,7 @@ class Assoc2SeqMapper extends Mapper {
/** @var bool faut-il afficher les en-têtes en sortie? */ /** @var bool faut-il afficher les en-têtes en sortie? */
protected $ppOutputKeys; protected $ppOutputKeys;
private static final function is_different(array $h1, array $h2): bool { private static function is_different(array $h1, array $h2): bool {
sort($h1); sort($h1);
sort($h2); sort($h2);
return $h1 != $h2; return $h1 != $h2;

View File

@ -215,7 +215,7 @@ class md {
} }
} }
private static final function _ensure_array_item(&$item, ?array $schema, $item_key): void { private static function _ensure_array_item(&$item, ?array $schema, $item_key): void {
if ($item_key !== null) { if ($item_key !== null) {
if (is_array($item)) { if (is_array($item)) {
if ($schema !== null) { if ($schema !== null) {
@ -235,7 +235,7 @@ class md {
} }
} }
private static final function _ensure_schema_recursive(&$item, array $schema, ?array $indexes=null): void { private static function _ensure_schema_recursive(&$item, array $schema, ?array $indexes=null): void {
self::_ensure_schema($item, $schema, $indexes); self::_ensure_schema($item, $schema, $indexes);
foreach ($schema as $key => $sfield) { foreach ($schema as $key => $sfield) {
$schema2 = $sfield["schema"]; $schema2 = $sfield["schema"];
@ -340,7 +340,7 @@ class md {
* les types simples sont reconnus. s'il s'agit d'un type complexe, la valeur * les types simples sont reconnus. s'il s'agit d'un type complexe, la valeur
* n'est pas vérifiée ni modifiée * n'est pas vérifiée ni modifiée
*/ */
private static final function _ensure_type(?string $type, &$value, $default, bool $exists): void { private static function _ensure_type(?string $type, &$value, $default, bool $exists): void {
if (self::_check_known_type($type, $value, $default, $exists)) { if (self::_check_known_type($type, $value, $default, $exists)) {
self::_convert_value($type, $value); self::_convert_value($type, $value);
} }

View File

@ -11,7 +11,7 @@ namespace nur;
* @see \nur\v\vo * @see \nur\v\vo
*/ */
class out { class out {
private static final function _print(?string $prefix, string $sep, array $values, ?string $suffix): void { private static function _print(?string $prefix, string $sep, array $values, ?string $suffix): void {
if ($prefix !== null) echo $prefix; if ($prefix !== null) echo $prefix;
echo implode($sep, $values); echo implode($sep, $values);
if ($suffix !== null) echo $suffix; if ($suffix !== null) echo $suffix;

View File

@ -51,7 +51,7 @@ class prop {
return self::_set($c, $object, $property, $value, $method); return self::_set($c, $object, $property, $value, $method);
} }
private static final function _set(ReflectionClass $c, object $object, string $property, $value, ?string $method) { private static function _set(ReflectionClass $c, object $object, string $property, $value, ?string $method) {
if ($method === null) $method = self::get_setter_name($property); if ($method === null) $method = self::get_setter_name($property);
try { try {
$m = $c->getMethod($method); $m = $c->getMethod($method);

View File

@ -53,7 +53,7 @@ class shell {
return implode(" ", $parts); return implode(" ", $parts);
} }
private static final function add_redir(string &$cmd, ?string $redir, ?string $input, ?string $output): void { private static function add_redir(string &$cmd, ?string $redir, ?string $input, ?string $output): void {
if ($redir !== null) { if ($redir !== null) {
switch ($redir) { switch ($redir) {
case "outonly": case "outonly":

View File

@ -104,7 +104,7 @@ class txt {
return implode("", $ucwords); return implode("", $ucwords);
} }
private static final function _starts_with(string $prefix, string $s, ?int $min_len=null): bool { private static function _starts_with(string $prefix, string $s, ?int $min_len=null): bool {
if ($prefix === $s) return true; if ($prefix === $s) return true;
$len = mb_strlen($prefix); $len = mb_strlen($prefix);
if ($min_len !== null && ($len < $min_len || $len > mb_strlen($s))) return false; if ($min_len !== null && ($len < $min_len || $len > mb_strlen($s))) return false;
@ -163,7 +163,7 @@ class txt {
$s = self::with_prefix($prefix, $s, null, $unless_exists); $s = self::with_prefix($prefix, $s, null, $unless_exists);
} }
private static final function _ends_with(?string $suffix, string $s, ?int $min_len=null): bool { private static function _ends_with(?string $suffix, string $s, ?int $min_len=null): bool {
if ($suffix === $s) return true; if ($suffix === $s) return true;
$len = mb_strlen($suffix); $len = mb_strlen($suffix);
if ($min_len !== null && ($len < $min_len || $len > mb_strlen($s))) return false; if ($min_len !== null && ($len < $min_len || $len > mb_strlen($s))) return false;

View File

@ -52,7 +52,7 @@ class RouteManager implements IRouteManager {
/** @var array routes pour des préfixes de chemin */ /** @var array routes pour des préfixes de chemin */
protected $proutes; protected $proutes;
private static final function get_package(?string $class): ?string { private static function get_package(?string $class): ?string {
if ($class === null) return null; if ($class === null) return null;
str::del_prefix($class, "\\"); str::del_prefix($class, "\\");
if (($pos = strrpos($class, "\\")) === false) return ""; if (($pos = strrpos($class, "\\")) === false) return "";

View File

@ -43,7 +43,7 @@ class Bs3NavbarManager extends TagsManager implements INavbarManager {
return [$class, $style]; return [$class, $style];
} }
private static final function get_align_class($align): ?string { private static function get_align_class($align): ?string {
if ($align === null) return null; if ($align === null) return null;
switch ($align) { switch ($align) {
case "navbar-left": case "navbar-left":

View File

@ -171,7 +171,7 @@ class page {
http::download_as($filename, $disposition); http::download_as($filename, $disposition);
} }
private static final function _get_url($dest): string { private static function _get_url($dest): string {
if ($dest === null) $url = self::self(); if ($dest === null) $url = self::self();
elseif ($dest === true || is_array($dest)) $url = self::self($dest); elseif ($dest === true || is_array($dest)) $url = self::self($dest);
else $url = self::bu($dest); else $url = self::bu($dest);

View File

@ -51,7 +51,7 @@ class sh {
return implode(" ", $parts); return implode(" ", $parts);
} }
private static final function add_redir(string &$cmd, ?string $redir, ?string $input, ?string $output): void { private static function add_redir(string &$cmd, ?string $redir, ?string $input, ?string $output): void {
if ($redir !== null) { if ($redir !== null) {
switch ($redir) { switch ($redir) {
case "outonly": case "outonly":

View File

@ -26,7 +26,7 @@ class c {
} }
const nq = [self::class, "nq"]; const nq = [self::class, "nq"];
private static final function add_static_content(array &$dest, iterable $values, $key, bool $seq): void { private static function add_static_content(array &$dest, iterable $values, $key, bool $seq): void {
$sindex = 0; $sindex = 0;
foreach ($values as $skey => $svalue) { foreach ($values as $skey => $svalue) {
if ($skey === $sindex) { if ($skey === $sindex) {
@ -102,14 +102,14 @@ class c {
} }
const resolve = [self::class, "resolve"]; const resolve = [self::class, "resolve"];
private static final function wend(?string $value): bool { private static function wend(?string $value): bool {
return $value !== null && preg_match('/(\w|\w\.)$/', $value); return $value !== null && preg_match('/(\w|\w\.)$/', $value);
} }
private static final function startw(?string $value): bool { private static function startw(?string $value): bool {
return $value !== null && preg_match('/^\w/', $value); return $value !== null && preg_match('/^\w/', $value);
} }
private static final function to_values($content, ?array &$values=null): void { private static function to_values($content, ?array &$values=null): void {
$pvalue = cl::last($values); $pvalue = cl::last($values);
$wend = self::wend($pvalue); $wend = self::wend($pvalue);
foreach ($content as $value) { foreach ($content as $value) {

View File

@ -53,7 +53,7 @@ class mprop {
return self::_set($c, $object, $property, $value, $method); return self::_set($c, $object, $property, $value, $method);
} }
private static final function _set(ReflectionClass $c, object $object, string $property, $value, ?string $method) { private static function _set(ReflectionClass $c, object $object, string $property, $value, ?string $method) {
if ($method === null) $method = self::get_setter_name($property); if ($method === null) $method = self::get_setter_name($property);
try { try {
$m = $c->getMethod($method); $m = $c->getMethod($method);

View File

@ -267,7 +267,7 @@ class nur_func {
const METHOD_PS = ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_STATIC; const METHOD_PS = ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_STATIC;
const METHOD_P = ReflectionMethod::IS_PUBLIC; const METHOD_P = ReflectionMethod::IS_PUBLIC;
private static final function matches(string $name, array $includes, array $excludes): bool { private static function matches(string $name, array $includes, array $excludes): bool {
if ($includes) { if ($includes) {
$matches = false; $matches = false;
foreach ($includes as $include) { foreach ($includes as $include) {