exit() and die() functions should be avoided

  • Major
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.use_exit_function

in web/app_dev.php, line 4
  1. <?php
  2. if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
  3. die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Collective
  4. }
  5. require_once __DIR__.'/../app/bootstrap.php.cache';
  6. require_once __DIR__.'/../app/AppKernel.php';

Object parameters should be type hinted 4

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.object_parameter_not_type_hinted

  1. /**
  2. * @var Symfony\Component\DependencyInjection\ContainerInterface
  3. */
  4. protected $container;
  5. public function load($manager)

    The parameter manager, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Collective
  6. {
  7. $book = new Book();
  8. $book->setTitle('Disabled book');
  9. $book->setSlug('disabled-book');
  10. $book->setReadAt(new \DateTime('2011-10-10'));
  1. use Doctrine\Common\DataFixtures\AbstractFixture;
  2. use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
  3. class LoadPostCommentData extends AbstractFixture implements OrderedFixtureInterface
  4. {
  5. public function load($manager)

    The parameter manager, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Collective
  6. {
  7. $data = $this->getData();
  8. foreach ($data as $postSlug => $commentsData) {
  9. $post = $manager->getRepository('AlomWebsiteBundle:Post')->findOneBySlug($postSlug);
  1. use Doctrine\Common\DataFixtures\AbstractFixture;
  2. use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
  3. class LoadPostData extends AbstractFixture implements OrderedFixtureInterface
  4. {
  5. public function load($manager)

    The parameter manager, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Collective
  6. {
  7. $post_Symfony2_Services = new Post();
  8. $post_Symfony2_Services->setTitle('Symfony2 - Create your services');
  9. $post_Symfony2_Services->setSlug('Symfony2-Create-Your-Services');
  10. $post_Symfony2_Services->setPublishedAt("2010-09-20 00:00:00");
  1. /**
  2. * @var Symfony\Component\DependencyInjection\ContainerInterface
  3. */
  4. protected $container;
  5. public function load($manager)

    The parameter manager, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Collective
  6. {
  7. $user = new User();
  8. $user->setUsername('user');
  9. $user->setIsAdmin(false);
  10. $this->setPassword($user, 'user');

Unused method, property, variable or parameter

  • Minor
  • Deadcode

More information: https://insight.sensiolabs.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. }
  2. $comment->activate();
  3. $em->remove($comment);
  4. $em->flush();
  5. $fallbackUrl = $this->generateUrl('alom_website_post_view', array('slug' => $comment->getPost()->getSlug()));

    This fallbackUrl local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Collective
  6. return $this->redirect($request->headers->get('Referer', fallbackUrl));
  7. }
  8. public function activateAction($id)

Unused use statement should be avoided 2

  • Minor
  • Deadcode

More information: https://insight.sensiolabs.com/what-we-analyse/php.unused_use_statement

  1. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  2. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  3. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  4. use Alom\WebsiteBundle\Entity\PostComment;

    The class Alom\WebsiteBundle\Entity\PostComment is declared but never used. You should remove the use statement.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Collective
  5. class PostCommentController extends Controller
  6. {
  7. public function listAction()
  8. {
  1. <?php
  2. namespace Alom\WebsiteBundle\Entity;
  3. use Doctrine\ORM\EntityRepository;
  4. Use Doctrine\ORM\Query;

    The class Doctrine\ORM\Query is declared but never used. You should remove the use statement.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Collective
  5. class PostCommentRepository extends EntityRepository
  6. {
  7. public function fetchAllOrderedByDate()
  8. {