Development Code Fragment feature is not working #345

Open
chrisyue opened this Issue Feb 5, 2016 · 7 comments

Projects

None yet

4 participants

@chrisyue
chrisyue commented Feb 5, 2016
$ phpmd --version
PHPMD 2.3.2

$ phpmd path/to/File.php text design

the exit code is 0, but the File.php does contain var_dump and print_r

and the other features in design are working i think (I only test checking die/exit, goto, eval)

@ravage84 ravage84 added the Bug label Feb 5, 2016
@ravage84 ravage84 added this to the 2.3.3 milestone Feb 5, 2016
@ravage84 ravage84 modified the milestone: 2.3.3, 2.4.2 Mar 8, 2016
@manuelpichler manuelpichler modified the milestone: 2.4.2, 2.4.3 Mar 10, 2016
@manuelpichler
Member

Can you please provide a reproducable file for this issue

@chrisyue

@manuelpichler here is the file content:

<?php

namespace AppBundle\Controller\Front;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

/**
 * @Route("/hotsale")
 */
class HotSaleController extends Controller
{
    /**
     * @Route("/", name="front_hotsale_index", methods={"GET"})
     */
    public function indexAction(Request $request)
    {
        $hotsales = $this->getDoctrine()->getRepository('AppBundle:HotSale')
            ->createQueryBuilder('h')
            ->select('h, v')
            ->join('h.video', 'v')
            ->orderBy('h.sequence')
            ->getQuery()
            ->getResult();

        var_dump($hotsales);

        $banners = $this->get('app.banner.file_manager')->findAll();

        return $this->render('front/hotsale/index.html.twig', compact('hotsales', 'banners'));
    }
}

and I also found it maybe related to the namespace, because it can work after I remove the line of namespace declaration.

@chrisyue

Maybe PHPMD thinks var_dump is AppBundle\Controller\Front\var_dump?

@ravage84
Member

@chrisyue can you reduce the example to the following and still confirm the issue?

<?php

namespace AppBundle\Controller\Front;

class Foo
{
    public function testFoo()
    {
        var_dump($hotsales = '');
    }
}
@chrisyue

@ravage84 same issue, won't work until I remove namespace.

And it is also strange that it shows the message The method Foo::testFoo() calls the typical debug function var_dump() which is mostly only used during development. twice, it should show only once? Maybe it's another issue, I don't know..

@ravage84 ravage84 added the PDepend label Mar 25, 2016
@ravage84 ravage84 modified the milestone: 2.4.3, 2.4.4 Apr 25, 2016
@torkiljohnsen

I can confirm this issue.

@manuelpichler
Member

Works in the latest version that will be release today.

@manuelpichler manuelpichler reopened this Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment