Skip to content

Commit c48eee8

Browse files
Merge branch '3.4' into 4.0
* 3.4: (22 commits) [appveyor] use PHP 7.1 to run composer [HttpKernel] Don't clean legacy containers that are still loaded [VarDumper] Fix HtmlDumper classes match Make the simple auth provider the same as in Symfony 2.7. [PhpUnitBridge] silence wget fix merge [Security] guardAuthenticationProvider::authenticate cannot return null according to interface specification [PhpUnitBridge] Fix #26994 [VarDumper] Remove decoration from actual output in tests [PropertyInfo] Minor cleanup and perf improvement [Bridge/Doctrine] fix count() notice on PHP 7.2 [Security] Skip user checks if not implementing UserInterface [DI] Add check of internal type to ContainerBuilder::getReflectionClass [HttpFoundation] Add HTTP_EARLY_HINTS const [DoctrineBridge] Improve exception message at `IdReader::getIdValue()` Add type hints fixed CS Use new PHP7.2 functions in hasColorSupport [VarDumper] Fix dumping of SplObjectStorage [HttpFoundation] Add functional tests for Response::sendHeaders() ...
2 parents 6d9d329 + e1ca89b commit c48eee8

File tree

50 files changed

+646
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+646
-242
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install:
4545
- copy /Y .composer\* %APPDATA%\Composer\
4646
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
4747
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
48-
- php -dmemory_limit=-1 composer.phar update --no-progress --no-suggest --ansi
48+
- php composer.phar update --no-progress --no-suggest --ansi
4949
- php phpunit install
5050

5151
test_script:

src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ public function getIdValue($object)
9595
}
9696

9797
if (!$this->om->contains($object)) {
98-
throw new RuntimeException(
99-
'Entities passed to the choice field must be managed. Maybe '.
100-
'persist them in the entity manager?'
101-
);
98+
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_class($object)));
10299
}
103100

104101
$this->om->initializeObject($object);

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,34 @@ public function testEntityManagerNullObject()
630630
$this->validator->validate($entity, $constraint);
631631
}
632632

633+
public function testValidateUniquenessOnNullResult()
634+
{
635+
$repository = $this->createRepositoryMock();
636+
$repository
637+
->method('find')
638+
->will($this->returnValue(null))
639+
;
640+
641+
$this->em = $this->createEntityManagerMock($repository);
642+
$this->registry = $this->createRegistryMock($this->em);
643+
$this->validator = $this->createValidator();
644+
$this->validator->initialize($this->context);
645+
646+
$constraint = new UniqueEntity(array(
647+
'message' => 'myMessage',
648+
'fields' => array('name'),
649+
'em' => self::EM_NAME,
650+
));
651+
652+
$entity = new SingleIntIdEntity(1, null);
653+
654+
$this->em->persist($entity);
655+
$this->em->flush();
656+
657+
$this->validator->validate($entity, $constraint);
658+
$this->assertNoViolation();
659+
}
660+
633661
public function testValidateInheritanceUniqueness()
634662
{
635663
$constraint = new UniqueEntity(array(

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,23 @@ public function validate($entity, Constraint $constraint)
148148
*/
149149
if ($result instanceof \Iterator) {
150150
$result->rewind();
151-
} elseif (is_array($result)) {
151+
if ($result instanceof \Countable && 1 < \count($result)) {
152+
$result = array($result->current(), $result->current());
153+
} else {
154+
$result = $result->current();
155+
$result = null === $result ? array() : array($result);
156+
}
157+
} elseif (\is_array($result)) {
152158
reset($result);
159+
} else {
160+
$result = null === $result ? array() : array($result);
153161
}
154162

155163
/* If no entity matched the query criteria or a single entity matched,
156164
* which is the same as the entity being validated, the criteria is
157165
* unique.
158166
*/
159-
if (0 === count($result) || (1 === count($result) && $entity === ($result instanceof \Iterator ? $result->current() : current($result)))) {
167+
if (!$result || (1 === \count($result) && current($result) === $entity)) {
160168
return;
161169
}
162170

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

+26-5
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,38 @@ public static function collectDeprecations($outputFile)
297297
});
298298
}
299299

300+
/**
301+
* Returns true if STDOUT is defined and supports colorization.
302+
*
303+
* Reference: Composer\XdebugHandler\Process::supportsColor
304+
* https://github.com/composer/xdebug-handler
305+
*
306+
* @return bool
307+
*/
300308
private static function hasColorSupport()
301309
{
302-
if ('\\' === DIRECTORY_SEPARATOR) {
303-
return
304-
defined('STDOUT') && function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT)
305-
|| '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
310+
if (!defined('STDOUT')) {
311+
return false;
312+
}
313+
314+
if (DIRECTORY_SEPARATOR === '\\') {
315+
return (function_exists('sapi_windows_vt100_support')
316+
&& sapi_windows_vt100_support(STDOUT))
306317
|| false !== getenv('ANSICON')
307318
|| 'ON' === getenv('ConEmuANSI')
308319
|| 'xterm' === getenv('TERM');
309320
}
310321

311-
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);
322+
if (function_exists('stream_isatty')) {
323+
return stream_isatty(STDOUT);
324+
}
325+
326+
if (function_exists('posix_isatty')) {
327+
return posix_isatty(STDOUT);
328+
}
329+
330+
$stat = fstat(STDOUT);
331+
// Check if formatted mode is S_IFCHR
332+
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
312333
}
313334
}

src/Symfony/Bridge/PhpUnit/Legacy/Command.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
*
1717
* @internal
1818
*/
19-
class Command extends \PHPUnit_TextUI_Command
19+
class CommandForV5 extends \PHPUnit_TextUI_Command
2020
{
2121
/**
2222
* {@inheritdoc}
2323
*/
2424
protected function createRunner()
2525
{
26-
return new TestRunner($this->arguments['loader']);
26+
return new TestRunnerForV5($this->arguments['loader']);
2727
}
2828
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\TextUI\Command as BaseCommand;
15+
use PHPUnit\TextUI\TestRunner as BaseRunner;
16+
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
17+
18+
/**
19+
* {@inheritdoc}
20+
*
21+
* @internal
22+
*/
23+
class CommandForV6 extends BaseCommand
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
protected function createRunner(): BaseRunner
29+
{
30+
return new TestRunner($this->arguments['loader']);
31+
}
32+
}

src/Symfony/Bridge/PhpUnit/Legacy/TestRunner.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @internal
1818
*/
19-
class TestRunner extends \PHPUnit_TextUI_TestRunner
19+
class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
2020
{
2121
/**
2222
* {@inheritdoc}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\TextUI\TestRunner as BaseRunner;
15+
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
16+
17+
/**
18+
* {@inheritdoc}
19+
*
20+
* @internal
21+
*/
22+
class TestRunnerForV6 extends BaseRunner
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
protected function handleConfiguration(array &$arguments): void
28+
{
29+
$listener = new SymfonyTestsListener();
30+
31+
parent::handleConfiguration($arguments);
32+
33+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
34+
35+
$registeredLocally = false;
36+
37+
foreach ($arguments['listeners'] as $registeredListener) {
38+
if ($registeredListener instanceof SymfonyTestsListener) {
39+
$registeredListener->globalListenerDisabled();
40+
$registeredLocally = true;
41+
break;
42+
}
43+
}
44+
45+
if (!$registeredLocally) {
46+
$arguments['listeners'][] = $listener;
47+
}
48+
}
49+
}

src/Symfony/Bridge/PhpUnit/TextUI/Command.php

+6-16
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\TextUI;
1313

14-
use PHPUnit\TextUI\Command as BaseCommand;
15-
1614
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
17-
class_alias('Symfony\Bridge\PhpUnit\Legacy\Command', 'Symfony\Bridge\PhpUnit\TextUI\Command');
15+
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command');
1816
} else {
19-
/**
20-
* {@inheritdoc}
21-
*
22-
* @internal
23-
*/
24-
class Command extends BaseCommand
17+
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
18+
}
19+
20+
if (false) {
21+
class Command
2522
{
26-
/**
27-
* {@inheritdoc}
28-
*/
29-
protected function createRunner()
30-
{
31-
return new TestRunner($this->arguments['loader']);
32-
}
3323
}
3424
}

src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php

+6-37
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,14 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\TextUI;
1313

14-
use PHPUnit\TextUI\TestRunner as BaseRunner;
15-
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
16-
1714
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
18-
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunner', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
15+
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV5', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
1916
} else {
20-
/**
21-
* {@inheritdoc}
22-
*
23-
* @internal
24-
*/
25-
class TestRunner extends BaseRunner
26-
{
27-
/**
28-
* {@inheritdoc}
29-
*/
30-
protected function handleConfiguration(array &$arguments)
31-
{
32-
$listener = new SymfonyTestsListener();
33-
34-
$result = parent::handleConfiguration($arguments);
35-
36-
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
37-
38-
$registeredLocally = false;
39-
40-
foreach ($arguments['listeners'] as $registeredListener) {
41-
if ($registeredListener instanceof SymfonyTestsListener) {
42-
$registeredListener->globalListenerDisabled();
43-
$registeredLocally = true;
44-
break;
45-
}
46-
}
47-
48-
if (!$registeredLocally) {
49-
$arguments['listeners'][] = $listener;
50-
}
17+
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
18+
}
5119

52-
return $result;
53-
}
20+
if (false) {
21+
class TestRunner
22+
{
5423
}
5524
}

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
7272
stream_copy_to_stream($remoteZipStream, fopen("$PHPUNIT_VERSION.zip", 'wb'));
7373
} else {
7474
@unlink("$PHPUNIT_VERSION.zip");
75-
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
75+
passthru("wget -q https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
7676
}
7777
if (!class_exists('ZipArchive')) {
7878
throw new \Exception('simple-phpunit requires the "zip" PHP extension to be installed and enabled in order to uncompress the downloaded PHPUnit packages.');

src/Symfony/Component/Console/Output/StreamOutput.php

+18-15
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,34 @@ protected function doWrite($message, $newline)
8383
*
8484
* Colorization is disabled if not supported by the stream:
8585
*
86-
* - the stream is redirected (eg php file.php >log)
87-
* - Windows without VT100 support, Ansicon, ConEmu, Mintty
88-
* - non tty consoles
86+
* This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo
87+
* terminals via named pipes, so we can only check the environment.
88+
*
89+
* Reference: Composer\XdebugHandler\Process::supportsColor
90+
* https://github.com/composer/xdebug-handler
8991
*
9092
* @return bool true if the stream supports colorization, false otherwise
9193
*/
9294
protected function hasColorSupport()
9395
{
94-
if (function_exists('stream_isatty') && !@stream_isatty($this->stream)) {
95-
return false;
96-
}
9796
if (DIRECTORY_SEPARATOR === '\\') {
98-
if (function_exists('sapi_windows_vt100_support')) {
99-
$vt100Enabled = @sapi_windows_vt100_support($this->stream);
100-
} else {
101-
$vt100Enabled = '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
102-
}
103-
104-
return
105-
$vt100Enabled
97+
return (function_exists('sapi_windows_vt100_support')
98+
&& @sapi_windows_vt100_support($this->stream))
10699
|| false !== getenv('ANSICON')
107100
|| 'ON' === getenv('ConEmuANSI')
108101
|| 'xterm' === getenv('TERM');
109102
}
110103

111-
return function_exists('posix_isatty') && @posix_isatty($this->stream);
104+
if (function_exists('stream_isatty')) {
105+
return @stream_isatty($this->stream);
106+
}
107+
108+
if (function_exists('posix_isatty')) {
109+
return @posix_isatty($this->stream);
110+
}
111+
112+
$stat = @fstat($this->stream);
113+
// Check if formatted mode is S_IFCHR
114+
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
112115
}
113116
}

0 commit comments

Comments
 (0)