for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the WPPhpSpecBridge library.
*
* 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.
* @author Beñat Espiña <[email protected]>
*/
namespace {
define('WP_DEBUG', true);
class WP_Widget
{
public $id_base;
public $name;
public $number = false;
public function __construct($id_base, $name, $widget_options = [], $control_options = [])
$widget_options
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$control_options
$this->id_base = empty($id_base) ? preg_replace('/(wp_)?widget_/', '', strtolower(get_class($this))) : strtolower($id_base);
$this->name = $name;
$this->option_name = 'widget_' . $this->id_base;
option_name
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
function add_action($hook, $callback)
$hook
$callback
return true;
function add_filter($tag, $functionToAdd)
$tag
$functionToAdd
function add_theme_support($feature)
$feature
function wp_enqueue_script($name, $from, $dependencies, $version, $inFooter)
$name
$from
$dependencies
$version
$inFooter
function wp_enqueue_style($name, $from, $dependencies, $version, $media)
$media
function get_template_directory_uri()
function is_admin()
function add_post_type_support()
function remove_post_type_support()
function register_widget($className)
$className
function get_bloginfo()
return 'WordPress Standard';
function home_url()
return 'http://wordpress-standard';
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.