resourceloader: Use -1 instead of null in DerivativeResourceLoaderContext
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 10 Jun 2015 17:43:32 +0000 (18:43 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 13 Jun 2015 04:55:20 +0000 (05:55 +0100)
commitd20583dd19502c8088f7522c07dde42d0846d6b1
treebe168c9a38120faf9052d5eef564792dc16cf914
parent28431788854c8a3f6f790d7fe29e04bd0ff0f5e1
resourceloader: Use -1 instead of null in DerivativeResourceLoaderContext

The ResourceLoaderContext class used null to determine absence of
an overridde in the derivative object.

However three of the members in question allow null as legitimate value.
(Namely 'only', 'user', and 'version').

This makes is impossible for a derivative context to remove one
of those values if the parent context has them set.

Use case: I782df43c needs to create a derivative context of
          load.php?only=scripts&modules=startup without 'only'.

Use -1 instead as internal placeholder value.

Also:

* ResourceLoaderContext::getSkin() was documented as returning 'string|null' when in
  fact it always has a default value. Never returns null.

* DerivativeResourceLoaderContext::setOnly() and setVersion() were missing
  type hint for 'null' (as it was incompatible with their getter). Adding 'false'.

* Swap if/else statements to handle the special case first (inheriting).
  Allowing the rest of the function body to handle the local value.
  In preparation for further development.

Change-Id: I058884525237effe8aef35469ed7693bb7cea591
includes/resourceloader/DerivativeResourceLoaderContext.php
includes/resourceloader/ResourceLoaderContext.php
tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php [new file with mode: 0644]