Verified Commit 5f59e9f2 authored by Andrei Mateescu's avatar Andrei Mateescu
Browse files

task: #3578084 Add return types to Twig implementations

By: longwave
By: smustgrave
By: godotislate
By: sivaji_ganesh_jojodae
By: dcam
parent cf771503
Loading
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -13,14 +13,7 @@

# Skip some dependencies' DebugClassLoader forward compatibility warnings, in
# order to let contrib modules make their necessary fixes first.
%Method "Twig\\Extension\\ExtensionInterface::[^"]+" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\\Core\\Template\\TwigExtension" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\Loader\\FilesystemLoader::findTemplate\(\)" might add "\?string" as a native return type declaration in the future. Do the same in child class "Drupal\\Core\\Template\\Loader\\FilesystemLoader" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\Loader\\LoaderInterface::exists\(\)" might add "bool" as a native return type declaration in the future. Do the same in implementation "Drupal\\Core\\Template\\Loader\\StringLoader" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\Node\\Node::compile\(\)" might add "void" as a native return type declaration in the future. Do the same in child class "Drupal\\Core\\Template\\TwigNodeCheckDeprecations" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\Node\\Node::compile\(\)" might add "void" as a native return type declaration in the future. Do the same in child class "Drupal\\Core\\Template\\TwigNodeTrans" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\NodeVisitor\\NodeVisitorInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in implementation "Drupal\\Core\\Template\\RemoveCheckToStringNodeVisitor" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\NodeVisitor\\NodeVisitorInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in implementation "Drupal\\Core\\Template\\TwigNodeVisitor" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Twig\\TokenParser\\TokenParserInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in implementation "Drupal\\Core\\Template\\TwigTransTokenParser" now to avoid errors or add an explicit @return annotation to suppress this message%
#(none at the moment)

# Indirect deprecations. These are not in Drupal's remit to fix, but it is
# worth keeping track of dependencies' issues.
+0 −6
Original line number Diff line number Diff line
@@ -9781,12 +9781,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Template/TwigExtension.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Template\\\\TwigExtension\\:\\:getName\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Template/TwigExtension.php',
];
$ignoreErrors[] = [
	'message' => '#^Cannot unset property Drupal\\\\Core\\\\Template\\\\TwigNodeVisitor\\:\\:\\$skipRenderVarFunction because it might have hooks in a subclass\\.$#',
	'identifier' => 'unset.possiblyHookedProperty',
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public function addPath(string $path, string $namespace = self::MAIN_NAMESPACE):
  /**
   * {@inheritdoc}
   */
  protected function findTemplate($name, $throw = TRUE) {
  protected function findTemplate($name, $throw = TRUE): ?string {
    $extension = pathinfo($name, PATHINFO_EXTENSION);
    if (!in_array($extension, $this->allowedFileExtensions, TRUE)) {
      if (!$throw) {
+1 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class StringLoader implements LoaderInterface {
  /**
   * {@inheritdoc}
   */
  public function exists($name) {
  public function exists($name): bool {
    if (str_starts_with($name, '{# inline_template_start #}')) {
      return TRUE;
    }
@@ -55,7 +55,6 @@ public function isFresh(string $name, int $time): bool {
   * {@inheritdoc}
   */
  public function getSourceContext(string $name): Source {
    $name = (string) $name;
    return new Source($name, $name);
  }

+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public function leaveNode(Node $node, Environment $env): ?Node {
  /**
   * {@inheritdoc}
   */
  public function getPriority() {
  public function getPriority(): int {
    // Runs after sandbox visitor.
    return 1;
  }
Loading