Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4, 8.0, 8.1]
php: [8.1, 8.2]
stability: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rector:
vendor/bin/rector process src

rector-dry:
vendor/bin/rector process src --dry-run
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=8.1",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.4|^7.0",
Expand All @@ -28,6 +28,7 @@
"require-dev": {
"phpstan/phpstan": "^1.5",
"phpunit/phpunit": "^8.5.23",
"rector/rector": "^0.17.1",
"vimeo/psalm": "^4.0|^5.0"
},
"suggest": {
Expand Down
57 changes: 57 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php80\Rector\Identical\StrEndsWithRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
// PHP 7.4
TypedPropertyFromAssignsRector::class,
NullCoalescingOperatorRector::class, // https://wiki.php.net/rfc/null_coalesce_equal_operator
ClosureToArrowFunctionRector::class, // https://wiki.php.net/rfc/arrow_functions_v2
// PHP 8.1
MixedTypeRector::class,
ClassPropertyAssignToConstructorPromotionRector::class, // https://wiki.php.net/rfc/constructor_promotion https://github.com/php/php-src/pull/5291
ClassOnObjectRector::class, // https://wiki.php.net/rfc/class_name_literal_on_object
NullToStrictStringFuncCallArgRector::class,
ReturnNeverTypeRector::class, // https://wiki.php.net/rfc/noreturn_type
RemoveUnusedVariableInCatchRector::class, // https://wiki.php.net/rfc/non-capturing_catches
StrEndsWithRector::class, // https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions
StrContainsRector::class, // https://externals.io/message/108562 https://github.com/php/php-src/pull/5179
MyCLabsMethodCallToEnumConstRector::class, // https://wiki.php.net/rfc/enumerations
MyCLabsClassToEnumRector::class, // https://wiki.php.net/rfc/enumerations
StringableForToStringRector::class, // https://wiki.php.net/rfc/stringable
ReadOnlyPropertyRector::class, // https://wiki.php.net/rfc/readonly_properties_v2
]);
};
4 changes: 2 additions & 2 deletions src/Exception/SnelstartApiErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class SnelstartApiErrorException extends \RuntimeException
public static function handleError(array $body): self
{
if (isset($body["modelState"])) {
$errorMessages = [ sprintf("%d validation failures occurred.", \count($body["modelState"])) ];
$errorMessages = [ sprintf("%d validation failures occurred.", is_countable($body["modelState"]) ? \count($body["modelState"]) : 0) ];

foreach ($body["modelState"] as $field => $modelStateErrors) {
$errorMessages[] = $field . ": ";
Expand Down Expand Up @@ -39,6 +39,6 @@ public static function handleError(array $body): self
return new static($body["Message"] ?? $body["message"], 400);
}

throw new static("Unknown exception. Message body: " . \json_encode($body), 400);
throw new static("Unknown exception. Message body: " . \json_encode($body, JSON_THROW_ON_ERROR), 400);
}
}
6 changes: 2 additions & 4 deletions src/Request/ODataRequestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ final class ODataRequestData implements ODataRequestDataInterface
/**
* @var int
*/
private $top;
private $top = Snelstart::MAX_RESULTS;

/**
* @var int
*/
private $skip;
private $skip = 0;

/**
* @var string
Expand All @@ -48,8 +48,6 @@ final class ODataRequestData implements ODataRequestDataInterface

public function __construct()
{
$this->top = Snelstart::MAX_RESULTS;
$this->skip = 0;
}

public function getFilter(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Secure/CachedAccessTokenConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ public function getToken(?BearerTokenInterface $bearerToken = null): AccessToken

protected function getItemKey(): string
{
return self::CACHE_ITEM_PREFIX . \spl_object_hash($this) . mt_rand(0, 99);
return self::CACHE_ITEM_PREFIX . \spl_object_hash($this) . random_int(0, 99);
}
}