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>
106 lines
3.5 KiB
PHP
106 lines
3.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\Serializer\Mapping\Loader;
|
|
|
|
use Symfony\Component\Serializer\Attribute\Ignore;
|
|
|
|
/**
|
|
* Provides methods to detect accessor name collisions during serialization.
|
|
*
|
|
* @internal
|
|
*/
|
|
trait AccessorCollisionResolverTrait
|
|
{
|
|
private function getAttributeNameFromAccessor(\ReflectionClass $class, \ReflectionMethod $method, bool $andMutator): ?string
|
|
{
|
|
$methodName = $method->name;
|
|
|
|
$i = match ($methodName[0]) {
|
|
's' => $andMutator && str_starts_with($methodName, 'set') ? 3 : null,
|
|
'g' => str_starts_with($methodName, 'get') ? 3 : null,
|
|
'h' => str_starts_with($methodName, 'has') ? 3 : null,
|
|
'c' => str_starts_with($methodName, 'can') ? 3 : null,
|
|
'i' => str_starts_with($methodName, 'is') ? 2 : null,
|
|
default => null,
|
|
};
|
|
|
|
// ctype_lower check to find out if method looks like accessor but actually is not, e.g. hash, cancel
|
|
if (null === $i || ctype_lower($methodName[$i] ?? 'a') || (!$andMutator && $method->isStatic())) {
|
|
return null;
|
|
}
|
|
|
|
if ('s' === $methodName[0] ? !$method->getNumberOfParameters() : ($method->getNumberOfRequiredParameters() || \in_array((string) $method->getReturnType(), ['void', 'never'], true))) {
|
|
return null;
|
|
}
|
|
|
|
$attributeName = substr($methodName, $i);
|
|
|
|
if (!$class->hasProperty($attributeName)) {
|
|
$attributeName = lcfirst($attributeName);
|
|
}
|
|
|
|
return $attributeName;
|
|
}
|
|
|
|
private function hasPropertyForAccessor(\ReflectionClass $class, string $propName): bool
|
|
{
|
|
do {
|
|
if ($class->hasProperty($propName)) {
|
|
return true;
|
|
}
|
|
} while ($class = $class->getParentClass());
|
|
|
|
return false;
|
|
}
|
|
|
|
private function hasPublicPropertyForAccessor(\ReflectionClass $class, string $propName): bool
|
|
{
|
|
return $class->hasProperty($propName) && $class->getProperty($propName)->isPublic();
|
|
}
|
|
|
|
private function hasAttributeNameCollision(\ReflectionClass $class, string $attributeName, string $methodName): bool
|
|
{
|
|
if ($this->hasPropertyForAccessor($class, $attributeName)) {
|
|
return true;
|
|
}
|
|
|
|
if ($class->hasMethod($attributeName)) {
|
|
$candidate = $class->getMethod($attributeName);
|
|
if ($candidate->getName() !== $methodName && $this->isReadableAccessorMethod($candidate)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
$ucAttributeName = ucfirst($attributeName);
|
|
foreach (['get', 'is', 'has', 'can'] as $prefix) {
|
|
$candidateName = $prefix.$ucAttributeName;
|
|
if ($candidateName === $methodName || !$class->hasMethod($candidateName)) {
|
|
continue;
|
|
}
|
|
|
|
if ($this->isReadableAccessorMethod($class->getMethod($candidateName))) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private function isReadableAccessorMethod(\ReflectionMethod $method): bool
|
|
{
|
|
return $method->isPublic()
|
|
&& !$method->isStatic()
|
|
&& !$method->getAttributes(Ignore::class)
|
|
&& !$method->getNumberOfRequiredParameters()
|
|
&& !\in_array((string) $method->getReturnType(), ['void', 'never'], true);
|
|
}
|
|
}
|