Merge branch '2.3' into 2.4
* 2.3: fixed a typo fixed CS for lambdas [Yaml] fixed some license headers Fixes message value for objects Check for hour, minute & second validity fixed various typos [Filesystem] Fixed mirror for symlinks [Validator] Removed duplicated test for IBAN in data provider Conflicts: src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php src/Symfony/Component/Console/Application.php src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php src/Symfony/Component/Filesystem/Tests/FilesystemTest.php src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php
This commit is contained in:
commit
d87d8daa36
@ -62,7 +62,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
|
||||
$this->container = $container;
|
||||
$this->connections = $container->getParameter($this->connections);
|
||||
$sortFunc = function($a, $b) {
|
||||
$sortFunc = function ($a, $b) {
|
||||
$a = isset($a['priority']) ? $a['priority'] : 0;
|
||||
$b = isset($b['priority']) ? $b['priority'] : 0;
|
||||
|
||||
|
@ -282,7 +282,7 @@ class UniqueValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will(
|
||||
$this->returnCallback(function() use ($entity) {
|
||||
$this->returnCallback(function () use ($entity) {
|
||||
$returnValue = array(
|
||||
$entity,
|
||||
);
|
||||
|
@ -20,7 +20,7 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
|
||||
|
||||
/**
|
||||
* Generates dumped php code of proxies via reflection.
|
||||
* Generates dumped PHP code of proxies via reflection.
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
*/
|
||||
|
@ -84,7 +84,7 @@ EOF
|
||||
|
||||
$filesystem->rename($realCacheDir, $oldCacheDir);
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
sleep(1); // workaround for windows php rename bug
|
||||
sleep(1); // workaround for Windows PHP rename bug
|
||||
}
|
||||
$filesystem->rename($warmupDir, $realCacheDir);
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ class Configuration implements ConfigurationInterface
|
||||
->end()
|
||||
->arrayNode('trusted_proxies')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return !is_array($v) && !is_null($v); })
|
||||
->then(function($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
|
||||
->ifTrue(function ($v) { return !is_array($v) && !is_null($v); })
|
||||
->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
|
||||
->end()
|
||||
->prototype('scalar')
|
||||
->validate()
|
||||
->ifTrue(function($v) {
|
||||
->ifTrue(function ($v) {
|
||||
if (empty($v)) {
|
||||
return false;
|
||||
}
|
||||
@ -70,8 +70,8 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('default_locale')->defaultValue('en')->end()
|
||||
->arrayNode('trusted_hosts')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_string($v); })
|
||||
->then(function($v) { return array($v); })
|
||||
->ifTrue(function ($v) { return is_string($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
@ -258,7 +258,7 @@ class Configuration implements ConfigurationInterface
|
||||
|
||||
private function addTemplatingSection(ArrayNodeDefinition $rootNode)
|
||||
{
|
||||
$organizeUrls = function($urls) {
|
||||
$organizeUrls = function ($urls) {
|
||||
$urls += array(
|
||||
'http' => array(),
|
||||
'ssl' => array(),
|
||||
@ -295,8 +295,8 @@ class Configuration implements ConfigurationInterface
|
||||
->addDefaultChildrenIfNoneSet()
|
||||
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
|
||||
->validate()
|
||||
->ifTrue(function($v) {return !in_array('FrameworkBundle:Form', $v); })
|
||||
->then(function($v){
|
||||
->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
|
||||
->then(function ($v) {
|
||||
return array_merge(array('FrameworkBundle:Form'), $v);
|
||||
})
|
||||
->end()
|
||||
@ -310,8 +310,8 @@ class Configuration implements ConfigurationInterface
|
||||
->performNoDeepMerging()
|
||||
->addDefaultsIfNotSet()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return !is_array($v); })
|
||||
->then(function($v) { return array($v); })
|
||||
->ifTrue(function ($v) { return !is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->always()
|
||||
@ -335,8 +335,8 @@ class Configuration implements ConfigurationInterface
|
||||
->isRequired()
|
||||
->requiresAtLeastOneElement()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v){ return !is_array($v); })
|
||||
->then(function($v){ return array($v); })
|
||||
->ifTrue(function ($v) { return !is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
@ -345,8 +345,8 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('loaders')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v){ return !is_array($v); })
|
||||
->then(function($v){ return array($v); })
|
||||
->ifTrue(function ($v) { return !is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
@ -364,8 +364,8 @@ class Configuration implements ConfigurationInterface
|
||||
->performNoDeepMerging()
|
||||
->addDefaultsIfNotSet()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return !is_array($v); })
|
||||
->then(function($v) { return array($v); })
|
||||
->ifTrue(function ($v) { return !is_array($v); })
|
||||
->then(function ($v) { return array($v); })
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->always()
|
||||
|
@ -437,7 +437,7 @@ class FrameworkExtension extends Extension
|
||||
// Apply request scope to assets helper if one or more packages are request-scoped
|
||||
$requireRequestScope = array_reduce(
|
||||
$namedPackages,
|
||||
function($v, Reference $ref) use ($container) {
|
||||
function ($v, Reference $ref) use ($container) {
|
||||
return $v || 'request' === $container->getDefinition($ref)->getScope();
|
||||
},
|
||||
'request' === $defaultPackage->getScope()
|
||||
@ -448,7 +448,7 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
if (!empty($config['loaders'])) {
|
||||
$loaders = array_map(function($loader) { return new Reference($loader); }, $config['loaders']);
|
||||
$loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']);
|
||||
|
||||
// Use a delegation unless only a single loader was registered
|
||||
if (1 === count($loaders)) {
|
||||
@ -485,7 +485,7 @@ class FrameworkExtension extends Extension
|
||||
}
|
||||
|
||||
$container->setParameter('templating.engines', $config['engines']);
|
||||
$engines = array_map(function($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
|
||||
$engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']);
|
||||
|
||||
// Use a delegation unless only a single engine was registered
|
||||
if (1 === count($engines)) {
|
||||
|
@ -203,7 +203,7 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
$files = array_map(function($resource) { return realpath($resource[1]); }, $resources);
|
||||
$files = array_map(function ($resource) { return realpath($resource[1]); }, $resources);
|
||||
$ref = new \ReflectionClass('Symfony\Component\Validator\Validator');
|
||||
$this->assertContains(
|
||||
strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),
|
||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Translation\MessageCatalogue;
|
||||
use Symfony\Component\Translation\Extractor\ExtractorInterface;
|
||||
|
||||
/**
|
||||
* PhpExtractor extracts translation messages from a php template.
|
||||
* PhpExtractor extracts translation messages from a PHP template.
|
||||
*
|
||||
* @author Michel Salib <michelsalib@hotmail.com>
|
||||
*/
|
||||
@ -88,7 +88,7 @@ class PhpExtractor implements ExtractorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts trans message from php tokens.
|
||||
* Extracts trans message from PHP tokens.
|
||||
*
|
||||
* @param array $tokens
|
||||
* @param MessageCatalogue $catalog
|
||||
|
@ -57,7 +57,7 @@ class SecurityDataCollector extends DataCollector
|
||||
'authenticated' => $token->isAuthenticated(),
|
||||
'token_class' => get_class($token),
|
||||
'user' => $token->getUsername(),
|
||||
'roles' => array_map(function ($role){ return $role->getRole();}, $token->getRoles()),
|
||||
'roles' => array_map(function ($role) { return $role->getRole();}, $token->getRoles()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -132,10 +132,10 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->useAttributeAsKey('id')
|
||||
->prototype('array')
|
||||
->performNoDeepMerging()
|
||||
->beforeNormalization()->ifString()->then(function($v) { return array('value' => $v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array('value' => $v); })->end()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['value']); })
|
||||
->then(function($v) { return preg_split('/\s*,\s*/', $v['value']); })
|
||||
->ifTrue(function ($v) { return is_array($v) && isset($v['value']); })
|
||||
->then(function ($v) { return preg_split('/\s*,\s*/', $v['value']); })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
@ -162,11 +162,11 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->end()
|
||||
->scalarNode('host')->defaultNull()->end()
|
||||
->arrayNode('ips')
|
||||
->beforeNormalization()->ifString()->then(function($v) { return array($v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->arrayNode('methods')
|
||||
->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->scalarNode('allow_if')->defaultNull()->end()
|
||||
@ -174,7 +174,7 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->fixXmlConfig('role')
|
||||
->children()
|
||||
->arrayNode('roles')
|
||||
->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
@ -251,8 +251,8 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('delete_cookies')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && is_int(key($v)); })
|
||||
->then(function($v) { return array_map(function($v) { return array('name' => $v); }, $v); })
|
||||
->ifTrue(function ($v) { return is_array($v) && is_int(key($v)); })
|
||||
->then(function ($v) { return array_map(function ($v) { return array('name' => $v); }, $v); })
|
||||
->end()
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('array')
|
||||
@ -306,10 +306,10 @@ class MainConfiguration implements ConfigurationInterface
|
||||
$firewallNodeBuilder
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function($v) {
|
||||
->ifTrue(function ($v) {
|
||||
return true === $v['security'] && isset($v['pattern']) && !isset($v['request_matcher']);
|
||||
})
|
||||
->then(function($firewall) use ($abstractFactoryKeys) {
|
||||
->then(function ($firewall) use ($abstractFactoryKeys) {
|
||||
foreach ($abstractFactoryKeys as $k) {
|
||||
if (!isset($firewall[$k]['check_path'])) {
|
||||
continue;
|
||||
@ -359,7 +359,7 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->arrayNode('providers')
|
||||
->beforeNormalization()
|
||||
->ifString()
|
||||
->then(function($v) { return preg_split('/\s*,\s*/', $v); })
|
||||
->then(function ($v) { return preg_split('/\s*,\s*/', $v); })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
@ -377,11 +377,11 @@ class MainConfiguration implements ConfigurationInterface
|
||||
|
||||
$providerNodeBuilder
|
||||
->validate()
|
||||
->ifTrue(function($v){return count($v) > 1;})
|
||||
->ifTrue(function ($v) {return count($v) > 1;})
|
||||
->thenInvalid('You cannot set multiple provider types for the same provider')
|
||||
->end()
|
||||
->validate()
|
||||
->ifTrue(function($v){return count($v) === 0;})
|
||||
->ifTrue(function ($v) {return count($v) === 0;})
|
||||
->thenInvalid('You must set a provider definition for the provider.')
|
||||
->end()
|
||||
;
|
||||
@ -406,7 +406,7 @@ class MainConfiguration implements ConfigurationInterface
|
||||
->prototype('array')
|
||||
->canBeUnset()
|
||||
->performNoDeepMerging()
|
||||
->beforeNormalization()->ifString()->then(function($v) { return array('algorithm' => $v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end()
|
||||
->children()
|
||||
->scalarNode('algorithm')->cannotBeEmpty()->end()
|
||||
->scalarNode('hash_algorithm')->info('Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms.')->defaultValue('sha512')->end()
|
||||
|
@ -126,7 +126,7 @@ class RememberMeFactory implements SecurityFactoryInterface
|
||||
->scalarNode('token_provider')->end()
|
||||
->arrayNode('user_providers')
|
||||
->beforeNormalization()
|
||||
->ifString()->then(function($v) { return array($v); })
|
||||
->ifString()->then(function ($v) { return array($v); })
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
|
@ -57,7 +57,7 @@ class InMemoryFactory implements UserProviderFactoryInterface
|
||||
->children()
|
||||
->scalarNode('password')->defaultValue(uniqid())->end()
|
||||
->arrayNode('roles')
|
||||
->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -236,7 +236,7 @@ class SecurityExtension extends Extension
|
||||
$mapDef->replaceArgument(1, $map);
|
||||
|
||||
// add authentication providers to authentication manager
|
||||
$authenticationProviders = array_map(function($id) {
|
||||
$authenticationProviders = array_map(function ($id) {
|
||||
return new Reference($id);
|
||||
}, array_values(array_unique($authenticationProviders)));
|
||||
$container
|
||||
|
@ -58,8 +58,8 @@ class Configuration implements ConfigurationInterface
|
||||
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
|
||||
->example(array('MyBundle::form.html.twig'))
|
||||
->validate()
|
||||
->ifTrue(function($v) { return !in_array('form_div_layout.html.twig', $v); })
|
||||
->then(function($v){
|
||||
->ifTrue(function ($v) { return !in_array('form_div_layout.html.twig', $v); })
|
||||
->then(function ($v) {
|
||||
return array_merge(array('form_div_layout.html.twig'), $v);
|
||||
})
|
||||
->end()
|
||||
@ -81,8 +81,8 @@ class Configuration implements ConfigurationInterface
|
||||
->example(array('foo' => '"@bar"', 'pi' => 3.14))
|
||||
->prototype('array')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v){ return is_string($v) && 0 === strpos($v, '@'); })
|
||||
->then(function($v){
|
||||
->ifTrue(function ($v) { return is_string($v) && 0 === strpos($v, '@'); })
|
||||
->then(function ($v) {
|
||||
if (0 === strpos($v, '@@')) {
|
||||
return substr($v, 1);
|
||||
}
|
||||
@ -91,7 +91,7 @@ class Configuration implements ConfigurationInterface
|
||||
})
|
||||
->end()
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v){
|
||||
->ifTrue(function ($v) {
|
||||
if (is_array($v)) {
|
||||
$keys = array_keys($v);
|
||||
sort($keys);
|
||||
@ -101,7 +101,7 @@ class Configuration implements ConfigurationInterface
|
||||
|
||||
return true;
|
||||
})
|
||||
->then(function($v){ return array('value' => $v); })
|
||||
->then(function ($v) { return array('value' => $v); })
|
||||
->end()
|
||||
->children()
|
||||
->scalarNode('id')->end()
|
||||
|
@ -206,7 +206,7 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($cookie1, $cookieJar->get('foo','/','example.com'));
|
||||
$this->assertEquals($cookie2, $cookieJar->get('foo1','/','test.example.com'));
|
||||
}
|
||||
|
||||
|
||||
public function testCookieGetWithSubdirectory()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
|
@ -227,7 +227,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
->treatNullLike(array('enabled' => true))
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function($v) {
|
||||
->then(function ($v) {
|
||||
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
|
||||
|
||||
return $v;
|
||||
|
@ -44,7 +44,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function always(\Closure $then = null)
|
||||
{
|
||||
$this->ifPart = function($v) { return true; };
|
||||
$this->ifPart = function ($v) { return true; };
|
||||
|
||||
if (null !== $then) {
|
||||
$this->thenPart = $then;
|
||||
@ -65,7 +65,7 @@ class ExprBuilder
|
||||
public function ifTrue(\Closure $closure = null)
|
||||
{
|
||||
if (null === $closure) {
|
||||
$closure = function($v) { return true === $v; };
|
||||
$closure = function ($v) { return true === $v; };
|
||||
}
|
||||
|
||||
$this->ifPart = $closure;
|
||||
@ -80,7 +80,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function ifString()
|
||||
{
|
||||
$this->ifPart = function($v) { return is_string($v); };
|
||||
$this->ifPart = function ($v) { return is_string($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -92,7 +92,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function ifNull()
|
||||
{
|
||||
$this->ifPart = function($v) { return null === $v; };
|
||||
$this->ifPart = function ($v) { return null === $v; };
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -104,7 +104,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function ifArray()
|
||||
{
|
||||
$this->ifPart = function($v) { return is_array($v); };
|
||||
$this->ifPart = function ($v) { return is_array($v); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -118,7 +118,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function ifInArray(array $array)
|
||||
{
|
||||
$this->ifPart = function($v) use ($array) { return in_array($v, $array, true); };
|
||||
$this->ifPart = function ($v) use ($array) { return in_array($v, $array, true); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -132,7 +132,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function ifNotInArray(array $array)
|
||||
{
|
||||
$this->ifPart = function($v) use ($array) { return !in_array($v, $array, true); };
|
||||
$this->ifPart = function ($v) use ($array) { return !in_array($v, $array, true); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -158,7 +158,7 @@ class ExprBuilder
|
||||
*/
|
||||
public function thenEmptyArray()
|
||||
{
|
||||
$this->thenPart = function($v) { return array(); };
|
||||
$this->thenPart = function ($v) { return array(); };
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -225,7 +225,7 @@ class ExprBuilder
|
||||
{
|
||||
foreach ($expressions as $k => $expr) {
|
||||
if ($expr instanceof ExprBuilder) {
|
||||
$expressions[$k] = function($v) use ($expr) {
|
||||
$expressions[$k] = function ($v) use ($expr) {
|
||||
return call_user_func($expr->ifPart, $v) ? call_user_func($expr->thenPart, $v) : $v;
|
||||
};
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Config\Tests\Definition;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy;
|
||||
|
||||
class ArrayNodeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -34,13 +34,13 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFinalizedValueIs('new_value', $test, array('key'=>true));
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifTrue( function($v){ return true; })
|
||||
->ifTrue( function ($v) { return true; })
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('new_value', $test);
|
||||
|
||||
$test = $this->getTestBuilder()
|
||||
->ifTrue( function($v){ return false; })
|
||||
->ifTrue( function ($v) { return false; })
|
||||
->then($this->returnClosure('new_value'))
|
||||
->end();
|
||||
$this->assertFinalizedValueIs('value',$test);
|
||||
@ -193,7 +193,7 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function returnClosure($val)
|
||||
{
|
||||
return function($v) use ($val) {
|
||||
return function ($v) use ($val) {
|
||||
return $val;
|
||||
};
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class NormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
->node('encoders', 'array')
|
||||
->useAttributeAsKey('class')
|
||||
->prototype('array')
|
||||
->beforeNormalization()->ifString()->then(function($v) { return array('algorithm' => $v); })->end()
|
||||
->beforeNormalization()->ifString()->then(function ($v) { return array('algorithm' => $v); })->end()
|
||||
->children()
|
||||
->node('algorithm', 'scalar')->end()
|
||||
->end()
|
||||
@ -86,7 +86,7 @@ class NormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
|
||||
return array_map(function($v) {
|
||||
return array_map(function ($v) {
|
||||
return array($v);
|
||||
}, $configs);
|
||||
}
|
||||
@ -134,7 +134,7 @@ class NormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
|
||||
return array_map(function($v) { return array($v); }, $configs);
|
||||
return array_map(function ($v) { return array($v); }, $configs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ class NormalizerTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
|
||||
return array_map(function($v) { return array($v); }, $configs);
|
||||
return array_map(function ($v) { return array($v); }, $configs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +168,7 @@ class XmlUtils
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an xml value to a php type.
|
||||
* Converts an xml value to a PHP type.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
|
@ -1038,7 +1038,8 @@ class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds alternative of $name among $collection
|
||||
* Finds alternative of $name among $collection,
|
||||
* if nothing is found in $collection, try in $abbrevs
|
||||
*
|
||||
* @param string $name The string
|
||||
* @param array|Traversable $collection The collection
|
||||
|
@ -337,7 +337,7 @@ class DialogHelper extends InputAwareHelper
|
||||
{
|
||||
$that = $this;
|
||||
|
||||
$interviewer = function() use ($output, $question, $default, $autocomplete, $that) {
|
||||
$interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
|
||||
return $that->ask($output, $question, $default, $autocomplete);
|
||||
};
|
||||
|
||||
@ -367,7 +367,7 @@ class DialogHelper extends InputAwareHelper
|
||||
{
|
||||
$that = $this;
|
||||
|
||||
$interviewer = function() use ($output, $question, $fallback, $that) {
|
||||
$interviewer = function () use ($output, $question, $fallback, $that) {
|
||||
return $that->askHiddenResponse($output, $question, $fallback);
|
||||
};
|
||||
|
||||
@ -405,7 +405,7 @@ class DialogHelper extends InputAwareHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a valid unix shell
|
||||
* Return a valid Unix shell
|
||||
*
|
||||
* @return string|Boolean The valid shell name, false in case no valid shell is found
|
||||
*/
|
||||
|
@ -89,7 +89,7 @@ class StreamOutput extends Output
|
||||
*
|
||||
* Colorization is disabled if not supported by the stream:
|
||||
*
|
||||
* - windows without ansicon and ConEmu
|
||||
* - Windows without Ansicon and ConEmu
|
||||
* - non tty consoles
|
||||
*
|
||||
* @return Boolean true if the stream supports colorization, false otherwise
|
||||
|
@ -104,7 +104,7 @@ EOF
|
||||
;
|
||||
|
||||
$output = $this->output;
|
||||
$process->run(function($type, $data) use ($output) {
|
||||
$process->run(function ($type, $data) use ($output) {
|
||||
$output->writeln($data);
|
||||
});
|
||||
|
||||
|
@ -205,7 +205,7 @@ class ErrorHandler
|
||||
}
|
||||
|
||||
// get current exception handler
|
||||
$exceptionHandler = set_exception_handler(function() {});
|
||||
$exceptionHandler = set_exception_handler(function () {});
|
||||
restore_exception_handler();
|
||||
|
||||
if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) {
|
||||
|
@ -109,7 +109,7 @@ PHP
|
||||
set_exception_handler(array($exceptionHandler, 'handle'));
|
||||
|
||||
$that = $this;
|
||||
$exceptionCheck = function($exception) use ($that) {
|
||||
$exceptionCheck = function ($exception) use ($that) {
|
||||
$that->assertInstanceOf('Symfony\Component\Debug\Exception\ContextErrorException', $exception);
|
||||
$that->assertEquals(E_NOTICE, $exception->getSeverity());
|
||||
$that->assertEquals(__LINE__ + 44, $exception->getLine());
|
||||
@ -215,7 +215,7 @@ PHP
|
||||
$logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||
|
||||
$that = $this;
|
||||
$warnArgCheck = function($message, $context) use ($that) {
|
||||
$warnArgCheck = function ($message, $context) use ($that) {
|
||||
$that->assertEquals('foo', $message);
|
||||
$that->assertArrayHasKey('type', $context);
|
||||
$that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION);
|
||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
/**
|
||||
* Lazy proxy dumper capable of generating the instantiation logic php code for proxied services.
|
||||
* Lazy proxy dumper capable of generating the instantiation logic PHP code for proxied services.
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
||||
class SimpleXMLElement extends \SimpleXMLElement
|
||||
{
|
||||
/**
|
||||
* Converts an attribute as a php type.
|
||||
* Converts an attribute as a PHP type.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
@ -34,7 +34,7 @@ class SimpleXMLElement extends \SimpleXMLElement
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns arguments as valid php types.
|
||||
* Returns arguments as valid PHP types.
|
||||
*
|
||||
* @param string $name
|
||||
* @param Boolean $lowercase
|
||||
@ -99,7 +99,7 @@ class SimpleXMLElement extends \SimpleXMLElement
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an xml value to a php type.
|
||||
* Converts an xml value to a PHP type.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
|
@ -270,7 +270,7 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$dispatcher->addListener('bug.62976', new CallableClass());
|
||||
$dispatcher->removeListener('bug.62976', function() {});
|
||||
$dispatcher->removeListener('bug.62976', function () {});
|
||||
$this->assertTrue($dispatcher->hasListeners('bug.62976'));
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ class Filesystem
|
||||
* Sets access and modification time of file.
|
||||
*
|
||||
* @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to create
|
||||
* @param integer $time The touch time as a unix timestamp
|
||||
* @param integer $atime The access time as a unix timestamp
|
||||
* @param integer $time The touch time as a Unix timestamp
|
||||
* @param integer $atime The access time as a Unix timestamp
|
||||
*
|
||||
* @throws IOException When touch fails
|
||||
*/
|
||||
@ -309,7 +309,7 @@ class Filesystem
|
||||
*/
|
||||
public function makePathRelative($endPath, $startPath)
|
||||
{
|
||||
// Normalize separators on windows
|
||||
// Normalize separators on Windows
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$endPath = strtr($endPath, '\\', '/');
|
||||
$startPath = strtr($startPath, '\\', '/');
|
||||
@ -396,7 +396,7 @@ class Filesystem
|
||||
}
|
||||
} else {
|
||||
if (is_link($file)) {
|
||||
$this->symlink($file, $target);
|
||||
$this->symlink($file->getLinkTarget(), $target);
|
||||
} elseif (is_dir($file)) {
|
||||
$this->mkdir($target);
|
||||
} elseif (is_file($file)) {
|
||||
|
@ -860,7 +860,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertFileExists($filename);
|
||||
$this->assertSame('bar', file_get_contents($filename));
|
||||
|
||||
// skip mode check on windows
|
||||
// skip mode check on Windows
|
||||
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$this->assertFilePermissions(753, $filename);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function getAdapters()
|
||||
{
|
||||
return array_values(array_map(function(array $adapter) {
|
||||
return array_values(array_map(function (array $adapter) {
|
||||
return $adapter['adapter'];
|
||||
}, $this->adapters));
|
||||
}
|
||||
|
@ -270,10 +270,10 @@ class Command
|
||||
public function join()
|
||||
{
|
||||
return implode(' ', array_filter(
|
||||
array_map(function($bit) {
|
||||
array_map(function ($bit) {
|
||||
return $bit instanceof Command ? $bit->join() : ($bit ?: null);
|
||||
}, $this->bits),
|
||||
function($bit) { return null !== $bit; }
|
||||
function ($bit) { return null !== $bit; }
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class Shell
|
||||
public function testCommand($command)
|
||||
{
|
||||
if (self::TYPE_WINDOWS === $this->type) {
|
||||
// todo: find a way to test if windows command exists
|
||||
// todo: find a way to test if Windows command exists
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$this->assertEquals(
|
||||
array('c', 'e', 'a', 'd', 'b'),
|
||||
array_map(function(Adapter\AdapterInterface $adapter) {
|
||||
array_map(function (Adapter\AdapterInterface $adapter) {
|
||||
return $adapter->getName();
|
||||
}, $finder->getAdapters())
|
||||
);
|
||||
@ -609,7 +609,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
public function getAdaptersTestData()
|
||||
{
|
||||
return array_map(
|
||||
function ($adapter) { return array($adapter); },
|
||||
function ($adapter) { return array($adapter); },
|
||||
$this->getValidAdapters()
|
||||
);
|
||||
}
|
||||
@ -723,7 +723,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
public function testAccessDeniedException(Adapter\AdapterInterface $adapter)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$this->markTestSkipped('chmod is not supported on windows');
|
||||
$this->markTestSkipped('chmod is not supported on Windows');
|
||||
}
|
||||
|
||||
$finder = $this->buildFinder($adapter);
|
||||
@ -749,7 +749,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
public function testIgnoredAccessDeniedException(Adapter\AdapterInterface $adapter)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$this->markTestSkipped('chmod is not supported on windows');
|
||||
$this->markTestSkipped('chmod is not supported on Windows');
|
||||
}
|
||||
|
||||
$finder = $this->buildFinder($adapter);
|
||||
@ -791,7 +791,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
new Adapter\GnuFindAdapter(),
|
||||
new Adapter\PhpAdapter()
|
||||
),
|
||||
function (Adapter\AdapterInterface $adapter) {
|
||||
function (Adapter\AdapterInterface $adapter) {
|
||||
return $adapter->isSupported();
|
||||
}
|
||||
);
|
||||
|
@ -15,7 +15,7 @@ class MockFileListIterator extends \ArrayIterator
|
||||
{
|
||||
public function __construct(array $filesArray = array())
|
||||
{
|
||||
$files = array_map(function($file){ return new MockSplFileInfo($file); }, $filesArray);
|
||||
$files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
|
||||
parent::__construct($files);
|
||||
}
|
||||
}
|
||||
|
@ -144,15 +144,15 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
|
||||
));
|
||||
}
|
||||
|
||||
if (isset($value['month']) && !ctype_digit($value['month']) && !is_int($value['month'])) {
|
||||
if (isset($value['month']) && !ctype_digit((string) $value['month'])) {
|
||||
throw new TransformationFailedException('This month is invalid');
|
||||
}
|
||||
|
||||
if (isset($value['day']) && !ctype_digit($value['day']) && !is_int($value['day'])) {
|
||||
if (isset($value['day']) && !ctype_digit((string) $value['day'])) {
|
||||
throw new TransformationFailedException('This day is invalid');
|
||||
}
|
||||
|
||||
if (isset($value['year']) && !ctype_digit($value['year']) && !is_int($value['year'])) {
|
||||
if (isset($value['year']) && !ctype_digit((string) $value['year'])) {
|
||||
throw new TransformationFailedException('This year is invalid');
|
||||
}
|
||||
|
||||
@ -160,6 +160,18 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
|
||||
throw new TransformationFailedException('This is an invalid date');
|
||||
}
|
||||
|
||||
if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) {
|
||||
throw new TransformationFailedException('This hour is invalid');
|
||||
}
|
||||
|
||||
if (isset($value['minute']) && !ctype_digit((string) $value['minute'])) {
|
||||
throw new TransformationFailedException('This minute is invalid');
|
||||
}
|
||||
|
||||
if (isset($value['second']) && !ctype_digit((string) $value['second'])) {
|
||||
throw new TransformationFailedException('This second is invalid');
|
||||
}
|
||||
|
||||
try {
|
||||
$dateTime = new \DateTime(sprintf(
|
||||
'%s-%s-%s %s:%s:%s %s',
|
||||
|
@ -900,13 +900,12 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
);
|
||||
}
|
||||
|
||||
public function testDateTimeWithEmptyValueOnTime()
|
||||
public function testDateTimeWithHourAndMinute()
|
||||
{
|
||||
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '', 'minute' => '');
|
||||
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
|
||||
|
||||
$form = $this->factory->createNamed('name', 'datetime', $data, array(
|
||||
'input' => 'array',
|
||||
'empty_value' => array('hour' => 'Change&Me', 'minute' => 'Change&Me'),
|
||||
'required' => false,
|
||||
));
|
||||
|
||||
@ -931,10 +930,10 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
[
|
||||
./select
|
||||
[@id="name_time_hour"]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value="4"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_time_minute"]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value="5"][@selected="selected"]]
|
||||
]
|
||||
]
|
||||
[count(.//select)=5]
|
||||
|
@ -509,4 +509,52 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase
|
||||
'second' => '6',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformWithEmptyStringHour()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
'year' => '2010',
|
||||
'month' => '2',
|
||||
'day' => '31',
|
||||
'hour' => '',
|
||||
'minute' => '5',
|
||||
'second' => '6',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformWithEmptyStringMinute()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
'year' => '2010',
|
||||
'month' => '2',
|
||||
'day' => '31',
|
||||
'hour' => '4',
|
||||
'minute' => '',
|
||||
'second' => '6',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformWithEmptyStringSecond()
|
||||
{
|
||||
$transformer = new DateTimeToArrayTransformer();
|
||||
$transformer->reverseTransform(array(
|
||||
'year' => '2010',
|
||||
'month' => '2',
|
||||
'day' => '31',
|
||||
'hour' => '4',
|
||||
'minute' => '5',
|
||||
'second' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
array('z', '33', '1970-02-03 00:00:00 UTC'),
|
||||
|
||||
// not bijective
|
||||
// this will not work as php will use actual date to replace missing info
|
||||
// this will not work as PHP will use actual date to replace missing info
|
||||
// and after change of date will lookup for closest Wednesday
|
||||
// i.e. value: 2010-02, php value: 2010-02-(today i.e. 20), parsed date: 2010-02-24
|
||||
// i.e. value: 2010-02, PHP value: 2010-02-(today i.e. 20), parsed date: 2010-02-24
|
||||
//array('Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'),
|
||||
//array('Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'),
|
||||
|
||||
@ -55,7 +55,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase
|
||||
array('g:i:s a', '4:05:06 pm', '1970-01-01 16:05:06 UTC'),
|
||||
array('h:i:s a', '04:05:06 pm', '1970-01-01 16:05:06 UTC'),
|
||||
|
||||
// seconds since unix
|
||||
// seconds since Unix
|
||||
array('U', '1265213106', '2010-02-03 16:05:06 UTC'),
|
||||
);
|
||||
|
||||
|
@ -394,7 +394,7 @@ class FormValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$context = $this->getMockExecutionContext();
|
||||
$object = $this->getMock('\stdClass');
|
||||
$options = array('validation_groups' => function(FormInterface $form){
|
||||
$options = array('validation_groups' => function (FormInterface $form) {
|
||||
return array('group1', 'group2');
|
||||
});
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
@ -529,7 +529,7 @@ class FormValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$object = $this->getMock('\stdClass');
|
||||
|
||||
$parentOptions = array(
|
||||
'validation_groups' => function(FormInterface $form){
|
||||
'validation_groups' => function (FormInterface $form) {
|
||||
return array('group1', 'group2');
|
||||
},
|
||||
'cascade_validation' => true,
|
||||
|
@ -64,7 +64,7 @@ abstract class BaseValidatorExtensionTest extends TypeTestCase
|
||||
public function testValidationGroupsCanBeSetToClosure()
|
||||
{
|
||||
$form = $this->createForm(array(
|
||||
'validation_groups' => function(FormInterface $form){ return null; },
|
||||
'validation_groups' => function (FormInterface $form) { return null; },
|
||||
));
|
||||
|
||||
$this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
|
||||
|
@ -90,7 +90,7 @@ class AcceptHeaderItem
|
||||
{
|
||||
$string = $this->value.($this->quality < 1 ? ';q='.$this->quality : '');
|
||||
if (count($this->attributes) > 0) {
|
||||
$string .= ';'.implode(';', array_map(function($name, $value) {
|
||||
$string .= ';'.implode(';', array_map(function ($name, $value) {
|
||||
return sprintf(preg_match('/[,;=]/', $value) ? '%s="%s"' : '%s=%s', $name, $value);
|
||||
}, array_keys($this->attributes), $this->attributes));
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class UploadedFile extends File
|
||||
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
|
||||
UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.',
|
||||
UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.',
|
||||
UPLOAD_ERR_EXTENSION => 'File upload was stopped by a php extension.',
|
||||
UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.',
|
||||
);
|
||||
|
||||
$errorCode = $this->error;
|
||||
|
@ -90,7 +90,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method('update')
|
||||
->will($this->returnCallback(function($criteria, $updateData, $options) use ($that, &$data) {
|
||||
->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) {
|
||||
$that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria);
|
||||
$that->assertEquals(array('upsert' => true, 'multiple' => false), $options);
|
||||
|
||||
@ -118,7 +118,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$collection->expects($this->exactly(2))
|
||||
->method('update')
|
||||
->will($this->returnCallback(function($criteria, $updateData, $options) use (&$data) {
|
||||
->will($this->returnCallback(function ($criteria, $updateData, $options) use (&$data) {
|
||||
$data = $updateData;
|
||||
}));
|
||||
|
||||
@ -161,7 +161,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$collection->expects($this->once())
|
||||
->method('remove')
|
||||
->will($this->returnCallback(function($criteria) use ($that) {
|
||||
->will($this->returnCallback(function ($criteria) use ($that) {
|
||||
$that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']);
|
||||
$that->assertGreaterThanOrEqual(time() - -1, $criteria[$that->options['time_field']]['$lt']->sec);
|
||||
}));
|
||||
|
@ -56,7 +56,7 @@ class ContainerAwareHttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$request = new Request();
|
||||
$expected = new Response();
|
||||
$controller = function() use ($expected) {
|
||||
$controller = function () use ($expected) {
|
||||
return $expected;
|
||||
};
|
||||
|
||||
|
@ -268,8 +268,8 @@ EOF;
|
||||
|
||||
$output = Kernel::stripComments($source);
|
||||
|
||||
// Heredocs are preserved, making the output mixing unix and windows line
|
||||
// endings, switching to "\n" everywhere on windows to avoid failure.
|
||||
// Heredocs are preserved, making the output mixing Unix and Windows line
|
||||
// endings, switching to "\n" everywhere on Windows to avoid failure.
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
$expected = str_replace("\r\n", "\n", $expected);
|
||||
$output = str_replace("\r\n", "\n", $output);
|
||||
|
@ -91,7 +91,7 @@ class FullTransformer
|
||||
{
|
||||
$that = $this;
|
||||
|
||||
$formatted = preg_replace_callback($this->regExp, function($matches) use ($that, $dateTime) {
|
||||
$formatted = preg_replace_callback($this->regExp, function ($matches) use ($that, $dateTime) {
|
||||
return $that->formatReplace($matches[0], $dateTime);
|
||||
}, $this->pattern);
|
||||
|
||||
@ -185,7 +185,7 @@ class FullTransformer
|
||||
// when parsing a date/time value
|
||||
$escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
|
||||
|
||||
$reverseMatchingRegExp = preg_replace_callback($this->regExp, function($matches) use ($that) {
|
||||
$reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) use ($that) {
|
||||
$length = strlen($matches[0]);
|
||||
$transformerIndex = $matches[0][0];
|
||||
|
||||
@ -245,7 +245,7 @@ class FullTransformer
|
||||
{
|
||||
$specialCharsArray = str_split($specialChars);
|
||||
|
||||
$specialCharsMatch = implode('|', array_map(function($char) {
|
||||
$specialCharsMatch = implode('|', array_map(function ($char) {
|
||||
return $char.'+';
|
||||
}, $specialCharsArray));
|
||||
|
||||
|
@ -60,7 +60,7 @@ class MonthTransformer extends Transformer
|
||||
public function __construct()
|
||||
{
|
||||
if (0 === count(self::$shortMonths)) {
|
||||
self::$shortMonths = array_map(function($month) {
|
||||
self::$shortMonths = array_map(function ($month) {
|
||||
return substr($month, 0, 3);
|
||||
}, self::$months);
|
||||
|
||||
|
@ -201,8 +201,8 @@ class IntlDateFormatter
|
||||
// intl allows timestamps to be passed as arrays - we don't
|
||||
if (is_array($timestamp)) {
|
||||
$message = version_compare(PHP_VERSION, '5.3.4', '>=') ?
|
||||
'Only integer unix timestamps and DateTime objects are supported' :
|
||||
'Only integer unix timestamps are supported';
|
||||
'Only integer Unix timestamps and DateTime objects are supported' :
|
||||
'Only integer Unix timestamps are supported';
|
||||
|
||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'timestamp', $timestamp, $message);
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
||||
$this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.3.4', '>=')) {
|
||||
$this->assertStringEndsWith('Only integer unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
|
||||
$this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
|
||||
} else {
|
||||
$this->assertStringEndsWith('Only integer unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
|
||||
$this->assertStringEndsWith('Only integer Unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ class Process
|
||||
$this->commandline = $commandline;
|
||||
$this->cwd = $cwd;
|
||||
|
||||
// on windows, if the cwd changed via chdir(), proc_open defaults to the dir where php was started
|
||||
// on gnu/linux, PHP builds with --enable-maintainer-zts are also affected
|
||||
// on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started
|
||||
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
|
||||
// @see : https://bugs.php.net/bug.php?id=51800
|
||||
// @see : https://bugs.php.net/bug.php?id=50524
|
||||
|
||||
@ -345,9 +345,9 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a posix signal to the process.
|
||||
* Sends a POSIX signal to the process.
|
||||
*
|
||||
* @param integer $signal A valid posix signal (see http://www.php.net/manual/en/pcntl.constants.php)
|
||||
* @param integer $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
|
||||
* @return Process
|
||||
*
|
||||
* @throws LogicException In case the process is not running
|
||||
@ -644,7 +644,7 @@ class Process
|
||||
* Stops the process.
|
||||
*
|
||||
* @param integer|float $timeout The timeout in seconds
|
||||
* @param integer $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL
|
||||
* @param integer $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL
|
||||
*
|
||||
* @return integer The exit-code of the process
|
||||
*
|
||||
@ -1152,7 +1152,7 @@ class Process
|
||||
if (-1 == $this->exitcode && null !== $this->fallbackExitcode) {
|
||||
$this->exitcode = $this->fallbackExitcode;
|
||||
} elseif (-1 === $this->exitcode && $this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
|
||||
// if process has been signaled, no exitcode but a valid termsig, apply unix convention
|
||||
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
|
||||
$this->exitcode = 128 + $this->processInformation['termsig'];
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class ProcessPipes
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes unix pipes.
|
||||
* Closes Unix pipes.
|
||||
*
|
||||
* Nothing happens in case file handles are used.
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ class ProcessUtils
|
||||
public static function escapeArgument($argument)
|
||||
{
|
||||
//Fix for PHP bug #43784 escapeshellarg removes % from given string
|
||||
//Fix for PHP bug #49446 escapeshellarg dosn`t work on windows
|
||||
//Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
|
||||
//@see https://bugs.php.net/bug.php?id=43784
|
||||
//@see https://bugs.php.net/bug.php?id=49446
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
|
@ -459,7 +459,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testPhpDeadlock()
|
||||
{
|
||||
$this->markTestSkipped('Can course php to hang');
|
||||
$this->markTestSkipped('Can course PHP to hang');
|
||||
|
||||
// Sleep doesn't work as it will allow the process to handle signals and close
|
||||
// file handles from the other end.
|
||||
@ -633,7 +633,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
private function verifyPosixIsEnabled()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
}
|
||||
if (!defined('SIGUSR1')) {
|
||||
$this->markTestSkipped('The pcntl extension is not enabled');
|
||||
@ -646,7 +646,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSignalWithWrongIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
@ -660,7 +660,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->markTestSkipped('POSIX signals do not work on windows');
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('php -r "sleep(3);"');
|
||||
|
@ -33,11 +33,11 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
//not executable PHP_PATH
|
||||
putenv('PHP_PATH=/not/executable/php');
|
||||
$this->assertFalse($f->find(), '::find() returns false for not executable php');
|
||||
$this->assertFalse($f->find(), '::find() returns false for not executable PHP');
|
||||
|
||||
//executable PHP_PATH
|
||||
putenv('PHP_PATH='.$current);
|
||||
$this->assertEquals($f->find(), $current, '::find() returns the executable php');
|
||||
$this->assertEquals($f->find(), $current, '::find() returns the executable PHP');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,10 +55,10 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$current = $f->find();
|
||||
|
||||
//TODO maybe php executable is custom or even windows
|
||||
//TODO maybe php executable is custom or even Windows
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertTrue(is_executable($current));
|
||||
$this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable php with suffixes');
|
||||
$this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
// required for signal handling
|
||||
declare(ticks = 1);
|
||||
|
||||
pcntl_signal(SIGUSR1, function(){echo "Caught SIGUSR1"; exit;});
|
||||
pcntl_signal(SIGUSR1, function () {echo "Caught SIGUSR1"; exit;});
|
||||
|
||||
$n=0;
|
||||
|
||||
|
@ -21,6 +21,6 @@ class CustomXmlFileLoader extends XmlFileLoader
|
||||
{
|
||||
protected function loadFile($file)
|
||||
{
|
||||
return XmlUtils::loadFile($file, function() { return true; });
|
||||
return XmlUtils::loadFile($file, function () { return true; });
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $username The username
|
||||
* @param integer $expires The unixtime when the cookie expires
|
||||
* @param integer $expires The Unix timestamp when the cookie expires
|
||||
* @param string $password The encoded password
|
||||
*
|
||||
* @throws \RuntimeException if username contains invalid chars
|
||||
@ -138,7 +138,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $username The username
|
||||
* @param integer $expires The unixtime when the cookie expires
|
||||
* @param integer $expires The Unix timestamp when the cookie expires
|
||||
* @param string $password The encoded password
|
||||
*
|
||||
* @throws \RuntimeException when the private key is empty
|
||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Translation\Dumper;
|
||||
use Symfony\Component\Translation\MessageCatalogue;
|
||||
|
||||
/**
|
||||
* PhpFileDumper generates php files from a message catalogue.
|
||||
* PhpFileDumper generates PHP files from a message catalogue.
|
||||
*
|
||||
* @author Michel Salib <michelsalib@hotmail.com>
|
||||
*/
|
||||
|
@ -27,6 +27,12 @@ class NullValidator extends ConstraintValidator
|
||||
public function validate($value, Constraint $constraint)
|
||||
{
|
||||
if (null !== $value) {
|
||||
if (is_object($value)) {
|
||||
$value = get_class($value);
|
||||
} elseif (is_array($value)) {
|
||||
$value = 'Array';
|
||||
}
|
||||
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testValidChoiceCallbackClosure()
|
||||
{
|
||||
$constraint = new Choice(array('callback' => function() {
|
||||
$constraint = new Choice(array('callback' => function () {
|
||||
return array('foo', 'bar');
|
||||
}));
|
||||
|
||||
|
@ -53,7 +53,6 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function getValidIbans()
|
||||
{
|
||||
return array(
|
||||
array('CH93 0076 2011 6238 5295 7'), //Switzerland
|
||||
array('CH9300762011623852957'), // Switzerland without spaces
|
||||
|
||||
//Country list
|
||||
|
@ -43,7 +43,7 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider getInvalidValues
|
||||
*/
|
||||
public function testInvalidValues($value)
|
||||
public function testInvalidValues($value, $readableValue)
|
||||
{
|
||||
$constraint = new Null(array(
|
||||
'message' => 'myMessage'
|
||||
@ -52,7 +52,7 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->context->expects($this->once())
|
||||
->method('addViolation')
|
||||
->with('myMessage', array(
|
||||
'{{ value }}' => $value,
|
||||
'{{ value }}' => $readableValue,
|
||||
));
|
||||
|
||||
$this->validator->validate($value, $constraint);
|
||||
@ -61,10 +61,13 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function getInvalidValues()
|
||||
{
|
||||
return array(
|
||||
array(0),
|
||||
array(false),
|
||||
array(true),
|
||||
array(''),
|
||||
array(0, 0),
|
||||
array(false, false),
|
||||
array(true, true),
|
||||
array('', ''),
|
||||
array('foo bar', 'foo bar'),
|
||||
array(new \DateTime(), 'DateTime'),
|
||||
array(array(), 'Array'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
->will($this->returnValue(false));
|
||||
$cache->expects($this->once())
|
||||
->method('write')
|
||||
->will($this->returnCallback(function($metadata) use ($tester, $constraints) {
|
||||
->will($this->returnCallback(function ($metadata) use ($tester, $constraints) {
|
||||
$tester->assertEquals($constraints, $metadata->getConstraints());
|
||||
}));
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
@ -48,7 +49,7 @@ class Unescaper
|
||||
public function unescapeDoubleQuotedString($value)
|
||||
{
|
||||
$self = $this;
|
||||
$callback = function($match) use ($self) {
|
||||
$callback = function ($match) use ($self) {
|
||||
return $self->unescapeCharacter($match[0]);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user