When implementing a custom formatter, it's natural to extend from RestWSBaseFormat. However, the base class uses some static methods and calls them via self::method instead of static::method. This sucks, as it makes it impossible to override the method.

As we cannot go with static::method without requiring php 5.3, I'd suggest converting the static method to a run-time method. I see no reason this has to be static and that way RestWS keeps working with PHP 5.2. This is a small API break, however I don't think anyone is calling the method directly?

CommentFileSizeAuthor
d7_restws_nostatic.patch3.35 KBfago

Comments

klausi’s picture

Status: Active » Needs review

Fine with me I guess, but I think the git commit message should come with a big fat "API change" since it is one at least theoretically.

Grayside’s picture

This works for me in development of https://github.com/grayside/hal, and is a dependency of that module.

neograph734’s picture

  • Commit ec280c7 on 7.x-2.x by klausi:
    Issue #2208745 by fago: API change: static RestWSBaseFormat methods...
klausi’s picture

Status: Needs review » Fixed
neograph734’s picture

Hey guys, I just discovered some more static functions on lines 643 & 678 of restws.formats.inc

Shouldn't those be overridden as well? `public static function setXMLReference` is still blocking #2253947: format suffix not added to next-first-last page url's.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.