Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9072ba8

Browse filesBrowse files
committed
Merge branch '3.4' into 4.3
* 3.4: [Twig] Remove dead code Add gitignore file for Symfony 3.4 [Inflector] Add .gitignore file [Security] Removed unused argument in Test [Console] Get dimensions from stty on windows if possible [Inflector] add support 'see' to 'ee' for singularize 'fees' to 'fee'
2 parents fa7d74a + d9ce895 commit 9072ba8
Copy full SHA for 9072ba8

File tree

14 files changed

+103
-76
lines changed
Filter options

14 files changed

+103
-76
lines changed

‎src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ public function testCompile($source, $expected)
3434
$stream = $env->tokenize($source);
3535
$parser = new Parser($env);
3636

37-
if (method_exists($expected, 'setSourceContext')) {
38-
$expected->setSourceContext($source);
39-
}
37+
$expected->setSourceContext($source);
4038

4139
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
4240
}

‎src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,10 @@ public function testExtractSyntaxError($resources)
112112
try {
113113
$extractor->extract($resources, new MessageCatalogue('en'));
114114
} catch (Error $e) {
115-
if (method_exists($e, 'getSourceContext')) {
116-
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
117-
$this->assertSame(1, $e->getLine());
118-
$this->assertSame('Unclosed "block".', $e->getMessage());
119-
} else {
120-
$this->expectExceptionMessageRegExp('/Unclosed "block" in ".*extractor(\\/|\\\\)syntax_error\\.twig" at line 1/');
121-
}
115+
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
116+
$this->assertSame(1, $e->getLine());
117+
$this->assertSame('Unclosed "block".', $e->getMessage());
118+
122119
throw $e;
123120
}
124121
}

‎src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ public function extract($resource, MessageCatalogue $catalogue)
6161
if ($file instanceof \SplFileInfo) {
6262
$path = $file->getRealPath() ?: $file->getPathname();
6363
$name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path;
64-
if (method_exists($e, 'setSourceContext')) {
65-
$e->setSourceContext(new Source('', $name, $path));
66-
} else {
67-
$e->setTemplateName($name);
68-
}
64+
$e->setSourceContext(new Source('', $name, $path));
6965
}
7066

7167
throw $e;

‎src/Symfony/Bundle/TwigBundle/TwigEngine.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/TwigEngine.php
-23Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use Symfony\Bridge\Twig\TwigEngine as BaseEngine;
1717
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
18-
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
1918
use Symfony\Component\Config\FileLocatorInterface;
2019
use Symfony\Component\HttpFoundation\Response;
2120
use Symfony\Component\Templating\TemplateNameParserInterface;
@@ -40,28 +39,6 @@ public function __construct(Environment $environment, TemplateNameParserInterfac
4039
$this->locator = $locator;
4140
}
4241

43-
/**
44-
* {@inheritdoc}
45-
*/
46-
public function render($name, array $parameters = [])
47-
{
48-
try {
49-
return parent::render($name, $parameters);
50-
} catch (Error $e) {
51-
if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) {
52-
try {
53-
// try to get the real name of the template where the error occurred
54-
$name = $e->getTemplateName();
55-
$path = (string) $this->locator->locate($this->parser->parse($name));
56-
$e->setTemplateName($path);
57-
} catch (\Exception $e2) {
58-
}
59-
}
60-
61-
throw $e;
62-
}
63-
}
64-
6542
/**
6643
* {@inheritdoc}
6744
*

‎src/Symfony/Component/Console/Helper/QuestionHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/QuestionHelper.php
+3-16Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Console\Output\OutputInterface;
2222
use Symfony\Component\Console\Question\ChoiceQuestion;
2323
use Symfony\Component\Console\Question\Question;
24+
use Symfony\Component\Console\Terminal;
2425

2526
/**
2627
* The QuestionHelper class provides helpers to interact with the user.
@@ -117,7 +118,7 @@ private function doAsk(OutputInterface $output, Question $question)
117118
$inputStream = $this->inputStream ?: STDIN;
118119
$autocomplete = $question->getAutocompleterCallback();
119120

120-
if (null === $autocomplete || !$this->hasSttyAvailable()) {
121+
if (null === $autocomplete || !Terminal::hasSttyAvailable()) {
121122
$ret = false;
122123
if ($question->isHidden()) {
123124
try {
@@ -376,7 +377,7 @@ private function getHiddenResponse(OutputInterface $output, $inputStream): strin
376377
return $value;
377378
}
378379

379-
if ($this->hasSttyAvailable()) {
380+
if (Terminal::hasSttyAvailable()) {
380381
$sttyMode = shell_exec('stty -g');
381382

382383
shell_exec('stty -echo');
@@ -462,18 +463,4 @@ private function getShell()
462463

463464
return self::$shell;
464465
}
465-
466-
/**
467-
* Returns whether Stty is available or not.
468-
*/
469-
private function hasSttyAvailable(): bool
470-
{
471-
if (null !== self::$stty) {
472-
return self::$stty;
473-
}
474-
475-
exec('stty 2>&1', $output, $exitcode);
476-
477-
return self::$stty = 0 === $exitcode;
478-
}
479466
}

‎src/Symfony/Component/Console/Terminal.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Terminal.php
+27-1Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Terminal
1515
{
1616
private static $width;
1717
private static $height;
18+
private static $stty;
1819

1920
/**
2021
* Gets the terminal width.
@@ -54,6 +55,22 @@ public function getHeight()
5455
return self::$height ?: 50;
5556
}
5657

58+
/**
59+
* @internal
60+
*
61+
* @return bool
62+
*/
63+
public static function hasSttyAvailable()
64+
{
65+
if (null !== self::$stty) {
66+
return self::$stty;
67+
}
68+
69+
exec('stty 2>&1', $output, $exitcode);
70+
71+
return self::$stty = 0 === $exitcode;
72+
}
73+
5774
private static function initDimensions()
5875
{
5976
if ('\\' === \DIRECTORY_SEPARATOR) {
@@ -62,12 +79,21 @@ private static function initDimensions()
6279
// or [w, h] from "wxh"
6380
self::$width = (int) $matches[1];
6481
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
82+
} elseif (self::hasSttyAvailable()) {
83+
self::initDimensionsUsingStty();
6584
} elseif (null !== $dimensions = self::getConsoleMode()) {
6685
// extract [w, h] from "wxh"
6786
self::$width = (int) $dimensions[0];
6887
self::$height = (int) $dimensions[1];
6988
}
70-
} elseif ($sttyString = self::getSttyColumns()) {
89+
} else {
90+
self::initDimensionsUsingStty();
91+
}
92+
}
93+
94+
private static function initDimensionsUsingStty()
95+
{
96+
if ($sttyString = self::getSttyColumns()) {
7197
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
7298
// extract [w, h] from "rows h; columns w;"
7399
self::$width = (int) $matches[2];

‎src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
+7-13Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Question\ChoiceQuestion;
2020
use Symfony\Component\Console\Question\ConfirmationQuestion;
2121
use Symfony\Component\Console\Question\Question;
22+
use Symfony\Component\Console\Terminal;
2223

2324
/**
2425
* @group tty
@@ -167,7 +168,7 @@ public function testAsk()
167168

168169
public function testAskWithAutocomplete()
169170
{
170-
if (!$this->hasSttyAvailable()) {
171+
if (!Terminal::hasSttyAvailable()) {
171172
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
172173
}
173174

@@ -243,7 +244,7 @@ function ($word) use ($suggestionBase) {
243244

244245
public function testAskWithAutocompleteWithNonSequentialKeys()
245246
{
246-
if (!$this->hasSttyAvailable()) {
247+
if (!Terminal::hasSttyAvailable()) {
247248
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
248249
}
249250

@@ -262,7 +263,7 @@ public function testAskWithAutocompleteWithNonSequentialKeys()
262263

263264
public function testAskWithAutocompleteWithExactMatch()
264265
{
265-
if (!$this->hasSttyAvailable()) {
266+
if (!Terminal::hasSttyAvailable()) {
266267
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
267268
}
268269

@@ -298,7 +299,7 @@ public function getInputs()
298299
*/
299300
public function testAskWithAutocompleteWithMultiByteCharacter($character)
300301
{
301-
if (!$this->hasSttyAvailable()) {
302+
if (!Terminal::hasSttyAvailable()) {
302303
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
303304
}
304305

@@ -322,7 +323,7 @@ public function testAskWithAutocompleteWithMultiByteCharacter($character)
322323

323324
public function testAutocompleteWithTrailingBackslash()
324325
{
325-
if (!$this->hasSttyAvailable()) {
326+
if (!Terminal::hasSttyAvailable()) {
326327
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
327328
}
328329

@@ -669,7 +670,7 @@ public function testEmptyChoices()
669670

670671
public function testTraversableAutocomplete()
671672
{
672-
if (!$this->hasSttyAvailable()) {
673+
if (!Terminal::hasSttyAvailable()) {
673674
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
674675
}
675676

@@ -754,13 +755,6 @@ protected function createInputInterfaceMock($interactive = true)
754755

755756
return $mock;
756757
}
757-
758-
private function hasSttyAvailable()
759-
{
760-
exec('stty 2>&1', $output, $exitcode);
761-
762-
return 0 === $exitcode;
763-
}
764758
}
765759

766760
class AutocompleteValues implements \IteratorAggregate

‎src/Symfony/Component/Console/Tests/TerminalTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/TerminalTest.php
+38Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,31 @@ class TerminalTest extends TestCase
1818
{
1919
private $colSize;
2020
private $lineSize;
21+
private $ansiCon;
2122

2223
protected function setUp(): void
2324
{
2425
$this->colSize = getenv('COLUMNS');
2526
$this->lineSize = getenv('LINES');
27+
$this->ansiCon = getenv('ANSICON');
28+
$this->resetStatics();
2629
}
2730

2831
protected function tearDown(): void
2932
{
3033
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
3134
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
35+
putenv($this->ansiCon ? 'ANSICON='.$this->ansiCon : 'ANSICON');
36+
$this->resetStatics();
37+
}
38+
39+
private function resetStatics()
40+
{
41+
foreach (['height', 'width', 'stty'] as $name) {
42+
$property = new \ReflectionProperty(Terminal::class, $name);
43+
$property->setAccessible(true);
44+
$property->setValue(null);
45+
}
3246
}
3347

3448
public function test()
@@ -56,4 +70,28 @@ public function test_zero_values()
5670
$this->assertSame(0, $terminal->getWidth());
5771
$this->assertSame(0, $terminal->getHeight());
5872
}
73+
74+
public function testSttyOnWindows()
75+
{
76+
if ('\\' !== \DIRECTORY_SEPARATOR) {
77+
$this->markTestSkipped('Must be on windows');
78+
}
79+
80+
$sttyString = exec('(stty -a | grep columns) 2>&1', $output, $exitcode);
81+
if (0 !== $exitcode) {
82+
$this->markTestSkipped('Must have stty support');
83+
}
84+
85+
$matches = [];
86+
if (0 === preg_match('/columns.(\d+)/i', $sttyString, $matches)) {
87+
$this->fail('Could not determine existing stty columns');
88+
}
89+
90+
putenv('COLUMNS');
91+
putenv('LINES');
92+
putenv('ANSICON');
93+
94+
$terminal = new Terminal();
95+
$this->assertSame((int) $matches[1], $terminal->getWidth());
96+
}
5997
}
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/
2+
composer.lock
3+
phpunit.xml

‎src/Symfony/Component/Inflector/Inflector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Inflector/Inflector.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ final class Inflector
120120
// bureaus (bureau)
121121
['suae', 4, false, true, 'eau'],
122122

123+
// fees (fee), trees (tree), employees (employee)
124+
['see', 3, true, true, 'ee'],
125+
123126
// roses (rose), garages (garage), cassettes (cassette),
124127
// waltzes (waltz), heroes (hero), bushes (bush), arches (arch),
125128
// shoes (shoe)

‎src/Symfony/Component/Inflector/Tests/InflectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Inflector/Tests/InflectorTest.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function singularizeProvider()
3838
['bases', ['bas', 'base', 'basis']],
3939
['batches', ['batch', 'batche']],
4040
['beaux', 'beau'],
41-
['bees', ['be', 'bee']],
41+
['bees', 'bee'],
4242
['boxes', 'box'],
4343
['boys', 'boy'],
4444
['bureaus', 'bureau'],
@@ -68,7 +68,9 @@ public function singularizeProvider()
6868
['echoes', ['echo', 'echoe']],
6969
['elves', ['elf', 'elve', 'elff']],
7070
['emphases', ['emphas', 'emphase', 'emphasis']],
71+
['employees', 'employee'],
7172
['faxes', 'fax'],
73+
['fees', 'fee'],
7274
['feet', 'foot'],
7375
['feedback', 'feedback'],
7476
['foci', 'focus'],
@@ -143,14 +145,14 @@ public function singularizeProvider()
143145
['theses', ['thes', 'these', 'thesis']],
144146
['thieves', ['thief', 'thieve', 'thieff']],
145147
['treasons', 'treason'],
146-
['trees', ['tre', 'tree']],
148+
['trees', 'tree'],
147149
['waltzes', ['waltz', 'waltze']],
148150
['wives', 'wife'],
149151

150152
// test casing: if the first letter was uppercase, it should remain so
151153
['Men', 'Man'],
152154
['GrandChildren', 'GrandChild'],
153-
['SubTrees', ['SubTre', 'SubTree']],
155+
['SubTrees', 'SubTree'],
154156

155157
// Known issues
156158
//['insignia', 'insigne'],
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/
2+
composer.lock
3+
phpunit.xml

‎src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testHandleAuthenticationFailure()
8787
/**
8888
* @dataProvider getTokenClearingTests
8989
*/
90-
public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderKey, $actualProviderKey)
90+
public function testHandleAuthenticationClearsToken($tokenProviderKey, $actualProviderKey)
9191
{
9292
$this->tokenStorage->expects($this->never())
9393
->method('setToken')
@@ -108,10 +108,10 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK
108108
public function getTokenClearingTests()
109109
{
110110
$tests = [];
111-
// correct token class and matching firewall => clear the token
112-
$tests[] = ['Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'the_firewall_key'];
113-
$tests[] = ['Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'different_key'];
114-
$tests[] = ['Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', 'the_firewall_key', 'the_firewall_key'];
111+
// matching firewall => clear the token
112+
$tests[] = ['the_firewall_key', 'the_firewall_key'];
113+
$tests[] = ['the_firewall_key', 'different_key'];
114+
$tests[] = ['the_firewall_key', 'the_firewall_key'];
115115

116116
return $tests;
117117
}
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/
2+
composer.lock
3+
phpunit.xml

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.