Skip to content

Commit 5abb74b

Browse files
authored
refactor: partial update to property hooks (#848)
1 parent 05dac5c commit 5abb74b

File tree

75 files changed

+418
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+418
-499
lines changed

.github/workflows/coding-conventions.yml

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@ on:
44
pull_request:
55
workflow_dispatch:
66

7+
# CSFixer and Rector are temporarily disabled until they have proper PHP 8.4 support
78
jobs:
8-
check-style:
9-
name: Run Style Check
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v4
13-
14-
- name: Setup PHP
15-
uses: shivammathur/setup-php@v2
16-
with:
17-
php-version: 8.4
18-
coverage: none
19-
20-
- name: Install composer dependencies
21-
uses: ramsey/composer-install@v3
22-
23-
- name: Run php-cs-fixer
24-
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -vvv
25-
env:
26-
PHP_CS_FIXER_IGNORE_ENV: true
9+
# check-style:
10+
# name: Run Style Check
11+
# runs-on: ubuntu-latest
12+
# steps:
13+
# - uses: actions/checkout@v4
14+
#
15+
# - name: Setup PHP
16+
# uses: shivammathur/setup-php@v2
17+
# with:
18+
# php-version: 8.4
19+
# coverage: none
20+
#
21+
# - name: Install composer dependencies
22+
# uses: ramsey/composer-install@v3
23+
#
24+
# - name: Run php-cs-fixer
25+
# run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --allow-risky=yes --dry-run -vvv
26+
# env:
27+
# PHP_CS_FIXER_IGNORE_ENV: true
2728

2829
phpstan:
2930
name: "Run Static Analysis: PHPStan"
@@ -43,21 +44,21 @@ jobs:
4344
- name: Run PHPStan
4445
run: vendor/bin/phpstan --error-format=github
4546

46-
rector:
47-
name: "Run Static Analysis: Rector"
48-
runs-on: ubuntu-latest
49-
50-
steps:
51-
- uses: actions/checkout@v4
52-
53-
- name: Setup PHP
54-
uses: shivammathur/setup-php@v2
55-
with:
56-
php-version: 8.4
57-
coverage: none
58-
59-
- name: Install composer dependencies
60-
uses: ramsey/composer-install@v3
61-
62-
- name: Run Rector
63-
run: vendor/bin/rector process --no-ansi --dry-run --no-progress-bar
47+
# rector:
48+
# name: "Run Static Analysis: Rector"
49+
# runs-on: ubuntu-latest
50+
#
51+
# steps:
52+
# - uses: actions/checkout@v4
53+
#
54+
# - name: Setup PHP
55+
# uses: shivammathur/setup-php@v2
56+
# with:
57+
# php-version: 8.4
58+
# coverage: none
59+
#
60+
# - name: Install composer dependencies
61+
# uses: ramsey/composer-install@v3
62+
#
63+
# - name: Run Rector
64+
# run: vendor/bin/rector process --no-ansi --dry-run --no-progress-bar

.php-cs-fixer.dist.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@
120120
],
121121
'php_unit_mock_short_will_return' => true,
122122
'php_unit_set_up_tear_down_visibility' => true,
123+
'visibility_required' => [
124+
'elements' => [
125+
// 'property' // Disabled because of PHP 8.4 aviz
126+
'method',
127+
'const'
128+
],
129+
],
123130
'php_unit_size_class' => false,
124131
'php_unit_test_annotation' => [
125132
'style' => 'prefix',

src/Tempest/Auth/src/AuthInstaller.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ final class AuthInstaller implements Installer
1212
{
1313
use PublishesFiles;
1414

15-
public function getName(): string
16-
{
17-
return 'auth';
18-
}
15+
private(set) string $name = 'auth';
1916

2017
public function install(): void
2118
{
2219
$publishFiles = [
2320
__DIR__ . '/Install/User.php' => src_path('Auth/User.php'),
24-
__DIR__ . '/Install/UserMigration.php' => src_path('Auth/UserMigration.php'),
2521
__DIR__ . '/Install/Permission.php' => src_path('Auth/Permission.php'),
26-
__DIR__ . '/Install/PermissionMigration.php' => src_path('Auth/PermissionMigration.php'),
2722
__DIR__ . '/Install/UserPermission.php' => src_path('Auth/UserPermission.php'),
28-
__DIR__ . '/Install/UserPermissionMigration.php' => src_path('Auth/UserPermissionMigration.php'),
23+
__DIR__ . '/Install/CreateUsersTable.php' => src_path('Auth/CreateUsersTable.php'),
24+
__DIR__ . '/Install/CreatePermissionsTable.php' => src_path('Auth/CreatePermissionsTable.php'),
25+
__DIR__ . '/Install/CreateUserPermissionsTable.php' => src_path('Auth/CreateUserPermissionsTable.php'),
2926
];
3027

3128
foreach ($publishFiles as $source => $destination) {

src/Tempest/Auth/src/Install/PermissionMigration.php renamed to src/Tempest/Auth/src/Install/CreatePermissionsTable.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
namespace Tempest\Auth\Install;
66

77
use Tempest\Core\DoNotDiscover;
8-
use Tempest\Database\Migration;
8+
use Tempest\Database\DatabaseMigration;
99
use Tempest\Database\QueryStatements\CreateTableStatement;
1010
use Tempest\Database\QueryStatements\DropTableStatement;
1111

1212
#[DoNotDiscover]
13-
final readonly class PermissionMigration implements Migration
13+
final class CreatePermissionsTable implements DatabaseMigration
1414
{
15-
public function getName(): string
16-
{
17-
return '0000-00-01_create_permissions_table';
18-
}
15+
private(set) string $name = '0000-00-01_create_permissions_table';
1916

2017
public function up(): CreateTableStatement
2118
{
22-
return (new CreateTableStatement('permissions'))
19+
return new CreateTableStatement('permissions')
2320
->primary()
2421
->varchar('name');
2522
}

src/Tempest/Auth/src/Install/UserPermissionMigration.php renamed to src/Tempest/Auth/src/Install/CreateUserPermissionsTable.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
namespace Tempest\Auth\Install;
66

77
use Tempest\Core\DoNotDiscover;
8-
use Tempest\Database\Migration;
8+
use Tempest\Database\DatabaseMigration;
99
use Tempest\Database\QueryStatements\CreateTableStatement;
1010
use Tempest\Database\QueryStatements\DropTableStatement;
1111

1212
#[DoNotDiscover]
13-
final readonly class UserPermissionMigration implements Migration
13+
final class CreateUserPermissionsTable implements DatabaseMigration
1414
{
15-
public function getName(): string
16-
{
17-
return '0000-00-02_create_user_permissions_table';
18-
}
15+
private(set) string $name = '0000-00-02_create_user_permissions_table';
1916

2017
public function up(): CreateTableStatement
2118
{

src/Tempest/Auth/src/Install/UserMigration.php renamed to src/Tempest/Auth/src/Install/CreateUsersTable.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
namespace Tempest\Auth\Install;
66

77
use Tempest\Core\DoNotDiscover;
8-
use Tempest\Database\Migration;
8+
use Tempest\Database\DatabaseMigration;
99
use Tempest\Database\QueryStatements\CreateTableStatement;
1010
use Tempest\Database\QueryStatements\DropTableStatement;
1111

1212
#[DoNotDiscover]
13-
final readonly class UserMigration implements Migration
13+
final class CreateUsersTable implements DatabaseMigration
1414
{
15-
public function getName(): string
16-
{
17-
return '0000-00-00_create_users_table';
18-
}
15+
private(set) string $name = '0000-00-00_create_users_table';
1916

2017
public function up(): CreateTableStatement
2118
{
22-
return (new CreateTableStatement('users'))
19+
return new CreateTableStatement('users')
2320
->primary()
2421
->varchar('name')
2522
->varchar('email')

src/Tempest/Console/src/Components/Interactive/ConfirmComponent.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class ConfirmComponent implements InteractiveConsoleComponent, HasStaticCo
2828

2929
public function __construct(
3030
private readonly string $question,
31+
/** @phpstan-ignore-next-line https://github.com/phpstan/phpstan/issues/12255 */
3132
private readonly bool $default = false,
3233
readonly ?string $yes = null,
3334
readonly ?string $no = null,
@@ -36,6 +37,13 @@ public function __construct(
3637
$this->renderer = new ConfirmRenderer($yes ?? 'Yes', $no ?? 'No');
3738
}
3839

40+
public StaticConsoleComponent $staticComponent {
41+
get => new StaticConfirmComponent(
42+
$this->question,
43+
$this->default,
44+
);
45+
}
46+
3947
public function render(Terminal $terminal): string
4048
{
4149
return $this->renderer->render(
@@ -79,12 +87,4 @@ public function input(string $key): void
7987
default => $this->answer,
8088
};
8189
}
82-
83-
public function getStaticComponent(): StaticConsoleComponent
84-
{
85-
return new StaticConfirmComponent(
86-
$this->question,
87-
$this->default,
88-
);
89-
}
9090
}

src/Tempest/Console/src/Components/Interactive/MultipleChoiceComponent.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public function __construct(
4444
$this->updateQuery();
4545
}
4646

47+
public StaticConsoleComponent $staticComponent {
48+
get => new StaticMultipleChoiceComponent(
49+
label: $this->label,
50+
options: $this->options->getRawOptions(),
51+
default: $this->default,
52+
);
53+
}
54+
4755
public function render(Terminal $terminal): string
4856
{
4957
$this->updateQuery();
@@ -92,15 +100,6 @@ public function cursorVisible(): bool
92100
return $this->bufferEnabled;
93101
}
94102

95-
public function getStaticComponent(): StaticConsoleComponent
96-
{
97-
return new StaticMultipleChoiceComponent(
98-
label: $this->label,
99-
options: $this->options->getRawOptions(),
100-
default: $this->default,
101-
);
102-
}
103-
104103
#[HandlesKey]
105104
public function input(string $key): void
106105
{

src/Tempest/Console/src/Components/Interactive/ProgressBarComponent.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public function __construct(
2929
) {
3030
}
3131

32+
public StaticConsoleComponent $staticComponent {
33+
get => new StaticProgressBarComponent(
34+
data: $this->data,
35+
handler: $this->handler,
36+
format: $this->format,
37+
);
38+
}
39+
3240
public function render(Terminal $terminal): Generator
3341
{
3442
$result = [];
@@ -73,15 +81,6 @@ public function render(Terminal $terminal): Generator
7381
return $result;
7482
}
7583

76-
public function getStaticComponent(): StaticConsoleComponent
77-
{
78-
return new StaticProgressBarComponent(
79-
data: $this->data,
80-
handler: $this->handler,
81-
format: $this->format,
82-
);
83-
}
84-
8584
private function getControls(): array
8685
{
8786
return [

src/Tempest/Console/src/Components/Interactive/SearchComponent.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public function __construct(
5555
$this->updateQuery();
5656
}
5757

58+
public StaticConsoleComponent $staticComponent {
59+
get => new StaticSearchComponent(
60+
label: $this->label,
61+
search: $this->search,
62+
multiple: $this->multiple,
63+
default: $this->default,
64+
);
65+
}
66+
5867
public function render(Terminal $terminal): string
5968
{
6069
$this->updateQuery();
@@ -111,16 +120,6 @@ public function cursorVisible(): bool
111120
return $this->bufferEnabled;
112121
}
113122

114-
public function getStaticComponent(): StaticConsoleComponent
115-
{
116-
return new StaticSearchComponent(
117-
label: $this->label,
118-
search: $this->search,
119-
multiple: $this->multiple,
120-
default: $this->default,
121-
);
122-
}
123-
124123
#[HandlesKey]
125124
public function input(string $key): void
126125
{

0 commit comments

Comments
 (0)