Skip to content

Commit

Permalink
[TASK] updates phpstan config and updates/ adapts several classes acc…
Browse files Browse the repository at this point in the history
…ordingly

[TASK] updates required packages in composer.json
[TASK] updates version constraints in ext_emconf
[TASK] updates CHANGELOG
  • Loading branch information
EvilBMP committed Oct 15, 2024
1 parent 6ce15fa commit 7364d48
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 41 deletions.
56 changes: 51 additions & 5 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
includes:
- %currentWorkingDirectory%/.Build/vendor/phpstan/phpstan-strict-rules/rules.neon
- %currentWorkingDirectory%/.Build/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- %currentWorkingDirectory%/.Build/vendor/friendsoftypo3/phpstan-typo3/extension.neon
- ../.Build/vendor/phpstan/phpstan-strict-rules/rules.neon
- ../.Build/vendor/phpstan/phpstan-deprecation-rules/rules.neon
- ../.Build/vendor/friendsoftypo3/phpstan-typo3/extension.neon
- ../.Build/vendor/spaze/phpstan-disallowed-calls/extension.neon
- ../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
- ../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
- ../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon
- ../.Build/vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon
#- ../.Build/vendor/tomasvotruba/cognitive-complexity/config/extension.neon
- ../.Build/vendor/tomasvotruba/type-coverage/config/extension.neon

parameters:
level: 8

paths:
- %currentWorkingDirectory%/Classes
- ../Classes

excludePaths:
analyse:
- %currentWorkingDirectory%/Classes/DataHandling
- ../Classes/DataHandling

# Allow instanceof checks, particularly in tests
checkAlwaysTrueCheckTypeFunctionCall: false

type_coverage:
return: 98
param: 98
property: 95
constant: 0 # TODO: Set to 100, when PHP 8.3 is minimum requirement

#cognitive_complexity:
# class: 10
# function: 5

disallowedFunctionCalls:
-
function:
- 'var_dump()'
- 'xdebug_break()'
- 'debug()'
message: 'Use logging instead or remove if it was for debugging purposes.'
-
function: 'header()'
message: 'Use PSR-7 API instead'
disallowedStaticCalls:
-
method:
- 'TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump()'
- 'TYPO3\CMS\Core\Utility\DebugUtility::debug()'
message: 'Use logging instead or remove if it was for debugging purposes.'
disallowedSuperglobals:
-
superglobal:
- '$_GET'
- '$_POST'
- '$_FILES'
- '$_SERVER'
message: 'Use PSR-7 API instead'
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# PxDbsequencer Changelog

0.13.0 - 2024-10-15
-------------------
* [TASK] updates phpstan config and updates/ adapts several classes accordingly
* [TASK] updates required packages in composer.json
* [TASK] updates version constraints in ext_emconf
* [TASK] updates CHANGELOG

#### 2024-09-17
* [BUGFIX] removes php 8.1 from workflow matrix, as TYPO3 v13 has 8.2 as minimum
* [TASK] adds php 8.3 to workflow matrix
* [TASK] updates ext_emconf
* [CLEANUP] updates to DataHandler override
* [CLEANUP] updates README

#### 2024-08-06
* [TASK] updates DataHandler xclass to be compatible with TYPO3 v13.2

0.12.0 - 2023-11-27
-------------------
* [CLEANUP] small code clean-ups
Expand Down
25 changes: 15 additions & 10 deletions Classes/Hook/DataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@

namespace Portrino\PxDbsequencer\Hook;

use Doctrine\DBAL\Driver\Exception;
use Portrino\PxDbsequencer\DataHandling\DataHandler;
use Portrino\PxDbsequencer\Service;
use Portrino\PxDbsequencer\Service\SequencerService;
use Portrino\PxDbsequencer\Service\TYPO3Service;

/**
* DataHandlerHook
*/
class DataHandlerHook
{
/**
* @var Service\TYPO3Service
*/
private $TYPO3Service;
private TYPO3Service $TYPO3Service;

/**
* Constructor
*/
public function __construct()
{
$this->TYPO3Service = new Service\TYPO3Service(new Service\SequencerService());
$this->TYPO3Service = new TYPO3Service(new SequencerService());
}

/**
Expand All @@ -36,12 +35,18 @@ public function __construct()
* @param string $status
* @param string $table
* @param mixed $id
* @param array<mixed> $fieldArray
* @param array<string, mixed> $fieldArray
* @param DataHandler $pObj
* @throws \Exception
* @throws Exception
* @throws \Doctrine\DBAL\Exception
*/
public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$pObj): void
{
public function processDatamap_postProcessFieldArray(
string $status,
string $table,
mixed $id,
array &$fieldArray,
DataHandler &$pObj
): void {
if (str_contains($id, 'NEW') && $this->TYPO3Service->needsSequencer($table)) {
$newId = $this->TYPO3Service->getSequencerService()->getNextIdForTable($table);
if ($newId > 0) {
Expand Down
8 changes: 4 additions & 4 deletions Classes/Service/SequencerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ class SequencerService
/**
* @var string
*/
private $sequenceTable = 'tx_pxdbsequencer_sequence';
private string $sequenceTable = 'tx_pxdbsequencer_sequence';

/**
* @var int
*/
private $defaultStart = 0;
private int $defaultStart = 0;

/**
* @var int
*/
private $defaultOffset = 1;
private int $defaultOffset = 1;

/**
* @var ConnectionPool
*/
private $connectionPool;
private ConnectionPool $connectionPool;

/**
* SequencerService constructor.
Expand Down
9 changes: 3 additions & 6 deletions Classes/Service/TYPO3Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@
*/
class TYPO3Service
{
/**
* @var SequencerService
*/
private $sequencerService;
private SequencerService $sequencerService;

/**
* @var array<string> Array of configured tables that should call the sequencer
*/
private $supportedTables = [];
private array $supportedTables = [];

/**
* Constructor
*
* @param SequencerService $sequencer
* @param array<mixed>|null $conf
* @param array<string, mixed>|null $conf
*/
public function __construct(SequencerService $sequencer, ?array $conf = null)
{
Expand Down
36 changes: 24 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "With this extension you can ensure different unique keys for the configured tables (e.g.: pages, tt_content)",
"license": "GPL-2.0-or-later",
"type": "typo3-cms-extension",
"readme": "README.md",
"authors": [
{
"name": "portrino GmbH",
Expand All @@ -16,19 +17,22 @@
"source": "https://github.com/portrino/px_dbsequencer/"
},
"require": {
"typo3/cms-backend": "^13.2"
"php": "^8.2",
"typo3/cms-backend": "^13.4"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.28",
"friendsofphp/php-cs-fixer": "^3.14",
"ergebnis/composer-normalize": "^2.44",
"friendsofphp/php-cs-fixer": "^3.64",
"friendsoftypo3/phpstan-typo3": "^0.9",
"helmich/typo3-typoscript-lint": "^3.1",
"php-coveralls/php-coveralls": "^2.5",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-strict-rules": "^1.5",
"seld/jsonlint": "^1.9",
"typo3/coding-standards": "dev-main"
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-strict-rules": "^1.6",
"seld/jsonlint": "^1.11",
"spaze/phpstan-disallowed-calls": "^3.5",
"tomasvotruba/cognitive-complexity": "^0.2.3",
"tomasvotruba/type-coverage": "^0.3.1",
"typo3/coding-standards": "^0.8"
},
"replace": {
"typo3-ter/px-dbsequencer": "self.version"
Expand Down Expand Up @@ -65,15 +69,21 @@
},
"scripts": {
"ci": [
"@ci:composer",
"@ci:static"
],
"ci:composer:normalize": "@composer normalize --no-check-lock --dry-run",
"ci:composer": [
"@ci:composer:validate",
"@ci:composer:normalize",
"@ci:composer:psr-verify"
],
"ci:composer:normalize": "@composer normalize --dry-run",
"ci:composer:psr-verify": "@composer dumpautoload --optimize --strict-psr",
"ci:composer:validate": "@composer validate",
"ci:json:lint": "find . ! -path '*.Build/*' ! -path '*node_modules/*' -name '*.json' | xargs -r php .Build/bin/jsonlint -q",
"ci:php": [
"@ci:php:cs-fixer",
"@ci:php:lint",
"@ci:php:sniff",
"@ci:php:stan"
],
"ci:php:cs-fixer": "./.Build/bin/php-cs-fixer fix --config ./Build/php-cs-fixer.php -v --dry-run --using-cache no --diff",
Expand All @@ -90,18 +100,20 @@
],
"ci:ts:lint": "[ -d Configuration/TypoScript ] && ./.Build/bin/typoscript-lint -c ./Build/typoscript-lint.yaml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript || echo 'No TypoScript files found.'",
"ci:yaml:lint": "find . ! -path '*.Build/*' ! -path '*node_modules/*' -regextype egrep -regex '.*.ya?ml$' | xargs -r php ./.Build/bin/yaml-lint",
"fix:composer:normalize": "@composer normalize",
"fix:php": [
"@fix:php:cs"
],
"fix:php:cs": "./.Build/bin/php-cs-fixer fix --config ./Build/php-cs-fixer.php"
},
"scripts-descriptions": {
"ci": "Runs all dynamic and static code checks.",
"ci:composer": "Runs all checks for composer.json.",
"ci:composer:normalize": "Checks the composer.json.",
"ci:composer:psr-verify": "Verifies PSR-4 namespace correctness.",
"ci:composer:validate": "Validates the composer.json.",
"ci:json:lint": "Lints the JSON files.",
"ci:php": "Runs all static checks for the PHP files.",
"ci:php:copypaste": "Checks for copy'n'pasted PHP code.",
"ci:php:cs-fixer": "Checks the code style with the PHP Coding Standards Fixer (PHP-CS-Fixer).",
"ci:php:lint": "Lints the PHP files for syntax errors.",
"ci:php:stan": "Checks the PHP types using PHPStan.",
Expand Down
8 changes: 4 additions & 4 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

$EM_CONF[$_EXTKEY] = [
'title' => 'Database Sequencer',
'description' => 'With this extension you can ensure different unique keys for the configured tables (e.g.: pages, pages_language_overlay, tt_content)',
'description' => 'With this extension you can ensure different unique keys for the configured tables (e.g.: pages, tt_content, ...)',
'category' => 'be',
'author' => 'Andre Wuttig, Axel Boeswetter, Thomas Griessbach',
'author_email' => '[email protected], [email protected], griessbach@portrino.de',
'author' => 'Andre Wuttig, Axel Böswetter, Thomas Grießbach',
'author_email' => 'dev@portrino.de',
'author_company' => 'portrino GmbH',
'shy' => '',
'priority' => '',
Expand All @@ -30,7 +30,7 @@
'version' => '0.13.0',
'constraints' => [
'depends' => [
'typo3' => '13.0.0-13.99.99',
'typo3' => '13.4.0-13.99.99',
],
'conflicts' => [
],
Expand Down

0 comments on commit 7364d48

Please sign in to comment.