mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 00:12:29 +02:00
add few create_function cases
This commit is contained in:
parent
da9e036b85
commit
c31dcb18a0
@ -16,6 +16,7 @@ final class CreateFunctionToAnonymousFunctionRectorTest extends AbstractRectorTe
|
||||
__DIR__ . '/Fixture/stackoverflow.php.inc',
|
||||
__DIR__ . '/Fixture/drupal.php.inc',
|
||||
__DIR__ . '/Fixture/php_net.php.inc',
|
||||
__DIR__ . '/Fixture/wordpress.php.inc',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector\Fixture;
|
||||
|
||||
class Wordpress
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$replace = create_function('$t', 'return $t || "0" === $t;');
|
||||
|
||||
$php_with = 'abc';
|
||||
$function = create_function('$x', "return \$php_with.\$x;");
|
||||
|
||||
$this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
|
||||
|
||||
$this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector\Fixture;
|
||||
|
||||
class Wordpress
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$replace = function ($t) {
|
||||
return $t || "0" === $t;
|
||||
};
|
||||
|
||||
$php_with = 'abc';
|
||||
$function = function ($x) use ($php_with) {
|
||||
return $php_with . $x;
|
||||
};
|
||||
|
||||
$this->map_attrs_func = function ($k, $v) {
|
||||
return "{$k}=\"{$v}\"";
|
||||
};
|
||||
|
||||
$this->map_xmlns_func = function ($p, $n) use ($xd) {
|
||||
$xd = "xmlns";
|
||||
if (strlen($n[0]) > 0) {
|
||||
$xd .= ":{$n[0]}";
|
||||
}
|
||||
return "{$xd}=\"{$n[1]}\"";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user