</rule>
<rule ref="PEAR.Commenting.FunctionComment"/>
<rule ref="PEAR.Commenting.InlineComment"/>
+ <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
+ <exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
+ </rule>
+ <rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
+ <exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
+ </rule>
+ <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
+ <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation"/>
+ <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
+ </rule>
</ruleset>
"friendsoftwig/twigcs": "^6.2",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^10.0",
- "malukenho/docheader": "^1.0"
+ "malukenho/docheader": "^1.0",
+ "slevomat/coding-standard": "^8.14"
},
"config": {
"optimize-autoloader": true,
- "platform-check": false
+ "platform-check": false,
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": true
+ }
},
"scripts": {
"post-install-cmd": [
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "49aee4bfa35737b80d4e7c19726e83c8",
+ "content-hash": "be5bd2ccb4b48326a2ceeec5665880c3",
"packages": [
{
"name": "akrabat/rka-slim-session-middleware",
}
],
"packages-dev": [
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/composer-installer.git",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da",
+ "reference": "4be43904336affa5c2f70744a348312336afd0da",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0 || ^2.0",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
+ },
+ "require-dev": {
+ "composer/composer": "*",
+ "ext-json": "*",
+ "ext-zip": "*",
+ "php-parallel-lint/php-parallel-lint": "^1.3.1",
+ "phpcompatibility/php-compatibility": "^9.0",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "franck.nijhof@dealerdirect.com",
+ "homepage": "http://www.frenck.nl",
+ "role": "Developer / IT Manager"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "homepage": "http://www.dealerdirect.com",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcbf",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/composer-installer/issues",
+ "source": "https://github.com/PHPCSStandards/composer-installer"
+ },
+ "time": "2023-01-05T11:28:13+00:00"
+ },
{
"name": "friendsoftwig/twigcs",
"version": "6.2.0",
},
"time": "2022-02-21T01:04:05+00:00"
},
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "1.28.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb",
+ "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^2.0",
+ "nikic/php-parser": "^4.15",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^1.5",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.0",
+ "phpunit/phpunit": "^9.5",
+ "symfony/process": "^5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "support": {
+ "issues": "https://github.com/phpstan/phpdoc-parser/issues",
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0"
+ },
+ "time": "2024-04-03T18:51:33+00:00"
+ },
{
"name": "phpstan/phpstan",
"version": "1.10.41",
],
"time": "2023-02-07T11:34:05+00:00"
},
+ {
+ "name": "slevomat/coding-standard",
+ "version": "8.14.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/slevomat/coding-standard.git",
+ "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/fea1fd6f137cc84f9cba0ae30d549615dbc6a926",
+ "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
+ "php": "^7.2 || ^8.0",
+ "phpstan/phpdoc-parser": "^1.23.1",
+ "squizlabs/php_codesniffer": "^3.7.1"
+ },
+ "require-dev": {
+ "phing/phing": "2.17.4",
+ "php-parallel-lint/php-parallel-lint": "1.3.2",
+ "phpstan/phpstan": "1.10.37",
+ "phpstan/phpstan-deprecation-rules": "1.1.4",
+ "phpstan/phpstan-phpunit": "1.3.14",
+ "phpstan/phpstan-strict-rules": "1.5.1",
+ "phpunit/phpunit": "8.5.21|9.6.8|10.3.5"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "8.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "SlevomatCodingStandard\\": "SlevomatCodingStandard/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
+ "keywords": [
+ "dev",
+ "phpcs"
+ ],
+ "support": {
+ "issues": "https://github.com/slevomat/coding-standard/issues",
+ "source": "https://github.com/slevomat/coding-standard/tree/8.14.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/kukulich",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-10-08T07:28:08+00:00"
+ },
{
"name": "squizlabs/php_codesniffer",
"version": "3.7.2",
*
* @return boolean
*/
-function isValidWebUrl($url)
+function isValidWebUrl(string $url): bool
{
return (preg_match(
'#^http[s]?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i',
------------------------------------------------------------------------------*/
error_reporting(E_ALL);
-set_error_handler(function ($severity, $message, $file, $line) {
+set_error_handler(function ($severity, $message, $file, $line): void {
if (error_reporting() & $severity) {
throw new \ErrorException($message, 0, $severity, $file, $line);
}
*
* @return string
*/
-function _T($string, $domain = 'galette', $nt = true)
+function _T(string $string, string $domain = 'galette', bool $nt = true): string
{
global $language, $installer, $translator, $l10n;
*
* @return string
*/
-function _Tn($singular, $plural, $count, $domain = 'galette', $nt = true)
+function _Tn(string $singular, string $plural, int $count, string $domain = 'galette', bool $nt = true): string
{
global $language, $installer, $translator, $l10n;
*
* @return string
*/
-function _Tx($context, $string, $domain = 'galette', $nt = true)
+function _Tx(string $context, string $string, string $domain = 'galette', bool $nt = true): string
{
global $language, $installer, $translator, $l10n;
*
* @return string
*/
-function _Tnx($context, $singular, $plural, $count, $domain = 'galette', $nt = true)
+function _Tnx(string $context, string $singular, string $plural, int $count, string $domain = 'galette', bool $nt = true): string
{
global $language, $installer, $translator, $l10n;
*
* @return string
*/
-function contextualizedString($string, $context)
+function contextualizedString(string $string, string $context): string
{
return "{$string}\004{$context}";
}
*
* @return string
*/
-function __($string, $domain = 'galette')
+function __(string $string, string $domain = 'galette'): string
{
return _T($string, $domain, false);
}
use Galette\Filters\MembersList;
use Slim\Routing\RouteCollectorProxy;
-$app->group('/ajax', function (RouteCollectorProxy $app) use ($authenticate) {
+$app->group('/ajax', function (RouteCollectorProxy $app) use ($authenticate): void {
$app->get(
'/messages',
[AjaxController::class, 'messages']
$app->group(
'/plugins',
- function (\Slim\Routing\RouteCollectorProxy $app) use ($authenticate) {
+ function (\Slim\Routing\RouteCollectorProxy $app) use ($authenticate): void {
/** @var $container \DI\Container */
$container = $app->getContainer();
$modules = $container->get('plugins')->getModules();
$app->group(
'/' . $module['route'],
//$module_id may be used in included _routes.php from plugin.
- function (\Slim\Routing\RouteCollectorProxy $app) use ($module, $module_id, $authenticate, $container) {
+ function (\Slim\Routing\RouteCollectorProxy $app) use ($module, $module_id, $authenticate, $container): void {
//Plugin home: give information
$app->get(
'',
use Galette\Controllers\Crud;
use Slim\Routing\RouteCollectorProxy;
-$app->group('/public', function (RouteCollectorProxy $app) use ($routeparser) {
+$app->group('/public', function (RouteCollectorProxy $app) use ($routeparser): void {
//public members list
$app->get(
'/{type:list|trombi}[/{option:page|order}/{value:\d+|\w+}]',
*
* @return string
*/
-function remove_comments(&$output)
+function remove_comments(string &$output): string
{
$lines = explode("\n", $output);
$output = "";
*
* @return string
*/
-function remove_remarks($sql)
+function remove_remarks(string $sql): string
{
$lines = explode("\n", $sql);
*
* @return array
*/
-function split_sql_file($sql, $delimiter)
+function split_sql_file(string $sql, string $delimiter): array
{
// Split up our string into "possible" SQL statements.
$tokens = explode($delimiter, $sql);
abstract class AbstractController
{
- /**
- * @var ContainerInterface
- */
- private $container;
- /**
- * @var Db
- */
+ private ContainerInterface $container;
#[Inject]
protected Db $zdb;
- /**
- * @var Login
- */
#[Inject]
protected Login $login;
- /**
- * @var Preferences
- */
#[Inject]
protected Preferences $preferences;
- /**
- * @var Twig
- */
#[Inject]
protected Twig $view;
- /**
- * @var Logo
- */
#[Inject]
protected Logo $logo;
- /**
- * @var PrintLogo
- */
#[Inject]
protected PrintLogo $print_logo;
- /**
- * @var Plugins
- */
#[Inject]
protected Plugins $plugins;
- /**
- * @var RouteParser
- */
#[Inject]
protected RouteParser $routeparser;
- /**
- * @var History
- */
#[Inject]
protected History $history;
- /**
- * @var I18n
- */
#[Inject]
protected I18n $i18n;
- /**
- * @var L10n
- */
#[Inject]
protected L10n $l10n;
- /**
- * @var Session
- */
#[Inject("session")]
protected Session $session;
- /**
- * @var Messages
- */
#[Inject]
protected Messages $flash;
- /**
- * @var FieldsConfig
- */
#[Inject]
protected FieldsConfig $fields_config;
- /**
- * @var ListsConfig
- */
#[Inject]
protected ListsConfig $lists_config;
/**
{
use BatchList;
- /** @var bool */
private bool $is_self_membership = false;
// CRUD - Create
*
* @return Response
*/
- public function doEdit(Request $request, Response $response, int $id = null, $type = null): Response
+ public function doEdit(Request $request, Response $response, int $id = null, ?string $type = null): Response
{
$post = $request->getParsedBody();
$trans = new Transaction($this->zdb, $this->login);
/**
* Generates a new password for specified member
*
- * @param mixed $arg Any argument required
+ * @param int $id_adh Member identifier
*
* @return boolean
*/
- abstract public function generateNewPassword($arg): bool;
+ abstract public function generateNewPassword(int $id_adh): bool;
/**
* Remove expired passwords queries (older than 24 hours)
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = array('logged', 'admin', 'active', 'superadmin', 'staff', 'cron', 'uptodate');
if (in_array($name, $forbidden)) {
*/
class Db
{
- /** @var Adapter */
private Adapter $db;
- /** @var string */
private string $type_db;
- /** @var Sql */
private Sql $sql;
/** @var array<string,string> */
private array $options;
- /** @var string */
private string $last_query;
public const MYSQL = 'mysql';
* @return mixed
* @throws RuntimeException
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
switch ($name) {
case 'db':
*
* @return integer
*/
- public function getLastGeneratedValue($entity): int
+ public function getLastGeneratedValue(object $entity): int
{
/** @phpstan-ignore-next-line */
return (int)$this->driver->getLastGeneratedValue(
private int $max = 12;
private int $min = 0;
- /** @var I18n */
private I18n $i18n;
- /** @var integer */
private int $current_left;
- /** @var integer */
private int $current_right;
- /** @var integer */
private int $current_op;
- /** @var integer */
private int $gaptcha;
/**
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
- Analog::log(
- '[History] Getting property `' . $name . '`',
- Analog::DEBUG
- );
-
$forbidden = array();
if (!in_array($name, $forbidden)) {
return $this->$name;
- } else {
- Analog::log(
- '[History] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
Analog::log(
'[History] Setting property `' . $name . '`',
*
* @return boolean
*/
- public function isStepPassed($step): bool
+ public function isStepPassed(int $step): bool
{
return $this->step > $step;
}
{
public const TABLE = 'l10n';
- /** @var Db */
private Db $zdb;
- /** @var I18n */
private I18n $i18n;
/**
class LightSlimApp
{
private string $mode;
- /** @var App */
private App $app;
/**
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = array('ordered');
if (!in_array($name, $forbidden)) {
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'subject':
*/
public function __construct(Db $zdb, Login $login, Preferences $preferences, MailingsList $filters = null, Mailing $mailing = null)
{
+ if ($filters === null) {
+ $filters = new MailingsList();
+ }
+
parent::__construct($zdb, $login, $preferences, $filters);
$this->mailing = $mailing;
}
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
if (in_array($name, $this->pagination_fields)) {
return $this->$name;
- } else {
- Analog::log(
- '[' . get_class($this) .
- '|Pagination] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'ordered':
*
* @return boolean
*/
- public function generateNewPassword($id_adh): bool
+ public function generateNewPassword(int $id_adh): bool
{
//first of all, we'll remove all existant entries for specified id
$this->removeOldEntries($id_adh);
*
* @return false|int false if hash is not valid, member id otherwise
*/
- public function isHashValid(string $hash)
+ public function isHashValid(string $hash): false|int
{
try {
$select = $this->zdb->select(self::TABLE);
/**
* Default constructor.
*
- * @param mixed|null $id_adh the id of the member
+ * @param string|int|null $id_adh the id of the member
*/
- public function __construct($id_adh = null)
+ public function __construct(string|int|null $id_adh = null)
{
$this->init(
null,
);
// '!==' needed, otherwise ''==0
- if ($id_adh !== '' && $id_adh !== null) {
+ if (!empty($id_adh) && $id_adh !== '') {
$this->id = $id_adh;
if (!isset($this->db_id)) {
$this->db_id = $id_adh;
}
/**
- * Get image file content
+ * Get image file contents in stdOut
*
- * @return mixed
+ * @return void
*/
- public function getContents()
+ public function getContents(): void
{
readfile($this->file_path);
}
*
* @return string Localized message
*/
- public function getErrorMessage($code): string
+ public function getErrorMessage(int $code): string
{
$error = null;
switch ($code) {
*
* @return mixed module's information
*/
- public function moduleInfo(string $id, string $info)
+ public function moduleInfo(string $id, string $info): mixed
{
return $this->modules[$id][$info] ?? null;
}
*
* @return mixed
*/
- public function validateValue(string $fieldname, $value)
+ public function validateValue(string $fieldname, mixed $value): mixed
{
global $login;
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = array('defaults');
$virtuals = array('vpref_email', 'vpref_email_newadh');
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
//does this pref exists ?
if (!array_key_exists($name, self::$defaults)) {
*/
class SlimApp
{
- /** @var App */
private App $app;
/**
* @param Db $zdb Database instance
* @param mixed $args Arguments
*/
- public function __construct(Db $zdb, $args = null)
+ public function __construct(Db $zdb, mixed $args = null)
{
$this->zdb = $zdb;
*
* @return void
*/
- public function validate(string $field, $value, array $values): void
+ public function validate(string $field, mixed $value, array $values): void
{
global $preferences;
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = array(
'admin', 'staff', 'due_free', 'appears_in_list', 'active',
/** @var array<int, PaymentType> */
private array $ptypes_list;
- /** @var Db */
private Db $zdb;
- /** @var Login */
private Login $login;
/** @var array<string> */
protected array $errors = [];
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
if (in_array($name, $this->forbidden_fields)) {
Analog::log(
"Unknown property '$name'",
Analog::WARNING
);
- return null;
}
+
+ return null;
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
global $preferences;
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = array();
$virtuals = array('extension', 'libelle');
public const MINUTES = 'minutes';
public const VOTES = 'votes';
- /** @var Db */
private Db $zdb;
- /** @var int */
private int $id;
- /** @var string */
private string $type;
- /** @var string */
private string $filename;
- /** @var DateTime */
private DateTime $creation_date;
- /** @var string */
protected string $store_path = GALETTE_DOCUMENTS_PATH;
- /** @var ?string */
private ?string $comment = null;
/** @var array<string> */
private array $errors = [];
if (count($this->core_db_fields)) {
array_walk(
$this->core_db_fields,
- function ($field) use (&$_all_fields) {
+ function ($field) use (&$_all_fields): void {
$_all_fields[$field['field_id']] = $field;
}
);
namespace Galette\Entity;
use ArrayObject;
-use stdClass;
use Throwable;
use Analog\Analog;
use Galette\Core\Login;
/**
* Handle list labels
*
- * @param stdClass $field Field data
+ * @param object $field Field data
*
* @return void
*/
- private function handleLabel(stdClass $field): void
+ private function handleLabel(object $field): void
{
switch ($field->field_id) {
case 'bool_admin_adh':
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
switch ($name) {
case 'id':
case 'name':
return $this->$name;
- default:
- Analog::log(
- 'Unable to get Title property ' . $name,
- Analog::WARNING
- );
- break;
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'name':
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
- global $lang;
-
switch ($name) {
case 'id':
return (int)$this->$name;
$value = $this->proceedReplacements($prop_value);
return $value;
- default:
- Analog::log(
- 'Unable to get PdfModel property ' . $name,
- Analog::WARNING
- );
- break;
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'type':
private int $type;
private Adherent $dest;
private string $date;
- /** @var boolean */
private bool $success = false;
- /** @var boolean */
private bool $nomail;
private string $comment;
private string $msg;
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
switch ($name) {
case 'member_id':
return $this->$name;
case 'comment':
return $this->comment;
- default:
- Analog::log(
- 'Unable to get Reminder property ' . $name,
- Analog::WARNING
- );
- break;
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'type':
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = [];
$virtuals = ['sparameters'];
}
return $parameters;
default:
- if (!property_exists($this, $name)) {
- Analog::log(
- "Unknown property '$name'",
- Analog::WARNING
- );
- return null;
- } else {
+ if (property_exists($this, $name)) {
return $this->$name;
}
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'form':
public const BLOG = 'blog';
public const DISCORD = 'discord';
- /** @var Db */
private Db $zdb;
- /** @var int */
private int $id;
- /** @var string */
private string $type;
- /** @var string */
private string $url;
- /** @var int */
private ?int $id_adh;
- /** @var Adherent|null */
private ?Adherent $member = null;
/**
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
return $this->$name;
}
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
$forbidden = array();
$virtuals = array('extension', 'libelle');
*
* @return mixed
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
global $lang;
} else {
return $this->$rname;
}
- default:
- Analog::log(
- 'Unable to get Title property ' . $name,
- Analog::WARNING
- );
- break;
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
switch ($name) {
case 'short':
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
if (!in_array($name, $this->forbidden_fields) && property_exists($this, $name)) {
switch ($name) {
*
* @return array<string>|true
*/
- public function handleFiles(array $files)
+ public function handleFiles(array $files): array|bool
{
$this->errors = [];
*/
class ContribListener implements ListenerSubscriber
{
- /** @var Preferences */
private Preferences $preferences;
- /** @var RouteParser */
private RouteParser $routeparser;
- /** @var History */
private History $history;
- /** @var Messages */
private Messages $flash;
- /** @var Login */
private Login $login;
- /** @var Db */
private Db $zdb;
/**
{
$acceptor->subscribeTo(
'contribution.add',
- function (GaletteEvent $event) {
+ function (GaletteEvent $event): void {
$this->contributionAdded($event->getObject());
}
);
*/
class GaletteEvent implements HasEventName
{
- /** @var string */
private string $name;
private object $object;
*/
class MemberListener implements ListenerSubscriber
{
- /** @var Preferences */
private Preferences $preferences;
- /** @var RouteParser */
private RouteParser $routeparser;
- /** @var History */
private History $history;
- /** @var Messages */
private Messages $flash;
- /** @var Login */
private Login $login;
- /** @var Db */
private Db $zdb;
/**
{
$acceptor->subscribeTo(
'member.add',
- function (GaletteEvent $event) {
+ function (GaletteEvent $event): void {
$this->memberAdded($event->getObject());
}
);
$acceptor->subscribeTo(
'member.edit',
- function (GaletteEvent $event) {
+ function (GaletteEvent $event): void {
$this->memberEdited($event->getObject());
}
);
*
* @return bool
*/
- abstract protected function cacheLoaded($content): bool;
+ abstract protected function cacheLoaded(mixed $content): bool;
}
{
use Dependencies;
- /** @var string */
protected string $name_pattern = 'info_field_';
- /** @var DynamicFieldsHandle */
protected DynamicFieldsHandle $dynamics;
/**
private array $dynamic_patterns = [];
private ?PHPMailer $mail = null;
- /**
- * @var Db
- */
#[Inject("zdb")]
protected Db $zdb;
- /**
- * @var Login
- */
#[Inject("login")]
protected Login $login;
- /**
- * @var Preferences
- */
#[Inject("preferences")]
protected Preferences $preferences;
- /**
- * @var RouteParser
- */
protected RouteParser $routeparser;
/**
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
-
- Analog::log(
- '[AdvancedMembersList] Getting property `' . $name . '`',
- Analog::DEBUG
- );
-
if (
in_array($name, $this->pagination_fields)
|| in_array($name, $this->memberslist_fields)
return $search_fields;
}
return $this->$name;
- } else {
- Analog::log(
- '[AdvancedMembersList] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
global $zdb, $preferences, $login;
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
- Analog::log(
- '[ContributionsList] Getting property `' . $name . '`',
- Analog::DEBUG
- );
-
if (in_array($name, $this->pagination_fields)) {
return parent::__get($name);
} else {
default:
return $this->$name;
}
- } else {
- Analog::log(
- '[ContributionsList] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
if (in_array($name, $this->pagination_fields)) {
parent::__set($name, $value);
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
- Analog::log(
- '[' . static::class . '] Getting property `' . $name . '`',
- Analog::DEBUG
- );
-
if (in_array($name, $this->pagination_fields)) {
return parent::__get($name);
} else {
$e->getMessage(),
Analog::INFO
);
- return $this->$name;
}
- break;
+ return $this->$name;
default:
return $this->$name;
}
- } else {
- Analog::log(
- '[' . static::class . '] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
if (in_array($name, $this->pagination_fields)) {
parent::__set($name, $value);
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
if (in_array($name, $this->pagination_fields)) {
return parent::__get($name);
} else {
if (in_array($name, $this->memberslist_fields)) {
return $this->$name;
- } else {
- Analog::log(
- '[MembersList] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
if (in_array($name, $this->pagination_fields)) {
parent::__set($name, $value);
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
if (in_array($name, $this->pagination_fields)) {
return parent::__get($name);
default:
return $this->$name;
}
- } else {
- Analog::log(
- '[ScheduledPaymentsList] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
if (in_array($name, $this->pagination_fields)) {
parent::__set($name, $value);
*
* @return mixed the called property
*/
- public function __get(string $name)
+ public function __get(string $name): mixed
{
- Analog::log(
- '[TransactionsList] Getting property `' . $name . '`',
- Analog::DEBUG
- );
-
if (in_array($name, $this->pagination_fields)) {
return parent::__get($name);
} else {
default:
return $this->$name;
}
- } else {
- Analog::log(
- '[TransactionsList] Unable to get property `' . $name . '`',
- Analog::WARNING
- );
}
}
+
+ throw new \RuntimeException(
+ sprintf(
+ 'Unable to get property "%s::%s"!',
+ __CLASS__,
+ $name
+ )
+ );
}
/**
*
* @return void
*/
- public function __set(string $name, $value): void
+ public function __set(string $name, mixed $value): void
{
if (in_array($name, $this->pagination_fields)) {
parent::__set($name, $value);
*
* @return void
*/
- public function exportContributions(ContributionsList $filters)
+ public function exportContributions(ContributionsList $filters): void
{
$class = '\\Galette\\Entity\\' . ucwords(trim($this->type, 's'));
$contrib = new $class($this->zdb, $this->login);
*
* @return string
*/
- public function getPath()
+ public function getPath(): string
{
return $this->path;
}
*
* @return string
*/
- public function getFileName()
+ public function getFileName(): string
{
return $this->filename;
}
*
* @return void
*/
- private function loadFields()
+ private function loadFields(): void
{
//at last, we got the defaults
$this->fields = $this->default_fields;
*
* @return array<string>
*/
- public function getDefaultFields()
+ public function getDefaultFields(): array
{
return $this->default_fields;
}
Db $zdb,
Preferences $preferences,
History $history,
- $filename,
+ string $filename,
array $members_fields,
array $members_fields_cats,
- $dryrun
- ) {
+ bool $dryrun
+ ): bool|int {
if (
!file_exists(self::DEFAULT_DIRECTORY . '/' . $filename)
|| !is_readable(self::DEFAULT_DIRECTORY . '/' . $filename)
*
* @return boolean
*/
- private function check(string $filename)
+ private function check(string $filename): bool
{
$handle = fopen(self::DEFAULT_DIRECTORY . '/' . $filename, 'r');
if (!$handle) {
*
* @return boolean
*/
- private function storeMembers($filename)
+ private function storeMembers(string $filename): bool
{
$handle = fopen(self::DEFAULT_DIRECTORY . '/' . $filename, 'r');
*
* @return string Localized message
*/
- public function getErrorMessage($code)
+ public function getErrorMessage(int $code): string
{
$error = null;
switch ($code) {
* @return string CSV result
*/
public function export(
- $rs,
+ ResultSet|array $rs,
string $separator,
string $quote,
array|bool $titles = false,
protected ?string $extension;
protected ?string $dest_dir;
/** @var array<string> */
- protected $allowed_extensions = array();
+ protected array $allowed_extensions = array();
/** @var array<string,string> */
- protected $allowed_mimes = array();
+ protected array $allowed_mimes = array();
protected int $maxlenght;
protected int $mincropsize;
*
* @return void
*/
- public function exportMembers(MembersList $filters)
+ public function exportMembers(MembersList $filters): void
{
$export_fields = null;
if (file_exists(GALETTE_CONFIG_PATH . 'local_export_fields.inc.php')) {
*
* @return string
*/
- public function getPath()
+ public function getPath(): string
{
return $this->path;
}
*
* @return string
*/
- public function getFileName()
+ public function getFileName(): string
{
return $this->filename;
}
*
* @return bool
*/
- protected function cacheLoaded($contents): bool
+ protected function cacheLoaded(mixed $contents): bool
{
if (Galette::isSerialized($contents)) {
//legacy cache format
*
* @return void
*/
- public function exportScheduledPayments(ScheduledPaymentsList $filters)
+ public function exportScheduledPayments(ScheduledPaymentsList $filters): void
{
$scheduled = new ScheduledPayment($this->zdb);
$fields = $scheduled->getFields();
*
* @return string
*/
- public function getPath()
+ public function getPath(): string
{
return $this->path;
}
*
* @return string
*/
- public function getFileName()
+ public function getFileName(): string
{
return $this->filename;
}
*/
class Authenticate
{
- /**
- * @var Messages
- */
protected Messages $flash;
/**
*/
protected array $acls;
- /**
- * @var Login
- */
private Login $login;
- /**
- * @var Session
- */
private Session $session;
- /**
- * @var RouteParser
- */
private RouteParser $routeparser;
/**
*/
class PublicPages
{
- /**
- * @var Messages
- */
protected Messages $flash;
- /**
- * @var Login
- */
private Login $login;
- /**
- * @var RouteParser
- */
private RouteParser $routeparser;
- /**
- * @var Preferences
- */
private Preferences $preferences;
/**
*/
protected $callback;
- /**
- * @var I18n
- */
protected I18n $i18n;
- /**
- * @var RouteParser
- */
protected RouteParser $routeParser;
/**
*/
class Groups
{
- /** @var Db */
private Db $zdb;
- /** @var Login */
private Login $login;
/**
*
* @return boolean
*/
- public static function isUnique(Db $zdb, string $name, ?int $parent = null, ?int $current = null)
+ public static function isUnique(Db $zdb, string $name, ?int $parent = null, ?int $current = null): bool
{
try {
$select = $zdb->select(Group::TABLE);
?array $fields = null,
bool $count = true,
bool $limit = true
- ) {
+ ): array|ResultSet {
return $this->getMembersList(
$as_members,
$fields,
?array $fields = null,
bool $count = true,
bool $limit = true
- ) {
+ ): array|ResultSet {
return $this->getMembersList(
$as_members,
$fields,
bool $managed = false,
bool $limit = true,
bool $export = false
- ) {
+ ): array|ResultSet {
global $zdb;
if ($limit === true) {
*
* @return Adherent[]|ResultSet
*/
- public function getList(bool $as_members = false, ?array $fields = null)
+ public function getList(bool $as_members = false, ?array $fields = null): array|ResultSet
{
return $this->getMembersList(
$as_members,
*
* @return array<string, Adherent[]>
*/
- public function getPublicList(bool $with_photos)
+ public function getPublicList(bool $with_photos): array
{
global $zdb;
bool $export = false,
bool $dues = false,
bool $parent = false
- ) {
+ ): array|false {
global $zdb;
if (!is_array($ids) || count($ids) < 1) {
use Galette\Core\Preferences;
use Galette\Core\Login;
use Laminas\Db\ResultSet\ResultSet;
-use stdClass;
/**
* Repositories
/**
* Get entity instance
*
- * @return stdClass
+ * @return object
*/
- public function getEntity()
+ public function getEntity(): object
{
$name = $this->entity;
return new $name(
/**
* Get list
*
- * @return array<int, stdClass>|ResultSet
+ * @return array<int, object>|ResultSet
*/
abstract public function getList(): array|ResultSet;
class CsrfExtension extends AbstractExtension implements GlobalsInterface
{
- /**
- * @var Guard
- */
protected Guard $csrf;
/**
*
* @return bool
*/
- protected function cacheLoaded($content): bool
+ protected function cacheLoaded(mixed $content): bool
{
if ($content === null) {
return false;
*
* @return void
*/
- public function testStoreModels()
+ public function testStoreModels(): void
{
$model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
$this->assertSame('_T("Invoice") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}', $model->title);
*
* @return void
*/
- public function testMembersCards()
+ public function testMembersCards(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testFilteredMembersCards()
+ public function testFilteredMembersCards(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testMembersLabels()
+ public function testMembersLabels(): void
{
unset($this->session->filter_members);
$this->getMemberOne();
*
* @return void
*/
- public function testFilteredMembersLabels()
+ public function testFilteredMembersLabels(): void
{
unset($this->session->filter_members);
$this->getMemberOne();
*
* @return void
*/
- public function testadhesionForm()
+ public function testadhesionForm(): void
{
unset($this->session->filter_members);
$this->getMemberOne();
*
* @return void
*/
- public function testAttendanceSheet()
+ public function testAttendanceSheet(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testContribution()
+ public function testContribution(): void
{
$this->getMemberOne();
$this->createContribution();
*
* @return void
*/
- public function testAllOK()
+ public function testAllOK(): void
{
$checks = new \Galette\Core\CheckModules();
$this->assertTrue($checks->isValid());
*
* @return void
*/
- public function testAllKO()
+ public function testAllKO(): void
{
$checks = $this->getMockBuilder(\Galette\Core\CheckModules::class)
->setConstructorArgs([false])
*
* @return void
*/
- public function testToHtml()
+ public function testToHtml(): void
{
$checks = new \Galette\Core\CheckModules();
$checks->doCheck();
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$db = new \Galette\Core\Db();
$type = $db->type_db;
*
* @return void
*/
- public function testConnectivity()
+ public function testConnectivity(): void
{
$res = $this->db->testConnectivity(
TYPE_DB,
*
* @return void
*/
- public function testGrant()
+ public function testGrant(): void
{
$result = $this->db->dropTestTable();
*
* @return void
*/
- public function testGrantWException()
+ public function testGrantWException(): void
{
$atoum = $this;
$this->db->method('execute')
->will(
$this->returnCallback(
- function ($o) {
+ function ($o): void {
if ($o instanceof \Laminas\Db\Sql\Insert) {
throw new \LogicException('Error executing query!', 123);
}
*
* @return void
*/
- public function testIsPostgres()
+ public function testIsPostgres(): void
{
$is_pg = $this->db->isPostgres();
*
* @return void
*/
- public function testGetters()
+ public function testGetters(): void
{
switch (TYPE_DB) {
case 'pgsql':
*
* @return void
*/
- public function testSelect()
+ public function testSelect(): void
{
$select = $this->db->select('preferences', 'p');
$select->where(array('p.nom_pref' => 'pref_nom'));
*
* @return void
*/
- public function testSelectAll()
+ public function testSelectAll(): void
{
$all = $this->db->selectAll('preferences');
$this->assertInstanceOf('Laminas\Db\ResultSet\ResultSet', $all);
*
* @return void
*/
- public function testInsert()
+ public function testInsert(): void
{
$insert = $this->db->insert('titles');
$data = [
*
* @return void
*/
- public function testUpdate()
+ public function testUpdate(): void
{
$insert = $this->db->insert('titles');
$data = [
*
* @return void
*/
- public function testDelete()
+ public function testDelete(): void
{
$insert = $this->db->insert('titles');
$data = [
*
* @return void
*/
- public function testDbVersion()
+ public function testDbVersion(): void
{
$db_version = $this->db->getDbVersion();
$this->assertSame(GALETTE_DB_VERSION, $db_version);
*
* @return void
*/
- public function testDbVersionWException()
+ public function testDbVersionWException(): void
{
$this->db = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$this->db->method('execute')
->will(
$this->returnCallback(
- function ($table, $where) {
+ function ($table, $where): void {
throw new \LogicException('Error executing query!', 123);
}
)
*
* @return void
*/
- public function testGetColumns()
+ public function testGetColumns(): void
{
$cols = $this->db->getColumns('preferences');
*
* @return void
*/
- public function testTables()
+ public function testTables(): void
{
$expected = array (
'galette_groups_members',
*
* @return void
*/
- public function testConvertToUtf()
+ public function testConvertToUtf(): void
{
$convert = $this->db->convertToUTF();
$this->assertNull($convert);
*
* @return void
*/
- public function testGetPlatform()
+ public function testGetPlatform(): void
{
$quoted = $this->db->platform->quoteValue('somethin\' to "quote"');
*
* @return void
*/
- public function testExecute()
+ public function testExecute(): void
{
$select = $this->db->select('preferences', 'p');
$select->where(['p.nom_pref' => 'azerty']);
*
* @return void
*/
- public function testExecuteWException()
+ public function testExecuteWException(): void
{
$this->have_warnings = [
new \ArrayObject(
*
* @return void
*/
- public function testSerialization()
+ public function testSerialization(): void
{
$db = $this->db;
$serialized = serialize($db);
*
* @return void
*/
- public function testGitVersion()
+ public function testGitVersion(): void
{
$gitversion = \Galette\Core\Galette::gitVersion();
$this->assertStringStartsWith(str_replace('-dev', '', GALETTE_VERSION), $gitversion);
*
* @return void
*/
- public function testSerialization()
+ public function testSerialization(): void
{
//global objects
$login = new \Galette\Core\Login($this->zdb, $this->i18n);
*
* @return void
*/
- public function testGetMenus()
+ public function testGetMenus(): void
{
global $preferences, $login, $plugins;
$db = new \Galette\Core\Db();
*
* @return void
*/
- public function testGetPublicMenus()
+ public function testGetPublicMenus(): void
{
global $preferences;
*
* @return void
*/
- public function testGetDashboards()
+ public function testGetDashboards(): void
{
global $login;
*
* @return void
*/
- public function testGetListActions()
+ public function testGetListActions(): void
{
global $login;
*
* @return void
*/
- public function testGetDetailledActions()
+ public function testGetDetailledActions(): void
{
$member = $this->getMemberOne();
*
* @return void
*/
- public function testGetBatchActions()
+ public function testGetBatchActions(): void
{
global $login;
*
* @return void
*/
- public function testConstants()
+ public function testConstants(): void
{
$this->assertSame('logs', \Galette\Core\History::TABLE);
$this->assertSame('id_log', \Galette\Core\History::PK);
*
* @return void
*/
- public function testHistoryFlow()
+ public function testHistoryFlow(): void
{
$this->i18n->changeLanguage('en_US');
//nothing in the logs at the beginning
*
* @return void
*/
- public function testAutoLang()
+ public function testAutoLang(): void
{
$this->i18n = new \Galette\Core\I18n();
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$list = $this->i18n->getList();
*
* @return void
*/
- public function testGetArrayList()
+ public function testGetArrayList(): void
{
$list = $this->i18n->getArrayList();
*
* @return void
*/
- public function testGetNameFromid()
+ public function testGetNameFromid(): void
{
$lang = $this->i18n->getNameFromId('en_US');
$this->assertSame('English', $lang);
*
* @return void
*/
- public function testGetLangInfos()
+ public function testGetLangInfos(): void
{
$id = $this->i18n->getID();
$longid = $this->i18n->getLongID();
*
* @return void
*/
- public function testChangeUnknownLanguage()
+ public function testChangeUnknownLanguage(): void
{
$this->i18n->changeLanguage('un_KN');
$id = $this->i18n->getID();
*
* @return void
*/
- public function testSeemUtf8()
+ public function testSeemUtf8(): void
{
$is_utf = $this->i18n->seemUtf8('HéhéHÉHÉâ-ô߬- ©»«<ëßßä€êþÿûîœô');
$is_iso = $this->i18n->seemUtf8(mb_convert_encoding('Héhé', 'ISO-8859-1'));
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$install = new \Galette\Core\Install();
*
* @return void
*/
- public function testGetUpgradeScripts()
+ public function testGetUpgradeScripts(): void
{
$update_scripts = \Galette\Core\Install::getUpdateScripts(
GALETTE_BASE_PATH . '/install',
*
* @return void
*/
- public function testTypeStep()
+ public function testTypeStep(): void
{
$this->install->atTypeStep();
*
* @return void
*/
- public function testInstallDbStep()
+ public function testInstallDbStep(): void
{
$this->install->setMode(\Galette\Core\Install::INSTALL);
$this->install->atDbStep();
*
* @return void
*/
- public function testUpgradeDbStep()
+ public function testUpgradeDbStep(): void
{
$this->install->setMode(\Galette\Core\Install::UPDATE);
$this->install->atDbStep();
*
* @return void
*/
- public function testUnknownMode()
+ public function testUnknownMode(): void
{
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessage('Unknown mode "nonsense"');
*
* @return void
*/
- public function testSetDbType()
+ public function testSetDbType(): void
{
$types = array(
\Galette\Core\Db::MYSQL,
*
* @return void
*/
- public function testDbCheckStep()
+ public function testDbCheckStep(): void
{
$errors = array();
$this->install->setDbType(TYPE_DB, $errors);
*
* @return void
*/
- public function testDbInstallStep()
+ public function testDbInstallStep(): void
{
$errors = array();
$this->install->setDbType(TYPE_DB, $errors);
*
* @return void
*/
- public function testAdminStep()
+ public function testAdminStep(): void
{
$this->install->atAdminStep();
*
* @return void
*/
- public function testInitStep()
+ public function testInitStep(): void
{
$this->install->atGaletteInitStep();
*
* @return void
*/
- public function testAddDynamicTranslation()
+ public function testAddDynamicTranslation(): void
{
$this->i18n->changeLanguage('en_US');
*
* @return void
*/
- public function testGenerateNewLink()
+ public function testGenerateNewLink(): void
{
$links = $this->links;
$this->getMemberTwo();
*
* @return void
*/
- public function testExpiredValidate()
+ public function testExpiredValidate(): void
{
$links = $this->links;
$this->getMemberTwo();
*
* @return void
*/
- public function testCleanExpired()
+ public function testCleanExpired(): void
{
$date = new \DateTime();
$date->sub(new \DateInterval('PT48H'));
*
* @return void
*/
- public function testDuplicateLinkTarget()
+ public function testDuplicateLinkTarget(): void
{
$date = new \DateTime();
$date->sub(new \DateInterval('PT48H'));
*
* @return void
*/
- protected function createContribution()
+ protected function createContribution(): void
{
$now = new \DateTime(); // 2020-11-07
$begin_date = clone $now;
/**
* Check contributions expecteds
*
- * @param Contribution $contrib Contribution instance, if any
- * @param array $new_expecteds Changes on expected values
+ * @param ?\Galette\Entity\Contribution $contrib Contribution instance, if any
+ * @param array<string,mixed> $new_expecteds Changes on expected values
*
* @return void
*/
- protected function checkContribExpected($contrib = null, $new_expecteds = [])
+ protected function checkContribExpected(\Galette\Entity\Contribution $contrib = null, array $new_expecteds = []): void
{
if ($contrib === null) {
$contrib = $this->contrib;
*
* @return void
*/
- public function testDefaults()
+ public function testDefaults(): void
{
$this->assertFalse($this->login->isLogged());
$this->assertFalse($this->login->isStaff());
*
* @return void
*/
- public function testNotLoggedCantImpersonate()
+ public function testNotLoggedCantImpersonate(): void
{
$login = $this->getMockBuilder(\Galette\Core\Login::class)
->setConstructorArgs(array($this->zdb, $this->i18n))
*
* @return void
*/
- public function testStaffCantImpersonate()
+ public function testStaffCantImpersonate(): void
{
$login = $this->getMockBuilder(\Galette\Core\Login::class)
->setConstructorArgs(array($this->zdb, $this->i18n))
*
* @return void
*/
- public function testAdminCantImpersonate()
+ public function testAdminCantImpersonate(): void
{
$login = $this->getMockBuilder(\Galette\Core\Login::class)
->setConstructorArgs(array($this->zdb, $this->i18n))
*
* @return void
*/
- public function testImpersonateExistsWException()
+ public function testImpersonateExistsWException(): void
{
$zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$zdb->method('execute')
->willReturnCallback(
- function ($o) {
+ function ($o): void {
throw new \LogicException('Error executing query!', 123);
}
);
*
* @return void
*/
- public function testSuperadminCanImpersonate()
+ public function testSuperadminCanImpersonate(): void
{
$login = $this->getMockBuilder(\Galette\Core\Login::class)
->setConstructorArgs(array($this->zdb, $this->i18n))
*
* @return void
*/
- public function testInexistingGetter()
+ public function testInexistingGetter(): void
{
$this->expectException('RuntimeException');
$this->expectExceptionMessage('Property doesnotexists is not set!');
*
* @return void
*/
- public function testLoginExists()
+ public function testLoginExists(): void
{
$this->assertFalse($this->login->loginExists('exists'));
$this->assertFalse($this->login->loginExists('doesnotexists'));
*
* @return void
*/
- public function testLoginExistsWException()
+ public function testLoginExistsWException(): void
{
$zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$zdb->method('execute')
->willReturnCallback(
- function ($o) {
+ function ($o): void {
if ($o instanceof \Laminas\Db\Sql\Select) {
throw new \LogicException('Error executing query!', 123);
}
*
* @return void
*/
- public function testLogAdmin()
+ public function testLogAdmin(): void
{
$this->login->logAdmin('superadmin', $this->preferences);
$this->assertTrue($this->login->isLogged());
*
* @return void
*/
- private function createUser()
+ private function createUser(): void
{
$select = $this->zdb->select(\Galette\Entity\Adherent::TABLE, 'a');
$select->where(array('a.fingerprint' => 'FAKER' . $this->seed));
*
* @return void
*/
- public function testLoginExistsDb()
+ public function testLoginExistsDb(): void
{
$this->createUser();
$this->assertTrue($this->login->loginExists('dumas.roger'));
*
* @return void
*/
- public function testLogin()
+ public function testLogin(): void
{
$this->createUser();
$this->assertFalse($this->login->login('doenotexists', 'empty'));
*
* @return void
*/
- public function testLoggedInAs()
+ public function testLoggedInAs(): void
{
global $translator;
*
* @return void
*/
- public function testLogCron()
+ public function testLogCron(): void
{
$this->login->logCron('reminder', $this->preferences);
$this->assertTrue($this->login->isLogged());
*
* @return void
*/
- public function testDefaults()
+ public function testDefaults(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- public function testHistoryFlow()
+ public function testHistoryFlow(): void
{
$this->logSuperAdmin();
$mh = new \Galette\Core\MailingHistory(
*
* @return void
*/
- public function testRandom()
+ public function testRandom(): void
{
$results = array();
*
* @return int
*/
- private function createMember()
+ private function createMember(): int
{
try {
$this->deleteMember();
*
* @return void
*/
- private function deleteMember()
+ private function deleteMember(): void
{
$delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE);
$delete->where(['login_adh' => 'test_password_user']);
*
* @return void
*/
- public function testGenerateNewPassword()
+ public function testGenerateNewPassword(): void
{
$id_adh = $this->createMember();
$pass = $this->pass;
*
* @return void
*/
- public function testCleanExpired()
+ public function testCleanExpired(): void
{
$id_adh = $this->createMember();
*
* @return void
*/
- public function testGenerateNewPasswordWException()
+ public function testGenerateNewPasswordWException(): void
{
$this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$this->zdb->method('execute')
->will(
$this->returnCallback(
- function ($o) {
+ function ($o): void {
throw new \LogicException('Error executing query!', 123);
}
)
*
* @return void
*/
- public function testGenerateNewPasswordWFalseInsert()
+ public function testGenerateNewPasswordWFalseInsert(): void
{
$this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$this->zdb->method('execute')
->will(
$this->returnCallback(
- function ($o) {
+ function ($o): void {
throw new \LogicException('Error executing query!', 123);
}
)
*
* @return void
*/
- public function testCleanExpiredWException()
+ public function testCleanExpiredWException(): void
{
$this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$this->zdb->method('execute')
->will(
$this->returnCallback(
- function ($o) {
+ function ($o): void {
throw new \LogicException('Error executing query!', 123);
}
)
*
* @return void
*/
- public function testIsHashValidWException()
+ public function testIsHashValidWException(): void
{
$this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$this->zdb->method('execute')
->will(
$this->returnCallback(
- function ($o) {
+ function ($o): void {
throw new \LogicException('Error executing query!', 123);
}
)
*
* @return void
*/
- public function testRemoveHashWException()
+ public function testRemoveHashWException(): void
{
$this->zdb = $this->getMockBuilder(\Galette\Core\Db::class)
->onlyMethods(array('execute'))
$this->zdb->method('execute')
->will(
$this->returnCallback(
- function ($o) {
+ function ($o): void {
throw new \LogicException('Error executing query!', 123);
}
)
*
* @return void
*/
- public function testDefaults()
+ public function testDefaults(): void
{
$picture = new \Galette\Core\Picture();
$this->assertNull($picture->getDestDir());
*
* @return void
*/
- public function testSetters()
+ public function testSetters(): void
{
$this->assertNull($this->picture->getDestDir());
$this->assertNull($this->picture->getFileName());
*
* @return void
*/
- public function testFileInfoMimeType()
+ public function testFileInfoMimeType(): void
{
$url = realpath(GALETTE_ROOT . '../tests/fake_image.jpg');
$this->assertNotFalse($url);
*
* @return void
*/
- public function testStore()
+ public function testStore(): void
{
foreach ($this->expected_badchars as $badchar) {
$expected = \Galette\Core\Picture::INVALID_FILENAME;
*
* @return void
*/
- public function testErrorMessages()
+ public function testErrorMessages(): void
{
$this->assertSame(
'File name is invalid, it should not contain any special character or space.',
);
/**
- * Get instanciated plugins instance
+ * Get instantiated plugins instance
*
- * @return Galette\Core\Plugins
+ * @return \Galette\Core\Plugins
*/
- private function getPlugins()
+ private function getPlugins(): \Galette\Core\Plugins
{
$plugins = new \Galette\Core\Plugins();
$plugins->autoload(GALETTE_PLUGINS_PATH);
*
* @return void
*/
- public function testLoadModules()
+ public function testLoadModules(): void
{
$plugins = $this->getPlugins();
$this->assertCount(3, $this->plugins->getModules());
*
* @return void
*/
- public function testModuleExists()
+ public function testModuleExists(): void
{
$this->assertTrue($this->plugins->moduleExists('plugin-test2'));
$this->assertFalse($this->plugins->moduleExists('plugin-disabled'));
*
* @return void
*/
- public function testDisabledModules()
+ public function testDisabledModules(): void
{
$disabled_modules = $this->plugins->getDisabledModules();
$this->assertTrue(isset($disabled_modules['plugin-disabled']));
*
* @return void
*/
- public function testModuleRoot()
+ public function testModuleRoot(): void
{
$this->assertSame($this->plugin2['root'], $this->plugins->moduleRoot('plugin-test2'));
}
*
* @return void
*/
- public function testResetModulesList()
+ public function testResetModulesList(): void
{
$this->plugins->resetModulesList();
*
* @return void
*/
- public function testModuleActivation()
+ public function testModuleActivation(): void
{
$plugins = $this->getPlugins();
$modules = $plugins->getModules();
*
* @return void
*/
- public function testNeedDatabse()
+ public function testNeedDatabse(): void
{
$this->assertTrue($this->plugins->needsDatabase('plugin-db'));
$this->assertFalse($this->plugins->needsDatabase('plugin-test2'));
*
* @return void
*/
- public function testInstallInit()
+ public function testInstallInit(): void
{
$result = $this->preferences->installInit(
'en_US',
*
* @return void
*/
- public function testFieldsNames()
+ public function testFieldsNames(): void
{
$this->preferences->load();
$fields_names = $this->preferences->getFieldsNames();
*
* @return void
*/
- public function testUpdate()
+ public function testUpdate(): void
{
$delete = $this->zdb->delete(\Galette\Core\Preferences::TABLE);
$delete->where(
*
* @return void
*/
- public function testPublicPagesVisibility()
+ public function testPublicPagesVisibility(): void
{
$this->preferences->load();
*
* @return array
*/
- public static function sizesProvider()
+ public static function sizesProvider(): array
{
return [
[//defaults
*
* @return void
*/
- public function testCheckCardsSizes($vm, $hm, $vs, $hs, $count)
+ public function testCheckCardsSizes(int $vm, int $hm, int $vs, int $hs, int $count): void
{
$this->preferences->pref_card_marges_v = $vm;
$this->preferences->pref_card_marges_h = $hm;
*
* @return void
*/
- public function testColors($prop, $color, $expected)
+ public function testColors(string $prop, string $color, string $expected): void
{
$prop = 'pref_card_' . $prop;
$this->preferences->$prop = $color;
*
* @return void
*/
- public function testSocials()
+ public function testSocials(): void
{
$preferences = [];
foreach ($this->preferences->getDefaults() as $key => $value) {
*
* @return void
*/
- public function testGetMailSignature()
+ public function testGetMailSignature(): void
{
$mail = new PHPMailer();
$this->assertSame("\r\n-- \r\nGalette", $this->preferences->getMailSignature($mail));
*
* @return void
*/
- public function testGetLegend()
+ public function testGetLegend(): void
{
$legend = $this->preferences->getLegend();
$this->assertCount(2, $legend);
*
* @return void
*/
- public function testDefaults()
+ public function testDefaults(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\Boolean($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('boolean'), $this->bool->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->bool->isMultiValued();
$this->assertFalse($muliple);
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\Choice($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('choice'), $this->choice->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->choice->isMultiValued();
$this->assertFalse($muliple);
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\Date($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('date'), $this->date->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->date->isMultiValued();
$this->assertFalse($muliple);
*
* @return void
*/
- public function testLoadFieldType()
+ public function testLoadFieldType(): void
{
$this->assertFalse(\Galette\DynamicFields\DynamicField::loadFieldType($this->zdb, 10));
*
* @return void
*/
- public function testGetPermissionsList()
+ public function testGetPermissionsList(): void
{
$expected = [];
foreach (self::permsProvider() as $perm) {
*
* @return void
*/
- public function testGetPermissionName(int $perm, string $name)
+ public function testGetPermissionName(int $perm, string $name): void
{
$field_data = [
'form_name' => 'adh',
*
* @return void
*/
- public function testGetFormsNames()
+ public function testGetFormsNames(): void
{
$expected = [];
foreach ($this->formNamesProvider() as $form) {
*
* @return void
*/
- public function testGetFormTitle(string $form, string $expected)
+ public function testGetFormTitle(string $form, string $expected): void
{
$this->assertSame($expected, \Galette\DynamicFields\DynamicField::getFormTitle($form));
}
*
* @return void
*/
- public function testGetFixedValuesTableName()
+ public function testGetFixedValuesTableName(): void
{
$this->assertSame('field_contents_10', \Galette\DynamicFields\DynamicField::getFixedValuesTableName(10));
$this->assertSame('field_contents_10', \Galette\DynamicFields\DynamicField::getFixedValuesTableName(10, false));
*
* @return void
*/
- public function testGetValues()
+ public function testGetValues(): void
{
$field_data = [
'form_name' => 'adh',
*
* @return void
*/
- public function testCheck()
+ public function testCheck(): void
{
$values = [
'form_name' => 'adh',
*
* @return void
*/
- public function testMove()
+ public function testMove(): void
{
$field_data = [
'form_name' => 'adh',
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
$field_data = [
'form_name' => 'adh',
*
* @return void
*/
- public function testInformation()
+ public function testInformation(): void
{
$field_data = [
'form_name' => 'adh',
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\File($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('file'), $this->file->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->file->isMultiValued();
$this->assertFalse($muliple);
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\Line($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('single line'), $this->line->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->line->isMultiValued();
$this->assertTrue($muliple);
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\Separator($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('separator'), $this->separator->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->separator->isMultiValued();
$this->assertFalse($muliple);
*
* @return void
*/
- public function testConstructor()
+ public function testConstructor(): void
{
$o = new \Galette\DynamicFields\Text($this->zdb, 10);
$this->assertNull($o->getId());
*
* @return void
*/
- public function testGetTypeName()
+ public function testGetTypeName(): void
{
$this->assertSame(_T('free text'), $this->text->getTypeName());
}
*
* @return void
*/
- public function testBaseProperties()
+ public function testBaseProperties(): void
{
$muliple = $this->text->isMultiValued();
$this->assertFalse($muliple);
*
* @return void
*/
- public function testEmpty()
+ public function testEmpty(): void
{
$adh = $this->adh;
$this->assertFalse($adh->isAdmin());
*
* @return void
*/
- public function testDependencies()
+ public function testDependencies(): void
{
$adh = $this->adh;
$this->assertSame($this->default_deps, $adh->deps);
*
* @return void
*/
- public function testGetterWException()
+ public function testGetterWException(): void
{
$adh = $this->adh;
*
* @return void
*/
- public function testDepsAtConstuct()
+ public function testDepsAtConstuct(): void
{
$deps = [
'picture' => false,
*
* @return void
*/
- public function testSimpleMember()
+ public function testSimpleMember(): void
{
$this->getMemberOne();
$this->checkMemberOneExpected();
*
* @return void
*/
- public function testLoadForLogin()
+ public function testLoadForLogin(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testUpdatePassword()
+ public function testUpdatePassword(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testCheckErrors()
+ public function testCheckErrors(): void
{
$adh = $this->adh;
*
* @return void
*/
- public function testPhoto()
+ public function testPhoto(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testCanEdit()
+ public function testCanEdit(): void
{
$adh = new \Galette\Entity\Adherent($this->zdb);
*
* @return void
*/
- public function testDuplicate()
+ public function testDuplicate(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testParents()
+ public function testParents(): void
{
$this->getMemberOne();
*
* @return void
*/
- public function testInjection()
+ public function testInjection(): void
{
$data = [
'nom_adh' => 'Doe',
*
* @return void
*/
- public function testCan()
+ public function testCan(): void
{
$this->getMemberOne();
//load member from db
* @param string $name Name
* @param string $surname Surname
* @param \Galette\Entity\Title|false $title Title
- * @param string|false $id ID
+ * @param int|false $id ID
* @param string|false $nick Nick
- * @param string $expected Expected result
+ * @param string $expected Expected result
*
* @return void
*/
- public function testsGetNameWithCase(string $name, string $surname, $title, $id, $nick, string $expected)
- {
+ public function testsGetNameWithCase(
+ string $name,
+ string $surname,
+ \Galette\Entity\Title|false $title,
+ int|false $id,
+ string|false $nick,
+ string $expected
+ ): void {
$this->assertSame(
$expected,
\Galette\Entity\Adherent::getNameWithCase(
*
* @return void
*/
- public function testGetDueStatus()
+ public function testGetDueStatus(): void
{
$now = new \DateTime();
$member = new \Galette\Entity\Adherent($this->zdb);
*
* @return void
*/
- public function testEmpty()
+ public function testEmpty(): void
{
$contrib = $this->contrib;
$this->assertNull($contrib->id);
*
* @return void
*/
- public function testGetterSetter()
+ public function testGetterSetter(): void
{
$contrib = $this->contrib;
*
* @return void
*/
- public function testCreation()
+ public function testCreation(): void
{
$this->getMemberOne();
//create contribution for member
*
* @return void
*/
- public function testDonationUpdate()
+ public function testDonationUpdate(): void
{
$this->getMemberOne();
//create contribution for member
*
* @return void
*/
- public function testContributionUpdate()
+ public function testContributionUpdate(): void
{
$this->logSuperAdmin();
*
* @return void
*/
- public function testRetrieveEndDate()
+ public function testRetrieveEndDate(): void
{
global $preferences;
$orig_pref_beg_membership = $this->preferences->pref_beg_membership;
*
* @return void
*/
- public function testCheckOverlap()
+ public function testCheckOverlap(): void
{
$adh = new \Galette\Entity\Adherent($this->zdb);
$adh->setDependencies(
*
* @return void
*/
- public function testGetFieldLabel()
+ public function testGetFieldLabel(): void
{
$this->assertSame(
'Amount',
*
* @return void
*/
- public function testLoad()
+ public function testLoad(): void
{
$this->login = $this->getMockBuilder(\Galette\Core\Login::class)
->setConstructorArgs(array($this->zdb, $this->i18n))
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
$this->getMemberOne();
$this->createContribution();
*
* @return void
*/
- public function testCan()
+ public function testCan(): void
{
$this->getMemberOne();
//create contribution for member
*
* @return void
*/
- public function testNextYear()
+ public function testNextYear(): void
{
$this->logSuperAdmin();
$this->getMemberOne();
*
* @return void
*/
- public function testNextYearFrom096()
+ public function testNextYearFrom096(): void
{
$this->logSuperAdmin();
$this->getMemberOne();
*
* @return void
*/
- private function deleteTypes()
+ private function deleteTypes(): void
{
if (is_array($this->remove) && count($this->remove) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\ContributionsTypes::TABLE);
*
* @return void
*/
- public function testContributionsTypes()
+ public function testContributionsTypes(): void
{
global $i18n; // globals :(
$i18n = $this->i18n;
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$ctypes = new \Galette\Entity\ContributionsTypes($this->zdb);
*
* @return void
*/
- public function testNonRequired()
+ public function testNonRequired(): void
{
$nrequired = $this->fields_config->getNonRequired();
$expected = [
*
* @return void
*/
- public function testInstallInit()
+ public function testInstallInit(): void
{
$result = $this->fields_config->installInit();
$this->assertTrue($result);
*
* @return void
*/
- private function countCategorizedFields($categorized)
+ private function countCategorizedFields(array $categorized): void
{
$this->assertCount(3, $categorized);
$this->assertCount(13, $categorized[\Galette\Entity\FieldsCategories::ADH_CATEGORY_IDENTITY]);
*
* @return void
*/
- public function testSetNotRequired()
+ public function testSetNotRequired(): void
{
$fields_config = $this->fields_config;
$fields_config->load();
*
* @return void
*/
- public function testGetVisibility()
+ public function testGetVisibility(): void
{
$this->fields_config->load();
*
* @return void
*/
- public function testSetFields()
+ public function testSetFields(): void
{
$fields_config = $this->fields_config;
$fields_config->installInit();
*
* @return void
*/
- public function testIsSelfExcluded()
+ public function testIsSelfExcluded(): void
{
$this->assertTrue($this->fields_config->isSelfExcluded('bool_admin_adh'));
$this->assertTrue($this->fields_config->isSelfExcluded('info_adh'));
*
* @return void
*/
- public function testCheckUpdate()
+ public function testCheckUpdate(): void
{
$fields_config = $this->fields_config;
$fields_config->load();
*
* @return void
*/
- public function testCheckUpdateWhenEmpty()
+ public function testCheckUpdateWhenEmpty(): void
{
$this->zdb->db->query(
'TRUNCATE ' . PREFIX_DB . \Galette\Entity\FieldsConfig::TABLE,
*
* @return void
*/
- public function testGetDisplayElements()
+ public function testGetDisplayElements(): void
{
$fields_config = $this->fields_config;
$fields_config->load();
*
* @return void
*/
- public function testGetFormElements()
+ public function testGetFormElements(): void
{
$fields_config = $this->fields_config;
$fields_config->load();
*
* @return void
*/
- private function deleteGroups()
+ private function deleteGroups(): void
{
$delete = $this->zdb->delete(\Galette\Entity\Group::TABLE);
$delete->where('parent_group IS NOT NULL');
*
* @return void
*/
- public function testGroup()
+ public function testGroup(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- public function testSingleGroup()
+ public function testSingleGroup(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- public function testUnicity()
+ public function testUnicity(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- public function testSubGroup()
+ public function testSubGroup(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
global $zdb;
$zdb = $this->zdb;
*
* @return void
*/
- private function resetListsConfig()
+ private function resetListsConfig(): void
{
$new_list = [];
foreach ($this->default_lists as $key) {
*
* @return void
*/
- public function testGetVisibility()
+ public function testGetVisibility(): void
{
$this->lists_config->load();
*
* @return void
*/
- public function testSetFields()
+ public function testSetFields(): void
{
$lists_config = $this->lists_config;
$lists_config->installInit();
*
* @return void
*/
- public function testGetDisplayElements()
+ public function testGetDisplayElements(): void
{
$lists_config = $this->lists_config;
$lists_config->load();
*
* @return void
*/
- private function deletePaymentType()
+ private function deletePaymentType(): void
{
if (is_array($this->remove) && count($this->remove) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\PaymentType::TABLE);
*
* @return void
*/
- public function testPaymentType()
+ public function testPaymentType(): void
{
global $i18n; // globals :(
$i18n = $this->i18n;
*
* @return void
*/
- public function testExpectedPatterns()
+ public function testExpectedPatterns(): void
{
$model = new class ($this->zdb, $this->preferences, 1) extends \Galette\Entity\PdfModel {
};
*
* @return void
*/
- public function testGetypeClass($type, $expected)
+ public function testGetypeClass(int $type, string $expected): void
{
$this->assertSame($expected, \Galette\Entity\PdfModel::getTypeClass($type));
}
*
* @return void
*/
- public function testReplacements()
+ public function testReplacements(): void
{
//create dynamic fields
$field_data = [
*
* @return void
*/
- protected function createPdfContribution($cdf)
+ protected function createPdfContribution(DynamicField $cdf): void
{
$bdate = new \DateTime(); // 2020-11-07
$bdate->sub(new \DateInterval('P5M')); // 2020-06-07
*
* @return void
*/
- public function testStorage()
+ public function testStorage(): void
{
$model = new \Galette\Entity\PdfInvoice($this->zdb, $this->preferences);
*
* @return void
*/
- private function deleteCreated()
+ private function deleteCreated(): void
{
$this->zdb->db->query(
'TRUNCATE TABLE ' . PREFIX_DB . \Galette\Entity\SavedSearch::TABLE,
*
* @return void
*/
- public function testSave()
+ public function testSave(): void
{
global $i18n, $translator; // globals :(
$i18n = $this->i18n;
*
* @return void
*/
- private function deleteScheduledPayments()
+ private function deleteScheduledPayments(): void
{
$delete = $this->zdb->delete(\Galette\Entity\ScheduledPayment::TABLE);
$delete->where(['comment' => 'FAKER' . $this->seed]);
*
* @return void
*/
- private function deleteSocials()
+ private function deleteSocials(): void
{
$delete = $this->zdb->delete(\Galette\Entity\Social::TABLE);
$this->zdb->execute($delete);
*
* @return void
*/
- public function testObject()
+ public function testObject(): void
{
$social = new \Galette\Entity\Social($this->zdb);
*
* @return void
*/
- public function testGetSystemTypes()
+ public function testGetSystemTypes(): void
{
$social = new \Galette\Entity\Social($this->zdb);
$this->assertCount(10, $social->getSystemTypes());
*
* @return void
*/
- private function deleteStatus()
+ private function deleteStatus(): void
{
if (is_array($this->remove) && count($this->remove) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\Status::TABLE);
*
* @return void
*/
- public function testStatus()
+ public function testStatus(): void
{
global $i18n; // globals :(
$i18n = $this->i18n;
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$status = new \Galette\Entity\Status($this->zdb);
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$count_texts = 13;
$texts = new \Galette\Entity\Texts(
*
* @return void
*/
- private function deleteTitle()
+ private function deleteTitle(): void
{
if (is_array($this->remove) && count($this->remove) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\Title::TABLE);
*
* @return void
*/
- public function testTitle()
+ public function testTitle(): void
{
global $zdb;
$zdb = $this->zdb;
class Transaction extends GaletteTestCase
{
protected int $seed = 95842354;
- /** @var \Galette\Entity\Transaction */
private \Galette\Entity\Transaction $transaction;
/**
/**
* Create test transaction in database
*
- * @return void
+ * @return \Galette\Entity\Transaction
*/
- private function createTransaction()
+ private function createTransaction(): \Galette\Entity\Transaction
{
$date = new \DateTime(); // 2020-11-07
$data = [
*
* @return void
*/
- public function testEmpty()
+ public function testEmpty(): void
{
$this->assertNull($this->transaction->id);
$this->assertEquals(date('Y-m-d'), $this->transaction->date);
*
* @return void
*/
- public function testGetterSetter()
+ public function testGetterSetter(): void
{
$transaction = $this->transaction;
*
* @return void
*/
- public function testCreation()
+ public function testCreation(): void
{
$this->getMemberOne();
//create transaction for member
*
* @return void
*/
- public function testUpdate()
+ public function testUpdate(): void
{
$this->getMemberOne();
//create transaction for member
*
* @return void
*/
- public function testGetFieldLabel()
+ public function testGetFieldLabel(): void
{
$this->assertSame(
'Amount',
*
* @return void
*/
- public function testLoad()
+ public function testLoad(): void
{
$this->login = $this->getMockBuilder(\Galette\Core\Login::class)
->setConstructorArgs(array($this->zdb, new \Galette\Core\I18n()))
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
$this->logSuperAdmin();
*
* @return void
*/
- public function testCan()
+ public function testCan(): void
{
$this->getMemberOne();
//create transaction for member
*
* @return void
*/
- public function testCreate()
+ public function testCreate(): void
{
$filters = new \Galette\Filters\ContributionsList();
*
* @return void
*/
- public function testCreate()
+ public function testCreate(): void
{
$filters = new \Galette\Filters\HistoryList();
*
* @return void
*/
- public function testCreate()
+ public function testCreate(): void
{
$filters = new \Galette\Filters\TransactionsList();
*/
private function doImportFileTest(
array $fields,
- $file_name,
+ string $file_name,
array $flash_messages,
array $members_list,
- $count_before = null,
- $count_after = null,
+ int $count_before = null,
+ int $count_after = null,
array $values = []
- ) {
+ ): void {
if ($count_before === null) {
$count_before = 0;
}
*
* @return void
*/
- public function testImport()
+ public function testImport(): void
{
$fields = ['nom_adh', 'ville_adh', 'bool_exempt_adh', 'fingerprint'];
$file_name = 'test-import-atoum.csv';
*
* @return \Galette\Entity\ImportModel
*/
- protected function getModel($fields): \Galette\Entity\ImportModel
+ protected function getModel(array $fields): \Galette\Entity\ImportModel
{
$model = new \Galette\Entity\ImportModel();
$this->assertTrue($model->remove($this->zdb));
*
* @return void
*/
- protected function checkDynamicTranslation($text_orig, $lang = 'fr_FR.utf8')
+ protected function checkDynamicTranslation(string $text_orig, string $lang = 'fr_FR.utf8'): void
{
$langs = array_keys($this->i18n->getArrayList());
$select = $this->zdb->select(\Galette\Core\L10n::TABLE);
*
* @return void
*/
- public function testImportDynamics()
+ public function testImportDynamics(): void
{
$field_data = [
*
* @return array
*/
- private function getMemberData1()
+ private function getMemberData1(): array
{
return array(
'FAKER_0' => array (
*
* @return array
*/
- private function getMemberData2()
+ private function getMemberData2(): array
{
return array (
'FAKER_0' => array (
*
* @return array
*/
- private function getMemberData2NoName()
+ private function getMemberData2NoName(): array
{
$data = $this->getMemberData2();
$data['FAKER_2']['nom_adh'] = '';
*
* @return void
*/
- public function testLoadNews()
+ public function testLoadNews(): void
{
//ensure allow_url_fopen is on
ini_set('allow_url_fopen', true);
*
* @return void
*/
- public function testCacheNews()
+ public function testCacheNews(): void
{
//will use default lang to build RSS URL
$file = GALETTE_CACHE_DIR . md5($this->local_url) . '.cache';
*
* @return void
*/
- public function testLoadNewsWExeption()
+ public function testLoadNewsWExeption(): void
{
$news = $this->getMockBuilder(\Galette\IO\News::class)
->setConstructorArgs(array($this->local_url, true))
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$this->logSuperAdmin();
$contributions = new \Galette\Repository\Contributions($this->zdb, $this->login);
*
* @return void
*/
- public function testGetArrayList()
+ public function testGetArrayList(): void
{
$this->logSuperAdmin();
$contributions = new \Galette\Repository\Contributions($this->zdb, $this->login);
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
$this->logSuperAdmin();
$contributions = new \Galette\Repository\Contributions($this->zdb, $this->login);
*
* @return void
*/
- private function deleteGroups()
+ private function deleteGroups(): void
{
$zdb = new \Galette\Core\Db();
*
* @return void
*/
- public function testCreateGroups(string $parent_name, array $children)
+ public function testCreateGroups(string $parent_name, array $children): void
{
$group = new \Galette\Entity\Group();
$group->setName($parent_name);
*
* @return void
*/
- public function testGetSimpleList()
+ public function testGetSimpleList(): void
{
$groups = self::groupsProvider();
foreach ($groups as $group) {
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$this->logSuperAdmin();
*
* @return void
*/
- public function testUniqueness()
+ public function testUniqueness(): void
{
$groups = self::groupsProvider();
foreach ($groups as $group) {
}
/**
- * Create members and get their id
+ * Create members and store their id
*
- * @return int[]
+ * @return void
*/
- private function createMembers()
+ private function createMembers(): void
{
global $zdb, $login, $hist, $i18n; // globals :(
$zdb = $this->zdb;
*
* @return void
*/
- private function deleteMembers()
+ private function deleteMembers(): void
{
if (is_array($this->mids) && count($this->mids) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE);
*
* @return void
*/
- private function deleteGroups()
+ private function deleteGroups(): void
{
//clean groups
$delete = $this->zdb->delete(\Galette\Entity\Group::GROUPSUSERS_TABLE);
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$members = new \Galette\Repository\Members();
*
* @return void
*/
- public function testGetListContributionDynamics()
+ public function testGetListContributionDynamics(): void
{
// Advanced search on contributions dynamic fields
*
* @return void
*/
- public function testGetPublicList()
+ public function testGetPublicList(): void
{
$members = new \Galette\Repository\Members();
*
* @return void
*/
- public function testGroupsSearch()
+ public function testGroupsSearch(): void
{
$members = new \Galette\Repository\Members();
$list = $members->getList(true);
*
* @return void
*/
- public function testGetRemindersCount()
+ public function testGetRemindersCount(): void
{
$members = new \Galette\Repository\Members();
$counts = $members->getRemindersCount();
*
* @return void
*/
- public function testGetDropdownMembers()
+ public function testGetDropdownMembers(): void
{
$members = new \Galette\Repository\Members();
$this->logSuperAdmin();
*
* @return void
*/
- public function testGetArrayList()
+ public function testGetArrayList(): void
{
$members = new \Galette\Repository\Members();
*
* @return void
*/
- private function deletePaymentType()
+ private function deletePaymentType(): void
{
if (is_array($this->remove) && count($this->remove) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\PaymentType::TABLE);
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$types = new \Galette\Repository\PaymentTypes($this->zdb, $this->preferences, $this->login);
*
* @return void
*/
- private function deletePdfModels()
+ private function deletePdfModels(): void
{
if (is_array($this->remove) && count($this->remove) > 0) {
$delete = $this->zdb->delete(\Galette\Entity\PdfModel::TABLE);
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
global $zdb;
$zdb = $this->zdb; //globals '(
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
//impendings
$ireminders = new \Galette\Repository\Reminders([\Galette\Entity\Reminder::IMPENDING]);
*
* @return void
*/
- private function deleteScheduledPayments()
+ private function deleteScheduledPayments(): void
{
$delete = $this->zdb->delete(\Galette\Entity\ScheduledPayment::TABLE);
$delete->where(['comment' => 'FAKER' . $this->seed]);
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$this->logSuperAdmin();
$scheduledPayments = new \Galette\Repository\ScheduledPayments($this->zdb, $this->login);
*
* @return void
*/
- public function testGetArrayList()
+ public function testGetArrayList(): void
{
$this->logSuperAdmin();
$scheduledPayments = new \Galette\Repository\ScheduledPayments($this->zdb, $this->login);
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
$this->logSuperAdmin();
$scheduledPayments = new \Galette\Repository\ScheduledPayments($this->zdb, $this->login);
class Transactions extends GaletteTestCase
{
protected int $seed = 20230328103438;
- /** @var \Galette\Entity\Transaction */
private \Galette\Entity\Transaction $transaction;
/**
*
* @return void
*/
- private function createTransaction()
+ private function createTransaction(): void
{
$date = new \DateTime();
$data = [
*
* @return void
*/
- public function testGetList()
+ public function testGetList(): void
{
$this->logSuperAdmin();
$transactions = new \Galette\Repository\Transactions($this->zdb, $this->login);
*
* @return void
*/
- public function testRemove()
+ public function testRemove(): void
{
$this->logSuperAdmin();
$transactions = new \Galette\Repository\Transactions($this->zdb, $this->login);
*
* @return array
*/
- public static function passProvider()
+ public static function passProvider(): array
{
return [
// [strength, password, errors]
* @return void
*/
#[DataProvider('passProvider')]
- public function testValidatePassword($level, $pass, $errors)
+ public function testValidatePassword(int $level, string $pass, array $errors): void
{
//errror messages mapping
foreach ($errors as &$err) {
*
* @return array
*/
- public static function blacklistProvider()
+ public static function blacklistProvider(): array
{
return [
['galette', true],
* @return void
*/
#[DataProvider('blacklistProvider')]
- public function testBlacklist($pass, $expected)
+ public function testBlacklist(string $pass, bool $expected): void
{
$this->preferences->pref_password_blacklist = true;
$password = new \Galette\Util\Password($this->preferences);
*
* @return void
*/
- public function testPersonalInformation()
+ public function testPersonalInformation(): void
{
$infos = [
'login' => 'mylogin',
*
* @return void
*/
- public function testGrabGaletteInfos()
+ public function testGrabGaletteInfos(): void
{
$expected = [
'uuid' => 'TO BE SET',
*
* @return void
*/
- public function testGrabDbInfos()
+ public function testGrabDbInfos(): void
{
$telemetry = new \Galette\Util\Telemetry(
$this->zdb,
*
* @return void
*/
- public function testGrabWebserverInfos()
+ public function testGrabWebserverInfos(): void
{
$telemetry = new \Galette\Util\Telemetry(
$this->zdb,
*
* @return void
*/
- public function testGrabPhpInfos()
+ public function testGrabPhpInfos(): void
{
$expected = [
'version' => str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION),
*
* @return void
*/
- public function testGrabOsInfos()
+ public function testGrabOsInfos(): void
{
$distro = '';
if (file_exists('/etc/redhat-release')) {
*
* @return void
*/
- public function testGetTelemetryInfos()
+ public function testGetTelemetryInfos(): void
{
$telemetry = new \Galette\Util\Telemetry(
$this->zdb,
class Install extends TestCase
{
private \Galette\Core\Db $zdb;
+ /** @var array<string> */
private array $flash_data;
private \Slim\Flash\Messages $flash;
private \DI\Container $container;
*
* @return void
*/
- public function testDbSupport()
+ public function testDbSupport(): void
{
$this->assertFalse($this->zdb->isEngineSUpported());
}
*
* @return void
*/
- public function testGetUnsupportedMessage()
+ public function testGetUnsupportedMessage(): void
{
$this->assertMatchesRegularExpression(
'/Minimum version for .+ engine is .+, .+ .+ found!/',
*/
abstract class GaletteTestCase extends TestCase
{
- /** @var \Galette\Core\Db */
protected \Galette\Core\Db $zdb;
protected array $members_fields;
protected array $members_fields_cats;
- /** @var \Galette\Core\I18n */
protected \Galette\Core\I18n $i18n;
- /** @var \Galette\Core\Preferences */
protected \Galette\Core\Preferences $preferences;
protected \RKA\Session $session;
- /** @var \Galette\Core\Login */
protected \Galette\Core\Login $login;
- /** @var \Galette\Core\History */
protected \Galette\Core\History $history;
- protected $logger_storage = '';
+ protected string $logger_storage = '';
- /** @var \Galette\Entity\Adherent */
protected \Galette\Entity\Adherent $adh;
- /** @var \Galette\Entity\Contribution */
protected \Galette\Entity\Contribution $contrib;
protected array $adh_ids = [];
protected array $contrib_ids = [];
/** @var array */
protected array $flash_data;
- /** @var \Slim\Flash\Messages */
protected \Slim\Flash\Messages $flash;
protected \DI\Container $container;
protected int $seed;
*
* @return void
*/
- protected function loadAdherent($id)
+ protected function loadAdherent(int $id): void
{
$this->adh = new \Galette\Entity\Adherent($this->zdb, (int)$id);
$this->adh->setDependencies(
*
* @return \Galette\Entity\Adherent
*/
- public function createMember(array $data)
+ public function createMember(array $data): \Galette\Entity\Adherent
{
$this->adh = new \Galette\Entity\Adherent($this->zdb);
$this->adh->setDependencies(
*
* @return void
*/
- protected function checkMemberOneExpected($adh = null, $new_expecteds = [])
+ protected function checkMemberOneExpected(\Galette\Entity\Adherent $adh = null, array $new_expecteds = []): void
{
if ($adh === null) {
$adh = $this->adh;
*
* @return void
*/
- protected function checkMemberTwoExpected($adh = null, $new_expecteds = [])
+ protected function checkMemberTwoExpected(\Galette\Entity\Adherent $adh = null, array $new_expecteds = []): void
{
if ($adh === null) {
$adh = $this->adh;
*
* @return false|\Laminas\Db\ResultSet\ResultSet
*/
- protected function adhOneExists()
+ protected function adhOneExists(): false|\Laminas\Db\ResultSet\ResultSet
{
$mdata = $this->dataAdherentOne();
$select = $this->zdb->select(\Galette\Entity\Adherent::TABLE, 'a');
*
* @return false|\Laminas\Db\ResultSet\ResultSet
*/
- protected function adhTwoExists()
+ protected function adhTwoExists(): false|\Laminas\Db\ResultSet\ResultSet
{
$mdata = $this->dataAdherentTwo();
$select = $this->zdb->select(\Galette\Entity\Adherent::TABLE, 'a');
*
* @return \Galette\Entity\Adherent
*/
- protected function getMemberOne()
+ protected function getMemberOne(): \Galette\Entity\Adherent
{
$rs = $this->adhOneExists();
if ($rs === false) {
*
* @return \Galette\Entity\Adherent
*/
- protected function getMemberTwo()
+ protected function getMemberTwo(): \Galette\Entity\Adherent
{
$rs = $this->adhTwoExists();
if ($rs === false) {
*
* @return \Galette\Entity\Contribution
*/
- public function createContrib(array $data, \Galette\Entity\Contribution $contrib = null)
+ public function createContrib(array $data, \Galette\Entity\Contribution $contrib = null): \Galette\Entity\Contribution
{
if ($contrib === null) {
$this->contrib = new \Galette\Entity\Contribution($this->zdb, $this->login);
*
* @return void
*/
- protected function createContribution()
+ protected function createContribution(): void
{
$now = new \DateTime(); // 2020-11-07
$begin_date = clone $now;
/**
* Check contributions expected
*
- * @param \Galette\Entity\Contribution $contrib Contribution instance, if any
- * @param array $new_expecteds Changes on expected values
+ * @param ?\Galette\Entity\Contribution $contrib Contribution instance, if any
+ * @param array<string,mixed> $new_expecteds Changes on expected values
*
* @return void
*/
- protected function checkContribExpected($contrib = null, $new_expecteds = [])
+ protected function checkContribExpected(\Galette\Entity\Contribution $contrib = null, array $new_expecteds = []): void
{
if ($contrib === null) {
$contrib = $this->contrib;
class Install extends TestCase
{
private \Galette\Core\Db $zdb;
+ /** @var array<string> */
private array $flash_data;
private \Slim\Flash\Messages $flash;
private \DI\Container $container;
*
* @return void
*/
- public function testDbSupport()
+ public function testDbSupport(): void
{
$this->assertTrue($this->zdb->isEngineSUpported());
}
*
* @return void
*/
- public function testUpdates()
+ public function testUpdates(): void
{
$install = new \Galette\Core\Install();
$update_scripts = \Galette\Core\Install::getUpdateScripts(