Skip to content

Commit

Permalink
Merge pull request #63 from ghostwriter/feature/php-8.2-support
Browse files Browse the repository at this point in the history
Feature: Support PHP 8.2
  • Loading branch information
Ocramius committed Nov 16, 2022
2 parents 628ae3d + 389b497 commit 1306b74
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 360 deletions.
5 changes: 5 additions & 0 deletions .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore_php_platform_requirements": {
"8.2": true
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"config": {
"sort-packages": true,
"platform": {
"php": "7.4.99"
"php": "8.0.99"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand All @@ -38,7 +38,7 @@
}
},
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"ext-dom": "*",
"ext-json": "*",
"psr/container": "^1.1.2 || ^2.0.2",
Expand Down
439 changes: 152 additions & 287 deletions composer.lock

Large diffs are not rendered by default.

58 changes: 23 additions & 35 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<file src="src/HalResource.php">
<DocblockTypeContradiction occurrences="1">
<code>is_object($resource)</code>
Expand All @@ -11,21 +11,19 @@
<code>$name</code>
<code>$rel</code>
<code>$resource</code>
<code>$resource</code>
<code>$value</code>
</MissingClosureParamType>
<MissingClosureReturnType occurrences="2">
<code>function ($item) {</code>
<code>function (array $byRelation, LinkInterface $link) {</code>
</MissingClosureReturnType>
<MixedArgument occurrences="10">
<MixedArgument occurrences="9">
<code>$links</code>
<code>$links</code>
<code>$name</code>
<code>$name</code>
<code>$relations</code>
<code>$resource</code>
<code>$resource</code>
<code>$value</code>
<code>$value</code>
<code>$value</code>
Expand Down Expand Up @@ -101,15 +99,8 @@
</UndefinedDocblockClass>
</file>
<file src="src/Link.php">
<DocblockTypeContradiction occurrences="5">
<code>! is_string($attribute)</code>
<code>! is_string($href)</code>
<code>! is_string($rel)</code>
<code>! is_string($rel)</code>
<code>is_object($rel)</code>
</DocblockTypeContradiction>
<MixedArgument occurrences="1">
<code>$rel</code>
<code>is_object($rel) ? $rel::class : gettype($rel)</code>
</MixedArgument>
<MixedAssignment occurrences="1">
<code>$value</code>
Expand All @@ -121,17 +112,19 @@
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$this-&gt;validateRelation($relation)</code>
</PossiblyInvalidPropertyAssignmentValue>
<RedundantCastGivenDocblockType occurrences="1">
<code>(string) $href</code>
</RedundantCastGivenDocblockType>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="3">
<code>gettype($rel)</code>
<code>is_object($href)</code>
<code>is_string($uri)</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="1">
<code>gettype($rel)</code>
</RedundantConditionGivenDocblockType>
<TypeDoesNotContainType occurrences="1">
<TypeDoesNotContainType occurrences="7">
<code>! is_string($attribute)</code>
<code>! is_string($rel)</code>
<code>! is_string($rel)</code>
<code>(string) $uri</code>
<code>gettype($href)</code>
<code>is_object($href)</code>
<code>is_object($rel)</code>
</TypeDoesNotContainType>
</file>
<file src="src/LinkCollection.php">
Expand Down Expand Up @@ -270,6 +263,7 @@
</TypeDoesNotContainType>
</file>
<file src="src/ResourceGenerator/ExtractCollectionTrait.php">
<MethodSignatureMismatch occurrences="1"/>
<MixedArgument occurrences="2">
<code>$item</code>
<code>$item</code>
Expand All @@ -290,7 +284,6 @@
<code>$perPage</code>
<code>$perPage</code>
</PossiblyNullOperand>
<TraitMethodSignatureMismatch occurrences="1"/>
<UndefinedInterfaceMethod occurrences="1">
<code>count</code>
</UndefinedInterfaceMethod>
Expand All @@ -311,6 +304,9 @@
<DocblockTypeContradiction occurrences="1">
<code>[]</code>
</DocblockTypeContradiction>
<MethodSignatureMismatch occurrences="1">
<code>protected function generateSelfLink(</code>
</MethodSignatureMismatch>
<MixedArgument occurrences="8">
<code>$metadata-&gt;getQueryStringArguments() ?? []</code>
<code>$metadata-&gt;getRoute()</code>
Expand All @@ -332,9 +328,6 @@
<RedundantConditionGivenDocblockType occurrences="1">
<code>$request-&gt;getQueryParams()</code>
</RedundantConditionGivenDocblockType>
<TraitMethodSignatureMismatch occurrences="1">
<code>protected function generateSelfLink(</code>
</TraitMethodSignatureMismatch>
<UndefinedMethod occurrences="6">
<code>getQueryStringArguments</code>
<code>getQueryStringArguments</code>
Expand All @@ -353,6 +346,9 @@
<InvalidScalarArgument occurrences="1">
<code>$page</code>
</InvalidScalarArgument>
<MethodSignatureMismatch occurrences="1">
<code>protected function generateSelfLink(</code>
</MethodSignatureMismatch>
<MixedArgument occurrences="1">
<code>$url</code>
</MixedArgument>
Expand All @@ -365,9 +361,6 @@
<RedundantConditionGivenDocblockType occurrences="1">
<code>$queryStringArgs !== null</code>
</RedundantConditionGivenDocblockType>
<TraitMethodSignatureMismatch occurrences="1">
<code>protected function generateSelfLink(</code>
</TraitMethodSignatureMismatch>
<UndefinedMethod occurrences="2">
<code>getUrl</code>
<code>getUrl</code>
Expand Down Expand Up @@ -468,8 +461,6 @@
<code>CustomUrlHelper</code>
<code>CustomUrlHelper</code>
<code>CustomUrlHelper</code>
<code>CustomUrlHelper</code>
<code>CustomUrlHelper</code>
</UndefinedClass>
</file>
<file src="test/LinkGeneratorFactoryTest.php">
Expand All @@ -489,6 +480,9 @@
</UndefinedClass>
</file>
<file src="test/LinkTest.php">
<ArgumentTypeCoercion occurrences="1">
<code>$uri</code>
</ArgumentTypeCoercion>
<MixedArgument occurrences="7">
<code>$name</code>
<code>$name</code>
Expand All @@ -498,12 +492,6 @@
<code>$value</code>
<code>$value</code>
</MixedArgument>
<PossiblyInvalidArgument occurrences="1">
<code>$uri</code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast occurrences="1">
<code>$uri</code>
</PossiblyInvalidCast>
<TooFewArguments occurrences="1">
<code>new Link()</code>
</TooFewArguments>
Expand Down
5 changes: 2 additions & 3 deletions src/Exception/InvalidResourceValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Mezzio\Hal\HalResource;
use RuntimeException;

use function get_class;
use function gettype;
use function is_object;
use function sprintf;
Expand All @@ -21,7 +20,7 @@ public static function fromValue($value): self
{
return new self(sprintf(
'Encountered non-primitive type "%s" when serializing %s instance; unable to serialize',
is_object($value) ? get_class($value) : gettype($value),
is_object($value) ? $value::class : gettype($value),
HalResource::class
));
}
Expand All @@ -33,7 +32,7 @@ public static function fromObject($object): self
{
return new self(sprintf(
'Encountered object of type "%s" when serializing %s instance; unable to serialize',
get_class($object),
$object::class,
HalResource::class
));
}
Expand Down
3 changes: 1 addition & 2 deletions src/Exception/InvalidStrategyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use InvalidArgumentException;
use Mezzio\Hal\ResourceGenerator\StrategyInterface;

use function get_class;
use function gettype;
use function is_object;
use function sprintf;
Expand All @@ -30,7 +29,7 @@ public static function forInstance($strategy): self
{
return new self(sprintf(
'Invalid strategy of type "%s"; does not implement %s',
is_object($strategy) ? get_class($strategy) : gettype($strategy),
is_object($strategy) ? $strategy::class : gettype($strategy),
StrategyInterface::class
));
}
Expand Down
3 changes: 1 addition & 2 deletions src/Exception/UnknownMetadataTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Mezzio\Hal\Metadata\AbstractMetadata;
use RuntimeException;

use function get_class;
use function sprintf;

class UnknownMetadataTypeException extends RuntimeException implements ExceptionInterface
Expand All @@ -16,7 +15,7 @@ public static function forMetadata(AbstractMetadata $metadata): self
{
return new self(sprintf(
'Encountered unknown metadata type %s; no strategy available for creating resource from this metadata',
get_class($metadata)
$metadata::class
));
}

Expand Down
3 changes: 1 addition & 2 deletions src/HalResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use function array_shift;
use function array_walk;
use function count;
use function get_class;
use function gettype;
use function in_array;
use function is_array;
Expand Down Expand Up @@ -214,7 +213,7 @@ public function embed(string $name, $resource, bool $forceCollection = false): H
__METHOD__,
self::class,
self::class,
is_object($resource) ? get_class($resource) : gettype($resource)
is_object($resource) ? $resource::class : gettype($resource)
));
}
$new = clone $this;
Expand Down
11 changes: 5 additions & 6 deletions src/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use function array_filter;
use function array_reduce;
use function get_class;
use function gettype;
use function in_array;
use function is_array;
Expand Down Expand Up @@ -97,7 +96,7 @@ public function withHref($href)
throw new InvalidArgumentException(sprintf(
'%s expects a string URI or an object implementing __toString; received %s',
__METHOD__,
is_object($href) ? get_class($href) : gettype($href)
is_object($href) ? $href::class : gettype($href)
));
}
$new = clone $this;
Expand All @@ -116,7 +115,7 @@ public function withRel($rel)
throw new InvalidArgumentException(sprintf(
'%s expects a non-empty string relation type; received %s',
__METHOD__,
is_object($rel) ? get_class($rel) : gettype($rel)
is_object($rel) ? $rel::class : gettype($rel)
));
}

Expand Down Expand Up @@ -195,7 +194,7 @@ private function validateAttributeName($name, string $context): void
throw new InvalidArgumentException(sprintf(
'%s expects the $name argument to be a non-empty string; received %s',
$context,
is_object($name) ? get_class($name) : gettype($name)
is_object($name) ? $name::class : gettype($name)
));
}
}
Expand All @@ -212,7 +211,7 @@ private function validateAttributeValue($value, string $context): void
throw new InvalidArgumentException(sprintf(
'%s expects the $value to be a PHP primitive or array of strings; received %s',
$context,
is_object($value) ? get_class($value) : gettype($value)
is_object($value) ? $value::class : gettype($value)
));
}

Expand Down Expand Up @@ -248,7 +247,7 @@ private function validateRelation($relation)
if (! is_array($relation) && (! is_string($relation) || empty($relation))) {
throw new InvalidArgumentException(sprintf(
'$relation argument must be a string or array of strings; received %s',
is_object($relation) ? get_class($relation) : gettype($relation)
is_object($relation) ? $relation::class : gettype($relation)
));
}

Expand Down
7 changes: 3 additions & 4 deletions src/Metadata/Exception/InvalidConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Mezzio\Hal\Metadata\MetadataMapFactory;
use RuntimeException;

use function get_class;
use function gettype;
use function implode;
use function is_object;
Expand All @@ -27,7 +26,7 @@ public static function dueToNonArray($config): self
return new self(sprintf(
'Invalid %s configuration; expected an array, but received %s',
MetadataMap::class,
is_object($config) ? get_class($config) : gettype($config)
is_object($config) ? $config::class : gettype($config)
));
}

Expand All @@ -39,7 +38,7 @@ public static function dueToNonArrayMetadata($metadata): self
return new self(sprintf(
'Invalid %s metadata item configuration; expected an array, but received %s',
MetadataMap::class,
is_object($metadata) ? get_class($metadata) : gettype($metadata)
is_object($metadata) ? $metadata::class : gettype($metadata)
));
}

Expand All @@ -55,7 +54,7 @@ public static function dueToInvalidMetadataClass($class): self
{
$className = $class;
if (! is_string($className)) {
$className = is_object($class) ? get_class($class) : gettype($class);
$className = is_object($class) ? $class::class : gettype($class);
}
return new self(sprintf(
'Invalid metadata class provided: %s is not a class name',
Expand Down
5 changes: 2 additions & 3 deletions src/ResourceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use function class_exists;
use function class_implements;
use function class_parents;
use function get_class;
use function in_array;
use function is_object;
use function is_string;
Expand Down Expand Up @@ -120,7 +119,7 @@ public function fromObject(object $instance, ServerRequestInterface $request, in
}

$metadata = $this->getClassMetadata($instance);
$metadataType = get_class($metadata);
$metadataType = $metadata::class;

if (! isset($this->strategies[$metadataType])) {
throw Exception\UnknownMetadataTypeException::forMetadata($metadata);
Expand All @@ -138,7 +137,7 @@ public function fromObject(object $instance, ServerRequestInterface $request, in

private function getClassMetadata(object $instance): AbstractMetadata
{
$class = get_class($instance);
$class = $instance::class;
if (! $this->metadataMap->has($class)) {
foreach (class_parents($instance) as $parent) {
if ($this->metadataMap->has($parent)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use RuntimeException;

use function get_class;
use function gettype;
use function is_object;
use function sprintf;
Expand All @@ -21,7 +20,7 @@ public static function fromInstance($instance, string $class): self
return new self(sprintf(
'%s is unable to create a resource for collection of type "%s"; not a Traversable',
$class,
is_object($instance) ? get_class($instance) : gettype($instance)
is_object($instance) ? $instance::class : gettype($instance)
));
}
}
Loading

0 comments on commit 1306b74

Please sign in to comment.