Skip to content
Snippets Groups Projects
Commit 725f280f authored by Tim Rohaly's avatar Tim Rohaly
Browse files

Issue #3477442 by tr: Parameter typing in DataFetcher service

parent 0ab84160
No related branches found
No related tags found
1 merge request!34Issue #3477442 by tr: Parameter typing in DataFetcher service
Pipeline #294878 passed with warnings
<?php
declare(strict_types=1);
namespace Drupal\typed_data;
use Drupal\Core\Cache\CacheableDependencyInterface;
......@@ -27,7 +29,7 @@ class DataFetcher implements DataFetcherInterface {
/**
* {@inheritdoc}
*/
public function fetchDataByPropertyPath(TypedDataInterface $typed_data, string $property_path, BubbleableMetadata $bubbleable_metadata = NULL, string $langcode = NULL): TypedDataInterface {
public function fetchDataByPropertyPath(TypedDataInterface $typed_data, string $property_path, ?BubbleableMetadata $bubbleable_metadata = NULL, ?string $langcode = NULL): TypedDataInterface {
$sub_paths = explode('.', $property_path);
return $this->fetchDataBySubPaths($typed_data, $sub_paths, $bubbleable_metadata, $langcode);
}
......@@ -35,7 +37,7 @@ class DataFetcher implements DataFetcherInterface {
/**
* {@inheritdoc}
*/
public function fetchDataBySubPaths(TypedDataInterface $typed_data, array $sub_paths, BubbleableMetadata $bubbleable_metadata = NULL, string $langcode = NULL): TypedDataInterface {
public function fetchDataBySubPaths(TypedDataInterface $typed_data, array $sub_paths, ?BubbleableMetadata $bubbleable_metadata = NULL, ?string $langcode = NULL): TypedDataInterface {
$current_selector = [];
$bubbleable_metadata = $bubbleable_metadata ?: new BubbleableMetadata();
......@@ -104,7 +106,7 @@ class DataFetcher implements DataFetcherInterface {
/**
* {@inheritdoc}
*/
public function fetchDefinitionByPropertyPath(DataDefinitionInterface $data_definition, string $property_path, string $langcode = NULL): DataDefinitionInterface {
public function fetchDefinitionByPropertyPath(DataDefinitionInterface $data_definition, string $property_path, ?string $langcode = NULL): DataDefinitionInterface {
$sub_paths = explode('.', $property_path);
return $this->fetchDefinitionBySubPaths($data_definition, $sub_paths, $langcode);
}
......@@ -112,7 +114,7 @@ class DataFetcher implements DataFetcherInterface {
/**
* {@inheritdoc}
*/
public function fetchDefinitionBySubPaths(DataDefinitionInterface $data_definition, array $sub_paths, string $langcode = NULL): DataDefinitionInterface {
public function fetchDefinitionBySubPaths(DataDefinitionInterface $data_definition, array $sub_paths, ?string $langcode = NULL): DataDefinitionInterface {
$current_selector = [];
foreach ($sub_paths as $name) {
......
......
......@@ -34,7 +34,7 @@ interface DataFetcherInterface {
* Thrown if the given path is not valid for the given data; e.g., a not
* existing property is referenced.
*/
public function fetchDataByPropertyPath(TypedDataInterface $typed_data, string $property_path, BubbleableMetadata $bubbleable_metadata = NULL, string $langcode = NULL): TypedDataInterface;
public function fetchDataByPropertyPath(TypedDataInterface $typed_data, string $property_path, ?BubbleableMetadata $bubbleable_metadata = NULL, ?string $langcode = NULL): TypedDataInterface;
/**
* Fetches data based upon the given sub-paths.
......@@ -59,7 +59,7 @@ interface DataFetcherInterface {
* Thrown if the given path is not valid for the given data; e.g., a non-
* existent property is referenced.
*/
public function fetchDataBySubPaths(TypedDataInterface $typed_data, array $sub_paths, BubbleableMetadata $bubbleable_metadata = NULL, string $langcode = NULL): TypedDataInterface;
public function fetchDataBySubPaths(TypedDataInterface $typed_data, array $sub_paths, ?BubbleableMetadata $bubbleable_metadata = NULL, ?string $langcode = NULL): TypedDataInterface;
/**
* Fetches a data definition based upon the given property path.
......@@ -79,7 +79,7 @@ interface DataFetcherInterface {
* Thrown if the given path is not valid for the given data; e.g., a not
* existing property is referenced.
*/
public function fetchDefinitionByPropertyPath(DataDefinitionInterface $data_definition, string $property_path, string $langcode = NULL): DataDefinitionInterface;
public function fetchDefinitionByPropertyPath(DataDefinitionInterface $data_definition, string $property_path, ?string $langcode = NULL): DataDefinitionInterface;
/**
* Fetches a data definition based upon the given sub-paths.
......@@ -99,7 +99,7 @@ interface DataFetcherInterface {
* Thrown if the given path is not valid for the given data; e.g., a not
* existing property is referenced.
*/
public function fetchDefinitionBySubPaths(DataDefinitionInterface $data_definition, array $sub_paths, string $langcode = NULL): DataDefinitionInterface;
public function fetchDefinitionBySubPaths(DataDefinitionInterface $data_definition, array $sub_paths, ?string $langcode = NULL): DataDefinitionInterface;
/**
* Provides autocomplete suggestions for an incomplete property path.
......
......
<?php
declare(strict_types=1);
namespace Drupal\typed_data;
/**
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment