The method PNGImageBaker::removeChunks() calls the typical debug function print_r() which is mostly only used during development. Open
print_r($sections);
- 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
Missing class import via use statement (line '102', column '23'). Open
throw new Exception('Is not a valid PNG image');
- 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
Remove error control operator '@' on line 33. Open
public function __construct($contents)
{
$this->_contents = $contents;
$png_signature = pack("C8", 137, 80, 78, 71, 13, 10, 26, 10);
// Read 8 bytes of PNG header and verify.
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Remove error control operator '@' on line 109. Open
public function removeChunks($chunkType, $key, $png)
{
// Read the magic bytes and verify
$retval = substr($png, 0, 8);
$ipos = 8;
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Remove error control operator '@' on line 157. Open
public function extractBadgeInfo($png, $key = 'openbadges')
{
// Read the magic bytes and verify
$retval = substr($png, 0, 8);
$ipos = 8;
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Avoid unused local variables such as '$data'. Open
[$key, $data] = explode("\0", $this->_chunks[$type][$typekey]);
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$skip'. Open
$skip = false;
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The property $_contents is not named in camelCase. Open
class PNGImageBaker
{
private $_contents;
private $_size;
private $_chunks;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_size is not named in camelCase. Open
class PNGImageBaker
{
private $_contents;
private $_size;
private $_chunks;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $_chunks is not named in camelCase. Open
class PNGImageBaker
{
private $_contents;
private $_size;
private $_chunks;
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Property name "$_contents" should not be prefixed with an underscore to indicate visibility Open
private $_contents;
- Exclude checks
Property name "$_size" should not be prefixed with an underscore to indicate visibility Open
private $_size;
- Exclude checks
Variable "png_signature" is not in valid camel caps format Open
if ($header != $png_signature) {
- Exclude checks
Property name "$_chunks" should not be prefixed with an underscore to indicate visibility Open
private $_chunks;
- Exclude checks
Variable "png_signature" is not in valid camel caps format Open
$png_signature = pack("C8", 137, 80, 78, 71, 13, 10, 26, 10);
- Exclude checks
The variable $png_signature is not named in camelCase. Open
public function __construct($contents)
{
$this->_contents = $contents;
$png_signature = pack("C8", 137, 80, 78, 71, 13, 10, 26, 10);
// Read 8 bytes of PNG header and verify.
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $png_signature is not named in camelCase. Open
public function __construct($contents)
{
$this->_contents = $contents;
$png_signature = pack("C8", 137, 80, 78, 71, 13, 10, 26, 10);
// Read 8 bytes of PNG header and verify.
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}