Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Real diff in favor of UTC diff #2975

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ jobs:

- name: Select PHPUnit version
if: matrix.phpunit
run: composer require --no-update phpunit/phpunit:^${{ matrix.phpunit }} --no-interaction --dev
shell: bash
run: composer require --no-update --no-interaction --dev "phpunit/phpunit:^${{ matrix.phpunit }}"

- name: Remove conflicting optional dependencies
if: matrix.phpunit >= 11
run: composer remove --no-update ondrejmirtes/better-reflection --no-interaction --dev
run: composer remove --no-update --no-interaction --dev ondrejmirtes/better-reflection

- name: Downgrade nikic/php-parser
if: matrix.phpunit < 11
shell: bash
run: composer require --no-update --no-interaction --dev "nikic/php-parser:^4"

- name: Install dependencies
uses: nick-fields/retry@v3
Expand All @@ -76,7 +82,7 @@ jobs:
timeout_minutes: 10
max_attempts: 3
command: |
composer remove --no-update phpmd/phpmd friendsofphp/php-cs-fixer kylekatarnls/multi-tester --no-interaction --dev;
composer remove --no-update --no-interaction --dev phpmd/phpmd friendsofphp/php-cs-fixer kylekatarnls/multi-tester;
composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }} ${{ matrix.classmap-authoritative && '--classmap-authoritative' || '' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};

- name: Run test suite
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
"require-dev": {
"doctrine/dbal": "^3.6.3 || ^4.0",
"doctrine/orm": "^2.15.2 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.18.0",
"kylekatarnls/multi-tester": "^2.2.0",
"ondrejmirtes/better-reflection": "^6.11.0.0",
"phpmd/phpmd": "^2.13.0",
"phpstan/extension-installer": "^1.3.0",
"phpstan/phpstan": "^1.10.20",
"phpunit/phpunit": "^10.2.2",
"squizlabs/php_codesniffer": "^3.7.2"
"friendsofphp/php-cs-fixer": "^3.52.1",
"kylekatarnls/multi-tester": "^2.5.3",
"ondrejmirtes/better-reflection": "^6.25.0.4",
"phpmd/phpmd": "^2.15.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.65",
"phpunit/phpunit": "^10.5.15",
"squizlabs/php_codesniffer": "^3.9.0"
},
"provide": {
"psr/clock-implementation": "1.0"
Expand Down
18 changes: 12 additions & 6 deletions phpdoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
['call', 'isSameUnit'],
['call', 'setUnit'],
['call', 'addUnit'],
['call', 'addRealUnit'],
['call', 'addUTCUnit'],
['call', 'roundUnit'],
['call', 'diffForHumans'],
];
Expand Down Expand Up @@ -418,33 +418,33 @@ function dumpParameter(string $method, ReflectionParameter $parameter): string

break;

case 'addRealUnit':
case 'addUTCUnit':
$unit = $vars->name;
$unitName = unitName($unit);
$plUnit = pluralize($unit);
$plUnitName = pluralize($unitName);
$autoDocLines[] = [
'@method',
'self',
'addReal'.ucFirst($plUnit).'(int|float $value = 1)',
'addUTC'.ucFirst($plUnit).'(int|float $value = 1)',
"Add $plUnitName (the \$value count passed in) to the instance (using timestamp).",
];
$autoDocLines[] = [
'@method',
'self',
'addReal'.ucFirst($unit).'()',
'addUTC'.ucFirst($unit).'()',
"Add one $unitName to the instance (using timestamp).",
];
$autoDocLines[] = [
'@method',
'self',
'subReal'.ucFirst($plUnit).'(int|float $value = 1)',
'subUTC'.ucFirst($plUnit).'(int|float $value = 1)',
"Sub $plUnitName (the \$value count passed in) to the instance (using timestamp).",
];
$autoDocLines[] = [
'@method',
'self',
'subReal'.ucFirst($unit).'()',
'subUTC'.ucFirst($unit).'()',
"Sub one $unitName to the instance (using timestamp).",
];
$autoDocLines[] = [
Expand All @@ -453,6 +453,12 @@ function dumpParameter(string $method, ReflectionParameter $parameter): string
$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.",
];
$autoDocLines[] = [
'@method',
'float',
'diffInUTC'.ucFirst($plUnit).'(DateTimeInterface|string|null $date, bool $absolute = false)',
"Convert current and given date in UTC timezone and return a floating number of $plUnitName.",
];

break;

Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ parameters:
- '#^Call to an undefined static method#'
- '#^Call to an undefined method Carbon\\Carbon(Immutable)?::floatDiffIn([A-Za-z]+)\(\)\.$#'
- '#^Call to an undefined method Carbon\\Carbon(Immutable)?::diffInReal([A-Za-z]+)\(\)\.$#'
- '#^Call to an undefined method Carbon\\Carbon(Immutable)?::(add|sub)Real([A-Za-z]+)\(\)\.$#'
- '#^Unsafe usage of new static\(\)\.$#'
- '#^Method Carbon\\Carbon(Interface|Immutable)?::(add|sub)[A-Z][A-Za-z]+\(\) invoked with 1 parameter, 0 required\.$#'
- '#^Call to an undefined method Carbon\\Carbon(Interface|Immutable)?::(super|noThis|toAppTz|copyWithAppTz)\(\)\.$#'
Expand Down
Loading
Loading