Skip to content

Commit

Permalink
[TASK] Use short array syntax
Browse files Browse the repository at this point in the history
Fixes: #5
  • Loading branch information
dkd-kaehm committed Sep 10, 2021
1 parent 870a5c2 commit ea20f4b
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: php-solr-explain Github Actions
name: BUILD

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Result/Explanation/Nodes/Explain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Result/Explanation/Nodes/Max.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
public function getTieBreaker()
{

$matches = array();
$matches = [];
preg_match('~plus (?<tiebreaker>.*) times~',$this->getContent(),$matches);
if(isset($matches['tiebreaker'])) {
return $matches['tiebreaker'];
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Result/Explanation/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected function removeLeadingSpacesFromNextLevelContent($tokenParts) {
*/
protected function getScoreFromContent($nodeName) {
$score = 0.0;
$scoreMatches = array();
$scoreMatches = [];
preg_match('~(?<score>[0-9]*\.[^ ]*)~',$nodeName,$scoreMatches);
if(isset($scoreMatches['score']) && (float) $scoreMatches['score'] > 0) {
$score = (float) $scoreMatches['score'];
Expand All @@ -154,12 +154,12 @@ protected function getScoreFromContent($nodeName) {
*/
protected function getQueryAttribute($content) {
$querystring = '';
$matches = array();
$matches = [];
preg_match("~^#(?<attributes>[^\n]*)~ism", $content, $matches);

if(isset($matches['attributes'])) {
$attributes = $matches['attributes'];
$attributeMatches = array();
$attributeMatches = [];
preg_match('~.*q=(?<querystring>[^&]*)~ism',$attributes,$attributeMatches);
if(isset($attributeMatches['querystring'])) {
$querystring = $attributeMatches['querystring'];
Expand All @@ -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\((?<fieldname>[^\):]*)~', $nodeName, $matches);
} elseif(mb_strpos($nodeName,'weight(') !== false ){
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Result/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Domain/Result/Explanation/ExplainServiceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testFixture1()
'bar'
);

$this->assertEquals(array('name' => 100), $result);
$this->assertEquals(['name' => 100], $result);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand All @@ -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());
}

/**
Expand All @@ -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());
}

/**
Expand All @@ -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));
Expand All @@ -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));
}
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Domain/Result/ParserTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testFixture001()
);

$this->assertEquals(
array('electronics','hard drive'),
['electronics','hard drive'],
$result->getDocumentCollection()->getDocument(1)->getFieldByName('cat')->getValue()
);

Expand Down

0 comments on commit ea20f4b

Please sign in to comment.