for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @package WPEmerge
* @author Atanas Angelov <[email protected]>
* @copyright 2018 Atanas Angelov
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
* @link https://wpemerge.com/
*/
namespace WPEmerge\Routing\Conditions;
use WPEmerge\Requests\RequestInterface;
* Check against the current ajax action.
class AdminCondition implements ConditionInterface {
* Menu slug.
*
* @var string
protected $menu = '';
* Parent menu slug.
protected $parent_menu = '';
* Constructor
* @codeCoverageIgnore
* @param string $menu
* @param string $parent_menu
public function __construct( $menu, $parent_menu = '' ) {
$this->menu = $menu;
$this->parent_menu = $parent_menu;
}
* Check if the admin page requirement matches.
* @return boolean
protected function isAdminPage() {
return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX );
* {@inheritDoc}
public function isSatisfied( RequestInterface $request ) {
if ( ! $this->isAdminPage() ) {
return false;
$screen = get_current_screen();
$screen
get_current_screen()
null
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
class A { function getObject() { return null; } } $a = new A(); $object = $a->getObject();
The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
if ( ! $screen ) {
false
return $screen->id === get_plugin_page_hookname( $this->menu, $this->parent_menu );
public function getArguments( RequestInterface $request ) {
return ['hook' => get_plugin_page_hookname( $this->menu, $this->parent_menu )];
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.