Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 157fa56

Browse files
committed
Merge branch '1.x' into 2.x
* 1.x: Fix CS Migrate to the new PHP CS Fixer config file
2 parents 7da9b04 + 87c09f6 commit 157fa56

11 files changed

Lines changed: 35 additions & 35 deletions

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
return PhpCsFixer\Config::create()
3+
return (new PhpCsFixer\Config())
44
->setRules([
55
'@Symfony' => true,
66
'@Symfony:risky' => true,
@@ -16,5 +16,5 @@
1616
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'all'],
1717
])
1818
->setRiskyAllowed(true)
19-
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
19+
->setFinder((new PhpCsFixer\Finder())->in(__DIR__))
2020
;

src/Cache/FilesystemCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class FilesystemCache implements CacheInterface
2020
{
21-
const FORCE_BYTECODE_INVALIDATION = 1;
21+
public const FORCE_BYTECODE_INVALIDATION = 1;
2222

2323
private $directory;
2424
private $options;
@@ -67,7 +67,7 @@ public function write($key, $content)
6767

6868
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
6969
// Compile cached file into bytecode cache
70-
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
70+
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) {
7171
@opcache_invalidate($key, true);
7272
} elseif (\function_exists('apc_compile_file')) {
7373
apc_compile_file($key);

src/FileExtensionEscapingStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function guess($name)
4141
$name = substr($name, 0, -5);
4242
}
4343

44-
$extension = pathinfo($name, PATHINFO_EXTENSION);
44+
$extension = pathinfo($name, \PATHINFO_EXTENSION);
4545

4646
switch ($extension) {
4747
case 'js':

src/Node/MacroNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class MacroNode extends Node
2323
{
24-
const VARARGS_NAME = 'varargs';
24+
public const VARARGS_NAME = 'varargs';
2525

2626
public function __construct(string $name, Node $body, Node $arguments, int $lineno, string $tag = null)
2727
{

src/Profiler/Profile.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
class Profile implements \IteratorAggregate, \Serializable
2020
{
21-
const ROOT = 'ROOT';
22-
const BLOCK = 'block';
23-
const TEMPLATE = 'template';
24-
const MACRO = 'macro';
21+
public const ROOT = 'ROOT';
22+
public const BLOCK = 'block';
23+
public const TEMPLATE = 'template';
24+
public const MACRO = 'macro';
2525

2626
private $template;
2727
private $name;

src/Test/IntegrationTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getTests($name, $legacyTests = false)
120120
$deprecation = $match[3];
121121
$templates = self::parseTemplates($match[4]);
122122
$exception = false;
123-
preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
123+
preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, \PREG_SET_ORDER);
124124
} else {
125125
throw new \InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
126126
}
@@ -255,7 +255,7 @@ protected function doIntegrationTest($file, $message, $condition, $templates, $e
255255
protected static function parseTemplates($test)
256256
{
257257
$templates = [];
258-
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
258+
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, \PREG_SET_ORDER);
259259
foreach ($matches as $match) {
260260
$templates[($match[1] ?: 'index.twig')] = $match[2];
261261
}

src/Token.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ final class Token
2323
private $type;
2424
private $lineno;
2525

26-
const EOF_TYPE = -1;
27-
const TEXT_TYPE = 0;
28-
const BLOCK_START_TYPE = 1;
29-
const VAR_START_TYPE = 2;
30-
const BLOCK_END_TYPE = 3;
31-
const VAR_END_TYPE = 4;
32-
const NAME_TYPE = 5;
33-
const NUMBER_TYPE = 6;
34-
const STRING_TYPE = 7;
35-
const OPERATOR_TYPE = 8;
36-
const PUNCTUATION_TYPE = 9;
37-
const INTERPOLATION_START_TYPE = 10;
38-
const INTERPOLATION_END_TYPE = 11;
39-
const ARROW_TYPE = 12;
26+
public const EOF_TYPE = -1;
27+
public const TEXT_TYPE = 0;
28+
public const BLOCK_START_TYPE = 1;
29+
public const VAR_START_TYPE = 2;
30+
public const BLOCK_END_TYPE = 3;
31+
public const VAR_END_TYPE = 4;
32+
public const NAME_TYPE = 5;
33+
public const NUMBER_TYPE = 6;
34+
public const STRING_TYPE = 7;
35+
public const OPERATOR_TYPE = 8;
36+
public const PUNCTUATION_TYPE = 9;
37+
public const INTERPOLATION_START_TYPE = 10;
38+
public const INTERPOLATION_END_TYPE = 11;
39+
public const ARROW_TYPE = 12;
4040

4141
/**
4242
* @param int $type The type of the token

tests/CompilerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ public function testReprNumericValueWithLocale()
2222
{
2323
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
2424

25-
$locale = setlocale(LC_NUMERIC, 0);
25+
$locale = setlocale(\LC_NUMERIC, 0);
2626
if (false === $locale) {
2727
$this->markTestSkipped('Your platform does not support locales.');
2828
}
2929

3030
$required_locales = ['fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'];
31-
if (false === setlocale(LC_NUMERIC, $required_locales)) {
31+
if (false === setlocale(\LC_NUMERIC, $required_locales)) {
3232
$this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales));
3333
}
3434

3535
$this->assertEquals('1.2', $compiler->repr(1.2)->getSource());
36-
$this->assertStringContainsString('fr', strtolower(setlocale(LC_NUMERIC, 0)));
36+
$this->assertStringContainsString('fr', strtolower(setlocale(\LC_NUMERIC, 0)));
3737

38-
setlocale(LC_NUMERIC, $locale);
38+
setlocale(\LC_NUMERIC, $locale);
3939
}
4040
}

tests/ErrorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ public function getErroredTemplates()
285285

286286
public function testTwigLeakOutputInDebugMode()
287287
{
288-
$output = exec(sprintf('%s %s debug', PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
288+
$output = exec(sprintf('%s %s debug', \PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
289289

290290
$this->assertSame('Hello OOPS', $output);
291291
}
292292

293293
public function testDoesNotTwigLeakOutput()
294294
{
295-
$output = exec(sprintf('%s %s', PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
295+
$output = exec(sprintf('%s %s', \PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
296296

297297
$this->assertSame('', $output);
298298
}

tests/Extension/StringLoaderExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Twig\Tests\Extension;
1313

14-
use Twig\Environment;
1514
use PHPUnit\Framework\TestCase;
15+
use Twig\Environment;
1616
use Twig\Extension\StringLoaderExtension;
1717

1818
class StringLoaderExtensionTest extends TestCase
@@ -21,6 +21,6 @@ public function testIncludeWithTemplateStringAndNoSandbox()
2121
{
2222
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
2323
$twig->addExtension(new StringLoaderExtension());
24-
$this->assertSame('something', twig_include($twig, [], twig_template_from_string($twig, "something")));
24+
$this->assertSame('something', twig_include($twig, [], twig_template_from_string($twig, 'something')));
2525
}
2626
}

0 commit comments

Comments
 (0)