diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-12-09 23:14:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-09 23:14:39 +0300 |
commit | 1b113aec10e43fceba07226621a83ba7f8aea52b (patch) | |
tree | ee2bc7f615b235759f407c9cc78067b2806a7bef /core/Period.php | |
parent | 11fefdf6721f7143992ca48739c4ec4e5c9de208 (diff) |
Make sure Period::toString() handles case when child period returns array and add a unit test. (#13762)
* Make sure Period::toString() always returns array of strings and add a unit test.
* Ensure backwards compatible.
* docblock tweak
* Fix tests.
Diffstat (limited to 'core/Period.php')
-rw-r--r-- | core/Period.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/Period.php b/core/Period.php index 8cd849ba41..c9b0c04900 100644 --- a/core/Period.php +++ b/core/Period.php @@ -264,7 +264,7 @@ abstract class Period * Returns a list of strings representing the current period. * * @param string $format The format of each individual day. - * @return array An array of string dates that this period consists of. + * @return array|string An array of string dates that this period consists of. */ public function toString($format = "Y-m-d") { @@ -272,7 +272,12 @@ abstract class Period $dateString = array(); foreach ($this->subperiods as $period) { - $dateString[] = $period->toString($format); + $childPeriodStr = $period->toString($format); + if (is_array($childPeriodStr)) { + $childPeriodStr = implode(",", $childPeriodStr); + } + + $dateString[] = $childPeriodStr; } return $dateString; |