Skip to content

Commit

Permalink
Merge pull request #2519 from briannesbitt/feature/add-unit-decimal
Browse files Browse the repository at this point in the history
Allow to add and subtract decimal numbers of any unit
  • Loading branch information
kylekatarnls committed Dec 5, 2021
2 parents 33ccae4 + cb20bc3 commit 503de0d
Show file tree
Hide file tree
Showing 31 changed files with 921 additions and 788 deletions.
18 changes: 9 additions & 9 deletions phpdoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'add'.ucFirst($plUnit).'(int $value = 1)',
'add'.ucFirst($plUnit).'(int|float $value = 1)',
"Add $plUnitName (the \$value count passed in) to the instance (using date interval).",
];
$autoDocLines[] = [
Expand All @@ -324,7 +324,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'sub'.ucFirst($plUnit).'(int $value = 1)',
'sub'.ucFirst($plUnit).'(int|float $value = 1)',
"Sub $plUnitName (the \$value count passed in) to the instance (using date interval).",
];
$autoDocLines[] = [
Expand All @@ -345,7 +345,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'add'.ucFirst($plUnit).'WithOverflow(int $value = 1)',
'add'.ucFirst($plUnit).'WithOverflow(int|float $value = 1)',
"Add $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly allowed.",
];
$autoDocLines[] = [
Expand All @@ -357,7 +357,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'sub'.ucFirst($plUnit).'WithOverflow(int $value = 1)',
'sub'.ucFirst($plUnit).'WithOverflow(int|float $value = 1)',
"Sub $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly allowed.",
];
$autoDocLines[] = [
Expand All @@ -371,7 +371,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'add'.ucFirst($plUnit)."$alias(int \$value = 1)",
'add'.ucFirst($plUnit)."$alias(int|float \$value = 1)",
"Add $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly forbidden.",
];
$autoDocLines[] = [
Expand All @@ -383,7 +383,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'sub'.ucFirst($plUnit)."$alias(int \$value = 1)",
'sub'.ucFirst($plUnit)."$alias(int|float \$value = 1)",
"Sub $plUnitName (the \$value count passed in) to the instance (using date interval) with overflow explicitly forbidden.",
];
$autoDocLines[] = [
Expand All @@ -407,7 +407,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'addReal'.ucFirst($plUnit).'(int $value = 1)',
'addReal'.ucFirst($plUnit).'(int|float $value = 1)',
"Add $plUnitName (the \$value count passed in) to the instance (using timestamp).",
];
$autoDocLines[] = [
Expand All @@ -419,7 +419,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'self',
'subReal'.ucFirst($plUnit).'(int $value = 1)',
'subReal'.ucFirst($plUnit).'(int|float $value = 1)',
"Sub $plUnitName (the \$value count passed in) to the instance (using timestamp).",
];
$autoDocLines[] = [
Expand All @@ -431,7 +431,7 @@ function dumpParameter($method, ReflectionParameter $parameter)
$autoDocLines[] = [
'@method',
'CarbonPeriod',
$plUnit.'Until($endDate = null, int $factor = 1)',
$plUnit.'Until($endDate = null, int|float $factor = 1)',
"Return an iterable period from current date to given end (string, DateTime or Carbon instance) for each $unitName or every X $plUnitName if a factor is given.",
];

Expand Down
2 changes: 1 addition & 1 deletion phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties>
<property name="maximum" value="25" />
<property name="maximum" value="26" />
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
Expand Down
8 changes: 4 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ parameters:
- '#^Call to an undefined method Carbon\\Carbon(Interface|Immutable)?::(super|noThis)\(\)\.$#'
- '#Call to an undefined method DateTimeInterface::setTimezone\(\)\.#'
- '#should return (\S*)static\(Carbon\\CarbonInterval\)\|null but returns Carbon\\CarbonInterval(\|null)?\.$#'
- '#should return (\S*)\$this\(Carbon\\CarbonInterval\) but returns Carbon\\CarbonInterval\.$#'
# - '#should return (\S*)static\(Carbon\\CarbonPeriod\) but returns Carbon\\CarbonPeriod\.$#'
- '#should return (\S*)static\(Carbon\\Carbon\) but returns Carbon\\Carbon(Interface)?\.$#'
- '#should return (\S*)static\(Carbon\\CarbonImmutable\) but returns Carbon\\Carbon(Immutable|Interface)\.$#'
- '#should return (\S*)static\(Carbon\\CarbonImmutable\)\|null but returns Carbon\\Carbon(Immutable|Interface)\|null\.$#'
- '#should return (\S*)static\(Carbon\\Carbon\)(\|null)? but returns Carbon\\Carbon(Interface)?(\|null)?\.$#'
- '#should return (\S*)static\(Carbon\\CarbonImmutable\)(\|null)? but returns Carbon\\Carbon(Immutable|Interface)(\|null)?\.$#'
- '#^PHPDoc tag @return with type Carbon\\CarbonTimeZone is not subtype of native type static\(Carbon\\CarbonTimeZone\)\.$#'
- '#^PHPDoc tag @mixin contains invalid type Carbon\\Traits\\DeprecatedProperties\.$#'
- '#^Implementing PHPStan\\Reflection\\Php\\BuiltinMethodReflection is not covered by backward compatibility promise\.#'
- '#^Calling PHPStan\\Reflection\\Php\\PhpMethodReflectionFactory::create\(\) is not covered by backward compatibility promise\.#'
# - '#^Protected property Carbon\\CarbonPeriod::\$.+ overriding public property DatePeriod::\$.+ should also be public\.$#'
- '#^Method Carbon\\CarbonInterval::withOriginal\(\) should return T but returns \(Carbon\\CarbonInterval&T\)\|T\.$#'
- '#^Method Carbon\\CarbonInterval::castIntervalToClass\(\) should return T of DateInterval but returns \(Carbon\CarbonInterval&T of DateInterval\)|T of DateInterval\.$#'
- '#^Method Carbon\\CarbonInterval::[a-zA-Z]+\(\) should return \$this\(Carbon\\CarbonInterval\) but returns static\(Carbon\\CarbonInterval\)\.#'
excludePaths:
- '*/src/Carbon/CarbonPeriod.php'
- '*/src/Carbon/Laravel/ServiceProvider.php'
Expand Down

0 comments on commit 503de0d

Please sign in to comment.