Skip to content

Commit

Permalink
Merge branch release/v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Dec 6, 2024
1 parent 32e80e2 commit 0fbc571
Show file tree
Hide file tree
Showing 20 changed files with 367 additions and 681 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.2', '8.3']
steps:
- uses: shivammathur/setup-php@v2
with:
Expand All @@ -37,7 +37,5 @@ jobs:
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
- name: Run PHPUnit tests
run: vendor/bin/phpunit -v --whitelist ./src tests
- name: Run PHP Code Sniffer
run: vendor/bin/phpcs -p ./src
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
}
],
"require": {
"php": ">=8.1",
"doctrine/orm": "~2.19.0",
"php": ">=8.2",
"doctrine/orm": "~2.20.0",
"jms/serializer": "^3.9.0",
"roadiz/nodetype-contracts": "~1.1.2",
"symfony/string": "6.4.*",
"symfony/translation-contracts": "^3.0",
"symfony/http-foundation": "6.4.*",
"symfony/serializer": "6.4.*",
"symfony/validator": "6.4.*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"doctrine/doctrine-bundle": "^2.8.1",
"php-coveralls/php-coveralls": "^2.4",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan": "^1.5.3"
"phpstan/phpstan": "^1.5.3",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand All @@ -51,8 +52,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-master": "2.4.x-dev",
"dev-develop": "2.5.x-dev"
}
}
}
13 changes: 0 additions & 13 deletions phpcs.xml.dist

This file was deleted.

30 changes: 4 additions & 26 deletions src/Bag/LazyParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function __construct()
}

/**
* @param string $key
* @param mixed|null $default
*
* @return mixed|null
*/
public function get(string $key, $default = null): mixed
Expand All @@ -32,11 +32,7 @@ public function get(string $key, $default = null): mixed
return parent::get($key, $default);
}

/**
* @param string|null $key
* @return array
*/
public function all(string $key = null): array
public function all(?string $key = null): array
{
if (!$this->ready) {
$this->populateParameters();
Expand All @@ -45,11 +41,6 @@ public function all(string $key = null): array
return parent::all();
}

/**
* @param string $key
*
* @return bool
*/
public function has(string $key): bool
{
if (!$this->ready) {
Expand All @@ -59,9 +50,6 @@ public function has(string $key): bool
return parent::has($key);
}

/**
* @return array
*/
public function keys(): array
{
if (!$this->ready) {
Expand All @@ -71,9 +59,6 @@ public function keys(): array
return parent::keys();
}

/**
* @return \ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator(): \ArrayIterator
{
Expand All @@ -84,9 +69,6 @@ public function getIterator(): \ArrayIterator
return parent::getIterator();
}

/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count(): int
{
Expand All @@ -98,12 +80,8 @@ public function count(): int
}

/**
* @param string $key
* @param null $default
* @param int $filter
* @param array $options
*
* @return mixed
* @param null $default
* @param array $options
*/
public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []): mixed
{
Expand Down
80 changes: 31 additions & 49 deletions src/Core/AbstractEntities/AbstractDateTimed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,112 +4,94 @@

namespace RZ\Roadiz\Core\AbstractEntities;

use DateTime;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation as SymfonySerializer;

/**
* An AbstractEntity with datetime fields to keep track of time with your items.
*/

#[
ORM\MappedSuperclass,
ORM\HasLifecycleCallbacks,
ORM\Table,
ORM\Index(columns: ["created_at"]),
ORM\Index(columns: ["updated_at"]),
ORM\Index(columns: ['created_at']),
ORM\Index(columns: ['updated_at']),
]
abstract class AbstractDateTimed extends AbstractEntity
{
/**
* @var DateTime|null
*/
#[
ORM\Column(name: "created_at", type: "datetime", nullable: true),
Serializer\Groups(["timestamps"]),
SymfonySerializer\Groups(["timestamps"]),
ORM\Column(name: 'created_at', type: 'datetime', nullable: true),
Serializer\Groups(['timestamps']),
SymfonySerializer\Groups(['timestamps']),
]
protected ?DateTime $createdAt = null;
protected ?\DateTime $createdAt = null;

/**
* @var DateTime|null
*/
#[
ORM\Column(name: "updated_at", type: "datetime", nullable: true),
Serializer\Groups(["timestamps"]),
SymfonySerializer\Groups(["timestamps"]),
ORM\Column(name: 'updated_at', type: 'datetime', nullable: true),
Serializer\Groups(['timestamps']),
SymfonySerializer\Groups(['timestamps']),
]
protected ?DateTime $updatedAt = null;
protected ?\DateTime $updatedAt = null;

/**
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}

/**
* @param DateTime|null $createdAt
* @return AbstractDateTimed
* @return $this
*/
public function setCreatedAt(?DateTime $createdAt)
public function setCreatedAt(?\DateTime $createdAt): self
{
$this->createdAt = $createdAt;

return $this;
}

/**
* @return DateTime|null
*/
public function getUpdatedAt(): ?DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}

/**
* @param DateTime|null $updatedAt
* @return AbstractDateTimed
* @return $this
*/
public function setUpdatedAt(?DateTime $updatedAt)
public function setUpdatedAt(?\DateTime $updatedAt): self
{
$this->updatedAt = $updatedAt;

return $this;
}

protected function initAbstractDateTimed(): void
{
$this->setUpdatedAt(new DateTime("now"));
$this->setCreatedAt(new DateTime("now"));
$this->setUpdatedAt(new \DateTime('now'));
$this->setCreatedAt(new \DateTime('now'));
}

/**
* @return void
*/
#[ORM\PreUpdate]
public function preUpdate()
public function preUpdate(): void
{
$this->setUpdatedAt(new DateTime("now"));
$this->setUpdatedAt(new \DateTime('now'));
}
/**
* @return void
*/

#[ORM\PrePersist]
public function prePersist()
public function prePersist(): void
{
$this->setUpdatedAt(new DateTime("now"));
$this->setCreatedAt(new DateTime("now"));
$this->setUpdatedAt(new \DateTime('now'));
$this->setCreatedAt(new \DateTime('now'));
}

/**
* Set creation and update date to *now*.
*
* @return AbstractEntity
* @return $this
*/
public function resetDates()
public function resetDates(): self
{
$this->setCreatedAt(new DateTime("now"));
$this->setUpdatedAt(new DateTime("now"));
$this->setCreatedAt(new \DateTime('now'));
$this->setUpdatedAt(new \DateTime('now'));

return $this;
}
Expand Down
19 changes: 5 additions & 14 deletions src/Core/AbstractEntities/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,25 @@
]
abstract class AbstractEntity implements PersistableInterface
{
/**
* @var int|string|null
*/
#[
ORM\Id,
ORM\Column(type: "integer"),
ORM\Column(type: 'integer'),
ORM\GeneratedValue,
Serializer\Groups(["id"]),
Serializer\Type("integer"),
SymfonySerializer\Groups(["id"])
Serializer\Groups(['id']),
Serializer\Type('integer'),
SymfonySerializer\Groups(['id'])
]
protected int|string|null $id = null;

/**
* @return int|string|null
*/
public function getId(): int|string|null
{
return $this->id;
}

/**
* @param int|string|null $id
* @return AbstractEntity
*/
public function setId(int|string|null $id): self
{
$this->id = $id;

return $this;
}
}
Loading

0 comments on commit 0fbc571

Please sign in to comment.