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

Do not call pure Misc methods through registry #792

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Feb 18, 2023

These have a singular purpose and except for parse_uri do not interact with other classes. Overriding them makes little sense.

This makes the code a bit cleaner and less opaque for static analysis.

I am ignoring Misc::error since it will go away and Misc::xml_encoding because it accesses registry.

Partly reverts f6e63e6

@jtojnar jtojnar force-pushed the no-misc-indirection branch 2 times, most recently from 6b33096 to 6230921 Compare February 18, 2023 20:01
@jtojnar jtojnar mentioned this pull request Mar 18, 2023
Copy link
Contributor

@Art4 Art4 left a comment

Choose a reason for hiding this comment

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

As much as I like this PR, but this would be a breaking change. Instead we could create non-static methods in Misc class and calling them with $registry->create(Misc::class)->.... Then we can deprecate the $registry->call() method.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 18, 2023

@Art4 I do not see what does this change break.

Or do you mean that it changes the behaviour that the methods will no longer be overridable? I do not see how that could be considered breaking any promises any more than any other implementation change would.

These have a singular purpose and except for parse_uri do not interact with other classes. Overriding them makes little sense.

This makes the code a bit cleaner and less opaque for static analysis.

I am ignoring `Misc::error` since it will go away and `Misc::xml_encoding` because it accesses registry.

Partly reverts simplepie@f6e63e6
@Art4
Copy link
Contributor

Art4 commented May 22, 2023

Something like this will not work anymore:

<?php

class CustomMisc extends \SimplePie\Misc
{
    public static function fix_protocol($url, $http = 1)
    {
        // custom implementation ...
        return $url;
    }
}

$simplepie = new \SimplePie\SimplePie();
$simplepie->get_registry()->register('Misc', CustomMisc::class);

$simplepie->set_feed_url('url_where_the_protocol_should_be_fixed_with_my_implementation');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants