for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Scriptotek\GoogleBooks;
class Volumes
{
protected $client;
protected $chunk = false;
public function __construct(GoogleBooks $client)
$this->client = $client;
}
/**
* @param $query
* @return \Generator|Volume || array
*/
public function search($query)
if ($this->chunk) {
return $this->client->chunk($this->fetchSearch($query), $this->chunk);
$this->chunk
boolean
integer
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return $this->fetchSearch($query);
* @return \Generator|Volume
private function fetchSearch($query)
foreach ($this->client->listItems('volumes', ['q' => $query]) as $item) {
yield new Volume($this->client, $item);
* @param $chunk
* @return Volumes
public function chunk(int $chunk)
$this->chunk = $chunk;
$chunk
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
return $this;
public function firstOrNull($query)
$res = $this->search($query)->current();
return $res;
public function get($id)
return new Volume($this->client, $this->client->getItem("volumes/$id"), true);
public function byIsbn($isbn)
$isbn = preg_replace('/[^0-9Xx]/', '', $isbn);
return $this->firstOrNull('isbn:' . $isbn);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: