Skip to content

Commit 62467ba

Browse files
committed
Bump minimum PHP to 7.4
1 parent ddae987 commit 62467ba

File tree

9 files changed

+55
-60
lines changed

9 files changed

+55
-60
lines changed

.github/workflows/main.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-24.04
1010
strategy:
1111
matrix:
12-
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
12+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
1313
name: PHP ${{ matrix.php }}
1414
steps:
1515
- uses: actions/checkout@v6
@@ -32,7 +32,7 @@ jobs:
3232
fetch-depth: 5
3333
- uses: shivammathur/setup-php@v2
3434
with:
35-
php-version: '7.1'
35+
php-version: '7.4'
3636
extensions: xml
3737
coverage: none
3838
- run: composer update --no-progress --prefer-lowest

.php-cs-fixer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
'@PhpCsFixer:risky' => true,
1414
'@PHP71Migration' => true,
1515
'@PHP71Migration:risky' => true,
16+
'@PHP73Migration' => true,
17+
'@PHP74Migration' => true,
18+
'@PHP74Migration:risky' => true,
19+
'@PHPUnit75Migration:risky' => true,
20+
'@PHPUnit7x5Migration:risky' => true,
21+
'@PHPUnit84Migration:risky' => true,
22+
'@PHPUnit8x4Migration:risky' => true,
23+
'@PHPUnit91Migration:risky' => true,
24+
'@PHPUnit9x1Migration:risky' => true,
1625
'array_syntax' => ['syntax' => 'short'],
1726
'php_unit_test_class_requires_covers' => false,
1827
'backtick_to_shell_exec' => true,

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.1 || ^8.0",
19+
"php": "^7.4 || ^8.0",
2020
"ext-dom": "*",
2121
"ext-filter": "*",
2222
"ext-libxml": "*",
@@ -25,11 +25,11 @@
2525
},
2626
"require-dev": {
2727
"friendsofphp/php-cs-fixer": "^3.0",
28-
"phpstan/phpstan": "^1.0 || ^2.0",
29-
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
30-
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
31-
"phpstan/phpstan-webmozart-assert": "^1.0 || ^2.0",
32-
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
28+
"phpstan/phpstan": "^2.0",
29+
"phpstan/phpstan-phpunit": "^2.0",
30+
"phpstan/phpstan-strict-rules": "^2.0",
31+
"phpstan/phpstan-webmozart-assert": "^2.0",
32+
"phpunit/phpunit": "^9.1 || ^10.0"
3333
},
3434
"config": {
3535
"sort-packages": true

example/feed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use AtomGenerator\Entry;
66
use AtomGenerator\Feed;
77

8-
include_once 'vendor/autoload.php';
8+
include_once __DIR__.'/../vendor/autoload.php';
99

1010
$entry = new Entry();
1111
$entry->setTitle('Post', 'text');

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
colors="true">
6-
<coverage>
6+
<source>
77
<include>
88
<directory suffix=".php">src</directory>
99
<directory suffix=".php">tests</directory>
1010
</include>
11-
</coverage>
11+
</source>
1212
<testsuites>
1313
<testsuite name="default">
1414
<directory>tests</directory>

src/AbstractElement.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,29 @@
1212

1313
abstract class AbstractElement
1414
{
15-
/** @var string */
16-
protected $id;
15+
protected string $id;
1716

18-
/** @var string */
19-
protected $title;
17+
protected string $title;
2018

21-
/** @var null|string */
22-
protected $titleType;
19+
protected ?string $titleType = null;
2320

24-
/** @var DateTimeInterface */
25-
protected $updatedDateTime;
21+
protected DateTimeInterface $updatedDateTime;
2622

27-
/** @var null|string */
28-
protected $rights;
23+
protected ?string $rights = null;
2924

30-
/** @var null|string */
31-
protected $rightsType;
25+
protected ?string $rightsType = null;
3226

3327
/** @var string[][] */
34-
protected $authors = [];
28+
protected array $authors = [];
3529

3630
/** @var string[][] */
37-
protected $contributors = [];
31+
protected array $contributors = [];
3832

3933
/** @var string[][] */
40-
protected $categories = [];
34+
protected array $categories = [];
4135

4236
/** @var string[][] */
43-
protected $links = [];
37+
protected array $links = [];
4438

4539
/**
4640
* AbstractElement constructor.

src/Entry.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,19 @@
1010

1111
class Entry extends AbstractElement
1212
{
13-
/** @var null|string */
14-
protected $summary;
13+
protected ?string $summary = null;
1514

16-
/** @var null|string */
17-
protected $summaryType;
15+
protected ?string $summaryType = null;
1816

19-
/** @var null|string */
20-
protected $content;
17+
protected ?string $content = null;
2118

22-
/** @var null|string */
23-
protected $contentType;
19+
protected ?string $contentType = null;
2420

25-
/** @var null|string */
26-
protected $contentSrc;
21+
protected ?string $contentSrc = null;
2722

28-
/** @var null|DateTimeInterface */
29-
protected $publishedDateTime;
23+
protected ?DateTimeInterface $publishedDateTime = null;
3024

31-
/** @var null|Feed */
32-
protected $source;
25+
protected ?Feed $source = null;
3326

3427
public function setSummary(?string $summary, ?string $type = null): void
3528
{

src/Feed.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,38 @@
55
namespace AtomGenerator;
66

77
use DOMDocument;
8+
use Exception;
89
use LibXMLError;
910
use SimpleXMLElement;
1011
use Webmozart\Assert\Assert;
1112

1213
class Feed extends AbstractElement
1314
{
1415
/** @var Entry[] */
15-
protected $entries = [];
16+
protected array $entries = [];
1617

17-
/** @var bool */
18-
protected $prettify = false;
18+
protected bool $prettify = false;
1919

20-
/** @var null|string */
21-
protected $language;
20+
protected ?string $language = null;
2221

23-
/** @var null|string */
24-
protected $subtitle;
22+
protected ?string $subtitle = null;
2523

26-
/** @var null|string */
27-
protected $icon;
24+
protected ?string $icon = null;
2825

29-
/** @var null|string */
30-
protected $logo;
26+
protected ?string $logo = null;
3127

32-
/** @var null|string */
33-
protected $generator;
28+
protected ?string $generator = null;
3429

35-
/** @var null|string */
36-
protected $generatorVersion;
30+
protected ?string $generatorVersion = null;
3731

38-
/** @var null|string */
39-
protected $generatorUri;
32+
protected ?string $generatorUri = null;
4033

4134
/**
4235
* @var array[]
4336
*
4437
* @phpstan-var array<array{ns: string, uri: string, name: string, value: string, attributes: string[]}>
4538
*/
46-
protected $customElements = [];
39+
protected array $customElements = [];
4740

4841
/**
4942
* Feed constructor.
@@ -174,6 +167,9 @@ public function addChildrenTo(SimpleXMLElement $parent): void
174167
}
175168
}
176169

170+
/**
171+
* @throws Exception
172+
*/
177173
public function getSimpleXML(): SimpleXMLElement
178174
{
179175
$attributes = [];

tests/FeedTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
final class FeedTest extends TestCase
1818
{
1919
protected const TEST_FEED_XML_PATH_1 = __DIR__.'/feed_1.xml';
20+
2021
protected const TEST_FEED_XML_PATH_2 = __DIR__.'/feed_2.xml';
22+
2123
protected const TEST_FEED_XML_PATH_3 = __DIR__.'/feed_3.xml';
24+
2225
protected const TEST_FEED_XML_PATH_4 = __DIR__.'/feed_4.xml';
2326

2427
/** @var bool reset file contents */
25-
protected static $reset = false;
28+
protected static bool $reset = false;
2629

2730
public function testFeedCreation1(): void
2831
{

0 commit comments

Comments
 (0)