Skip to content

Commit

Permalink
fixed return type declarations, require PHP 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Kalkbrenner committed Jan 31, 2019
1 parent dce5616 commit 96ab1b2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
12 changes: 2 additions & 10 deletions .travis.yml
Expand Up @@ -6,14 +6,13 @@ php:
- 7.3
- 7.2
- 7.1
- 7.0
- nightly

env:
- SYMFONY_VERSION=3.3.* SOLR_VERSION=6.6.5 SOLRCLOUD=false
- SYMFONY_VERSION=4.0.* SOLR_VERSION=6.6.5 SOLRCLOUD=false
- SYMFONY_VERSION=4.0.* SOLR_VERSION=7.5.0 SOLRCLOUD=false
- SYMFONY_VERSION=4.0.* SOLR_VERSION=7.5.0 SOLRCLOUD=true
- SYMFONY_VERSION=4.0.* SOLR_VERSION=7.6.0 SOLRCLOUD=false
- SYMFONY_VERSION=4.0.* SOLR_VERSION=7.6.0 SOLRCLOUD=true

cache:
directories:
Expand Down Expand Up @@ -53,13 +52,6 @@ after_success:
- travis_retry php vendor/bin/coveralls -v

matrix:
exclude:
- php: 7.0
env: SYMFONY_VERSION=4.0.* SOLR_VERSION=6.6.5 SOLRCLOUD=false
- php: 7.0
env: SYMFONY_VERSION=4.0.* SOLR_VERSION=7.5.0 SOLRCLOUD=false
- php: 7.0
env: SYMFONY_VERSION=4.0.* SOLR_VERSION=7.5.0 SOLRCLOUD=true
allow_failures:
- php: nightly

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.1",
"symfony/event-dispatcher": "^3.1 || ^4.0",
"symfony/cache": "^3.1 || ^4.0",
"ext-json": "*"
Expand Down
44 changes: 22 additions & 22 deletions src/Core/Client/Endpoint.php
Expand Up @@ -48,7 +48,7 @@ public function __toString()
*
* @return string
*/
public function getKey()
public function getKey(): string
{
return $this->getOption('key');
}
Expand All @@ -60,7 +60,7 @@ public function getKey()
*
* @return self Provides fluent interface
*/
public function setKey($value)
public function setKey($value): self
{
$this->setOption('key', $value);
return $this;
Expand All @@ -73,7 +73,7 @@ public function setKey($value)
*
* @return self Provides fluent interface
*/
public function setHost($host)
public function setHost($host): self
{
$this->setOption('host', $host);
return $this;
Expand All @@ -84,7 +84,7 @@ public function setHost($host)
*
* @return string
*/
public function getHost()
public function getHost(): string
{
return $this->getOption('host');
}
Expand All @@ -96,7 +96,7 @@ public function getHost()
*
* @return self Provides fluent interface
*/
public function setPort($port)
public function setPort($port): self
{
$this->setOption('port', $port);
return $this;
Expand All @@ -107,7 +107,7 @@ public function setPort($port)
*
* @return int
*/
public function getPort()
public function getPort(): int
{
return $this->getOption('port');
}
Expand All @@ -121,7 +121,7 @@ public function getPort()
*
* @return self Provides fluent interface
*/
public function setPath($path)
public function setPath($path): self
{
if ('/' === substr($path, -1)) {
$path = substr($path, 0, -1);
Expand All @@ -136,7 +136,7 @@ public function setPath($path)
*
* @return string
*/
public function getPath()
public function getPath(): string
{
return $this->getOption('path');
}
Expand All @@ -148,7 +148,7 @@ public function getPath()
*
* @return self Provides fluent interface
*/
public function setCollection($collection)
public function setCollection($collection): self
{
$this->setOption('collection', $collection);
return $this;
Expand All @@ -159,7 +159,7 @@ public function setCollection($collection)
*
* @return string|null
*/
public function getCollection()
public function getCollection(): ?string
{
return $this->getOption('collection');
}
Expand All @@ -171,7 +171,7 @@ public function getCollection()
*
* @return self Provides fluent interface
*/
public function setCore($core)
public function setCore($core): self
{
$this->setOption('core', $core);
return $this;
Expand All @@ -180,9 +180,9 @@ public function setCore($core)
/**
* Get core option.
*
* @return string
* @return string|null
*/
public function getCore()
public function getCore(): ?string
{
if (null === $this->getOption('core') && null !== $this->getOption('collection')) {
return $this->getCollection();
Expand All @@ -207,9 +207,9 @@ public function setTimeout($timeout): self
/**
* Get timeout option.
*
* @return string
* @return int
*/
public function getTimeout(): string
public function getTimeout(): int
{
return $this->getOption('timeout');
}
Expand All @@ -232,7 +232,7 @@ public function setScheme($scheme): self
*
* @return string
*/
public function getScheme()
public function getScheme(): string
{
return $this->getOption('scheme');
}
Expand Down Expand Up @@ -263,7 +263,7 @@ public function getCollectionBaseUri(): string
*
* @return string
*/
public function getCoreBaseUri()
public function getCoreBaseUri(): string
{
$uri = $this->getServerUri();
$core = $this->getCore();
Expand All @@ -284,7 +284,7 @@ public function getCoreBaseUri()
*
* @return string
*/
public function getBaseUri()
public function getBaseUri(): string
{
$message = 'Endpoint::getBaseUri is deprecated since Solarium 4.2, will be removed in Solarium 5.'.
'please use getServerUri or getCoreBaseUri now.';
Expand All @@ -298,7 +298,7 @@ public function getBaseUri()
*
* @return string
*/
public function getServerUri()
public function getServerUri(): string
{
return $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getPath().'/';
}
Expand All @@ -313,7 +313,7 @@ public function getServerUri()
*
* @return self Provides fluent interface
*/
public function setAuthentication($username, $password)
public function setAuthentication($username, $password): self
{
$this->setOption('username', $username);
$this->setOption('password', $password);
Expand All @@ -326,7 +326,7 @@ public function setAuthentication($username, $password)
*
* @return array
*/
public function getAuthentication()
public function getAuthentication(): array
{
return [
'username' => $this->getOption('username'),
Expand All @@ -341,7 +341,7 @@ public function getAuthentication()
*
* @return $this
*/
public function setLeader(bool $leader)
public function setLeader(bool $leader): self
{
$this->setOption('leader', $leader);
return $this;
Expand Down
5 changes: 2 additions & 3 deletions src/Core/Client/State/ShardState.php
Expand Up @@ -96,7 +96,7 @@ public function getReplicas(): array
*
* @return ReplicaState|null
*/
public function getShardLeader()//: ?ReplicaState // @todo can return null, wait for PHP 7.1 for this to work
public function getShardLeader(): ?ReplicaState
{
if (isset($this->replicas[$this->shardLeader]) && $this->replicas[$this->shardLeader]->isActive()) {
return $this->replicas[$this->shardLeader];
Expand All @@ -108,8 +108,7 @@ public function getShardLeader()//: ?ReplicaState // @todo can return null, wait
/**
* @return string|null
*/
public function getShardLeaderBaseUri()//: ?string // @todo wait for PHP 7.1 to support this
: string
public function getShardLeaderBaseUri(): ?string
{
if ($this->getShardLeader() instanceof ReplicaState) {
return null !== $this->getShardLeader() ? $this->getShardLeader()->getServerUri() : null;
Expand Down

0 comments on commit 96ab1b2

Please sign in to comment.