Skip to content

Commit 8451a49

Browse files
authored
fix: lower php version (#25)
* refactor: lower php version to 8.2 * refactor: remove const types * docs: update php 8.4 to 8.2
1 parent d3ee595 commit 8451a49

File tree

18 files changed

+67
-65
lines changed

18 files changed

+67
-65
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: true
1919
matrix:
20-
php: [ 8.4 ]
20+
php: [ 8.2, 8.3, 8.4 ]
2121
laravel: [ 11.*, 12.* ]
2222
stability: [ prefer-lowest, prefer-stable ]
2323

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -980,17 +980,17 @@ class ArticlePermissions
980980
{
981981
#[Label('View Articles')]
982982
#[Description('Allows viewing articles')]
983-
public const string VIEW = 'article:view';
983+
public const VIEW = 'article:view';
984984

985985
#[Label('Create Articles')]
986986
#[Description('Allows creating new articles')]
987-
public const string CREATE = 'article:create';
987+
public const CREATE = 'article:create';
988988

989989
#[Label('Edit Articles')]
990-
public const string EDIT = 'article:edit';
990+
public const EDIT = 'article:edit';
991991

992992
#[Label('Delete Articles')]
993-
public const string DELETE = 'article:delete';
993+
public const DELETE = 'article:delete';
994994
}
995995
```
996996

@@ -1010,14 +1010,14 @@ class SystemRoles
10101010
{
10111011
#[Label('Administrator')]
10121012
#[Description('Has all permissions')]
1013-
public const string ADMIN = 'admin';
1013+
public const ADMIN = 'admin';
10141014

10151015
#[Label('Editor')]
10161016
#[Description('Can edit content')]
1017-
public const string EDITOR = 'editor';
1017+
public const EDITOR = 'editor';
10181018

10191019
#[Label('Viewer')]
1020-
public const string VIEWER = 'viewer';
1020+
public const VIEWER = 'viewer';
10211021
}
10221022
```
10231023

@@ -1097,7 +1097,8 @@ php artisan vendor:publish --tag=mandate-migrations-meta
10971097
php artisan migrate
10981098
```
10991099

1100-
This adds `label` and `description` columns to the permissions, roles, and capabilities tables. These columns are useful for displaying human-readable names in admin UIs, regardless of whether you use code-first definitions.
1100+
This adds `label` and `description` columns to the permissions, roles, and capabilities tables. These columns are useful
1101+
for displaying human-readable names in admin UIs, regardless of whether you use code-first definitions.
11011102

11021103
### Generator Commands
11031104

@@ -1128,7 +1129,8 @@ Generate TypeScript types for frontend type safety. The command automatically me
11281129
- **Code-first definitions** — PHP classes with attributes (if enabled)
11291130
- **Database records** — Permissions, roles, and capabilities from the database
11301131

1131-
This allows you to define permissions in code (tied to features) while managing roles in the database (business-defined).
1132+
This allows you to define permissions in code (tied to features) while managing roles in the database (
1133+
business-defined).
11321134

11331135
```bash
11341136
# Generate to configured location (default: resources/js/types/mandate.ts)
@@ -1199,7 +1201,7 @@ $user->assignRole('editor');
11991201
On the frontend, use the generated TypeScript types:
12001202

12011203
```typescript
1202-
import { ArticlePermissions, Roles, type Permission, type Role } from '@/types/mandate';
1204+
import {ArticlePermissions, Roles, type Permission, type Role} from '@/types/mandate';
12031205

12041206
// Type-safe permission checks
12051207
function canEdit(userPermissions: Permission[]): boolean {
@@ -1235,15 +1237,15 @@ Event::listen(MandateSynced::class, function ($event) {
12351237

12361238
### Code-First Configuration Options
12371239

1238-
| Option | Default | Description |
1239-
|---------------------------------|--------------------------------------|------------------------------------------|
1240-
| `code_first.enabled` | `false` | Enable code-first mode |
1241-
| `code_first.paths.permissions` | `app_path('Permissions')` | Directory to scan for permission classes |
1242-
| `code_first.paths.roles` | `app_path('Roles')` | Directory to scan for role classes |
1243-
| `code_first.paths.capabilities` | `app_path('Capabilities')` | Directory to scan for capability classes |
1244-
| `code_first.assignments` | `[]` | Role-permission/capability assignments |
1240+
| Option | Default | Description |
1241+
|---------------------------------|----------------------------------------|------------------------------------------|
1242+
| `code_first.enabled` | `false` | Enable code-first mode |
1243+
| `code_first.paths.permissions` | `app_path('Permissions')` | Directory to scan for permission classes |
1244+
| `code_first.paths.roles` | `app_path('Roles')` | Directory to scan for role classes |
1245+
| `code_first.paths.capabilities` | `app_path('Capabilities')` | Directory to scan for capability classes |
1246+
| `code_first.assignments` | `[]` | Role-permission/capability assignments |
12451247
| `code_first.typescript_path` | `resource_path('js/types/mandate.ts')` | Default output path for TypeScript types |
1246-
| `feature_generator` | `null` | Custom feature generator class |
1248+
| `feature_generator` | `null` | Custom feature generator class |
12471249

12481250
---
12491251

@@ -1455,7 +1457,7 @@ See [UPGRADE.md](UPGRADE.md) for detailed migration instructions.
14551457

14561458
## Requirements
14571459

1458-
- PHP 8.4+
1460+
- PHP 8.2+
14591461
- Laravel 11.x or 12.x
14601462

14611463
## License

UPGRADE.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ class UserPermissions
118118
{
119119
#[Label('View Users')]
120120
#[Description('Can view user list')]
121-
public const string VIEW = 'user:view';
121+
public const VIEW = 'user:view';
122122
}
123123

124124
#[RoleSet('system')]
125125
#[Inherits(EditorRole::class)]
126126
class AdminRole
127127
{
128-
public const string ADMIN = 'admin';
128+
public const ADMIN = 'admin';
129129
}
130130
```
131131

@@ -142,14 +142,14 @@ class UserPermissions
142142
{
143143
#[Label('View Users')]
144144
#[Description('Can view user list')]
145-
public const string VIEW = 'user:view';
145+
public const VIEW = 'user:view';
146146
}
147147

148148
#[Guard('web')]
149149
class SystemRoles
150150
{
151151
#[Label('Administrator')]
152-
public const string ADMIN = 'admin';
152+
public const ADMIN = 'admin';
153153
}
154154
```
155155

@@ -291,10 +291,10 @@ serve this purpose but with more power — they can be assigned to roles and opt
291291
#[PermissionsSet('users', label: 'User Management', description: 'Manage users')]
292292
class UserPermissions
293293
{
294-
public const string VIEW = 'user:view';
295-
public const string CREATE = 'user:create';
296-
public const string EDIT = 'user:edit';
297-
public const string DELETE = 'user:delete';
294+
public const VIEW = 'user:view';
295+
public const CREATE = 'user:create';
296+
public const EDIT = 'user:edit';
297+
public const DELETE = 'user:delete';
298298
}
299299
```
300300

@@ -306,16 +306,16 @@ class UserPermissions
306306
class UserPermissions
307307
{
308308
#[Label('View Users')]
309-
public const string VIEW = 'user:view';
309+
public const VIEW = 'user:view';
310310

311311
#[Label('Create Users')]
312-
public const string CREATE = 'user:create';
312+
public const CREATE = 'user:create';
313313

314314
#[Label('Edit Users')]
315-
public const string EDIT = 'user:edit';
315+
public const EDIT = 'user:edit';
316316

317317
#[Label('Delete Users')]
318-
public const string DELETE = 'user:delete';
318+
public const DELETE = 'user:delete';
319319
}
320320

321321
// 2. Create a capability to group them
@@ -438,8 +438,8 @@ If you used the code-first approach in 1.x with `#[PermissionsSet]` attributes,
438438
#[PermissionsSet('users', label: 'User Management', description: 'Manage users')]
439439
class UserPermissions
440440
{
441-
public const string VIEW = 'user:view';
442-
public const string CREATE = 'user:create';
441+
public const VIEW = 'user:view';
442+
public const CREATE = 'user:create';
443443
}
444444

445445
// After: Creates a "users-management" capability with those permissions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^8.4",
21+
"php": "^8.2",
2222
"illuminate/contracts": "^11.0|^12.0",
2323
"illuminate/console": "^11.0|^12.0",
2424
"illuminate/support": "^11.0|^12.0"

src/Attributes/Capability.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
*
1414
* @example
1515
* #[Capability('user-management')]
16-
* public const string VIEW = 'user:view';
16+
* public const VIEW = 'user:view';
1717
*
1818
* #[Capability('user-management')]
1919
* #[Capability('reporting')]
20-
* public const string EXPORT = 'user:export';
20+
* public const EXPORT = 'user:export';
2121
*/
2222
#[Attribute(Attribute::TARGET_CLASS_CONSTANT | Attribute::IS_REPEATABLE)]
2323
final readonly class Capability

src/Attributes/Context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @example
1515
* #[Context(ExportFeature::class)]
16-
* public const string EXPORT = 'user:export';
16+
* public const EXPORT = 'user:export';
1717
*/
1818
#[Attribute(Attribute::TARGET_CLASS_CONSTANT)]
1919
final readonly class Context

src/Attributes/Description.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @example
1515
* #[Description('Allows viewing user profiles and account details')]
16-
* public const string VIEW = 'user:view';
16+
* public const VIEW = 'user:view';
1717
*/
1818
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_CLASS_CONSTANT)]
1919
final readonly class Description

src/Attributes/Guard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* #[Guard('api')]
1616
* final class ApiPermissions
1717
* {
18-
* public const string VIEW = 'api.view';
18+
* public const VIEW = 'api.view';
1919
* }
2020
*/
2121
#[Attribute(Attribute::TARGET_CLASS)]

src/Attributes/Label.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @example
1515
* #[Label('View Users')]
16-
* public const string VIEW = 'user:view';
16+
* public const VIEW = 'user:view';
1717
*/
1818
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_CLASS_CONSTANT)]
1919
final readonly class Label

src/CodeFirst/DefinitionCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
final class DefinitionCache
1515
{
16-
private const string CACHE_KEY_PREFIX = 'mandate.code_first';
16+
private const CACHE_KEY_PREFIX = 'mandate.code_first';
1717

1818
private CacheRepository $cache;
1919

0 commit comments

Comments
 (0)