for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Hyphper\Frame;
class Flags implements \IteratorAggregate, \Countable
{
protected $valid_flags = [];
protected $flags = [];
public function __construct(int ...$valid_flags)
$this->valid_flags = array_combine($valid_flags, $valid_flags);
}
public function getIterator(): array
return $this->flags;
public function add($flag)
if (isset($this->valid_flags[$flag])) {
return $this->flags[$flag] = $flag;
throw new \Hyphper\Frame\Exception\InvalidFlagException($flag, $this->valid_flags);
$this->valid_flags
array
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);
public function remove($flag)
if (isset($this->flags[$flag])) {
unset($this->flags[$flag]);
public function hasFlag($flag)
return isset($this->flags[$flag]);
/**
* Count elements of an object
* @link http://php.net/manual/en/countable.count.php
* @return int The custom count as an integer.
* </p>
* <p>
* The return value is cast to an integer.
* @since 5.1.0
*/
public function count()
return count($this->flags);
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: