for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Balloon\Format;
use Balloon\Reader\IFileReader;
/**
* Class Json
* @package Balloon\Format
* @author Raphaël Lefebvre <[email protected]>
*/
class Json implements IFileReader
{
* @var IFileReader
private $fileReader;
* @var int
private $flags;
* @param IFileReader $fileReader
* @param int $flags
$flags
integer|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
public function __construct(IFileReader $fileReader, $flags = null)
$this->fileReader = $fileReader;
$this->initFlags($flags);
}
* @return array|null
public function read()
return json_decode($this->fileReader->read(), true);
* @param mixed $data
* @param int $mode
* @return int
public function write($data, $mode = 0)
return $this->fileReader->write(json_encode($data, $this->flags), $mode);
* @param $flags
private function initFlags($flags)
if ($flags === null) {
$this->flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
} else {
$this->flags = $flags;
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.