Merge branch '3.4' into 4.0
* 3.4: SCA with Php Inspections (EA Extended) Add test case for #25264 Fixed the null value exception case. Remove rc/beta suffix from composer.json files Throw an exception is expression language is not installed Fail as early and noisily as possible [Console][DI] Fail gracefully [FrameworkBundle] Fix visibility of a test helper [link] clear the cache after linking [DI] Trigger deprecation when setting a to-be-private synthetic service [link] Prevent warnings when running link with 2.7 [Validator] ExpressionValidator should use OBJECT_TO_STRING to allow value in message do not eagerly filter comment lines [WebProfilerBundle], [TwigBundle] Fix Profiler breaking XHTML pages (Content-Type: application/xhtml+xml)
This commit is contained in:
commit
1da85910c7
13
link
13
link
@ -35,11 +35,14 @@ if (!is_dir("$argv[1]/vendor/symfony")) {
|
||||
}
|
||||
|
||||
$sfPackages = array('symfony/symfony' => __DIR__);
|
||||
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||
$sfPackages[json_decode(file_get_contents("$dir/composer.json"))->name] = $dir;
|
||||
}
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||
if ($filesystem->exists($composer = "$dir/composer.json")) {
|
||||
$sfPackages[json_decode(file_get_contents($composer))->name] = $dir;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||
$package = 'symfony/'.basename($dir);
|
||||
if (is_link($dir)) {
|
||||
@ -57,3 +60,7 @@ foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir)
|
||||
$filesystem->symlink($sfDir, $dir);
|
||||
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
|
||||
}
|
||||
|
||||
foreach (glob("$argv[1]/var/cache/*") as $cacheDir) {
|
||||
$filesystem->remove($cacheDir);
|
||||
}
|
||||
|
@ -59,7 +59,12 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
|
||||
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
|
||||
}
|
||||
if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
|
||||
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
|
||||
$remoteZip = "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip";
|
||||
$remoteZipStream = @fopen($remoteZip, 'rb');
|
||||
if (!$remoteZipStream) {
|
||||
throw new \RuntimeException("Could not find $remoteZip");
|
||||
}
|
||||
stream_copy_to_stream($remoteZipStream, fopen("$PHPUNIT_VERSION.zip", 'wb'));
|
||||
} else {
|
||||
@unlink("$PHPUNIT_VERSION.zip");
|
||||
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
|
||||
|
@ -24,7 +24,7 @@
|
||||
"symfony/asset": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/finder": "~3.4|~4.0",
|
||||
"symfony/form": "~3.4-beta4|~4.0-beta4",
|
||||
"symfony/form": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/http-kernel": "~3.4|~4.0",
|
||||
"symfony/polyfill-intl-icu": "~1.0",
|
||||
|
@ -252,7 +252,7 @@ class RedirectControllerTest extends TestCase
|
||||
return new RedirectController(null, $httpPort, $httpsPort);
|
||||
}
|
||||
|
||||
public function assertRedirectUrl(Response $returnResponse, $expectedUrl)
|
||||
private function assertRedirectUrl(Response $returnResponse, $expectedUrl)
|
||||
{
|
||||
$this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location'));
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
"symfony/cache": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/config": "~3.4|~4.0",
|
||||
"symfony/event-dispatcher": "~3.4-beta4|~4.0-beta4",
|
||||
"symfony/event-dispatcher": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/http-kernel": "~3.4|~4.0",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
|
@ -18,7 +18,7 @@
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-xml": "*",
|
||||
"symfony/security": "~3.4-beta5|~4.0-beta5",
|
||||
"symfony/security": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/http-kernel": "~3.4|~4.0"
|
||||
},
|
||||
@ -30,7 +30,7 @@
|
||||
"symfony/dom-crawler": "~3.4|~4.0",
|
||||
"symfony/event-dispatcher": "~3.4|~4.0",
|
||||
"symfony/form": "~3.4|~4.0",
|
||||
"symfony/framework-bundle": "~3.4-rc1|~4.0-rc1",
|
||||
"symfony/framework-bundle": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/translation": "~3.4|~4.0",
|
||||
"symfony/twig-bundle": "~3.4|~4.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{# This file is based on WebProfilerBundle/Resources/views/Profiler/base_js.html.twig.
|
||||
If you make any change in this file, verify the same change is needed in the other file. #}
|
||||
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
|
||||
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
|
||||
{# Caution: the contents of this file are processed by Twig before loading
|
||||
them as JavaScript source code. Always use '/*' comments instead
|
||||
of '//' comments to avoid impossible-to-debug side-effects #}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{# This file is partially duplicated in TwigBundle/Resources/views/base_js.html.twig. If you
|
||||
make any change in this file, verify the same change is needed in the other file. #}
|
||||
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
|
||||
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
|
||||
{# Caution: the contents of this file are processed by Twig before loading
|
||||
them as JavaScript source code. Always use '/*' comments instead
|
||||
of '//' comments to avoid impossible-to-debug side-effects #}
|
||||
|
@ -3,7 +3,7 @@
|
||||
<style{% if csp_style_nonce %} nonce="{{ csp_style_nonce }}"{% endif %}>
|
||||
{{ include('@WebProfiler/Profiler/toolbar.css.twig') }}
|
||||
</style>
|
||||
<script{% if csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
|
||||
<script{% if csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
|
||||
(function () {
|
||||
Sfjs.load(
|
||||
'sfwdt{{ token }}',
|
||||
|
@ -39,6 +39,8 @@ use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
/**
|
||||
@ -116,6 +118,25 @@ class Application
|
||||
$output = new ConsoleOutput();
|
||||
}
|
||||
|
||||
$renderException = function ($e) use ($output) {
|
||||
if (!$e instanceof \Exception) {
|
||||
$e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
||||
}
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$this->renderException($e, $output->getErrorOutput());
|
||||
} else {
|
||||
$this->renderException($e, $output);
|
||||
}
|
||||
};
|
||||
if ($phpHandler = set_exception_handler($renderException)) {
|
||||
restore_exception_handler();
|
||||
if (!is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
|
||||
$debugHandler = true;
|
||||
} elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
|
||||
$phpHandler[0]->setExceptionHandler($debugHandler);
|
||||
}
|
||||
}
|
||||
|
||||
$this->configureIO($input, $output);
|
||||
|
||||
try {
|
||||
@ -125,11 +146,7 @@ class Application
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$this->renderException($e, $output->getErrorOutput());
|
||||
} else {
|
||||
$this->renderException($e, $output);
|
||||
}
|
||||
$renderException($e);
|
||||
|
||||
$exitCode = $e->getCode();
|
||||
if (is_numeric($exitCode)) {
|
||||
@ -140,6 +157,12 @@ class Application
|
||||
} else {
|
||||
$exitCode = 1;
|
||||
}
|
||||
} finally {
|
||||
if (!$phpHandler) {
|
||||
restore_exception_handler();
|
||||
} elseif (!$debugHandler) {
|
||||
$phpHandler[0]->setExceptionHandler(null);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->autoExit) {
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\DependencyInjection\Compiler;
|
||||
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\ExpressionLanguage;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@ -148,6 +149,10 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
||||
private function getExpressionLanguage()
|
||||
{
|
||||
if (null === $this->expressionLanguage) {
|
||||
if (!class_exists(ExpressionLanguage::class)) {
|
||||
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
|
||||
}
|
||||
|
||||
$providers = $this->container->getExpressionLanguageProviders();
|
||||
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
|
||||
if ('""' === substr_replace($arg, '', 1, -1)) {
|
||||
|
@ -224,12 +224,16 @@ EOF;
|
||||
{$namespaceLine}
|
||||
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
|
||||
|
||||
if (!class_exists(\\Container{$hash}\\{$options['class']}::class, false)) {
|
||||
require __DIR__.'/Container{$hash}/{$options['class']}.php';
|
||||
if (\\class_exists(\\Container{$hash}\\{$options['class']}::class, false)) {
|
||||
// no-op
|
||||
} elseif (!include __DIR__.'/Container{$hash}/{$options['class']}.php') {
|
||||
touch(__DIR__.'/Container{$hash}.legacy');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!class_exists({$options['class']}::class, false)) {
|
||||
class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false);
|
||||
if (!\\class_exists({$options['class']}::class, false)) {
|
||||
\\class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false);
|
||||
}
|
||||
|
||||
return new \\Container{$hash}\\{$options['class']}();
|
||||
@ -424,13 +428,13 @@ EOTXT
|
||||
}
|
||||
|
||||
foreach (array_diff_key(array_flip($lineage), $this->inlinedRequires) as $file => $class) {
|
||||
$code .= sprintf(" require_once %s;\n", $file);
|
||||
$code .= sprintf(" include_once %s;\n", $file);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($inlinedDefinitions as $def) {
|
||||
if ($file = $def->getFile()) {
|
||||
$code .= sprintf(" require_once %s;\n", $this->dumpValue($file));
|
||||
$code .= sprintf(" include_once %s;\n", $this->dumpValue($file));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1082,7 +1086,7 @@ EOF;
|
||||
foreach ($lineage as $file) {
|
||||
if (!isset($this->inlinedRequires[$file])) {
|
||||
$this->inlinedRequires[$file] = true;
|
||||
$code .= sprintf(" require_once %s;\n", $file);
|
||||
$code .= sprintf(" include_once %s;\n", $file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
|
||||
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
|
||||
// Returns the public 'method_call1' shared service.
|
||||
|
||||
require_once ($this->targetDirs[0].'/Fixtures/includes/foo.php');
|
||||
include_once ($this->targetDirs[0].'/Fixtures/includes/foo.php');
|
||||
|
||||
$this->services['method_call1'] = $instance = new \Bar\FooClass();
|
||||
|
||||
@ -483,12 +483,16 @@ class ProjectServiceContainer extends Container
|
||||
|
||||
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
|
||||
|
||||
if (!class_exists(\Container%s\ProjectServiceContainer::class, false)) {
|
||||
require __DIR__.'/Container%s/ProjectServiceContainer.php';
|
||||
if (\class_exists(\Container%s\ProjectServiceContainer::class, false)) {
|
||||
// no-op
|
||||
} elseif (!include __DIR__.'/Container%s/ProjectServiceContainer.php') {
|
||||
touch(__DIR__.'/Container%s.legacy');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!class_exists(ProjectServiceContainer::class, false)) {
|
||||
class_alias(\Container%s\ProjectServiceContainer::class, ProjectServiceContainer::class, false);
|
||||
if (!\class_exists(ProjectServiceContainer::class, false)) {
|
||||
\class_alias(\Container%s\ProjectServiceContainer::class, ProjectServiceContainer::class, false);
|
||||
}
|
||||
|
||||
return new \Container%s\ProjectServiceContainer();
|
||||
|
@ -340,7 +340,7 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getMethodCall1Service()
|
||||
{
|
||||
require_once '%path%foo.php';
|
||||
include_once '%path%foo.php';
|
||||
|
||||
$this->services['method_call1'] = $instance = new \Bar\FooClass();
|
||||
|
||||
|
@ -37,10 +37,10 @@ class ProjectServiceContainer extends Container
|
||||
|
||||
$this->aliases = array();
|
||||
|
||||
require_once $this->targetDirs[1].'/includes/HotPath/I1.php';
|
||||
require_once $this->targetDirs[1].'/includes/HotPath/P1.php';
|
||||
require_once $this->targetDirs[1].'/includes/HotPath/T1.php';
|
||||
require_once $this->targetDirs[1].'/includes/HotPath/C1.php';
|
||||
include_once $this->targetDirs[1].'/includes/HotPath/I1.php';
|
||||
include_once $this->targetDirs[1].'/includes/HotPath/P1.php';
|
||||
include_once $this->targetDirs[1].'/includes/HotPath/T1.php';
|
||||
include_once $this->targetDirs[1].'/includes/HotPath/C1.php';
|
||||
}
|
||||
|
||||
public function reset()
|
||||
@ -95,8 +95,8 @@ class ProjectServiceContainer extends Container
|
||||
*/
|
||||
protected function getC2Service()
|
||||
{
|
||||
require_once $this->targetDirs[1].'/includes/HotPath/C3.php';
|
||||
require_once $this->targetDirs[1].'/includes/HotPath/C2.php';
|
||||
include_once $this->targetDirs[1].'/includes/HotPath/C3.php';
|
||||
include_once $this->targetDirs[1].'/includes/HotPath/C2.php';
|
||||
|
||||
return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3());
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
"symfony/http-kernel": "~3.4|~4.0",
|
||||
"symfony/security-csrf": "~3.4|~4.0",
|
||||
"symfony/translation": "~3.4|~4.0",
|
||||
"symfony/var-dumper": "~3.4-beta3|~4.0-beta3"
|
||||
"symfony/var-dumper": "~3.4|~4.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
|
||||
|
@ -356,7 +356,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
*/
|
||||
public function setAnnotatedClassCache(array $annotatedClasses)
|
||||
{
|
||||
file_put_contents(($this->warmupDir ?: $this->getCacheDir()).'/annotations.map', sprintf('<?php return %s;', var_export($annotatedClasses, true)));
|
||||
file_put_contents(($this->warmupDir ?: $this->getCacheDir()).'/annotations.map', sprintf('<?php return %s;', var_export($annotatedClasses, true)), LOCK_EX);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -452,7 +452,13 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$cacheDir = $this->warmupDir ?: $this->getCacheDir();
|
||||
$cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug);
|
||||
if ($fresh = $cache->isFresh()) {
|
||||
$this->container = require $cache->getPath();
|
||||
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
|
||||
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
|
||||
try {
|
||||
$this->container = include $cache->getPath();
|
||||
} finally {
|
||||
error_reporting($errorLevel);
|
||||
}
|
||||
$fresh = \is_object($this->container);
|
||||
}
|
||||
if (!$fresh) {
|
||||
@ -460,7 +466,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$collectedLogs = array();
|
||||
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
|
||||
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
|
||||
return $previousHandler ? $previousHandler($type & ~E_WARNING, $message, $file, $line) : E_WARNING === $type;
|
||||
}
|
||||
|
||||
if (isset($collectedLogs[$message])) {
|
||||
@ -487,23 +493,27 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
'count' => 1,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
|
||||
}
|
||||
|
||||
try {
|
||||
$container = null;
|
||||
$container = $this->buildContainer();
|
||||
$container->compile();
|
||||
|
||||
$oldContainer = file_exists($cache->getPath()) && is_object($oldContainer = include $cache->getPath()) ? new \ReflectionClass($oldContainer) : false;
|
||||
} finally {
|
||||
if ($this->debug) {
|
||||
restore_error_handler();
|
||||
|
||||
file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
|
||||
file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : '');
|
||||
} else {
|
||||
error_reporting($errorLevel);
|
||||
}
|
||||
}
|
||||
|
||||
$oldContainer = file_exists($cache->getPath()) && is_object($oldContainer = @include $cache->getPath()) ? new \ReflectionClass($oldContainer) : false;
|
||||
|
||||
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
|
||||
$this->container = require $cache->getPath();
|
||||
}
|
||||
@ -519,13 +529,13 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
// old container files are not removed immediately,
|
||||
// but on a next dump of the container.
|
||||
$oldContainerDir = dirname($oldContainer->getFileName());
|
||||
foreach (glob(dirname($oldContainerDir).'/*.legacyContainer') as $legacyContainer) {
|
||||
if ($oldContainerDir.'.legacyContainer' !== $legacyContainer && @unlink($legacyContainer)) {
|
||||
foreach (glob(dirname($oldContainerDir).'/*.legacy') as $legacyContainer) {
|
||||
if ($oldContainerDir.'.legacy' !== $legacyContainer && @unlink($legacyContainer)) {
|
||||
(new Filesystem())->remove(substr($legacyContainer, 0, -16));
|
||||
}
|
||||
}
|
||||
|
||||
touch($oldContainerDir.'.legacyContainer');
|
||||
touch($oldContainerDir.'.legacy');
|
||||
}
|
||||
|
||||
if ($this->container->has('cache_warmer')) {
|
||||
|
@ -521,7 +521,7 @@ EOF;
|
||||
|
||||
$this->assertTrue(get_class($kernel->getContainer()) !== $containerClass);
|
||||
$this->assertFileExists($containerFile);
|
||||
$this->assertFileExists(dirname($containerFile).'.legacyContainer');
|
||||
$this->assertFileExists(dirname($containerFile).'.legacy');
|
||||
}
|
||||
|
||||
public function testKernelPass()
|
||||
|
@ -20,10 +20,10 @@
|
||||
"symfony/security-core": "~3.4|~4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/http-foundation": "~3.4-beta5|~4.0-beta5"
|
||||
"symfony/http-foundation": "~3.4|~4.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-foundation": "<3.4-beta5|~4.0,<4.0-beta5"
|
||||
"symfony/http-foundation": "<3.4"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/http-foundation": "For using the class SessionTokenStorage."
|
||||
|
@ -18,7 +18,7 @@
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/event-dispatcher": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~3.4-beta5|~4.0-beta5",
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/http-kernel": "~3.4|~4.0",
|
||||
"symfony/property-access": "~3.4|~4.0"
|
||||
},
|
||||
|
@ -45,7 +45,7 @@ class ExpressionValidator extends ConstraintValidator
|
||||
|
||||
if (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) {
|
||||
$this->context->buildViolation($constraint->message)
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING))
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->addViolation();
|
||||
}
|
||||
|
@ -26,6 +26,10 @@ class ValidValidator extends ConstraintValidator
|
||||
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Valid');
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->context
|
||||
->getValidator()
|
||||
->inContext($this->context)
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Validator\Constraints\Expression;
|
||||
use Symfony\Component\Validator\Constraints\ExpressionValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\ToString;
|
||||
|
||||
class ExpressionValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
@ -87,6 +88,40 @@ class ExpressionValidatorTest extends ConstraintValidatorTestCase
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSucceedingExpressionAtObjectLevelWithToString()
|
||||
{
|
||||
$constraint = new Expression('this.data == 1');
|
||||
|
||||
$object = new ToString();
|
||||
$object->data = '1';
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testFailingExpressionAtObjectLevelWithToString()
|
||||
{
|
||||
$constraint = new Expression(array(
|
||||
'expression' => 'this.data == 1',
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$object = new ToString();
|
||||
$object->data = '2';
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
$this->validator->validate($object, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', 'toString')
|
||||
->setCode(Expression::EXPRESSION_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testSucceedingExpressionAtPropertyLevel()
|
||||
{
|
||||
$constraint = new Expression('value == this.data');
|
||||
|
@ -20,6 +20,18 @@ class ValidValidatorTest extends TestCase
|
||||
$this->assertSame('fooBar.fooBarBaz.foo', $violations->get(0)->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testNullValues()
|
||||
{
|
||||
$validatorBuilder = new ValidatorBuilder();
|
||||
$validator = $validatorBuilder->enableAnnotationMapping()->getValidator();
|
||||
|
||||
$foo = new Foo();
|
||||
$foo->fooBar = null;
|
||||
$violations = $validator->validate($foo, null, array('nested'));
|
||||
|
||||
$this->assertCount(0, $violations);
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new ValidValidator();
|
||||
|
22
src/Symfony/Component/Validator/Tests/Fixtures/ToString.php
Normal file
22
src/Symfony/Component/Validator/Tests/Fixtures/ToString.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Validator\Tests\Fixtures;
|
||||
|
||||
class ToString
|
||||
{
|
||||
public $data;
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return 'toString';
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ final class Definition
|
||||
|
||||
private function addPlace(string $place)
|
||||
{
|
||||
if (!preg_match('{^[\w\d_-]+$}', $place)) {
|
||||
if (!preg_match('{^[\w_-]+$}', $place)) {
|
||||
throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place));
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class DefinitionBuilder
|
||||
*/
|
||||
public function addPlace($place)
|
||||
{
|
||||
if (!preg_match('{^[\w\d_-]+$}', $place)) {
|
||||
if (!preg_match('{^[\w_-]+$}', $place)) {
|
||||
throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place));
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Transition
|
||||
*/
|
||||
public function __construct(string $name, $froms, $tos)
|
||||
{
|
||||
if (!preg_match('{^[\w\d_-]+$}', $name)) {
|
||||
if (!preg_match('{^[\w_-]+$}', $name)) {
|
||||
throw new InvalidArgumentException(sprintf('The transition "%s" contains invalid characters.', $name));
|
||||
}
|
||||
|
||||
|
@ -585,21 +585,10 @@ class Parser
|
||||
continue;
|
||||
}
|
||||
|
||||
// we ignore "comment" lines only when we are not inside a scalar block
|
||||
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
|
||||
// remember ignored comment lines (they are used later in nested
|
||||
// parser calls to determine real line numbers)
|
||||
//
|
||||
// CAUTION: beware to not populate the global property here as it
|
||||
// will otherwise influence the getRealCurrentLineNb() call here
|
||||
// for consecutive comment lines and subsequent embedded blocks
|
||||
$this->locallySkippedLineNumbers[] = $this->getRealCurrentLineNb();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($indent >= $newIndent) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
} elseif ($this->isCurrentLineComment()) {
|
||||
$data[] = $this->currentLine;
|
||||
} elseif (0 == $indent) {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
|
@ -1433,6 +1433,24 @@ YAML;
|
||||
$this->assertSame(array('foobar' => 'foobar'), $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testCommentCharactersInMultiLineQuotedStrings()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
foobar: 'foo
|
||||
#bar'
|
||||
bar: baz
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'foobar' => 'foo #bar',
|
||||
'bar' => 'baz',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testParseMultiLineUnquotedString()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
|
Reference in New Issue
Block a user