The method testReverseTransform uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
Phake::when($this->transformerManager)->reverseTransform('redirection', $facade)->thenReturn('ok');
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Phake' in method 'facadesProvider'. Open
$facade1 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'facadesProvider'. Open
$facadeCollection1 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'setUp'. Open
$this->transformerManager = Phake::mock('OpenOrchestra\BaseApi\Transformer\TransformerManager');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'testReverseTransform'. Open
Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'facadesProvider'. Open
$facade3 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'facadesProvider'. Open
$facadeCollection3 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'facadesProvider'. Open
$facadeCollection2 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'facadesProvider'. Open
$facade2 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'testReverseTransform'. Open
Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'setUp'. Open
$authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Phake' in method 'setUp'. Open
$this->redirectionTransformer = Phake::mock('OpenOrchestra\ApiBundle\Transformer\RedirectionTransformer');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Call to method times
from undeclared class \Phake
Open
Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$facade1 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
- Create a ticketCreate a ticket
- Exclude checks
Call to method verify
from undeclared class \Phake
Open
Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($facadeCollection2)->getRedirections()->thenReturn(array($facade1));
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$facadeCollection3 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');
- Create a ticketCreate a ticket
- Exclude checks
Saw an @param annotation for setCount,
but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open
* @param int $setCount
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->transformerManager)->reverseTransform('redirection', $facade)->thenReturn('ok');
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($facadeCollection3)->getRedirections()->thenReturn(array($facade1, $facade2, $facade3));
- Create a ticketCreate a ticket
- Exclude checks
Saw an @param annotation for facade,
but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open
* @param FacadeInterface $facade
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractBaseTestCase
Open
class RedirectionCollectionTransformerTest extends AbstractBaseTestCase
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$this->transformerManager = Phake::mock('OpenOrchestra\BaseApi\Transformer\TransformerManager');
- Create a ticketCreate a ticket
- Exclude checks
Call to method anyParameters
from undeclared class \Phake
Open
Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->transformerManager)->get('redirection')->thenReturn($this->redirectionTransformer);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Tests\Transformer\RedirectionCollectionTransformerTest::assertCount
Open
$this->assertCount($expectedSize, $collection);
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$facade3 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$this->redirectionTransformer = Phake::mock('OpenOrchestra\ApiBundle\Transformer\RedirectionTransformer');
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($facadeCollection1)->getRedirections()->thenReturn(array());
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\RedirectionCollectionTransformer::setContext
Open
$this->transformer->setContext($this->transformerManager);
- Create a ticketCreate a ticket
- Exclude checks
Saw an @param annotation for searchCount,
but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open
* @param int $searchCount
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->transformerManager)->reverseTransform('redirection', $facade)->thenReturn(null);
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$facade2 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');
- Create a ticketCreate a ticket
- Exclude checks
Call with 2 arg(s) to \OpenOrchestra\ApiBundle\Transformer\RedirectionCollectionTransformer::__construct()
which only takes 0 arg(s) defined at /code/ApiBundle/Transformer/RedirectionCollectionTransformer.php:13
Open
$this->transformer = new RedirectionCollectionTransformer(
- Create a ticketCreate a ticket
- Exclude checks
Saw an @param annotation for source,
but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open
* @param ContentInterface $source
- Create a ticketCreate a ticket
- Exclude checks
Possibly zero references to use statement for classlike/namespace RedirectionCollectionFacade
(\OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade)
Open
use OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade;
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$facadeCollection1 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$facadeCollection2 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Tests\Transformer\RedirectionCollectionTransformerTest::assertSame
Open
$this->assertSame('redirection_collection', $this->transformer->getName());
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $redirectionTransformer. Keep variable name length under 20. Open
protected $redirectionTransformer;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Line exceeds 120 characters; contains 127 characters Open
Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');
- Create a ticketCreate a ticket
- Exclude checks