Skip to content

Commit

Permalink
Fix various issues found by phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesread committed Aug 28, 2023
1 parent 639d288 commit d6eae08
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 26 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
default: tests lint

test: tests
phpunit: tests

tests:
composer run-script test
Expand All @@ -11,7 +12,10 @@ phpcs:
./vendor/bin/phpcs

phpstan:
./vendor/bin/phpstan analyse --level 1 src/main/php/libAllure/
./vendor/bin/phpstan analyse --level 5 src/main/php/libAllure/

docs:
doxygen


.PHONY: test tests default lint
Binary file removed src/main/php/libAllure/.ErrorHandler.php.swo
Binary file not shown.
7 changes: 2 additions & 5 deletions src/main/php/libAllure/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ public function __construct($dsn, $username, $password)
//$this->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, true);
}

public function prepareSelectById($table, $id)
public function prepareSelectById($table, $id, ...$fields)
{
$args = func_get_args();
$table = array_shift($args);
$id = intval(array_shift($args));
$fields = implode(', ', array_merge(array('id'), $fields));

$fields = implode(array_merge(array('id'), $args), ', ');
$sql = "SELECT {$fields} FROM {$table} WHERE id = :id";
$stmt = $this->prepare($sql);
$stmt->bindValue(':id', $id);
Expand Down
1 change: 0 additions & 1 deletion src/main/php/libAllure/ElementButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ protected function afterConstruct()
public function render()
{
return '<button name = "' . $this->name . '" type = "' . $this->type . '" value = "' . $this->value . '">' . $this->caption . '</button>';
return '<input name = "' . $this->name . '" type = "' . $this->type . '" value = "' . $this->caption . '" />';
}
}
5 changes: 0 additions & 5 deletions src/main/php/libAllure/ElementNumeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class ElementNumeric extends ElementInput
{
private $allowNegative = false;
private $allowFloatingPoint = false;
private $allowNonDenery = false;
private $maximum = PHP_INT_MAX;
private $minimum = 0;

Expand All @@ -21,10 +20,6 @@ public function setAllowFloatingPoint($allowFloatingPoint)
$this->allowFloatingPoint = $allowFloatingPoint;
}

public function setAllowNonDenery($allowNonDenary)
{
}

public function setBounds($minimum, $maximum)
{
if (!is_numeric($minimum) || !is_numeric($maximum)) {
Expand Down
7 changes: 0 additions & 7 deletions src/main/php/libAllure/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ abstract class Form
{
public static $registeredForms = array();

private $rules = array();
protected $elements = array();
public $scripts = array();
private $name;
private $submitter;
private $title = '';
private $generalError;
private $action;

protected $enctype = 'multipart/form-data';
Expand Down Expand Up @@ -261,11 +259,6 @@ private function getElementName($element)
}
}

public function setGeneralError($generalError)
{
$this->generalError = $generalError;
}

public static function strToForm($s)
{
if (class_exists($s)) {
Expand Down
1 change: 0 additions & 1 deletion src/main/php/libAllure/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Sanitizer
public const FORMAT_FOR_ALL = 64;

private $inputSource = self::INPUT_REQUEST;
private $variableNamePrefixes = array ('form');

private static $instance;

Expand Down
2 changes: 0 additions & 2 deletions src/main/php/libAllure/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
class Scheduler
{
private $db;
private $startTime;

public function __construct(\libAllure\Database $db)
{
$this->db = $db;
$this->startTime = time();
}

public function executeOverdueJobs()
Expand Down
3 changes: 0 additions & 3 deletions src/main/php/libAllure/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class Session
public static $cookieSecure = false;
public static $cookieHttpOnly = true;

// static copy of $_SESSION['user']
private static $user;

protected function __construct()
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/libAllure/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function boolToString($test, $onTrue = "Yes", $onFalse = "No", $onNull =
{
if ($test == null) {
return $onNull;
} elseif ($test) {
} elseif ($test == true) {
return $onTrue;
} else {
return $onFalse;
Expand Down

0 comments on commit d6eae08

Please sign in to comment.