Skip to content

Commit

Permalink
allow php 8 (#880)
Browse files Browse the repository at this point in the history
* allow php 8

* run tests using PHP 8.0

* remove fixed phpstan version

* allow phpunit 9

* fix invalid return type for magic "__set" method

* fix __unset return type

* try increasing phpstan memory limit

* fix curl_init returning \CurlHandle instead of resource

Co-authored-by: Markus Kalkbrenner <[email protected]>
  • Loading branch information
dmaicher and mkalkbrenner authored Nov 5, 2020
1 parent 8599c72 commit dd1446e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 28 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
php: [7.2, 7.3, 7.4]
php: [7.2, 7.3, 7.4, 8.0]
solr: [7, 8]
mode: [cloud, server]

Expand Down Expand Up @@ -63,12 +63,11 @@ jobs:
- name: Install dependencies
run: |
composer require phpstan/phpstan:0.12.25
composer update
- name: Run tests
run: |
vendor/bin/phpstan analyze src/ tests/ --level=1
vendor/bin/phpstan analyze src/ tests/ --level=1 --memory-limit=1G
vendor/bin/phpunit -c phpunit.xml --exclude-group skip_for_solr_${{ matrix.mode }} -v --coverage-clover build/logs/clover.xml
- name: Execute examples
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.2 || ^8.0",
"ext-json": "*",
"psr/event-dispatcher": "^1.0",
"psr/http-client": "^1.0",
Expand All @@ -27,7 +27,7 @@
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.0",
"phpunit/phpunit": "^8.5 || ^9.4",
"roave/security-advisories": "dev-master",
"symfony/event-dispatcher": "^4.3 || ^5.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getResponse($handle, $httpResponse): Response
*
* @throws InvalidArgumentException
*
* @return resource
* @return resource|\CurlHandle
*/
public function createHandle($request, $endpoint)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Core/Query/AbstractDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ abstract class AbstractDocument implements DocumentInterface, \IteratorAggregate
/**
* @param mixed $name
* @param mixed $value
*
* @return \Solarium\Core\Query\DocumentInterface
*/
abstract public function __set($name, $value): DocumentInterface;
abstract public function __set($name, $value): void;

/**
* Get field value by name.
Expand Down
4 changes: 1 addition & 3 deletions src/Plugin/MinimumScoreFilter/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ public function __isset($name): bool
* @param string $value
*
* @throws RuntimeException
*
* @return self
*/
public function __set($name, $value): self
public function __set($name, $value): void
{
throw new RuntimeException('A readonly document cannot be altered');
}
Expand Down
5 changes: 1 addition & 4 deletions src/QueryType/Select/Result/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Solarium\QueryType\Select\Result;

use Solarium\Core\Query\AbstractDocument;
use Solarium\Core\Query\DocumentInterface;
use Solarium\Exception\RuntimeException;

/**
Expand Down Expand Up @@ -48,10 +47,8 @@ public function __construct(array $fields)
* @param string $value
*
* @throws RuntimeException
*
* @return DocumentInterface
*/
public function __set($name, $value): DocumentInterface
public function __set($name, $value): void
{
throw new RuntimeException('A readonly document cannot be altered');
}
Expand Down
13 changes: 2 additions & 11 deletions src/QueryType/Update/Query/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Solarium\QueryType\Update\Query;

use Solarium\Core\Query\AbstractDocument;
use Solarium\Core\Query\DocumentInterface;
use Solarium\Core\Query\Helper;
use Solarium\Exception\RuntimeException;

Expand Down Expand Up @@ -175,14 +174,10 @@ public function __construct(array $fields = [], array $boosts = [], array $modif
*
* @param string $name
* @param mixed $value
*
* @return self
*/
public function __set($name, $value): DocumentInterface
public function __set($name, $value): void
{
$this->setField($name, $value);

return $this;
}

/**
Expand All @@ -191,14 +186,10 @@ public function __set($name, $value): DocumentInterface
* Magic method for removing fields by un-setting object properties
*
* @param string $name
*
* @return self
*/
public function __unset($name): self
public function __unset($name): void
{
$this->removeField($name);

return $this;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion tests/Core/Client/Adapter/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public function testCanCreateHandleForDeleteRequest()
$curlAdapter = new Curl();
$handler = $curlAdapter->createHandle($request, $endpoint);

$this->assertIsResource($handler);
if (class_exists(\CurlHandle::class)) {
$this->assertInstanceOf(\CurlHandle::class, $handler);
} else {
$this->assertIsResource($handler);
}
curl_close($handler);
}
}

0 comments on commit dd1446e

Please sign in to comment.