Skip to content

Commit d53874b

Browse files
Merge branch '3.0'
* 3.0: (22 commits) Fix backport [travis] Upgrade phpunit wrapper & hirak/prestissimo [Bridge\PhpUnit] Workaround old phpunit bug, no colors in weak mode, add tests [PropertyAccess] Fix isPropertyWritable not using the reflection cache [PropertyAccess] Backport fixes from 2.7 [FrameworkBundle][2.8] Add tests for the Controller class [DependencyInjection] Update changelog Added WebProfiler toolbar ajax panel table layout css. [Validator] use correct term for a property in docblock (not "option") [Routing] small refactoring for scheme requirement [PropertyAccess] Remove most ref mismatches to improve perf [PropertyInfo] Support Doctrine custom mapping type in DoctrineExtractor [Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols [NumberFormatter] Fix invalid numeric literal on PHP 7 [Process] fix docblock syntax use the clock mock for progress indicator tests Use XML_ELEMENT_NODE in nodeType check [PropertyAccess] Reduce overhead of UnexpectedTypeException tracking [PropertyAccess] Throw an UnexpectedTypeException when the type do not match [FrameworkBundle] Add tests for the Controller class ... Conflicts: src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php src/Symfony/Bundle/FrameworkBundle/composer.json src/Symfony/Component/PropertyAccess/PropertyAccessor.php src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
2 parents 003507d + 3c40825 commit d53874b

File tree

33 files changed

+980
-383
lines changed

33 files changed

+980
-383
lines changed

.composer/composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.composer/config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"config": {
3+
"preferred-install": {
4+
"*": "dist"
5+
}
6+
}
7+
}

.travis.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ before_install:
5454
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = redis.so >> $INI_FILE; fi;
5555
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi;
5656
- if [[ $deps != skip ]]; then composer self-update; fi;
57-
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install --prefer-dist; fi;
57+
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install; fi;
5858
- if [[ $deps != skip ]]; then ./phpunit install; fi;
5959
- export PHPUNIT=$(readlink -f ./phpunit)
6060
- mkdir /tmp/slapd
@@ -69,18 +69,20 @@ install:
6969
- if [[ $deps != skip && $deps ]]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
7070
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
7171
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi;
72-
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi;
72+
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi;
7373
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
7474
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi;
7575
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev;
76-
- if [[ ! $deps ]]; then composer update --prefer-dist; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi;
76+
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi;
77+
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi;
7778
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi;
7879

7980
script:
8081
- if [[ ! $deps ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
8182
- if [[ ! $deps ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
8283
- if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi;
83-
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-dist; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi;
84-
- if [[ $deps = high ]]; then (cd src/Symfony/Bridge/PhpUnit && phpenv global 5.3 && php --version && $PHPUNIT && find -name '*.php' -not -path './vendor/*' | xargs -n1 php -l); fi;
85-
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-dist --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
84+
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi;
85+
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
86+
# Test the PhpUnit bridge using the original phpunit script
87+
- if [[ $deps = low ]]; then (cd src/Symfony/Bridge/PhpUnit && phpenv global 5.3 && php --version && composer update && phpunit); fi;
8688
- if [[ $deps = skip ]]; then echo This matrix line is skipped for pull requests.; fi;

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ install:
5050
- cd c:\projects\symfony
5151
- mkdir %APPDATA%\Composer
5252
- IF %APPVEYOR_REPO_NAME%==symfony/symfony copy /Y .composer\* %APPDATA%\Composer\
53-
- IF %APPVEYOR_REPO_NAME%==symfony/symfony composer global install --prefer-dist --no-progress --ansi || echo curl.cainfo needs PHP 5.3.7
53+
- IF %APPVEYOR_REPO_NAME%==symfony/symfony composer global install --no-progress --ansi || echo curl.cainfo needs PHP 5.3.7
5454
- php phpunit install
5555
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
56-
- composer update --prefer-dist --no-progress --ansi
56+
- composer update --no-progress --ansi
5757

5858
test_script:
5959
- cd c:\projects\symfony

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@
9393
},
9494
"autoload": {
9595
"psr-4": {
96-
"Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/",
97-
"Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/",
98-
"Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/",
99-
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
96+
"Symfony\\Bridge\\": "src/Symfony/Bridge/",
10097
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
10198
"Symfony\\Component\\": "src/Symfony/Component/"
10299
},

phpunit

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
// Please update when phpunit needs to be reinstalled with fresh deps:
14-
// Cache-Id-Version: 2016-03-16 15:36 UTC
14+
// Cache-Id-Version: 2016-03-22 17:23 UTC
1515

1616
use Symfony\Component\Process\ProcessUtils;
1717

@@ -54,11 +54,17 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
5454
passthru("$COMPOSER remove --no-update symfony/yaml");
5555
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\"");
5656
passthru("$COMPOSER install --prefer-dist --no-progress --ansi");
57-
file_put_contents('phpunit', <<<EOPHP
57+
file_put_contents('phpunit', <<<'EOPHP'
5858
<?php
5959
6060
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
61-
require PHPUNIT_COMPOSER_INSTALL;
61+
62+
$loader = require PHPUNIT_COMPOSER_INSTALL;
63+
64+
if (getenv('SYMFONY_PHPUNIT_OVERLOAD') && file_exists(__DIR__.'/../../src/Symfony/Bridge/PhpUnit')) {
65+
$loader->addPsr4('Symfony\\Bridge\\PhpUnit\\', array('src/Symfony/Bridge/PhpUnit'), true);
66+
}
67+
unset($loader);
6268
Symfony\Bridge\PhpUnit\TextUI\Command::main();
6369

6470
EOPHP

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
1515
use Doctrine\Common\Persistence\Mapping\MappingException;
16+
use Doctrine\DBAL\Types\Type as DBALType;
1617
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1718
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
1819
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
@@ -93,23 +94,26 @@ public function getTypes($class, $property, array $context = array())
9394
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
9495

9596
switch ($typeOfField) {
96-
case 'date':
97-
case 'datetime':
98-
case 'datetimetz':
99-
case 'time':
97+
case DBALType::DATE:
98+
case DBALType::DATETIME:
99+
case DBALType::DATETIMETZ:
100+
case 'vardatetime':
101+
case DBALType::TIME:
100102
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime'));
101103

102-
case 'array':
104+
case DBALType::TARRAY:
103105
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
104106

105-
case 'simple_array':
107+
case DBALType::SIMPLE_ARRAY:
106108
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)));
107109

108-
case 'json_array':
110+
case DBALType::JSON_ARRAY:
109111
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
110112

111113
default:
112-
return array(new Type($this->getPhpType($typeOfField), $nullable));
114+
$builtinType = $this->getPhpType($typeOfField);
115+
116+
return $builtinType ? array(new Type($builtinType, $nullable)) : null;
113117
}
114118
}
115119
}
@@ -119,36 +123,37 @@ public function getTypes($class, $property, array $context = array())
119123
*
120124
* @param string $doctrineType
121125
*
122-
* @return string
126+
* @return string|null
123127
*/
124128
private function getPhpType($doctrineType)
125129
{
126130
switch ($doctrineType) {
127-
case 'smallint':
128-
// No break
129-
case 'bigint':
130-
// No break
131-
case 'integer':
131+
case DBALType::SMALLINT:
132+
case DBALType::BIGINT:
133+
case DBALType::INTEGER:
132134
return Type::BUILTIN_TYPE_INT;
133135

134-
case 'decimal':
136+
case DBALType::FLOAT:
137+
case DBALType::DECIMAL:
135138
return Type::BUILTIN_TYPE_FLOAT;
136139

137-
case 'text':
138-
// No break
139-
case 'guid':
140+
case DBALType::STRING:
141+
case DBALType::TEXT:
142+
case DBALType::GUID:
140143
return Type::BUILTIN_TYPE_STRING;
141144

142-
case 'boolean':
145+
case DBALType::BOOLEAN:
143146
return Type::BUILTIN_TYPE_BOOL;
144147

145-
case 'blob':
146-
// No break
148+
case DBALType::BLOB:
147149
case 'binary':
148150
return Type::BUILTIN_TYPE_RESOURCE;
149151

152+
case DBALType::OBJECT:
153+
return Type::BUILTIN_TYPE_OBJECT;
154+
150155
default:
151-
return $doctrineType;
156+
return;
152157
}
153158
}
154159
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\PropertyInfo\Tests;
1313

14+
use Doctrine\DBAL\Types\Type as DBALType;
1415
use Doctrine\ORM\EntityManager;
1516
use Doctrine\ORM\Tools\Setup;
1617
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
@@ -31,6 +32,11 @@ protected function setUp()
3132
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'), true);
3233
$entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config);
3334

35+
if (!DBALType::hasType('foo')) {
36+
DBALType::addType('foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType');
37+
$entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('custom_foo', 'foo');
38+
}
39+
3440
$this->extractor = new DoctrineExtractor($entityManager->getMetadataFactory());
3541
}
3642

@@ -45,6 +51,7 @@ public function testGetProperties()
4551
'simpleArray',
4652
'bool',
4753
'binary',
54+
'customFoo',
4855
'foo',
4956
'bar',
5057
),
@@ -78,6 +85,7 @@ public function typesProvider()
7885
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
7986
))),
8087
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
88+
array('customFoo', null),
8189
array('notMapped', null),
8290
);
8391
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@ class DoctrineDummy
7070
*/
7171
private $binary;
7272

73+
/**
74+
* @Column(type="custom_foo")
75+
*/
76+
private $customFoo;
77+
7378
public $notMapped;
7479
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
use Doctrine\DBAL\Platforms\AbstractPlatform;
15+
use Doctrine\DBAL\Types\ConversionException;
16+
use Doctrine\DBAL\Types\Type;
17+
18+
/**
19+
* @author Teoh Han Hui <teohhanhui@gmail.com>
20+
*/
21+
class DoctrineFooType extends Type
22+
{
23+
/**
24+
* Type name.
25+
*/
26+
const NAME = 'foo';
27+
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
public function getName()
32+
{
33+
return self::NAME;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
40+
{
41+
return $platform->getClobTypeDeclarationSQL(array());
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function convertToDatabaseValue($value, AbstractPlatform $platform)
48+
{
49+
if (null === $value) {
50+
return;
51+
}
52+
if (!$value instanceof Foo) {
53+
throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', gettype($value)));
54+
}
55+
56+
return $foo->bar;
57+
}
58+
59+
/**
60+
* {@inheritdoc}
61+
*/
62+
public function convertToPHPValue($value, AbstractPlatform $platform)
63+
{
64+
if (null === $value) {
65+
return;
66+
}
67+
if (!is_string($value)) {
68+
throw ConversionException::conversionFailed($value, self::NAME);
69+
}
70+
71+
$foo = new Foo();
72+
$foo->bar = $value;
73+
74+
return $foo;
75+
}
76+
77+
/**
78+
* {@inheritdoc}
79+
*/
80+
public function requiresSQLCommentHint(AbstractPlatform $platform)
81+
{
82+
return true;
83+
}
84+
}

0 commit comments

Comments
 (0)