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 5f328e0

Browse filesBrowse files
committed
Merge branch '3.1'
* 3.1: [Console] SymfonyStyle: Align multi-line/very-long-line blocks [Console][DX] Fixed ambiguous error message when using a duplicate option shortcut Fix js comment in profiler [Ldap] Fixed issue with Entry password attribute containing array of values and made password attribute configurable [Serializer][#18837] adding a test [Cache] Drop counting hit/miss in ProxyAdapter [Serializer] AbstractObjectNormalizer: be sure that isAllowedAttribute is called [Serializer] ObjectNormalizer: add missing parameters
2 parents 93139f6 + c968257 commit 5f328e0
Copy full SHA for 5f328e0

File tree

17 files changed

+325
-70
lines changed
Filter options

17 files changed

+325
-70
lines changed

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function create(ContainerBuilder $container, $id, $config)
3535
->replaceArgument(4, $config['default_roles'])
3636
->replaceArgument(5, $config['uid_key'])
3737
->replaceArgument(6, $config['filter'])
38+
->replaceArgument(7, $config['password_attribute'])
3839
;
3940
}
4041

@@ -58,6 +59,7 @@ public function addConfiguration(NodeDefinition $node)
5859
->end()
5960
->scalarNode('uid_key')->defaultValue('sAMAccountName')->end()
6061
->scalarNode('filter')->defaultValue('({uid_key}={username})')->end()
62+
->scalarNode('password_attribute')->defaultNull()->end()
6163
->end()
6264
;
6365
}

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
requestStack = [],
8484
8585
extractHeaders = function(xhr, stackElement) {
86-
// Here we avoid to call xhr.getResponseHeader in order to
87-
// prevent polluting the console with CORS security errors
86+
/* Here we avoid to call xhr.getResponseHeader in order to */
87+
/* prevent polluting the console with CORS security errors */
8888
var allHeaders = xhr.getAllResponseHeaders();
8989
var ret;
9090

‎src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
+2-34Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class ProxyAdapter implements AdapterInterface
2424
private $namespace;
2525
private $namespaceLen;
2626
private $createCacheItem;
27-
private $hits = 0;
28-
private $misses = 0;
2927

3028
public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defaultLifetime = 0)
3129
{
@@ -54,13 +52,8 @@ public function getItem($key)
5452
{
5553
$f = $this->createCacheItem;
5654
$item = $this->pool->getItem($this->getId($key));
57-
if ($isHit = $item->isHit()) {
58-
++$this->hits;
59-
} else {
60-
++$this->misses;
61-
}
6255

63-
return $f($key, $item->get(), $isHit);
56+
return $f($key, $item->get(), $item->isHit());
6457
}
6558

6659
/**
@@ -158,39 +151,14 @@ private function generateItems($items)
158151
$f = $this->createCacheItem;
159152

160153
foreach ($items as $key => $item) {
161-
if ($isHit = $item->isHit()) {
162-
++$this->hits;
163-
} else {
164-
++$this->misses;
165-
}
166154
if ($this->namespaceLen) {
167155
$key = substr($key, $this->namespaceLen);
168156
}
169157

170-
yield $key => $f($key, $item->get(), $isHit);
158+
yield $key => $f($key, $item->get(), $item->isHit());
171159
}
172160
}
173161

174-
/**
175-
* Returns the number of cache read hits.
176-
*
177-
* @return int
178-
*/
179-
public function getHits()
180-
{
181-
return $this->hits;
182-
}
183-
184-
/**
185-
* Returns the number of cache read misses.
186-
*
187-
* @return int
188-
*/
189-
public function getMisses()
190-
{
191-
return $this->misses;
192-
}
193-
194162
private function getId($key)
195163
{
196164
CacheItem::validateKey($key);

‎src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php
-17Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,4 @@ public function createCachePool()
2929
{
3030
return new ProxyAdapter(new ArrayAdapter());
3131
}
32-
33-
public function testGetHitsMisses()
34-
{
35-
$pool = $this->createCachePool();
36-
37-
$this->assertSame(0, $pool->getHits());
38-
$this->assertSame(0, $pool->getMisses());
39-
40-
$bar = $pool->getItem('bar');
41-
$this->assertSame(0, $pool->getHits());
42-
$this->assertSame(1, $pool->getMisses());
43-
44-
$pool->save($bar->set('baz'));
45-
$bar = $pool->getItem('bar');
46-
$this->assertSame(1, $pool->getHits());
47-
$this->assertSame(1, $pool->getMisses());
48-
}
4932
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Command/Command.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ public function mergeApplicationDefinition($mergeArgs = true)
300300
return;
301301
}
302302

303+
$this->definition->addOptions($this->application->getDefinition()->getOptions());
304+
303305
if ($mergeArgs) {
304306
$currentArguments = $this->definition->getArguments();
305307
$this->definition->setArguments($this->application->getDefinition()->getArguments());
306308
$this->definition->addArguments($currentArguments);
307309
}
308310

309-
$this->definition->addOptions($this->application->getDefinition()->getOptions());
310-
311311
$this->applicationDefinitionMerged = true;
312312
if ($mergeArgs) {
313313
$this->applicationDefinitionMergedWithArgs = true;

‎src/Symfony/Component/Console/Style/SymfonyStyle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Style/SymfonyStyle.php
+16-3Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,36 @@ public function block($messages, $type = null, $style = null, $prefix = ' ', $pa
6868
{
6969
$this->autoPrependBlock();
7070
$messages = is_array($messages) ? array_values($messages) : array($messages);
71+
$indentLength = 0;
7172
$lines = array();
7273

73-
// add type
7474
if (null !== $type) {
75-
$messages[0] = sprintf('[%s] %s', $type, $messages[0]);
75+
$typePrefix = sprintf('[%s] ', $type);
76+
$indentLength = strlen($typePrefix);
77+
$lineIndentation = str_repeat(' ', $indentLength);
7678
}
7779

7880
// wrap and add newlines for each element
7981
foreach ($messages as $key => $message) {
8082
$message = OutputFormatter::escape($message);
81-
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix), PHP_EOL, true)));
83+
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix) - $indentLength, PHP_EOL, true)));
84+
85+
// prefix each line with a number of spaces equivalent to the type length
86+
if (null !== $type) {
87+
foreach ($lines as &$line) {
88+
$line = $lineIndentation === substr($line, 0, $indentLength) ? $line : $lineIndentation.$line;
89+
}
90+
}
8291

8392
if (count($messages) > 1 && $key < count($messages) - 1) {
8493
$lines[] = '';
8594
}
8695
}
8796

97+
if (null !== $type) {
98+
$lines[0] = substr_replace($lines[0], $typePrefix, 0, $indentLength);
99+
}
100+
88101
if ($padding && $this->isDecorated()) {
89102
array_unshift($lines, '');
90103
$lines[] = '';

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/ApplicationTest.php
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,33 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero()
733733
$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0');
734734
}
735735

736+
/**
737+
* @expectedException \LogicException
738+
* @expectedExceptionMessage An option with shortcut "e" already exists.
739+
*/
740+
public function testAddingOptionWithDuplicateShortcut()
741+
{
742+
$dispatcher = new EventDispatcher();
743+
$application = new Application();
744+
$application->setAutoExit(false);
745+
$application->setCatchExceptions(false);
746+
$application->setDispatcher($dispatcher);
747+
748+
$application->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'Environment'));
749+
750+
$application
751+
->register('foo')
752+
->setAliases(['f'])
753+
->setDefinition(array(new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')))
754+
->setCode(function (InputInterface $input, OutputInterface $output) {})
755+
;
756+
757+
$input = new ArrayInput(array('command' => 'foo'));
758+
$output = new NullOutput();
759+
760+
$application->run($input, $output);
761+
}
762+
736763
/**
737764
* @expectedException \LogicException
738765
* @dataProvider getAddingAlreadySetDefinitionElementData
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Input\InputInterface;
4+
use Symfony\Component\Console\Output\OutputInterface;
5+
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
6+
7+
//Ensure that all lines are aligned to the begin of the first line in a very long line block
8+
return function (InputInterface $input, OutputInterface $output) {
9+
$output = new SymfonyStyleWithForcedLineLength($input, $output);
10+
$output->block(
11+
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
12+
'CUSTOM',
13+
'fg=white;bg=green',
14+
'X ',
15+
true
16+
);
17+
};
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Input\InputInterface;
4+
use Symfony\Component\Console\Output\OutputInterface;
5+
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
6+
7+
//Ensure that all lines are aligned to the begin of the first line in a multi-line block
8+
return function (InputInterface $input, OutputInterface $output) {
9+
$output = new SymfonyStyleWithForcedLineLength($input, $output);
10+
$output->block(['Custom block', 'Second custom block line'], 'CUSTOM', 'fg=white;bg=green', 'X ', true);
11+
};
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
X [CUSTOM] Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
3+
X dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
4+
X commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
5+
X nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
6+
X anim id est laborum
7+
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
X [CUSTOM] Custom block
3+
X
4+
X Second custom block line
5+

‎src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function inputCommandToOutputFilesProvider()
5757

5858
public function testLongWordsBlockWrapping()
5959
{
60-
$word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon';
60+
$word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygovgollhjvhvljfezefeqifzeiqgiqzhrsdgihqzridghqridghqirshdghdghieridgheirhsdgehrsdvhqrsidhqshdgihrsidvqhneriqsdvjzergetsrfhgrstsfhsetsfhesrhdgtesfhbzrtfbrztvetbsdfbrsdfbrn';
6161
$wordLength = strlen($word);
6262
$maxLineLength = SymfonyStyle::MAX_LINE_LENGTH - 3;
6363

0 commit comments

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