Skip to content

Commit

Permalink
Merge pull request #15 from spatie/php81
Browse files Browse the repository at this point in the history
PHP 8.1
  • Loading branch information
rubenvanassche authored Dec 8, 2021
2 parents b33a0db + 13a3f74 commit 403dae7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none

Expand Down
49 changes: 30 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
6 changes: 3 additions & 3 deletions src/Structures/TypesCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function offsetGet($class): ?TransformedType
return $this->types[$class] ?? null;
}

public function getIterator()
public function getIterator(): ArrayIterator
{
return new ArrayIterator($this->types);
}
Expand Down Expand Up @@ -60,12 +60,12 @@ public function offsetUnset($class): void
unset($this->types[$class]);
}

public function count()
public function count(): int
{
return count($this->types);
}

protected function ensureTypeCanBeAdded(TransformedType $type)
protected function ensureTypeCanBeAdded(TransformedType $type): void
{
$namespace = array_reduce($type->getNamespaceSegments(), function (array $checkedSegments, string $segment) {
$segments = array_merge($checkedSegments, [$segment]);
Expand Down
8 changes: 4 additions & 4 deletions tests/Fakes/FakeReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FakeReflectionClass extends ReflectionClass
{
use FakedReflection;

private ?string $withNamespace = null;
private string $withNamespace = '';

public function __construct()
{
Expand All @@ -30,12 +30,12 @@ public function withoutNamespace(): self
return $this;
}

public function getNamespaceName()
public function getNamespaceName(): string
{
return $this->withNamespace ?? parent::getNamespaceName();
return $this->withNamespace ?: parent::getNamespaceName();
}

public function getName()
public function getName(): string
{
$name = $this->entityName ?? parent::getShortName();

Expand Down
8 changes: 4 additions & 4 deletions tests/Fakes/FakeReflectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class FakeReflectionType extends ReflectionNamedType
{
private ?string $type = null;
private string $type = '';

private bool $isBuiltIn = true;

Expand Down Expand Up @@ -42,17 +42,17 @@ public function withAllowsNull(bool $allowsNull = true): self
return $this;
}

public function getName(): ?string
public function getName(): string
{
return $this->type;
}

public function isBuiltin()
public function isBuiltin(): bool
{
return $this->isBuiltIn;
}

public function allowsNull()
public function allowsNull(): bool
{
return $this->allowsNull;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Fakes/FakedReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait FakedReflection

private ?string $entityName = null;

private ?string $docComment = null;
private string $docComment = '';

public function __construct()
{
Expand Down Expand Up @@ -43,19 +43,19 @@ public function withType(FakeReflectionType | ReflectionType $type): self
return $this;
}

public function getDocComment()
public function getDocComment(): string|false
{
if ($this->docComment === null) {
if ($this->docComment === '') {
return false;
}

return $this->docComment;
}

public function getName()
public function getName(): string
{
if ($this->entityName === null) {
return null;
return '';
}

return $this->entityName;
Expand Down

0 comments on commit 403dae7

Please sign in to comment.