Upgraded PHP-CS-Fixer / applied optimized rules

This commit is contained in:
Bernd Bestel
2023-08-02 18:44:30 +02:00
parent 6c4cc00fd5
commit d006436d49
21 changed files with 56 additions and 166 deletions

View File

@@ -5,7 +5,6 @@ namespace Grocy\Services;
class ApiKeyService extends BaseService
{
const API_KEY_TYPE_DEFAULT = 'default';
const API_KEY_TYPE_SPECIAL_PURPOSE_CALENDAR_ICAL = 'special-purpose-calendar-ical';
public function CreateApiKey(string $keyType = self::API_KEY_TYPE_DEFAULT, string $description = null)

View File

@@ -33,7 +33,8 @@ class ApplicationService extends BaseService
}
// Sort changelog items to have the changelog descending by newest version
usort($changelogItems, function ($a, $b) {
usort($changelogItems, function ($a, $b)
{
if ($a['release_number'] == $b['release_number'])
{
return 0;

View File

@@ -5,25 +5,15 @@ namespace Grocy\Services;
class ChoresService extends BaseService
{
const CHORE_ASSIGNMENT_TYPE_IN_ALPHABETICAL_ORDER = 'in-alphabetical-order';
const CHORE_ASSIGNMENT_TYPE_NO_ASSIGNMENT = 'no-assignment';
const CHORE_ASSIGNMENT_TYPE_RANDOM = 'random';
const CHORE_ASSIGNMENT_TYPE_WHO_LEAST_DID_FIRST = 'who-least-did-first';
const CHORE_PERIOD_TYPE_HOURLY = 'hourly';
const CHORE_PERIOD_TYPE_DAILY = 'daily';
const CHORE_PERIOD_TYPE_MANUALLY = 'manually';
const CHORE_PERIOD_TYPE_MONTHLY = 'monthly';
const CHORE_PERIOD_TYPE_WEEKLY = 'weekly';
const CHORE_PERIOD_TYPE_YEARLY = 'yearly';
const CHORE_PERIOD_TYPE_ADAPTIVE = 'adaptive';
public function CalculateNextExecutionAssignment($choreId)
@@ -70,7 +60,8 @@ class ChoresService extends BaseService
}
elseif ($chore->assignment_type == self::CHORE_ASSIGNMENT_TYPE_IN_ALPHABETICAL_ORDER)
{
usort($assignedUsers, function ($a, $b) {
usort($assignedUsers, function ($a, $b)
{
return strcmp($a->display_name, $b->display_name);
});

View File

@@ -8,9 +8,7 @@ use LessQL\Database;
class DatabaseService
{
private static $DbConnection = null;
private static $DbConnectionRaw = null;
private static $instance = null;
public function ExecuteDbQuery(string $sql)
@@ -63,7 +61,8 @@ class DatabaseService
$logFilePath = GROCY_DATAPATH . '/sql.log';
if (file_exists($logFilePath))
{
self::$DbConnection->setQueryCallback(function ($query, $params) use ($logFilePath) {
self::$DbConnection->setQueryCallback(function ($query, $params) use ($logFilePath)
{
file_put_contents($logFilePath, $query . ' #### ' . implode(';', $params) . PHP_EOL, FILE_APPEND);
});
}
@@ -80,12 +79,14 @@ class DatabaseService
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_EMPTY_STRING);
$pdo->sqliteCreateFunction('regexp', function ($pattern, $value) {
$pdo->sqliteCreateFunction('regexp', function ($pattern, $value)
{
mb_regex_encoding('UTF-8');
return (false !== mb_ereg($pattern, $value)) ? 1 : 0;
});
$pdo->sqliteCreateFunction('grocy_user_setting', function ($value) {
$pdo->sqliteCreateFunction('grocy_user_setting', function ($value)
{
$usersService = new UsersService();
return $usersService->GetUserSetting(GROCY_USER_ID, $value);
});

View File

@@ -10,7 +10,6 @@ class DemoDataGeneratorService extends BaseService
}
protected $LocalizationService;
private $LastSupermarketId = 1;
public function PopulateDemoData()

View File

@@ -16,19 +16,12 @@ class LocalizationService
}
protected $Po;
protected $PoQu;
protected $Pot;
protected $PotMain;
protected $Translator;
protected $TranslatorQu;
protected $Culture;
private static $instanceMap = [];
public function CheckAndAddMissingTranslationToPot($text)

View File

@@ -7,11 +7,8 @@ use LessQL\Result;
class RecipesService extends BaseService
{
const RECIPE_TYPE_MEALPLAN_DAY = 'mealplan-day'; // A recipe per meal plan day => name = YYYY-MM-DD
const RECIPE_TYPE_MEALPLAN_WEEK = 'mealplan-week'; // A recipe per meal plan week => name = YYYY-WW (week number)
const RECIPE_TYPE_MEALPLAN_SHADOW = 'mealplan-shadow'; // A recipe per meal plan recipe (for separated stock fulfillment checking) => name = YYYY-MM-DD#<meal_plan.id>
const RECIPE_TYPE_NORMAL = 'normal'; // Normal / manually created recipes
public function AddNotFulfilledProductsToShoppingList($recipeId, $excludedProductIds = null)

View File

@@ -8,21 +8,13 @@ use Grocy\Helpers\WebhookRunner;
class StockService extends BaseService
{
const TRANSACTION_TYPE_CONSUME = 'consume';
const TRANSACTION_TYPE_INVENTORY_CORRECTION = 'inventory-correction';
const TRANSACTION_TYPE_PRODUCT_OPENED = 'product-opened';
const TRANSACTION_TYPE_PURCHASE = 'purchase';
const TRANSACTION_TYPE_SELF_PRODUCTION = 'self-production';
const TRANSACTION_TYPE_STOCK_EDIT_NEW = 'stock-edit-new';
const TRANSACTION_TYPE_STOCK_EDIT_OLD = 'stock-edit-old';
const TRANSACTION_TYPE_TRANSFER_FROM = 'transfer_from';
const TRANSACTION_TYPE_TRANSFER_TO = 'transfer_to';
public function AddMissingProductsToShoppingList($listId = 1)
@@ -121,7 +113,7 @@ class StockService extends BaseService
throw new \Exception('Product does not exist or is inactive');
}
$productDetails = (object) $this->GetProductDetails($productId);
$productDetails = (object)$this->GetProductDetails($productId);
// Tare weight handling
// The given amount is the new total amount including the container weight (gross)
@@ -369,7 +361,7 @@ class StockService extends BaseService
throw new \Exception('Location does not exist');
}
$productDetails = (object) $this->GetProductDetails($productId);
$productDetails = (object)$this->GetProductDetails($productId);
// Tare weight handling
// The given amount is the new total amount including the container weight (gross)
@@ -915,7 +907,7 @@ class StockService extends BaseService
throw new \Exception('Product does not exist or is inactive');
}
$productDetails = (object) $this->GetProductDetails($productId);
$productDetails = (object)$this->GetProductDetails($productId);
if ($price === null)
{
@@ -979,7 +971,7 @@ class StockService extends BaseService
throw new \Exception('Product does not exist or is inactive');
}
$productDetails = (object) $this->GetProductDetails($productId);
$productDetails = (object)$this->GetProductDetails($productId);
$productStockAmountUnopened = $productDetails->stock_amount_aggregated - $productDetails->stock_amount_opened_aggregated;
$potentialStockEntries = $this->GetProductStockEntries($productId, true, $allowSubproductSubstitution);
$product = $this->getDatabase()->products($productId);
@@ -1270,7 +1262,7 @@ class StockService extends BaseService
// Tare weight handling
// The given amount is the new total amount including the container weight (gross)
// The amount to be posted needs to be the absolute value of the given amount - stock amount - tare weight
$productDetails = (object) $this->GetProductDetails($productId);
$productDetails = (object)$this->GetProductDetails($productId);
if ($productDetails->product->enable_tare_weight_handling == 1)
{

View File

@@ -5,29 +5,17 @@ namespace Grocy\Services;
class UserfieldsService extends BaseService
{
const USERFIELD_TYPE_CHECKBOX = 'checkbox';
const USERFIELD_TYPE_DATE = 'date';
const USERFIELD_TYPE_DATETIME = 'datetime';
const USERFIELD_TYPE_DECIMAL_NUMBER = 'number-decimal';
const USERFIELD_TYPE_FILE = 'file';
const USERFIELD_TYPE_IMAGE = 'image';
const USERFIELD_TYPE_INTEGRAL_NUMBER = 'number-integral';
const USERFIELD_TYPE_LINK = 'link';
const USERFIELD_TYPE_LINK_WITH_TITLE = 'link-with-title';
const USERFIELD_TYPE_PRESET_CHECKLIST = 'preset-checklist';
const USERFIELD_TYPE_PRESET_LIST = 'preset-list';
const USERFIELD_TYPE_SINGLE_LINE_TEXT = 'text-single-line';
const USERFIELD_TYPE_SINGLE_MULTILINE_TEXT = 'text-multi-line';
protected $OpenApiSpec = null;