Skip to content

Commit f4d78b4

Browse files
committed
Adds missing PHPDoc. More PHPStan rules.
1 parent 397aa8b commit f4d78b4

File tree

7 files changed

+37
-11
lines changed

7 files changed

+37
-11
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Ignore all test and documentation with “export-ignore”.
22
/.gitattributes export-ignore
33
/.gitignore export-ignore
4-
/.php_cs export-ignore
4+
/.php-cs-fixer.php export-ignore
55
/.github export-ignore
66
/README.md export-ignore
77
/phpunit.xml export-ignore

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/vendor/
2-
/.php-cs-fixer.cache
3-
/.phpunit.result.cache
2+
/.*.cache
43
/tests-report-html/
54
/composer.lock
6-
/coverage.xml
5+
/coverage.xml

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"require-dev": {
2727
"friendsofphp/php-cs-fixer": "^3.0",
2828
"phpstan/phpstan": "^1.0",
29+
"phpstan/phpstan-phpunit": "^1.0",
2930
"phpstan/phpstan-strict-rules": "^1.0",
3031
"phpstan/phpstan-webmozart-assert": "^1.0",
3132
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
- vendor/phpstan/phpstan-phpunit/rules.neon
24
- vendor/phpstan/phpstan-strict-rules/rules.neon
35
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

phpunit.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
colors="true">
6+
<coverage>
7+
<include>
8+
<directory suffix=".php">src</directory>
9+
<directory suffix=".php">tests</directory>
10+
</include>
11+
</coverage>
612
<testsuites>
713
<testsuite name="default">
814
<directory>tests</directory>
915
</testsuite>
1016
</testsuites>
11-
<filter>
12-
<whitelist>
13-
<directory suffix=".php">src</directory>
14-
<directory suffix=".php">tests</directory>
15-
</whitelist>
16-
</filter>
1717
</phpunit>

src/Feed.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AtomGenerator;
44

55
use DOMDocument;
6+
use Exception;
67
use LibXMLError;
78
use SimpleXMLElement;
89
use Webmozart\Assert\Assert;
@@ -37,7 +38,7 @@ class Feed extends AbstractElement
3738
protected $generatorUri;
3839

3940
/**
40-
* @var mixed[][]
41+
* @var array[]
4142
* @phpstan-var array<array{ns: string, uri: string, name: string, value: string, attributes: string[]}>
4243
*/
4344
protected $customElements = [];
@@ -169,6 +170,9 @@ public function addChildrenTo(SimpleXMLElement $parent): void
169170
}
170171
}
171172

173+
/**
174+
* @throws Exception
175+
*/
172176
public function getSimpleXML(): SimpleXMLElement
173177
{
174178
$attributes = [];
@@ -191,6 +195,9 @@ public function getSimpleXML(): SimpleXMLElement
191195
return $xml;
192196
}
193197

198+
/**
199+
* @throws Exception
200+
*/
194201
public function getDocument(): DOMDocument
195202
{
196203
$node = dom_import_simplexml($this->getSimpleXML());
@@ -202,6 +209,8 @@ public function getDocument(): DOMDocument
202209
}
203210

204211
/**
212+
* @throws Exception
213+
*
205214
* @return false|string
206215
*/
207216
public function saveXML()

tests/FeedTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use AtomGenerator\Entry;
66
use AtomGenerator\Feed;
77
use DateTime;
8+
use Exception;
89
use InvalidArgumentException;
910
use LibXMLError;
1011
use PHPUnit\Framework\TestCase;
@@ -22,6 +23,9 @@ final class FeedTest extends TestCase
2223
/** @var bool reset file contents */
2324
protected static $reset = false;
2425

26+
/**
27+
* @throws Exception
28+
*/
2529
public function testFeedCreation1(): void
2630
{
2731
$feed = new Feed();
@@ -72,6 +76,9 @@ public function testFeedCreation1(): void
7276
self::assertXmlStringEqualsXmlFile(self::TEST_FEED_XML_PATH_1, $xml);
7377
}
7478

79+
/**
80+
* @throws Exception
81+
*/
7582
public function testFeedCreation2(): void
7683
{
7784
$feed = new Feed();
@@ -104,6 +111,9 @@ public function testFeedCreation2(): void
104111
self::assertXmlStringEqualsXmlFile(self::TEST_FEED_XML_PATH_2, $xml);
105112
}
106113

114+
/**
115+
* @throws Exception
116+
*/
107117
public function testFeedCreation3(): void
108118
{
109119
$feed = new Feed();
@@ -132,6 +142,9 @@ public function testFeedCreation3(): void
132142
self::assertXmlStringEqualsXmlFile(self::TEST_FEED_XML_PATH_3, $xml);
133143
}
134144

145+
/**
146+
* @throws Exception
147+
*/
135148
public function testFeedCreation4(): void
136149
{
137150
$sourceFeed = new Feed();
@@ -198,6 +211,8 @@ public function testFeedCreationException3(): void
198211

199212
/**
200213
* @codeCoverageIgnore
214+
*
215+
* @throws Exception
201216
*/
202217
public function testFeedCreationException4(): void
203218
{

0 commit comments

Comments
 (0)