wiki.techinc.nl/includes/utils/MWFunction.php
Tim Starling e4bcbe722e Introduce includes/utils directory
These are classes that provide facilities for use by any caller, are
independent of user interface, and have a limited set of dependencies on
the rest of MediaWiki. See the README file for a more precise
definition.

These classes cannot go in includes/libs because of a dependency on the
MediaWiki framework, such as wfDebug() or MWException, but they are
otherwise similar. I thought it would be useful to put them in their own
directory, to make them more discoverable, and as part of a general
program of reducing clutter in the base includes/ directory.

I've probably missed a few classes which could be included here, but the
following classes were considered and were rejected for now:

* Fallback: single caller only
* GitInfo: getViewers() has inappropriate dependencies
* HttpFunctions: depends on configuration, $wgTitle
* PoolCounter: depends on configuration
* CacheHelper: depends on IContextSource, wfMemc()

Also moved a couple of classes into libs/ instead, where that seemed to
be more appropriate.

Change-Id: I274cff805b7d694b728a89b764a049cd62d320fe
2013-11-04 11:00:42 +11:00

61 lines
1.7 KiB
PHP

<?php
/**
* Helper methods to call functions and instance objects.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
class MWFunction {
/**
* @deprecated since 1.22; use call_user_func()
* @param $callback
* @return mixed
*/
public static function call( $callback ) {
wfDeprecated( __METHOD__, '1.22' );
$args = func_get_args();
return call_user_func_array( 'call_user_func', $args );
}
/**
* @deprecated since 1.22; use call_user_func_array()
* @param $callback
* @param $argsarams
* @return mixed
*/
public static function callArray( $callback, $argsarams ) {
wfDeprecated( __METHOD__, '1.22' );
return call_user_func_array( $callback, $argsarams );
}
/**
* @param $class
* @param $args array
* @return object
*/
public static function newObj( $class, $args = array() ) {
if ( !count( $args ) ) {
return new $class;
}
$ref = new ReflectionClass( $class );
return $ref->newInstanceArgs( $args );
}
}