Skip to content

Upgrade to PHP 8.4#13

Merged
hcsagan merged 2 commits intomasterfrom
feature/KDS-589-Module-kodus-session-Upgrade-to-PHP-8.4
Jan 13, 2025
Merged

Upgrade to PHP 8.4#13
hcsagan merged 2 commits intomasterfrom
feature/KDS-589-Module-kodus-session-Upgrade-to-PHP-8.4

Conversation

@hcsagan
Copy link
Contributor

@hcsagan hcsagan commented Jan 10, 2025

Tests did not fail at all, but there were some areas that could be improved, so I just did that.

Copy link
Contributor

@thomasnordahl-dk thomasnordahl-dk left a comment

Choose a reason for hiding this comment

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

I appreciate the boyscout rule, but adding return types and the default makes this backwards incompatible. Let's keep it light for the PHP 8.4 upgrade, and not do major versions here.

public function __construct(
private string $client_session_id,
private array $data,
private bool $is_new = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private bool $is_new = false
private bool $is_new

Adding it as a default is backwards incompatible

Copy link
Contributor Author

@hcsagan hcsagan Jan 10, 2025

Choose a reason for hiding this comment

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

It already has a default in line 40, so it doesn't have a difference.

Besides that, I am not sure how far backwards compatible we are talking about. composer.json says minimum php 8.0 already and everything passes in 8.0 environment.

Copy link
Contributor

Choose a reason for hiding this comment

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

It wasn't default in the constructor signature, which is the breaking part :-)

original: public function __construct(string $client_session_id, array $data, bool $is_new)

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it is public, we should stay strict - we can cut corners on private repositories because we know how we extend and when a b\c break is an issue or not.

src/Session.php Outdated
* @return void
*/
public function clear();
public function clear(): void;
Copy link

Choose a reason for hiding this comment

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

This is also a breaking change :)

Copy link
Contributor

@thomasnordahl-dk thomasnordahl-dk Jan 13, 2025

Choose a reason for hiding this comment

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

I checked in 3v4l.org and I think the void return type isn't an issue on extension. This works fine:

<?php

class Foo
{
    public function myMethod()
    {
        echo 'hello';
    }
}

class Bar extends Foo
{
    public function myMethod(): void
    {
        echo 'hola';
    }
}

new Bar()->myMethod();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not internally, because SessionData has the return types as well. In your example Foo should be an interface and it should have the return type, not Bar. In that case it throws a fatal error:

Fatal error: Declaration of SessionData::clear() must be compatible with Session::clear(): void in /in/JcVqe on line 8

So, the return types should be removed from the interface and SessionData if we want to keep them compatible.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@hcsagan hcsagan force-pushed the feature/KDS-589-Module-kodus-session-Upgrade-to-PHP-8.4 branch from 97ec1ae to b5d9d04 Compare January 13, 2025 10:19
@hcsagan hcsagan requested a review from mifich January 13, 2025 10:20
@hcsagan hcsagan merged commit eddf275 into master Jan 13, 2025
6 checks passed
@hcsagan hcsagan deleted the feature/KDS-589-Module-kodus-session-Upgrade-to-PHP-8.4 branch January 13, 2025 10:28
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