tests/Base.php
The method Base::onNotSuccessfulTest() calls the typical debug function print_r() which is mostly only used during development. Open
Open
\print_r($this->logs);
- Read upRead up
- Exclude checks
DevelopmentCodeFragment
Since: 2.3.0
Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.
Example
class SuspectCode {
public function doSomething(array $items)
{
foreach ($items as $i => $item) {
// …
if ('qafoo' == $item) var_dump($i);
// …
}
}
}
Source https://phpmd.org/rules/design.html#developmentcodefragment
Reference to static property logToFile
from undeclared class \App\Log
Open
Open
\App\Log::$logToFile = false;
- Exclude checks
Class extends undeclared class \PHPUnit\Framework\TestCase
Open
Open
abstract class Base extends TestCase
- Exclude checks
Reference to static property logToFile
from undeclared class \App\Log
Open
Open
$this->logToFile = \App\Log::$logToFile;
- Exclude checks
Reference to static property logToFile
from undeclared class \App\Log
Open
Open
\App\Log::$logToFile = $this->logToFile;
- Exclude checks
Remove this commented out code. Open
Open
//var_export(array_shift($t->getTrace()));
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Avoid variables with short names like $t. Configured minimum length is 3. Open
Open
protected function onNotSuccessfulTest(\Throwable $t): void
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var mixed Last logs. */
- 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
echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected function disableLogs(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected function onNotSuccessfulTest(\Throwable $t): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Disable system logs.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Enable system logs.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @codeCoverageIgnore
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
- 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 $logs;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var bool Last logs. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* This method is called when a test method did not execute successfully.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ LOGS:\n";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
//var_export(array_shift($t->getTrace()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
\App\Log::$logToFile = $this->logToFile;
- 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
\print_r($this->logs);
- 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
private $logToFile;
- 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
\App\Log::$logToFile = 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
protected function enableLogs(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param \Throwable $t
- 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
if (isset($this->logs)) {
- 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
$this->logToFile = \App\Log::$logToFile;
- 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 $t;
- 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