minor #33332 [3.4] Fix return types declarations (nicolas-grekas, derrabus)
This PR was merged into the 3.4 branch. Discussion ---------- [3.4] Fix return types declarations | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This is the subset of #33236 that applies to branch 3.4. This PR ensures return types are correctly declared, and adjust some implementations that return incorrect types. Commits -------2ceb453ee5
[SecurityBundle] fix return type declarationsc1d7a88b57
[BrowserKit] fix return type declarations07405e2c60
[PropertyInfo] fix return type declarations5f3b4b616b
[Bridge/Doctrine] fix return type declarations8706f18ea8
[Form] fix return type declarationsa32a713045
[Console] fix return type declarations523e9b9feb
[Intl] fix return type declarations73f504c94a
[Templating] fix return type declarations2b8ef1d6d7
[DomCrawler] fix return type declarations2ea98bb4a1
[Validator] fix return type declarations6af0c80342
[Process] fix return type declarations28646c7f9b
[Workflow] fix return type declarations5f9aaa743c
[Cache] fix return type declarations5072cfc7f8
[Serializer] fix return type declarations70feaa407e
[Translation] fix return type declarationsca1fad471e
[DI] fix return type declarations9c63be489e
[Config] fix return type declarations05fe553666
[HttpKernel] Fix return type declarationse0d79f71ed
[Security] Fix return type declarationsc1b7118d7c
[Routing] Fix return type declarationsef5ead0005
[HttpFoundation] fix return type declarations
This commit is contained in:
commit
e9886e4e4c
@ -89,6 +89,6 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
|||||||
return $qb->andWhere($where)
|
return $qb->andWhere($where)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->setParameter($parameter, $values, $parameterType)
|
->setParameter($parameter, $values, $parameterType)
|
||||||
->getResult();
|
->getResult() ?: [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,8 @@ class TranslationDefaultDomainNodeVisitor extends AbstractNodeVisitor
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getPriority()
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,8 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getPriority()
|
||||||
{
|
{
|
||||||
|
@ -106,9 +106,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array $directory
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
protected function extractFromDirectory($directory)
|
protected function extractFromDirectory($directory)
|
||||||
{
|
{
|
||||||
|
@ -1743,9 +1743,7 @@ class FrameworkExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base path for the XSD files.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string The XSD base path
|
|
||||||
*/
|
*/
|
||||||
public function getXsdValidationBasePath()
|
public function getXsdValidationBasePath()
|
||||||
{
|
{
|
||||||
|
@ -24,16 +24,16 @@ class ProfilerTest extends AbstractWebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$client->request('GET', '/profiler');
|
$client->request('GET', '/profiler');
|
||||||
$this->assertFalse($client->getProfile());
|
$this->assertNull($client->getProfile());
|
||||||
|
|
||||||
// enable the profiler for the next request
|
// enable the profiler for the next request
|
||||||
$client->enableProfiler();
|
$client->enableProfiler();
|
||||||
$this->assertFalse($client->getProfile());
|
$this->assertNull($client->getProfile());
|
||||||
$client->request('GET', '/profiler');
|
$client->request('GET', '/profiler');
|
||||||
$this->assertIsObject($client->getProfile());
|
$this->assertIsObject($client->getProfile());
|
||||||
|
|
||||||
$client->request('GET', '/profiler');
|
$client->request('GET', '/profiler');
|
||||||
$this->assertFalse($client->getProfile());
|
$this->assertNull($client->getProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfigs()
|
public function getConfigs()
|
||||||
|
@ -231,7 +231,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Gets the roles of the user.
|
* Gets the roles of the user.
|
||||||
*
|
*
|
||||||
* @return array The roles
|
* @return array|Data
|
||||||
*/
|
*/
|
||||||
public function getRoles()
|
public function getRoles()
|
||||||
{
|
{
|
||||||
@ -241,7 +241,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Gets the inherited roles of the user.
|
* Gets the inherited roles of the user.
|
||||||
*
|
*
|
||||||
* @return array The inherited roles
|
* @return array|Data
|
||||||
*/
|
*/
|
||||||
public function getInheritedRoles()
|
public function getInheritedRoles()
|
||||||
{
|
{
|
||||||
@ -269,16 +269,25 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
return $this->data['authenticated'];
|
return $this->data['authenticated'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isImpersonated()
|
public function isImpersonated()
|
||||||
{
|
{
|
||||||
return $this->data['impersonated'];
|
return $this->data['impersonated'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
public function getImpersonatorUser()
|
public function getImpersonatorUser()
|
||||||
{
|
{
|
||||||
return $this->data['impersonator_user'];
|
return $this->data['impersonator_user'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
public function getImpersonationExitPath()
|
public function getImpersonationExitPath()
|
||||||
{
|
{
|
||||||
return $this->data['impersonation_exit_path'];
|
return $this->data['impersonation_exit_path'];
|
||||||
@ -287,7 +296,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Get the class name of the security token.
|
* Get the class name of the security token.
|
||||||
*
|
*
|
||||||
* @return string The token
|
* @return string|Data|null The token
|
||||||
*/
|
*/
|
||||||
public function getTokenClass()
|
public function getTokenClass()
|
||||||
{
|
{
|
||||||
@ -297,7 +306,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Get the full security token class as Data object.
|
* Get the full security token class as Data object.
|
||||||
*
|
*
|
||||||
* @return Data
|
* @return Data|null
|
||||||
*/
|
*/
|
||||||
public function getToken()
|
public function getToken()
|
||||||
{
|
{
|
||||||
@ -307,7 +316,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Get the logout URL.
|
* Get the logout URL.
|
||||||
*
|
*
|
||||||
* @return string The logout URL
|
* @return string|null The logout URL
|
||||||
*/
|
*/
|
||||||
public function getLogoutUrl()
|
public function getLogoutUrl()
|
||||||
{
|
{
|
||||||
@ -317,7 +326,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Returns the FQCN of the security voters enabled in the application.
|
* Returns the FQCN of the security voters enabled in the application.
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]|Data
|
||||||
*/
|
*/
|
||||||
public function getVoters()
|
public function getVoters()
|
||||||
{
|
{
|
||||||
@ -337,7 +346,7 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Returns the log of the security decisions made by the access decision manager.
|
* Returns the log of the security decisions made by the access decision manager.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|Data
|
||||||
*/
|
*/
|
||||||
public function getAccessDecisionLog()
|
public function getAccessDecisionLog()
|
||||||
{
|
{
|
||||||
@ -347,13 +356,16 @@ class SecurityDataCollector extends DataCollector implements LateDataCollectorIn
|
|||||||
/**
|
/**
|
||||||
* Returns the configuration of the current firewall context.
|
* Returns the configuration of the current firewall context.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|Data
|
||||||
*/
|
*/
|
||||||
public function getFirewall()
|
public function getFirewall()
|
||||||
{
|
{
|
||||||
return $this->data['firewall'];
|
return $this->data['firewall'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|Data
|
||||||
|
*/
|
||||||
public function getListeners()
|
public function getListeners()
|
||||||
{
|
{
|
||||||
return $this->data['listeners'];
|
return $this->data['listeners'];
|
||||||
|
@ -130,9 +130,9 @@ abstract class AbstractFactory implements SecurityFactoryInterface
|
|||||||
* @param ContainerBuilder $container
|
* @param ContainerBuilder $container
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @param string $defaultEntryPointId
|
* @param string|null $defaultEntryPointId
|
||||||
*
|
*
|
||||||
* @return string the entry point id
|
* @return string|null the entry point id
|
||||||
*/
|
*/
|
||||||
protected function createEntryPoint($container, $id, $config, $defaultEntryPointId)
|
protected function createEntryPoint($container, $id, $config, $defaultEntryPointId)
|
||||||
{
|
{
|
||||||
|
@ -24,10 +24,10 @@ interface SecurityFactoryInterface
|
|||||||
/**
|
/**
|
||||||
* Configures the container services required to use the authentication listener.
|
* Configures the container services required to use the authentication listener.
|
||||||
*
|
*
|
||||||
* @param string $id The unique id of the firewall
|
* @param string $id The unique id of the firewall
|
||||||
* @param array $config The options array for the listener
|
* @param array $config The options array for the listener
|
||||||
* @param string $userProvider The service id of the user provider
|
* @param string $userProvider The service id of the user provider
|
||||||
* @param string $defaultEntryPoint
|
* @param string|null $defaultEntryPoint
|
||||||
*
|
*
|
||||||
* @return array containing three values:
|
* @return array containing three values:
|
||||||
* - the provider id
|
* - the provider id
|
||||||
|
@ -798,9 +798,7 @@ class SecurityExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base path for the XSD files.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string The XSD base path
|
|
||||||
*/
|
*/
|
||||||
public function getXsdValidationBasePath()
|
public function getXsdValidationBasePath()
|
||||||
{
|
{
|
||||||
|
@ -255,9 +255,7 @@ class TwigExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base path for the XSD files.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string The XSD base path
|
|
||||||
*/
|
*/
|
||||||
public function getXsdValidationBasePath()
|
public function getXsdValidationBasePath()
|
||||||
{
|
{
|
||||||
|
@ -64,9 +64,7 @@ class WebProfilerExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base path for the XSD files.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string The XSD base path
|
|
||||||
*/
|
*/
|
||||||
public function getXsdValidationBasePath()
|
public function getXsdValidationBasePath()
|
||||||
{
|
{
|
||||||
|
@ -141,9 +141,9 @@ abstract class Client
|
|||||||
* Gets single server parameter for specified key.
|
* Gets single server parameter for specified key.
|
||||||
*
|
*
|
||||||
* @param string $key A key of the parameter to get
|
* @param string $key A key of the parameter to get
|
||||||
* @param string $default A default value when key is undefined
|
* @param mixed $default A default value when key is undefined
|
||||||
*
|
*
|
||||||
* @return string A value of the parameter
|
* @return mixed A value of the parameter
|
||||||
*/
|
*/
|
||||||
public function getServerParameter($key, $default = '')
|
public function getServerParameter($key, $default = '')
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ class Request
|
|||||||
/**
|
/**
|
||||||
* Gets the request raw body data.
|
* Gets the request raw body data.
|
||||||
*
|
*
|
||||||
* @return string The request raw body data
|
* @return string|null The request raw body data
|
||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
|||||||
*/
|
*/
|
||||||
protected function doFlush()
|
protected function doFlush()
|
||||||
{
|
{
|
||||||
$this->pool->clear();
|
return $this->pool->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,5 +98,6 @@ class DoctrineProvider extends CacheProvider implements PruneableInterface, Rese
|
|||||||
*/
|
*/
|
||||||
protected function doGetStats()
|
protected function doGetStats()
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,10 @@ class MaxIdLengthAdapterTest extends TestCase
|
|||||||
->setConstructorArgs([str_repeat('-', 26)])
|
->setConstructorArgs([str_repeat('-', 26)])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
$cache
|
||||||
|
->method('doFetch')
|
||||||
|
->willReturn(['2:']);
|
||||||
|
|
||||||
$reflectionClass = new \ReflectionClass(AbstractAdapter::class);
|
$reflectionClass = new \ReflectionClass(AbstractAdapter::class);
|
||||||
|
|
||||||
$reflectionMethod = $reflectionClass->getMethod('getId');
|
$reflectionMethod = $reflectionClass->getMethod('getId');
|
||||||
@ -56,7 +60,7 @@ class MaxIdLengthAdapterTest extends TestCase
|
|||||||
$reflectionProperty->setValue($cache, true);
|
$reflectionProperty->setValue($cache, true);
|
||||||
|
|
||||||
// Versioning enabled
|
// Versioning enabled
|
||||||
$this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
|
$this->assertEquals('--------------------------:2:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
|
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
|
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
|
||||||
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
|
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
|
||||||
|
@ -38,17 +38,13 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes keys between the different configuration formats.
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
|
* Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
|
||||||
* After running this method, all keys are normalized to foo_bar.
|
* After running this method, all keys are normalized to foo_bar.
|
||||||
*
|
*
|
||||||
* If you have a mixed key like foo-bar_moo, it will not be altered.
|
* If you have a mixed key like foo-bar_moo, it will not be altered.
|
||||||
* The key will also not be altered if the target key already exists.
|
* The key will also not be altered if the target key already exists.
|
||||||
*
|
|
||||||
* @param mixed $value
|
|
||||||
*
|
|
||||||
* @return array The value with normalized keys
|
|
||||||
*/
|
*/
|
||||||
protected function preNormalize($value)
|
protected function preNormalize($value)
|
||||||
{
|
{
|
||||||
|
@ -49,21 +49,37 @@ abstract class BaseNode implements NodeInterface
|
|||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
*/
|
||||||
public function setAttribute($key, $value)
|
public function setAttribute($key, $value)
|
||||||
{
|
{
|
||||||
$this->attributes[$key] = $value;
|
$this->attributes[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function getAttribute($key, $default = null)
|
public function getAttribute($key, $default = null)
|
||||||
{
|
{
|
||||||
return isset($this->attributes[$key]) ? $this->attributes[$key] : $default;
|
return isset($this->attributes[$key]) ? $this->attributes[$key] : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function hasAttribute($key)
|
public function hasAttribute($key)
|
||||||
{
|
{
|
||||||
return isset($this->attributes[$key]);
|
return isset($this->attributes[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getAttributes()
|
public function getAttributes()
|
||||||
{
|
{
|
||||||
return $this->attributes;
|
return $this->attributes;
|
||||||
@ -74,6 +90,9 @@ abstract class BaseNode implements NodeInterface
|
|||||||
$this->attributes = $attributes;
|
$this->attributes = $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
*/
|
||||||
public function removeAttribute($key)
|
public function removeAttribute($key)
|
||||||
{
|
{
|
||||||
unset($this->attributes[$key]);
|
unset($this->attributes[$key]);
|
||||||
@ -92,7 +111,7 @@ abstract class BaseNode implements NodeInterface
|
|||||||
/**
|
/**
|
||||||
* Returns info message.
|
* Returns info message.
|
||||||
*
|
*
|
||||||
* @return string The info text
|
* @return string|null The info text
|
||||||
*/
|
*/
|
||||||
public function getInfo()
|
public function getInfo()
|
||||||
{
|
{
|
||||||
@ -112,7 +131,7 @@ abstract class BaseNode implements NodeInterface
|
|||||||
/**
|
/**
|
||||||
* Retrieves the example configuration for this node.
|
* Retrieves the example configuration for this node.
|
||||||
*
|
*
|
||||||
* @return string|array The example
|
* @return string|array|null The example
|
||||||
*/
|
*/
|
||||||
public function getExample()
|
public function getExample()
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
/**
|
/**
|
||||||
* Retrieves the name of the attribute which value should be used as key.
|
* Retrieves the name of the attribute which value should be used as key.
|
||||||
*
|
*
|
||||||
* @return string The name of the attribute
|
* @return string|null The name of the attribute
|
||||||
*/
|
*/
|
||||||
public function getKeyAttribute()
|
public function getKeyAttribute()
|
||||||
{
|
{
|
||||||
|
@ -152,7 +152,7 @@ class XmlUtils
|
|||||||
* @param \DOMElement $element A \DOMElement instance
|
* @param \DOMElement $element A \DOMElement instance
|
||||||
* @param bool $checkPrefix Check prefix in an element or an attribute name
|
* @param bool $checkPrefix Check prefix in an element or an attribute name
|
||||||
*
|
*
|
||||||
* @return array A PHP array
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true)
|
public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true)
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,6 @@ use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
|||||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||||
use Symfony\Component\Console\Exception\ExceptionInterface;
|
use Symfony\Component\Console\Exception\ExceptionInterface;
|
||||||
use Symfony\Component\Console\Exception\LogicException;
|
|
||||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||||
use Symfony\Component\Console\Helper\DebugFormatterHelper;
|
use Symfony\Component\Console\Helper\DebugFormatterHelper;
|
||||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||||
@ -457,13 +456,8 @@ class Application
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $command->getDefinition()) {
|
// Will throw if the command is not correctly initialized.
|
||||||
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
|
$command->getDefinition();
|
||||||
}
|
|
||||||
|
|
||||||
if (!$command->getName()) {
|
|
||||||
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->commands[$command->getName()] = $command;
|
$this->commands[$command->getName()] = $command;
|
||||||
|
|
||||||
@ -1023,7 +1017,7 @@ class Application
|
|||||||
/**
|
/**
|
||||||
* Gets the name of the command based on input.
|
* Gets the name of the command based on input.
|
||||||
*
|
*
|
||||||
* @return string The command name
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
protected function getCommandName(InputInterface $input)
|
protected function getCommandName(InputInterface $input)
|
||||||
{
|
{
|
||||||
|
@ -40,8 +40,8 @@ class Command
|
|||||||
private $aliases = [];
|
private $aliases = [];
|
||||||
private $definition;
|
private $definition;
|
||||||
private $hidden = false;
|
private $hidden = false;
|
||||||
private $help;
|
private $help = '';
|
||||||
private $description;
|
private $description = '';
|
||||||
private $ignoreValidationErrors = false;
|
private $ignoreValidationErrors = false;
|
||||||
private $applicationDefinitionMerged = false;
|
private $applicationDefinitionMerged = false;
|
||||||
private $applicationDefinitionMergedWithArgs = false;
|
private $applicationDefinitionMergedWithArgs = false;
|
||||||
@ -105,7 +105,7 @@ class Command
|
|||||||
/**
|
/**
|
||||||
* Gets the helper set.
|
* Gets the helper set.
|
||||||
*
|
*
|
||||||
* @return HelperSet A HelperSet instance
|
* @return HelperSet|null A HelperSet instance
|
||||||
*/
|
*/
|
||||||
public function getHelperSet()
|
public function getHelperSet()
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ class Command
|
|||||||
/**
|
/**
|
||||||
* Gets the application instance for this command.
|
* Gets the application instance for this command.
|
||||||
*
|
*
|
||||||
* @return Application An Application instance
|
* @return Application|null An Application instance
|
||||||
*/
|
*/
|
||||||
public function getApplication()
|
public function getApplication()
|
||||||
{
|
{
|
||||||
@ -347,6 +347,10 @@ class Command
|
|||||||
*/
|
*/
|
||||||
public function getDefinition()
|
public function getDefinition()
|
||||||
{
|
{
|
||||||
|
if (null === $this->definition) {
|
||||||
|
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($this)));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->definition;
|
return $this->definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,6 +457,10 @@ class Command
|
|||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
|
if (!$this->name) {
|
||||||
|
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class Question
|
|||||||
*
|
*
|
||||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||||
*
|
*
|
||||||
* @return callable
|
* @return callable|null
|
||||||
*/
|
*/
|
||||||
public function getNormalizer()
|
public function getNormalizer()
|
||||||
{
|
{
|
||||||
|
@ -444,8 +444,6 @@ class Container implements ResettableContainerInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a service by requiring its factory file.
|
* Creates a service by requiring its factory file.
|
||||||
*
|
|
||||||
* @return object The service created by the file
|
|
||||||
*/
|
*/
|
||||||
protected function load($file)
|
protected function load($file)
|
||||||
{
|
{
|
||||||
|
@ -796,7 +796,7 @@ class Definition
|
|||||||
/**
|
/**
|
||||||
* Gets the configurator to call after the service is fully initialized.
|
* Gets the configurator to call after the service is fully initialized.
|
||||||
*
|
*
|
||||||
* @return callable|null The PHP callable to call
|
* @return callable|array|null
|
||||||
*/
|
*/
|
||||||
public function getConfigurator()
|
public function getConfigurator()
|
||||||
{
|
{
|
||||||
|
@ -21,9 +21,7 @@ interface DumperInterface
|
|||||||
/**
|
/**
|
||||||
* Dumps the service container.
|
* Dumps the service container.
|
||||||
*
|
*
|
||||||
* @param array $options An array of options
|
* @return string|array The representation of the service container
|
||||||
*
|
|
||||||
* @return string The representation of the service container
|
|
||||||
*/
|
*/
|
||||||
public function dump(array $options = []);
|
public function dump(array $options = []);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ interface ExtensionInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the base path for the XSD files.
|
* Returns the base path for the XSD files.
|
||||||
*
|
*
|
||||||
* @return string The XSD base path
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function getXsdValidationBasePath();
|
public function getXsdValidationBasePath();
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ EOF
|
|||||||
*
|
*
|
||||||
* @param \DOMElement $element A \DOMElement instance
|
* @param \DOMElement $element A \DOMElement instance
|
||||||
*
|
*
|
||||||
* @return array A PHP array
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function convertDomElementToArray(\DOMElement $element)
|
public static function convertDomElementToArray(\DOMElement $element)
|
||||||
{
|
{
|
||||||
|
@ -195,7 +195,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
* @param string $value The string to resolve
|
* @param string $value The string to resolve
|
||||||
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
|
* @param array $resolving An array of keys that are being resolved (used internally to detect circular references)
|
||||||
*
|
*
|
||||||
* @return string The resolved string
|
* @return mixed The resolved string
|
||||||
*
|
*
|
||||||
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
|
* @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
|
||||||
* @throws ParameterCircularReferenceException if a circular reference if detected
|
* @throws ParameterCircularReferenceException if a circular reference if detected
|
||||||
|
@ -43,7 +43,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
|||||||
private $document;
|
private $document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \DOMElement[]
|
* @var \DOMNode[]
|
||||||
*/
|
*/
|
||||||
private $nodes = [];
|
private $nodes = [];
|
||||||
|
|
||||||
@ -55,9 +55,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
|||||||
private $isHtml = true;
|
private $isHtml = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $node A Node to use as the base for the crawling
|
* @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A Node to use as the base for the crawling
|
||||||
* @param string $uri The current URI
|
|
||||||
* @param string $baseHref The base href value
|
|
||||||
*/
|
*/
|
||||||
public function __construct($node = null, $uri = null, $baseHref = null)
|
public function __construct($node = null, $uri = null, $baseHref = null)
|
||||||
{
|
{
|
||||||
@ -102,7 +100,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
|||||||
* This method uses the appropriate specialized add*() method based
|
* This method uses the appropriate specialized add*() method based
|
||||||
* on the type of the argument.
|
* on the type of the argument.
|
||||||
*
|
*
|
||||||
* @param \DOMNodeList|\DOMNode|array|string|null $node A node
|
* @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A node
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException when node is not the expected type
|
* @throws \InvalidArgumentException when node is not the expected type
|
||||||
*/
|
*/
|
||||||
@ -1049,7 +1047,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
|||||||
/**
|
/**
|
||||||
* @param int $position
|
* @param int $position
|
||||||
*
|
*
|
||||||
* @return \DOMElement|null
|
* @return \DOMNode|null
|
||||||
*/
|
*/
|
||||||
public function getNode($position)
|
public function getNode($position)
|
||||||
{
|
{
|
||||||
@ -1065,7 +1063,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \ArrayIterator|\DOMElement[]
|
* @return \ArrayIterator|\DOMNode[]
|
||||||
*/
|
*/
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
@ -1146,7 +1144,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
|||||||
/**
|
/**
|
||||||
* Creates a crawler for some subnodes.
|
* Creates a crawler for some subnodes.
|
||||||
*
|
*
|
||||||
* @param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes
|
* @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $nodes
|
||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
|||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $disabled;
|
private $disabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ResolvedFormTypeInterface
|
* @var ResolvedFormTypeInterface
|
||||||
|
@ -26,6 +26,7 @@ class ButtonType extends BaseType implements ButtonTypeInterface
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,6 +190,7 @@ class FormType extends BaseType
|
|||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ class FormError implements \Serializable
|
|||||||
/**
|
/**
|
||||||
* Returns the form that caused this error.
|
* Returns the form that caused this error.
|
||||||
*
|
*
|
||||||
* @return FormInterface The form that caused this error
|
* @return FormInterface|null The form that caused this error
|
||||||
*/
|
*/
|
||||||
public function getOrigin()
|
public function getOrigin()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
|
|||||||
* @throws Exception\LogicException when trying to set a parent for a form with
|
* @throws Exception\LogicException when trying to set a parent for a form with
|
||||||
* an empty name
|
* an empty name
|
||||||
*/
|
*/
|
||||||
public function setParent(self $parent = null);
|
public function setParent(FormInterface $parent = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent form.
|
* Returns the parent form.
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Test\Traits;
|
|||||||
|
|
||||||
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
||||||
use Symfony\Component\Form\Test\TypeTestCase;
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolationList;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
||||||
@ -37,9 +38,9 @@ trait ValidatorExtensionTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
|
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
|
||||||
$metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(['addPropertyConstraint'])->getMock();
|
$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->setMethods(['addPropertyConstraint'])->getMock();
|
||||||
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
|
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
|
||||||
$this->validator->expects($this->any())->method('validate')->will($this->returnValue([]));
|
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(new ConstraintViolationList()));
|
||||||
|
|
||||||
return new ValidatorExtension($this->validator);
|
return new ValidatorExtension($this->validator);
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ abstract class AbstractRequestHandlerTest extends TestCase
|
|||||||
[1024, '1K', false],
|
[1024, '1K', false],
|
||||||
[null, '1K', false],
|
[null, '1K', false],
|
||||||
[1024, '', false],
|
[1024, '', false],
|
||||||
[1024, 0, false],
|
[1024, '0', false],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,9 @@ namespace Symfony\Component\Form\Tests\ChoiceList\Factory;
|
|||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||||
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
||||||
|
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
@ -38,7 +40,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
|
|
||||||
public function testCreateFromChoicesEmpty()
|
public function testCreateFromChoicesEmpty()
|
||||||
{
|
{
|
||||||
$list = new \stdClass();
|
$list = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
@ -54,7 +56,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
// The top-most traversable is converted to an array
|
// The top-most traversable is converted to an array
|
||||||
$choices1 = new \ArrayIterator(['A' => 'a']);
|
$choices1 = new \ArrayIterator(['A' => 'a']);
|
||||||
$choices2 = ['A' => 'a'];
|
$choices2 = ['A' => 'a'];
|
||||||
$list = new \stdClass();
|
$list = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
@ -69,8 +71,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$choices1 = ['key' => ['A' => 'a']];
|
$choices1 = ['key' => ['A' => 'a']];
|
||||||
$choices2 = ['A' => 'a'];
|
$choices2 = ['A' => 'a'];
|
||||||
$list1 = new \stdClass();
|
$list1 = new ArrayChoiceList([]);
|
||||||
$list2 = new \stdClass();
|
$list2 = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
@ -92,7 +94,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$choices1 = [$choice1];
|
$choices1 = [$choice1];
|
||||||
$choices2 = [$choice2];
|
$choices2 = [$choice2];
|
||||||
$list = new \stdClass();
|
$list = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
@ -110,8 +112,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$choices1 = [$choice1];
|
$choices1 = [$choice1];
|
||||||
$choices2 = [$choice2];
|
$choices2 = [$choice2];
|
||||||
$list1 = new \stdClass();
|
$list1 = new ArrayChoiceList([]);
|
||||||
$list2 = new \stdClass();
|
$list2 = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
@ -129,7 +131,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
public function testCreateFromChoicesSameValueClosure()
|
public function testCreateFromChoicesSameValueClosure()
|
||||||
{
|
{
|
||||||
$choices = [1];
|
$choices = [1];
|
||||||
$list = new \stdClass();
|
$list = new ArrayChoiceList([]);
|
||||||
$closure = function () {};
|
$closure = function () {};
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
@ -144,8 +146,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
public function testCreateFromChoicesDifferentValueClosure()
|
public function testCreateFromChoicesDifferentValueClosure()
|
||||||
{
|
{
|
||||||
$choices = [1];
|
$choices = [1];
|
||||||
$list1 = new \stdClass();
|
$list1 = new ArrayChoiceList([]);
|
||||||
$list2 = new \stdClass();
|
$list2 = new ArrayChoiceList([]);
|
||||||
$closure1 = function () {};
|
$closure1 = function () {};
|
||||||
$closure2 = function () {};
|
$closure2 = function () {};
|
||||||
|
|
||||||
@ -165,7 +167,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
public function testCreateFromLoaderSameLoader()
|
public function testCreateFromLoaderSameLoader()
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||||
$list = new \stdClass();
|
$list = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createListFromLoader')
|
->method('createListFromLoader')
|
||||||
@ -180,8 +182,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||||
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||||
$list1 = new \stdClass();
|
$list1 = new ArrayChoiceList([]);
|
||||||
$list2 = new \stdClass();
|
$list2 = new ArrayChoiceList([]);
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createListFromLoader')
|
->method('createListFromLoader')
|
||||||
@ -199,7 +201,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
public function testCreateFromLoaderSameValueClosure()
|
public function testCreateFromLoaderSameValueClosure()
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||||
$list = new \stdClass();
|
$list = new ArrayChoiceList([]);
|
||||||
$closure = function () {};
|
$closure = function () {};
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
@ -214,8 +216,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
public function testCreateFromLoaderDifferentValueClosure()
|
public function testCreateFromLoaderDifferentValueClosure()
|
||||||
{
|
{
|
||||||
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
|
||||||
$list1 = new \stdClass();
|
$list1 = new ArrayChoiceList([]);
|
||||||
$list2 = new \stdClass();
|
$list2 = new ArrayChoiceList([]);
|
||||||
$closure1 = function () {};
|
$closure1 = function () {};
|
||||||
$closure2 = function () {};
|
$closure2 = function () {};
|
||||||
|
|
||||||
@ -236,7 +238,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$preferred = ['a'];
|
$preferred = ['a'];
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -252,8 +254,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$preferred1 = ['a'];
|
$preferred1 = ['a'];
|
||||||
$preferred2 = ['b'];
|
$preferred2 = ['b'];
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -272,7 +274,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$preferred = function () {};
|
$preferred = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -288,8 +290,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$preferred1 = function () {};
|
$preferred1 = function () {};
|
||||||
$preferred2 = function () {};
|
$preferred2 = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -308,7 +310,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$labels = function () {};
|
$labels = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -324,8 +326,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$labels1 = function () {};
|
$labels1 = function () {};
|
||||||
$labels2 = function () {};
|
$labels2 = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -344,7 +346,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$index = function () {};
|
$index = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -360,8 +362,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$index1 = function () {};
|
$index1 = function () {};
|
||||||
$index2 = function () {};
|
$index2 = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -380,7 +382,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$groupBy = function () {};
|
$groupBy = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -396,8 +398,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$groupBy1 = function () {};
|
$groupBy1 = function () {};
|
||||||
$groupBy2 = function () {};
|
$groupBy2 = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -416,7 +418,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$attr = ['class' => 'foobar'];
|
$attr = ['class' => 'foobar'];
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -432,8 +434,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$attr1 = ['class' => 'foobar1'];
|
$attr1 = ['class' => 'foobar1'];
|
||||||
$attr2 = ['class' => 'foobar2'];
|
$attr2 = ['class' => 'foobar2'];
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -452,7 +454,7 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
{
|
{
|
||||||
$attr = function () {};
|
$attr = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view = new \stdClass();
|
$view = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->once())
|
$this->decoratedFactory->expects($this->once())
|
||||||
->method('createView')
|
->method('createView')
|
||||||
@ -468,8 +470,8 @@ class CachingFactoryDecoratorTest extends TestCase
|
|||||||
$attr1 = function () {};
|
$attr1 = function () {};
|
||||||
$attr2 = function () {};
|
$attr2 = function () {};
|
||||||
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
|
||||||
$view1 = new \stdClass();
|
$view1 = new ChoiceListView();
|
||||||
$view2 = new \stdClass();
|
$view2 = new ChoiceListView();
|
||||||
|
|
||||||
$this->decoratedFactory->expects($this->at(0))
|
$this->decoratedFactory->expects($this->at(0))
|
||||||
->method('createView')
|
->method('createView')
|
||||||
|
@ -13,7 +13,9 @@ namespace Symfony\Component\Form\Tests\ChoiceList\Factory;
|
|||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||||
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
|
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
|
||||||
|
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
|
||||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,10 +47,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
->with($choices, $this->isInstanceOf('\Closure'))
|
->with($choices, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($choices, $callback) {
|
->willReturnCallback(function ($choices, $callback) {
|
||||||
return array_map($callback, $choices);
|
return new ArrayChoiceList(array_map($callback, $choices));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, 'property'));
|
$this->assertSame(['value' => 'value'], $this->factory->createListFromChoices($choices, 'property')->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateFromChoicesPropertyPathInstance()
|
public function testCreateFromChoicesPropertyPathInstance()
|
||||||
@ -59,10 +61,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
->with($choices, $this->isInstanceOf('\Closure'))
|
->with($choices, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($choices, $callback) {
|
->willReturnCallback(function ($choices, $callback) {
|
||||||
return array_map($callback, $choices);
|
return new ArrayChoiceList(array_map($callback, $choices));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame(['value'], $this->factory->createListFromChoices($choices, new PropertyPath('property')));
|
$this->assertSame(['value' => 'value'], $this->factory->createListFromChoices($choices, new PropertyPath('property'))->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,10 +90,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createListFromLoader')
|
->method('createListFromLoader')
|
||||||
->with($loader, $this->isInstanceOf('\Closure'))
|
->with($loader, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($loader, $callback) {
|
->willReturnCallback(function ($loader, $callback) {
|
||||||
return $callback((object) ['property' => 'value']);
|
return new ArrayChoiceList((array) $callback((object) ['property' => 'value']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('value', $this->factory->createListFromLoader($loader, 'property'));
|
$this->assertSame(['value' => 'value'], $this->factory->createListFromLoader($loader, 'property')->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,10 +120,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createListFromChoices')
|
->method('createListFromChoices')
|
||||||
->with($choices, $this->isInstanceOf('\Closure'))
|
->with($choices, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($choices, $callback) {
|
->willReturnCallback(function ($choices, $callback) {
|
||||||
return array_map($callback, $choices);
|
return new ArrayChoiceList(array_map($callback, $choices));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame([null], $this->factory->createListFromChoices($choices, 'property'));
|
$this->assertSame([null], $this->factory->createListFromChoices($choices, 'property')->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/symfony/symfony/issues/5494
|
// https://github.com/symfony/symfony/issues/5494
|
||||||
@ -133,10 +135,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createListFromLoader')
|
->method('createListFromLoader')
|
||||||
->with($loader, $this->isInstanceOf('\Closure'))
|
->with($loader, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($loader, $callback) {
|
->willReturnCallback(function ($loader, $callback) {
|
||||||
return $callback(null);
|
return new ArrayChoiceList((array) $callback(null));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertNull($this->factory->createListFromLoader($loader, 'property'));
|
$this->assertSame([], $this->factory->createListFromLoader($loader, 'property')->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateFromLoaderPropertyPathInstance()
|
public function testCreateFromLoaderPropertyPathInstance()
|
||||||
@ -147,10 +149,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createListFromLoader')
|
->method('createListFromLoader')
|
||||||
->with($loader, $this->isInstanceOf('\Closure'))
|
->with($loader, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($loader, $callback) {
|
->willReturnCallback(function ($loader, $callback) {
|
||||||
return $callback((object) ['property' => 'value']);
|
return new ArrayChoiceList((array) $callback((object) ['property' => 'value']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('value', $this->factory->createListFromLoader($loader, new PropertyPath('property')));
|
$this->assertSame(['value' => 'value'], $this->factory->createListFromLoader($loader, new PropertyPath('property'))->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateViewPreferredChoicesAsPropertyPath()
|
public function testCreateViewPreferredChoicesAsPropertyPath()
|
||||||
@ -161,13 +163,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, $this->isInstanceOf('\Closure'))
|
->with($list, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred) {
|
->willReturnCallback(function ($list, $preferred) {
|
||||||
return $preferred((object) ['property' => true]);
|
return new ChoiceListView((array) $preferred((object) ['property' => true]));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertTrue($this->factory->createView(
|
$this->assertSame([true], $this->factory->createView($list, 'property')->choices);
|
||||||
$list,
|
|
||||||
'property'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,13 +195,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, $this->isInstanceOf('\Closure'))
|
->with($list, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred) {
|
->willReturnCallback(function ($list, $preferred) {
|
||||||
return $preferred((object) ['property' => true]);
|
return new ChoiceListView((array) $preferred((object) ['property' => true]));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertTrue($this->factory->createView(
|
$this->assertSame([true], $this->factory->createView($list, 'property')->choices);
|
||||||
$list,
|
|
||||||
new PropertyPath('property')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/symfony/symfony/issues/5494
|
// https://github.com/symfony/symfony/issues/5494
|
||||||
@ -214,13 +210,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, $this->isInstanceOf('\Closure'))
|
->with($list, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred) {
|
->willReturnCallback(function ($list, $preferred) {
|
||||||
return $preferred((object) ['category' => null]);
|
return new ChoiceListView((array) $preferred((object) ['category' => null]));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertFalse($this->factory->createView(
|
$this->assertSame([false], $this->factory->createView($list, 'category.preferred')->choices);
|
||||||
$list,
|
|
||||||
'category.preferred'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateViewLabelsAsPropertyPath()
|
public function testCreateViewLabelsAsPropertyPath()
|
||||||
@ -231,14 +224,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label) {
|
->willReturnCallback(function ($list, $preferred, $label) {
|
||||||
return $label((object) ['property' => 'label']);
|
return new ChoiceListView((array) $label((object) ['property' => 'label']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('label', $this->factory->createView(
|
$this->assertSame(['label'], $this->factory->createView($list, null, 'property')->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
'property'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,14 +257,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label) {
|
->willReturnCallback(function ($list, $preferred, $label) {
|
||||||
return $label((object) ['property' => 'label']);
|
return new ChoiceListView((array) $label((object) ['property' => 'label']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('label', $this->factory->createView(
|
$this->assertSame(['label'], $this->factory->createView($list, null, new PropertyPath('property'))->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
new PropertyPath('property')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateViewIndicesAsPropertyPath()
|
public function testCreateViewIndicesAsPropertyPath()
|
||||||
@ -286,15 +271,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index) {
|
->willReturnCallback(function ($list, $preferred, $label, $index) {
|
||||||
return $index((object) ['property' => 'index']);
|
return new ChoiceListView((array) $index((object) ['property' => 'index']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('index', $this->factory->createView(
|
$this->assertSame(['index'], $this->factory->createView($list, null, null, 'property')->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
'property'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -325,15 +305,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index) {
|
->willReturnCallback(function ($list, $preferred, $label, $index) {
|
||||||
return $index((object) ['property' => 'index']);
|
return new ChoiceListView((array) $index((object) ['property' => 'index']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('index', $this->factory->createView(
|
$this->assertSame(['index'], $this->factory->createView($list, null, null, new PropertyPath('property'))->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
new PropertyPath('property')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateViewGroupsAsPropertyPath()
|
public function testCreateViewGroupsAsPropertyPath()
|
||||||
@ -344,16 +319,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
||||||
return $groupBy((object) ['property' => 'group']);
|
return new ChoiceListView((array) $groupBy((object) ['property' => 'group']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('group', $this->factory->createView(
|
$this->assertSame(['group'], $this->factory->createView($list, null, null, null, 'property')->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
null, // index
|
|
||||||
'property'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -385,16 +354,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
||||||
return $groupBy((object) ['property' => 'group']);
|
return new ChoiceListView((array) $groupBy((object) ['property' => 'group']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('group', $this->factory->createView(
|
$this->assertSame(['group'], $this->factory->createView($list, null, null, null, new PropertyPath('property'))->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
null, // index
|
|
||||||
new PropertyPath('property')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/symfony/symfony/issues/5494
|
// https://github.com/symfony/symfony/issues/5494
|
||||||
@ -406,16 +369,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
|
||||||
return $groupBy((object) ['group' => null]);
|
return new ChoiceListView((array) $groupBy((object) ['group' => null]));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertNull($this->factory->createView(
|
$this->assertSame([], $this->factory->createView($list, null, null, null, 'group.name')->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
null, // index
|
|
||||||
'group.name'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateViewAttrAsPropertyPath()
|
public function testCreateViewAttrAsPropertyPath()
|
||||||
@ -426,17 +383,10 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
|
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
|
||||||
return $attr((object) ['property' => 'attr']);
|
return new ChoiceListView((array) $attr((object) ['property' => 'attr']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('attr', $this->factory->createView(
|
$this->assertSame(['attr'], $this->factory->createView($list, null, null, null, null, 'property')->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
null, // index
|
|
||||||
null, // groups
|
|
||||||
'property'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -469,16 +419,9 @@ class PropertyAccessDecoratorTest extends TestCase
|
|||||||
->method('createView')
|
->method('createView')
|
||||||
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
|
->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
|
||||||
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
|
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
|
||||||
return $attr((object) ['property' => 'attr']);
|
return new ChoiceListView((array) $attr((object) ['property' => 'attr']));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->assertSame('attr', $this->factory->createView(
|
$this->assertSame(['attr'], $this->factory->createView($list, null, null, null, null, new PropertyPath('property'))->choices);
|
||||||
$list,
|
|
||||||
null, // preferred choices
|
|
||||||
null, // label
|
|
||||||
null, // index
|
|
||||||
null, // groups
|
|
||||||
new PropertyPath('property')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,10 @@ class LazyChoiceListTest extends TestCase
|
|||||||
// The same list is returned by the loader
|
// The same list is returned by the loader
|
||||||
$this->loadedList->expects($this->exactly(2))
|
$this->loadedList->expects($this->exactly(2))
|
||||||
->method('getChoices')
|
->method('getChoices')
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getChoices());
|
$this->assertSame(['RESULT'], $this->list->getChoices());
|
||||||
$this->assertSame('RESULT', $this->list->getChoices());
|
$this->assertSame(['RESULT'], $this->list->getChoices());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,10 +96,10 @@ class LazyChoiceListTest extends TestCase
|
|||||||
// The same list is returned by the loader
|
// The same list is returned by the loader
|
||||||
$this->loadedList->expects($this->exactly(2))
|
$this->loadedList->expects($this->exactly(2))
|
||||||
->method('getValues')
|
->method('getValues')
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getValues());
|
$this->assertSame(['RESULT'], $this->list->getValues());
|
||||||
$this->assertSame('RESULT', $this->list->getValues());
|
$this->assertSame(['RESULT'], $this->list->getValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetStructuredValuesLoadsLoadedListOnFirstCall()
|
public function testGetStructuredValuesLoadsLoadedListOnFirstCall()
|
||||||
@ -112,10 +112,10 @@ class LazyChoiceListTest extends TestCase
|
|||||||
// The same list is returned by the loader
|
// The same list is returned by the loader
|
||||||
$this->loadedList->expects($this->exactly(2))
|
$this->loadedList->expects($this->exactly(2))
|
||||||
->method('getStructuredValues')
|
->method('getStructuredValues')
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getStructuredValues());
|
$this->assertSame(['RESULT'], $this->list->getStructuredValues());
|
||||||
$this->assertSame('RESULT', $this->list->getStructuredValues());
|
$this->assertSame(['RESULT'], $this->list->getStructuredValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetOriginalKeysLoadsLoadedListOnFirstCall()
|
public function testGetOriginalKeysLoadsLoadedListOnFirstCall()
|
||||||
@ -128,10 +128,10 @@ class LazyChoiceListTest extends TestCase
|
|||||||
// The same list is returned by the loader
|
// The same list is returned by the loader
|
||||||
$this->loadedList->expects($this->exactly(2))
|
$this->loadedList->expects($this->exactly(2))
|
||||||
->method('getOriginalKeys')
|
->method('getOriginalKeys')
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getOriginalKeys());
|
$this->assertSame(['RESULT'], $this->list->getOriginalKeys());
|
||||||
$this->assertSame('RESULT', $this->list->getOriginalKeys());
|
$this->assertSame(['RESULT'], $this->list->getOriginalKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetChoicesForValuesForwardsCallIfListNotLoaded()
|
public function testGetChoicesForValuesForwardsCallIfListNotLoaded()
|
||||||
@ -139,10 +139,10 @@ class LazyChoiceListTest extends TestCase
|
|||||||
$this->loader->expects($this->exactly(2))
|
$this->loader->expects($this->exactly(2))
|
||||||
->method('loadChoicesForValues')
|
->method('loadChoicesForValues')
|
||||||
->with(['a', 'b'])
|
->with(['a', 'b'])
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
|
$this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b']));
|
||||||
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
|
$this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetChoicesForValuesUsesLoadedList()
|
public function testGetChoicesForValuesUsesLoadedList()
|
||||||
@ -160,13 +160,13 @@ class LazyChoiceListTest extends TestCase
|
|||||||
$this->loadedList->expects($this->exactly(2))
|
$this->loadedList->expects($this->exactly(2))
|
||||||
->method('getChoicesForValues')
|
->method('getChoicesForValues')
|
||||||
->with(['a', 'b'])
|
->with(['a', 'b'])
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
// load choice list
|
// load choice list
|
||||||
$this->list->getChoices();
|
$this->list->getChoices();
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
|
$this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b']));
|
||||||
$this->assertSame('RESULT', $this->list->getChoicesForValues(['a', 'b']));
|
$this->assertSame(['RESULT'], $this->list->getChoicesForValues(['a', 'b']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,12 +198,12 @@ class LazyChoiceListTest extends TestCase
|
|||||||
$this->loadedList->expects($this->exactly(2))
|
$this->loadedList->expects($this->exactly(2))
|
||||||
->method('getValuesForChoices')
|
->method('getValuesForChoices')
|
||||||
->with(['a', 'b'])
|
->with(['a', 'b'])
|
||||||
->willReturn('RESULT');
|
->willReturn(['RESULT']);
|
||||||
|
|
||||||
// load choice list
|
// load choice list
|
||||||
$this->list->getChoices();
|
$this->list->getChoices();
|
||||||
|
|
||||||
$this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b']));
|
$this->assertSame(['RESULT'], $this->list->getValuesForChoices(['a', 'b']));
|
||||||
$this->assertSame('RESULT', $this->list->getValuesForChoices(['a', 'b']));
|
$this->assertSame(['RESULT'], $this->list->getValuesForChoices(['a', 'b']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
$this->tokenManager->expects($this->once())
|
$this->tokenManager->expects($this->once())
|
||||||
->method('getToken')
|
->method('getToken')
|
||||||
->with('FORM_NAME')
|
->with('FORM_NAME')
|
||||||
->willReturn('token');
|
->willReturn(new CsrfToken('TOKEN_ID', 'token'));
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
->createNamed('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||||
@ -160,7 +160,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||||||
$this->tokenManager->expects($this->once())
|
$this->tokenManager->expects($this->once())
|
||||||
->method('getToken')
|
->method('getToken')
|
||||||
->with('Symfony\Component\Form\Extension\Core\Type\FormType')
|
->with('Symfony\Component\Form\Extension\Core\Type\FormType')
|
||||||
->willReturn('token');
|
->willReturn(new CsrfToken('TOKEN_ID', 'token'));
|
||||||
|
|
||||||
$view = $this->factory
|
$view = $this->factory
|
||||||
->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
->createNamed('', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, [
|
||||||
|
@ -16,6 +16,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||||
use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor;
|
use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
@ -57,7 +58,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getInnerType')
|
->method('getInnerType')
|
||||||
->willReturn(new \stdClass());
|
->willReturn(new HiddenType());
|
||||||
|
|
||||||
$form = $this->createBuilder('name')
|
$form = $this->createBuilder('name')
|
||||||
->setType($type)
|
->setType($type)
|
||||||
@ -66,7 +67,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$this->assertSame([
|
$this->assertSame([
|
||||||
'id' => 'name',
|
'id' => 'name',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'type_class' => 'stdClass',
|
'type_class' => HiddenType::class,
|
||||||
'synchronized' => true,
|
'synchronized' => true,
|
||||||
'passed_options' => [],
|
'passed_options' => [],
|
||||||
'resolved_options' => [],
|
'resolved_options' => [],
|
||||||
@ -78,7 +79,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getInnerType')
|
->method('getInnerType')
|
||||||
->willReturn(new \stdClass());
|
->willReturn(new HiddenType());
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'b' => 'foo',
|
'b' => 'foo',
|
||||||
@ -96,7 +97,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$this->assertSame([
|
$this->assertSame([
|
||||||
'id' => 'name',
|
'id' => 'name',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'type_class' => 'stdClass',
|
'type_class' => HiddenType::class,
|
||||||
'synchronized' => true,
|
'synchronized' => true,
|
||||||
'passed_options' => [
|
'passed_options' => [
|
||||||
'a' => 'bar',
|
'a' => 'bar',
|
||||||
@ -112,7 +113,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getInnerType')
|
->method('getInnerType')
|
||||||
->willReturn(new \stdClass());
|
->willReturn(new HiddenType());
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'b' => 'foo',
|
'b' => 'foo',
|
||||||
@ -127,7 +128,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$this->assertSame([
|
$this->assertSame([
|
||||||
'id' => 'name',
|
'id' => 'name',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'type_class' => 'stdClass',
|
'type_class' => HiddenType::class,
|
||||||
'synchronized' => true,
|
'synchronized' => true,
|
||||||
'passed_options' => [],
|
'passed_options' => [],
|
||||||
'resolved_options' => [
|
'resolved_options' => [
|
||||||
@ -143,7 +144,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getInnerType')
|
->method('getInnerType')
|
||||||
->willReturn(new \stdClass());
|
->willReturn(new HiddenType());
|
||||||
|
|
||||||
$grandParent = $this->createBuilder('grandParent')
|
$grandParent = $this->createBuilder('grandParent')
|
||||||
->setCompound(true)
|
->setCompound(true)
|
||||||
@ -163,7 +164,7 @@ class FormDataExtractorTest extends TestCase
|
|||||||
$this->assertSame([
|
$this->assertSame([
|
||||||
'id' => 'grandParent_parent_name',
|
'id' => 'grandParent_parent_name',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'type_class' => 'stdClass',
|
'type_class' => HiddenType::class,
|
||||||
'synchronized' => true,
|
'synchronized' => true,
|
||||||
'passed_options' => [],
|
'passed_options' => [],
|
||||||
'resolved_options' => [],
|
'resolved_options' => [],
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Tests;
|
|||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Form\FormFactory;
|
use Symfony\Component\Form\FormFactory;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormTypeGuesserChain;
|
use Symfony\Component\Form\FormTypeGuesserChain;
|
||||||
use Symfony\Component\Form\Guess\Guess;
|
use Symfony\Component\Form\Guess\Guess;
|
||||||
use Symfony\Component\Form\Guess\TypeGuess;
|
use Symfony\Component\Form\Guess\TypeGuess;
|
||||||
@ -193,11 +194,13 @@ class FormFactoryTest extends TestCase
|
|||||||
->method('buildForm')
|
->method('buildForm')
|
||||||
->with($this->builder, $resolvedOptions);
|
->with($this->builder, $resolvedOptions);
|
||||||
|
|
||||||
|
$form = $this->createMock(FormInterface::class);
|
||||||
|
|
||||||
$this->builder->expects($this->once())
|
$this->builder->expects($this->once())
|
||||||
->method('getForm')
|
->method('getForm')
|
||||||
->willReturn('FORM');
|
->willReturn($form);
|
||||||
|
|
||||||
$this->assertSame('FORM', $this->factory->create('TYPE', null, $options));
|
$this->assertSame($form, $this->factory->create('TYPE', null, $options));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateNamed()
|
public function testCreateNamed()
|
||||||
@ -224,11 +227,13 @@ class FormFactoryTest extends TestCase
|
|||||||
->method('buildForm')
|
->method('buildForm')
|
||||||
->with($this->builder, $resolvedOptions);
|
->with($this->builder, $resolvedOptions);
|
||||||
|
|
||||||
|
$form = $this->createMock(FormInterface::class);
|
||||||
|
|
||||||
$this->builder->expects($this->once())
|
$this->builder->expects($this->once())
|
||||||
->method('getForm')
|
->method('getForm')
|
||||||
->willReturn('FORM');
|
->willReturn($form);
|
||||||
|
|
||||||
$this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options));
|
$this->assertSame($form, $this->factory->createNamed('name', 'type', null, $options));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderForPropertyWithoutTypeGuesser()
|
public function testCreateBuilderForPropertyWithoutTypeGuesser()
|
||||||
@ -242,11 +247,11 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence()
|
public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence()
|
||||||
@ -274,11 +279,11 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\PasswordType', null, ['attr' => ['maxlength' => 7]])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderCreatesTextFormIfNoGuess()
|
public function testCreateBuilderCreatesTextFormIfNoGuess()
|
||||||
@ -293,11 +298,11 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
$this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName');
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptionsCanBeOverridden()
|
public function testOptionsCanBeOverridden()
|
||||||
@ -316,7 +321,7 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['class' => 'foo', 'maxlength' => 11]])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty(
|
$this->builder = $factory->createBuilderForProperty(
|
||||||
'Application\Author',
|
'Application\Author',
|
||||||
@ -325,7 +330,7 @@ class FormFactoryTest extends TestCase
|
|||||||
['attr' => ['maxlength' => 11]]
|
['attr' => ['maxlength' => 11]]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderUsesMaxLengthIfFound()
|
public function testCreateBuilderUsesMaxLengthIfFound()
|
||||||
@ -351,14 +356,14 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20]])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty(
|
$this->builder = $factory->createBuilderForProperty(
|
||||||
'Application\Author',
|
'Application\Author',
|
||||||
'firstName'
|
'firstName'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderUsesMaxLengthAndPattern()
|
public function testCreateBuilderUsesMaxLengthAndPattern()
|
||||||
@ -384,7 +389,7 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce']])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty(
|
$this->builder = $factory->createBuilderForProperty(
|
||||||
'Application\Author',
|
'Application\Author',
|
||||||
@ -393,7 +398,7 @@ class FormFactoryTest extends TestCase
|
|||||||
['attr' => ['class' => 'tinymce']]
|
['attr' => ['class' => 'tinymce']]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderUsesRequiredSettingWithHighestConfidence()
|
public function testCreateBuilderUsesRequiredSettingWithHighestConfidence()
|
||||||
@ -419,14 +424,14 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['required' => false])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty(
|
$this->builder = $factory->createBuilderForProperty(
|
||||||
'Application\Author',
|
'Application\Author',
|
||||||
'firstName'
|
'firstName'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateBuilderUsesPatternIfFound()
|
public function testCreateBuilderUsesPatternIfFound()
|
||||||
@ -452,14 +457,14 @@ class FormFactoryTest extends TestCase
|
|||||||
$factory->expects($this->once())
|
$factory->expects($this->once())
|
||||||
->method('createNamedBuilder')
|
->method('createNamedBuilder')
|
||||||
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']])
|
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, ['attr' => ['pattern' => '[a-zA-Z]']])
|
||||||
->willReturn('builderInstance');
|
->willReturn($this->builder);
|
||||||
|
|
||||||
$this->builder = $factory->createBuilderForProperty(
|
$this->builder = $factory->createBuilderForProperty(
|
||||||
'Application\Author',
|
'Application\Author',
|
||||||
'firstName'
|
'firstName'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('builderInstance', $this->builder);
|
$this->assertSame($this->builder, $this->builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMockFactory(array $methods = [])
|
private function getMockFactory(array $methods = [])
|
||||||
|
@ -327,12 +327,12 @@ class BinaryFileResponse extends Response
|
|||||||
if (null !== $content) {
|
if (null !== $content) {
|
||||||
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
|
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return false
|
|
||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
|
@ -75,8 +75,8 @@ class FileBag extends ParameterBag
|
|||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $this->fixPhpFilesArray($file);
|
|
||||||
if (\is_array($file)) {
|
if (\is_array($file)) {
|
||||||
|
$file = $this->fixPhpFilesArray($file);
|
||||||
$keys = array_keys($file);
|
$keys = array_keys($file);
|
||||||
sort($keys);
|
sort($keys);
|
||||||
|
|
||||||
@ -109,14 +109,12 @@ class FileBag extends ParameterBag
|
|||||||
* It's safe to pass an already converted array, in which case this method
|
* It's safe to pass an already converted array, in which case this method
|
||||||
* just returns the original array unmodified.
|
* just returns the original array unmodified.
|
||||||
*
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function fixPhpFilesArray($data)
|
protected function fixPhpFilesArray($data)
|
||||||
{
|
{
|
||||||
if (!\is_array($data)) {
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
$keys = array_keys($data);
|
$keys = array_keys($data);
|
||||||
sort($keys);
|
sort($keys);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($first) {
|
if ($first) {
|
||||||
return \count($headers[$key]) ? $headers[$key][0] : $default;
|
return \count($headers[$key]) ? (string) $headers[$key][0] : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $headers[$key];
|
return $headers[$key];
|
||||||
|
@ -528,6 +528,10 @@ class Request
|
|||||||
try {
|
try {
|
||||||
$content = $this->getContent();
|
$content = $this->getContent();
|
||||||
} catch (\LogicException $e) {
|
} catch (\LogicException $e) {
|
||||||
|
if (\PHP_VERSION_ID >= 70400) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
return trigger_error($e, E_USER_ERROR);
|
return trigger_error($e, E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -912,7 +916,7 @@ class Request
|
|||||||
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
|
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
|
||||||
* argument of the Request::setTrustedProxies() method instead.
|
* argument of the Request::setTrustedProxies() method instead.
|
||||||
*
|
*
|
||||||
* @return string The client IP address
|
* @return string|null The client IP address
|
||||||
*
|
*
|
||||||
* @see getClientIps()
|
* @see getClientIps()
|
||||||
* @see https://wikipedia.org/wiki/X-Forwarded-For
|
* @see https://wikipedia.org/wiki/X-Forwarded-For
|
||||||
|
@ -407,7 +407,7 @@ class Response
|
|||||||
/**
|
/**
|
||||||
* Gets the current response content.
|
* Gets the current response content.
|
||||||
*
|
*
|
||||||
* @return string Content
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ class NamespacedAttributeBag extends AttributeBag
|
|||||||
* @param string $name Key name
|
* @param string $name Key name
|
||||||
* @param bool $writeContext Write context, default false
|
* @param bool $writeContext Write context, default false
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
protected function &resolveAttributePath($name, $writeContext = false)
|
protected function &resolveAttributePath($name, $writeContext = false)
|
||||||
{
|
{
|
||||||
|
@ -40,9 +40,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
|||||||
* * prefix: The prefix to use for the memcached keys in order to avoid collision
|
* * prefix: The prefix to use for the memcached keys in order to avoid collision
|
||||||
* * expiretime: The time to live in seconds.
|
* * expiretime: The time to live in seconds.
|
||||||
*
|
*
|
||||||
* @param \Memcached $memcached A \Memcached instance
|
|
||||||
* @param array $options An associative array of Memcached options
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException When unsupported options are passed
|
* @throws \InvalidArgumentException When unsupported options are passed
|
||||||
*/
|
*/
|
||||||
public function __construct(\Memcached $memcached, array $options = [])
|
public function __construct(\Memcached $memcached, array $options = [])
|
||||||
@ -58,7 +55,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
@ -74,7 +71,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateTimestamp($sessionId, $data)
|
public function updateTimestamp($sessionId, $data)
|
||||||
{
|
{
|
||||||
@ -102,7 +99,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ class NullSessionHandler extends AbstractSessionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
|
@ -286,7 +286,7 @@ class PdoSessionHandler extends AbstractSessionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ class StrictSessionHandler extends AbstractSessionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ abstract class AbstractProxy
|
|||||||
/**
|
/**
|
||||||
* Gets the session.save_handler name.
|
* Gets the session.save_handler name.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function getSaveHandlerName()
|
public function getSaveHandlerName()
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function gc($maxlifetime)
|
public function gc($maxlifetime)
|
||||||
{
|
{
|
||||||
|
@ -136,8 +136,6 @@ class StreamedResponse extends Response
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return false
|
|
||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ class BinaryFileResponseTest extends ResponseTestCase
|
|||||||
|
|
||||||
$this->assertEquals(206, $response->getStatusCode());
|
$this->assertEquals(206, $response->getStatusCode());
|
||||||
$this->assertEquals($responseRange, $response->headers->get('Content-Range'));
|
$this->assertEquals($responseRange, $response->headers->get('Content-Range'));
|
||||||
$this->assertSame($length, $response->headers->get('Content-Length'));
|
$this->assertSame((string) $length, $response->headers->get('Content-Length'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +144,8 @@ class SessionHandlerProxyTest extends TestCase
|
|||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
|
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
|
||||||
$mock->expects($this->once())
|
$mock->expects($this->once())
|
||||||
->method('updateTimestamp');
|
->method('updateTimestamp')
|
||||||
|
->willReturn(false);
|
||||||
|
|
||||||
$proxy = new SessionHandlerProxy($mock);
|
$proxy = new SessionHandlerProxy($mock);
|
||||||
$proxy->updateTimestamp('id', 'data');
|
$proxy->updateTimestamp('id', 'data');
|
||||||
|
@ -85,10 +85,10 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$callable = $this->createController($controller);
|
try {
|
||||||
|
$callable = $this->createController($controller);
|
||||||
if (!\is_callable($callable)) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable)));
|
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $callable;
|
return $callable;
|
||||||
@ -165,7 +165,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
*
|
*
|
||||||
* @return callable A PHP callable
|
* @return callable A PHP callable
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException When the controller cannot be created
|
||||||
*/
|
*/
|
||||||
protected function createController($controller)
|
protected function createController($controller)
|
||||||
{
|
{
|
||||||
@ -179,7 +179,13 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$this->instantiateController($class), $method];
|
$controller = [$this->instantiateController($class), $method];
|
||||||
|
|
||||||
|
if (!\is_callable($controller)) {
|
||||||
|
throw new \InvalidArgumentException($this->getControllerError($controller));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ class ArgumentMetadata
|
|||||||
*
|
*
|
||||||
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
|
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,7 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
|||||||
/**
|
/**
|
||||||
* Gets the token.
|
* Gets the token.
|
||||||
*
|
*
|
||||||
* @return string The token
|
* @return string|null The token
|
||||||
*/
|
*/
|
||||||
public function getToken()
|
public function getToken()
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ class ExceptionDataCollector extends DataCollector
|
|||||||
/**
|
/**
|
||||||
* Gets the exception.
|
* Gets the exception.
|
||||||
*
|
*
|
||||||
* @return \Exception The exception
|
* @return \Exception|FlattenException
|
||||||
*/
|
*/
|
||||||
public function getException()
|
public function getException()
|
||||||
{
|
{
|
||||||
|
@ -72,11 +72,6 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the logs.
|
|
||||||
*
|
|
||||||
* @return array An array of logs
|
|
||||||
*/
|
|
||||||
public function getLogs()
|
public function getLogs()
|
||||||
{
|
{
|
||||||
return isset($this->data['logs']) ? $this->data['logs'] : [];
|
return isset($this->data['logs']) ? $this->data['logs'] : [];
|
||||||
|
@ -132,7 +132,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
|||||||
/**
|
/**
|
||||||
* Gets the request time.
|
* Gets the request time.
|
||||||
*
|
*
|
||||||
* @return int The time
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getStartTime()
|
public function getStartTime()
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,7 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +95,6 @@ class Ssi extends AbstractSurrogate
|
|||||||
// remove SSI/1.0 from the Surrogate-Control header
|
// remove SSI/1.0 from the Surrogate-Control header
|
||||||
$this->removeFromControl($response);
|
$this->removeFromControl($response);
|
||||||
|
|
||||||
return null;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
/**
|
/**
|
||||||
* Gets a HTTP kernel from the container.
|
* Gets a HTTP kernel from the container.
|
||||||
*
|
*
|
||||||
* @return HttpKernel
|
* @return HttpKernelInterface
|
||||||
*/
|
*/
|
||||||
protected function getHttpKernel()
|
protected function getHttpKernel()
|
||||||
{
|
{
|
||||||
@ -425,7 +425,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
*/
|
*/
|
||||||
public function getStartTime()
|
public function getStartTime()
|
||||||
{
|
{
|
||||||
return $this->debug ? $this->startTime : -INF;
|
return $this->debug && null !== $this->startTime ? $this->startTime : -INF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +138,7 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
|||||||
/**
|
/**
|
||||||
* Gets the request start time (not available if debug is disabled).
|
* Gets the request start time (not available if debug is disabled).
|
||||||
*
|
*
|
||||||
* @return int The request start timestamp
|
* @return float The request start timestamp
|
||||||
*/
|
*/
|
||||||
public function getStartTime();
|
public function getStartTime();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class Profile
|
|||||||
/**
|
/**
|
||||||
* Returns the IP.
|
* Returns the IP.
|
||||||
*
|
*
|
||||||
* @return string The IP
|
* @return string|null The IP
|
||||||
*/
|
*/
|
||||||
public function getIp()
|
public function getIp()
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ class Profile
|
|||||||
/**
|
/**
|
||||||
* Returns the request method.
|
* Returns the request method.
|
||||||
*
|
*
|
||||||
* @return string The request method
|
* @return string|null The request method
|
||||||
*/
|
*/
|
||||||
public function getMethod()
|
public function getMethod()
|
||||||
{
|
{
|
||||||
@ -137,13 +137,16 @@ class Profile
|
|||||||
/**
|
/**
|
||||||
* Returns the URL.
|
* Returns the URL.
|
||||||
*
|
*
|
||||||
* @return string The URL
|
* @return string|null The URL
|
||||||
*/
|
*/
|
||||||
public function getUrl()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $url
|
||||||
|
*/
|
||||||
public function setUrl($url)
|
public function setUrl($url)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
@ -180,7 +183,7 @@ class Profile
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public function getStatusCode()
|
public function getStatusCode()
|
||||||
{
|
{
|
||||||
|
@ -65,12 +65,12 @@ class Profiler
|
|||||||
/**
|
/**
|
||||||
* Loads the Profile for the given Response.
|
* Loads the Profile for the given Response.
|
||||||
*
|
*
|
||||||
* @return Profile|false A Profile instance
|
* @return Profile|null A Profile instance
|
||||||
*/
|
*/
|
||||||
public function loadProfileFromResponse(Response $response)
|
public function loadProfileFromResponse(Response $response)
|
||||||
{
|
{
|
||||||
if (!$token = $response->headers->get('X-Debug-Token')) {
|
if (!$token = $response->headers->get('X-Debug-Token')) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->loadProfile($token);
|
return $this->loadProfile($token);
|
||||||
@ -81,7 +81,7 @@ class Profiler
|
|||||||
*
|
*
|
||||||
* @param string $token A token
|
* @param string $token A token
|
||||||
*
|
*
|
||||||
* @return Profile A Profile instance
|
* @return Profile|null A Profile instance
|
||||||
*/
|
*/
|
||||||
public function loadProfile($token)
|
public function loadProfile($token)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,9 @@ class BundleTest extends TestCase
|
|||||||
$this->assertNull($bundle2->registerCommands($app));
|
$this->assertNull($bundle2->registerCommands($app));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testGetContainerExtensionWithInvalidClass()
|
public function testGetContainerExtensionWithInvalidClass()
|
||||||
{
|
{
|
||||||
$this->expectException('LogicException');
|
$this->expectException('LogicException');
|
||||||
|
@ -23,7 +23,7 @@ class LoggerDataCollectorTest extends TestCase
|
|||||||
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
||||||
->setMethods(['countErrors', 'getLogs', 'clear'])
|
->setMethods(['countErrors', 'getLogs', 'clear'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$logger->expects($this->once())->method('countErrors')->willReturn('foo');
|
$logger->expects($this->once())->method('countErrors')->willReturn(123);
|
||||||
$logger->expects($this->exactly(2))->method('getLogs')->willReturn([]);
|
$logger->expects($this->exactly(2))->method('getLogs')->willReturn([]);
|
||||||
|
|
||||||
$c = new LoggerDataCollector($logger, __DIR__.'/');
|
$c = new LoggerDataCollector($logger, __DIR__.'/');
|
||||||
|
@ -44,7 +44,7 @@ class TimeDataCollectorTest extends TestCase
|
|||||||
$this->assertEquals(0, $c->getStartTime());
|
$this->assertEquals(0, $c->getStartTime());
|
||||||
|
|
||||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||||
$kernel->expects($this->once())->method('getStartTime')->willReturn(123456);
|
$kernel->expects($this->once())->method('getStartTime')->willReturn(123456.0);
|
||||||
|
|
||||||
$c = new TimeDataCollector($kernel);
|
$c = new TimeDataCollector($kernel);
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
|
@ -22,6 +22,7 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
|||||||
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
|
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
|
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
|
||||||
|
use Symfony\Component\HttpKernel\HttpKernel;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
|
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
|
||||||
@ -720,8 +721,8 @@ EOF;
|
|||||||
{
|
{
|
||||||
$this->expectException('LogicException');
|
$this->expectException('LogicException');
|
||||||
$this->expectExceptionMessage('Trying to register two bundles with the same name "DuplicateName"');
|
$this->expectExceptionMessage('Trying to register two bundles with the same name "DuplicateName"');
|
||||||
$fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName');
|
$fooBundle = $this->getBundle(__DIR__.'/Fixtures/FooBundle', null, 'FooBundle', 'DuplicateName');
|
||||||
$barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName');
|
$barBundle = $this->getBundle(__DIR__.'/Fixtures/BarBundle', null, 'BarBundle', 'DuplicateName');
|
||||||
|
|
||||||
$kernel = $this->getKernel([], [$fooBundle, $barBundle]);
|
$kernel = $this->getKernel([], [$fooBundle, $barBundle]);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
@ -22,6 +22,9 @@ class Logger implements LoggerInterface
|
|||||||
$this->clear();
|
$this->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getLogs($level = false)
|
public function getLogs($level = false)
|
||||||
{
|
{
|
||||||
return false === $level ? $this->logs : $this->logs[$level];
|
return false === $level ? $this->logs : $this->logs[$level];
|
||||||
|
@ -415,7 +415,7 @@ class IntlDateFormatter
|
|||||||
* contain -1 otherwise it will contain the position at which parsing
|
* contain -1 otherwise it will contain the position at which parsing
|
||||||
* ended. If $parse_pos > strlen($value), the parse fails immediately.
|
* ended. If $parse_pos > strlen($value), the parse fails immediately.
|
||||||
*
|
*
|
||||||
* @return int Parsed value as a timestamp
|
* @return int|false Parsed value as a timestamp
|
||||||
*
|
*
|
||||||
* @see https://php.net/intldateformatter.parse
|
* @see https://php.net/intldateformatter.parse
|
||||||
*
|
*
|
||||||
|
@ -71,7 +71,7 @@ class Process implements \IteratorAggregate
|
|||||||
private $status = self::STATUS_READY;
|
private $status = self::STATUS_READY;
|
||||||
private $incrementalOutputOffset = 0;
|
private $incrementalOutputOffset = 0;
|
||||||
private $incrementalErrorOutputOffset = 0;
|
private $incrementalErrorOutputOffset = 0;
|
||||||
private $tty;
|
private $tty = false;
|
||||||
private $pty;
|
private $pty;
|
||||||
private $inheritEnv = false;
|
private $inheritEnv = false;
|
||||||
|
|
||||||
@ -864,7 +864,7 @@ class Process implements \IteratorAggregate
|
|||||||
* @param int|float $timeout The timeout in seconds
|
* @param int|float $timeout The timeout in seconds
|
||||||
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
|
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
|
||||||
*
|
*
|
||||||
* @return int The exit-code of the process
|
* @return int|null The exit-code of the process or null if it's not running
|
||||||
*/
|
*/
|
||||||
public function stop($timeout = 10, $signal = null)
|
public function stop($timeout = 10, $signal = null)
|
||||||
{
|
{
|
||||||
|
@ -193,7 +193,7 @@ class PropertyPathBuilder
|
|||||||
/**
|
/**
|
||||||
* Returns the current property path.
|
* Returns the current property path.
|
||||||
*
|
*
|
||||||
* @return PropertyPathInterface The constructed property path
|
* @return PropertyPathInterface|null The constructed property path
|
||||||
*/
|
*/
|
||||||
public function getPropertyPath()
|
public function getPropertyPath()
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ interface PropertyPathInterface extends \Traversable
|
|||||||
*
|
*
|
||||||
* If this property path only contains one item, null is returned.
|
* If this property path only contains one item, null is returned.
|
||||||
*
|
*
|
||||||
* @return PropertyPath|null The parent path or null
|
* @return self|null The parent path or null
|
||||||
*/
|
*/
|
||||||
public function getParent();
|
public function getParent();
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
|
|||||||
{
|
{
|
||||||
$this->assertIsString($class);
|
$this->assertIsString($class);
|
||||||
$this->assertIsString($property);
|
$this->assertIsString($property);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +41,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
|
|||||||
{
|
{
|
||||||
$this->assertIsString($class);
|
$this->assertIsString($class);
|
||||||
$this->assertIsString($property);
|
$this->assertIsString($property);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +52,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
|
|||||||
{
|
{
|
||||||
$this->assertIsString($class);
|
$this->assertIsString($class);
|
||||||
$this->assertIsString($property);
|
$this->assertIsString($property);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,6 +63,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
|
|||||||
{
|
{
|
||||||
$this->assertIsString($class);
|
$this->assertIsString($class);
|
||||||
$this->assertIsString($property);
|
$this->assertIsString($property);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,6 +74,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
|
|||||||
{
|
{
|
||||||
$this->assertIsString($class);
|
$this->assertIsString($class);
|
||||||
$this->assertIsString($property);
|
$this->assertIsString($property);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,6 +84,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
|
|||||||
public function getProperties($class, array $context = [])
|
public function getProperties($class, array $context = [])
|
||||||
{
|
{
|
||||||
$this->assertIsString($class);
|
$this->assertIsString($class);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertIsString($string)
|
private function assertIsString($string)
|
||||||
|
@ -263,9 +263,9 @@ class Router implements RouterInterface, RequestMatcherInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the UrlMatcher instance associated with this Router.
|
* Gets the UrlMatcher or RequestMatcher instance associated with this Router.
|
||||||
*
|
*
|
||||||
* @return UrlMatcherInterface A UrlMatcherInterface instance
|
* @return UrlMatcherInterface|RequestMatcherInterface
|
||||||
*/
|
*/
|
||||||
public function getMatcher()
|
public function getMatcher()
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,9 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
|||||||
|
|
||||||
class DaoAuthenticationProviderTest extends TestCase
|
class DaoAuthenticationProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
|
public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
||||||
|
@ -62,6 +62,9 @@ class UserAuthenticationProviderTest extends TestCase
|
|||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
|
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationServiceException');
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
namespace Symfony\Component\Security\Guard\Tests\Provider;
|
namespace Symfony\Component\Security\Guard\Tests\Provider;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
||||||
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
|
use Symfony\Component\Security\Guard\Provider\GuardAuthenticationProvider;
|
||||||
|
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
|
||||||
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
|
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
|
||||||
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
|
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class GuardAuthenticationProviderTest extends TestCase
|
|||||||
->with($enteredCredentials, $mockedUser)
|
->with($enteredCredentials, $mockedUser)
|
||||||
// authentication works!
|
// authentication works!
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$authedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
|
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
|
||||||
$authenticatorB->expects($this->once())
|
$authenticatorB->expects($this->once())
|
||||||
->method('createAuthenticatedToken')
|
->method('createAuthenticatedToken')
|
||||||
->with($mockedUser, $providerKey)
|
->with($mockedUser, $providerKey)
|
||||||
@ -130,7 +130,7 @@ class GuardAuthenticationProviderTest extends TestCase
|
|||||||
->with($enteredCredentials, $mockedUser)
|
->with($enteredCredentials, $mockedUser)
|
||||||
// authentication works!
|
// authentication works!
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
$authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
|
$authedToken = $this->getMockBuilder(GuardTokenInterface::class)->getMock();
|
||||||
$authenticatorB->expects($this->once())
|
$authenticatorB->expects($this->once())
|
||||||
->method('createAuthenticatedToken')
|
->method('createAuthenticatedToken')
|
||||||
->with($mockedUser, $providerKey)
|
->with($mockedUser, $providerKey)
|
||||||
|
@ -31,7 +31,7 @@ interface AuthenticationSuccessHandlerInterface
|
|||||||
* is called by authentication listeners inheriting from
|
* is called by authentication listeners inheriting from
|
||||||
* AbstractAuthenticationListener.
|
* AbstractAuthenticationListener.
|
||||||
*
|
*
|
||||||
* @return Response never null
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token);
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ interface RememberMeServicesInterface
|
|||||||
* make sure to throw an AuthenticationException as this will consequentially
|
* make sure to throw an AuthenticationException as this will consequentially
|
||||||
* result in a call to loginFail() and therefore an invalidation of the cookie.
|
* result in a call to loginFail() and therefore an invalidation of the cookie.
|
||||||
*
|
*
|
||||||
* @return TokenInterface
|
* @return TokenInterface|null
|
||||||
*/
|
*/
|
||||||
public function autoLogin(Request $request);
|
public function autoLogin(Request $request);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Tests\Authentication;
|
namespace Symfony\Component\Security\Http\Tests\Authentication;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
@ -62,7 +63,7 @@ class DefaultAuthenticationFailureHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testRedirect()
|
public function testRedirect()
|
||||||
{
|
{
|
||||||
$response = new Response();
|
$response = new RedirectResponse('/login');
|
||||||
$this->httpUtils->expects($this->once())
|
$this->httpUtils->expects($this->once())
|
||||||
->method('createRedirectResponse')->with($this->request, '/login')
|
->method('createRedirectResponse')->with($this->request, '/login')
|
||||||
->willReturn($response);
|
->willReturn($response);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
|
namespace Symfony\Component\Security\Http\Tests\EntryPoint;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
|
use Symfony\Component\Security\Http\EntryPoint\FormAuthenticationEntryPoint;
|
||||||
@ -21,7 +22,7 @@ class FormAuthenticationEntryPointTest extends TestCase
|
|||||||
public function testStart()
|
public function testStart()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
|
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
|
||||||
$response = new Response();
|
$response = new RedirectResponse('/the/login/path');
|
||||||
|
|
||||||
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||||
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
||||||
|
@ -72,6 +72,9 @@ class ExceptionListenerTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testExceptionWhenEntryPointReturnsBadValue()
|
public function testExceptionWhenEntryPointReturnsBadValue()
|
||||||
{
|
{
|
||||||
$event = $this->createEvent(new AuthenticationException());
|
$event = $this->createEvent(new AuthenticationException());
|
||||||
|
@ -122,6 +122,9 @@ class LogoutListenerTest extends TestCase
|
|||||||
$listener->handle($event);
|
$listener->handle($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testSuccessHandlerReturnsNonResponse()
|
public function testSuccessHandlerReturnsNonResponse()
|
||||||
{
|
{
|
||||||
$this->expectException('RuntimeException');
|
$this->expectException('RuntimeException');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
@ -40,6 +41,10 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
|||||||
->method('checkRequestPath')
|
->method('checkRequestPath')
|
||||||
->willReturn(true)
|
->willReturn(true)
|
||||||
;
|
;
|
||||||
|
$httpUtils
|
||||||
|
->method('createRedirectResponse')
|
||||||
|
->willReturn(new RedirectResponse('/hello'))
|
||||||
|
;
|
||||||
|
|
||||||
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
|
$failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
|
||||||
$failureHandler
|
$failureHandler
|
||||||
@ -52,7 +57,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
|||||||
$authenticationManager
|
$authenticationManager
|
||||||
->expects($ok ? $this->once() : $this->never())
|
->expects($ok ? $this->once() : $this->never())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->willReturn(new Response())
|
->willReturnArgument(0)
|
||||||
;
|
;
|
||||||
|
|
||||||
$listener = new UsernamePasswordFormAuthenticationListener(
|
$listener = new UsernamePasswordFormAuthenticationListener(
|
||||||
@ -61,7 +66,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
|
|||||||
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
|
$this->getMockBuilder('Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(),
|
||||||
$httpUtils,
|
$httpUtils,
|
||||||
'TheProviderKey',
|
'TheProviderKey',
|
||||||
$this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(),
|
new DefaultAuthenticationSuccessHandler($httpUtils),
|
||||||
$failureHandler,
|
$failureHandler,
|
||||||
['require_previous_session' => false]
|
['require_previous_session' => false]
|
||||||
);
|
);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Tests\Logout;
|
namespace Symfony\Component\Security\Http\Tests\Logout;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
|
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
|
||||||
|
|
||||||
class DefaultLogoutSuccessHandlerTest extends TestCase
|
class DefaultLogoutSuccessHandlerTest extends TestCase
|
||||||
@ -20,7 +20,7 @@ class DefaultLogoutSuccessHandlerTest extends TestCase
|
|||||||
public function testLogout()
|
public function testLogout()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
||||||
$response = new Response();
|
$response = new RedirectResponse('/dashboard');
|
||||||
|
|
||||||
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
|
||||||
$httpUtils->expects($this->once())
|
$httpUtils->expects($this->once())
|
||||||
|
@ -39,6 +39,9 @@ class AbstractRememberMeServicesTest extends TestCase
|
|||||||
$this->assertNull($service->autoLogin(new Request()));
|
$this->assertNull($service->autoLogin(new Request()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
|
public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface()
|
||||||
{
|
{
|
||||||
$this->expectException('RuntimeException');
|
$this->expectException('RuntimeException');
|
||||||
|
@ -36,7 +36,7 @@ interface SerializerInterface
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $format
|
* @param string $format
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object|array
|
||||||
*/
|
*/
|
||||||
public function deserialize($data, $type, $format, array $context = []);
|
public function deserialize($data, $type, $format, array $context = []);
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|||||||
* @param mixed $value A variable to escape
|
* @param mixed $value A variable to escape
|
||||||
* @param string $context The context name
|
* @param string $context The context name
|
||||||
*
|
*
|
||||||
* @return string The escaped value
|
* @return mixed The escaped value
|
||||||
*/
|
*/
|
||||||
public function escape($value, $context = 'html')
|
public function escape($value, $context = 'html')
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array|Data
|
||||||
*/
|
*/
|
||||||
public function getMessages()
|
public function getMessages()
|
||||||
{
|
{
|
||||||
|
@ -21,9 +21,9 @@ use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
|||||||
abstract class AbstractFileExtractor
|
abstract class AbstractFileExtractor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string|array $resource Files, a file or a directory
|
* @param string|iterable $resource Files, a file or a directory
|
||||||
*
|
*
|
||||||
* @return array
|
* @return iterable
|
||||||
*/
|
*/
|
||||||
protected function extractFiles($resource)
|
protected function extractFiles($resource)
|
||||||
{
|
{
|
||||||
@ -79,7 +79,7 @@ abstract class AbstractFileExtractor
|
|||||||
/**
|
/**
|
||||||
* @param string|array $resource Files, a file or a directory
|
* @param string|array $resource Files, a file or a directory
|
||||||
*
|
*
|
||||||
* @return array files to be extracted
|
* @return iterable files to be extracted
|
||||||
*/
|
*/
|
||||||
abstract protected function extractFromDirectory($resource);
|
abstract protected function extractFromDirectory($resource);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
*
|
*
|
||||||
* @param mixed $token
|
* @param mixed $token
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
protected function normalizeToken($token)
|
protected function normalizeToken($token)
|
||||||
{
|
{
|
||||||
@ -257,9 +257,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array $directory
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
protected function extractFromDirectory($directory)
|
protected function extractFromDirectory($directory)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,10 @@ class YamlFileLoader extends FileLoader
|
|||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $messages;
|
if (null !== $messages && !\is_array($messages)) {
|
||||||
|
throw new InvalidResourceException(sprintf('Unable to load file "%s".', $resource));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $messages ?: [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ interface ExecutionContextInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the validation group that is currently being validated.
|
* Returns the validation group that is currently being validated.
|
||||||
*
|
*
|
||||||
* @return string The current validation group
|
* @return string|null The current validation group
|
||||||
*/
|
*/
|
||||||
public function getGroup();
|
public function getGroup();
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user