- Issue created by @acbramley
- 🇩🇰Denmark ressa Copenhagen
Thanks for working on this, tagging with PHP 8.4, to easier follow along.
Patch created on-demand for those in need. I do not know where to park the patch file.
Filename: "3499531-fix-implicit-nullables.patch"diff --git a/src/Entity/XmlSitemap.php b/src/Entity/XmlSitemap.php index 354c0eb..7876571 100644 --- a/src/Entity/XmlSitemap.php +++ b/src/Entity/XmlSitemap.php @@ -197,7 +197,7 @@ class XmlSitemap extends ConfigEntityBase implements XmlSitemapInterface { /** * {@inheritdoc} */ - public static function loadByContext(array $context = NULL) { + public static function loadByContext(?array $context = NULL) { if (!isset($context)) { $context = xmlsitemap_get_current_context(); } diff --git a/src/XmlSitemapInterface.php b/src/XmlSitemapInterface.php index 1d7ec50..b28d7d4 100644 --- a/src/XmlSitemapInterface.php +++ b/src/XmlSitemapInterface.php @@ -137,14 +137,14 @@ interface XmlSitemapInterface extends ConfigEntityInterface { /** * Returns the sitemap with the context specified as parameter. * - * @param array $context + * @param array|null $context * An optional XML Sitemap context array to use to find the correct XML * sitemap. If not provided, the current site's context will be used. * * @return \Drupal\xmlsitemap\XmlSitemapInterface * Sitemap with the specified context or NULL. */ - public static function loadByContext(array $context = NULL); + public static function loadByContext(?array $context = NULL); /** * Save the state information about the sitemap. diff --git a/src/XmlSitemapLinkStorage.php b/src/XmlSitemapLinkStorage.php index 9c7827d..22ebc1f 100644 --- a/src/XmlSitemapLinkStorage.php +++ b/src/XmlSitemapLinkStorage.php @@ -245,7 +245,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface { /** * {@inheritdoc} */ - public function checkChangedLink(array $link, array $original_link = NULL, $flag = FALSE) { + public function checkChangedLink(array $link, ?array $original_link = NULL, $flag = FALSE) { $changed = FALSE; if ($original_link === NULL) { @@ -406,7 +406,7 @@ class XmlSitemapLinkStorage implements XmlSitemapLinkStorageInterface { /** * {@inheritdoc} */ - public function getEntityQuery(string $entity_type_id, array $bundles = [], SelectInterface $subquery = NULL, string $subquery_operator = 'IN'): QueryInterface { + public function getEntityQuery(string $entity_type_id, array $bundles = [], ?SelectInterface $subquery = NULL, string $subquery_operator = 'IN'): QueryInterface { $storage = $this->entityTypeManager->getStorage($entity_type_id); $entity_type = $storage->getEntityType(); $query = $storage->getQuery(); diff --git a/src/XmlSitemapLinkStorageInterface.php b/src/XmlSitemapLinkStorageInterface.php index dda0d0d..49dead8 100644 --- a/src/XmlSitemapLinkStorageInterface.php +++ b/src/XmlSitemapLinkStorageInterface.php @@ -45,7 +45,7 @@ interface XmlSitemapLinkStorageInterface { * @return bool * TRUE if the link is changed, or FALSE otherwise. */ - public function checkChangedLink(array $link, array $original_link = NULL, $flag = FALSE); + public function checkChangedLink(array $link, ?array $original_link = NULL, $flag = FALSE); /** * Check if there is a visible sitemap link given a certain set of conditions. @@ -169,6 +169,6 @@ interface XmlSitemapLinkStorageInterface { * @return \Drupal\Core\Entity\Query\QueryInterface * The entity query object. */ - public function getEntityQuery(string $entity_type_id, array $bundles = [], SelectInterface $subquery = NULL, string $subquery_operator = 'IN'): QueryInterface; + public function getEntityQuery(string $entity_type_id, array $bundles = [], ?SelectInterface $subquery = NULL, string $subquery_operator = 'IN'): QueryInterface; } diff --git a/src/XmlSitemapStorage.php b/src/XmlSitemapStorage.php index d469020..d52bf6a 100644 --- a/src/XmlSitemapStorage.php +++ b/src/XmlSitemapStorage.php @@ -40,7 +40,7 @@ class XmlSitemapStorage extends ConfigEntityStorage { * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface|null $memory_cache * The memory cache backend. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, StateInterface $state, MemoryCacheInterface $memory_cache = NULL) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, StateInterface $state, ?MemoryCacheInterface $memory_cache = NULL) { parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache); $this->state = $state; } @@ -75,7 +75,7 @@ class XmlSitemapStorage extends ConfigEntityStorage { /** * {@inheritdoc} */ - protected function doLoadMultiple(array $ids = NULL) { + protected function doLoadMultiple(?array $ids = NULL) { $entities = parent::doLoadMultiple($ids); // Load the auxiliar xmlsitemap data and attach it to the entity. diff --git a/src/XmlSitemapWriter.php b/src/XmlSitemapWriter.php index 246e8ab..df921e7 100644 --- a/src/XmlSitemapWriter.php +++ b/src/XmlSitemapWriter.php @@ -173,7 +173,7 @@ class XmlSitemapWriter extends \XMLWriter { * @param string|array $content * The element contents or an array of the elements' sub-elements. */ - public function writeElement(string $name, string|array $content = NULL): bool { + public function writeElement(string $name, string|array|null $content = NULL): bool { if (is_array($content)) { $return = $this->startElement($name); $return &= $this->writeRaw($this->formatXmlElements($content)); diff --git a/xmlsitemap.module b/xmlsitemap.module index 7448051..ce969c2 100644 --- a/xmlsitemap.module +++ b/xmlsitemap.module @@ -485,7 +485,7 @@ function xmlsitemap_sitemap_uri(XmlSitemapInterface $sitemap) { /** * @} End of "defgroup xmlsitemap_api" */ -function xmlsitemap_get_directory(XmlSitemapInterface $sitemap = NULL, $directory = NULL) { +function xmlsitemap_get_directory(?XmlSitemapInterface $sitemap = NULL, $directory = NULL) { if (!isset($directory)) { $directory = \Drupal::config('xmlsitemap.settings')->get('path') ?: 'xmlsitemap'; } @@ -502,7 +502,7 @@ function xmlsitemap_get_directory(XmlSitemapInterface $sitemap = NULL, $director /** * Check that the sitemap files directory exists and is writable. */ -function xmlsitemap_check_directory(XmlSitemapInterface $sitemap = NULL) { +function xmlsitemap_check_directory(?XmlSitemapInterface $sitemap = NULL) { $directory = xmlsitemap_get_directory($sitemap); /** @var \Drupal\Core\File\FileSystemInterface $filesystem */ $filesystem = \Drupal::service('file_system'); @@ -552,7 +552,7 @@ function xmlsitemap_check_all_directories() { * @return bool * Returns TRUE is operation was successful, FALSE otherwise. */ -function xmlsitemap_clear_directory(XmlSitemapInterface $sitemap = NULL, $delete = FALSE) { +function xmlsitemap_clear_directory(?XmlSitemapInterface $sitemap = NULL, $delete = FALSE) { $directory = xmlsitemap_get_directory($sitemap); return _xmlsitemap_delete_recursive($directory, $delete); } @@ -2155,7 +2155,7 @@ function xmlsitemap_get_status_options($default = NULL) { * @return int|string * Returns current chunk of the sitemap. */ -function xmlsitemap_get_current_chunk(XmlSitemapInterface $sitemap, Request $request = NULL) { +function xmlsitemap_get_current_chunk(XmlSitemapInterface $sitemap, ?Request $request = NULL) { if (!isset($request)) { $request = \Drupal::request(); }