Skip to content

Commit

Permalink
Fix for a BC Break
Browse files Browse the repository at this point in the history
We've made some changes to the ItemList class.
Previously, some parameters were marked as int,
but they have been redefined as String. To avoid
any backward compatibility breaks, we're allowing
both types.
  • Loading branch information
Stefan Heimes authored and Stefan Heimes committed Jan 13, 2025
1 parent 09216ec commit ebeff7c
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/ItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,33 @@ public function overrideOutputFormat(string $outputFormat = null): self
/**
* Set MetaModel and render settings.
*
* @param string $intMetaModel The MetaModel to use.
* @param string $intView The render settings to use (if 0, the default will be used).
* @param string|int $intMetaModel The MetaModel to use.
* @param string|int $intView The render settings to use (if 0, the default will be used).
*
* @return ItemList
*/
public function setMetaModel(string $intMetaModel, string $intView): self
public function setMetaModel(string|int $intMetaModel, string|int $intView): self
{
if (is_int($intMetaModel)) {
$intMetaModel = (string) $intMetaModel;
// @codingStandardsIgnoreStart Silencing errors is discouraged
@trigger_error(
'Parameter $intMetaModel in "' . __CLASS__ . '::' .__METHOD__. '" has been changed from int to string.',
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
}

if (is_int($intView)) {
$intView = (string) $intView;
// @codingStandardsIgnoreStart Silencing errors is discouraged
@trigger_error(
'Parameter $intView in "' . __CLASS__ . '::' .__METHOD__. '" has been changed from int to string.',
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
}

$this->intMetaModel = $intMetaModel;
$this->intView = $intView;

Expand Down Expand Up @@ -663,14 +683,24 @@ protected function prepareView(): void
/**
* Set the filter setting to use.
*
* @param string $intFilter The filter setting id to use.
* @param string|int $intFilter The filter setting id to use.
*
* @return $this
*
* @throws RuntimeException When the filter settings can not be found.
*/
public function setFilterSettings(string $intFilter): self
public function setFilterSettings(string|int $intFilter): self
{
if (is_int($intFilter)) {
$intFilter = (string) $intFilter;
// @codingStandardsIgnoreStart Silencing errors is discouraged
@trigger_error(
'Parameter $intFilter in "' . __CLASS__ . '::' .__METHOD__. '" has been changed from int to string.',
E_USER_DEPRECATED
);
// @codingStandardsIgnoreEnd
}

$this->objFilterSettings = $this->getFilterFactory()->createCollection($intFilter);

return $this;
Expand Down

0 comments on commit ebeff7c

Please sign in to comment.