mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°8910 - Upgrade Symfony packages (#811)
This commit is contained in:
@@ -261,17 +261,13 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
foreach ($this->accessorPrefixes as $prefix) {
|
||||
$methodName = $prefix.$camelProp;
|
||||
|
||||
if ($reflClass->hasMethod($methodName) && $reflClass->getMethod($methodName)->getModifiers() & $this->methodReflectionFlags && !$reflClass->getMethod($methodName)->getNumberOfRequiredParameters()) {
|
||||
$method = $reflClass->getMethod($methodName);
|
||||
|
||||
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $methodName, $this->getReadVisiblityForMethod($method), $method->isStatic(), false);
|
||||
if ($reflClass->hasMethod($methodName) && ($m = $reflClass->getMethod($methodName))->getModifiers() & $this->methodReflectionFlags && !$m->getNumberOfRequiredParameters() && !\in_array((string) $m->getReturnType(), ['void', 'never'], true)) {
|
||||
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $methodName, $this->getReadVisibilityForMethod($m), $m->isStatic(), false);
|
||||
}
|
||||
}
|
||||
|
||||
if ($allowGetterSetter && $reflClass->hasMethod($getsetter) && ($reflClass->getMethod($getsetter)->getModifiers() & $this->methodReflectionFlags)) {
|
||||
$method = $reflClass->getMethod($getsetter);
|
||||
|
||||
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $getsetter, $this->getReadVisiblityForMethod($method), $method->isStatic(), false);
|
||||
if ($allowGetterSetter && $reflClass->hasMethod($getsetter) && ($m = $reflClass->getMethod($getsetter))->getModifiers() & $this->methodReflectionFlags && !$m->getNumberOfRequiredParameters() && !\in_array((string) $m->getReturnType(), ['void', 'never'], true)) {
|
||||
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $getsetter, $this->getReadVisibilityForMethod($m), $m->isStatic(), false);
|
||||
}
|
||||
|
||||
if ($allowMagicGet && $reflClass->hasMethod('__get') && (($r = $reflClass->getMethod('__get'))->getModifiers() & $this->methodReflectionFlags)) {
|
||||
@@ -279,7 +275,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
}
|
||||
|
||||
if ($hasProperty && (($r = $reflClass->getProperty($property))->getModifiers() & $this->propertyReflectionFlags)) {
|
||||
return new PropertyReadInfo(PropertyReadInfo::TYPE_PROPERTY, $property, $this->getReadVisiblityForProperty($r), $r->isStatic(), true);
|
||||
return new PropertyReadInfo(PropertyReadInfo::TYPE_PROPERTY, $property, $this->getReadVisibilityForProperty($r), $r->isStatic(), true);
|
||||
}
|
||||
|
||||
if ($allowMagicCall && $reflClass->hasMethod('__call') && ($reflClass->getMethod('__call')->getModifiers() & $this->methodReflectionFlags)) {
|
||||
@@ -305,6 +301,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
$allowAdderRemover = $context['enable_adder_remover_extraction'] ?? true;
|
||||
|
||||
$camelized = $this->camelize($property);
|
||||
$nonCamelized = ucfirst($property);
|
||||
$constructor = $reflClass->getConstructor();
|
||||
$singulars = $this->inflector->singularize($camelized);
|
||||
$errors = [];
|
||||
@@ -323,8 +320,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
$removerMethod = $reflClass->getMethod($removerAccessName);
|
||||
|
||||
$mutator = new PropertyWriteInfo(PropertyWriteInfo::TYPE_ADDER_AND_REMOVER);
|
||||
$mutator->setAdderInfo(new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $adderAccessName, $this->getWriteVisiblityForMethod($adderMethod), $adderMethod->isStatic()));
|
||||
$mutator->setRemoverInfo(new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $removerAccessName, $this->getWriteVisiblityForMethod($removerMethod), $removerMethod->isStatic()));
|
||||
$mutator->setAdderInfo(new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $adderAccessName, $this->getWriteVisibilityForMethod($adderMethod), $adderMethod->isStatic()));
|
||||
$mutator->setRemoverInfo(new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $removerAccessName, $this->getWriteVisibilityForMethod($removerMethod), $removerMethod->isStatic()));
|
||||
|
||||
return $mutator;
|
||||
}
|
||||
@@ -343,27 +340,56 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
$method = $reflClass->getMethod($methodName);
|
||||
|
||||
if (!\in_array($mutatorPrefix, $this->arrayMutatorPrefixes, true)) {
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $methodName, $this->getWriteVisiblityForMethod($method), $method->isStatic());
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $methodName, $this->getWriteVisibilityForMethod($method), $method->isStatic());
|
||||
}
|
||||
}
|
||||
|
||||
if ($camelized !== $nonCamelized) {
|
||||
foreach ($this->mutatorPrefixes as $mutatorPrefix) {
|
||||
$methodName = $mutatorPrefix.$nonCamelized;
|
||||
|
||||
[$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, $methodName, 1);
|
||||
if (!$accessible) {
|
||||
$errors[] = $methodAccessibleErrors;
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = $reflClass->getMethod($methodName);
|
||||
|
||||
if (!\in_array($mutatorPrefix, $this->arrayMutatorPrefixes, true)) {
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $methodName, $this->getWriteVisibilityForMethod($method), $method->isStatic());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getsetter = lcfirst($camelized);
|
||||
$getsetterNonCamelized = lcfirst($nonCamelized);
|
||||
|
||||
if ($allowGetterSetter) {
|
||||
[$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, $getsetter, 1);
|
||||
if ($accessible) {
|
||||
$method = $reflClass->getMethod($getsetter);
|
||||
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $getsetter, $this->getWriteVisiblityForMethod($method), $method->isStatic());
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $getsetter, $this->getWriteVisibilityForMethod($method), $method->isStatic());
|
||||
}
|
||||
|
||||
$errors[] = $methodAccessibleErrors;
|
||||
|
||||
if ($getsetter !== $getsetterNonCamelized) {
|
||||
[$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, $getsetterNonCamelized, 1);
|
||||
if ($accessible) {
|
||||
$method = $reflClass->getMethod($getsetterNonCamelized);
|
||||
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $getsetterNonCamelized, $this->getWriteVisibilityForMethod($method), $method->isStatic());
|
||||
}
|
||||
$errors[] = $methodAccessibleErrors;
|
||||
}
|
||||
}
|
||||
|
||||
if ($reflClass->hasProperty($property) && ($reflClass->getProperty($property)->getModifiers() & $this->propertyReflectionFlags)) {
|
||||
$reflProperty = $reflClass->getProperty($property);
|
||||
if (!$reflProperty->isReadOnly()) {
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_PROPERTY, $property, $this->getWriteVisiblityForProperty($reflProperty), $reflProperty->isStatic());
|
||||
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_PROPERTY, $property, $this->getWriteVisibilityForProperty($reflProperty), $reflProperty->isStatic());
|
||||
}
|
||||
|
||||
$errors[] = [\sprintf('The property "%s" in class "%s" is a promoted readonly property.', $property, $reflClass->getName())];
|
||||
@@ -757,6 +783,10 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
*/
|
||||
private function camelize(string $string): string
|
||||
{
|
||||
if ('' === ltrim($string, '_')) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
return str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
|
||||
}
|
||||
|
||||
@@ -804,7 +834,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
return $propertyFlags;
|
||||
}
|
||||
|
||||
private function getReadVisiblityForProperty(\ReflectionProperty $reflectionProperty): string
|
||||
private function getReadVisibilityForProperty(\ReflectionProperty $reflectionProperty): string
|
||||
{
|
||||
if ($reflectionProperty->isPrivate()) {
|
||||
return PropertyReadInfo::VISIBILITY_PRIVATE;
|
||||
@@ -817,7 +847,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
return PropertyReadInfo::VISIBILITY_PUBLIC;
|
||||
}
|
||||
|
||||
private function getReadVisiblityForMethod(\ReflectionMethod $reflectionMethod): string
|
||||
private function getReadVisibilityForMethod(\ReflectionMethod $reflectionMethod): string
|
||||
{
|
||||
if ($reflectionMethod->isPrivate()) {
|
||||
return PropertyReadInfo::VISIBILITY_PRIVATE;
|
||||
@@ -830,7 +860,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
return PropertyReadInfo::VISIBILITY_PUBLIC;
|
||||
}
|
||||
|
||||
private function getWriteVisiblityForProperty(\ReflectionProperty $reflectionProperty): string
|
||||
private function getWriteVisibilityForProperty(\ReflectionProperty $reflectionProperty): string
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 80400) {
|
||||
if ($reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) {
|
||||
@@ -857,7 +887,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
|
||||
return PropertyWriteInfo::VISIBILITY_PUBLIC;
|
||||
}
|
||||
|
||||
private function getWriteVisiblityForMethod(\ReflectionMethod $reflectionMethod): string
|
||||
private function getWriteVisibilityForMethod(\ReflectionMethod $reflectionMethod): string
|
||||
{
|
||||
if ($reflectionMethod->isPrivate()) {
|
||||
return PropertyWriteInfo::VISIBILITY_PRIVATE;
|
||||
|
||||
Reference in New Issue
Block a user