Skip to content

Commit

Permalink
[TASK] Drop PHP 7.2 + 7.3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dkd-kaehm committed Oct 27, 2023
1 parent 4c93539 commit 739d883
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 257 deletions.
72 changes: 72 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# EditorConfig is awesome: http://EditorConfig.org
# TYPO3 Standard: https://github.com/TYPO3/coding-standards

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

# TS/JS-Files
[*.{ts,js}]
indent_size = 2

# JSON-Files
[*.json]
indent_style = tab

# ReST-Files
[*.{rst,rst.txt}]
indent_size = 3
max_line_length = 80

# YAML-Files
[*.{yaml,yml}]
indent_size = 2

# NEON-Files
[*.neon]
indent_size = 2
indent_style = tab

# package.json
[package.json]
indent_size = 2

# composer.json (Reason: git history in composer.json)
[composer.json]
indent_size = 2
indent_style = space

# TypoScript
[*.{typoscript,tsconfig}]
indent_size = 2

# XLF/XML-Files
[*.{xlf,xml}]
indent_style = tab

# HTML-Files
[*.html]
indent_size = 2
indent_style = tab

# SQL-Files
[*.sql]
indent_style = tab
indent_size = 2

# .htaccess
[{_.htaccess,.htaccess}]
indent_style = tab

# Bash scripts
[*.sh]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
PHP: [ '7.2', '7.3', '7.4', '8.0' ]
PHP: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

name: On PHP ${{ matrix.PHP }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions Build/phar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ rm -fR .Build
composer install --no-dev

cd ..
wget https://github.com/clue/phar-composer/releases/download/v1.2.0/phar-composer-1.2.0.phar -O phar-composer
php phar-composer build "$ROOT_PATH/../php-solr-explain"
wget https://github.com/clue/phar-composer/releases/download/v1.4.0/phar-composer-1.4.0.phar -O phar-composer
php phar-composer build "$ROOT_PATH/../php-solr-explain"
86 changes: 25 additions & 61 deletions Classes/Domain/Result/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
use DOMDocument;
use DOMElement;
use DOMNodeList;
use DOMText;
use DOMXPath;

class Parser
{
/**
* @var
* @var DOMNodeList|false
*/
protected $explainNodes;

Expand Down Expand Up @@ -50,10 +51,6 @@ public function parse(string $xml): Result
return $result;
}

/**
* @param DOMXPath $resultXpath
* @return int
*/
protected function extractCompleteResultCount(DOMXPath $resultXpath): int
{
$result = 0;
Expand All @@ -66,10 +63,6 @@ protected function extractCompleteResultCount(DOMXPath $resultXpath): int
return $result;
}

/**
* @param DOMXPath $resultXpath
* @return int
*/
protected function extractQueryTime(DOMXPath $resultXpath): int
{
$result = 0;
Expand All @@ -82,10 +75,6 @@ protected function extractQueryTime(DOMXPath $resultXpath): int
return $result;
}

/**
* @param DOMXPath $resultXpath
* @return Collection
*/
protected function extractDocumentCollection(DOMXPath $resultXpath): Collection
{
$result = new Collection();
Expand All @@ -95,8 +84,11 @@ protected function extractDocumentCollection(DOMXPath $resultXpath): Collection
foreach ($documentNodes as $documentNode) {
$document = new Document();

/* @var DOMElement $documentNode */
/* @var DOMElement|DOMText $documentNode */
foreach ($documentNode->childNodes as $fieldNode) {
if (!($fieldNode instanceof DOMElement)) {
continue;
}
$this->extractDocumentFields($fieldNode, $document);
}

Expand All @@ -113,37 +105,31 @@ protected function extractDocumentCollection(DOMXPath $resultXpath): Collection
/**
* This method is used to extract the fields from the xml response
* and attach them to the document object.
*
* @param $fieldNode
* @param Document $document
*/
protected function extractDocumentFields($fieldNode, Document $document)
protected function extractDocumentFields(DOMElement $fieldNode, Document $document): void
{
if ($fieldNode instanceof DOMElement) {
$field = new Field();

if ($fieldNode->nodeName == 'arr') {
//multivalue field
$value = [];
foreach ($fieldNode->childNodes as $singleField) {
$value[] = $singleField->textContent;
}
} else {
//single value field
$value = $fieldNode->textContent;
$field = new Field();

if ($fieldNode->nodeName == 'arr') {
//multivalue field
$value = [];
foreach ($fieldNode->childNodes as $singleField) {
$value[] = $singleField->textContent;
}
} else {
//single value field
$value = $fieldNode->textContent;
}

$field->setValue($value);
$field->setValue($value);

$fieldName = $fieldNode->getAttribute('name');
$field->setName($fieldName);
$fieldName = $fieldNode->getAttribute('name');
$field->setName($fieldName);

$document->addField($field);
}
$document->addField($field);
}

/**
* @param DOMXPath $resultXPath
* @return DOMNodeList|false a DOMNodeList containing all nodes matching
* the given XPath expression. Any expression which does not return nodes
* will return an empty DOMNodeList. The return is false if the expression
Expand All @@ -158,12 +144,7 @@ protected function getExplainNodes(DOMXPath $resultXPath)
return $this->explainNodes;
}

/**
* @param DOMXPath $resultXPath
* @param
* @return string
*/
protected function extractExplainContent(DOMXPath $resultXPath, $documentCount): string
protected function extractExplainContent(DOMXPath $resultXPath, int $documentCount): string
{
$explainContent = '';

Expand All @@ -176,10 +157,6 @@ protected function extractExplainContent(DOMXPath $resultXPath, $documentCount):
return $explainContent;
}

/**
* @param DOMXPath $xpath
* @return Timing
*/
protected function extractTiming(DOMXPath $xpath): Timing
{
$prepareItemCollection = new ItemCollection();
Expand Down Expand Up @@ -212,13 +189,9 @@ protected function extractTiming(DOMXPath $xpath): Timing
}

/**
* This method is used to build timing items from timing subnodes.
*
* @param DOMXPath $xpath
* @param string $nodeXPath
* @param ItemCollection $itemCollection
* This method is used to build timing items from timing sub-nodes.
*/
protected function extractTimingSubNodes(DOMXPath $xpath, string $nodeXPath, ItemCollection $itemCollection)
protected function extractTimingSubNodes(DOMXPath $xpath, string $nodeXPath, ItemCollection $itemCollection): void
{
$nodes = $xpath->query($nodeXPath);

Expand All @@ -238,11 +211,6 @@ protected function extractTimingSubNodes(DOMXPath $xpath, string $nodeXPath, Ite
}
}

/**
* @param DOMXPath $xpath
* @param string $path
* @return float
*/
protected function getTimeFromNode(DOMXPath $xpath, string $path): float
{
$timeNode = $xpath->query($path);
Expand All @@ -254,10 +222,6 @@ protected function getTimeFromNode(DOMXPath $xpath, string $path): float
return $time;
}

/**
* @param DOMXPath $xpath
* @return string
*/
protected function extractParserName(DOMXPath $xpath): string
{
$result = '';
Expand Down
68 changes: 11 additions & 57 deletions Classes/Domain/Result/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,115 +7,69 @@

class Result
{
/**
* @var int
*/
protected $completeResultCount = 0;
protected int $completeResultCount = 0;

/**
* @var int
*/
protected $queryTime = 0;
protected int $queryTime = 0;

/**
* @var string
*/
protected $queryParser = '';
protected string $queryParser = '';

/**
* @var Collection
*/
protected $documentCollection;
protected ?Collection $documentCollection = null;

/**
* @var Timing
*/
protected $timing;
protected ?Timing $timing = null;

/**
* @param int $completeResultCount
* @return self
*/
public function setCompleteResultCount(int $completeResultCount): Result
{
$this->completeResultCount = $completeResultCount;

return $this;
}

/**
* @return int
*/
public function getCompleteResultCount(): int
{
return $this->completeResultCount;
}

/**
* @return int
*/
public function getResultCount(): int
{
return $this->documentCollection->count();
}

/**
* @param int $queryTime
* @return self
*/
public function setQueryTime(int $queryTime): Result
{
$this->queryTime = $queryTime;

return $this;
}

/**
* @return int
*/
public function getQueryTime(): int
{
return $this->queryTime;
}

/**
* @param Collection $documentCollection
*/
public function setDocumentCollection(Collection $documentCollection)
public function setDocumentCollection(Collection $documentCollection): Result
{
$this->documentCollection = $documentCollection;
return $this;
}

/**
* @return Collection
*/
public function getDocumentCollection(): Collection
{
return $this->documentCollection;
}

/**
* @param Timing $timing
*/
public function setTiming(Timing $timing)
public function setTiming(Timing $timing): Result
{
$this->timing = $timing;
return $this;
}

/**
* @return Timing
*/
public function getTiming(): ?Timing
{
return $this->timing;
}

/**
* @param string $queryParser
*/
public function setQueryParser(string $queryParser)
public function setQueryParser(string $queryParser): Result
{
$this->queryParser = $queryParser;
return $this;
}

/**
Expand Down
Loading

0 comments on commit 739d883

Please sign in to comment.