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\Post;
use Timber\Timber;
/**
* Basic controller that works in the same way of MVC frameworks like Laravel or Symfony.
* It uses Timber that renders views with Twig Template engine inside Wordpress.
* @author Gorka Laucirica <[email protected]>
* @author Beñat Espiña <[email protected]>
final class DefaultController
{
* Index action.
* @return bool|string
public function indexAction()
$context = Timber::get_context();
return Timber::render('pages/index.twig', $context);
'pages/index.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);
}
* Not found action.
public function notFoundAction()
return Timber::render('pages/404.twig', $context);
'pages/404.twig'
* Page action.
public function pageAction()
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['page'] = new Post();
return Timber::render('pages/default.twig', $context);
'pages/default.twig'
* Attachment action.
public function attachmentAction()
$context['attachment'] = Timber::get_post();
$context['attachment_image'] = wp_attachment_is_image($context['attachment']->ID);
return Timber::render('pages/attachment/show.twig', $context);
'pages/attachment/show.twig'
This check marks files that end in a newline character, i.e. an empy line.
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: