Commit 27158f7c authored by catch's avatar catch
Browse files

Issue #3262190 by daffie, longwave: Add miscellaneous return type hints for Symfony 6

parent 2ae5a549
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public function addRoutes(\Symfony\Component\Routing\RouteCollection $routes)
         * {@inheritdoc}
         */
        public function dump(array $options = array (
        ))
        )): string
        {
            return $this->lazyLoadItself()->dump($options);
        }
@@ -87,7 +87,7 @@ public function dump(array $options = array (
        /**
         * {@inheritdoc}
         */
        public function getRoutes()
        public function getRoutes(): \Symfony\Component\Routing\RouteCollection
        {
            return $this->lazyLoadItself()->getRoutes();
        }
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public function __construct($content = '', int $status = 200, array $headers = [
   *
   * @return $this
   */
  public function setContent($content) {
  public function setContent($content): static {
    // A render array can automatically be converted to a string and set the
    // necessary metadata.
    if (is_array($content) && (isset($content['#markup']))) {
+5 −5
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Core\Routing;

use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

class LazyRouteCollection extends RouteCollection {
@@ -33,8 +34,7 @@ public function getIterator(): \ArrayIterator {
   * @return int
   *   The number of routes
   */
  #[\ReturnTypeWillChange]
  public function count() {
  public function count(): int {
    return count($this->all());
  }

@@ -44,7 +44,7 @@ public function count() {
   * @return \Symfony\Component\Routing\Route[]
   *   An array of routes
   */
  public function all() {
  public function all(): array {
    return $this->provider->getRoutesByNames(NULL);
  }

@@ -57,12 +57,12 @@ public function all() {
   * @return \Symfony\Component\Routing\Route|null
   *   A Route instance or null when not found
   */
  public function get($name) {
  public function get($name): ?Route {
    try {
      return $this->provider->getRouteByName($name);
    }
    catch (RouteNotFoundException $e) {
      return;
      return NULL;
    }
  }

+4 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public function addRoutes(RouteCollection $routes) {
   *   Thrown if the table could not be created or the database connection
   *   failed.
   */
  public function dump(array $options = []) {
  public function dump(array $options = []): string {
    // Convert all of the routes into database records.
    // Accumulate the menu masks on top of any we found before.
    $masks = array_flip($this->state->get('routing.menu_masks.' . $this->tableName, []));
@@ -159,6 +159,8 @@ public function dump(array $options = []) {
    $this->state->set('routing.menu_masks.' . $this->tableName, $masks);

    $this->routes = NULL;

    return '';
  }

  /**
@@ -168,7 +170,7 @@ public function dump(array $options = []) {
   *   A RouteCollection instance representing all routes currently in the
   *   dumper.
   */
  public function getRoutes() {
  public function getRoutes(): RouteCollection {
    return $this->routes;
  }

+3 −2
Original line number Diff line number Diff line
@@ -39,9 +39,10 @@ public function addRoutes(RouteCollection $routes) {
   * @param array $options
   *   An array of options.
   */
  public function dump(array $options = []) {
  public function dump(array $options = []): string {
    // The dumper is reused for multiple providers, so reset the queued routes.
    $this->routes = NULL;
    return '';
  }

  /**
@@ -51,7 +52,7 @@ public function dump(array $options = []) {
   *   A RouteCollection instance representing all routes currently in the
   *   dumper.
   */
  public function getRoutes() {
  public function getRoutes(): RouteCollection {
    return $this->routes;
  }

Loading