8000 minor #13063 [2.3] [Bridge] [Propel] minor improvements to the Propel… · symfony/symfony@9ea3f6a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ea3f6a

Browse files
committed
minor #13063 [2.3] [Bridge] [Propel] minor improvements to the Propel bridge. (hhamon)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3] [Bridge] [Propel] minor improvements to the Propel bridge. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- 6d9d460 [Bridge] [Propel] minor improvements to the Propel bridge.
2 parents cad7f0e + 6d9d460 commit 9ea3f6a

File tree

13 files changed

+75
-64
lines changed

13 files changed

+75
-64
lines changed

src/Symfony/Bridge/Propel1/DataCollector/PropelDataCollector.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PropelDataCollector extends DataCollector
2626
/**
2727
* Propel logger.
2828
*
29-
* @var \Symfony\Bridge\Propel1\Logger\PropelLogger
29+
* @var PropelLogger
3030
*/
3131
private $logger;
3232

@@ -63,17 +63,17 @@ public function collect(Request $request, Response $response, \Exception $except
6363
/**
6464
* Returns the collector name.
6565
*
66-
* @return string The collector name.
66+
* @return string
6767
*/
6868
public function getName()
6969
{
7070
return 'propel';
7171
}
7272

7373
/**
74-
* Returns queries.
74+
* Returns the collected stats for all executed SQL queries.
7575
*
76-
* @return array Queries
76+
* @return array
7777
*/
7878
public function getQueries()
7979
{
@@ -83,17 +83,17 @@ public function getQueries()
8383
/**
8484
* Returns the query count.
8585
*
86-
* @return int The query count
86+
* @return int
8787
*/
8888
public function getQueryCount()
8989
{
9090
return $this->data['querycount'];
9191
}
9292

9393
/**
94-
* Returns the total time of queries.
94+
* Returns the total time spent on running all queries.
9595
*
96-
* @return float The total time of queries
96+
* @return float
9797
*/
9898
public function getTime()
9999
{
@@ -106,9 +106,9 @@ public function getTime()
106106
}
107107

108108
/**
109-
* Creates an array of Build objects.
109+
* Computes the stats of all executed SQL queries.
110110
*
111-
* @return array An array of Build objects
111+
* @return array
112112
*/
113113
private function buildQueries()
114114
{
@@ -136,9 +136,9 @@ private function buildQueries()
136136
}
137137

138138
/**
139-
* Count queries.
139+
* Returns the total count of SQL queries.
140140
*
141-
* @return int The number of queries.
141+
* @return int
142142
*/
143143
private function countQueries()
144144
{

src/Symfony/Bridge/Propel1/DependencyInjection/Security/UserProvider/PropelFactory.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class PropelFactory implements UserProviderFactoryInterface
2626
private $key;
2727
private $providerId;
2828

29+
/**
30+
* Constructor.
31+
*
32+
* @param string $key
33+
* @param string $providerId
34+
*/
2935
public function __construct($key, $providerId)
3036
{
3137
$this->key = $key;
@@ -38,7 +44,7 @@ public function create(ContainerBuilder $container, $id, $config)
3844
->setDefinition($id, new DefinitionDecorator($this->providerId))
3945
->addArgument($config['class'])
4046
->addArgument($config['property'])
41-
;
47+
;
4248
}
4349

4450
public function getKey()
@@ -50,9 +56,14 @@ public function addConfiguration(NodeDefinition $node)
5056
{
5157
$node
5258
->children()
53-
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
54-
->scalarNode('property')->defaultNull()->end()
59+
->scalarNode('class')
60+
->isRequired()
61+
->cannotBeEmpty()
62+
->end()
63+
->scalarNode('property')
64+
->defaultNull()
65+
->end()
5566
->end()
56-
;
67+
;
5768
}
5869
}

src/Symfony/Bridge/Propel1/Form/Type/ModelType.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,29 @@ class ModelType extends AbstractType
5555
*/
5656
private $propertyAccessor;
5757

58+
/**
59+
* Constructor.
60+
*
61+
* @param PropertyAccessorInterface|null $propertyAccessor
62+
*/
5863
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
5964
{
6065
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
6166
}
6267

68+
/**
69+
* {@inheritdoc}
70+
*/
6371
public function buildForm(FormBuilderInterface $builder, array $options)
6472
{
6573
if ($options['multiple']) {
6674
$builder->addViewTransformer(new CollectionToArrayTransformer(), true);
6775
}
6876
}
6977

78+
/**
79+
* {@inheritdoc}
80+
*/
7081
public function setDefaultOptions(OptionsResolverInterface $resolver)
7182
{
7283
$propertyAccessor = $this->propertyAccessor;
@@ -97,11 +108,17 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
97108
));
98109
}
99110

111+
/**
112+
* {@inheritdoc}
113+
*/
100114
public function getParent()
101115
{
102116
return 'choice';
103117
}
104118

119+
/**
120+
* {@inheritdoc}
121+
*/
105122
public function getName()
106123
{
107124
return 'model';

src/Symfony/Bridge/Propel1/Form/Type/TranslationCollectionType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4040
$builder->addEventSubscriber($listener);
4141
}
4242

43+
/**
44+
* {@inheritdoc}
45+
*/
4346
public function getParent()
4447
{
4548
return 'collection';

src/Symfony/Bridge/Propel1/Tests/DataCollector/PropelDataCollectorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,19 @@ public function testCollectWithMultipleData()
9292
private function createCollector($queries)
9393
{
9494
$config = $this->getMock('\PropelConfiguration');
95+
9596
$config
9697
->expects($this->any())
9798
->method('getParameter')
9899
->will($this->returnArgument(1))
99-
;
100+
;
100101

101102
$logger = $this->getMock('\Symfony\Bridge\Propel1\Logger\PropelLogger');
102103
$logger
103104
->expects($this->any())
104105
->method('getQueries')
105106
->will($this->returnValue($queries))
106-
;
107+
;
107108

108109
return new PropelDataCollector($logger, $config);
109110
}

src/Symfony/Bridge/Propel1/Tests/Fixtures/Column.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class Column
1515
{
1616
private $name;
17-
1817
private $type;
1918

2019
public function __construct($name, $type)
@@ -35,13 +34,13 @@ public function isText()
3534
}
3635

3736
switch ($this->type) {
38-
case \PropelColumnTypes::CHAR:
39-
case \PropelColumnTypes::VARCHAR:
40-
case \PropelColumnTypes::LONGVARCHAR:
41-
case \PropelColumnTypes::BLOB:
42-
case \PropelColumnTypes::CLOB:
43-
case \PropelColumnTypes::CLOB_EMU:
44-
return true;
37+
case \PropelColumnTypes::CHAR:
38+
case \PropelColumnTypes::VARCHAR:
39+
case \PropelColumnTypes::LONGVARCHAR:
40+
case \PropelColumnTypes::BLOB:
41+
case \PropelColumnTypes::CLOB:
42+
case \PropelColumnTypes::CLOB_EMU:
43+
return true;
4544
}
4645

4746
return false;
@@ -54,6 +53,6 @@ public function getSize()
5453

5554
public function isNotNull()
5655
{
57-
return ('id' === $this->name);
56+
return 'id' === $this->name;
5857
}
5958
}

src/Symfony/Bridge/Propel1/Tests/Fixtures/Item.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@
1111

1212
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
1313

14-
use PropelPDO;
15-
1614
class Item implements \Persistent
1715
{
1816
private $id;
19-
2017
private $value;
21-
2218
private $groupName;
23-
2419
private $price;
2520

2621
public function __construct($id = null, $value = null, $groupName = null, $price = null)
@@ -98,11 +93,11 @@ public function setDeleted($b)
9893
{
9994
}
10095

101-
public function delete(PropelPDO $con = null)
96+
public function delete(\PropelPDO $con = null)
10297
{
10398
}
10499

105-
public function save(PropelPDO $con = null)
100+
public function save(\PropelPDO $con = null)
106101
{
107102
}
108103
}

src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItem.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@
1111

1212
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
1313

14-
use PropelPDO;
15-
1614
class TranslatableItem implements \Persistent
1715
{
1816
private $id;
19-
2017
private $currentTranslations;
21-
2218
private $groupName;
23-
2419
private $price;
2520

2621
public function __construct($id = null, $translations = array())
@@ -91,15 +86,15 @@ public function setDeleted($b)
9186
{
9287
}
9388

94-
public function delete(PropelPDO $con = null)
89+
public function delete(\PropelPDO $con = null)
9590
{
9691
}
9792

98-
public function save(PropelPDO $con = null)
93+
public function save(\PropelPDO $con = null)
9994
{
10095
}
10196

102-
public function getTranslation($locale = 'de', PropelPDO $con = null)
97+
public function getTranslation($locale = 'de', \PropelPDO $con = null)
10398
{
10499
if (!isset($this->currentTranslations[$locale])) {
105100
$translation = new TranslatableItemI18n();

src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@
1111

1212
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
1313

14-
use PropelPDO;
15-
1614
class TranslatableItemI18n implements \Persistent
1715
{
1816
private $id;
19-
2017
private $locale;
21-
2218
private $value;
23-
2419
private $value2;
25-
2620
private $item;
2721

2822
public function __construct($id = null, $locale = null, $value = null)
@@ -84,11 +78,11 @@ public function setDeleted($b)
8478
{
8579
}
8680

87-
public function delete(PropelPDO $con = null)
81+
public function delete(\PropelPDO $con = null)
8882
{
8983
}
9084

91-
public function save(PropelPDO $con = null)
85+
public function save(\PropelPDO $con = null)
9286
{
9387
}
9488

src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ public function testDontAllowInvalidChoiceValues()
249249
*/
250250
public function testEmptyClass()
251251
{
252-
$choiceList = new ModelChoiceList('');
252+
new ModelChoiceList('');
253253
}
254254

255255
/**
256256
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
257257
*/
258258
public function testInvalidClass()
259259
{
260-
$choiceList = new ModelChoiceList('Foo\Bar\DoesNotExistClass');
260+
new ModelChoiceList('Foo\Bar\DoesNotExistClass');
261261
}
262262
}

src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php

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

1212
namespace Symfony\Bridge\Propel1\Tests\Form\DataTransformer;
1313

14-
use PropelObjectCollection;
1514
use Symfony\Bridge\Propel1\Form\DataTransformer\CollectionToArrayTransformer;
1615
use Symfony\Bridge\Propel1\Tests\Propel1TestCase;
1716

@@ -32,7 +31,7 @@ protected function setUp()
3231

3332
public function testTransform()
3433
{
35-
$result = $this->transformer->transform(new PropelObjectCollection());
34+
$result = $this->transformer->transform(new \PropelObjectCollection());
3635

3736
$this->assertTrue(is_array($result));
3837
$this->assertCount(0, $result);
@@ -56,7 +55,7 @@ public function testTransformThrowsExceptionIfNotPropelObjectCollection()
5655

5756
public function testTransformWithData()
5857
{
59-
$coll = new PropelObjectCollection();
58+
$coll = new \PropelObjectCollection();
6059
$coll->setData(array('foo', 'bar'));
6160

6261
$result = $this->transformer->transform($coll);

src/Symfony/Bridge/Propel1/Tests/Form/PropelTypeGuesserTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@
1818
class PropelTypeGuesserTest extends Propel1TestCase
1919
{
2020
const CLASS_NAME = 'Symfony\Bridge\Propel1\Tests\Fixtures\Item';
21-
2221
const UNKNOWN_CLASS_NAME = 'Symfony\Bridge\Propel1\Tests\Fixtures\UnknownItem';
2322

2423
private $guesser;
2524

26-
public function setUp()
25+
protected function setUp()
2726
{
2827
$this->guesser = new PropelTypeGuesser();
2928
}
3029

30+
protected function tearDown()
31+
{
32+
$this->guesser = null;
33+
}
34+
3135
public function testGuessMaxLengthWithText()
3236
{
3337
$value = $this->guesser->guessMaxLength(self::CLASS_NAME, 'value');

0 commit comments

Comments
 (0)
0