Merge branch '6.4' into 7.3

* 6.4:
  do not use PHPUnit mock objects without configured expectations
  do not use PHPUnit mock objects without configured expectations
  do not use PHPUnit mock objects without configured expectations
  [PropertyAccess][PropertyInfo][Serializer] Skip methods that look like getters but return void or never
  [Form][TwigBridge] Prevent cached block prefixes from leaking across nested collections
  [Uid] Remove $uid from InvalidArgumentException message
This commit is contained in:
Christian Flothmann
2026-01-04 00:21:50 +01:00

View File

@@ -45,6 +45,11 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
*/
private array $resourceHierarchyLevels = [];
/**
* @var array<string, array<string, bool>>
*/
private array $resourceInheritability = [];
/**
* Creates a new renderer engine.
*
@@ -67,7 +72,17 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
// Unset instead of resetting to an empty array, in order to allow
// implementations (like TwigRendererEngine) to check whether $cacheKey
// is set at all.
unset($this->resources[$cacheKey], $this->resourceHierarchyLevels[$cacheKey]);
unset($this->resources[$cacheKey], $this->resourceHierarchyLevels[$cacheKey], $this->resourceInheritability[$cacheKey]);
}
protected function setResourceInheritability(string $cacheKey, string $blockName, bool $inheritable): void
{
$this->resourceInheritability[$cacheKey][$blockName] = $inheritable;
}
protected function isResourceInheritable(string $cacheKey, string $blockName): bool
{
return $this->resourceInheritability[$cacheKey][$blockName] ?? false;
}
public function getResourceForBlockName(FormView $view, string $blockName): mixed
@@ -134,6 +149,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
// cache. The only missing thing is to set the hierarchy level at which
// the template was found.
$this->resourceHierarchyLevels[$cacheKey][$blockName] = $hierarchyLevel;
$this->setResourceInheritability($cacheKey, $blockName, true);
return true;
}
@@ -157,6 +173,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
// Cache the shortcuts for further accesses
$this->resources[$cacheKey][$blockName] = $this->resources[$cacheKey][$parentBlockName];
$this->resourceHierarchyLevels[$cacheKey][$blockName] = $this->resourceHierarchyLevels[$cacheKey][$parentBlockName];
$this->setResourceInheritability($cacheKey, $blockName, false);
return true;
}
@@ -165,6 +182,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
// Cache the shortcuts for further accesses
$this->resources[$cacheKey][$blockName] = $this->resources[$cacheKey][$parentBlockName];
$this->resourceHierarchyLevels[$cacheKey][$blockName] = $this->resourceHierarchyLevels[$cacheKey][$parentBlockName];
$this->setResourceInheritability($cacheKey, $blockName, false);
return true;
}
@@ -173,6 +191,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
// Cache the result for further accesses
$this->resources[$cacheKey][$blockName] = false;
$this->resourceHierarchyLevels[$cacheKey][$blockName] = false;
$this->setResourceInheritability($cacheKey, $blockName, true);
return false;
}
@@ -183,5 +202,6 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
$this->useDefaultThemes = [];
$this->resources = [];
$this->resourceHierarchyLevels = [];
$this->resourceInheritability = [];
}
}