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

Question about return type for with/without methods on HierarchicalPath #153

Open
SeriousKen opened this issue Jan 12, 2025 · 0 comments
Open

Comments

@SeriousKen
Copy link

SeriousKen commented Jan 12, 2025

Q A
Package league/uri-components
Version 7.5.1

Question

Is there any reason that the withLeadingSlash, withoutLeadingSlash, withTrailingSlash, withoutTrailingSlash and withoutDotSegments have a return type of PathInterface and not SegmentedPathInterface on the HierarchicalPath class?

This currently causes an issue with intellisense where the order of chaining methods matters. For example, in VSCode using the PHP Intellephense plugin the following code is highlighted as an error (assuming $path is an instance of HierarchicalPath)

$path->withoutLeadingSlash()->withoutEmptySegments();

Whereas if I was to swap the methods to:

$path->withoutEmptySegments()->withoutLeadingSlash();

Then the code would be highlighted as correct.

If I change the return type in the class methods from PathInterface to SegmentedPathInterface then both work as expected with intellisense and are not highlighted as errors. Also, the change does not cause any of the current PhpUnit test suite to fail.

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

No branches or pull requests

1 participant