app/Controller/ExposeMethod.php
Missing class import via use statement (line '70', column '13'). Open
Open
throw new \App\Exceptions\AppException('ERR_NOT_ACCESSIBLE', 406);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid assigning values to variables in if clauses and the like (line '80', column '7'). Open
Open
public function process(\App\Request $request)
{
if ($mode = $request->getMode()) {
$this->invokeExposedMethod($mode, $request);
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Saw an @param annotation for request,
but the param list of function invokeExposedMethod() : \App\Controller\type
is empty Open
Open
* @param \App\Request $request
- Exclude checks
Return type of invokeExposedMethod()
is undeclared type \App\Controller\type
Open
Open
public function invokeExposedMethod()
- Exclude checks
Saw an @param annotation for name,
but the param list of function invokeExposedMethod() : \App\Controller\type
is empty Open
Open
* @param string $name - method name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function checks if the method is exposed for client usage.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (\in_array($name, $this->exposedMethods)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$parameters = \func_get_args();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->invokeExposedMethod($mode, $request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Control the exposure of methods to be invoked from client (kind-of RPC).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (!\in_array($name, $this->exposedMethods)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function invokes exposed methods for this class.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->exposedMethods[] = $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $name - method name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $name - method name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return \call_user_func_array([$this, $name], $parameters);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($mode = $request->getMode()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected function exposeMethod($name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function invokeExposedMethod()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function isMethodExposed($name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (!empty($name) && $this->isMethodExposed($name)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function that will expose methods for external access.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected $exposedMethods = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$name = array_shift($parameters);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $name - method name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Process action.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
throw new \App\Exceptions\AppException('ERR_NOT_ACCESSIBLE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function process(\App\Request $request)
- Exclude checks