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. {