Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replase php 7.2 deprecated create_function() to anonimous function() #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src-php/EMT.Lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ public static function remove_html_tags($text, $allowableTag = null)
public static function safe_tag_chars($text, $way)
{
if ($way)
$text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', create_function('$m','return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == \'-\' && substr(trim($m[2]), 1, 1) != \'-\')? $m[0] : $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . EMT_Lib::encrypt_tag(trim($m[2])) . $m[3];'), $text);
$text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', function($m) {return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == '-' && substr(trim($m[2]), 1, 1) != '-')? $m[0] : $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . EMT_Lib::encrypt_tag(trim($m[2])) . $m[3]; }, $text);
else
$text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', create_function('$m','return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == \'-\' && substr(trim($m[2]), 1, 1) != \'-\')? $m[0] : $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? EMT_Lib::decrypt_tag(substr(trim($m[2]), 4)) : EMT_Lib::decrypt_tag(trim($m[2])) ) . $m[3];'), $text);
$text = preg_replace_callback('/(\<\/?)([^<>]+?)(\>)/s', function($m) {return (strlen($m[1])==1 && substr(trim($m[2]), 0, 1) == '-' && substr(trim($m[2]), 1, 1) != '-')? $m[0] : $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? EMT_Lib::decrypt_tag(substr(trim($m[2]), 4)) : EMT_Lib::decrypt_tag(trim($m[2])) ) . $m[3];} , $text);
return $text;
}

Expand All @@ -212,7 +212,7 @@ public static function safe_tag_chars($text, $way)
*/
public static function decode_internal_blocks($text)
{
$text = preg_replace_callback('/'.EMT_Lib::INTERNAL_BLOCK_OPEN.'([a-zA-Z0-9\/=]+?)'.EMT_Lib::INTERNAL_BLOCK_CLOSE.'/s', create_function('$m','return EMT_Lib::decrypt_tag($m[1]);'), $text);
$text = preg_replace_callback('/'.EMT_Lib::INTERNAL_BLOCK_OPEN.'([a-zA-Z0-9\/=]+?)'.EMT_Lib::INTERNAL_BLOCK_CLOSE.'/s', function($m) {return EMT_Lib::decrypt_tag($m[1]);}, $text);
return $text;
}

Expand Down Expand Up @@ -649,13 +649,13 @@ public static function html_char_entity_to_unicode($entity)
public static function convert_html_entities_to_unicode(&$text)
{
$text = preg_replace_callback("/\&#([0-9]+)\;/",
create_function('$m', 'return EMT_Lib::_getUnicodeChar(intval($m[1]));')
function($m) {return EMT_Lib::_getUnicodeChar(intval($m[1])); }
, $text);
$text = preg_replace_callback("/\&#x([0-9A-F]+)\;/",
create_function('$m', 'return EMT_Lib::_getUnicodeChar(hexdec($m[1]));')
function($m) {return EMT_Lib::_getUnicodeChar(hexdec($m[1])); }
, $text);
$text = preg_replace_callback("/\&([a-zA-Z0-9]+)\;/",
create_function('$m', '$r = EMT_Lib::html_char_entity_to_unicode($m[1]); return $r ? $r : $m[0];')
function($m) { $r = EMT_Lib::html_char_entity_to_unicode($m[1]); return $r ? $r : $m[0]; }
, $text);
}

Expand Down
2 changes: 1 addition & 1 deletion src-php/EMT.Tret.Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function build_sub_quotations()
if($__ax)
{
$k = preg_replace_callback("/(^|[^0-9])([0-9]+)\&raquo\;/ui",
create_function('$m','global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."&Prime;";} return $m[0];'),
function($m) {global $__ax,$__ay; $__ay++; if($__ay==$__ax){ return $m[1].$m[2]."&Prime;";} return $m[0];},
$k);
$amount = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src-php/EMT.Tret.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private function apply_rule($rule)
}
$this->error('Функция '.$rule['function'].' из правила '.$rule['id']. " не найдена");
} else {
$this->_text = preg_replace_callback($rule['pattern'], create_function('$m', $rule['function']), $this->_text);
$this->_text = preg_replace_callback($rule['pattern'], function($m) use($rule) { $rule['function']; }, $this->_text);
$this->log('Замена с использованием preg_replace_callback с инлайн функцией из правила '.$rule['id']);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src-php/EMT.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function safe_blocks($text, $way, $show = true)
$safeblocks = true === $way ? $this->_safe_blocks : array_reverse($this->_safe_blocks);
foreach ($safeblocks as $block)
{
$text = preg_replace_callback("/({$block['open']})(.+?)({$block['close']})/s", create_function('$m','return $m[1].'.$safeType . '.$m[3];') , $text);
$text = preg_replace_callback("/({$block['open']})(.+?)({$block['close']})/s", function($m) {return $m[1].'.$safeType . '.$m[3];}, $text);
}
}

Expand Down