Skip to content

Commit bb4618c

Browse files
committed
Even more QA
1 parent 6a07f7b commit bb4618c

12 files changed

+57
-59
lines changed

Event/IndexEvent.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the FOSElasticaBundle project.
5+
*
6+
* (c) Tim Nagel <[email protected]>
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 FOS\ElasticaBundle\Event;
13+
14+
use Symfony\Component\EventDispatcher\Event;
15+
16+
class IndexEvent extends Event
17+
{
18+
/**
19+
* @var string
20+
*/
21+
private $index;
22+
23+
/**
24+
* @param string $index
25+
*/
26+
public function __construct($index)
27+
{
28+
$this->index = $index;
29+
}
30+
31+
/**
32+
* @return string
33+
*/
34+
public function getIndex()
35+
{
36+
return $this->index;
37+
}
38+
}

Event/IndexPopulateEvent.php

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

1212
namespace FOS\ElasticaBundle\Event;
1313

14-
use Symfony\Component\EventDispatcher\Event;
15-
1614
/**
1715
* Index Populate Event.
1816
*
1917
* @author Oleg Andreyev <[email protected]>
2018
*/
21-
class IndexPopulateEvent extends Event
19+
class IndexPopulateEvent extends IndexEvent
2220
{
2321
const PRE_INDEX_POPULATE = 'elastica.index.index_pre_populate';
2422
const POST_INDEX_POPULATE = 'elastica.index.index_post_populate';
2523

26-
/**
27-
* @var string
28-
*/
29-
private $index;
30-
3124
/**
3225
* @var bool
3326
*/
@@ -45,19 +38,12 @@ class IndexPopulateEvent extends Event
4538
*/
4639
public function __construct($index, $reset, $options)
4740
{
48-
$this->index = $index;
41+
parent::__construct($index);
42+
4943
$this->reset = $reset;
5044
$this->options = $options;
5145
}
5246

53-
/**
54-
* @return string
55-
*/
56-
public function getIndex()
57-
{
58-
return $this->index;
59-
}
60-
6147
/**
6248
* @return boolean
6349
*/

Event/IndexResetEvent.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111

1212
namespace FOS\ElasticaBundle\Event;
1313

14-
use Symfony\Component\EventDispatcher\Event;
15-
1614
/**
1715
* Index ResetEvent.
1816
*
1917
* @author Oleg Andreyev <[email protected]>
2018
*/
21-
class IndexResetEvent extends Event
19+
class IndexResetEvent extends IndexEvent
2220
{
2321
const PRE_INDEX_RESET = 'elastica.index.pre_reset';
2422
const POST_INDEX_RESET = 'elastica.index.post_reset';
@@ -28,11 +26,6 @@ class IndexResetEvent extends Event
2826
*/
2927
private $force;
3028

31-
/**
32-
* @var string
33-
*/
34-
private $index;
35-
3629
/**
3730
* @var bool
3831
*/
@@ -45,19 +38,12 @@ class IndexResetEvent extends Event
4538
*/
4639
public function __construct($index, $populating, $force)
4740
{
41+
parent::__construct($index);
42+
4843
$this->force = $force;
49-
$this->index = $index;
5044
$this->populating = $populating;
5145
}
5246

53-
/**
54-
* @return string
55-
*/
56-
public function getIndex()
57-
{
58-
return $this->index;
59-
}
60-
6147
/**
6248
* @return boolean
6349
*/

Event/TypeResetEvent.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@
1818
*
1919
* @author Oleg Andreyev <[email protected]>
2020
*/
21-
class TypeResetEvent extends Event
21+
class TypeResetEvent extends IndexEvent
2222
{
2323
const PRE_TYPE_RESET = 'elastica.index.type_pre_reset';
2424
const POST_TYPE_RESET = 'elastica.index.type_post_reset';
2525

26-
/**
27-
* @var string
28-
*/
29-
private $index;
30-
3126
/**
3227
* @var string
3328
*/
@@ -39,16 +34,9 @@ class TypeResetEvent extends Event
3934
*/
4035
public function __construct($index, $type)
4136
{
42-
$this->type = $type;
43-
$this->index = $index;
44-
}
37+
parent::__construct($index);
4538

46-
/**
47-
* @return string
48-
*/
49-
public function getIndex()
50-
{
51-
return $this->index;
39+
$this->type = $type;
5240
}
5341

5442
/**

Propel/Provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function populate(\Closure $loggerClosure = null, array $options = array(
3030
->getArrayCopy();
3131

3232
$objects = array_filter($objects, array($this, 'isObjectIndexable'));
33-
if ($objects) {
33+
if (!empty($objects)) {
3434
$this->objectPersister->insertMany($objects);
3535
}
3636

Provider/AbstractProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class AbstractProvider implements ProviderInterface
2525
protected $options;
2626

2727
/**
28-
* @var Indexable
28+
* @var IndexableInterface
2929
*/
3030
private $indexable;
3131

Serializer/Callback.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Callback
99
{
1010
protected $serializer;
11-
protected $groups;
11+
protected $groups = array();
1212
protected $version;
1313

1414
public function setSerializer($serializer)
@@ -41,7 +41,7 @@ public function serialize($object)
4141
{
4242
$context = $this->serializer instanceof SerializerInterface ? SerializationContext::create()->enableMaxDepthChecks() : array();
4343

44-
if ($this->groups) {
44+
if (!empty($this->groups)) {
4545
$context->setGroups($this->groups);
4646
}
4747

Tests/Persister/ObjectPersisterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function testThatErrorIsHandledWhenCannotInsertManyObject()
203203
private function getTransformer()
204204
{
205205
$transformer = new ModelToElasticaAutoTransformer();
206-
$transformer->setPropertyAccessor(PropertyAccess::getPropertyAccessor());
206+
$transformer->setPropertyAccessor(PropertyAccess::createPropertyAccessor());
207207

208208
return $transformer;
209209
}

Tests/Persister/ObjectSerializerPersisterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testThatCanInsertManyObjects()
112112
private function getTransformer()
113113
{
114114
$transformer = new ModelToElasticaIdentifierTransformer();
115-
$transformer->setPropertyAccessor(PropertyAccess::getPropertyAccessor());
115+
$transformer->setPropertyAccessor(PropertyAccess::createPropertyAccessor());
116116

117117
return $transformer;
118118
}

Tests/RepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public function testThatFindHybridCallsFindHybridOnFinder()
5757

5858
/**
5959
* @param string $testQuery
60-
* @param int $testLimit
60+
* @param mixed $testLimit
6161
* @param string $method
6262
*
63-
* @return \FOS\ElasticaBundle\Finder\TransformedFinder|\PHPUnit_Framework_MockObject_MockObject
63+
* @return \FOS\ElasticaBundle\Finder\TransformedFinder
6464
*/
6565
private function getFinderMock($testQuery, $testLimit = null, $method = 'find')
6666
{

0 commit comments

Comments
 (0)