mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Fix PHPDocs for I18n
This commit is contained in:
parent
748ec9a39a
commit
a092647abb
@ -1,35 +1,126 @@
|
||||
<?php namespace CodeIgniter\I18n\Exceptions;
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014-2019 British Columbia Institute of Technology
|
||||
* Copyright (c) 2019-2020 CodeIgniter Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author CodeIgniter Dev Team
|
||||
* @copyright 2019-2020 CodeIgniter Foundation
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 4.0.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\I18n\Exceptions;
|
||||
|
||||
use CodeIgniter\Exceptions\ExceptionInterface;
|
||||
use CodeIgniter\Exceptions\FrameworkException;
|
||||
|
||||
/**
|
||||
* I18nException
|
||||
*/
|
||||
class I18nException extends FrameworkException implements ExceptionInterface
|
||||
{
|
||||
/**
|
||||
* Thrown when the numeric representation of the month falls
|
||||
* outside the range of allowed months.
|
||||
*
|
||||
* @param string $month
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forInvalidMonth(string $month)
|
||||
{
|
||||
return new static(lang('Time.invalidMonth', [$month]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when the supplied day falls outside the range
|
||||
* of allowed days.
|
||||
*
|
||||
* @param string $day
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forInvalidDay(string $day)
|
||||
{
|
||||
return new static(lang('Time.invalidDay', [$day]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when the day provided falls outside the allowed
|
||||
* last day for the given month.
|
||||
*
|
||||
* @param string $lastDay
|
||||
* @param string $day
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forInvalidOverDay(string $lastDay, string $day)
|
||||
{
|
||||
return new static(lang('Time.invalidOverDay', [$lastDay, $day]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when the supplied hour falls outside the
|
||||
* range of allowed hours.
|
||||
*
|
||||
* @param string $hour
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forInvalidHour(string $hour)
|
||||
{
|
||||
return new static(lang('Time.invalidHour', [$hour]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when the supplied minutes falls outside the
|
||||
* range of allowed minutes.
|
||||
*
|
||||
* @param string $minutes
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forInvalidMinutes(string $minutes)
|
||||
{
|
||||
return new static(lang('Time.invalidMinutes', [$minutes]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when the supplied seconds falls outside the
|
||||
* range of allowed seconds.
|
||||
*
|
||||
* @param string $seconds
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function forInvalidSeconds(string $seconds)
|
||||
{
|
||||
return new static(lang('Time.invalidSeconds', [$seconds]));
|
||||
|
@ -61,7 +61,7 @@ class Time extends DateTime
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var \DateTimeZone
|
||||
*/
|
||||
protected $timezone;
|
||||
|
||||
@ -96,9 +96,9 @@ class Time extends DateTime
|
||||
/**
|
||||
* Time constructor.
|
||||
*
|
||||
* @param string|null $time
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param string|null $time
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -162,9 +162,9 @@ class Time extends DateTime
|
||||
* Example:
|
||||
* $time = Time::parse('first day of December 2008');
|
||||
*
|
||||
* @param string $datetime
|
||||
* @param string|null $timezone
|
||||
* @param string|null $locale
|
||||
* @param string $datetime
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -179,8 +179,8 @@ class Time extends DateTime
|
||||
/**
|
||||
* Return a new time with the time set to midnight.
|
||||
*
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -195,8 +195,8 @@ class Time extends DateTime
|
||||
/**
|
||||
* Returns an instance set to midnight yesterday morning.
|
||||
*
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -211,8 +211,8 @@ class Time extends DateTime
|
||||
/**
|
||||
* Returns an instance set to midnight tomorrow morning.
|
||||
*
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -228,11 +228,11 @@ class Time extends DateTime
|
||||
* Returns a new instance based on the year, month and day. If any of those three
|
||||
* are left empty, will default to the current value.
|
||||
*
|
||||
* @param integer|null $year
|
||||
* @param integer|null $month
|
||||
* @param integer|null $day
|
||||
* @param null $timezone
|
||||
* @param string $locale
|
||||
* @param integer|null $year
|
||||
* @param integer|null $month
|
||||
* @param integer|null $day
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -247,11 +247,11 @@ class Time extends DateTime
|
||||
/**
|
||||
* Returns a new instance with the date set to today, and the time set to the values passed in.
|
||||
*
|
||||
* @param integer|null $hour
|
||||
* @param integer|null $minutes
|
||||
* @param integer|null $seconds
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param integer|null $hour
|
||||
* @param integer|null $minutes
|
||||
* @param integer|null $seconds
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -266,14 +266,14 @@ class Time extends DateTime
|
||||
/**
|
||||
* Returns a new instance with the date time values individually set.
|
||||
*
|
||||
* @param integer|null $year
|
||||
* @param integer|null $month
|
||||
* @param integer|null $day
|
||||
* @param integer|null $hour
|
||||
* @param integer|null $minutes
|
||||
* @param integer|null $seconds
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param integer|null $year
|
||||
* @param integer|null $month
|
||||
* @param integer|null $day
|
||||
* @param integer|null $hour
|
||||
* @param integer|null $minutes
|
||||
* @param integer|null $seconds
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -296,9 +296,9 @@ class Time extends DateTime
|
||||
* Provides a replacement for DateTime's own createFromFormat function, that provides
|
||||
* more flexible timeZone handling
|
||||
*
|
||||
* @param string $format
|
||||
* @param string $datetime
|
||||
* @param DateTimeZone|string $timeZone
|
||||
* @param string $format
|
||||
* @param string $datetime
|
||||
* @param \DateTimeZone|string|null $timeZone
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -315,16 +315,16 @@ class Time extends DateTime
|
||||
/**
|
||||
* Returns a new instance with the datetime set based on the provided UNIX timestamp.
|
||||
*
|
||||
* @param integer $timestamp
|
||||
* @param DateTimeZone $timeZone
|
||||
* @param string|null $locale
|
||||
* @param integer $timestamp
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createFromTimestamp(int $timestamp, $timeZone = null, string $locale = null)
|
||||
public static function createFromTimestamp(int $timestamp, $timezone = null, string $locale = null)
|
||||
{
|
||||
return new Time(date('Y-m-d H:i:s', $timestamp), $timeZone, $locale);
|
||||
return new Time(date('Y-m-d H:i:s', $timestamp), $timezone, $locale);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
@ -370,9 +370,9 @@ class Time extends DateTime
|
||||
* Creates an instance of Time that will be returned during testing
|
||||
* when calling 'Time::now' instead of the current time.
|
||||
*
|
||||
* @param \CodeIgniter\I18n\Time|string $datetime
|
||||
* @param null $timezone
|
||||
* @param string|null $locale
|
||||
* @param \CodeIgniter\I18n\Time|string|null $datetime
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @param string|null $locale
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -390,7 +390,7 @@ class Time extends DateTime
|
||||
{
|
||||
$datetime = new Time($datetime, $timezone, $locale);
|
||||
}
|
||||
else if ($datetime instanceof DateTime && ! $datetime instanceof Time)
|
||||
elseif ($datetime instanceof DateTime && ! $datetime instanceof Time)
|
||||
{
|
||||
$datetime = new Time($datetime->format('Y-m-d H:i:s'), $timezone);
|
||||
}
|
||||
@ -548,6 +548,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Returns the age in years from the "current" date and 'now'
|
||||
*
|
||||
* @return integer
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getAge()
|
||||
@ -591,7 +592,7 @@ class Time extends DateTime
|
||||
{
|
||||
if ($transition['time'] > $this->format('U'))
|
||||
{
|
||||
$daylightSaving = (bool) $transition['isdst'] ?? $daylightSaving;
|
||||
$daylightSaving = (bool) $transition['isdst'] ?: $daylightSaving;
|
||||
}
|
||||
}
|
||||
return $daylightSaving;
|
||||
@ -641,7 +642,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Sets the current year for this instance.
|
||||
*
|
||||
* @param $value
|
||||
* @param integer|string $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -654,7 +655,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Sets the month of the year.
|
||||
*
|
||||
* @param $value
|
||||
* @param integer|string $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -677,7 +678,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Sets the day of the month.
|
||||
*
|
||||
* @param $value
|
||||
* @param integer|string $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -702,7 +703,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Sets the hour of the day (24 hour cycle)
|
||||
*
|
||||
* @param $value
|
||||
* @param integer|string $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -720,7 +721,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Sets the minute of the hour
|
||||
*
|
||||
* @param $value
|
||||
* @param integer|string $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -738,7 +739,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Sets the second of the minute.
|
||||
*
|
||||
* @param $value
|
||||
* @param integer|string $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -756,8 +757,8 @@ class Time extends DateTime
|
||||
/**
|
||||
* Helper method to do the heavy lifting of the 'setX' methods.
|
||||
*
|
||||
* @param string $name
|
||||
* @param $value
|
||||
* @param string $name
|
||||
* @param integer $value
|
||||
*
|
||||
* @return \CodeIgniter\I18n\Time
|
||||
* @throws \Exception
|
||||
@ -1038,7 +1039,7 @@ class Time extends DateTime
|
||||
* @return string|boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toLocalizedString(?string $format = null)
|
||||
public function toLocalizedString(string $format = null)
|
||||
{
|
||||
$format = $format ?? $this->toStringFormat;
|
||||
|
||||
@ -1253,11 +1254,11 @@ class Time extends DateTime
|
||||
$time = $time->toDateTime()
|
||||
->setTimezone(new DateTimeZone('UTC'));
|
||||
}
|
||||
else if ($time instanceof DateTime)
|
||||
elseif ($time instanceof DateTime)
|
||||
{
|
||||
$time = $time->setTimezone(new DateTimeZone('UTC'));
|
||||
}
|
||||
else if (is_string($time))
|
||||
elseif (is_string($time))
|
||||
{
|
||||
$timezone = $timezone ?: $this->timezone;
|
||||
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
|
||||
@ -1328,7 +1329,7 @@ class Time extends DateTime
|
||||
* return values.
|
||||
* See http://php.net/manual/en/language.oop5.overloading.php
|
||||
*
|
||||
* @param $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -1349,7 +1350,7 @@ class Time extends DateTime
|
||||
/**
|
||||
* Allow for property-type checking to any getX method...
|
||||
*
|
||||
* @param $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ class TimeDifference
|
||||
/**
|
||||
* The timestamp of the "current" time.
|
||||
*
|
||||
* @var integer
|
||||
* @var \IntlCalendar
|
||||
*/
|
||||
protected $currentTime;
|
||||
|
||||
@ -291,28 +291,28 @@ class TimeDifference
|
||||
$phrase = lang('Time.years', [abs($years)], $locale);
|
||||
$before = $years < 0;
|
||||
}
|
||||
else if ($months !== 0)
|
||||
elseif ($months !== 0)
|
||||
{
|
||||
$phrase = lang('Time.months', [abs($months)], $locale);
|
||||
$before = $months < 0;
|
||||
}
|
||||
else if ($days !== 0 && (abs($days) >= 7))
|
||||
elseif ($days !== 0 && (abs($days) >= 7))
|
||||
{
|
||||
$weeks = ceil($days / 7);
|
||||
$phrase = lang('Time.weeks', [abs($weeks)], $locale);
|
||||
$before = $days < 0;
|
||||
}
|
||||
else if ($days !== 0)
|
||||
elseif ($days !== 0)
|
||||
{
|
||||
$phrase = lang('Time.days', [abs($days)], $locale);
|
||||
$before = $days < 0;
|
||||
}
|
||||
else if ($hours !== 0)
|
||||
elseif ($hours !== 0)
|
||||
{
|
||||
$phrase = lang('Time.hours', [abs($hours)], $locale);
|
||||
$before = $hours < 0;
|
||||
}
|
||||
else if ($minutes !== 0)
|
||||
elseif ($minutes !== 0)
|
||||
{
|
||||
$phrase = lang('Time.minutes', [abs($minutes)], $locale);
|
||||
$before = $minutes < 0;
|
||||
@ -330,7 +330,7 @@ class TimeDifference
|
||||
/**
|
||||
* Allow property-like access to our calculated values.
|
||||
*
|
||||
* @param $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -350,7 +350,7 @@ class TimeDifference
|
||||
/**
|
||||
* Allow property-like checking for our calculated values.
|
||||
*
|
||||
* @param $name
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user