Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/CHANGELOG.md export-ignore
/CONTRIBUTING.md export-ignore
/README.md export-ignore
/.php-cs-fixer.dist.php export-ignore
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04]
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
os: [ubuntu-latest]
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5]

name: League - PHP ${{ matrix.php }} on ${{ matrix.os }}

steps:

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -25,7 +25,7 @@ jobs:
tools: phpcs, phpunit

- name: Download dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run Tests
run: vendor/bin/phpunit
20 changes: 10 additions & 10 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@ name: Static analysis
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: apcu, redis
coverage: none
tools: phpstan:1.4.6, cs2pr
tools: cs2pr

- name: Download dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3

- name: PHPStan
run: phpstan analyze --no-progress --error-format=checkstyle | cs2pr
run: ./vendor/bin/phpstan analyze --no-progress --error-format=checkstyle | cs2pr

psalm:
name: Psalm
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: apcu, redis
coverage: none
tools: vimeo/psalm:4.30.0
tools: cs2pr

- name: Download dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3

- name: Psalm
run: psalm --no-progress --output-format=github
run: ./vendor/bin/psalm --no-progress --output-format=github
17 changes: 4 additions & 13 deletions .github/workflows/style-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,15 @@ jobs:
steps:

- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Cache Dependencies
id: composer-cache-style
uses: actions/cache@v2
with:
path: vendor
key: ubuntu-composer-cache-style-${{ hashFiles('**/composer.lock') }}
restore-keys: ubuntu-php-style

- name: Install Dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Download dependencies
uses: ramsey/composer-install@v3

- name: Check Coding Style
run: vendor/bin/phpcs src/
run: composer lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
vendor
.phpunit.result.cache
.idea
.php-cs-fixer.cache
13 changes: 13 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
;

return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
// @TODO Remove this when PHP minimum is 8.0+
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'array_destructuring', 'arrays', 'match']],
])
->setFinder($finder);
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
},
"require-dev": {
"doctrine/orm": "^2.5",
"friendsofphp/php-cs-fixer": "^3.91",
"illuminate/contracts": "~5.0",
"laminas/laminas-paginator": "~2.12",
"mockery/mockery": "^1.3",
"pagerfanta/pagerfanta": "~1.0.0|~4.0.0",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "~3.4",
"vimeo/psalm": "^4.30"
},
"suggest": {
Expand All @@ -50,7 +50,8 @@
}
},
"scripts": {
"check": "vendor/bin/phpcs src/",
"lint": "PHP_CS_FIXER_FUTURE_MODE=1 php ./vendor/bin/php-cs-fixer check -v --diff",
"lint:fix": "PHP_CS_FIXER_FUTURE_MODE=1 php ./vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/phpunit --testdox --colors=always",
"test:coverage": "vendor/bin/phpunit --coverage-html build/coverage"
},
Expand Down
14 changes: 0 additions & 14 deletions phpcs.xml.dist

This file was deleted.

1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ includes:
parameters:
level: 5
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
paths:
- src
bootstrapFiles:
Expand Down
12 changes: 6 additions & 6 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function parseIncludes($includes): self

if (! is_array($includes)) {
throw new \InvalidArgumentException(
'The parseIncludes() method expects a string or an array. '.gettype($includes).' given'
'The parseIncludes() method expects a string or an array. ' . gettype($includes) . ' given',
);
}

Expand Down Expand Up @@ -207,9 +207,9 @@ public function getRequestedFieldsets(): array
*/
public function getFieldset(string $type): ?ParamBag
{
return !isset($this->requestedFieldsets[$type]) ?
null :
new ParamBag($this->requestedFieldsets[$type]);
return !isset($this->requestedFieldsets[$type])
? null
: new ParamBag($this->requestedFieldsets[$type]);
}

/**
Expand All @@ -225,7 +225,7 @@ public function parseExcludes($excludes): self

if (! is_array($excludes)) {
throw new \InvalidArgumentException(
'The parseExcludes() method expects a string or an array. '.gettype($excludes).' given'
'The parseExcludes() method expects a string or an array. ' . gettype($excludes) . ' given',
);
}

Expand Down Expand Up @@ -273,7 +273,7 @@ protected function autoIncludeParents(): void
$parsed[] = $part;

while (count($nested) > 0) {
$part .= '.'.array_shift($nested);
$part .= '.' . array_shift($nested);
$parsed[] = $part;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Pagination/DoctrinePaginatorAdapter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the League\Fractal package.
*
Expand Down
4 changes: 1 addition & 3 deletions src/Resource/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@
* other sort of intelligent result, DataMapper model, etc but could
* be a basic array, object, or whatever you like.
*/
class Item extends ResourceAbstract
{
}
class Item extends ResourceAbstract {}
4 changes: 1 addition & 3 deletions src/Resource/Primitive.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@
* The Primitive Resource can store any primitive data, like a string, integer,
* float, double etc.
*/
class Primitive extends ResourceAbstract
{
}
class Primitive extends ResourceAbstract {}
4 changes: 2 additions & 2 deletions src/Resource/ResourceAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function getData()
*/
public function setData($data): self
{
$this->data = $data;
$this->data = $data;

return $this;
return $this;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function toArray(): ?array
// serialize the included data and merge it with the data.
if ($serializer->sideloadIncludes()) {
//Filter out any relation that wasn't requested
$rawIncludedData = array_map(array($this, 'filterFieldsets'), $rawIncludedData);
$rawIncludedData = array_map([$this, 'filterFieldsets'], $rawIncludedData);

$includedData = $serializer->includedData($this->resource, $rawIncludedData);

Expand All @@ -193,7 +193,7 @@ public function toArray(): ?array
// the objects that are sideloaded, it can do so now.
$includedData = $serializer->filterIncludes(
$includedData,
$data
$data,
);
}

Expand Down Expand Up @@ -257,7 +257,7 @@ public function transformPrimitiveResource()
{
if (! ($this->resource instanceof Primitive)) {
throw new InvalidArgumentException(
'Argument $resource should be an instance of League\Fractal\Resource\Primitive'
'Argument $resource should be an instance of League\Fractal\Resource\Primitive',
);
}

Expand Down Expand Up @@ -300,7 +300,7 @@ protected function executeResourceTransformers(): array
} else {
throw new InvalidArgumentException(
'Argument $resource should be an instance of League\Fractal\Resource\Item'
.' or League\Fractal\Resource\Collection'
. ' or League\Fractal\Resource\Collection',
);
}

Expand Down Expand Up @@ -427,8 +427,8 @@ protected function filterFieldsets(array $data): array
$filterFieldset = array_flip(
array_merge(
$serializer->getMandatoryFields(),
$requestedFieldset
)
$requestedFieldset,
),
);
return array_intersect_key($data, $filterFieldset);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Serializer/JsonApiSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function includedData(ResourceInterface $resource, array $data): array
list($serializedData, $linkedIds) = $this->serializeIncludedObjectsWithCacheKey(
$includeObjects,
$linkedIds,
$serializedData
$serializedData,
);
}
}
Expand Down Expand Up @@ -258,8 +258,8 @@ protected function isRootObject(array $object): bool

protected function isCollection(array $data): bool
{
return array_key_exists('data', $data) &&
array_key_exists(0, $data['data']);
return array_key_exists('data', $data)
&& array_key_exists(0, $data['data']);
}

protected function isNull(array $data): bool
Expand Down Expand Up @@ -311,7 +311,7 @@ protected function getIdFromData(array $data)
{
if (!array_key_exists('id', $data)) {
throw new InvalidArgumentException(
'JSON API resource objects MUST have a valid id'
'JSON API resource objects MUST have a valid id',
);
}

Expand All @@ -332,7 +332,7 @@ protected function pullOutNestedIncludedData(array $data): array
list($includedData, $linkedIds) = $this->serializeIncludedObjectsWithCacheKey(
$includeObject['included'],
$linkedIds,
$includedData
$includedData,
);
}
}
Expand Down Expand Up @@ -495,9 +495,9 @@ private function addRelationshipLinks(array $resource, string $relationshipKey):
'links' => [
'self' => "{$this->baseUrl}/{$resource['type']}/{$resource['id']}/relationships/{$relationshipKey}",
'related' => "{$this->baseUrl}/{$resource['type']}/{$resource['id']}/{$relationshipKey}",
]
],
],
$resource['relationships'][$relationshipKey]
$resource['relationships'][$relationshipKey],
);

return $resource;
Expand Down
1 change: 1 addition & 0 deletions src/Serializer/Serializer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace League\Fractal\Serializer;

use League\Fractal\Pagination\CursorInterface;
Expand Down
Loading