Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-5827: Replaced deprecated string interpolation (PHP 8.2+) #386

Merged
merged 6 commits into from
Dec 7, 2023
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"symfony/phpunit-bridge": "^5.1",
"symfony/proxy-manager-bridge": "^5.3",
"phpstan/phpstan": "^1.2"
"phpstan/phpstan": "^1.2",
"symfony/runtime": "^5.3.0"
},
"conflict": {
"friendsofphp/php-cs-fixer": "3.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public function assertUserWithNameExistsWithFields($username, TableNode $table)
*/
private function findNonExistingUserEmail($username = 'User')
{
$email = "${username}@ez.no";
$email = "{$username}@ez.no";
if ($this->checkUserExistenceByEmail($email)) {
return $email;
}
Expand Down
2 changes: 1 addition & 1 deletion eZ/Publish/API/Repository/Tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected function getSetupFactory(): SetupFactory
if (null === $this->setupFactory) {
if (false === ($setupClass = getenv('setupFactory'))) {
$setupClass = LegacySetupFactory::class;
putenv("setupFactory=${setupClass}");
putenv("setupFactory={$setupClass}");
}

if (false === getenv('fixtureDir')) {
Expand Down
2 changes: 1 addition & 1 deletion eZ/Publish/API/Repository/Tests/ContentTypeServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ public function testCreateContentTypeStructValues(array $data)
$this->assertEquals(
$typeCreate->$propertyName,
$contentType->$propertyName,
"Did not assert that property '${propertyName}' is equal on struct and resulting value object"
"Did not assert that property '{$propertyName}' is equal on struct and resulting value object"
);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion eZ/Publish/Core/FieldType/GatewayBasedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function getGateway(array $context)
);

if (!isset($this->gateways[$context['identifier']])) {
throw new \OutOfBoundsException("No gateway for ${context['identifier']} available.");
throw new \OutOfBoundsException("No gateway for {$context['identifier']} available.");
}

$gateway = $this->gateways[$context['identifier']];
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Persistence/Cache/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public function __construct(
/**
* Helper for getting multiple cache items in one call and do the id extraction for you.
*
* Cache items must be stored with a key in the following format "${keyPrefix}${id}", like "ez-content-info-${id}",
* Cache items must be stored with a key in the following format "{$keyPrefix}{$id}", like "ez-content-info-{$id}",
* in order for this method to be able to prefix key on id's and also extract key prefix afterwards.
*
* It also optionally supports a key suffixs, for use on a variable argument that affects all lookups,
* like translations, i.e. "ez-content-${id}-${translationKey}" where $keySuffixes = [$id => "-${translationKey}"].
* like translations, i.e. "ez-content-{$id}-{$translationKey}" where $keySuffixes = [$id => "-{$translationKey}"].
*
* @param array $ids
* @param string $keyPrefix E.g "ez-content-"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ final protected function getListCacheValue(
* Load items from in-memory cache, symfony cache pool or backend in that order.
* If not cached the returned objects will be placed in cache.
*
* Cache items must be stored with a key in the following format "${keyPrefix}${id}", like "ez-content-info-${id}",
* Cache items must be stored with a key in the following format "{$keyPrefix}{$id}", like "ez-content-info-{$id}",
* in order for this method to be able to prefix key on id's and also extract key prefix afterwards.
*
* @param array $ids
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/Persistence/Cache/ContentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function copy($contentId, $versionNo = null, $newOwnerId = null)
*/
public function load($contentId, $versionNo = null, array $translations = null)
{
$keySuffix = $versionNo ? "-${versionNo}-" : '-';
$keySuffix = $versionNo ? "-{$versionNo}-" : '-';
$keySuffix .= empty($translations) ? self::ALL_TRANSLATIONS_KEY : implode('|', $translations);

return $this->getCacheValue(
Expand Down Expand Up @@ -235,7 +235,7 @@ function () use ($remoteId) {
*/
public function loadVersionInfo($contentId, $versionNo = null)
{
$keySuffix = $versionNo ? "-${versionNo}" : '';
$keySuffix = $versionNo ? "-{$versionNo}" : '';
$cacheItem = $this->cache->getItem(
$this->cacheIdentifierGenerator->generateKey(
self::CONTENT_VERSION_INFO_IDENTIFIER,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Contracts\Core\MVC\Symfony\ErrorHandler;

use const PHP_VERSION_ID;
use Symfony\Component\Runtime\Internal\BasicErrorHandler;

final class Php82HideDeprecationsErrorHandler
{
public static function register(bool $debug): void
{
BasicErrorHandler::register($debug);

if (PHP_VERSION_ID > 80200) {
error_reporting(E_ALL & ~E_DEPRECATED);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Tests\Core\MVC\Symfony\ErrorHandler;
konradoboza marked this conversation as resolved.
Show resolved Hide resolved

use Ibexa\Contracts\Core\MVC\Symfony\ErrorHandler\Php82HideDeprecationsErrorHandler;
use PHPUnit\Framework\TestCase;

/**
* @requires PHP >= 8.2.0
*/
final class Php82HideDeprecationsErrorHandlerTest extends TestCase
{
/** @var int */
private $originalErrorReporting;
konradoboza marked this conversation as resolved.
Show resolved Hide resolved

protected function setUp(): void
{
$this->originalErrorReporting = error_reporting();
}

protected function tearDown(): void
{
error_reporting($this->originalErrorReporting);
restore_error_handler();
}

public function testRegisterDebug(): void
{
Php82HideDeprecationsErrorHandler::register(true);
$errorReporting = error_reporting();

$this->assertSame(E_ALL & ~E_DEPRECATED, $errorReporting);
}

public function testRegisterNoDebug(): void
{
Php82HideDeprecationsErrorHandler::register(false);
$errorReporting = error_reporting();

$this->assertSame(E_ALL & ~E_DEPRECATED, $errorReporting);
}
}
Loading