diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba80fc6..b1f0548 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: php-solr-explain Github Actions +name: BUILD on: push: diff --git a/Classes/Domain/Result/Explanation/Nodes/Explain.php b/Classes/Domain/Result/Explanation/Nodes/Explain.php index 2cea6fd..dd02ccf 100644 --- a/Classes/Domain/Result/Explanation/Nodes/Explain.php +++ b/Classes/Domain/Result/Explanation/Nodes/Explain.php @@ -91,7 +91,7 @@ protected function handleProductParent() $neighbors = $this->getParent()->getChildren(); if ($neighbors->count() > 1) { - $neighborScorePart = array(); + $neighborScorePart = []; $parentPercentage = $this->getParent()->getAbsoluteImpactPercentage(); foreach ($neighbors as $neighbor) { diff --git a/Classes/Domain/Result/Explanation/Nodes/Max.php b/Classes/Domain/Result/Explanation/Nodes/Max.php index 34004a9..52eacd9 100644 --- a/Classes/Domain/Result/Explanation/Nodes/Max.php +++ b/Classes/Domain/Result/Explanation/Nodes/Max.php @@ -20,7 +20,7 @@ public function __construct() public function getTieBreaker() { - $matches = array(); + $matches = []; preg_match('~plus (?.*) times~',$this->getContent(),$matches); if(isset($matches['tiebreaker'])) { return $matches['tiebreaker']; diff --git a/Classes/Domain/Result/Explanation/Parser.php b/Classes/Domain/Result/Explanation/Parser.php index a1b4a2d..4203aec 100644 --- a/Classes/Domain/Result/Explanation/Parser.php +++ b/Classes/Domain/Result/Explanation/Parser.php @@ -139,7 +139,7 @@ protected function removeLeadingSpacesFromNextLevelContent($tokenParts) { */ protected function getScoreFromContent($nodeName) { $score = 0.0; - $scoreMatches = array(); + $scoreMatches = []; preg_match('~(?[0-9]*\.[^ ]*)~',$nodeName,$scoreMatches); if(isset($scoreMatches['score']) && (float) $scoreMatches['score'] > 0) { $score = (float) $scoreMatches['score']; @@ -154,12 +154,12 @@ protected function getScoreFromContent($nodeName) { */ protected function getQueryAttribute($content) { $querystring = ''; - $matches = array(); + $matches = []; preg_match("~^#(?[^\n]*)~ism", $content, $matches); if(isset($matches['attributes'])) { $attributes = $matches['attributes']; - $attributeMatches = array(); + $attributeMatches = []; preg_match('~.*q=(?[^&]*)~ism',$attributes,$attributeMatches); if(isset($attributeMatches['querystring'])) { $querystring = $attributeMatches['querystring']; @@ -177,7 +177,7 @@ protected function getQueryAttribute($content) { */ protected function getFieldNameFromNodeName($nodeName) { $result = ''; - $matches = array(); + $matches = []; if (mb_strpos($nodeName,'weight(Synonym(') !== false ) { preg_match('~weight\(Synonym\((?[^\):]*)~', $nodeName, $matches); } elseif(mb_strpos($nodeName,'weight(') !== false ){ diff --git a/Classes/Domain/Result/Parser.php b/Classes/Domain/Result/Parser.php index a5ee831..3c788b5 100644 --- a/Classes/Domain/Result/Parser.php +++ b/Classes/Domain/Result/Parser.php @@ -123,7 +123,7 @@ protected function extractDocumentFields($fieldNode, Document $document) { if ($fieldNode->nodeName == 'arr') { //multivalue field - $value = array(); + $value = []; foreach ($fieldNode->childNodes as $singleField) { $value[] = $singleField->textContent; } diff --git a/README.md b/README.md index c41b514..af5760e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PHP Solr Explain -[![Build Status](https://travis-ci.org/TYPO3-Solr/php-solr-explain.svg?branch=master)](https://travis-ci.org/TYPO3-Solr/php-solr-explain) +[![Build Status](https://github.com/TYPO3-Solr/php-solr-explain/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/TYPO3-Solr/php-solr-explain/actions?query=branch%3Amaster) [![Latest Stable Version](https://poser.pugx.org/apache-solr-for-typo3/php-solr-explain/v/stable)](https://packagist.org/packages/apache-solr-for-typo3/php-solr-explain) [![Latest Unstable Version](https://poser.pugx.org/apache-solr-for-typo3/php-solr-explain/v/unstable)](https://packagist.org/packages/apache-solr-for-typo3/php-solr-explain) [![License](https://poser.pugx.org/apache-solr-for-typo3/php-solr-explain/license)](https://packagist.org/packages/apache-solr-for-typo3/php-solr-explain) diff --git a/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php b/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php index a3d897f..6acbae0 100644 --- a/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php +++ b/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php @@ -22,7 +22,7 @@ public function testFixture1() 'bar' ); - $this->assertEquals(array('name' => 100), $result); + $this->assertEquals(['name' => 100], $result); } /** diff --git a/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php b/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php index db5757e..7f2c9e0 100644 --- a/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php +++ b/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php @@ -37,7 +37,7 @@ public function testCanSummarizeFieldImpactFixture001() $explain->getRootNode()->visitNodes($visitor); $this->assertEquals(100.0,$visitor->getFieldImpact('name')); - $this->assertEquals(array('name'),$visitor->getRelevantFieldNames()); + $this->assertEquals(['name'],$visitor->getRelevantFieldNames()); } /** @@ -50,7 +50,7 @@ public function testCanSummarizeFieldImpactFixture003() $explain->getRootNode()->visitNodes($visitor); $this->assertEquals(95.756597168764,$visitor->getFieldImpact('price')); - $this->assertEquals(array('name','manu','price'),$visitor->getRelevantFieldNames()); + $this->assertEquals(['name','manu','price'],$visitor->getRelevantFieldNames()); } /** @@ -63,7 +63,7 @@ public function testCanSummarizeFieldImpactFixture004() $explain->getRootNode()->visitNodes($visitor); $this->assertEquals(100.0,$visitor->getFieldImpact('name')); - $this->assertEquals(array('name','price'),$visitor->getRelevantFieldNames()); + $this->assertEquals(['name','price'],$visitor->getRelevantFieldNames()); } /** @@ -75,7 +75,7 @@ public function testCanSummarizeCustomTieBreakerFixture() $visitor = new SummarizeFieldImpacts(); $explain->getRootNode()->visitNodes($visitor); - $this->assertEquals(array('expandedcontent','content','doctype'),$visitor->getRelevantFieldNames()); + $this->assertEquals(['expandedcontent','content','doctype'],$visitor->getRelevantFieldNames()); $this->assertEquals(47.9,round($visitor->getFieldImpact('doctype'),1)); $this->assertEquals(47.9,round($visitor->getFieldImpact('expandedcontent'),1)); $this->assertEquals(4.2,round($visitor->getFieldImpact('content'),1)); @@ -90,7 +90,7 @@ public function testCanSummarizeCustomTieBreaker2Fixture() $visitor = new SummarizeFieldImpacts(); $explain->getRootNode()->visitNodes($visitor); - $this->assertEquals(array('pr_title','doctype'),$visitor->getRelevantFieldNames()); + $this->assertEquals(['pr_title','doctype'],$visitor->getRelevantFieldNames()); $this->assertEquals(0.07,round($visitor->getFieldImpact('doctype'),2)); $this->assertEquals(99.93,round($visitor->getFieldImpact('pr_title'),2)); } @@ -105,7 +105,7 @@ public function testCanSummarizeCustomTieBreaker3Fixture() $visitor = new SummarizeFieldImpacts(); $explain->getRootNode()->visitNodes($visitor); - $this->assertEquals(array('keywords','expandedcontent','content','description','doctype'),$visitor->getRelevantFieldNames()); + $this->assertEquals(['keywords','expandedcontent','content','description','doctype'],$visitor->getRelevantFieldNames()); $this->assertEquals(0.00,round($visitor->getFieldImpact('keywords'),2)); $this->assertEquals(7.55,round($visitor->getFieldImpact('expandedcontent'),2)); $this->assertEquals(4.72,round($visitor->getFieldImpact('content'),2)); diff --git a/Tests/Domain/Result/Explanation/Visitors/SummarizeLeafImpactsTestCase.php b/Tests/Domain/Result/Explanation/Visitors/SummarizeLeafImpactsTestCase.php index 3414caa..1507702 100644 --- a/Tests/Domain/Result/Explanation/Visitors/SummarizeLeafImpactsTestCase.php +++ b/Tests/Domain/Result/Explanation/Visitors/SummarizeLeafImpactsTestCase.php @@ -33,45 +33,45 @@ protected function getExplain($filename) */ public function leafSumFixtureNameDataProvider() { - return array( - array('3.0.001'), - array('3.0.002'), - array('3.0.003'), - array('3.0.004'), - array('3.0.005'), - array('3.4.001'), - array('3.4.002'), - array('3.4.003'), - array('3.4.004'), - array('3.4.005'), - array('3.4.006'), - array('3.4.007'), - array('3.4.008'), - array('3.4.009'), - array('3.4.010'), - array('3.4.011'), - array('3.4.012'), - array('3.4.013'), - array('3.4.014'), - array('3.4.015'), - array('3.4.016'), - array('3.4.017'), + return [ + ['3.0.001'], + ['3.0.002'], + ['3.0.003'], + ['3.0.004'], + ['3.0.005'], + ['3.4.001'], + ['3.4.002'], + ['3.4.003'], + ['3.4.004'], + ['3.4.005'], + ['3.4.006'], + ['3.4.007'], + ['3.4.008'], + ['3.4.009'], + ['3.4.010'], + ['3.4.011'], + ['3.4.012'], + ['3.4.013'], + ['3.4.014'], + ['3.4.015'], + ['3.4.016'], + ['3.4.017'], //contains invalid content therefore no overall impact of 100 expected - array('3.4.018',0.0), - array('3.4.019'), - array('3.4.020'), - array('3.4.021'), - array('3.4.022'), - array('3.4.023'), - array('3.4.024'), - array('3.4.025'), - array('3.4.026'), - array('3.4.027'), - array('3.4.028'), - array('4.0.001'), - array('complex'), - array('custom.tieBreaker') - ); + ['3.4.018',0.0], + ['3.4.019'], + ['3.4.020'], + ['3.4.021'], + ['3.4.022'], + ['3.4.023'], + ['3.4.024'], + ['3.4.025'], + ['3.4.026'], + ['3.4.027'], + ['3.4.028'], + ['4.0.001'], + ['complex'], + ['custom.tieBreaker'] + ]; } /** diff --git a/Tests/Domain/Result/ParserTestCase.php b/Tests/Domain/Result/ParserTestCase.php index 12a7821..aab3daf 100644 --- a/Tests/Domain/Result/ParserTestCase.php +++ b/Tests/Domain/Result/ParserTestCase.php @@ -27,7 +27,7 @@ public function testFixture001() ); $this->assertEquals( - array('electronics','hard drive'), + ['electronics','hard drive'], $result->getDocumentCollection()->getDocument(1)->getFieldByName('cat')->getValue() );