Add compatibility to 'Strict standards' in php 5.4.16

This commit is contained in:
Renato Covarrubias 2013-07-13 18:04:38 -04:00
parent b9bc49de45
commit 12f5f70658
3 changed files with 42 additions and 40 deletions

View File

@ -19,10 +19,12 @@ class StringExtractor {
foreach ( $file_names as $file_name ) {
if ( '.' == $file_name || '..' == $file_name ) continue;
if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) {
$translations->merge_originals_with( $this->extract_from_file( $file_name, $prefix ) );
$t = $this->extract_from_file( $file_name, $prefix );
$translations->merge_originals_with( $t );
}
if ( is_dir( $file_name ) ) {
$translations->merge_originals_with( $this->extract_from_directory( $file_name, $excludes, $includes, $prefix . $file_name . '/' ) );
$t = $this->extract_from_directory( $file_name, $excludes, $includes, $prefix . $file_name . '/' );
$translations->merge_originals_with( $t );
}
}
chdir( $old_cwd );

View File

@ -173,33 +173,33 @@ class WC_Makepot {
* @param int $lines (default: 30)
* @return void
*/
public function get_first_lines($filename, $lines = 30) {
$extf = fopen($filename, 'r');
if (!$extf) return false;
$first_lines = '';
foreach(range(1, $lines) as $x) {
$line = fgets($extf);
if (feof($extf)) break;
if (false === $line) {
return false;
}
$first_lines .= $line;
}
return $first_lines;
}
public static function get_first_lines($filename, $lines = 30) {
$extf = fopen($filename, 'r');
if (!$extf) return false;
$first_lines = '';
foreach(range(1, $lines) as $x) {
$line = fgets($extf);
if (feof($extf)) break;
if (false === $line) {
return false;
}
$first_lines .= $line;
}
return $first_lines;
}
/**
* get_addon_header function.
*
* @access public
* @param mixed $header
* @param mixed &$source
* @return void
*/
public function get_addon_header($header, &$source) {
if (preg_match('|'.$header.':(.*)$|mi', $source, $matches))
return trim($matches[1]);
else
return false;
}
}
/**
* get_addon_header function.
*
* @access public
* @param mixed $header
* @param mixed &$source
* @return void
*/
public static function get_addon_header($header, &$source) {
if (preg_match('|'.$header.':(.*)$|mi', $source, $matches))
return trim($matches[1]);
else
return false;
}
}

View File

@ -97,7 +97,7 @@ class PO extends Gettext_Translations {
* @param string $string the string to format
* @return string the poified string
*/
function poify($string) {
public static function poify($string) {
$quote = '"';
$slash = '\\';
$newline = "\n";
@ -128,7 +128,7 @@ class PO extends Gettext_Translations {
* @param string $string PO-formatted string
* @return string enascaped string
*/
function unpoify($string) {
public static function unpoify($string) {
$escapes = array('t' => "\t", 'n' => "\n", '\\' => '\\');
$lines = array_map('trim', explode("\n", $string));
$lines = array_map(array('PO', 'trim_quotes'), $lines);
@ -160,7 +160,7 @@ class PO extends Gettext_Translations {
* @param string $string prepend lines in this string
* @param string $with prepend lines with this string
*/
function prepend_each_line($string, $with) {
public static function prepend_each_line($string, $with) {
$php_with = var_export($with, true);
$lines = explode("\n", $string);
// do not prepend the string on the last empty line, artefact by explode
@ -180,7 +180,7 @@ class PO extends Gettext_Translations {
* @param string $char character to denote a special PO comment,
* like :, default is a space
*/
function comment_block($text, $char=' ') {
public static function comment_block($text, $char=' ') {
$text = wordwrap($text, PO_MAX_LINE_LEN - 3);
return PO::prepend_each_line($text, "#$char ");
}
@ -193,7 +193,7 @@ class PO extends Gettext_Translations {
* @return string|bool PO-style formatted string for the entry or
* false if the entry is empty
*/
function export_entry(&$entry) {
public static function export_entry(&$entry) {
if (is_null($entry->singular)) return false;
$po = array();
if (!empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
@ -343,7 +343,7 @@ class PO extends Gettext_Translations {
return array('entry' => $entry, 'lineno' => $lineno);
}
function read_line($f, $action = 'read') {
public static function read_line($f, $action = 'read') {
static $last_line = '';
static $use_last_line = false;
if ('clear' == $action) {
@ -361,7 +361,7 @@ class PO extends Gettext_Translations {
return $line;
}
function add_comment_to_entry(&$entry, $po_comment_line) {
public static function add_comment_to_entry(&$entry, $po_comment_line) {
$first_two = substr($po_comment_line, 0, 2);
$comment = trim(substr($po_comment_line, 2));
if ('#:' == $first_two) {
@ -375,10 +375,10 @@ class PO extends Gettext_Translations {
}
}
function trim_quotes($s) {
public static function trim_quotes($s) {
if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
return $s;
}
}
endif;
endif;