Merge branch '5.1' into 5.2
* 5.1: fix code style Remove full head content in HTML to text converter apply the sort callback on the whole search result
This commit is contained in:
commit
900cb0eece
@ -74,6 +74,6 @@ final class BodyRenderer implements BodyRendererInterface
|
||||
return $this->converter->convert($html);
|
||||
}
|
||||
|
||||
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}i', '', $html));
|
||||
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}is', '', $html));
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,23 @@ class BodyRendererTest extends TestCase
|
||||
$this->assertEquals(str_replace('=', '=3D', $html), $body->getParts()[1]->bodyToString());
|
||||
}
|
||||
|
||||
public function testRenderMultiLineHtmlOnly()
|
||||
{
|
||||
$html = <<<HTML
|
||||
<head>
|
||||
<style type="text/css">
|
||||
css
|
||||
</style>
|
||||
</head>
|
||||
<b>HTML</b>
|
||||
HTML;
|
||||
$email = $this->prepareEmail(null, $html);
|
||||
$body = $email->getBody();
|
||||
$this->assertInstanceOf(AlternativePart::class, $body);
|
||||
$this->assertEquals('HTML', str_replace(["\r", "\n"], '', $body->getParts()[0]->bodyToString()));
|
||||
$this->assertEquals(str_replace(['=', "\n"], ['=3D', "\r\n"], $html), $body->getParts()[1]->bodyToString());
|
||||
}
|
||||
|
||||
public function testRenderHtmlOnlyWithTextSet()
|
||||
{
|
||||
$email = $this->prepareEmail(null, '<b>HTML</b>');
|
||||
|
@ -51,7 +51,7 @@ $container->loadFromExtension('framework', [
|
||||
'fallback' => 'fr',
|
||||
'paths' => ['%kernel.project_dir%/Fixtures/translations'],
|
||||
'cache_dir' => '%kernel.cache_dir%/translations',
|
||||
'enabled_locales' => ['fr', 'en']
|
||||
'enabled_locales' => ['fr', 'en'],
|
||||
],
|
||||
'validation' => [
|
||||
'enabled' => true,
|
||||
|
@ -15,7 +15,6 @@ use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Version;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\PdoAdapter;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
@ -23,7 +23,7 @@ class DummyOutput extends BufferedOutput
|
||||
public function getLogs(): array
|
||||
{
|
||||
$logs = [];
|
||||
foreach (explode(PHP_EOL, trim($this->fetch())) as $message) {
|
||||
foreach (explode(\PHP_EOL, trim($this->fetch())) as $message) {
|
||||
preg_match('/^\[(.*)\] (.*)/', $message, $matches);
|
||||
$logs[] = sprintf('%s %s', $matches[1], $matches[2]);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use Symfony\Component\DependencyInjection\Argument\ServiceLocator;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
@ -611,7 +611,13 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
}
|
||||
|
||||
if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||
return $this->searchInDirectory($this->dirs[0]);
|
||||
$iterator = $this->searchInDirectory($this->dirs[0]);
|
||||
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
$iterator = new \AppendIterator();
|
||||
@ -623,6 +629,10 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
$iterator->append($it);
|
||||
}
|
||||
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
$iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
@ -767,11 +777,6 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
|
||||
}
|
||||
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting);
|
||||
$iterator = $iteratorAggregate->getIterator();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
|
@ -832,6 +832,39 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
]), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testSortAcrossDirectories()
|
||||
{
|
||||
$finder = $this->buildFinder()
|
||||
->in([
|
||||
self::$tmpDir,
|
||||
self::$tmpDir.'/qux',
|
||||
self::$tmpDir.'/foo',
|
||||
])
|
||||
->depth(0)
|
||||
->files()
|
||||
->filter(static function (\SplFileInfo $file): bool {
|
||||
return '' !== $file->getExtension();
|
||||
})
|
||||
->sort(static function (\SplFileInfo $a, \SplFileInfo $b): int {
|
||||
return strcmp($a->getExtension(), $b->getExtension()) ?: strcmp($a->getFilename(), $b->getFilename());
|
||||
})
|
||||
;
|
||||
|
||||
$this->assertOrderedIterator($this->toAbsolute([
|
||||
'qux_0_1.php',
|
||||
'qux_1000_1.php',
|
||||
'qux_1002_0.php',
|
||||
'qux_10_2.php',
|
||||
'qux_12_0.php',
|
||||
'qux_2_0.php',
|
||||
'test.php',
|
||||
'qux/baz_100_1.py',
|
||||
'qux/baz_1_2.py',
|
||||
'test.py',
|
||||
'foo/bar.tmp',
|
||||
]), $finder->getIterator());
|
||||
}
|
||||
|
||||
public function testFilter()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
|
@ -31,7 +31,8 @@ abstract class IteratorTestCase extends TestCase
|
||||
|
||||
protected function assertOrderedIterator($expected, \Traversable $iterator)
|
||||
{
|
||||
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
|
||||
$values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', \DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator));
|
||||
$expected = array_map(function ($path) { return str_replace('/', \DIRECTORY_SEPARATOR, $path); }, $expected);
|
||||
|
||||
$this->assertEquals($expected, array_values($values));
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
|
||||
{
|
||||
if (null !== $this->scale && null !== $this->roundingMode) {
|
||||
// shift number to maintain the correct scale during rounding
|
||||
$roundingCoef = pow(10, $this->scale);
|
||||
$roundingCoef = 10 ** $this->scale;
|
||||
|
||||
if (self::FRACTIONAL == $this->type) {
|
||||
$roundingCoef *= 100;
|
||||
|
@ -72,7 +72,7 @@ class JsonResponse extends Response
|
||||
*/
|
||||
public static function create($data = null, int $status = 200, array $headers = [])
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
|
||||
return new static($data, $status, $headers);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class RedirectResponse extends Response
|
||||
*/
|
||||
public static function create($url = '', int $status = 302, array $headers = [])
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
|
||||
return new static($url, $status, $headers);
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ class Response
|
||||
*/
|
||||
public static function create(?string $content = '', int $status = 200, array $headers = [])
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
|
||||
return new static($content, $status, $headers);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class StreamedResponse extends Response
|
||||
*/
|
||||
public static function create($callback = null, int $status = 200, array $headers = [])
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, \get_called_class());
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
|
||||
return new static($callback, $status, $headers);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ final class SesTransportFactory extends AbstractTransportFactory
|
||||
throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component or AsyncAws package is not installed. Try running "composer require async-aws/ses".', __CLASS__));
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/amazon-mailer', '5.1', 'Using the "%s" transport without AsyncAws is deprecated. Try running "composer require async-aws/ses".', $scheme, \get_called_class());
|
||||
trigger_deprecation('symfony/amazon-mailer', '5.1', 'Using the "%s" transport without AsyncAws is deprecated. Try running "composer require async-aws/ses".', $scheme, static::class);
|
||||
|
||||
$user = $this->getUser($dsn);
|
||||
$password = $this->getPassword($dsn);
|
||||
|
@ -35,7 +35,7 @@ abstract class AbstractAuthenticator implements AuthenticatorInterface
|
||||
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
|
||||
{
|
||||
if (!$passport instanceof UserPassportInterface) {
|
||||
throw new LogicException(sprintf('Passport does not contain a user, overwrite "createAuthenticatedToken()" in "%s" to create a custom authenticated token.', \get_class($this)));
|
||||
throw new LogicException(sprintf('Passport does not contain a user, overwrite "createAuthenticatedToken()" in "%s" to create a custom authenticated token.', static::class));
|
||||
}
|
||||
|
||||
return new PostAuthenticationToken($passport->getUser(), $firewallName, $passport->getUser()->getRoles());
|
||||
|
@ -23,7 +23,7 @@ class AbstractNormalizerDummy extends AbstractNormalizer
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAllowedAttributes($classOrObject, array $context, bool $attributesAsString = false)
|
||||
public function getAllowedAttributes($classOrObject, array $context, bool $attributesAsString = false)
|
||||
{
|
||||
return parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
|
||||
}
|
||||
|
Reference in New Issue
Block a user