Merge branch '4.4' into 5.0

* 4.4:
  [appveyor] bump cache
  [Twig][Mime] Removed extra quotes in missing package exception message
  [DI] µfix
  Allowing empty secrets to be set
  [DI] add missing property declarations in InlineServiceConfigurator
  [DI] fix detecting short service syntax in yaml
  Supress error from fread when reading a unix pipe
  [HttpClient] Fix scoped client without query option configuration
  [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore
  [Workflow] Use a strict comparison when retrieving raw markin in MarkingStore
This commit is contained in:
Nicolas Grekas 2020-04-10 23:22:25 +02:00
commit c978b19e4f
16 changed files with 86 additions and 13 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
// Cache-Id: 2020-01-31 10:00 UTC // Cache-Id: 2020-04-10 20:30 UTC
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n"; echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";

View File

@ -51,7 +51,7 @@ class NotificationEmail extends TemplatedEmail
} }
if ($missingPackages) { if ($missingPackages) {
throw new \LogicException(sprintf('You cannot use "%s" if the "%s" Twig extension%s not available; try running "composer require "%s"".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', implode(' ', array_keys($missingPackages)))); throw new \LogicException(sprintf('You cannot use "%s" if the "%s" Twig extension%s not available; try running "%s".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', 'composer require '.implode(' ', array_keys($missingPackages))));
} }
parent::__construct($headers, $body); parent::__construct($headers, $body);

View File

@ -96,6 +96,11 @@ EOF
$value = strtr(substr(base64_encode(random_bytes($random)), 0, $random), '+/', '-_'); $value = strtr(substr(base64_encode(random_bytes($random)), 0, $random), '+/', '-_');
} elseif (!$file = $input->getArgument('file')) { } elseif (!$file = $input->getArgument('file')) {
$value = $io->askHidden('Please type the secret value'); $value = $io->askHidden('Please type the secret value');
if (null === $value) {
$io->warning('No value provided: using empty string');
$value = '';
}
} elseif ('-' === $file) { } elseif ('-' === $file) {
$value = file_get_contents('php://stdin'); $value = file_get_contents('php://stdin');
} elseif (is_file($file) && is_readable($file)) { } elseif (is_file($file) && is_readable($file)) {
@ -106,12 +111,6 @@ EOF
throw new \InvalidArgumentException(sprintf('File is not readable: "%s".', $file)); throw new \InvalidArgumentException(sprintf('File is not readable: "%s".', $file));
} }
if (null === $value) {
$io->warning('No value provided, aborting.');
return 1;
}
if ($vault->generateKeys()) { if ($vault->generateKeys()) {
$io->success($vault->getLastMessage()); $io->success($vault->getLastMessage());

View File

@ -1345,7 +1345,7 @@ class Configuration implements ConfigurationInterface
->thenInvalid('Either "scope" or "base_uri" should be defined.') ->thenInvalid('Either "scope" or "base_uri" should be defined.')
->end() ->end()
->validate() ->validate()
->ifTrue(function ($v) { return isset($v['query']) && !isset($v['base_uri']); }) ->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
->thenInvalid('"query" applies to "base_uri" but no base URI is defined.') ->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
->end() ->end()
->children() ->children()

View File

@ -0,0 +1,11 @@
<?php
$container->loadFromExtension('framework', [
'http_client' => [
'scoped_clients' => [
'foo' => [
'scope' => '.*',
],
],
],
]);

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:http-client>
<framework:scoped-client
name="foo"
scope=".*"
/>
</framework:http-client>
</framework:config>
</container>

View File

@ -0,0 +1,5 @@
framework:
http_client:
scoped_clients:
foo:
scope: '.*'

View File

@ -1346,6 +1346,14 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass()); $this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
} }
public function testScopedHttpClientWithoutQueryOption()
{
$container = $this->createContainerFromFile('http_client_scoped_without_query_option');
$this->assertTrue($container->hasDefinition('foo'), 'should have the "foo" service.');
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
}
public function testHttpClientOverrideDefaultOptions() public function testHttpClientOverrideDefaultOptions()
{ {
$container = $this->createContainerFromFile('http_client_override_default_options'); $container = $this->createContainerFromFile('http_client_override_default_options');

View File

@ -20,6 +20,7 @@ class AliasConfigurator extends AbstractServiceConfigurator
{ {
const FACTORY = 'alias'; const FACTORY = 'alias';
use Traits\DeprecateTrait;
use Traits\PublicTrait; use Traits\PublicTrait;
public function __construct(ServicesConfigurator $parent, Alias $alias) public function __construct(ServicesConfigurator $parent, Alias $alias)

View File

@ -29,6 +29,10 @@ class InlineServiceConfigurator extends AbstractConfigurator
use Traits\ParentTrait; use Traits\ParentTrait;
use Traits\TagTrait; use Traits\TagTrait;
private $id = '[inline]';
private $allowParent = true;
private $path = null;
public function __construct(Definition $definition) public function __construct(Definition $definition)
{ {
$this->definition = $definition; $this->definition = $definition;

View File

@ -299,7 +299,7 @@ class YamlFileLoader extends FileLoader
private function isUsingShortSyntax(array $service): bool private function isUsingShortSyntax(array $service): bool
{ {
foreach ($service as $key => $value) { foreach ($service as $key => $value) {
if (\is_string($key) && ('' === $key || '$' !== $key[0])) { if (\is_string($key) && ('' === $key || ('$' !== $key[0] && false === strpos($key, '\\')))) {
return false; return false;
} }
} }
@ -345,7 +345,7 @@ class YamlFileLoader extends FileLoader
if (isset($service['alias'])) { if (isset($service['alias'])) {
$this->container->setAlias($id, $alias = new Alias($service['alias'])); $this->container->setAlias($id, $alias = new Alias($service['alias']));
if (\array_key_exists('public', $service)) { if (isset($service['public'])) {
$alias->setPublic($service['public']); $alias->setPublic($service['public']);
} elseif (isset($defaults['public'])) { } elseif (isset($defaults['public'])) {
$alias->setPublic($defaults['public']); $alias->setPublic($defaults['public']);

View File

@ -0,0 +1,6 @@
services:
foo_bar: [1, 2]
bar_foo:
$a: 'a'
App\Foo: 'foo'

View File

@ -205,6 +205,17 @@ class YamlFileLoaderTest extends TestCase
$this->assertEquals(['decorated', 'decorated.pif-pouf', 5, ContainerInterface::IGNORE_ON_INVALID_REFERENCE], $services['decorator_service_with_name_and_priority_and_on_invalid']->getDecoratedService()); $this->assertEquals(['decorated', 'decorated.pif-pouf', 5, ContainerInterface::IGNORE_ON_INVALID_REFERENCE], $services['decorator_service_with_name_and_priority_and_on_invalid']->getDecoratedService());
} }
public function testLoadShortSyntax()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services_short_syntax.yml');
$services = $container->getDefinitions();
$this->assertSame([1, 2], $services['foo_bar']->getArguments());
$this->assertSame(['$a' => 'a', 'App\Foo' => 'foo'], $services['bar_foo']->getArguments());
}
public function testDeprecatedAliases() public function testDeprecatedAliases()
{ {
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -118,7 +118,7 @@ class UnixPipes extends AbstractPipes
$read[$type = array_search($pipe, $this->pipes, true)] = ''; $read[$type = array_search($pipe, $this->pipes, true)] = '';
do { do {
$data = fread($pipe, self::CHUNK_SIZE); $data = @fread($pipe, self::CHUNK_SIZE);
$read[$type] .= $data; $read[$type] .= $data;
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1]))); } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));

View File

@ -56,7 +56,7 @@ final class MethodMarkingStore implements MarkingStoreInterface
$marking = $subject->{$method}(); $marking = $subject->{$method}();
if (!$marking) { if (null === $marking) {
return new Marking(); return new Marking();
} }

View File

@ -53,6 +53,18 @@ class MethodMarkingStoreTest extends TestCase
$this->assertEquals($marking, $marking2); $this->assertEquals($marking, $marking2);
} }
public function testGetSetMarkingWithSingleStateAndAlmostEmptyPlaceName()
{
$subject = new Subject(0);
$markingStore = new MethodMarkingStore(true);
$marking = $markingStore->getMarking($subject);
$this->assertInstanceOf(Marking::class, $marking);
$this->assertCount(1, $marking->getPlaces());
}
public function testGetMarkingWithValueObject() public function testGetMarkingWithValueObject()
{ {
$subject = new Subject($this->createValueObject('first_place')); $subject = new Subject($this->createValueObject('first_place'));