Skip to content

Code optimisations for PHP8 #45

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

Merged
merged 1 commit into from
Feb 6, 2023
Merged

Code optimisations for PHP8 #45

merged 1 commit into from
Feb 6, 2023

Conversation

GromNaN
Copy link
Contributor

@GromNaN GromNaN commented Feb 3, 2023

I'd like to propose this minor changes, mostly suggested by PHPStorm.

@@ -227,7 +227,7 @@ public function unlock(Request $request): bool

try {
$this->locks[$cacheKey]->release();
} catch (LockReleasingException $e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -100,7 +100,7 @@ public function __construct(array $options = [])
$this->options = $resolver->resolve($options);
$this->cache = $this->options['cache'];
$this->lockFactory = $this->options['lock_factory'];
$this->hashAlgorithm = version_compare(PHP_VERSION, '8.1.0', '>=') ? 'xxh128' : 'sha256';
$this->hashAlgorithm = \PHP_VERSION_ID >= 80100 ? 'xxh128' : 'sha256';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expression is evaluated by the compiler.

@@ -508,13 +508,13 @@ private function restoreResponse(array $cacheData): ?Response

// BC
if (\is_string($value)) {
$value = ['expires' => 0, 'contents' => $value];
Copy link
Contributor Author

@GromNaN GromNaN Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key expires is not used.

@Toflar
Copy link
Owner

Toflar commented Feb 6, 2023

LGTM, wdyt @alexander-schranz?

@alexander-schranz
Copy link
Contributor

alexander-schranz commented Feb 6, 2023

Looks fine from my side the only case I have not enough knowledge about is the deletion of expires: 0 part.

@Toflar Toflar merged commit 25623d8 into Toflar:4.x Feb 6, 2023
@Toflar
Copy link
Owner

Toflar commented Feb 6, 2023

The only case I have not enough knowledge about is the deletion of expires: 0 part.

That's indeed not needed :)

Thanks @GromNaN - released as 4.1.1: https://github.com/Toflar/psr6-symfony-http-cache-store/releases/tag/4.1.1

@GromNaN GromNaN deleted the php8 branch February 7, 2023 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants