for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the WordPress Standard project.
*
* Copyright (c) 2015-2016 LIN3S <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AppTheme\Controller;
use Timber\Timber;
/**
* WordPress base Post controller implementation.
* @author Beñat Espiña <[email protected]>
* @author Jon Torrado <[email protected]>
final class PostController
{
* Blog posts page.
* @return bool|string
public function listAction()
$context = Timber::get_context();
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$context['posts'] = Timber::get_posts();
return Timber::render('pages/post/list.twig', $context);
'pages/post/list.twig'
string
array
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
}
* Category list action.
public function categoryListAction()
return Timber::render('pages/post/category_list.twig', $context);
'pages/post/category_list.twig'
* Show action.
public function showAction()
$context['post'] = Timber::get_post();
return Timber::render('pages/post/show.twig', $context);
'pages/post/show.twig'
This check marks files that end in a newline character, i.e. an empy line.
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.