Skip to content
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
48 changes: 25 additions & 23 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ on:

jobs:
tests:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
name: PHP ${{ matrix.php }}
steps:
- uses: actions/checkout@v3
# required for "git tag" presence for MonorepoBuilder split and ChangelogLinker git tags resolver; default is 1
- run: git fetch --depth=100000 origin
# see https://github.com/shivammathur/setup-php
- uses: actions/checkout@v6
with:
fetch-depth: 5
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand All @@ -26,29 +25,29 @@ jobs:

tests_lowest_dependencies:
name: Lowest dependencies
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=100000 origin
# see https://github.com/shivammathur/setup-php
- uses: actions/checkout@v6
with:
fetch-depth: 5
- uses: shivammathur/setup-php@v2
with:
php-version: '7.1'
php-version: '7.4'
extensions: xml
coverage: none
- run: composer update --no-progress --prefer-lowest
- run: composer phpunit

test_coverage:
name: Coverage
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=100000 origin
# see https://github.com/shivammathur/setup-php
- uses: actions/checkout@v6
with:
fetch-depth: 5
- uses: shivammathur/setup-php@v2
with:
php-version: '7.1'
php-version: '7.4'
extensions: xml, xdebug
coverage: xdebug
- run: composer install --no-progress
Expand All @@ -59,26 +58,29 @@ jobs:

php-cs-fixer:
name: PHP CS Fixer
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
# see https://github.com/shivammathur/setup-php
- uses: actions/checkout@v6
with:
fetch-depth: 5
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4'
extensions: xml
coverage: none
- run: composer install --no-progress
- run: composer php-cs-fixer-dry-run

phpstan:
name: PHPStan
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
with:
fetch-depth: 5
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4'
coverage: none
- run: composer install --no-progress
- run: composer phpstan
57 changes: 30 additions & 27 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
<?php

$finder = PhpCsFixer\Finder::create()
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = Finder::create()
->exclude('vendor')
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'@PSR12:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'php_unit_test_class_requires_covers' => false,
'backtick_to_shell_exec' => true,
'blank_line_before_statement' => [
'statements' => ['declare', 'return', 'case'],
],
'comment_to_phpdoc' => false,
'declare_equal_normalize' => ['space' => 'single'],
'global_namespace_import' => true,
'linebreak_after_opening_tag' => true,
'native_function_invocation' => false,
'no_unset_on_property' => false,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_to_comment' => false,
'self_static_accessor' => true,
])
->setFinder($finder)
;
$config = new Config();
return $config
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@auto' => true,
'@auto:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'php_unit_test_class_requires_covers' => false,
'backtick_to_shell_exec' => true,
'blank_line_before_statement' => [
'statements' => ['declare', 'return', 'case'],
],
'comment_to_phpdoc' => false,
'declare_equal_normalize' => ['space' => 'single'],
'global_namespace_import' => true,
'linebreak_after_opening_tag' => true,
'native_function_invocation' => false,
'no_unset_on_property' => false,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_to_comment' => false,
'self_static_accessor' => true,
])
->setFinder($finder);
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
}
],
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-dom": "*",
"ext-filter": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"webmozart/assert": "^1.5"
"webmozart/assert": "^1.5 || ^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
"friendsofphp/php-cs-fixer": "^3.92",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^9.1 || ^10.0"
},
"config": {
"sort-packages": true
Expand Down
2 changes: 1 addition & 1 deletion example/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use AtomGenerator\Entry;
use AtomGenerator\Feed;

include_once 'vendor/autoload.php';
include_once __DIR__.'/../vendor/autoload.php';

$entry = new Entry();
$entry->setTitle('Post', 'text');
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<coverage>
<source>
<include>
<directory suffix=".php">src</directory>
<directory suffix=".php">tests</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
Expand Down
26 changes: 10 additions & 16 deletions src/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,29 @@

abstract class AbstractElement
{
/** @var string */
protected $id;
protected string $id;

/** @var string */
protected $title;
protected string $title;

/** @var null|string */
protected $titleType;
protected ?string $titleType = null;

/** @var DateTimeInterface */
protected $updatedDateTime;
protected DateTimeInterface $updatedDateTime;

/** @var null|string */
protected $rights;
protected ?string $rights = null;

/** @var null|string */
protected $rightsType;
protected ?string $rightsType = null;

/** @var string[][] */
protected $authors = [];
protected array $authors = [];

/** @var string[][] */
protected $contributors = [];
protected array $contributors = [];

/** @var string[][] */
protected $categories = [];
protected array $categories = [];

/** @var string[][] */
protected $links = [];
protected array $links = [];

/**
* AbstractElement constructor.
Expand Down
21 changes: 7 additions & 14 deletions src/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,19 @@

class Entry extends AbstractElement
{
/** @var null|string */
protected $summary;
protected ?string $summary = null;

/** @var null|string */
protected $summaryType;
protected ?string $summaryType = null;

/** @var null|string */
protected $content;
protected ?string $content = null;

/** @var null|string */
protected $contentType;
protected ?string $contentType = null;

/** @var null|string */
protected $contentSrc;
protected ?string $contentSrc = null;

/** @var null|DateTimeInterface */
protected $publishedDateTime;
protected ?DateTimeInterface $publishedDateTime = null;

/** @var null|Feed */
protected $source;
protected ?Feed $source = null;

public function setSummary(?string $summary, ?string $type = null): void
{
Expand Down
32 changes: 14 additions & 18 deletions src/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,38 @@
namespace AtomGenerator;

use DOMDocument;
use Exception;
use LibXMLError;
use SimpleXMLElement;
use Webmozart\Assert\Assert;

class Feed extends AbstractElement
{
/** @var Entry[] */
protected $entries = [];
protected array $entries = [];

/** @var bool */
protected $prettify = false;
protected bool $prettify = false;

/** @var null|string */
protected $language;
protected ?string $language = null;

/** @var null|string */
protected $subtitle;
protected ?string $subtitle = null;

/** @var null|string */
protected $icon;
protected ?string $icon = null;

/** @var null|string */
protected $logo;
protected ?string $logo = null;

/** @var null|string */
protected $generator;
protected ?string $generator = null;

/** @var null|string */
protected $generatorVersion;
protected ?string $generatorVersion = null;

/** @var null|string */
protected $generatorUri;
protected ?string $generatorUri = null;

/**
* @var array[]
*
* @phpstan-var array<array{ns: string, uri: string, name: string, value: string, attributes: string[]}>
*/
protected $customElements = [];
protected array $customElements = [];

/**
* Feed constructor.
Expand Down Expand Up @@ -174,6 +167,9 @@ public function addChildrenTo(SimpleXMLElement $parent): void
}
}

/**
* @throws Exception
*/
public function getSimpleXML(): SimpleXMLElement
{
$attributes = [];
Expand Down
Loading