Hi All,
How do people feel about allowing the addition of type hinting to MediaWiki's internal
function declarations?
E.g. from this:
function UploadForm( &$request ) {
to:
function UploadForm( WebRequest $request ) {
From:
public function parse( $text, &$title, $options, $linestart = true, $clearState =
true, $revid = null ) {
to:
public function parse( $text, Title $title, array $options, $linestart = true, $clearState
= true, $revid = null ) {
From:
function addLinkObj( &$nt ) {
to:
function addLinkObj( Title $nt ) {
Pros:
* Code is a bit more readable and self-documenting, and it's easier to see what's
going on at a glance.
* Redundant object pass-by-refs in function declarations can more easily be identified and
removed (i.e. in PHP5 only scalar types
where we modify the input need the pass-by-ref ampersands).
* Types are enforced.
Cons:
* Requires PHP >= 5.1.0 for array type hinting.
* Requires PHP >= 5.1.0 for allowing NULL as a default value for objects.
* For some things like the SpecialPage base class, it may not make sense to add this, so
as to make for easier backwards
compatibility for extension writers who use "class MyExtension extends
SpecialPage".
I.e. Is it reasonable to require PHP >= 5.1.0 for MediaWiki 1.10, which will be
released around mid-April 2007? PHP 5.1.0 was
released on 24-Nov-2005. If so, are there any other reasons to do or not to do this?
All the best,
Nick.