Skip to content

Commit

Permalink
Merge pull request #1174: Resolve PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Dec 11, 2024
2 parents cbd6c6f + 73a8040 commit 090b2df
Show file tree
Hide file tree
Showing 147 changed files with 217 additions and 300 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/.github export-ignore
/.* export-ignore
/builder export-ignore
/tests export-ignore
Expand Down
53 changes: 0 additions & 53 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,59 +117,6 @@ jobs:
vendor/bin/psalm --no-cache --shepherd --stats --output-format=checkstyle --php-version=${{ matrix.php }}
vendor/bin/rector --dry-run --clear-cache
coding-standards:
name: Coding Standards
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: ['8.3'] # Note: This workflow requires only the LATEST version of PHP
os: [ubuntu-latest]

steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
# Install PHP Dependencies
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate Composer
run: composer validate
- name: Get Composer Cache Directory
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress

# Execution
- name: Check Coding Standards
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -vvv --dry-run --using-cache=no

#
# Execute unit tests on all valid PHP versions.
#
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ composer.lock
Thumbs.db

# Other
runtime
.phpunit.cache
.phpunit.result.cache
.php-cs-fixer.cache
Expand Down
27 changes: 9 additions & 18 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@

declare(strict_types=1);

if (!file_exists(__DIR__.'/src')) {
exit(0);
}
require_once 'vendor/autoload.php';

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'ternary_operator_spaces' => false,
])
->setRiskyAllowed(true)
->setFinder(
(new PhpCsFixer\Finder())
->files()
->name('*.php')
->in(__DIR__ . '/src')
->append([__FILE__])
->notPath(['#/Fixtures/#', '#/tests/#', '#/views/#'])
)
->setCacheFile('.php-cs-fixer.cache');
return \Spiral\CodeStyle\Builder::create()
->include(__DIR__ . '/builder')
->include(__DIR__ . '/src')
->include(__DIR__ . '/tests')
->include(__FILE__)
->cache('./runtime/php-cs-fixer.cache')
->allowRisky()
->build();
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased

- Definitions of nullable parameters have been fixed according to PHP 8.4 deprecations.

## 3.14.7 - 2024-11-25

- **Bug Fixes**
Expand Down
18 changes: 7 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@
"phpunit/phpunit": "10.5.3",
"ramsey/collection": "^1.2",
"ramsey/uuid": "^4.2.3",
"rector/rector": "1.2.5",
"spiral/code-style": "^1.1",
"rector/rector": "1.2.10",
"spiral/code-style": "^2.2",
"spiral/nyholm-bridge": "^1.2",
"spiral/testing": "^2.8",
"spiral/validator": "^1.3",
Expand Down Expand Up @@ -264,15 +264,11 @@
"spiral/sapi-bridge": "<1.1"
},
"scripts": {
"tests": [
"phpunit --testdox",
"phpcs --standard=phpcs.xml",
"psalm --no-cache"
],
"fixers": [
"phpcbf --standard=phpcs.xml",
"psalm --alter --dry-run"
]
"cs:diff": "php-cs-fixer fix --dry-run -v --diff",
"cs:fix": "php-cs-fixer fix -v",
"psalm": "psalm",
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
"test": "phpunit --color=always"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/src/AuthContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
) {
}

public function start(TokenInterface $token, string $transport = null): void
public function start(TokenInterface $token, ?string $transport = null): void
{
$this->closed = false;
$this->actor = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/src/AuthContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface AuthContextInterface
/**
* Start new auth context based on a given token. Actor can be received on demand.
*/
public function start(TokenInterface $token, string $transport = null): void;
public function start(TokenInterface $token, ?string $transport = null): void;

/**
* Returns associated token if any.
Expand Down
4 changes: 1 addition & 3 deletions src/Auth/src/TokenStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ public function load(string $id): ?TokenInterface;
/**
* Create token based on the payload provided by actor provider.
*
* @param \DateTimeInterface|null $expiresAt
*
* @throws TokenStorageException
*/
public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface;
public function create(array $payload, ?\DateTimeInterface $expiresAt = null): TokenInterface;

/**
* Delete token from the persistent storage.
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/tests/Stub/TestAuthToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestAuthToken implements TokenInterface
* @param array $payload
* @param \DateTimeInterface|null $expiresAt
*/
public function __construct(string $id, array $payload, \DateTimeInterface $expiresAt = null)
public function __construct(string $id, array $payload, ?\DateTimeInterface $expiresAt = null)
{
$this->id = $id;
$this->expiresAt = $expiresAt;
Expand Down
2 changes: 1 addition & 1 deletion src/AuthHttp/src/HttpTransportInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function commitToken(
Request $request,
Response $response,
string $tokenID,
\DateTimeInterface $expiresAt = null
?\DateTimeInterface $expiresAt = null
): Response;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/AuthHttp/src/Transport/CookieTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function fetchToken(Request $request): ?string
public function commitToken(
Request $request,
Response $response,
string $tokenID = null,
\DateTimeInterface $expiresAt = null
?string $tokenID = null,
?\DateTimeInterface $expiresAt = null
): Response {
/** @var CookieQueue $cookieQueue */
$cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE);
Expand Down Expand Up @@ -82,7 +82,7 @@ public function removeToken(Request $request, Response $response, string $tokenI
/**
* @return int<0, max>|null
*/
private function getLifetime(\DateTimeInterface $expiresAt = null): ?int
private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int
{
if ($expiresAt === null) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/AuthHttp/src/Transport/HeaderTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function commitToken(
Request $request,
Response $response,
string $tokenID,
\DateTimeInterface $expiresAt = null
?\DateTimeInterface $expiresAt = null
): Response {
if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) {
return $response;
Expand Down
2 changes: 1 addition & 1 deletion src/AuthHttp/src/TransportRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function setTransport(string $name, HttpTransportInterface $transport): v
$this->transports[$name] = $transport;
}

public function getTransport(string $name = null): HttpTransportInterface
public function getTransport(?string $name = null): HttpTransportInterface
{
$name ??= $this->default;

Expand Down
6 changes: 3 additions & 3 deletions src/AuthHttp/tests/Diactoros/UploadedFileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ final class UploadedFileFactory implements UploadedFileFactoryInterface
*/
public function createUploadedFile(
StreamInterface $stream,
int $size = null,
?int $size = null,
int $error = \UPLOAD_ERR_OK,
string $clientFilename = null,
string $clientMediaType = null
?string $clientFilename = null,
?string $clientMediaType = null
): UploadedFileInterface {
if ($size === null) {
$size = $stream->getSize();
Expand Down
2 changes: 1 addition & 1 deletion src/AuthHttp/tests/Stub/TestAuthHttpStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function load(string $id): ?TokenInterface
return new TestAuthHttpToken($id, ['id' => $id]);
}

public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface
public function create(array $payload, ?\DateTimeInterface $expiresAt = null): TokenInterface
{
return new TestAuthHttpToken(
$payload['id'],
Expand Down
2 changes: 1 addition & 1 deletion src/AuthHttp/tests/Stub/TestAuthHttpToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestAuthHttpToken implements TokenInterface
* @param array $payload
* @param \DateTimeInterface|null $expiresAt
*/
public function __construct(string $id, array $payload, \DateTimeInterface $expiresAt = null)
public function __construct(string $id, array $payload, ?\DateTimeInterface $expiresAt = null)
{
$this->id = $id;
$this->expiresAt = $expiresAt;
Expand Down
2 changes: 1 addition & 1 deletion src/Boot/src/Injector/EnumInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
) {
}

public function createInjection(\ReflectionClass $class, string $context = null): UnitEnum
public function createInjection(\ReflectionClass $class, ?string $context = null): UnitEnum
{
$attribute = $this->reader->firstClassMetadata($class, ProvideFrom::class);
if ($attribute === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/src/Core/CacheInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
) {
}

public function createInjection(ReflectionClass $class, string $context = null): CacheInterface
public function createInjection(ReflectionClass $class, ?string $context = null): CacheInterface
{
try {
if ($context === null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Config/src/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function modify(string $section, PatchInterface $patch): array
}
}

public function getConfig(string $section = null): array
public function getConfig(?string $section = null): array
{
if (isset($this->data[$section])) {
return $this->data[$section];
Expand All @@ -99,7 +99,7 @@ public function getConfig(string $section = null): array
return $this->data[$section] = $data;
}

public function createInjection(\ReflectionClass $class, string $context = null): object
public function createInjection(\ReflectionClass $class, ?string $context = null): object
{
$config = $class->getConstant('CONFIG');
if (isset($this->instances[$config])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Config/tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function setUp(): void
$this->container = new Container();
}

protected function getFactory(string $directory = null, bool $strict = true): ConfigManager
protected function getFactory(?string $directory = null, bool $strict = true): ConfigManager
{
if (is_null($directory)) {
$directory = __DIR__ . '/fixtures';
Expand Down
6 changes: 3 additions & 3 deletions src/Console/src/Traits/HelpersTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function confirm(string $question, bool $default = false): bool
/**
* Asks a question.
*/
protected function ask(string $question, string $default = null): mixed
protected function ask(string $question, ?string $default = null): mixed
{
return $this->output->ask($question, $default);
}
Expand All @@ -93,7 +93,7 @@ protected function choiceQuestion(
string $question,
array $choices,
mixed $default = null,
int $attempts = null,
?int $attempts = null,
bool $multiselect = false
): mixed {
$question = new ChoiceQuestion($question, $choices, $default);
Expand Down Expand Up @@ -180,7 +180,7 @@ protected function alert(string $string): void
/**
* Write a string as standard output.
*/
protected function line(string $string, string $style = null): void
protected function line(string $string, ?string $style = null): void
{
$styled = $style ? "<$style>$string</$style>" : $string;

Expand Down
2 changes: 1 addition & 1 deletion src/Console/tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function setUp(): void
);
}

protected function getCore(LocatorInterface $locator = null, ?EventDispatcherInterface $eventDispatcher = null): Console
protected function getCore(?LocatorInterface $locator = null, ?EventDispatcherInterface $eventDispatcher = null): Console
{
$config = $this->container->get(ConsoleConfig::class);

Expand Down
9 changes: 1 addition & 8 deletions src/Console/tests/SignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function perform(): int
])
);

$this->assertSame(
$this->assertStringStartsWith(
<<<'HELP'
Usage:
foo:bar [options] [--] <foo> [<bar> [<baz>...]]
Expand All @@ -150,13 +150,6 @@ public function perform(): int
-o, --id[=ID] Id option description. (multiple values allowed)
-Q, --quit Quit option description.
--naf[=NAF] Naf option description. [default: "default"]
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

HELP
,
$core->run(command: 'help', input: ['command_name' => 'foo:bar'])->getOutput()->fetch()
Expand Down
10 changes: 5 additions & 5 deletions src/Cookies/src/CookieQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public function __construct(
*/
public function set(
string $name,
string $value = null,
int $lifetime = null,
string $path = null,
string $domain = null,
bool $secure = null,
?string $value = null,
?int $lifetime = null,
?string $path = null,
?string $domain = null,
?bool $secure = null,
bool $httpOnly = true,
?string $sameSite = null
): self {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/ConfigsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ interface ConfigsInterface extends InjectorInterface
*
* @throws ConfiguratorException
*/
public function getConfig(string $section = null): array;
public function getConfig(?string $section = null): array;
}
Loading

0 comments on commit 090b2df

Please sign in to comment.