Skip to content

Commit d55c3d5

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent aaff71a commit d55c3d5

26 files changed

Lines changed: 1505 additions & 537 deletions

.github/workflows/run-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
php-version: ['8.3', '8.4']
22+
php-version: ['8.1', '8.2', '8.3']
2323
steps:
2424
- uses: shivammathur/setup-php@v2
2525
with:
@@ -37,5 +37,7 @@ jobs:
3737
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
3838
- name: Run PHPUnit tests
3939
run: vendor/bin/phpunit -v --whitelist ./src tests
40+
- name: Run PHP Code Sniffer
41+
run: vendor/bin/phpcs -p ./src
4042
- name: Run PHPStan
4143
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2025 Ambroise Maupate
3+
Copyright © 2024 Ambroise Maupate
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

composer.json

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,20 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=8.3",
22-
"doctrine/orm": "~2.20.0",
23-
"api-platform/doctrine-orm": "^4.1.18",
24-
"api-platform/metadata": "^4.1.18",
25-
"roadiz/nodetype-contracts": "^3.1.1",
26-
"symfony/string": "7.4.*",
21+
"php": ">=8.1",
22+
"doctrine/orm": "~2.19.0",
23+
"jms/serializer": "^3.9.0",
24+
"symfony/string": "6.4.*",
2725
"symfony/translation-contracts": "^3.0",
28-
"symfony/http-foundation": "7.4.*",
29-
"symfony/serializer": "7.4.*",
30-
"symfony/uid": "7.4.*",
31-
"symfony/validator": "7.4.*"
26+
"symfony/http-foundation": "6.4.*",
27+
"symfony/serializer": "6.4.*",
28+
"symfony/validator": "6.4.*"
3229
},
3330
"require-dev": {
34-
"doctrine/doctrine-bundle": "^2.8.1",
31+
"phpunit/phpunit": "^9.5",
3532
"php-coveralls/php-coveralls": "^2.4",
36-
"phpstan/phpstan": "^2.1.36",
37-
"phpstan/phpdoc-parser": "<2",
38-
"phpunit/phpunit": "^9.6"
33+
"squizlabs/php_codesniffer": "^3.5",
34+
"phpstan/phpstan": "^1.5.3"
3935
},
4036
"autoload": {
4137
"psr-4": {
@@ -55,8 +51,8 @@
5551
},
5652
"extra": {
5753
"branch-alias": {
58-
"dev-master": "2.7.x-dev",
59-
"dev-develop": "2.8.x-dev"
54+
"dev-master": "2.3.x-dev",
55+
"dev-develop": "2.4.x-dev"
6056
}
6157
}
6258
}

phpcs.xml.dist

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
<arg name="basepath" value="."/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
<arg name="extensions" value="php"/>
9+
<rule ref="PSR12">
10+
<exclude name="Generic.Files.LineLength"/>
11+
</rule>
12+
<file>src/</file>
13+
</ruleset>

src/Bag/LazyParameterBag.php

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ public function __construct()
1919
}
2020

2121
/**
22+
* @param string $key
2223
* @param mixed|null $default
23-
*
2424
* @return mixed|null
2525
*/
26-
#[\Override]
2726
public function get(string $key, $default = null): mixed
2827
{
2928
if (!$this->ready) {
@@ -33,8 +32,11 @@ public function get(string $key, $default = null): mixed
3332
return parent::get($key, $default);
3433
}
3534

36-
#[\Override]
37-
public function all(?string $key = null): array
35+
/**
36+
* @param string|null $key
37+
* @return array
38+
*/
39+
public function all(string $key = null): array
3840
{
3941
if (!$this->ready) {
4042
$this->populateParameters();
@@ -43,7 +45,11 @@ public function all(?string $key = null): array
4345
return parent::all();
4446
}
4547

46-
#[\Override]
48+
/**
49+
* @param string $key
50+
*
51+
* @return bool
52+
*/
4753
public function has(string $key): bool
4854
{
4955
if (!$this->ready) {
@@ -53,7 +59,9 @@ public function has(string $key): bool
5359
return parent::has($key);
5460
}
5561

56-
#[\Override]
62+
/**
63+
* @return array
64+
*/
5765
public function keys(): array
5866
{
5967
if (!$this->ready) {
@@ -63,8 +71,10 @@ public function keys(): array
6371
return parent::keys();
6472
}
6573

74+
/**
75+
* @return \ArrayIterator
76+
*/
6677
#[\ReturnTypeWillChange]
67-
#[\Override]
6878
public function getIterator(): \ArrayIterator
6979
{
7080
if (!$this->ready) {
@@ -74,8 +84,10 @@ public function getIterator(): \ArrayIterator
7484
return parent::getIterator();
7585
}
7686

87+
/**
88+
* @return int
89+
*/
7790
#[\ReturnTypeWillChange]
78-
#[\Override]
7991
public function count(): int
8092
{
8193
if (!$this->ready) {
@@ -86,10 +98,13 @@ public function count(): int
8698
}
8799

88100
/**
89-
* @param null $default
90-
* @param array $options
101+
* @param string $key
102+
* @param null $default
103+
* @param int $filter
104+
* @param array $options
105+
*
106+
* @return mixed
91107
*/
92-
#[\Override]
93108
public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []): mixed
94109
{
95110
if (!$this->ready) {

src/Core/AbstractEntities/AbstractDateTimed.php

Lines changed: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,113 @@
44

55
namespace RZ\Roadiz\Core\AbstractEntities;
66

7+
use DateTime;
78
use Doctrine\ORM\Mapping as ORM;
9+
use JMS\Serializer\Annotation as Serializer;
10+
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
811

912
/**
1013
* An AbstractEntity with datetime fields to keep track of time with your items.
11-
*
12-
* @deprecated since 2.6, use composition with DateTimedTrait instead.
1314
*/
14-
#[ORM\MappedSuperclass,
15+
16+
#[
17+
ORM\MappedSuperclass,
1518
ORM\HasLifecycleCallbacks,
1619
ORM\Table,
17-
ORM\Index(columns: ['created_at']),
18-
ORM\Index(columns: ['updated_at']),]
19-
abstract class AbstractDateTimed extends AbstractEntity implements DateTimedInterface
20+
ORM\Index(columns: ["created_at"]),
21+
ORM\Index(columns: ["updated_at"]),
22+
]
23+
abstract class AbstractDateTimed extends AbstractEntity
2024
{
21-
use DateTimedTrait;
25+
/**
26+
* @var DateTime|null
27+
*/
28+
#[
29+
ORM\Column(name: "created_at", type: "datetime", nullable: true),
30+
Serializer\Groups(["timestamps"]),
31+
SymfonySerializer\Groups(["timestamps"]),
32+
]
33+
protected ?DateTime $createdAt = null;
34+
35+
/**
36+
* @var DateTime|null
37+
*/
38+
#[
39+
ORM\Column(name: "updated_at", type: "datetime", nullable: true),
40+
Serializer\Groups(["timestamps"]),
41+
SymfonySerializer\Groups(["timestamps"]),
42+
]
43+
protected ?DateTime $updatedAt = null;
44+
45+
/**
46+
* @return DateTime|null
47+
*/
48+
public function getCreatedAt(): ?DateTime
49+
{
50+
return $this->createdAt;
51+
}
52+
53+
/**
54+
* @param DateTime|null $createdAt
55+
* @return AbstractDateTimed
56+
*/
57+
public function setCreatedAt(?DateTime $createdAt)
58+
{
59+
$this->createdAt = $createdAt;
60+
return $this;
61+
}
62+
63+
/**
64+
* @return DateTime|null
65+
*/
66+
public function getUpdatedAt(): ?DateTime
67+
{
68+
return $this->updatedAt;
69+
}
70+
71+
/**
72+
* @param DateTime|null $updatedAt
73+
* @return AbstractDateTimed
74+
*/
75+
public function setUpdatedAt(?DateTime $updatedAt)
76+
{
77+
$this->updatedAt = $updatedAt;
78+
return $this;
79+
}
80+
81+
protected function initAbstractDateTimed(): void
82+
{
83+
$this->setUpdatedAt(new DateTime("now"));
84+
$this->setCreatedAt(new DateTime("now"));
85+
}
86+
87+
/**
88+
* @return void
89+
*/
90+
#[ORM\PreUpdate]
91+
public function preUpdate()
92+
{
93+
$this->setUpdatedAt(new DateTime("now"));
94+
}
95+
/**
96+
* @return void
97+
*/
98+
#[ORM\PrePersist]
99+
public function prePersist()
100+
{
101+
$this->setUpdatedAt(new DateTime("now"));
102+
$this->setCreatedAt(new DateTime("now"));
103+
}
104+
/**
105+
* Set creation and update date to *now*.
106+
*
107+
* @return AbstractEntity
108+
*/
109+
public function resetDates()
110+
{
111+
$this->setCreatedAt(new DateTime("now"));
112+
$this->setUpdatedAt(new DateTime("now"));
113+
114+
return $this;
115+
}
22116
}

src/Core/AbstractEntities/AbstractEntity.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,46 @@
55
namespace RZ\Roadiz\Core\AbstractEntities;
66

77
use Doctrine\ORM\Mapping as ORM;
8+
use JMS\Serializer\Annotation as Serializer;
9+
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
810

911
/**
1012
* Base entity implementing PersistableInterface to offer a unique ID.
11-
*
12-
* @deprecated since 2.6, use composition with PersistableInterface and SequentialIdTrait or UuidTrait instead.
1313
*/
14-
#[ORM\MappedSuperclass,
15-
ORM\Table]
14+
#[
15+
ORM\MappedSuperclass,
16+
ORM\Table
17+
]
1618
abstract class AbstractEntity implements PersistableInterface
1719
{
18-
use SequentialIdTrait;
20+
/**
21+
* @var int|string|null
22+
*/
23+
#[
24+
ORM\Id,
25+
ORM\Column(type: "integer"),
26+
ORM\GeneratedValue,
27+
Serializer\Groups(["id"]),
28+
Serializer\Type("integer"),
29+
SymfonySerializer\Groups(["id"])
30+
]
31+
protected int|string|null $id = null;
32+
33+
/**
34+
* @return int|string|null
35+
*/
36+
public function getId(): int|string|null
37+
{
38+
return $this->id;
39+
}
40+
41+
/**
42+
* @param int|string|null $id
43+
* @return AbstractEntity
44+
*/
45+
public function setId(int|string|null $id): self
46+
{
47+
$this->id = $id;
48+
return $this;
49+
}
1950
}

0 commit comments

Comments
 (0)