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

Drop PHP 7, Support PHP 8.2 #90

Merged
merged 4 commits into from
Jul 12, 2023

Conversation

rogervila
Copy link
Contributor

Signed-off-by: Roger Vilà [email protected]

Q A
Documentation no
Bugfix no
BC Break no
New Feature no
RFC no
QA no

Description

Drop PHP 7, Support PHP 8.2

Signed-off-by: Roger Vilà <[email protected]>
@rogervila rogervila marked this pull request as draft January 9, 2023 21:43
@rogervila
Copy link
Contributor Author

Depends on laminas-api-tools/api-tools#96

@weierophinney weierophinney added the Enhancement New feature or request label Jul 12, 2023
@weierophinney weierophinney added this to the 2.1.0 milestone Jul 12, 2023
Bumps to most recent releases of all api-tools components.

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
All of these are due to array shapes.

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
Several tests have ".dist" config files that a setUp process copies to a path omitting the suffix.
That file is then _included_ by the test in order to do assertions.
Psalm was flagging the include as invalid due to the file not existing in a clean setup (which it will not).

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
@weierophinney weierophinney marked this pull request as ready for review July 12, 2023 13:58
* @param array<string, mixed> $config
*/
public function __construct($name, $config)
public function __construct(public string $name, public array $config)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see a number of these changes in the various entity classes (adding constructor property promotion with explicit types).

Overall, I think they are fine; these were the documented types in annotations, and what we test against; further, using constructor property promotion ensures the properties are actually declared, which they were not before.

However, it is a subtle BC break for anybody extending these classes. @Ocramius , what are your thoughts? Should we go ahead with these for next minor, push to next major, or ask to revert them?

Copy link
Member

Choose a reason for hiding this comment

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

On the constructor, they are mostly fine due to them not affecting LSP checks

Copy link
Member

Choose a reason for hiding this comment

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

since the property is dynamic, it is bc break https://3v4l.org/vLe8v

Rector can cover that:

  1. dynamic: skipped https://getrector.com/demo/9cbff805-62d4-4557-baab-ea1875b11127
  2. defined property: applied
    a. typed https://getrector.com/demo/1ef76619-2b7f-43d4-9c7b-0cd009d69b45
    b. not typed https://getrector.com/demo/085e9f92-ed93-45b4-ace9-1673c8770816

Instead, I suggest add public property instead:

public $name;
public $config;

Copy link
Member

Choose a reason for hiding this comment

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

anyway, Rector has CompleteDynamicPropertiesRector to auto add public property if needed:

https://getrector.com/demo/a8f2c237-a12c-4fae-9f92-eba6677a53d4

Copy link
Member

Choose a reason for hiding this comment

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

So, if you combine CompleteDynamicPropertiesRector + ClassPropertyAssignToConstructorPromotionRector , you will get it processed but kept the @param without adding new type

https://getrector.com/demo/26c0e45b-a208-4a5f-acd8-f82e11bbda51

Copy link
Member

Choose a reason for hiding this comment

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

On summary, just remove the type, and it will be safer:

Suggested change
public function __construct(public string $name, public array $config)
public function __construct(public $name, public $config)

Copy link
Contributor

Choose a reason for hiding this comment

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

since the property is dynamic, it is bc break

Right, but these are (a) essentially internal, and (b) the expectation is that the properties are present. I'd argue it actually tightens the contract and makes it more reliable.

Copy link
Member

Choose a reason for hiding this comment

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

@weierophinney I see, it need @internal flag then

Copy link
Contributor

Choose a reason for hiding this comment

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

remove the type,

We should have been validating the type all along, however. This ensures the type is correct.

@weierophinney weierophinney merged commit 7799e42 into laminas-api-tools:2.1.x Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants