for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
namespace Facile\MongoDbBundle\Twig;
class FacileMongoDbBundleExtension extends \Twig_Extension
{
public function getFunctions()
return array(
new \Twig_Simplefunction('filterLabelTranslate', array($this, 'queryFilterTranslate')),
new \Twig_Simplefunction('dataLabelTranslate', array($this, 'queryDataTranslate')),
);
}
/**
* @param string $label
* @param string $methodName
*
* @return string
*/
public function queryFilterTranslate(string $label, string $methodName)
switch(strtolower($methodName)) {
default:
default: return $label;
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
return false
return $label;
public function queryDataTranslate(string $label, string $methodName)
case 'aggregate':
return 'Pipeline';
case 'insertOne':
return 'Document';
case 'updateOne':
case 'findOneAndUpdate':
return 'Update';
case 'replaceOne':
return 'Replacement';
* Returns the name of the extension.
* @return string The extension name
public function getName()
return 'facile_mongo_db_extesion';
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.