Skip to content

Commit e3e5498

Browse files
committed
Merge branch 'craft-5' into main
2 parents 3a91f6e + e19fba7 commit e3e5498

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It’s powered by Phil Sturgeon’s excellent [Fractal](http://fractal.thephplea
66

77
## Requirements
88

9-
This plugin requires Craft CMS 4.0 or later.
9+
This plugin requires Craft CMS 4.0.0+ or 5.0.0+.
1010

1111
## Installation
1212

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"minimum-stability": "dev",
2727
"prefer-stable": true,
2828
"require": {
29-
"craftcms/cms": "^4.0.0-RC3",
29+
"craftcms/cms": "^4.0.0-RC3|^5.0.0-beta.1",
3030
"league/fractal": "^0.20.1"
3131
},
3232
"require-dev": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/JsonFeedV1Serializer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function meta(array $meta): array
4040
*/
4141
public function paginator(PaginatorInterface $paginator): array
4242
{
43-
$currentPage = (int)$paginator->getCurrentPage();
44-
$lastPage = (int)$paginator->getLastPage();
43+
$currentPage = $paginator->getCurrentPage();
44+
$lastPage = $paginator->getLastPage();
4545

4646
if ($currentPage < $lastPage) {
4747
return [

src/PaginatorAdapter.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,32 @@ class PaginatorAdapter implements PaginatorInterface
1717
/**
1818
* @var int
1919
*/
20-
protected $elementsPerPage;
20+
protected int $elementsPerPage;
2121

2222
/**
2323
* @var int
2424
*/
25-
protected $totalElements;
25+
protected int $totalElements;
2626

2727
/**
2828
* @var string
2929
*/
30-
protected $pageParam;
30+
protected string $pageParam;
3131

3232
/**
3333
* @var int
3434
*/
35-
protected $totalPages;
35+
protected int $totalPages;
3636

3737
/**
3838
* @var int
3939
*/
40-
protected $currentPage;
40+
protected int $currentPage;
4141

4242
/**
4343
* @var int
4444
*/
45-
protected $count;
45+
protected int $count;
4646

4747
/**
4848
* Constructor
@@ -51,7 +51,7 @@ class PaginatorAdapter implements PaginatorInterface
5151
* @param integer $totalElements
5252
* @param string $pageParam
5353
*/
54-
public function __construct($elementsPerPage, $totalElements, $pageParam)
54+
public function __construct(int $elementsPerPage, int $totalElements, string $pageParam)
5555
{
5656
$this->elementsPerPage = $elementsPerPage;
5757
$this->totalElements = $totalElements;
@@ -105,7 +105,7 @@ public function getCount(): int
105105
*
106106
* @param int $count
107107
*/
108-
public function setCount($count)
108+
public function setCount(int $count): void
109109
{
110110
$this->count = $count;
111111
}
@@ -126,7 +126,7 @@ public function getPerPage(): int
126126
* @param int $page
127127
* @return string
128128
*/
129-
public function getUrl($page): string
129+
public function getUrl(int $page): string
130130
{
131131
$request = Craft::$app->getRequest();
132132

src/Plugin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class Plugin extends \craft\base\Plugin
2626
* @var array The default Fractal resource adapter configuration
2727
* @see getDefaultResourceAdapterConfig()
2828
*/
29-
private $_defaultResourceAdapterConfig;
29+
private ?array $_defaultResourceAdapterConfig = null;
3030

3131
/**
3232
* @inheritdoc
3333
*/
34-
public function init()
34+
public function init(): void
3535
{
3636
parent::init();
3737

@@ -59,7 +59,7 @@ function(RegisterCacheOptionsEvent $event) {
5959
* @param string $pattern
6060
* @return callable|array|ResourceAdapterInterface|null
6161
*/
62-
public function getEndpoint($pattern)
62+
public function getEndpoint(string $pattern)
6363
{
6464
return $this->getSettings()->endpoints[$pattern] ?? null;
6565
}
@@ -83,7 +83,7 @@ public function getDefaultResourceAdapterConfig(): array
8383
*
8484
* @param RegisterUrlRulesEvent $event
8585
*/
86-
public function registerUrlRules(RegisterUrlRulesEvent $event)
86+
public function registerUrlRules(RegisterUrlRulesEvent $event): void
8787
{
8888
foreach ($this->getSettings()->endpoints as $pattern => $config) {
8989
$event->rules[$pattern] = [

src/Settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ class Settings extends Model
2020
/**
2121
* @var array The endpoint configurations.
2222
*/
23-
public $endpoints = [];
23+
public array $endpoints = [];
2424

2525
/**
2626
* Returns the default endpoint configuration.
2727
*
2828
* @return array The default endpoint configuration.
2929
* @since 2.6.0
3030
*/
31-
public function getDefaults()
31+
public function getDefaults(): array
3232
{
3333
return is_callable($this->defaults) ? call_user_func($this->defaults) : $this->defaults;
3434
}

src/resources/ElementResource.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class ElementResource extends BaseObject implements ResourceAdapterInterface
3030
/**
3131
* @var string The element type class name
3232
*/
33-
public $elementType;
33+
public string $elementType;
3434

3535
/**
3636
* @var array The element criteria params that should be used to filter the matching elements
3737
*/
38-
public $criteria = [];
38+
public array $criteria = [];
3939

4040
/**
4141
* @var callable|string|array|TransformerAbstract The transformer config, or an actual transformer object
@@ -45,34 +45,34 @@ class ElementResource extends BaseObject implements ResourceAdapterInterface
4545
/**
4646
* @var bool Whether to only return one result
4747
*/
48-
public $one = false;
48+
public bool $one = false;
4949

5050
/**
5151
* @var bool Whether to paginate the results
5252
*/
53-
public $paginate = true;
53+
public bool $paginate = true;
5454

5555
/**
5656
* @var int The number of elements to include per page
5757
* @see paginate
5858
*/
59-
public $elementsPerPage = 100;
59+
public int $elementsPerPage = 100;
6060

6161
/**
6262
* @var string The query string param name that should be used to specify the page number
6363
* @see paginate
6464
*/
65-
public $pageParam = 'page';
65+
public string $pageParam = 'page';
6666

6767
/**
6868
* @var string|null The resource key that should be set on the resource
6969
*/
70-
public $resourceKey;
70+
public ?string $resourceKey = 'data';
7171

7272
/**
7373
* @var array|null Custom meta values
7474
*/
75-
public $meta;
75+
public ?array $meta = null;
7676

7777
/**
7878
* @inheritdoc
@@ -91,9 +91,9 @@ public function __construct(array $config = [])
9191
* @inheritdoc
9292
* @throws InvalidConfigException
9393
*/
94-
public function init()
94+
public function init(): void
9595
{
96-
if ($this->elementType === null || !is_subclass_of($this->elementType, ElementInterface::class)) {
96+
if (!isset($this->elementType) || !is_subclass_of($this->elementType, ElementInterface::class)) {
9797
throw new InvalidConfigException('Endpoint has an invalid elementType');
9898
}
9999

0 commit comments

Comments
 (0)