for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BlogController extends Controller
{
/**
* @Route("/blog", name="blog_homepage")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function indexAction()
$posts = $this->getDoctrine()
->getRepository('AppBundle:Post')
->findAll();
return $this->render(
'blog/index.html.twig',
['posts' => $posts]
);
}
* @Route("/blog/{year}/{month}/{day}/{slug}", name="blog_show", requirements={
* "year": "\d+",
* "month": "\d+",
* "day": "\d+"
* })
* @param $slug
public function showAction($slug)
$post = $this->getDoctrine()
->findOneBySlug($slug);
$em = $this->getDoctrine()->getManager();
$em
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
if (!$post) {
throw $this->createNotFoundException(
'No post found for slug '.$slug
'blog/show.html.twig',
['post' => $post]
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.