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

Support PHP 8.4 #44

Merged
merged 17 commits into from
Feb 7, 2025
Merged

Support PHP 8.4 #44

merged 17 commits into from
Feb 7, 2025

Conversation

compwright
Copy link
Contributor

Resolves #43

  • Adds PHPStan to detect problems
  • Adds missing type hints
  • Tightens existing type hints
  • Fixes typos
  • Removes unused imports, properties, and mocks

Copy link
Member

@harikt harikt left a comment

Choose a reason for hiding this comment

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

Does adding return type : void breaks the BC ? @koriym @pmjones

src/Relation/HasManyThrough.php Show resolved Hide resolved
src/Relation/HasOne.php Show resolved Hide resolved
@harikt
Copy link
Member

harikt commented Jan 25, 2025

Lots of changes, so that easy to get lost. I wished next time, we can have smaller changes. Good to see all tests are passing.

Copy link
Contributor Author

@compwright compwright left a comment

Choose a reason for hiding this comment

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

@harikt thanks for your review, please see my comments.

If you need this broken up somehow, I'm happy to do that with some direction.

Otherwise, I would appreciate it if you would merge and release, as all tests and all CI actions in supported PHP versions are passing.

src/Relation/HasManyThrough.php Show resolved Hide resolved
src/Relation/HasOne.php Show resolved Hide resolved
@compwright
Copy link
Contributor Author

compwright commented Jan 29, 2025

Does adding return type : void breaks the BC ? @koriym @pmjones

@harikt It does not break BC, as demonstrated by the passing tests. It might affect implementations that have extended classes to overload any of these methods, but that is not a documented use case and I don't think you need to be concerned with it.

If it were me I would do a minor version release, I don't think it merits a major version release.

@harikt
Copy link
Member

harikt commented Jan 30, 2025

@compwright as we are not type hinting return type on other methods can we remove the new type defined: void in the src directory. I don't care about the introduction in tests.

If you need this broken up somehow, I'm happy to do that with some direction.

No you don't need to do in this PR. I was just telling smaller changes are easy to review and move forward.

I will do a release once you make the change.

@@ -66,10 +69,10 @@ public function testNoForeignType()

$this->manager = new Manager($type_builder, $relation_builder, $types);
$this->expectException('Aura\Marshal\Exception');
$this->manager->posts;
$this->manager->__get('posts');
Copy link
Member

Choose a reason for hiding this comment

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

Why did you changed this ?

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 effect is the same, the change makes the code more readable, and satisfies PHPStan.

Copy link
Member

@harikt harikt Jan 31, 2025

Choose a reason for hiding this comment

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

I do understand the effect is same, but wished those changes are not made to satisfy phpstan. This is tests file right ? I can revert that, not an issue.

Copy link
Contributor Author

@compwright compwright Jan 31, 2025

Choose a reason for hiding this comment

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

To be honest, it should never have been written the first way. It is a statement that only has any meaning BECAUSE there is a magic method, but that is not obvious to look at it. It looks like a typo, and PHPStan flags things like that for good reason. Calling the magic method explicitly is exactly what should be done in a test case for the magic method.

My 2 cents :)

Copy link
Member

Choose a reason for hiding this comment

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

@compwright It's up to @harikt to resolve the conversation when he sees fit.

@koriym
Copy link
Member

koriym commented Jan 30, 2025

but that is not a documented use case and I don't think you need to be concerned with it.

Thank you for the suggestion. However, since we haven't marked the class as final, adding a runtime void return type poses a risk of breaking existing subclasses. We believe @return void alongside phpstan is sufficient in this case, and don't see a compelling reason to introduce a runtime void at this point.

@compwright
Copy link
Contributor Author

Since we haven't marked the class as final, adding a runtime void return type poses a risk of breaking existing subclasses. We believe @return void alongside phpstan is sufficient in this case, and don't see a compelling reason to introduce a runtime void at this point.

@harikt @koriym done

@frederikbosch frederikbosch removed their request for review January 30, 2025 18:38
@harikt
Copy link
Member

harikt commented Jan 31, 2025

Thank you @compwright for the changes. I am ok with the changes. Anyone else have a different opinion? I will wait for 2 more days before merging.

@compwright
Copy link
Contributor Author

Thank you @compwright for the changes. I am ok with the changes. Anyone else have a different opinion? I will wait for 2 more days before merging.

Will you be able to release this soon? Thanks in advance!

@harikt harikt merged commit bd33dc5 into auraphp:4.x Feb 7, 2025
9 checks passed
@harikt
Copy link
Member

harikt commented Feb 7, 2025

@compwright https://github.com/auraphp/Aura.Marshal/releases/tag/4.0.3 . Sorry for the delay and thanks for making this happen.

Regarding the usage $this->manager->posts , phpstan was complaing that line was doing anything, so assigning to a variable was suppressing the error. So I am doing like this for now $k = $this->manager->posts; . I have noted this in the comments. Just a note.

Another thing as @pmjones mentioned, the person who have asked the question should resolve the conversation, else it will get lost.

Thank you all for your help.

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.

Deprecation error in PHP 8.4.x
4 participants