diff options
| author | Christian Schneider | 2010-01-08 14:17:18 +0000 | 
|---|---|---|
| committer | Christian Schneider | 2010-01-08 14:17:18 +0000 | 
| commit | 940735ead52921744e1a8e531001333c8d7e26ea (patch) | |
| tree | 3333bbcd5af069ca8892ef5139200cf4efb1e7ae | |
| parent | 202d85168ea881adb8c6b5c437f42bb9e1d424ef (diff) | |
| download | itools-940735ead52921744e1a8e531001333c8d7e26ea.tar.gz itools-940735ead52921744e1a8e531001333c8d7e26ea.tar.bz2 itools-940735ead52921744e1a8e531001333c8d7e26ea.zip | |
Mark static functions as static to avoid PHP 5.3 strict warnings (performance?)
| -rw-r--r-- | it.class | 50 | ||||
| -rw-r--r-- | it_cache.class | 8 | 
2 files changed, 29 insertions, 29 deletions
| @@ -33,7 +33,7 @@ class it   *      site: Domain name of application (default: from caller path)   *      db: Database of application (default: from caller path)   */ -function createconfig($p = array()) +static function createconfig($p = array())  {  	$stack = debug_backtrace();  	$filename = $stack[0]['file']; @@ -62,7 +62,7 @@ function createconfig($p = array())  /**   * Clone an object and return copy, works for all PHP versions   */ -function &cloneobj(&$object) +static function &cloneobj(&$object)  {  	$result = (is_object($object) && version_compare(zend_version(), 2, '>=')) ? clone($object) : $object; @@ -75,7 +75,7 @@ function &cloneobj(&$object)   * @param $name Name of logfile   * @param $line1 Line to append (varargs)   */ -function log($name /* ... */) +static function log($name /* ... */)  {  	$args = func_get_args();  	$line = date("Y-m-d H:i:s") . "\t" . implode("\t", array_slice($args, 1)) . "\n"; @@ -101,7 +101,7 @@ function log($name /* ... */)  /**   * Store timings for appending to log/timer_log-* in auto_append.php   */ -function timerlog($label = '') +static function timerlog($label = '')  {  	if ($GLOBALS['debug_timerlog'])  	{ @@ -127,7 +127,7 @@ function timerlog($label = '')   * @param $p['blockmailid'] block mail for $p['blockmail'] seconds with same id. Default: $p['to']   * @param $p['omitdebuginfo'] Do not add stack dump, locals and environment to output [false]   */ -function error($p = array(), $body = null, $to = null) # $body and $to deprecated +static function error($p = array(), $body = null, $to = null) # $body and $to deprecated  {  	if (!is_array($p))  		$p = array('title' => $p, 'body' => $body, 'to' => $to); @@ -254,7 +254,7 @@ function error($p = array(), $body = null, $to = null) # $body and $to deprecate   * Same as it::error(), plus exit   * @see error()   */ -function fatal($title='', $body='', $to='') +static function fatal($title='', $body='', $to='')  {  	$p = is_array($title) ? $title : array('title' => $title, 'body' => $body, 'to' => $to);  	$p['backtraceskip']++; @@ -266,7 +266,7 @@ function fatal($title='', $body='', $to='')  /**   * Print message to stderr and exit with error code   */ -function bail($message = "Bailed.\n") +static function bail($message = "Bailed.\n")  {  	fputs(STDERR, $message);  	exit(1); @@ -277,7 +277,7 @@ function bail($message = "Bailed.\n")   * Check wether I am on a live server for this service. Honors 'aslive' and 'asdevel' debug vars   * @return true if servertype is 'live'   */ -function is_live() +static function is_live()  {  	return (preg_match("/^live/", $GLOBALS['ULTRASERVERTYPE']) || !$GLOBALS['ULTRASERVERTYPE'] || EDC('aslive')) && !EDC('asdevel');  } @@ -287,7 +287,7 @@ function is_live()   * Check wether I am on a development server for this service. Honors 'aslive' and 'asdevel' debug vars   * @return true if servertype is 'devel'   */ -function is_devel() +static function is_devel()  {  	return (preg_match("/^devel/", $GLOBALS['ULTRASERVERTYPE']) || EDC('asdevel')) && !EDC('aslive');  } @@ -298,7 +298,7 @@ function is_devel()   * @param $text Text to convert   * @return mapped/stripped version of $text contains only chars [0..127]   */ -function toascii($text) +static function toascii($text)  {  	return strtr(strtr($text,  		'ÇéâàåçêëèïîìÅÉôòûùÿøØáíóúñÑÁÂÀãÃÊËÈÍÎÏÓÔõÕÚÛÙýÝ', @@ -317,7 +317,7 @@ function toascii($text)   * @param $p['extended'] add modifier x   * @return converted regex to use with preg   */ -function convertregex($pattern, $p = array()) +static function convertregex($pattern, $p = array())  {  	$pattern = preg_replace('|/|', '\/', $pattern);   	$modifiers = ''; @@ -349,7 +349,7 @@ function convertregex($pattern, $p = array())   * @param $p contains pattern modifiers, @see convertregex()   * @return Matched string or false    */ -function match($pattern, $string, $p = array()) +static function match($pattern, $string, $p = array())  {  	$flags = 0;  	$p += array('locale' => 'de_CH'); @@ -397,7 +397,7 @@ function match($pattern, $string, $p = array())   * @param $string String to change.   * @return New string.   */ -function replace($replacements, $string, $p = array()) +static function replace($replacements, $string, $p = array())  {  	$patterns = array(); @@ -417,7 +417,7 @@ function replace($replacements, $string, $p = array())   * @param $array array to filter   * @param $keys array or comma separated list of keys to keep   */ -function filter_keys($array, $keys) +static function filter_keys($array, $keys)  {  	$result = array();  	$keep = array_flip(is_string($keys) ? explode(",", $keys) : (array)$keys); @@ -438,7 +438,7 @@ function filter_keys($array, $keys)   * @param $values (zero, one or more arrays can be passed)   * @return output of command. shell errors not detectable, see error_log in /www/server/logs   */ -function exec(/* $cmd, $values1 = array(), ... */) +static function exec(/* $cmd, $values1 = array(), ... */)  {  	$args = func_get_args();  	$cmd = array_shift($args); @@ -489,7 +489,7 @@ function exec(/* $cmd, $values1 = array(), ... */)  }  #fails with C locale!!! -function _exec_quotevalue($value) +static function _exec_quotevalue($value)  {  	$result = strval($value); @@ -510,7 +510,7 @@ function _exec_quotevalue($value)   * @param $p['-opts']	Custom command line options to ImageMagick convert   * @return Success of convert as true/false   */ -function imageconvert($p) +static function imageconvert($p)  {  	$result = false;  	$imagetype = @exif_imagetype($p['in']); @@ -553,7 +553,7 @@ function imageconvert($p)   * @param $helplines Usage parsed to determine options   * @return Associative array of options   */ -function getopt($helplines) +static function getopt($helplines)  {  	$GLOBALS['it_stdin'] = array(  		'fd' => null, @@ -652,7 +652,7 @@ function getopt($helplines)  	return $result;  } -function _stdin_next() +static function _stdin_next()  {  	if ($result = $GLOBALS['it_stdin']['args'])  	{ @@ -669,7 +669,7 @@ function _stdin_next()   * Note: You need to call getopt() before using this function.   * @return Line (including newline) or false on eof   */ -function gets() +static function gets()  {  	do {  		$result = fgets($GLOBALS['it_stdin']['fd']); @@ -687,7 +687,7 @@ function gets()   * @param stamp optional unix timestamp (default is now).   *        If it contains nondigits, it is fed to strtotime   */ -function date($format = "", $stamp = null) +static function date($format = "", $stamp = null)  {  	list($name, $language) = explode(":", $format); @@ -717,7 +717,7 @@ function date($format = "", $stamp = null)   * @param $expression The expression to apply, may contain $k for keys and $v for values   * @param $array The array to iterate over   */ -function map($expression, $array) +static function map($expression, $array)  {  	static $cache = array(); @@ -734,7 +734,7 @@ function map($expression, $array)   * Send a mail. Expects array for Header => Content pairs with Body => for the mail body.   * @return nothing useful   */ -function mail($p) +static function mail($p)  {  	$body = $p['Body'];  	unset($p['Body']); @@ -750,7 +750,7 @@ function mail($p)   * @param $p['keyval'] each line of the file is one tab-separated key/value pair, return assoc array   * @param $p['lines'] return file as array of lines without newline   */ -function file_get($filename, $p = array()) +static function file_get($filename, $p = array())  {  	$data = file_get_contents($filename == "-" ? "php://stdin" : $filename);  	if ($p['keyval']) @@ -776,7 +776,7 @@ function file_get($filename, $p = array())   * @param $p['keyval'] $data must be an assoc array and is written as tab-separated lines   * @param $p['lines'] write array of lines, appending newline   */ -function file_put($filename, $data, $p = array()) +static function file_put($filename, $data, $p = array())  {  	if ($p['keyval'])  		$data = join("", it::map('"$k\t$v\n"', $data)); diff --git a/it_cache.class b/it_cache.class index d6d3029..bcd9bd3 100644 --- a/it_cache.class +++ b/it_cache.class @@ -24,7 +24,7 @@  class it_cache  { -function _defaults($p) +static function _defaults($p)  {  	$p += array(  		'ttl' => 2, @@ -43,7 +43,7 @@ function _defaults($p)   * @param $key Key to get value for   * @return Value for given key or null   */ -function get($key, $p = array()) +static function get($key, $p = array())  {  	$p = it_cache::_defaults($p); @@ -64,7 +64,7 @@ function get($key, $p = array())   * @param $p['ttl'] Time to live for this key/value-pair   * @return Boolean if value was put into cache   */ -function put($key, $value, $p = array()) +static function put($key, $value, $p = array())  {  	$p = it_cache::_defaults($p); @@ -83,7 +83,7 @@ function put($key, $value, $p = array())  	return $result;  } -function _get_memcache($p) +static function _get_memcache($p)  {  	$memcache_id = "it_cache_memcache_" . $p['hostsfile']; |