Skip to content

Commit 674dd2d

Browse files
committed
TASK: Code cleanup and clearify some interfaces with type hints
1 parent b892c33 commit 674dd2d

24 files changed

Lines changed: 74 additions & 23 deletions

Classes/Client/ClientFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ClientFactory
3232
* Create a client
3333
*
3434
* @return Client
35+
* @throws \Flowpack\ElasticSearch\Exception
3536
*/
3637
public function create()
3738
{

Classes/Command/NodeIndexCommandController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use Neos\Flow\Annotations as Flow;
2828
use Neos\Flow\Cli\CommandController;
2929
use Neos\Flow\Configuration\ConfigurationManager;
30+
use Neos\Flow\Configuration\Exception\InvalidConfigurationTypeException;
31+
use Neos\Flow\Mvc\Exception\StopActionException;
3032
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
3133
use Neos\Neos\Controller\CreateContentContextTrait;
3234
use Symfony\Component\Yaml\Yaml;
@@ -105,6 +107,7 @@ class NodeIndexCommandController extends CommandController
105107
* Called by the Flow object framework after creating the object and resolving all dependencies.
106108
*
107109
* @param integer $cause Creation cause
110+
* @throws InvalidConfigurationTypeException
108111
*/
109112
public function initializeObject($cause)
110113
{
@@ -154,6 +157,7 @@ public function showMappingCommand()
154157
* @param string $identifier
155158
* @param string $workspace
156159
* @return void
160+
* @throws StopActionException
157161
*/
158162
public function indexNodeCommand($identifier, $workspace = null)
159163
{
@@ -221,6 +225,7 @@ public function indexNodeCommand($identifier, $workspace = null)
221225
* @param string $workspace name of the workspace which should be indexed
222226
* @param string $postfix Index postfix, index with the same postfix will be deleted if exist
223227
* @return void
228+
* @throws StopActionException
224229
*/
225230
public function buildCommand($limit = null, $update = false, $workspace = null, $postfix = null)
226231
{
@@ -312,7 +317,7 @@ public function cleanupCommand()
312317
* @param string $postfix
313318
* @return void
314319
*/
315-
protected function createNewIndex($postfix)
320+
protected function createNewIndex(string $postfix)
316321
{
317322
$this->nodeIndexer->setIndexNamePostfix($postfix ?: time());
318323
if ($this->nodeIndexer->getIndex()->exists() === true) {

Classes/Command/NodeTypeCommandController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* source code.
1212
*/
1313

14+
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
15+
use Neos\ContentRepository\Exception\NodeTypeNotFoundException;
1416
use Neos\Flow\Annotations as Flow;
1517
use Neos\Flow\Cli\CommandController;
1618

@@ -25,7 +27,7 @@ class NodeTypeCommandController extends CommandController
2527
{
2628
/**
2729
* @Flow\Inject
28-
* @var \Neos\ContentRepository\Domain\Service\NodeTypeManager
30+
* @var NodeTypeManager
2931
*/
3032
protected $nodeTypeManager;
3133

@@ -34,6 +36,7 @@ class NodeTypeCommandController extends CommandController
3436
*
3537
* @param string $nodeType the node type to optionally filter for
3638
* @return void
39+
* @throws NodeTypeNotFoundException
3740
*/
3841
public function showCommand($nodeType = null)
3942
{

Classes/Driver/AbstractNodeTypeMappingBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function initializeObject($cause)
6969
* @param string $nodeTypeName
7070
* @return string
7171
*/
72-
public function convertNodeTypeNameToMappingName($nodeTypeName)
72+
public function convertNodeTypeNameToMappingName(string $nodeTypeName): string
7373
{
7474
return str_replace('.', '-', $nodeTypeName);
7575
}

Classes/Driver/IndexDriverInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ interface IndexDriverInterface
1919
/**
2020
* Get the list of Indexes attached to the given alias
2121
*
22-
* @param $alias
22+
* @param string $alias
2323
* @return array
2424
*/
25-
public function indexesByAlias($alias);
25+
public function indexesByAlias(string $alias);
2626

2727
/**
2828
* Remove alias by name
2929
*
3030
* @param string $index
3131
* @return void
3232
*/
33-
public function deleteIndex($index);
33+
public function deleteIndex(string $index);
3434

3535
/**
3636
* Execute batch aliases actions

Classes/Driver/IndexerDriverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface IndexerDriverInterface
2828
* @param array $documentData
2929
* @return array
3030
*/
31-
public function document($indexName, NodeInterface $node, ElasticSearchDocument $document, array $documentData);
31+
public function document(string $indexName, NodeInterface $node, ElasticSearchDocument $document, array $documentData);
3232

3333
/**
3434
* Generate the query to index the fulltext of the document

Classes/Driver/NodeTypeMappingBuilderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface NodeTypeMappingBuilderInterface
2727
* @param string $nodeTypeName
2828
* @return string
2929
*/
30-
public function convertNodeTypeNameToMappingName($nodeTypeName);
30+
public function convertNodeTypeNameToMappingName(string $nodeTypeName): string;
3131

3232
/**
3333
* Builds a Mapping Collection from the configured node types

Classes/Driver/Version1/DocumentDriver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function delete(NodeInterface $node, $identifier)
5050

5151
/**
5252
* {@inheritdoc}
53+
* @throws \Flowpack\ElasticSearch\Exception
5354
*/
5455
public function deleteDuplicateDocumentNotMatchingType(Index $index, $documentIdentifier, NodeType $nodeType)
5556
{

Classes/Driver/Version1/IndexDriver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public function aliasActions(array $actions)
3333

3434
/**
3535
* {@inheritdoc}
36+
* @throws Exception
3637
*/
37-
public function deleteIndex($index)
38+
public function deleteIndex(string $index)
3839
{
3940
$response = $this->searchClient->request('HEAD', '/' . $index);
4041
if ($response->getStatusCode() === 200) {
@@ -47,8 +48,9 @@ public function deleteIndex($index)
4748

4849
/**
4950
* {@inheritdoc}
51+
* @throws Exception
5052
*/
51-
public function indexesByAlias($alias)
53+
public function indexesByAlias(string $alias)
5254
{
5355
$response = $this->searchClient->request('GET', '/_alias/' . $alias);
5456
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 404) {

Classes/Driver/Version1/IndexerDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class IndexerDriver extends AbstractIndexerDriver implements IndexerDriverInterf
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function document($indexName, NodeInterface $node, ElasticSearchDocument $document, array $documentData)
37+
public function document(string $indexName, NodeInterface $node, ElasticSearchDocument $document, array $documentData)
3838
{
3939
if ($this->isFulltextRoot($node)) {
4040
// for fulltext root documents, we need to preserve the "__fulltext" field. That's why we use the

0 commit comments

Comments
 (0)