Skip to content

Commit

Permalink
More comprehensive removal of psr/container from package
Browse files Browse the repository at this point in the history
  • Loading branch information
billtomczak committed Aug 8, 2022
1 parent eed3688 commit 2f0c2ce
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 36 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"pacely/mailchimp-apiv3": "^1.0"
},
"replace": {
"psr/container": "^1.1 || ^2.0"
"psr/container": "*"
}
}
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/admin/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -538,17 +538,17 @@
},
{
"name": "nesbot/carbon",
"version": "2.60.0",
"version_normalized": "2.60.0.0",
"version": "2.61.0",
"version_normalized": "2.61.0.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "00a259ae02b003c563158b54fb6743252b638ea6"
"reference": "bdf4f4fe3a3eac4de84dbec0738082a862c68ba6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/00a259ae02b003c563158b54fb6743252b638ea6",
"reference": "00a259ae02b003c563158b54fb6743252b638ea6",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bdf4f4fe3a3eac4de84dbec0738082a862c68ba6",
"reference": "bdf4f4fe3a3eac4de84dbec0738082a862c68ba6",
"shasum": ""
},
"require": {
Expand All @@ -571,7 +571,7 @@
"phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20",
"squizlabs/php_codesniffer": "^3.4"
},
"time": "2022-07-27T15:57:48+00:00",
"time": "2022-08-06T12:41:24+00:00",
"bin": [
"bin/carbon"
],
Expand Down
12 changes: 6 additions & 6 deletions src/admin/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'joomlashack/osdownloads',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'c03dffc069065b8f97bee5ca5e90833284d74e17',
'reference' => 'eed3688304c452c43b363f4a0287f54e91bf8d02',
'type' => 'joomla-component',
'install_path' => __DIR__ . '/../../../../',
'aliases' => array(),
Expand Down Expand Up @@ -67,16 +67,16 @@
'joomlashack/osdownloads' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => 'c03dffc069065b8f97bee5ca5e90833284d74e17',
'reference' => 'eed3688304c452c43b363f4a0287f54e91bf8d02',
'type' => 'joomla-component',
'install_path' => __DIR__ . '/../../../../',
'aliases' => array(),
'dev_requirement' => false,
),
'nesbot/carbon' => array(
'pretty_version' => '2.60.0',
'version' => '2.60.0.0',
'reference' => '00a259ae02b003c563158b54fb6743252b638ea6',
'pretty_version' => '2.61.0',
'version' => '2.61.0.0',
'reference' => 'bdf4f4fe3a3eac4de84dbec0738082a862c68ba6',
'type' => 'library',
'install_path' => __DIR__ . '/../nesbot/carbon',
'aliases' => array(),
Expand All @@ -103,7 +103,7 @@
'psr/container' => array(
'dev_requirement' => false,
'replaced' => array(
0 => '^1.1 || ^2.0',
0 => '*',
),
),
'psr/http-message' => array(
Expand Down
13 changes: 9 additions & 4 deletions src/admin/vendor/nesbot/carbon/src/Carbon/CarbonInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -2150,18 +2150,23 @@ public function divide($divider)
*
* @return string
*/
public static function getDateIntervalSpec(DateInterval $interval)
public static function getDateIntervalSpec(DateInterval $interval, bool $microseconds = false)
{
$date = array_filter([
static::PERIOD_YEARS => abs($interval->y),
static::PERIOD_MONTHS => abs($interval->m),
static::PERIOD_DAYS => abs($interval->d),
]);

$seconds = abs($interval->s);
if ($microseconds && $interval->f > 0) {
$seconds = sprintf('%d.%06d', $seconds, abs($interval->f) * 1000000);
}

$time = array_filter([
static::PERIOD_HOURS => abs($interval->h),
static::PERIOD_MINUTES => abs($interval->i),
static::PERIOD_SECONDS => abs($interval->s),
static::PERIOD_SECONDS => $seconds,
]);

$specString = static::PERIOD_PREFIX;
Expand All @@ -2185,9 +2190,9 @@ public static function getDateIntervalSpec(DateInterval $interval)
*
* @return string
*/
public function spec()
public function spec(bool $microseconds = false)
{
return static::getDateIntervalSpec($this);
return static::getDateIntervalSpec($this, $microseconds);
}

/**
Expand Down
26 changes: 24 additions & 2 deletions src/admin/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use DateInterval;
use DatePeriod;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use InvalidArgumentException;
Expand Down Expand Up @@ -1507,9 +1508,9 @@ public function cast(string $className)
if (!method_exists($className, 'instance')) {
if (is_a($className, DatePeriod::class, true)) {
return new $className(
$this->getStartDate(),
$this->rawDate($this->getStartDate()),
$this->getDateInterval(),
$this->getEndDate() ? $this->getIncludedEndDate() : $this->getRecurrences(),
$this->getEndDate() ? $this->rawDate($this->getIncludedEndDate()) : $this->getRecurrences(),
$this->isStartExcluded() ? DatePeriod::EXCLUDE_START_DATE : 0
);
}
Expand Down Expand Up @@ -2618,4 +2619,25 @@ private function isInfiniteDate($date): bool
{
return $date instanceof CarbonInterface && ($date->isEndOfTime() || $date->isStartOfTime());
}

private function rawDate($date): ?DateTimeInterface
{
if ($date === false || $date === null) {
return null;
}

if ($date instanceof CarbonInterface) {
return $date->isMutable()
? $date->toDateTime()
: $date->toDateTimeImmutable();
}

if (\in_array(\get_class($date), [DateTime::class, DateTimeImmutable::class], true)) {
return $date;
}

$class = $date instanceof DateTime ? DateTime::class : DateTimeImmutable::class;

return new $class($date->format('Y-m-d H:i:s.u'), $date->getTimezone());
}
}
12 changes: 12 additions & 0 deletions src/admin/vendor/nesbot/carbon/src/Carbon/CarbonTimeZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,18 @@ public function __toString()
return $this->getName();
}

/**
* Return the type number:
*
* Type 1; A UTC offset, such as -0300
* Type 2; A timezone abbreviation, such as GMT
* Type 3: A timezone identifier, such as Europe/London
*/
public function getType(): int
{
return preg_match('/"timezone_type";i:(\d)/', serialize($this), $match) ? (int) $match[1] : 3;
}

/**
* Create a CarbonTimeZone from mixed input.
*
Expand Down
37 changes: 33 additions & 4 deletions src/admin/vendor/nesbot/carbon/src/Carbon/Traits/Comparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public function eq($date): bool
*/
public function equalTo($date): bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);

return $this == $this->resolveCarbon($date);
}

Expand Down Expand Up @@ -155,6 +158,9 @@ public function gt($date): bool
*/
public function greaterThan($date): bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);

return $this > $this->resolveCarbon($date);
}

Expand Down Expand Up @@ -216,7 +222,10 @@ public function gte($date): bool
*/
public function greaterThanOrEqualTo($date): bool
{
return $this >= $date;
$this->discourageNull($date);
$this->discourageBoolean($date);

return $this >= $this->resolveCarbon($date);
}

/**
Expand Down Expand Up @@ -256,6 +265,9 @@ public function lt($date): bool
*/
public function lessThan($date): bool
{
$this->discourageNull($date);
$this->discourageBoolean($date);

return $this < $this->resolveCarbon($date);
}

Expand Down Expand Up @@ -317,7 +329,10 @@ public function lte($date): bool
*/
public function lessThanOrEqualTo($date): bool
{
return $this <= $date;
$this->discourageNull($date);
$this->discourageBoolean($date);

return $this <= $this->resolveCarbon($date);
}

/**
Expand Down Expand Up @@ -351,10 +366,10 @@ public function between($date1, $date2, $equal = true): bool
}

if ($equal) {
return $this->greaterThanOrEqualTo($date1) && $this->lessThanOrEqualTo($date2);
return $this >= $date1 && $this <= $date2;
}

return $this->greaterThan($date1) && $this->lessThan($date2);
return $this > $date1 && $this < $date2;
}

/**
Expand Down Expand Up @@ -1067,4 +1082,18 @@ public function isEndOfTime(): bool
{
return $this->endOfTime ?? false;
}

private function discourageNull($value): void
{
if ($value === null) {
@trigger_error("Since 2.61.0, it's deprecated to compare a date to null, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate null values.", \E_USER_DEPRECATED);
}
}

private function discourageBoolean($value): void
{
if (\is_bool($value)) {
@trigger_error("Since 2.61.0, it's deprecated to compare a date to true or false, meaning of such comparison is ambiguous and will no longer be possible in 3.0.0, you should explicitly pass 'now' or make an other check to eliminate boolean values.", \E_USER_DEPRECATED);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static function instance($date)

$instance = new static($date->format('Y-m-d H:i:s.u'), $date->getTimezone());

if ($date instanceof CarbonInterface || $date instanceof Options) {
if ($date instanceof CarbonInterface) {
$settings = $date->getSettings();

if (!$date->hasLocalTranslator()) {
Expand Down
Loading

0 comments on commit 2f0c2ce

Please sign in to comment.