Skip to content

Commit 9228ce9

Browse files
authored
Merge pull request #13 from thecaliskan/2.x
Added PHP 8.4 support and fixed CS for 2.x
2 parents 1e9d506 + 142f0f5 commit 9228ce9

35 files changed

Lines changed: 72 additions & 51 deletions

.github/workflows/tests.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
- php: 8.3
7575
setup: lowest
7676

77+
- php: 8.4
78+
7779
- php: 8.1
7880
laravel: true
7981
reference: 10.x
@@ -87,6 +89,14 @@ jobs:
8789
laravel: true
8890
reference: master
8991

92+
- php: 8.3
93+
laravel: true
94+
reference: master
95+
96+
- php: 8.4
97+
laravel: true
98+
reference: master
99+
90100
- php: 8.2
91101
laravel: true
92102
reference: master
@@ -148,7 +158,7 @@ jobs:
148158
if [[ "${{ matrix.laravel }}" != 'true' ]]; then
149159
composer remove --no-update kylekatarnls/multi-tester --no-interaction --dev;
150160
fi;
151-
${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }}
161+
${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.6.21 --no-interaction --dev;' || '' }}
152162
composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }} ${{ matrix.classmap-authoritative && '--classmap-authoritative' || '' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};
153163
154164
- name: Run test suite
@@ -230,6 +240,8 @@ jobs:
230240
- php: 8.3
231241
setup: lowest
232242

243+
- php: 8.4
244+
233245
name: PHP ${{ matrix.php }} - ${{ matrix.setup || 'stable' }} - windows
234246

235247
steps:
@@ -263,7 +275,7 @@ jobs:
263275
max_attempts: 3
264276
command: |
265277
composer remove --no-update kylekatarnls/multi-tester phpmd/phpmd friendsofphp/php-cs-fixer --no-interaction --dev;
266-
${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.5.20 --no-interaction --dev;' || '' }}
278+
${{ matrix.php >= 8.1 && 'composer require --no-update phpunit/phpunit:^9.6.21 --no-interaction --dev;' || '' }}
267279
composer update --prefer-dist --no-progress --prefer-${{ matrix.setup || 'stable' }}${{ matrix.php >= 8.2 && ' --ignore-platform-reqs' || '' }};
268280
269281
- name: Run test suite

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
'single_quote' => true,
8888
'space_after_semicolon' => true,
8989
'standardize_not_equals' => true,
90+
'statement_indentation' => false,
9091
'ternary_operator_spaces' => true,
9192
'trailing_comma_in_multiline' => true,
9293
'trim_array_spaces' => true,

src/Carbon/AbstractTranslator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function get($locale = null)
7878
return static::$singletons[$key];
7979
}
8080

81-
public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
81+
public function __construct($locale, ?MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
8282
{
8383
parent::setLocale($locale);
8484
$this->initializing = true;
@@ -162,7 +162,7 @@ public function resetMessages($locale = null)
162162
$this->assertValidLocale($locale);
163163

164164
foreach ($this->getDirectories() as $directory) {
165-
$data = @include sprintf('%s/%s.php', rtrim($directory, '\\/'), $locale);
165+
$data = @include \sprintf('%s/%s.php', rtrim($directory, '\\/'), $locale);
166166

167167
if ($data !== false) {
168168
$this->messages[$locale] = $data;

src/Carbon/CarbonInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ public static function createFromTimeString($time, $tz = null);
11621162
*
11631163
* @return static
11641164
*/
1165+
#[ReturnTypeWillChange]
11651166
public static function createFromTimestamp($timestamp, $tz = null);
11661167

11671168
/**

src/Carbon/CarbonInterval.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ public static function fromString($intervalDefinition)
980980

981981
default:
982982
throw new InvalidIntervalException(
983-
sprintf('Invalid part %s in definition %s', $part, $intervalDefinition)
983+
\sprintf('Invalid part %s in definition %s', $part, $intervalDefinition)
984984
);
985985
}
986986
}
@@ -2329,7 +2329,7 @@ public static function getDateIntervalSpec(DateInterval $interval, bool $microse
23292329

23302330
$seconds = abs($interval->s);
23312331
if ($microseconds && $interval->f > 0) {
2332-
$seconds = sprintf('%d.%06d', $seconds, abs($interval->f) * 1000000);
2332+
$seconds = \sprintf('%d.%06d', $seconds, abs($interval->f) * 1000000);
23332333
}
23342334

23352335
$time = array_filter([

src/Carbon/CarbonPeriod.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ public function getDateInterval()
10171017
*
10181018
* @return CarbonInterface
10191019
*/
1020-
public function getStartDate(string $rounding = null)
1020+
public function getStartDate(?string $rounding = null)
10211021
{
10221022
$date = $this->startDate->avoidMutation();
10231023

@@ -1031,7 +1031,7 @@ public function getStartDate(string $rounding = null)
10311031
*
10321032
* @return CarbonInterface|null
10331033
*/
1034-
public function getEndDate(string $rounding = null)
1034+
public function getEndDate(?string $rounding = null)
10351035
{
10361036
if (!$this->endDate) {
10371037
return null;
@@ -1899,7 +1899,7 @@ public function shiftTimezone($timezone)
18991899
*
19001900
* @return CarbonInterface
19011901
*/
1902-
public function calculateEnd(string $rounding = null)
1902+
public function calculateEnd(?string $rounding = null)
19031903
{
19041904
if ($end = $this->getEndDate($rounding)) {
19051905
return $end;

src/Carbon/CarbonTimeZone.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getAbbr($dst = false)
155155
*
156156
* @return string
157157
*/
158-
public function toOffsetName(DateTimeInterface $date = null)
158+
public function toOffsetName(?DateTimeInterface $date = null)
159159
{
160160
return static::getOffsetNameFromMinuteOffset(
161161
$this->getOffset($date ?: Carbon::now($this)) / 60
@@ -169,7 +169,7 @@ public function toOffsetName(DateTimeInterface $date = null)
169169
*
170170
* @return CarbonTimeZone
171171
*/
172-
public function toOffsetTimeZone(DateTimeInterface $date = null)
172+
public function toOffsetTimeZone(?DateTimeInterface $date = null)
173173
{
174174
return new static($this->toOffsetName($date));
175175
}
@@ -185,7 +185,7 @@ public function toOffsetTimeZone(DateTimeInterface $date = null)
185185
*
186186
* @return string|false
187187
*/
188-
public function toRegionName(DateTimeInterface $date = null, $isDst = 1)
188+
public function toRegionName(?DateTimeInterface $date = null, $isDst = 1)
189189
{
190190
$name = $this->getName();
191191
$firstChar = substr($name, 0, 1);
@@ -227,7 +227,7 @@ public function toRegionName(DateTimeInterface $date = null, $isDst = 1)
227227
*
228228
* @return CarbonTimeZone|false
229229
*/
230-
public function toRegionTimeZone(DateTimeInterface $date = null)
230+
public function toRegionTimeZone(?DateTimeInterface $date = null)
231231
{
232232
$tz = $this->toRegionName($date);
233233

src/Carbon/Exceptions/BadComparisonUnitException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BadComparisonUnitException extends UnitException
2929
* @param int $code
3030
* @param Throwable|null $previous
3131
*/
32-
public function __construct($unit, $code = 0, Throwable $previous = null)
32+
public function __construct($unit, $code = 0, ?Throwable $previous = null)
3333
{
3434
$this->unit = $unit;
3535

src/Carbon/Exceptions/BadFluentConstructorException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class BadFluentConstructorException extends BaseBadMethodCallException implement
3030
* @param int $code
3131
* @param Throwable|null $previous
3232
*/
33-
public function __construct($method, $code = 0, Throwable $previous = null)
33+
public function __construct($method, $code = 0, ?Throwable $previous = null)
3434
{
3535
$this->method = $method;
3636

37-
parent::__construct(sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous);
37+
parent::__construct(\sprintf("Unknown fluent constructor '%s'.", $method), $code, $previous);
3838
}
3939

4040
/**

src/Carbon/Exceptions/BadFluentSetterException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class BadFluentSetterException extends BaseBadMethodCallException implements Bad
3030
* @param int $code
3131
* @param Throwable|null $previous
3232
*/
33-
public function __construct($setter, $code = 0, Throwable $previous = null)
33+
public function __construct($setter, $code = 0, ?Throwable $previous = null)
3434
{
3535
$this->setter = $setter;
3636

37-
parent::__construct(sprintf("Unknown fluent setter '%s'", $setter), $code, $previous);
37+
parent::__construct(\sprintf("Unknown fluent setter '%s'", $setter), $code, $previous);
3838
}
3939

4040
/**

0 commit comments

Comments
 (0)