Skip to content

Commit 271e3ff

Browse files
committed
feat: add compatibility with PHP 8.5
1 parent 3f53c03 commit 271e3ff

File tree

105 files changed

+2984
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2984
-7
lines changed

.github/workflows/php-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
- "8.2"
3030
- "8.3"
3131
- "8.4"
32+
- "8.5"
3233
dependencies:
3334
- "lowest"
3435
- "highest"

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
This is a PHP_CodeSniffer coding standard package that provides two rulesets: `Fox91CodingStandard` (standard) and `Fox91CodingStandardStrict` (strict). The project is distributed as a Composer package and integrates multiple PHP coding standard tools.
88

9-
**Supported PHP Versions**: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4
9+
**Supported PHP Versions**: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5
1010

1111
## Essential Commands
1212

@@ -41,7 +41,7 @@ composer install
4141
```
4242

4343
The test script:
44-
- Creates fixed versions for PHP 7.4, 8.0, 8.1, 8.2, 8.3, and 8.4
44+
- Creates fixed versions for PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, and 8.5
4545
- Runs `phpcbf` against test inputs in `tests/input/`
4646
- Outputs fixed files to `tests/fixed/php-{version}/{Standard}/`
4747

@@ -99,7 +99,7 @@ Optional:
9999
## CI/CD
100100

101101
GitHub Actions workflow (`.github/workflows/php-ci.yml`) tests against:
102-
- All supported PHP versions (7.4 through 8.4)
102+
- All supported PHP versions (7.4 through 8.5)
103103
- Both "lowest" and "highest" dependency versions
104104
- Validates composer.json
105105
- Lists installed standards and sniffs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Downloads](https://img.shields.io/packagist/dt/fox91/coding-standard.svg?colorB=007EC6)](https://packagist.org/packages/fox91/coding-standard)
55
[![Build status](https://github.com/fox91/php-coding-standard/workflows/php-ci/badge.svg?branch=main)](https://github.com/fox91/php-coding-standard/actions?query=workflow%3Aphp-ci+branch%3Amain)
66

7-
Compatible with PHP `7.4`, `8.0`, `8.1`, `8.2`, `8.3` and `8.4`.
7+
Compatible with PHP `7.4`, `8.0`, `8.1`, `8.2`, `8.3`, `8.4` and `8.5`.
88

99
## Included tools
1010

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"minimum-stability": "dev",
1717
"prefer-stable": true,
1818
"require": {
19-
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
19+
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
2020
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
2121
"phpcompatibility/php-compatibility": "^9.3",
2222
"sirbrillig/phpcs-import-detection": "^1.3",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Spacing;
5+
6+
final class ClassPropertySpacing
7+
{
8+
public bool $foo;
9+
10+
/** @var array<string> */
11+
public array $bar;
12+
13+
/** @var array<string> */
14+
public array $baz;
15+
16+
public int $qux;
17+
18+
public int $fred;
19+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace ControlStructures;
5+
6+
use InvalidArgumentException;
7+
use Throwable;
8+
9+
use const PHP_VERSION;
10+
11+
class ControlStructures
12+
{
13+
private const VERSION = PHP_VERSION;
14+
15+
/** @return iterable<int> */
16+
public function varAndIfNoSpaceBetween(): iterable
17+
{
18+
$var = 1;
19+
if (self::VERSION === 0) {
20+
yield 0;
21+
}
22+
}
23+
24+
/** @return iterable<int> */
25+
public function ifAndYieldSpaceBetween(): iterable
26+
{
27+
if (self::VERSION === 0) {
28+
yield 0;
29+
}
30+
yield 1;
31+
}
32+
33+
/** @return iterable<int> */
34+
public function ifAndYieldFromSpaceBetween(): iterable
35+
{
36+
if (self::VERSION === 0) {
37+
yield 0;
38+
}
39+
yield from [];
40+
}
41+
42+
public function ifAndThrowSpaceBetween(): void
43+
{
44+
if (self::VERSION === 0) {
45+
return;
46+
}
47+
throw new InvalidArgumentException();
48+
}
49+
50+
public function ifAndReturnSpaceBetween(): int
51+
{
52+
if (self::VERSION === 0) {
53+
return 0;
54+
}
55+
56+
return 1;
57+
}
58+
59+
public function noSpaceAroundCase(): void
60+
{
61+
switch (self::VERSION) {
62+
case 1:
63+
case 2:
64+
// do something
65+
break;
66+
case 3:
67+
// do something else
68+
break;
69+
default:
70+
}
71+
}
72+
73+
public function spaceBelowBlocks(): void
74+
{
75+
if (true) {
76+
echo 1;
77+
}
78+
do {
79+
echo 2;
80+
} while (true);
81+
while (true) {
82+
echo 3;
83+
}
84+
for ($i = 0; $i < 1; $i++) {
85+
echo $i;
86+
}
87+
foreach ([] as $item) {
88+
echo $item;
89+
}
90+
switch (true) {
91+
default:
92+
}
93+
try {
94+
echo 4;
95+
} catch (Throwable) {
96+
}
97+
echo 5;
98+
}
99+
100+
public function spaceAroundMultilineIfs(): void
101+
{
102+
if (true
103+
&& false
104+
) {
105+
echo 1;
106+
} elseif (false
107+
|| true
108+
) {
109+
echo 2;
110+
}
111+
}
112+
113+
public function spacingAroundCasesWithBreakAndReturn(): void
114+
{
115+
switch (true) {
116+
case 1:
117+
throw new InvalidArgumentException();
118+
119+
case 2:
120+
return;
121+
122+
case 3:
123+
break;
124+
125+
case 4:
126+
echo 1;
127+
128+
}
129+
}
130+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Example;
5+
6+
class EarlyReturn
7+
{
8+
public function bar(): bool
9+
{
10+
if ($bar === 'bar') {
11+
return true;
12+
} else {
13+
return false;
14+
}
15+
}
16+
17+
public function foo(): ?string
18+
{
19+
foreach ($items as $item) {
20+
if (!($item->isItem())) {
21+
return 'There is an item that is not an item';
22+
} else {
23+
continue;
24+
}
25+
}
26+
27+
return null;
28+
}
29+
30+
public function baz(): string
31+
{
32+
if ($number > 0) {
33+
return 'Number is grater then 0';
34+
} else {
35+
exit;
36+
}
37+
}
38+
39+
public function quoox(): bool
40+
{
41+
if (true === 'true') {
42+
if (false === false) {
43+
return true;
44+
}
45+
} else {
46+
return false;
47+
}
48+
49+
return true;
50+
}
51+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace ExampleBackedEnum;
5+
6+
enum ExampleBackedEnum : int
7+
{
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Exceptions;
5+
6+
use Exception;
7+
use Throwable;
8+
9+
try {
10+
throw new Exception();
11+
} catch (Throwable $throwable) {
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Types;
5+
6+
class LowCaseTypes
7+
{
8+
public function stringToInt(String $string): int
9+
{
10+
return (int) $string;
11+
}
12+
13+
public function returnString(): String
14+
{
15+
return 'foo';
16+
}
17+
}

0 commit comments

Comments
 (0)