Skip to content

Commit 9a6d504

Browse files
authored
Merge pull request #198 from ben221199/php8
2 parents de93f50 + 662e0d4 commit 9a6d504

16 files changed

+137
-176
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
64
- 7.1
75
- 7.2
86
- 7.3
97
- 7.4
8+
- 8.0
109

1110
env:
1211
- DRIVER=mysqli SEARCH_BUILD=SPHINX2 EXCLUDE_GROUP="--exclude-group=Manticore"

CHANGELOG.md

+53-65
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
#### 2.1.0
1+
#### 3.0.0
2+
* Added support for PHP 8
3+
* Renamed `Foolz\SphinxQL\Match` to `Foolz\SphinxQL\MatchBuilder` (BREAKING CHANGE)
24

3-
* added exception code and previous throwable to errors
4-
* added `setType` method to `SphinxQL` class
5-
* added support for `MATCH` to `DELETE` queries
6-
* updated MySQLi driver to silence internal warnings by default
5+
#### 2.1.0
6+
* Added exception code and previous throwable to errors
7+
* Added `setType` method to `SphinxQL` class
8+
* Added support for `MATCH` to `DELETE` queries
9+
* Updated MySQLi driver to silence internal warnings by default
710

811
#### 2.0.0
9-
10-
* added support for [Manticore](https://manticoresearch.com)
11-
* added `Percolate` class for `Manticore`
12-
* added `orPhrase` method to `Match` class
13-
* added `resetFacets` method to `SphinxQL` class
14-
* added support for multi-document snippet call
15-
* fixed `Connection` exception thrown
16-
* fixed incorrect property accessibility/visibility
17-
* refactored `ResultSet` and `MultiResultSet` classes to reduce duplicate code
18-
* removed `Connection` error suppression
19-
* removed `SphinxQL\Drivers\ResultSetAdapterInterface` constants
20-
* removed static `SphinxQL::create` method
21-
* removed deprecated `\Foolz\SphinxQL\Connection`
22-
* removed support for PHP 5.3 and HHVM
23-
* updated fetch type for drivers to use `boolean` to return assoc/indexed arrays
24-
* updated PHPDoc blocks
12+
* Added support for [Manticore](https://manticoresearch.com)
13+
* Added `Percolate` class for `Manticore`
14+
* Added `orPhrase` method to `Match` class
15+
* Added `resetFacets` method to `SphinxQL` class
16+
* Added support for multi-document snippet call
17+
* Fixed `Connection` exception thrown
18+
* Fixed incorrect property accessibility/visibility
19+
* Refactored `ResultSet` and `MultiResultSet` classes to reduce duplicate code
20+
* Removed `Connection` error suppression
21+
* Removed `SphinxQL\Drivers\ResultSetAdapterInterface` constants
22+
* Removed static `SphinxQL::create` method
23+
* Removed deprecated `\Foolz\SphinxQL\Connection`
24+
* Removed support for PHP 5.3 and HHVM
25+
* Updated fetch type for drivers to use `boolean` to return assoc/indexed arrays
26+
* Updated PHPDoc blocks
2527

2628
Note: This release contains **breaking changes** around the instantiation of the `SphinxQL` class with the removal of static methods. Please refer to the README for any API changes.
2729

2830
#### 1.2.0
29-
30-
* added support for `GROUP N BY`
31-
* refactored `Connection`, `\Foolz\SphinxQL\Connection` is now deprecated.
32-
* refactored `ResultSet` and `MultiResultSet` to reduce duplicate code
31+
* Added support for `GROUP N BY`
32+
* Refactored `Connection`, `\Foolz\SphinxQL\Connection` is now deprecated.
33+
* Refactored `ResultSet` and `MultiResultSet` to reduce duplicate code
3334

3435
Note: This release contains **breaking changes** with the introduction of `ResultSet` and `MultiResultSet` changes. Please refer to the README for any API changes.
3536

3637
#### 0.9.7
37-
38-
* added support for unix sockets
39-
* added `NOT IN` condition in `WHERE` statements
38+
* Added support for unix sockets
39+
* Added `NOT IN` condition in `WHERE` statements
4040

4141
#### 0.9.6
42-
43-
* added named integer lists support to `OPTION` with associative array (@alpha0010)
44-
* deprecated special case `OPTION` for `field_weights` and `index_weights`
45-
* forced `Connection` to use utf8 charset (@t1gor)
42+
* Added named integer lists support to `OPTION` with associative array (@alpha0010)
43+
* Deprecated special case `OPTION` for `field_weights` and `index_weights`
44+
* Forced `Connection` to use utf8 charset (@t1gor)
4645

4746
#### 0.9.5
4847
* `Expression` support for `OPTION` value
@@ -53,58 +52,47 @@ Note: This release contains **breaking changes** with the introduction of `Resul
5352
* Added `ConnectionInterface`
5453

5554
#### 0.9.3
56-
5755
* HHVM support
5856
* Added escaping of new MATCH features by lowercasing the search string
5957

6058
#### 0.9.2
61-
62-
* created `Helper` class to contain non-query-builder query methods, all returning `SphinxQL` objects
63-
* deprecated all non-query-builder query methods in `SphinxQL` class
64-
* improved `$sq->enqueue()` in `SphinxQL` class to have a parameter to append any custom `SphinxQL` objects
65-
* added `$sq->query()` method to `SphinxQL` to allow setting SQL queries without executing them
59+
* Created `Helper` class to contain non-query-builder query methods, all returning `SphinxQL` objects
60+
* Deprecated all non-query-builder query methods in `SphinxQL` class
61+
* Improved `$sq->enqueue()` in `SphinxQL` class to have a parameter to append any custom `SphinxQL` objects
62+
* Added `$sq->query()` method to `SphinxQL` to allow setting SQL queries without executing them
6663

6764
#### 0.9.1
68-
69-
* deprecated SphinxQL::forge() with static Connection and implemented SphinxQL::create($conn)
70-
* added array and * support to MATCH columns (thanks to @FindTheBest)
71-
* added Expression support to MATCH value
65+
* Deprecated SphinxQL::forge() with static Connection and implemented SphinxQL::create($conn)
66+
* Added array and * support to MATCH columns (thanks to @FindTheBest)
67+
* Added Expression support to MATCH value
7268

7369
#### 0.9.0
74-
75-
* refactored to be fully OOP
76-
* changed code style to be PSR-2 compliant
77-
* removed all unnecessary `static` keywords
78-
* removed old bootstrap file for fuelphp
70+
* Refactored to be fully OOP
71+
* Changed code style to be PSR-2 compliant
72+
* Removed all unnecessary `static` keywords
73+
* Removed old bootstrap file for fuelphp
7974

8075
#### 0.8.6
81-
82-
* added Connection::ping()
83-
* added Connection::close()
84-
* fixed uncaught exception thrown by Connection::getConnection()
76+
* Added Connection::ping()
77+
* Added Connection::close()
78+
* Fixed uncaught exception thrown by Connection::getConnection()
8579

8680
#### 0.8.5
87-
88-
* removed Array typehints
89-
* removed unsupported charset argument
81+
* Removed Array typehints
82+
* Removed unsupported charset argument
9083

9184
#### 0.8.4
92-
93-
* fixed composer bootstrap
94-
* removed `Sphinxql` prefix on Connection and Expression classes
85+
* Fixed composer bootstrap
86+
* Removed `Sphinxql` prefix on Connection and Expression classes
9587

9688
#### 0.8.3
97-
98-
* added Queue support
89+
* Added Queue support
9990

10091
#### 0.8.2
101-
102-
* fixed composer bootstrap
92+
* Fixed composer bootstrap
10393

10494
#### 0.8.1
105-
106-
* improved phpunit tests
95+
* Improved phpunit tests
10796

10897
#### 0.8.0
109-
110-
* initial release
98+
* Initial release

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Query Builder for SphinxQL
1010

1111
This is a SphinxQL Query Builder used to work with SphinxQL, a SQL dialect used with the Sphinx search engine and it's fork Manticore. It maps most of the functions listed in the [SphinxQL reference](http://sphinxsearch.com/docs/current.html#SphinxQL-reference) and is generally [faster](http://sphinxsearch.com/blog/2010/04/25/sphinxapi-vs-SphinxQL-benchmark/) than the available Sphinx API.
1212

13-
This Query Builder has no dependencies except PHP 5.6, `\MySQLi` extension, `PDO`, and [Sphinx](http://sphinxsearch.com)/[Manticore](https://manticoresearch.com).
13+
This Query Builder has no dependencies except PHP 7.1 or later, `\MySQLi` extension, `PDO`, and [Sphinx](http://sphinxsearch.com)/[Manticore](https://manticoresearch.com).
1414

1515
### Missing methods?
1616

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"irc": "irc://irc.irchighway.net/fooldriver"
1313
},
1414
"require": {
15-
"php": "^5.6 || ^7.0"
15+
"php": "^5.6 || ^7 || ^8"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "^5.7 || 6.3.*"
18+
"phpunit/phpunit": "^5 || ^6 || ^7 || ^8 || ^9"
1919
},
2020
"autoload": {
2121
"psr-4": {

src/Match.php renamed to src/MatchBuilder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Query Builder class for Match statements.
77
*/
8-
class Match
8+
class MatchBuilder
99
{
1010
/**
1111
* The last compiled query.
@@ -51,12 +51,12 @@ public function __construct(SphinxQL $sphinxql)
5151
* });
5252
* // (a | b)
5353
*
54-
* $sub = new Match($sphinxql);
54+
* $sub = new MatchBuilder($sphinxql);
5555
* $sub->match('a')->orMatch('b');
5656
* $match->match($sub);
5757
* // (a | b)
5858
*
59-
* @param string|Match|\Closure $keywords The text or expression to match.
59+
* @param string|MatchBuilder|\Closure $keywords The text or expression to match.
6060
*
6161
* @return $this
6262
*/
@@ -79,7 +79,7 @@ public function match($keywords = null)
7979
* $match->match('test')->orMatch('case');
8080
* // test | case
8181
*
82-
* @param string|Match|\Closure $keywords The text or expression to alternatively match.
82+
* @param string|MatchBuilder|\Closure $keywords The text or expression to alternatively match.
8383
*
8484
* @return $this
8585
*/
@@ -101,7 +101,7 @@ public function orMatch($keywords = null)
101101
* $match->match('test')->maybe('case');
102102
* // test MAYBE case
103103
*
104-
* @param string|Match|\Closure $keywords The text or expression to optionally match.
104+
* @param string|MatchBuilder|\Closure $keywords The text or expression to optionally match.
105105
*
106106
* @return $this
107107
*/
@@ -500,7 +500,7 @@ public function compile()
500500
if (key($token) == 'MATCH') {
501501
if ($token['MATCH'] instanceof Expression) {
502502
$query .= $token['MATCH']->value().' ';
503-
} elseif ($token['MATCH'] instanceof Match) {
503+
} elseif ($token['MATCH'] instanceof MatchBuilder) {
504504
$query .= '('.$token['MATCH']->compile()->getCompiled().') ';
505505
} elseif ($token['MATCH'] instanceof \Closure) {
506506
$sub = new static($this->sphinxql);

src/SphinxQL.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,10 @@ public function compileMatch()
470470
foreach ($this->match as $match) {
471471
$pre = '';
472472
if ($match['column'] instanceof \Closure) {
473-
$sub = new Match($this);
473+
$sub = new MatchBuilder($this);
474474
call_user_func($match['column'], $sub);
475475
$pre .= $sub->compile()->getCompiled();
476-
} elseif ($match['column'] instanceof Match) {
476+
} elseif ($match['column'] instanceof MatchBuilder) {
477477
$pre .= $match['column']->compile()->getCompiled();
478478
} elseif (empty($match['column'])) {
479479
$pre .= '';
@@ -980,7 +980,7 @@ public function from($array = null)
980980
/**
981981
* MATCH clause (Sphinx-specific)
982982
*
983-
* @param mixed $column The column name (can be array, string, Closure, or Match)
983+
* @param mixed $column The column name (can be array, string, Closure, or MatchBuilder)
984984
* @param string $value The value
985985
* @param bool $half Exclude ", |, - control characters from being escaped
986986
*

tests/SphinxQL/ConnectionTest.php

+12-26
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class ConnectionTest extends \PHPUnit\Framework\TestCase
1111
*/
1212
private $connection = null;
1313

14-
protected function setUp()
14+
protected function setUp(): void
1515
{
1616
$this->connection = TestUtil::getConnectionDriver();
1717
$this->connection->setParams(array('host' => '127.0.0.1', 'port' => 9307));
1818
}
1919

20-
protected function tearDown()
20+
protected function tearDown(): void
2121
{
2222
$this->connection = null;
2323
}
@@ -80,11 +80,9 @@ public function testGetConnection()
8080
$this->assertNotNull($this->connection->getConnection());
8181
}
8282

83-
/**
84-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
85-
*/
8683
public function testGetConnectionThrowsException()
8784
{
85+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
8886
$this->connection->getConnection();
8987
}
9088

@@ -96,11 +94,9 @@ public function testConnect()
9694
$this->connection->connect();
9795
}
9896

99-
/**
100-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
101-
*/
10297
public function testConnectThrowsException()
10398
{
99+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
104100
$this->connection->setParam('port', 9308);
105101
$this->connection->connect();
106102
}
@@ -111,11 +107,9 @@ public function testPing()
111107
$this->assertTrue($this->connection->ping());
112108
}
113109

114-
/**
115-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
116-
*/
117110
public function testClose()
118111
{
112+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
119113
$encoding = mb_internal_encoding();
120114
$this->connection->connect();
121115

@@ -150,29 +144,23 @@ public function testMultiQuery()
150144
), $query->getNext()->fetchAllAssoc());
151145
}
152146

153-
/**
154-
* @expectedException Foolz\SphinxQL\Exception\SphinxQLException
155-
* @expectedExceptionMessage The Queue is empty.
156-
*/
157147
public function testEmptyMultiQuery()
158148
{
149+
$this->expectException(Foolz\SphinxQL\Exception\SphinxQLException::class);
150+
$this->expectExceptionMessage('The Queue is empty.');
159151
$this->connection->connect();
160152
$this->connection->multiQuery(array());
161153
}
162154

163-
/**
164-
* @expectedException Foolz\SphinxQL\Exception\DatabaseException
165-
*/
166155
public function testMultiQueryThrowsException()
167156
{
157+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
168158
$this->connection->multiQuery(array('SHOW METAL'));
169159
}
170160

171-
/**
172-
* @expectedException Foolz\SphinxQL\Exception\DatabaseException
173-
*/
174161
public function testQueryThrowsException()
175162
{
163+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
176164
$this->connection->query('SHOW METAL');
177165
}
178166

@@ -182,11 +170,9 @@ public function testEscape()
182170
$this->assertEquals('\'\\\' \\"\\" \\\'\\\' \'', $result);
183171
}
184172

185-
/**
186-
* @expectedException Foolz\SphinxQL\Exception\ConnectionException
187-
*/
188173
public function testEscapeThrowsException()
189174
{
175+
$this->expectException(Foolz\SphinxQL\Exception\ConnectionException::class);
190176
// or we get the wrong error popping up
191177
$this->connection->setParam('port', 9308);
192178
$this->connection->connect();
@@ -201,7 +187,7 @@ public function testQuote()
201187
$this->assertEquals(0, $this->connection->quote(false));
202188
$this->assertEquals("fo'o'bar", $this->connection->quote(new Expression("fo'o'bar")));
203189
$this->assertEquals(123, $this->connection->quote(123));
204-
$this->assertEquals("12.3", $this->connection->quote(12.3));
190+
$this->assertEquals("12.300000", $this->connection->quote(12.3));
205191
$this->assertEquals("'12.3'", $this->connection->quote('12.3'));
206192
$this->assertEquals("'12'", $this->connection->quote('12'));
207193
}
@@ -210,7 +196,7 @@ public function testQuoteArr()
210196
{
211197
$this->connection->connect();
212198
$this->assertEquals(
213-
array('null', 1, 0, "fo'o'bar", 123, "12.3", "'12.3'", "'12'"),
199+
array('null', 1, 0, "fo'o'bar", 123, "12.300000", "'12.3'", "'12'"),
214200
$this->connection->quoteArr(array(null, true, false, new Expression("fo'o'bar"), 123, 12.3, '12.3', '12'))
215201
);
216202
}

tests/SphinxQL/FacetTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class FacetTest extends \PHPUnit\Framework\TestCase
2929
'title' => 'what is there to do', 'content' => 'we need to create dummy data for tests'),
3030
);
3131

32-
public static function setUpBeforeClass()
32+
public static function setUpBeforeClass(): void
3333
{
3434
$conn = TestUtil::getConnectionDriver();
3535
$conn->setParam('port', 9307);

0 commit comments

Comments
 (0)