for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WebServCo\Framework;
final class SourceCode
{
const TYPE_XML = 'XML';
protected $type;
protected $data;
public function __construct($type, $data)
switch ($type) {
case self::TYPE_XML:
break;
default:
throw new \WebServCo\Framework\Exceptions\ApplicationException('Type not implemented');
}
$this->type = $type;
$this->data = $data;
public function highlight()
switch ($this->type) {
return $this->highlightXml($this->data);
break
The break statement is not necessary if it is preceded for example by a return statement:
return
switch ($x) { case 1: return 'foo'; break; // This break is not necessary and can be left off. }
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
case
return false;
protected function highlightXml($data)
$data = htmlentities($data);
$data = str_replace('<', '<span style="color: purple"><', $data);
$data = str_replace('>', '></span>', $data);
return $data;
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.