Issues (287)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

NamingConventions/ConstructorNameSniff.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * CodeIgniter_Sniffs_NamingConventions_ConstructorNameSniff.
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PHP_CodeSniffer
9
 * @author    Thomas Ernest <[email protected]>
10
 * @copyright 2011 Thomas Ernest
11
 * @license   http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
12
 * @link      http://pear.php.net/package/PHP_CodeSniffer
13
 */
14
15
namespace CodeIgniter\Sniffs\NamingConventions;
16
17
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
18
use PHP_CodeSniffer\Files\File;
19
20
/**
21
 * CodeIgniter_Sniffs_NamingConventions_ConstructorNameSniff.
22
 *
23
 * Favor PHP 4 constructor syntax, which uses "function ClassName()".
24
 * Avoid PHP 5 constructor syntax, which uses "function __construct()".
25
 *
26
 * @todo Try to avoid overly long and verbose names.
27
 *
28
 * @category  PHP
29
 * @package   PHP_CodeSniffer
30
 * @author    Thomas Ernest <[email protected]>
31
 * @copyright 2010 Thomas Ernest
32
 * @license   http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
33
 * @link      http://pear.php.net/package/PHP_CodeSniffer
34
 */
35
class ConstructorNameSniff extends AbstractScopeSniff
36
{
37
38
39
    public $php5Constructors = '1';
40
41
42
    /**
43
     * Constructs the test with the tokens it wishes to listen for.
44
     *
45
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
46
     */
47
    public function __construct()
48
    {
49
        parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true);
50
51
    }//end __construct()
52
53
54
    /**
55
     * Processes this test when one of its tokens is encountered.
56
     *
57
     * @param File $phpcsFile The current file being scanned.
58
     * @param int                  $stackPtr  The position of the current token
59
     *                                        in the stack passed in $tokens.
60
     * @param int                  $currScope A pointer to the start of the scope.
61
     *
62
     * @return void
63
     */
64
    protected function processTokenWithinScope(
65
        File $phpcsFile,
66
        $stackPtr,
67
        $currScope
68
    ) {
69
        $methodName = $phpcsFile->getDeclarationName($stackPtr);
70
        $className  = $phpcsFile->getDeclarationName($currScope);
71
72
	$isPhp4Constructor = strcasecmp($methodName, $className) === 0;
73
	$isPhp5Constructor = strcasecmp($methodName, '__construct') === 0;
74
        if ($this->php5Constructors != '0') {
75
            if ($isPhp4Constructor) {
76
                $error = "PHP4 style constructors are not allowed; use \"__construct\" instead";
77
                $phpcsFile->addError($error, $stackPtr);
0 ignored issues
show
The call to addError() misses a required argument $code.

This check looks for function calls that miss required arguments.

Loading history...
78
            }
79
        } else {
80
            if ($isPhp5Constructor) {
81
                $error = "PHP5 style constructors are not allowed; use \"$className\" instead";
82
                $phpcsFile->addError($error, $stackPtr);
0 ignored issues
show
The call to addError() misses a required argument $code.

This check looks for function calls that miss required arguments.

Loading history...
83
            }
84
        }
85
        if ( ! $isPhp4Constructor && ! $isPhp5Constructor ) {
86
            return;
87
        }
88
89
        $tokens = $phpcsFile->getTokens();
90
91
        $parentClassName = $phpcsFile->findExtendedClassName($currScope);
92
        $wrongConstructor = '';
93
        // prepares the error message and wrong constructor
94
        if ($this->php5Constructors != '0') {
95
            $error = 'PHP4 style calls to parent constructors are not allowed.';
96
            $error = "$error Please use \"parent::__construct\" instead.";
97
            if (false !== $parentClassName) {
98
                $wrongConstructor = $parentClassName;
99
            }
100
            // Else $wrongConstructor will be empty
101
            // and the test expression will always be false.
102
            // It doesn't check that no parent method should be called
103
            // when no parent class is defined.
104
        } else {
105
            $error = 'PHP5 style calls to parent constructors are not allowed.';
106
            if (false !== $parentClassName) {
107
                $error = "$error Please use \"parent::$parentClassName\" instead.";
108
            }
109
            $wrongConstructor = '__construct';
110
        }
111
112
        // looks for the use of a wrong constructor.
113
        $endFunctionIndex = $tokens[$stackPtr]['scope_closer'];
114
        $doubleColonIndex = $phpcsFile->findNext(
115
            array(T_DOUBLE_COLON),
116
            $stackPtr,
117
            $endFunctionIndex
118
        );
119
        while ($doubleColonIndex) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $doubleColonIndex of type integer|false is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
120
            if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING
121
                && $tokens[($doubleColonIndex + 1)]['content'] === $wrongConstructor
122
            ) {
123
                $phpcsFile->addError($error, ($doubleColonIndex + 1));
0 ignored issues
show
The call to addError() misses a required argument $code.

This check looks for function calls that miss required arguments.

Loading history...
124
            }
125
126
            $doubleColonIndex = $phpcsFile->findNext(
127
                array(T_DOUBLE_COLON),
128
                $doubleColonIndex + 1,
129
                $endFunctionIndex
130
            );
131
        }
132
133
    }//end processTokenWithinScope()
134
135
	protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
136
	{
137
		// TODO: Implement processTokenOutsideScope() method.
138
	}
139
140
}//end class
141
142
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
143