for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @package A simple ORM that performs basic CRUD operations
* @author Surajudeen AKANDE <[email protected]>
* @license MIT <https://opensource.org/licenses/MIT>
* @link http://www.github.com/andela-sakande
* */
namespace Sirolad\Libraries;
use PDOException;
use Sirolad\DB\DBConnect;
use Sirolad\Libraries\Formatter;
use Sirolad\Interfaces\TableMapperInterface;
use Sirolad\Exceptions\TableDoesNotExistException;
*
*/
class TableMapper implements TableMapperInterface
{
* Check for the existence of a table in the currentt database
* @param string $table Name of table to be searched in the database
* @param DbConnnect $dbConnect Database connection object
$dbConnect
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
* @return string Name of the table checked
public static function checkTableName($table)
try {
$dbConnect = new DBConnect();
$result = $dbConnect->getConnection()->query('SELECT 1 FROM ' . $table . ' LIMIT 1');
if ($result !== false) {
return $table;
}
} catch (PDOException $e) {
return $e->getMessage();
finally {
$dbConnect = null;
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
* @var array classname from class namespace
* @return string which is in lower case
**/
public static function getClassName($className)
$demarcation = explode('\\', $className);
return Formatter::addOrRemoveS(strtolower(end($demarcation)));
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.