Skip to content

Commit

Permalink
#2070 Fix CarbonInterface and CarbonInterval typing
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed May 6, 2020
1 parent 4015dac commit 3f9ca81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 0 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ parameters:
- '#^Using \$this in static method Carbon\\Carbon(Interface|Immutable|Interval|Period)?::loadMixinTrait\(\)\.$#'
- '#^Variable \$this in isset\(\) always exists and is not nullable\.$#'
- '#^Call to an undefined method Carbon\\Carbon(Interface|Immutable)?::(super|noThis)\(\)\.$#'
- '#Class Symfony\\Component\\Translation\\MessageSelector not found\.#'
- '#Class Symfony\\Component\\Translation\\IdentityTranslator does not have a constructor and must be instantiated without any parameters\.#'
- '#Instantiated class Symfony\\Component\\Translation\\MessageSelector not found\.#'
- '#Call to static method set\(\) on an unknown class Symfony\\Component\\Translation\\PluralizationRules\.#'
- '#Call to an undefined method DateTimeInterface::setTimezone\(\)\.#'
excludes_analyse:
Expand Down
1 change: 1 addition & 0 deletions src/Carbon/CarbonInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use InvalidArgumentException;
use JsonSerializable;
use ReflectionException;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Common interface for Carbon and CarbonImmutable.
Expand Down
5 changes: 3 additions & 2 deletions src/Carbon/CarbonInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use DateInterval;
use Exception;
use InvalidArgumentException;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* A simple API extension for DateInterval.
Expand Down Expand Up @@ -185,7 +186,7 @@ class CarbonInterval extends DateInterval
/**
* A translator to ... er ... translate stuff
*
* @var \Symfony\Component\Translation\TranslatorInterface
* @var TranslatorInterface
*/
protected static $translator;

Expand Down Expand Up @@ -1522,7 +1523,7 @@ public function forHumans($syntax = null, $short = false, $parts = -1, $options
$isFuture = $this->invert === 1;
$transId = $relativeToNow ? ($isFuture ? 'from_now' : 'ago') : ($isFuture ? 'after' : 'before');

/** @var \Symfony\Component\Translation\Translator $translator */
/** @var Translator $translator */
$translator = $this->getLocalTranslator();

$handleDeclensions = function ($unit, $count) use ($interpolations, $transId, $translator, $altNumbers, $absolute) {
Expand Down

0 comments on commit 3f9ca81

Please sign in to comment.