Skip to content

Commit ea20f4b

Browse files
committed
[TASK] Use short array syntax
Fixes: #5
1 parent 870a5c2 commit ea20f4b

File tree

10 files changed

+55
-55
lines changed

10 files changed

+55
-55
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: php-solr-explain Github Actions
1+
name: BUILD
22

33
on:
44
push:

Classes/Domain/Result/Explanation/Nodes/Explain.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function handleProductParent()
9191
$neighbors = $this->getParent()->getChildren();
9292

9393
if ($neighbors->count() > 1) {
94-
$neighborScorePart = array();
94+
$neighborScorePart = [];
9595
$parentPercentage = $this->getParent()->getAbsoluteImpactPercentage();
9696

9797
foreach ($neighbors as $neighbor) {

Classes/Domain/Result/Explanation/Nodes/Max.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct()
2020
public function getTieBreaker()
2121
{
2222

23-
$matches = array();
23+
$matches = [];
2424
preg_match('~plus (?<tiebreaker>.*) times~',$this->getContent(),$matches);
2525
if(isset($matches['tiebreaker'])) {
2626
return $matches['tiebreaker'];

Classes/Domain/Result/Explanation/Parser.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function removeLeadingSpacesFromNextLevelContent($tokenParts) {
139139
*/
140140
protected function getScoreFromContent($nodeName) {
141141
$score = 0.0;
142-
$scoreMatches = array();
142+
$scoreMatches = [];
143143
preg_match('~(?<score>[0-9]*\.[^ ]*)~',$nodeName,$scoreMatches);
144144
if(isset($scoreMatches['score']) && (float) $scoreMatches['score'] > 0) {
145145
$score = (float) $scoreMatches['score'];
@@ -154,12 +154,12 @@ protected function getScoreFromContent($nodeName) {
154154
*/
155155
protected function getQueryAttribute($content) {
156156
$querystring = '';
157-
$matches = array();
157+
$matches = [];
158158
preg_match("~^#(?<attributes>[^\n]*)~ism", $content, $matches);
159159

160160
if(isset($matches['attributes'])) {
161161
$attributes = $matches['attributes'];
162-
$attributeMatches = array();
162+
$attributeMatches = [];
163163
preg_match('~.*q=(?<querystring>[^&]*)~ism',$attributes,$attributeMatches);
164164
if(isset($attributeMatches['querystring'])) {
165165
$querystring = $attributeMatches['querystring'];
@@ -177,7 +177,7 @@ protected function getQueryAttribute($content) {
177177
*/
178178
protected function getFieldNameFromNodeName($nodeName) {
179179
$result = '';
180-
$matches = array();
180+
$matches = [];
181181
if (mb_strpos($nodeName,'weight(Synonym(') !== false ) {
182182
preg_match('~weight\(Synonym\((?<fieldname>[^\):]*)~', $nodeName, $matches);
183183
} elseif(mb_strpos($nodeName,'weight(') !== false ){

Classes/Domain/Result/Parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function extractDocumentFields($fieldNode, Document $document) {
123123

124124
if ($fieldNode->nodeName == 'arr') {
125125
//multivalue field
126-
$value = array();
126+
$value = [];
127127
foreach ($fieldNode->childNodes as $singleField) {
128128
$value[] = $singleField->textContent;
129129
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PHP Solr Explain
22

3-
[![Build Status](https://travis-ci.org/TYPO3-Solr/php-solr-explain.svg?branch=master)](https://travis-ci.org/TYPO3-Solr/php-solr-explain)
3+
[![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)
44
[![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)
55
[![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)
66
[![License](https://poser.pugx.org/apache-solr-for-typo3/php-solr-explain/license)](https://packagist.org/packages/apache-solr-for-typo3/php-solr-explain)

Tests/Domain/Result/Explanation/ExplainServiceTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testFixture1()
2222
'bar'
2323
);
2424

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

2828
/**

Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testCanSummarizeFieldImpactFixture001()
3737
$explain->getRootNode()->visitNodes($visitor);
3838

3939
$this->assertEquals(100.0,$visitor->getFieldImpact('name'));
40-
$this->assertEquals(array('name'),$visitor->getRelevantFieldNames());
40+
$this->assertEquals(['name'],$visitor->getRelevantFieldNames());
4141
}
4242

4343
/**
@@ -50,7 +50,7 @@ public function testCanSummarizeFieldImpactFixture003()
5050
$explain->getRootNode()->visitNodes($visitor);
5151

5252
$this->assertEquals(95.756597168764,$visitor->getFieldImpact('price'));
53-
$this->assertEquals(array('name','manu','price'),$visitor->getRelevantFieldNames());
53+
$this->assertEquals(['name','manu','price'],$visitor->getRelevantFieldNames());
5454
}
5555

5656
/**
@@ -63,7 +63,7 @@ public function testCanSummarizeFieldImpactFixture004()
6363
$explain->getRootNode()->visitNodes($visitor);
6464

6565
$this->assertEquals(100.0,$visitor->getFieldImpact('name'));
66-
$this->assertEquals(array('name','price'),$visitor->getRelevantFieldNames());
66+
$this->assertEquals(['name','price'],$visitor->getRelevantFieldNames());
6767
}
6868

6969
/**
@@ -75,7 +75,7 @@ public function testCanSummarizeCustomTieBreakerFixture()
7575
$visitor = new SummarizeFieldImpacts();
7676
$explain->getRootNode()->visitNodes($visitor);
7777

78-
$this->assertEquals(array('expandedcontent','content','doctype'),$visitor->getRelevantFieldNames());
78+
$this->assertEquals(['expandedcontent','content','doctype'],$visitor->getRelevantFieldNames());
7979
$this->assertEquals(47.9,round($visitor->getFieldImpact('doctype'),1));
8080
$this->assertEquals(47.9,round($visitor->getFieldImpact('expandedcontent'),1));
8181
$this->assertEquals(4.2,round($visitor->getFieldImpact('content'),1));
@@ -90,7 +90,7 @@ public function testCanSummarizeCustomTieBreaker2Fixture()
9090
$visitor = new SummarizeFieldImpacts();
9191
$explain->getRootNode()->visitNodes($visitor);
9292

93-
$this->assertEquals(array('pr_title','doctype'),$visitor->getRelevantFieldNames());
93+
$this->assertEquals(['pr_title','doctype'],$visitor->getRelevantFieldNames());
9494
$this->assertEquals(0.07,round($visitor->getFieldImpact('doctype'),2));
9595
$this->assertEquals(99.93,round($visitor->getFieldImpact('pr_title'),2));
9696
}
@@ -105,7 +105,7 @@ public function testCanSummarizeCustomTieBreaker3Fixture()
105105
$visitor = new SummarizeFieldImpacts();
106106
$explain->getRootNode()->visitNodes($visitor);
107107

108-
$this->assertEquals(array('keywords','expandedcontent','content','description','doctype'),$visitor->getRelevantFieldNames());
108+
$this->assertEquals(['keywords','expandedcontent','content','description','doctype'],$visitor->getRelevantFieldNames());
109109
$this->assertEquals(0.00,round($visitor->getFieldImpact('keywords'),2));
110110
$this->assertEquals(7.55,round($visitor->getFieldImpact('expandedcontent'),2));
111111
$this->assertEquals(4.72,round($visitor->getFieldImpact('content'),2));

Tests/Domain/Result/Explanation/Visitors/SummarizeLeafImpactsTestCase.php

+38-38
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,45 @@ protected function getExplain($filename)
3333
*/
3434
public function leafSumFixtureNameDataProvider()
3535
{
36-
return array(
37-
array('3.0.001'),
38-
array('3.0.002'),
39-
array('3.0.003'),
40-
array('3.0.004'),
41-
array('3.0.005'),
42-
array('3.4.001'),
43-
array('3.4.002'),
44-
array('3.4.003'),
45-
array('3.4.004'),
46-
array('3.4.005'),
47-
array('3.4.006'),
48-
array('3.4.007'),
49-
array('3.4.008'),
50-
array('3.4.009'),
51-
array('3.4.010'),
52-
array('3.4.011'),
53-
array('3.4.012'),
54-
array('3.4.013'),
55-
array('3.4.014'),
56-
array('3.4.015'),
57-
array('3.4.016'),
58-
array('3.4.017'),
36+
return [
37+
['3.0.001'],
38+
['3.0.002'],
39+
['3.0.003'],
40+
['3.0.004'],
41+
['3.0.005'],
42+
['3.4.001'],
43+
['3.4.002'],
44+
['3.4.003'],
45+
['3.4.004'],
46+
['3.4.005'],
47+
['3.4.006'],
48+
['3.4.007'],
49+
['3.4.008'],
50+
['3.4.009'],
51+
['3.4.010'],
52+
['3.4.011'],
53+
['3.4.012'],
54+
['3.4.013'],
55+
['3.4.014'],
56+
['3.4.015'],
57+
['3.4.016'],
58+
['3.4.017'],
5959
//contains invalid content therefore no overall impact of 100 expected
60-
array('3.4.018',0.0),
61-
array('3.4.019'),
62-
array('3.4.020'),
63-
array('3.4.021'),
64-
array('3.4.022'),
65-
array('3.4.023'),
66-
array('3.4.024'),
67-
array('3.4.025'),
68-
array('3.4.026'),
69-
array('3.4.027'),
70-
array('3.4.028'),
71-
array('4.0.001'),
72-
array('complex'),
73-
array('custom.tieBreaker')
74-
);
60+
['3.4.018',0.0],
61+
['3.4.019'],
62+
['3.4.020'],
63+
['3.4.021'],
64+
['3.4.022'],
65+
['3.4.023'],
66+
['3.4.024'],
67+
['3.4.025'],
68+
['3.4.026'],
69+
['3.4.027'],
70+
['3.4.028'],
71+
['4.0.001'],
72+
['complex'],
73+
['custom.tieBreaker']
74+
];
7575
}
7676

7777
/**

Tests/Domain/Result/ParserTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testFixture001()
2727
);
2828

2929
$this->assertEquals(
30-
array('electronics','hard drive'),
30+
['electronics','hard drive'],
3131
$result->getDocumentCollection()->getDocument(1)->getFieldByName('cat')->getValue()
3232
);
3333

0 commit comments

Comments
 (0)