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

Upgrade Service Manager to v4 in require, Cache to v4 and Validator to v3 in require-dev #103

Open
wants to merge 9 commits into
base: 3.0.x
Choose a base branch
from

Conversation

Jurj-Bogdan
Copy link
Contributor

Upgraded laminas/laminas-servicemanager to version 4, as well as the other dependencies required for it, and added various Psalm tweaks.

I seems I was working on this PR alongside #102 , with the main difference seemingly being the removal of v2 functions from the codebase in preparation for a new major release.

I was about to make a different PR to the current branch marking the functions removed here as deprecated, but I'll wait for feedback regarding the desired way forward.

Jurj-Bogdan and others added 4 commits January 24, 2025 12:25
@arhimede
Copy link
Member

@Jurj-Bogdan See #102
Please open a separate PR, which do not break BC , and against 2.23 branch, for the milestone 2.23.1

@arhimede
Copy link
Member

arhimede commented Feb 4, 2025

@laminas/technical-steering-committee
We have this PR and the other PR, #102
which are doing the same thing.
Only that this PR is removing the deprecated function .

So, should I create the branch 3.0.x and merge this one there ?

@gsteel
Copy link
Member

gsteel commented Feb 4, 2025

So, should I create the branch 3.0.x and merge this one there

Yes, create 3.0.x from the tip of the next minor release - You should probably get 2.24.x patches resolved first such as #106 so that merge-ups from 2.x have fewer conflicts

@arhimede arhimede added this to the 3.0.0 milestone Feb 5, 2025
@arhimede arhimede changed the base branch from 2.24.x to 3.0.x February 5, 2025 10:58
@arhimede
Copy link
Member

arhimede commented Feb 5, 2025

@Jurj-Bogdan Please fix the conflicts

renovate bot and others added 4 commits February 6, 2025 11:48
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ed deprecated usage functions

Signed-off-by: Jurj-Bogdan <[email protected]>
@arhimede arhimede requested a review from gsteel February 6, 2025 21:08
@@ -41,28 +40,20 @@ class ContainerAbstractServiceFactory implements AbstractFactoryInterface
{
Copy link
Member

Choose a reason for hiding this comment

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

This class should be made final and all properties private. You should also mark this class soft final with @final in a 2.x release

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - also a related question here. I just noticed there are already some classes marked as deprecated, maybe this should be a good time to remove them as well?

Talking about AbstractValidatorChain and AbstractValidatorChainEM3

Copy link
Member

Choose a reason for hiding this comment

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

Yes - anything that's deprecated should be dealt with in the next major. I don't know this lib well enough to know what the implications or plans might have been though.

Don't forget to document any BC breaks here with companion patches against 2.x including deprecations, and, make a start on a migration guide that lists all the BC breaking changes

* session?: Container,
* timeout?: ?int,
* }
*/
final class Csrf extends AbstractValidator
Copy link
Member

Choose a reason for hiding this comment

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

This whole class will probably need further refactoring such as deprecating and dropping all the public setters and getters

Copy link
Member

Choose a reason for hiding this comment

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

Not suggesting that work should happen in this patch tho!

@@ -114,7 +114,8 @@ public function testFactoryWillAddValidatorViaConfiguration(): void

$manager->start();

$chain = $manager->getValidatorChain();
$chain = $manager->getValidatorChain();
/** @psalm-suppress ArgumentTypeCoercion **/
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this suppression and replace it with assertions.

Assert the manager is ManagerInterface
Assert the chain is a EventManagerInterface or whatever it's supposed to be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some phpunit assertions as they're useful, but Psalm is still adamant in throwing "ArgumentTypeCoercion" errors which is why the suppressions are still there.

Copy link
Member

Choose a reason for hiding this comment

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

You need to assert $chain is an instance of EventManager (The concrete class) because that's what getListenersForEvent expects.

Please also add findUnusedPsalmSuppress="true" to psalm.xml so that unused inline suppressions are flagged.

@@ -198,7 +199,8 @@ public function testFactoryDoesNotAttachValidatorTwoTimes(): void
// Ignore exception, because we are not interested whether session validation passes in this test
}

$chain = $manager->getValidatorChain();
$chain = $manager->getValidatorChain();
/** @psalm-suppress ArgumentTypeCoercion **/
Copy link
Member

Choose a reason for hiding this comment

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

Same here… More assertions!

Copy link
Member

Choose a reason for hiding this comment

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

This suppression still needs fixing too!

@gsteel gsteel added Enhancement Dependencies Updates and changes to dependencies labels Feb 7, 2025
Signed-off-by: Jurj-Bogdan <[email protected]>
@arhimede arhimede requested a review from gsteel February 17, 2025 10:18
Copy link
Member

@gsteel gsteel left a comment

Choose a reason for hiding this comment

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

Thanks @Jurj-Bogdan - A few more tweaks please :)

Apart from inline comments, all of the changed factories need to be made final and they should all have a good cleanup - i.e protected props to private, drop any methods that are pointless etc. Happy to wait for another patch for those things, but we really don't want users extending factories and need to prevent that in the next major

*/
protected function getConfig(ContainerInterface $container)
protected function getConfig(ContainerInterface $container): array
Copy link
Member

Choose a reason for hiding this comment

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

This should be private

*/
protected function getSessionManager(ContainerInterface $container)
protected function getSessionManager(ContainerInterface $container): ?ManagerInterface
Copy link
Member

Choose a reason for hiding this comment

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

This should be private

*/
protected function normalizeContainerName($name)
protected function normalizeContainerName(string $name): string
Copy link
Member

Choose a reason for hiding this comment

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

This should be private or maybe inlined if it's only used once

@@ -114,7 +114,8 @@ public function testFactoryWillAddValidatorViaConfiguration(): void

$manager->start();

$chain = $manager->getValidatorChain();
$chain = $manager->getValidatorChain();
/** @psalm-suppress ArgumentTypeCoercion **/
Copy link
Member

Choose a reason for hiding this comment

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

You need to assert $chain is an instance of EventManager (The concrete class) because that's what getListenersForEvent expects.

Please also add findUnusedPsalmSuppress="true" to psalm.xml so that unused inline suppressions are flagged.

@@ -198,7 +199,8 @@ public function testFactoryDoesNotAttachValidatorTwoTimes(): void
// Ignore exception, because we are not interested whether session validation passes in this test
}

$chain = $manager->getValidatorChain();
$chain = $manager->getValidatorChain();
/** @psalm-suppress ArgumentTypeCoercion **/
Copy link
Member

Choose a reason for hiding this comment

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

This suppression still needs fixing too!

@gsteel gsteel changed the title bumped laminas-servicemanager to v4 alongside its dependencies, remov… Upgrade Service Manager to v4 in require, Cache to v4 and Validator to v3 in require-dev Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break Dependencies Updates and changes to dependencies Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version 3 + Implement service manager 4
4 participants