mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-13 12:33:52 +01:00
a0f2ad9789
[Privatization] Skip ChangeGlobalVariablesToPropertiesRector on read only global variable (#442)
43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
namespace RectorPrefix20210716\Symfony\Component\DependencyInjection;
|
|
|
|
use RectorPrefix20210716\Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
|
use RectorPrefix20210716\Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
|
/**
|
|
* Define some ExpressionLanguage functions.
|
|
*
|
|
* To get a service, use service('request').
|
|
* To get a parameter, use parameter('kernel.debug').
|
|
*
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
|
*/
|
|
class ExpressionLanguageProvider implements \RectorPrefix20210716\Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface
|
|
{
|
|
private $serviceCompiler;
|
|
public function __construct(callable $serviceCompiler = null)
|
|
{
|
|
$this->serviceCompiler = $serviceCompiler;
|
|
}
|
|
public function getFunctions()
|
|
{
|
|
return [new \RectorPrefix20210716\Symfony\Component\ExpressionLanguage\ExpressionFunction('service', $this->serviceCompiler ?: function ($arg) {
|
|
return \sprintf('$this->get(%s)', $arg);
|
|
}, function (array $variables, $value) {
|
|
return $variables['container']->get($value);
|
|
}), new \RectorPrefix20210716\Symfony\Component\ExpressionLanguage\ExpressionFunction('parameter', function ($arg) {
|
|
return \sprintf('$this->getParameter(%s)', $arg);
|
|
}, function (array $variables, $value) {
|
|
return $variables['container']->getParameter($value);
|
|
})];
|
|
}
|
|
}
|