for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace League\Fractal\Test\Pagination;
use League\Fractal\Pagination\PhalconFrameworkPaginatorAdapter;
use Mockery;
class PhalconFrameworkPaginatorAdapterTest extends \PHPUnit_Framework_TestCase
{
public function testPaginationAdapter()
$total = 50;
$count = 10;
$perPage = 10;
$perPage
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
$currentPage = 2;
$lastPage = 5;
$paginate =[
'last' => $lastPage,
'current' => $currentPage,
'total_items' => $total,
'total_pages' => $count,
];
$paginator = Mockery::mock('Phalcon\Paginator\Adapter\QueryBuilder');
$paginator->shouldReceive('currentPage')->andReturn($currentPage);
$paginator->shouldReceive('lastPage')->andReturn($lastPage);
$paginator->shouldReceive('count')->andReturn($count);
$paginator->shouldReceive('total')->andReturn($total);
$paginator->shouldReceive('getPaginate')->andReturn((object) $paginate);
$adapter = new PhalconFrameworkPaginatorAdapter($paginator);
$this->assertInstanceOf('League\Fractal\Pagination\PaginatorInterface', $adapter);
$this->assertSame($currentPage, $adapter->getCurrentPage());
$this->assertSame($lastPage, $adapter->getLastPage());
$this->assertSame($count, $adapter->getCount());
$this->assertSame($total, $adapter->getTotal());
}
public function tearDown()
Mockery::close();
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.