__construct accesses the super-global variable $_SESSION. Open
public function __construct(
$sFlitePath = CAPTCHA_FLITE_PATH, // path to flite binary
$sAudioPath = CAPTCHA_AUDIO_PATH // the location to temporarily store the generated audio CAPTCHA
)
{
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
__construct accesses the super-global variable $_SESSION. Open
public function __construct(
$sFlitePath = CAPTCHA_FLITE_PATH, // path to flite binary
$sAudioPath = CAPTCHA_AUDIO_PATH // the location to temporarily store the generated audio CAPTCHA
)
{
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Remove error control operator '@' on line 144. Open
public function Create()
{
$sText = $this->Mask($this->sCode);
$sFile = \md5($this->sCode . \time());
- 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 '$iValue'. Open
foreach ($sText as $i => $iValue) {
- 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
Method name "AudioPhpCaptcha::SetFlitePath" is not in camel caps format Open
public function SetFlitePath($sFlitePath)
- Exclude checks
Method name "AudioPhpCaptcha::Mask" is not in camel caps format Open
public function Mask($sText)
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Multi-line function declarations must define one parameter per line Open
$sFlitePath = CAPTCHA_FLITE_PATH, // path to flite binary
- Exclude checks
Method name "AudioPhpCaptcha::SetAudioPath" is not in camel caps format Open
public function SetAudioPath($sAudioPath)
- Exclude checks
Method name "AudioPhpCaptcha::Create" is not in camel caps format Open
public function Create()
- Exclude checks
The method SetFlitePath is not named in camelCase. Open
public function SetFlitePath($sFlitePath)
{
$this->sFlitePath = $sFlitePath;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method Mask is not named in camelCase. Open
public function Mask($sText)
{
$iLength = mb_strlen($sText);
// loop through characters in code and format
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method SetAudioPath is not named in camelCase. Open
public function SetAudioPath($sAudioPath)
{
$this->sAudioPath = $sAudioPath;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method Create is not named in camelCase. Open
public function Create()
{
$sText = $this->Mask($this->sCode);
$sFile = \md5($this->sCode . \time());
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}