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

Added return types #1439

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open

Added return types #1439

wants to merge 1 commit into from

Conversation

stephanvierkant
Copy link

Q A
Branch? 3.x
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Fixed tickets #1415
License MIT
Doc

Added or changed some return types. Most of the methods already had a return type. I couldn't find any methods where a parameter type declaration could be added.

Copy link
Member

@dbu dbu left a comment

Choose a reason for hiding this comment

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

thanks for the pull request.

as we are doing a new major version, i think that we should also change the LoaderInterface to have typed parameters (and then adjust all implementations accordingly)

i want to challenge if we need to make return types nullable - i would prefer to go the other direction of making more things not nullable.

src/Imagine/Cache/CacheManager.php Outdated Show resolved Hide resolved
src/Imagine/Filter/FilterManager.php Outdated Show resolved Hide resolved
src/Service/FilterService.php Outdated Show resolved Hide resolved
@dbu
Copy link
Member

dbu commented Jan 4, 2022

@stephanvierkant do you plan to follow up on the feedback? i would love to get these improvements in once we figured out the remaining questions.

@@ -56,7 +56,7 @@ public function remove(array $paths, array $filters): void
$this->resolver->remove($paths, $filters);
}

protected function rewriteUrl(string $url): string
protected function rewriteUrl(string $url): ?string
Copy link
Member

Choose a reason for hiding this comment

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

the only way how this can return null is when there is a regex error in the preg_replace call. is the calling side of this handling that? if not, i'd prefer to check the return value of preg_replace in this method and use preg_last_error_msg to throw an exception. then we can leave this as returning a non-nullable string.

* Returns resource url.
*/
public function getUrl(): ?string
public function getUrl(): string
Copy link
Member

Choose a reason for hiding this comment

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

i don't think you can change this to non-nullable as the url property of the class is nullable.

Copy link
Author

Choose a reason for hiding this comment

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

I've just looked at ‘protected ?string $url;’

Copy link
Member

Choose a reason for hiding this comment

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

the correct return type should look like this:

Suggested change
public function getUrl(): string
public function getUrl(): ?string

@dbu dbu mentioned this pull request Feb 9, 2022
@dbu dbu added this to the 3.0.0 milestone Feb 10, 2022
@cbeyer
Copy link

cbeyer commented Jun 12, 2023

Any news ?

@dbu
Copy link
Member

dbu commented Sep 23, 2023

i would love to get this moving again, but have little time. @cbeyer if you want to pick up the branch from stephan and do a new pull request with the conflicts resolved and possibly more strict typing cleanup, please do and i will be happy to review the changes.

@dbu
Copy link
Member

dbu commented Jan 2, 2024

@tacman this would be a crucial bit to modernize the code for 3.x

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.

None yet

3 participants