Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoffeys committed Feb 15, 2024
1 parent a7bc41b commit 13256df
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/JsonFeedV1Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function meta(array $meta): array
*/
public function paginator(PaginatorInterface $paginator): array
{
$currentPage = (int)$paginator->getCurrentPage();
$lastPage = (int)$paginator->getLastPage();
$currentPage = $paginator->getCurrentPage();
$lastPage = $paginator->getLastPage();

if ($currentPage < $lastPage) {
return [
Expand Down
8 changes: 4 additions & 4 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class Plugin extends \craft\base\Plugin
* @var array The default Fractal resource adapter configuration
* @see getDefaultResourceAdapterConfig()
*/
private $_defaultResourceAdapterConfig;
private array $_defaultResourceAdapterConfig;

/**
* @inheritdoc
*/
public function init()
public function init(): void
{
parent::init();

Expand Down Expand Up @@ -59,7 +59,7 @@ function(RegisterCacheOptionsEvent $event) {
* @param string $pattern
* @return callable|array|ResourceAdapterInterface|null
*/
public function getEndpoint($pattern)
public function getEndpoint(string $pattern)
{
return $this->getSettings()->endpoints[$pattern] ?? null;
}
Expand All @@ -83,7 +83,7 @@ public function getDefaultResourceAdapterConfig(): array
*
* @param RegisterUrlRulesEvent $event
*/
public function registerUrlRules(RegisterUrlRulesEvent $event)
public function registerUrlRules(RegisterUrlRulesEvent $event): void
{
foreach ($this->getSettings()->endpoints as $pattern => $config) {
$event->rules[$pattern] = [
Expand Down
4 changes: 2 additions & 2 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class Settings extends Model
/**
* @var array The endpoint configurations.
*/
public $endpoints = [];
public array $endpoints = [];

/**
* Returns the default endpoint configuration.
*
* @return array The default endpoint configuration.
* @since 2.6.0
*/
public function getDefaults()
public function getDefaults(): array
{
return is_callable($this->defaults) ? call_user_func($this->defaults) : $this->defaults;
}
Expand Down
18 changes: 9 additions & 9 deletions src/resources/ElementResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class ElementResource extends BaseObject implements ResourceAdapterInterface
/**
* @var string The element type class name
*/
public $elementType;
public string $elementType;

/**
* @var array The element criteria params that should be used to filter the matching elements
*/
public $criteria = [];
public array $criteria = [];

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

/**
* @var bool Whether to paginate the results
*/
public $paginate = true;
public bool $paginate = true;

/**
* @var int The number of elements to include per page
* @see paginate
*/
public $elementsPerPage = 100;
public int $elementsPerPage = 100;

/**
* @var string The query string param name that should be used to specify the page number
* @see paginate
*/
public $pageParam = 'page';
public string $pageParam = 'page';

/**
* @var string|null The resource key that should be set on the resource
*/
public $resourceKey;
public ?string $resourceKey;

/**
* @var array|null Custom meta values
*/
public $meta;
public ?array $meta;

/**
* @inheritdoc
Expand All @@ -91,7 +91,7 @@ public function __construct(array $config = [])
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
public function init(): void
{
if ($this->elementType === null || !is_subclass_of($this->elementType, ElementInterface::class)) {
throw new InvalidConfigException('Endpoint has an invalid elementType');
Expand Down

0 comments on commit 13256df

Please sign in to comment.