Skip to content

Commit

Permalink
Lock dev tools (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloKowalczyk authored Dec 12, 2022
1 parent 68319d3 commit 4bdee0d
Show file tree
Hide file tree
Showing 34 changed files with 72 additions and 109 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"require-dev": {
"ergebnis/composer-normalize": "^2.28",
"friendsofphp/php-cs-fixer": "^3.8",
"friendsofphp/php-cs-fixer": "3.13.*",
"mockery/mockery": "^1.0",
"phpmd/phpmd": "^2.6",
"phpstan/phpstan": "^1.7",
Expand Down
28 changes: 14 additions & 14 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ parameters:
path: src/Representation/BaseWriter.php

-
message: "#^Call to function assert\\(\\) with true and non\\-empty\\-string will always evaluate to true\\.$#"
message: "#^Call to function assert\\(\\) with true and non\\-falsy\\-string will always evaluate to true\\.$#"
count: 4
path: src/Representation/DocumentWriter.php

Expand Down Expand Up @@ -1176,7 +1176,7 @@ parameters:
path: src/Representation/DocumentWriter.php

-
message: "#^Strict comparison using \\!\\=\\= between false and string will always evaluate to true\\.$#"
message: "#^Strict comparison using \\!\\=\\= between false and non\\-empty\\-string will always evaluate to true\\.$#"
count: 4
path: src/Representation/DocumentWriter.php

Expand Down Expand Up @@ -1257,7 +1257,7 @@ parameters:

-
message: "#^Cannot access offset string on iterable\\|null\\.$#"
count: 2
count: 1
path: src/Schema/Error.php

-
Expand Down Expand Up @@ -1481,7 +1481,7 @@ parameters:
path: src/Schema/SchemaContainer.php

-
message: "#^Parameter \\#2 \\$haystack of function in_array expects array, array\\<string, string\\>\\|false given\\.$#"
message: "#^Parameter \\#2 \\$haystack of function in_array expects array, array\\<string, class\\-string\\>\\|false given\\.$#"
count: 1
path: src/Schema/SchemaContainer.php

Expand Down Expand Up @@ -2156,52 +2156,52 @@ parameters:
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:getFields\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:getFields\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:getIncludes\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:getIncludes\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:getProfileUrls\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:getProfileUrls\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:getSorts\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:getSorts\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:iterableToArray\\(\\) has parameter \\$iterable with no value type specified in iterable type iterable\\.$#"
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:iterableToArray\\(\\) has parameter \\$iterable with no value type specified in iterable type iterable\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:iterableToArray\\(\\) return type has no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:iterableToArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:\\$fields type has no value type specified in iterable type array\\.$#"
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:\\$fields type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:\\$includes type has no value type specified in iterable type array\\.$#"
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:\\$includes type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:\\$profile type has no value type specified in iterable type array\\.$#"
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:\\$profile type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

-
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:280\\:\\:\\$sorts type has no value type specified in iterable type array\\.$#"
message: "#^Property class@anonymous/tests/Http/Query/BaseQueryParserTest\\.php\\:279\\:\\:\\$sorts type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/Http/Query/BaseQueryParserTest.php

Expand Down
3 changes: 0 additions & 3 deletions src/Encoder/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ protected function encodeErrorsToArray(iterable $errors): array
return $array;
}

/**
* @param $meta
*/
protected function encodeMetaToArray($meta): array
{
$this->withMeta($meta);
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/BaseJsonApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* limitations under the License.
*/

use RuntimeException;

abstract class BaseJsonApiException extends RuntimeException
abstract class BaseJsonApiException extends \RuntimeException
{
}
3 changes: 1 addition & 2 deletions src/Exceptions/JsonApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* limitations under the License.
*/

use Exception;
use Neomerx\JsonApi\Contracts\Schema\ErrorInterface;
use Neomerx\JsonApi\Schema\ErrorCollection;

Expand Down Expand Up @@ -57,7 +56,7 @@ class JsonApiException extends BaseJsonApiException
* @SuppressWarnings(PHPMD.StaticAccess)
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function __construct($errors, int $httpCode = self::DEFAULT_HTTP_CODE, Exception $previous = null)
public function __construct($errors, int $httpCode = self::DEFAULT_HTTP_CODE, \Exception $previous = null)
{
parent::__construct('JSON API error', 0, $previous);

Expand Down
3 changes: 1 addition & 2 deletions src/Http/Headers/AcceptMediaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* limitations under the License.
*/

use Closure;
use Neomerx\JsonApi\Contracts\Http\Headers\AcceptMediaTypeInterface;
use Neomerx\JsonApi\Exceptions\InvalidArgumentException;

Expand Down Expand Up @@ -76,7 +75,7 @@ public function getQuality(): float
return $this->quality;
}

public static function getCompare(): Closure
public static function getCompare(): \Closure
{
return function (AcceptMediaTypeInterface $lhs, AcceptMediaTypeInterface $rhs) {
$qualityCompare = self::compareQuality($lhs->getQuality(), $rhs->getQuality());
Expand Down
4 changes: 2 additions & 2 deletions src/Parser/IdentifierAndResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function getRelationships(): iterable

\assert(
$hasData || $hasMeta || $hasLinks,
"Relationship `${name}` for type `" . $this->getType() .
"Relationship `{$name}` for type `" . $this->getType() .
'` MUST contain at least one of the following: links, data or meta.'
);

Expand Down Expand Up @@ -270,7 +270,7 @@ private function assertRelationshipNameAndDescription(string $name, array $descr
);
\assert(
true === \is_array($description) && false === empty($description),
"Relationship `${name}` for type `" . $this->getType() . '` should be a non-empty array.'
"Relationship `{$name}` for type `" . $this->getType() . '` should be a non-empty array.'
);

return true;
Expand Down
7 changes: 3 additions & 4 deletions src/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* limitations under the License.
*/

use IteratorAggregate;
use Neomerx\JsonApi\Contracts\Factories\FactoryInterface;
use Neomerx\JsonApi\Contracts\Parser\DocumentDataInterface;
use Neomerx\JsonApi\Contracts\Parser\EditableContextInterface;
Expand All @@ -33,8 +32,8 @@
use Neomerx\JsonApi\Contracts\Schema\PositionInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface;
use Neomerx\JsonApi\Exceptions\InvalidArgumentException;

use function Neomerx\JsonApi\I18n\format as _;
use Traversable;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -104,8 +103,8 @@ public function parse($data, array $paths = []): iterable
} elseif (true === \is_array($data)) {
yield $this->createDocumentDataIsCollection($rootPosition);
yield from $this->parseAsResourcesOrIdentifiers($rootPosition, $data);
} elseif ($data instanceof Traversable) {
$data = $data instanceof IteratorAggregate ? $data->getIterator() : $data;
} elseif ($data instanceof \Traversable) {
$data = $data instanceof \IteratorAggregate ? $data->getIterator() : $data;
yield $this->createDocumentDataIsCollection($rootPosition);
yield from $this->parseAsResourcesOrIdentifiers($rootPosition, $data);
} elseif (null === $data) {
Expand Down
8 changes: 4 additions & 4 deletions src/Parser/RelationshipData/ParseRelationshipDataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* limitations under the License.
*/

use IteratorAggregate;
use Neomerx\JsonApi\Contracts\Factories\FactoryInterface;
use Neomerx\JsonApi\Contracts\Parser\EditableContextInterface;
use Neomerx\JsonApi\Contracts\Parser\RelationshipDataInterface;
Expand All @@ -29,9 +28,10 @@
use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaInterface;
use Neomerx\JsonApi\Exceptions\InvalidArgumentException;

use function Neomerx\JsonApi\I18n\format as _;

use Neomerx\JsonApi\Parser\IdentifierAndResource;
use Traversable;

trait ParseRelationshipDataTrait
{
Expand Down Expand Up @@ -98,12 +98,12 @@ private function parseData(
return $factory->createRelationshipDataIsIdentifier($container, $context, $position, $data);
} elseif (true === \is_array($data)) {
return $factory->createRelationshipDataIsCollection($container, $context, $position, $data);
} elseif ($data instanceof Traversable) {
} elseif ($data instanceof \Traversable) {
return $factory->createRelationshipDataIsCollection(
$container,
$context,
$position,
$data instanceof IteratorAggregate ? $data->getIterator() : $data
$data instanceof \IteratorAggregate ? $data->getIterator() : $data
);
} elseif (null === $data) {
return $factory->createRelationshipDataIsNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Neomerx\JsonApi\Contracts\Schema\PositionInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface;
use Neomerx\JsonApi\Exceptions\LogicException;

use function Neomerx\JsonApi\I18n\format as _;

class RelationshipDataIsCollection extends BaseRelationshipData implements RelationshipDataInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Neomerx\JsonApi\Contracts\Schema\PositionInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface;
use Neomerx\JsonApi\Exceptions\LogicException;

use function Neomerx\JsonApi\I18n\format as _;

class RelationshipDataIsIdentifier extends BaseRelationshipData implements RelationshipDataInterface
Expand Down
1 change: 1 addition & 0 deletions src/Parser/RelationshipData/RelationshipDataIsNull.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Neomerx\JsonApi\Contracts\Parser\RelationshipDataInterface;
use Neomerx\JsonApi\Contracts\Parser\ResourceInterface;
use Neomerx\JsonApi\Exceptions\LogicException;

use function Neomerx\JsonApi\I18n\format as _;

class RelationshipDataIsNull implements RelationshipDataInterface
Expand Down
1 change: 1 addition & 0 deletions src/Parser/RelationshipData/RelationshipDataIsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Neomerx\JsonApi\Contracts\Schema\PositionInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface;
use Neomerx\JsonApi\Exceptions\LogicException;

use function Neomerx\JsonApi\I18n\format as _;

class RelationshipDataIsResource extends BaseRelationshipData implements RelationshipDataInterface
Expand Down
9 changes: 2 additions & 7 deletions src/Schema/ErrorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@
* limitations under the License.
*/

use ArrayAccess;
use ArrayIterator;
use Countable;
use IteratorAggregate;
use Neomerx\JsonApi\Contracts\Schema\DocumentInterface;
use Neomerx\JsonApi\Contracts\Schema\ErrorInterface;
use Neomerx\JsonApi\Contracts\Schema\LinkInterface;
use Serializable;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
class ErrorCollection implements IteratorAggregate, ArrayAccess, Serializable, Countable
class ErrorCollection implements \IteratorAggregate, \ArrayAccess, \Serializable, \Countable
{
private array $items = [];

Expand All @@ -52,7 +47,7 @@ public function __unserialize(array $data): void
*/
public function getIterator(): \Traversable
{
return new ArrayIterator($this->items);
return new \ArrayIterator($this->items);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Schema/SchemaContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* limitations under the License.
*/

use Closure;
use Neomerx\JsonApi\Contracts\Factories\FactoryInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaContainerInterface;
use Neomerx\JsonApi\Contracts\Schema\SchemaInterface;
use Neomerx\JsonApi\Exceptions\InvalidArgumentException;

use function Neomerx\JsonApi\I18n\format as _;

class SchemaContainer implements SchemaContainerInterface
Expand Down Expand Up @@ -62,7 +62,7 @@ public function __construct(FactoryInterface $factory, iterable $schemas)
/**
* Register provider for resource type.
*
* @param string|Closure $schema
* @param string|\Closure $schema
*
* @SuppressWarnings(PHPMD.StaticAccess)
* @SuppressWarnings(PHPMD.ElseExpression)
Expand Down Expand Up @@ -171,7 +171,7 @@ protected function getProviderMapping(string $type)
}

/**
* @param string|Closure $schema
* @param string|\Closure $schema
*/
protected function setProviderMapping(string $type, $schema): void
{
Expand Down
3 changes: 1 addition & 2 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* limitations under the License.
*/

use Mockery;
use Neomerx\JsonApi\Contracts\Factories\FactoryInterface;
use Neomerx\JsonApi\Factories\Factory;
use PHPUnit\Framework\TestCase;
Expand All @@ -33,7 +32,7 @@ abstract class BaseTestCase extends TestCase
protected function tearDown(): void
{
parent::tearDown();
Mockery::close();
\Mockery::close();
}

protected function createFactory(): FactoryInterface
Expand Down
8 changes: 2 additions & 6 deletions tests/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
* limitations under the License.
*/

use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;

class Collection implements ArrayAccess, IteratorAggregate
class Collection implements \ArrayAccess, \IteratorAggregate
{
private array $data = [];

Expand Down Expand Up @@ -63,6 +59,6 @@ public function offsetUnset($offset): void
*/
public function getIterator(): \Traversable
{
return new ArrayIterator($this->data);
return new \ArrayIterator($this->data);
}
}
4 changes: 1 addition & 3 deletions tests/Data/Models/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
* limitations under the License.
*/

use stdClass;

class Author extends stdClass
class Author extends \stdClass
{
public const ATTRIBUTE_ID = 'author_id';
public const ATTRIBUTE_FIRST_NAME = 'first_name';
Expand Down
Loading

0 comments on commit 4bdee0d

Please sign in to comment.