Improve PageCollectionInterface::dateRange signature and documentation. Report changes into implementations.

This commit is contained in:
Thibaut HENIN 2021-05-07 07:38:26 +02:00 committed by Matias Griese
parent 72b520745a
commit ec98ddc2df
5 changed files with 26 additions and 26 deletions

View File

@ -426,17 +426,17 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param string|false $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return static
* @return PageCollectionInterface
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
public function dateRange($startDate = null, $endDate = null, $field = null)
{
$start = $startDate ? Utils::date2timestamp($startDate) : false;
$end = $endDate ? Utils::date2timestamp($endDate) : false;

View File

@ -949,17 +949,17 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param bool $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return static
* @return PageCollectionInterface
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
public function dateRange($startDate = null, $endDate = null, $field = null)
{
$collection = $this->__call('dateRange', [$startDate, $endDate, $field]);

View File

@ -319,17 +319,17 @@ class Collection extends Iterator implements PageCollectionInterface
/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param bool $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return $this
* @return PageCollectionInterface
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
public function dateRange($startDate = null, $endDate = null, $field = null)
{
$start = $startDate ? Utils::date2timestamp($startDate) : false;
$end = $endDate ? Utils::date2timestamp($endDate) : false;

View File

@ -158,17 +158,17 @@ interface PageCollectionInterface extends Traversable, ArrayAccess, Countable, S
/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param bool $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return PageCollectionInterface
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null);
public function dateRange($startDate = null, $endDate = null, $field = null);
/**
* Creates new collection with only visible pages

View File

@ -540,9 +540,9 @@ class Pages
}
if (isset($params['dateRange'])) {
$start = $params['dateRange']['start'] ?? 0;
$end = $params['dateRange']['end'] ?? false;
$field = $params['dateRange']['field'] ?? false;
$start = $params['dateRange']['start'] ?? null;
$end = $params['dateRange']['end'] ?? null;
$field = $params['dateRange']['field'] ?? null;
$collection = $collection->dateRange($start, $end, $field);
}