Skip to content

Commit

Permalink
Adds missing PHPDoc. More PHPStan rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebin committed Jan 7, 2022
1 parent 397aa8b commit f4d78b4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ignore all test and documentation with “export-ignore”.
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.php-cs-fixer.php export-ignore
/.github export-ignore
/README.md export-ignore
/phpunit.xml export-ignore
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/vendor/
/.php-cs-fixer.cache
/.phpunit.result.cache
/.*.cache
/tests-report-html/
/composer.lock
/coverage.xml
/coverage.xml
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"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"
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
12 changes: 6 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
<directory suffix=".php">tests</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<directory suffix=".php">tests</directory>
</whitelist>
</filter>
</phpunit>
11 changes: 10 additions & 1 deletion src/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace AtomGenerator;

use DOMDocument;
use Exception;
use LibXMLError;
use SimpleXMLElement;
use Webmozart\Assert\Assert;
Expand Down Expand Up @@ -37,7 +38,7 @@ class Feed extends AbstractElement
protected $generatorUri;

/**
* @var mixed[][]
* @var array[]
* @phpstan-var array<array{ns: string, uri: string, name: string, value: string, attributes: string[]}>
*/
protected $customElements = [];
Expand Down Expand Up @@ -169,6 +170,9 @@ public function addChildrenTo(SimpleXMLElement $parent): void
}
}

/**
* @throws Exception
*/
public function getSimpleXML(): SimpleXMLElement
{
$attributes = [];
Expand All @@ -191,6 +195,9 @@ public function getSimpleXML(): SimpleXMLElement
return $xml;
}

/**
* @throws Exception
*/
public function getDocument(): DOMDocument
{
$node = dom_import_simplexml($this->getSimpleXML());
Expand All @@ -202,6 +209,8 @@ public function getDocument(): DOMDocument
}

/**
* @throws Exception
*
* @return false|string
*/
public function saveXML()
Expand Down
15 changes: 15 additions & 0 deletions tests/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use AtomGenerator\Entry;
use AtomGenerator\Feed;
use DateTime;
use Exception;
use InvalidArgumentException;
use LibXMLError;
use PHPUnit\Framework\TestCase;
Expand All @@ -22,6 +23,9 @@ final class FeedTest extends TestCase
/** @var bool reset file contents */
protected static $reset = false;

/**
* @throws Exception
*/
public function testFeedCreation1(): void
{
$feed = new Feed();
Expand Down Expand Up @@ -72,6 +76,9 @@ public function testFeedCreation1(): void
self::assertXmlStringEqualsXmlFile(self::TEST_FEED_XML_PATH_1, $xml);
}

/**
* @throws Exception
*/
public function testFeedCreation2(): void
{
$feed = new Feed();
Expand Down Expand Up @@ -104,6 +111,9 @@ public function testFeedCreation2(): void
self::assertXmlStringEqualsXmlFile(self::TEST_FEED_XML_PATH_2, $xml);
}

/**
* @throws Exception
*/
public function testFeedCreation3(): void
{
$feed = new Feed();
Expand Down Expand Up @@ -132,6 +142,9 @@ public function testFeedCreation3(): void
self::assertXmlStringEqualsXmlFile(self::TEST_FEED_XML_PATH_3, $xml);
}

/**
* @throws Exception
*/
public function testFeedCreation4(): void
{
$sourceFeed = new Feed();
Expand Down Expand Up @@ -198,6 +211,8 @@ public function testFeedCreationException3(): void

/**
* @codeCoverageIgnore
*
* @throws Exception
*/
public function testFeedCreationException4(): void
{
Expand Down

0 comments on commit f4d78b4

Please sign in to comment.