Showing 102 of 102 total issues
The variable $_memcached is not named in camelCase. Open
Open
public function configure($configuration)
{
$memcachedHost = $configuration['server'];
$memcachedPort = $configuration['port'];
$_memcached = new Memcached();
- 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 $_memcached is not named in camelCase. Open
Open
public function configure($configuration)
{
$memcachedHost = $configuration['server'];
$memcachedPort = $configuration['port'];
$_memcached = new Memcached();
- 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
Class extends undeclared class \Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
Open
Open
class MySQLProviderSetupCommand extends ContainerAwareCommand
- Exclude checks
Call to method setParameter
from undeclared class \Symfony\Component\DependencyInjection\ContainerBuilder
Open
Open
$container->setParameter('nw_request_limit.restriction_time', $restrictionTime);
- Exclude checks
Class extends undeclared class \Symfony\Component\HttpKernel\Bundle\Bundle
Open
Open
class NWRequestLimitBundle extends Bundle
- Exclude checks
Call to method set
from undeclared class \Memcached
Open
Open
return $this->_memcached->set($key, $expiresAt, 60 * 60 * 24 * 30);
- Exclude checks
@throws type of get
has undeclared type \Doctrine\DBAL\Driver\Exception
(Did you mean class \Exception) Open
Open
public function get($key)
- Exclude checks
Method \NW\RequestLimitBundle\Storage\Provider\MySQLProvider::remove
is declared to return mixed
but has no return value Open
Open
public function remove($key)
- Exclude checks
Call to undeclared method \NW\RequestLimitBundle\Tests\Unit\Utils\RestrictorTest::assertEquals
Open
Open
$this->assertEquals('userId', $result);
- Exclude checks
Call to method expects
from undeclared class \PHPUnit_Framework_MockObject_MockObject
Open
Open
$storageManager->expects($this->never())->method('getItem');
- Exclude checks
Define a constant instead of duplicating this literal "userId" 5 times. Open
Open
$result = $restrictor->blockBy('userId');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Parameter $input
has undeclared type \Symfony\Component\Console\Input\InputInterface
Open
Open
protected function execute(InputInterface $input, OutputInterface $output)
- Exclude checks
Class implements undeclared interface \Symfony\Component\Config\Definition\ConfigurationInterface
Open
Open
class Configuration implements ConfigurationInterface
- Exclude checks
Call to method delete
from undeclared class \Memcached
Open
Open
return $this->_memcached->delete($key);
- Exclude checks
Parameter $em
has undeclared type \Doctrine\ORM\EntityManager
Open
Open
public function __construct(EntityManager $em)
- Exclude checks
@throws type of remove
has undeclared type \Doctrine\DBAL\Driver\Exception
(Did you mean class \Exception) Open
Open
public function remove($key)
- Exclude checks
Call to method expects
from undeclared class \PHPUnit_Framework_MockObject_MockObject
Open
Open
$storageManager->expects($this->never())->method('setItem');
- Exclude checks
Rename "$_memcached" which has the same name as the field declared at line 17. Open
Open
$_memcached = new Memcached();
- Read upRead up
- Exclude checks
Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.
Noncompliant Code Example
class Foo { public $myField; public function doSomething() { $myField = 0; ... } }
See
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Call to method setParameter
from undeclared class \Symfony\Component\DependencyInjection\ContainerBuilder
Open
Open
$container->setParameter('nw_request_limit.provider_type', $providerType);
- Exclude checks
@throws type of fetchAllItems
has undeclared type \Doctrine\DBAL\Driver\Exception
(Did you mean class \Exception) Open
Open
public function fetchAllItems()
- Exclude checks