Skip to content

Commit 9861438

Browse files
authored
Merge pull request #46 from kdambekalns/cleanup
TASK: Clean up code and tests This does some code style cleanup, fixes type hints and adjusts the code in two places: - indexing skips non-gettable properties now - no longer use deprecated `getClassNameByObject` The latter makes this package depend on Flow 3.0 or higher. Also, the package now contains a LICENSE file (MIT license).
2 parents 919652e + 402dd6d commit 9861438

30 files changed

+188
-119
lines changed

Classes/Flowpack/ElasticSearch/Command/IndexCommandController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class IndexCommandController extends \TYPO3\Flow\Cli\CommandController
5656
*
5757
* @param string $indexName The name of the new index
5858
* @param string $clientName The client name to use
59+
* @return void
5960
*/
6061
public function createCommand($indexName, $clientName = null)
6162
{
@@ -84,6 +85,7 @@ public function createCommand($indexName, $clientName = null)
8485
*
8586
* @param string $indexName The name of the new index
8687
* @param string $clientName The client name to use
88+
* @return void
8789
*/
8890
public function updateSettingsCommand($indexName, $clientName = null)
8991
{
@@ -112,6 +114,7 @@ public function updateSettingsCommand($indexName, $clientName = null)
112114
*
113115
* @param string $indexName The name of the index to be removed
114116
* @param string $clientName The client name to use
117+
* @return void
115118
*/
116119
public function deleteCommand($indexName, $clientName = null)
117120
{
@@ -140,6 +143,7 @@ public function deleteCommand($indexName, $clientName = null)
140143
*
141144
* @param string $indexName The name of the index to be removed
142145
* @param string $clientName The client name to use
146+
* @return void
143147
*/
144148
public function refreshCommand($indexName, $clientName = null)
145149
{
@@ -164,6 +168,8 @@ public function refreshCommand($indexName, $clientName = null)
164168

165169
/**
166170
* List available document type
171+
*
172+
* @return void
167173
*/
168174
public function showConfiguredTypesCommand()
169175
{
@@ -181,6 +187,7 @@ public function showConfiguredTypesCommand()
181187
* @param string $object Class name of a domain object. If given, will only work on this single object
182188
* @param boolean $conductUpdate Set to TRUE to conduct the required corrections
183189
* @param string $clientName The client name to use
190+
* @return void
184191
*/
185192
public function statusCommand($object = null, $conductUpdate = false, $clientName = null)
186193
{
@@ -258,7 +265,6 @@ public function statusCommand($object = null, $conductUpdate = false, $clientNam
258265
/**
259266
* @param Client $client
260267
* @param string $className
261-
*
262268
* @return array
263269
*/
264270
protected function getModificationsNeededStatesAndIdentifiers(Client $client, $className)

Classes/Flowpack/ElasticSearch/Command/MappingCommandController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* source code.
1212
*/
1313

14+
use Flowpack\ElasticSearch\Mapping\MappingCollection;
1415
use TYPO3\Flow\Annotations as Flow;
1516

1617
/**
@@ -178,11 +179,11 @@ protected function markupDiffValue($entityValue, $backendValue)
178179
/**
179180
* Traverses through mappingInformation array and aggregates by index and type names
180181
*
181-
* @param \Flowpack\ElasticSearch\Mapping\MappingCollection $mappingCollection
182+
* @param MappingCollection $mappingCollection
182183
* @throws \Flowpack\ElasticSearch\Exception
183184
* @return array with index names as keys, second level type names as keys
184185
*/
185-
protected function buildArrayFromMappingCollection(\Flowpack\ElasticSearch\Mapping\MappingCollection $mappingCollection)
186+
protected function buildArrayFromMappingCollection(MappingCollection $mappingCollection)
186187
{
187188
$return = array();
188189

Classes/Flowpack/ElasticSearch/Domain/Exception/DocumentPropertiesMismatchException.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@
1111
* source code.
1212
*/
1313

14+
use TYPO3\Flow\Error\Result;
15+
1416
/**
1517
* Signals a mismatch between the
1618
*/
1719
class DocumentPropertiesMismatchException extends \Flowpack\ElasticSearch\Exception
1820
{
1921
/**
20-
* @var \TYPO3\Flow\Error\Result
22+
* @var Result
2123
*/
2224
protected $errorResult;
2325

2426
/**
25-
* @param \TYPO3\Flow\Error\Result $result
27+
* @param Result $result
28+
* @return void
2629
*/
27-
public function setErrorResult(\TYPO3\Flow\Error\Result $result)
30+
public function setErrorResult(Result $result)
2831
{
2932
$this->errorResult = $result;
3033
}

Classes/Flowpack/ElasticSearch/Domain/Factory/ClientFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function injectSettings(array $settings)
3737
* @param string $clientClassName
3838
* @throws \Flowpack\ElasticSearch\Exception
3939
* @return \Flowpack\ElasticSearch\Domain\Model\Client
40+
* @return void
4041
*/
4142
public function create($bundle = null, $clientClassName = 'Flowpack\ElasticSearch\Domain\Model\Client')
4243
{
@@ -59,12 +60,11 @@ public function create($bundle = null, $clientClassName = 'Flowpack\ElasticSearc
5960
}
6061

6162
/**
62-
* @param $clientsSettings
63-
*
63+
* @param array $clientsSettings
6464
* @return array
6565
* @throws \Flowpack\ElasticSearch\Exception
6666
*/
67-
protected function buildClientConfigurations($clientsSettings)
67+
protected function buildClientConfigurations(array $clientsSettings)
6868
{
6969
$clientConfigurations = array();
7070
foreach ($clientsSettings as $clientSettings) {

Classes/Flowpack/ElasticSearch/Domain/Model/AbstractType.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ public function getIndex()
7070
/**
7171
* Returns a document
7272
*
73-
* @param $id
74-
*
73+
* @param string $id
7574
* @return \Flowpack\ElasticSearch\Domain\Model\Document
7675
*/
7776
public function findDocumentById($id)
@@ -86,7 +85,7 @@ public function findDocumentById($id)
8685
}
8786

8887
/**
89-
* @param $id
88+
* @param string $id
9089
* @return boolean ...whether the deletion is considered successful
9190
*/
9291
public function deleteDocumentById($id)
@@ -125,10 +124,9 @@ public function search(array $searchQuery)
125124
* @param string $path
126125
* @param array $arguments
127126
* @param string $content
128-
*
129127
* @return \Flowpack\ElasticSearch\Transfer\Response
130128
*/
131-
public function request($method, $path = null, $arguments = array(), $content = null)
129+
public function request($method, $path = null, array $arguments = array(), $content = null)
132130
{
133131
$path = '/' . $this->name . ($path ?: '');
134132

Classes/Flowpack/ElasticSearch/Domain/Model/Client.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,9 @@ public function findIndex($indexName)
9191
* @param string $path
9292
* @param array $arguments
9393
* @param string|array $content
94-
*
9594
* @return \Flowpack\ElasticSearch\Transfer\Response
9695
*/
97-
public function request($method, $path = null, $arguments = array(), $content = null)
96+
public function request($method, $path = null, array $arguments = array(), $content = null)
9897
{
9998
return $this->requestService->request($method, $this, $path, $arguments, $content);
10099
}

Classes/Flowpack/ElasticSearch/Domain/Model/Client/ClientConfiguration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ClientConfiguration
4545

4646
/**
4747
* @param string $host
48+
* @return void
4849
*/
4950
public function setHost($host)
5051
{
@@ -61,6 +62,7 @@ public function getHost()
6162

6263
/**
6364
* @param int $port
65+
* @return void
6466
*/
6567
public function setPort($port)
6668
{
@@ -77,6 +79,7 @@ public function getPort()
7779

7880
/**
7981
* @param string $scheme
82+
* @return void
8083
*/
8184
public function setScheme($scheme)
8285
{

Classes/Flowpack/ElasticSearch/Domain/Model/Document.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class Document
2020
{
2121
/**
22-
* @var \Flowpack\ElasticSearch\Domain\Model\AbstractType
22+
* @var AbstractType
2323
*/
2424
protected $type;
2525

@@ -52,10 +52,10 @@ class Document
5252
protected $dirty = true;
5353

5454
/**
55-
* @param \Flowpack\ElasticSearch\Domain\Model\AbstractType $type
55+
* @param AbstractType $type
5656
* @param array $data
5757
* @param string $id
58-
* @param null $version
58+
* @param integer $version
5959
*/
6060
public function __construct(AbstractType $type, array $data = null, $id = null, $version = null)
6161
{
@@ -68,6 +68,8 @@ public function __construct(AbstractType $type, array $data = null, $id = null,
6868
/**
6969
* When cloning (locally), the cloned object doesn't represent a stored one anymore,
7070
* so reset id, version and the dirty state.
71+
*
72+
* @return void
7173
*/
7274
public function __clone()
7375
{
@@ -81,10 +83,9 @@ public function __clone()
8183
* @param string $path
8284
* @param array $arguments
8385
* @param string $content
84-
*
8586
* @return \Flowpack\ElasticSearch\Transfer\Response
8687
*/
87-
protected function request($method, $path = null, $arguments = array(), $content = null)
88+
protected function request($method, $path = null, array $arguments = array(), $content = null)
8889
{
8990
return $this->type->request($method, $path, $arguments, $content);
9091
}
@@ -114,6 +115,7 @@ public function store()
114115

115116
/**
116117
* @param boolean $dirty
118+
* @return void
117119
*/
118120
protected function setDirty($dirty = true)
119121
{
@@ -148,8 +150,9 @@ public function getData()
148150

149151
/**
150152
* @param array $data
153+
* @return void
151154
*/
152-
public function setData($data)
155+
public function setData(array $data)
153156
{
154157
$this->data = $data;
155158
$this->setDirty();
@@ -168,7 +171,6 @@ public function getId()
168171
*
169172
* @param string $fieldName
170173
* @param boolean $silent
171-
*
172174
* @throws \Flowpack\ElasticSearch\Exception
173175
* @return mixed
174176
*/
@@ -182,7 +184,7 @@ public function getField($fieldName, $silent = false)
182184
}
183185

184186
/**
185-
* @return \Flowpack\ElasticSearch\Domain\Model\AbstractType the type of this Document
187+
* @return AbstractType the type of this Document
186188
*/
187189
public function getType()
188190
{

Classes/Flowpack/ElasticSearch/Domain/Model/GenericType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class GenericType extends AbstractType
2020
{
2121
/**
22-
* @param \Flowpack\ElasticSearch\Domain\Model\Index $index
22+
* @param Index $index
2323
* @param string $name
2424
*/
2525
public function __construct(Index $index, $name)

Classes/Flowpack/ElasticSearch/Domain/Model/Index.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public function injectSettings(array $settings)
9696
/**
9797
* @param $name
9898
* @param Client $client $client
99-
*
10099
* @throws \Flowpack\ElasticSearch\Exception
101100
*/
102101
public function __construct($name, Client $client = null)
@@ -113,7 +112,7 @@ public function __construct($name, Client $client = null)
113112
}
114113

115114
/**
116-
* @param $typeName
115+
* @param string $typeName
117116
* @return \Flowpack\ElasticSearch\Domain\Model\AbstractType
118117
*/
119118
public function findType($typeName)
@@ -123,7 +122,6 @@ public function findType($typeName)
123122

124123
/**
125124
* @param array<AbstractType> $types
126-
*
127125
* @return TypeGroup
128126
*/
129127
public function findTypeGroup(array $types)
@@ -189,11 +187,10 @@ public function refresh()
189187
* @param array $arguments
190188
* @param string $content
191189
* @param boolean $prefixIndex
192-
*
193-
* @throws \Flowpack\ElasticSearch\Exception
194190
* @return \Flowpack\ElasticSearch\Transfer\Response
191+
* @throws \Flowpack\ElasticSearch\Exception
195192
*/
196-
public function request($method, $path = null, $arguments = array(), $content = null, $prefixIndex = true)
193+
public function request($method, $path = null, array $arguments = array(), $content = null, $prefixIndex = true)
197194
{
198195
if ($this->client === null) {
199196
throw new Exception('The client of the index "' . $this->name . '" is not set, hence no requests can be done.');
@@ -218,14 +215,16 @@ public function getName()
218215

219216
/**
220217
* @param Client $client
218+
* @return void
221219
*/
222220
public function setClient($client)
223221
{
224222
$this->client = $client;
225223
}
226224

227225
/**
228-
* @param $settingsKey
226+
* @param string $settingsKey
227+
* @return void
229228
*/
230229
public function setSettingsKey($settingsKey)
231230
{

0 commit comments

Comments
 (0)