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

Improved typing #96

Merged
merged 2 commits into from
Jan 29, 2024
Merged

Improved typing #96

merged 2 commits into from
Jan 29, 2024

Conversation

SamMousa
Copy link
Collaborator

This PR improves typing and fixes issues identified by phpstan.
It also removes some functions that were already marked as @internal (so it doesn't count as breaking backward compatibility)

@samdark samdark merged commit 219fbd9 into master Jan 29, 2024
6 checks passed
@samdark samdark deleted the chore-improve-typing branch January 29, 2024 09:54
@boboldehampsink
Copy link

This is breaking the implementation in Craft CMS's test class, as the Yii2 Module now is a "final" class? This is not really BC-compatible. If intended, it should atleast be a new version?

@SamMousa
Copy link
Collaborator Author

SamMousa commented Dec 9, 2024

You are right, changing classes to final should have been a major version update.

Are you up for making a PR that reverts the final change? Note that we will create a new major release where these classes will be final.

Extending 3rd party classes is generally not the way to go as your code becomes very strongly coupled to the library.

@samdark
Copy link
Member

samdark commented Dec 9, 2024

Un-finalized the module in master. Anything else?

@samdark
Copy link
Member

samdark commented Dec 9, 2024

Tagged release.

@boboldehampsink
Copy link

Tagging @brandonkelly, which has code that extends this module: https://github.com/craftcms/cms/blob/5.x/src/test/Craft.php

@boboldehampsink
Copy link

Un-finalized the module in master. Anything else?

I haven't tested it any further, will do tomorrow.

@boboldehampsink
Copy link

@brandonkelly the latest release of this module results in the following:

PHP Fatal error:  Declaration of craft\test\CraftConnector::startApp(?yii\log\Logger $logger = null) must be compatible with Codeception\Lib\Connector\Yii2::startApp(?yii\log\Logger $logger = null): void in /app/user/vendor/craftcms/cms/src/test/CraftConnector.php on line 135

Types need to be updated accordingly in Craft as well

@SamMousa
Copy link
Collaborator Author

SamMousa commented Dec 10, 2024 via email

@boboldehampsink
Copy link

This would be something for the Craft team to consider. To get some insight, here is how they are using this module: https://github.com/craftcms/cms/tree/5.x/src/test

By the way, I think even changing typing like this is worth a new major release, as its still not backward compatible.

@brandonkelly
Copy link

@boboldehampsink We updated the return type for CraftConnector::startApp() in Craft 5.5.6.

@SamMousa
Copy link
Collaborator Author

This would be something for the Craft team to consider. To get some insight, here is how they are using this module: https://github.com/craftcms/cms/tree/5.x/src/test

By the way, I think even changing typing like this is worth a new major release, as its still not backward compatible.

I agree, it was a mistake by me, which is why we reverted. Itll be in a major version bump.

@boboldehampsink
Copy link

@boboldehampsink We updated the return type for CraftConnector::startApp() in Craft 5.5.6.

Thanks! Any chance of a backport for v4 as well?

@brandonkelly
Copy link

@boboldehampsink We didn’t override that method until Craft 5. And Craft 4 is stuck on codeception/module-yii2 1.1.5, as 1.1.6 is when they started requiring Codeception 5.

If you’re using Codeception 5 with Craft 4, please PR whatever changes you need to Craft. Assuming they don’t break our own tests, we can pull them in.

@boboldehampsink
Copy link

@brandonkelly we're using Codeception 5 with Craft 4 indeed. That would just be the same fix, correct?

@brandonkelly
Copy link

As I said, we weren’t overriding that method until Craft 5.

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.

4 participants