Skip to content

Commit

Permalink
Require PHP 8.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Jan 13, 2025
1 parent a00e3f9 commit 7dc70a7
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.2"
php-version: "8.4"
ini-values: memory_limit=-1
tools: phpcs, cs2pr
- name: Run PHP Code Sniffer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
php-version: "8.4"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.4"
steps:
- name: Checkout
Expand Down Expand Up @@ -40,7 +39,7 @@ jobs:
run: make test-coveralls

- name: Upload code coverage
if: ${{ matrix.php-version == '8.2' }}
if: ${{ matrix.php-version == '8.4' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
ARG PHP_VERSION=8.2
ARG PHP_VERSION=8.4
FROM php:${PHP_VERSION}-cli-bookworm

RUN <<-EOF
docker-php-ext-enable opcache

if [ "$PHP_VERSION" \< "8.4" ]; then
apt-get update
apt-get install -y autoconf pkg-config
pecl channel-update pecl.php.net
pecl install xdebug
docker-php-ext-enable xdebug
fi
apt-get update
apt-get install -y autoconf pkg-config
pecl channel-update pecl.php.net
pecl install xdebug
docker-php-ext-enable opcache xdebug
EOF

RUN <<-EOF
Expand Down
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ test-cleanup:
@rm -rf tests/sandbox/*

.PHONY: test-container
test-container: test-container-82

.PHONY: test-container-82
test-container-82:
@-docker-compose run --rm app82 bash
@docker-compose down -v
test-container: test-container-84

.PHONY: test-container-84
test-container-84:
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "icanboogie/module",
"type": "library",
"description": "Provides module support to ICanBoogie.",
"version": "6.0",
"version": "7.0",
"keywords": [
"framework",
"module"
Expand Down Expand Up @@ -34,20 +34,20 @@
"icanboogie/operation": "^5.0"
},
"require": {
"php": ">=8.2",
"php": ">=8.4",
"icanboogie/errors": "^6.0",
"icanboogie/event": "^6.0",
"icanboogie/icanboogie": "^6.0"
"icanboogie/event": "^7.0",
"icanboogie/icanboogie": "^7.0"
},
"require-dev": {
"composer/composer": "^2.0",
"icanboogie/bind-activerecord": "^6.0",
"icanboogie/bind-event": "^6.0",
"icanboogie/bind-routing": "^6.0",
"icanboogie/bind-view": "^6.0",
"icanboogie/console": "^6.0",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^11.4"
"icanboogie/bind-activerecord": "^7.0",
"icanboogie/bind-event": "^7.0",
"icanboogie/bind-routing": "^7.0",
"icanboogie/bind-view": "^7.0",
"icanboogie/console": "^7.0",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.5"
},
"suggest": {
"icanboogie/facets": "In order to provide records fetchers to controllers."
Expand Down
13 changes: 1 addition & 12 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
---
services:
app82:
build:
context: .
args:
PHP_VERSION: "8.2"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-module'
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer:delegated
working_dir: /app
app84:
build:
context: .
args:
PHP_VERSION: "8.4.0RC4"
PHP_VERSION: "8.4"
environment:
PHP_IDE_CONFIG: 'serverName=icanboogie-module'
volumes:
Expand Down
104 changes: 36 additions & 68 deletions lib/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@

/**
* A module of the framework.
*
* @property-read string $flat_id Underscored identifier.
* @property-read string $id The identifier of the module, defined by {@see Descriptor::$id}.
* @property-read Model<ActiveRecord> $model The primary model of the module.
* @property-read Module $parent The parent module, defined by {@see Descriptor::$parent}.
* @property-read string $path The path to the module, defined by {@see Descriptor::$path}.
* @property-read string $title The localized title of the module.
* @property-read Application $app
*/
class Module extends Prototyped
class Module
{
/*
* PERMISSIONS:
Expand All @@ -40,43 +32,38 @@ class Module extends Prototyped
* ADMINISTER: You have complete control over the module
*
*/
public const PERMISSION_NONE = 0;
public const PERMISSION_ACCESS = 1;
public const PERMISSION_CREATE = 2;
public const PERMISSION_MAINTAIN = 3;
public const PERMISSION_MANAGE = 4;
public const PERMISSION_ADMINISTER = 5;
public const int PERMISSION_NONE = 0;
public const int PERMISSION_ACCESS = 1;
public const int PERMISSION_CREATE = 2;
public const int PERMISSION_MAINTAIN = 3;
public const int PERMISSION_MANAGE = 4;
public const int PERMISSION_ADMINISTER = 5;

/**
* Defines the name of the operation used to save the records of the module.
*/
public const OPERATION_SAVE = 'save';
public const string OPERATION_SAVE = 'save';

/**
* Defines the name of the operation used to delete the records of the module.
*/
public const OPERATION_DELETE = 'delete';
public const string OPERATION_DELETE = 'delete';

/**
* Returns the identifier of the module as defined by its descriptor.
*
* This method is the getter for the {@see $id} magic property.
* The identifier of the module as defined by its descriptor.
*/
protected function get_id(): string
{
return $this->descriptor->id;
public string $id {

Check failure on line 55 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be more than one property declared per statement
get => $this->descriptor->id;

Check failure on line 56 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on property "$this"
}

/**
* Returns the path of the module as defined by its descriptor.
*
* This method is the getter for the {@see $path} magic property.
* The path of the module as defined by its descriptor.
*/
protected function get_path(): string
{
/** @phpstan-ignore-next-line */
return $this->descriptor->path;
}
public string $path

Check failure on line 62 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be more than one property declared per statement
{
/** @phpstan-ignore-next-line */
get => $this->descriptor->path;

Check failure on line 65 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on property "$this"
}

public function __construct(
public readonly Descriptor $descriptor,
Expand All @@ -93,52 +80,33 @@ public function __toString(): string
}

/**
* Returns the _flat_ version of the module's identifier.
*
* This method is the getter for the {@see $flat_id} magic property.
* The _flat_ version of the module's identifier.
*/
protected function get_flat_id(): string
{
return strtr($this->id, [
public string $flat_id {

Check failure on line 85 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be more than one property declared per statement
get => strtr($this->id, [

Check failure on line 86 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

There must be 1 space after the property type declaration; 0 found

Check failure on line 86 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on property "$this"

'.' => '_',
'-' => '_'
'-' => '_',

]);
}

/**
* Returns the primary model of the module.
*
* This is the getter for the {@see $model} magic property.
* The primary model of the module.
*/
protected function get_model(): ActiveRecord\Model // @phpstan-ignore-line
{
return $this->model();
public ActiveRecord\Model $model {

Check failure on line 97 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be more than one property declared per statement

Check failure on line 97 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpstan

Property ICanBoogie\Module::$model with generic class ICanBoogie\ActiveRecord\Model does not specify its types: TRecord
get => $this->model();

Check failure on line 98 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on property "$this"
}

/**
* Returns the module title, translated to the current language.
*
* @deprecated
* The parent module, if any.
*/
protected function get_title(): string
{
// @phpstan-ignore-next-line
$default = $this->descriptor->title ?? 'Undefined';
public ?Module $parent {

Check failure on line 104 in lib/Module.php

View workflow job for this annotation

GitHub Actions / phpcs

There must not be more than one property declared per statement
get {
$parent = $this->descriptor->parent;

/** @phpstan-ignore-next-line */
return $this->app->translate($this->flat_id, [], [ 'scope' => 'module_title', 'default' => $default ]);
}

/**
* Returns the parent module.
*/
protected function get_parent(): ?Module
{
$parent = $this->descriptor->parent;

return $parent ? $this->module_provider->module_for_id($parent) : null;
return $parent ? $this->module_provider->module_for_id($parent) : null;
}
}

/**
Expand All @@ -159,7 +127,7 @@ public function is_installed(ErrorCollection $errors): ?bool
if (!$this->model($id)->is_installed()) {
$errors->add($this->id, "The model %name is not installed.", [

'name' => $id
'name' => $id,

]);

Expand All @@ -173,7 +141,7 @@ public function is_installed(ErrorCollection $errors): ?bool
/**
* Install the module.
*
* If the module has models they are installed.
* If the module has any model, they're installed as well.
*
* @return bool|null true if the module has successfully been installed, false if the
* module (or parts of the module) fails to install or null if the module has
Expand All @@ -200,7 +168,7 @@ public function install(ErrorCollection $errors): ?bool
$errors->add($this->id, "Unable to install model %model: !message", [

'model' => $id,
'message' => $e->getMessage()
'message' => $e->getMessage(),

]);

Expand Down Expand Up @@ -282,9 +250,9 @@ public function getBlock(string $name)

'%method' => $callback,
'%module' => $this->id,
'%type' => $name
'%type' => $name,

])
]),
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Module/Autoconfig/ModuleAutoconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
*/
interface ModuleAutoconfig
{
public const MODULES = 'modules';
public const string MODULES = 'modules';
}
4 changes: 2 additions & 2 deletions lib/Module/Autoconfig/ModuleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ final class ModuleExtension extends ExtensionAbstract
/**
* Identifier for module packages.
*/
public const PACKAGE_TYPE_MODULE = "icanboogie-module";
public const string PACKAGE_TYPE_MODULE = "icanboogie-module";

/**
* composer.json extra property for modules path. (root-only)
*/
public const OPTION_MODULES_PATH = 'modules-path';
public const string OPTION_MODULES_PATH = 'modules-path';

public function __construct(
private readonly AutoconfigGenerator $generator
Expand Down
4 changes: 2 additions & 2 deletions lib/Module/ModuleContainerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function load(array $configs, ContainerBuilder $container): void
// descriptor
$descriptor_id = "module_descriptor.$id";

$definition = (new Definition(Descriptor::class))
$definition = new Definition(Descriptor::class)
->setFactory([ new Reference(Config::class), 'descriptor_for' ])
->setArguments([ $id ])
->addTag('module_descriptor', [ 'id' => $id ]);
Expand All @@ -43,7 +43,7 @@ public function load(array $configs, ContainerBuilder $container): void
// module
$class = $descriptor->class;

$definition = (new Definition($class))
$definition = new Definition($class)
->setAutowired(true)
->setArgument('$descriptor', new Reference($descriptor_id))
->addTag('module', [ 'id' => $id ]);
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
bootstrap="tests/bootstrap.php"
Expand Down
19 changes: 0 additions & 19 deletions tests/lib/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@ class: Module::class,
});
}

#[DataProvider('provide_test_write_readonly_property')]
public function test_write_readonly_property(string $property): void
{
$this->expectException(PropertyNotWritable::class);
$this->node_module->$property = null;
}

/**
* @return array<array<string>>
*/
public static function provide_test_write_readonly_property(): array
{
$properties = 'flat_id id parent path title';

return array_map(function ($v) {
return (array)$v;
}, explode(' ', $properties));
}

public function test_get_descriptor(): void
{
$this->assertSame($this->node_descriptor, $this->node_module->descriptor);
Expand Down

0 comments on commit 7dc70a7

Please sign in to comment.