Skip to content

Commit

Permalink
Compatibility with 5.2 (#51)
Browse files Browse the repository at this point in the history
* update libraries
* use nullable typehint
* add override attribute
* use setEntity for form
* update action scripts
  • Loading branch information
DarkSide666 authored Jan 21, 2025
1 parent e910866 commit 5615473
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 25 deletions.
5 changes: 1 addition & 4 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ categories:
labels:
- "BC-break"
- title: "Other changes"
template: |
## What’s Changed
$CHANGES
template: $CHANGES
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Release
name: Build release

on:
push:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup cache 2/2
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-smoke-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }}
Expand All @@ -46,16 +46,16 @@ jobs:
- name: Install PHP dependencies
run: |
if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev; fi
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev; fi
if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit ergebnis/phpunit-slow-test-detector --dev; fi
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev; fi
if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* behat/\* --dev; fi
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
- name: "Run tests: SQLite (only for Phpunit)"
if: startsWith(matrix.type, 'Phpunit')
run: |
php demos/_demo-data/create-db.php
echo "not implemented" || vendor/bin/phpunit --exclude-group none --no-coverage -v
echo "not implemented" || vendor/bin/phpunit --exclude-group none --no-coverage --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi)
- name: Check Coding Style (only for CodingStyle)
if: matrix.type == 'CodingStyle'
Expand All @@ -69,4 +69,4 @@ jobs:
if: matrix.type == 'StaticAnalysis'
run: |
echo "memory_limit = 2G" > /usr/local/etc/php/conf.d/custom-memory-limit.ini
vendor/bin/phpstan analyse
vendor/bin/phpstan analyse -v
10 changes: 6 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,
'@PHP74Migration' => true,

// required by PSR-12
'concat_space' => [
'spacing' => 'one',
],

// disable some too strict rules
'phpdoc_types' => [
// keep enabled, but without "alias" group to not fix
// "Callback" to "callback" in phpdoc
'groups' => ['simple', 'meta'],
],
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
Expand Down Expand Up @@ -46,9 +51,6 @@
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
},
"require-release": {
"php": ">=7.4 <8.4",
"atk4/ui": "~5.0.0",
"atk4/ui": "~5.2.0",
"league/flysystem": "^2.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.13",
"ergebnis/phpunit-slow-test-detector": "^2.9",
"friendsofphp/php-cs-fixer": "^3.0",
"johnkary/phpunit-speedtrap": "^3.3",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^9.5.5"
"phpunit/phpunit": "^9.5.5 || ^10.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
1 change: 1 addition & 0 deletions demos/_includes/Friend.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Friend extends Model
/** @var Filesystem */
public $filesystem;

#[\Override]
protected function init(): void
{
parent::init();
Expand Down
2 changes: 1 addition & 1 deletion demos/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// new friend form
Header::addTo($t1, ['Add New Friend']);
$form = Form::addTo($t1);
$form->setModel(
$form->setEntity(
(new Friend($app->db, [
'filesystem' => $filesystem,
]))->createEntity()
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ includes:
parameters:
level: 6
paths:
- .
- ./
excludePaths:
- vendor
- vendor/

ignoreErrors:
# relax strict rules
Expand Down
2 changes: 2 additions & 0 deletions src/Form/Control/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class Upload extends \Atk4\Ui\Form\Control\Upload
{
#[\Override]
protected function init(): void
{
parent::init();
Expand Down Expand Up @@ -48,6 +49,7 @@ protected function deleted(string $token): ?JsExpressionable
return null;
}

#[\Override]
protected function renderView(): void
{
if ($this->entityField->getField()->fieldFilename) { // @phpstan-ignore-line
Expand Down
11 changes: 6 additions & 5 deletions src/Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class File extends Model
/** Draft files deleting delay in seconds, to prevent cleaning up unsaved forms */
protected int $draftsCleanupDelay = 2 * 24 * 3600;

#[\Override]
protected function init(): void
{
parent::init();
Expand Down Expand Up @@ -142,7 +143,7 @@ public function newFile(): Model
*
* @return static
*/
public function createFromPath(string $path, string $fileName = null): Model
public function createFromPath(string $path, ?string $fileName = null): Model
{
$this->assertIsModel();

Expand Down Expand Up @@ -201,9 +202,9 @@ public function createFromPath(string $path, string $fileName = null): Model
*/
public function createThumbnail(
string $path,
int $maxWidth = null,
int $maxHeight = null,
string $format = null
?int $maxWidth = null,
?int $maxHeight = null,
?string $format = null
): bool {
$this->assertIsEntity();

Expand Down Expand Up @@ -293,7 +294,7 @@ public function getStream(): StreamInterface
*
* @param int $draftsCleanupDelay Custom drafts cleanup delay in seconds
*/
public function cleanupDrafts(int $draftsCleanupDelay = null): void
public function cleanupDrafts(?int $draftsCleanupDelay = null): void
{
$draftsCleanupDelay ??= $this->draftsCleanupDelay;

Expand Down

0 comments on commit 5615473

Please sign in to comment.