Skip to content

Commit 098e1cc

Browse files
committed
Update to PHP 8.3, Doctrine ORM 3 and Collections 2
1 parent 8fb6b9e commit 098e1cc

Some content is hidden

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

80 files changed

+808
-1137
lines changed

.coveralls.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build/
22
vendor/
3-
.php_cs.cache
3+
.php-cs-fixer.cache
44
composer.lock

.php-cs-fixer.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(['vendor', 'build'])
5+
->in(__DIR__);
6+
7+
return (new PhpCsFixer\Config())
8+
->setRiskyAllowed(true)
9+
->setRules([
10+
'@Symfony' => true,
11+
'no_useless_else' => true,
12+
'no_useless_return' => true,
13+
'ordered_class_elements' => true,
14+
'strict_comparison' => true,
15+
'strict_param' => true,
16+
])
17+
->setFinder($finder);

.php_cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Doctrine Specification
1+
# Doctrine Specification
22
[![Build Status](https://travis-ci.org/rikbruil/Doctrine-Specification.svg)](https://travis-ci.org/rikbruil/Doctrine-Specification)
33
[![Coverage Status](https://coveralls.io/repos/rikbruil/Doctrine-Specification/badge.svg?branch=master)](https://coveralls.io/r/rikbruil/Doctrine-Specification?branch=master)
44
[![Latest Stable Version](https://poser.pugx.org/rikbruil/doctrine-specification/v/stable.svg)](https://packagist.org/packages/rikbruil/doctrine-specification)
@@ -43,12 +43,12 @@ return $qb->where('r.ended = 0')
4343
```
4444

4545
```php
46-
use Rb\Specification\Doctrine\Condition\Equals;
47-
use Rb\Specification\Doctrine\Condition\IsNull;
48-
use Rb\Specification\Doctrine\Condition\LessThan;
49-
use Rb\Specification\Doctrine\Logic\AndX;
50-
use Rb\Specification\Doctrine\Logic\OrX;
51-
use Rb\Specification\Doctrine\Specification;
46+
use Purist\Specification\Doctrine\Condition\Equals;
47+
use Purist\Specification\Doctrine\Condition\IsNull;
48+
use Purist\Specification\Doctrine\Condition\LessThan;
49+
use Purist\Specification\Doctrine\Logic\AndX;
50+
use Purist\Specification\Doctrine\Logic\OrX;
51+
use Purist\Specification\Doctrine\Specification;
5252

5353
// Using the lib
5454
$spec = new Specification([
@@ -89,7 +89,7 @@ class ExpiredAds extends Specification
8989
];
9090
parent::__construct($specs);
9191
}
92-
92+
9393
public function isSatisfiedBy($value)
9494
{
9595
return $value === Advertisement::class;
@@ -107,7 +107,7 @@ class AdsByUser extends Specification
107107
new Join('user', 'u'),
108108
new Equals('id', $user->getId(), 'u'),
109109
];
110-
110+
111111
parent::__construct($specs);
112112
}
113113

@@ -131,7 +131,7 @@ class SomeService
131131

132132
return $this->em->getRepository('Advertisement')->match($spec)->execute();
133133
}
134-
134+
135135
/**
136136
* Fetch adverts paginated by Doctrine Paginator with joins intact.
137137
* A paginator can be iterated over like a normal array or Doctrine Collection
@@ -142,7 +142,7 @@ class SomeService
142142
new ExpiredAds(),
143143
new AdsByUser($user),
144144
]);
145-
145+
146146
$query = $this->em->getRepository('Advertisement')->match($spec);
147147
$query->setFirstResult(($page - 1) * $size))
148148
->setMaxResults($size);
@@ -155,7 +155,7 @@ class SomeService
155155

156156
Doctrine-Specification requires:
157157

158-
- PHP 5.5+
158+
- PHP 8.3+
159159
- Doctrine 2.2
160160

161161
## License

composer.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,21 @@
1212
],
1313
"minimum-stability": "stable",
1414
"autoload": {
15-
"psr-4": {"Rb\\Specification\\Doctrine\\": "src/"}
15+
"psr-4": {"Purist\\Specification\\Doctrine\\": "src/"}
1616
},
1717
"autoload-dev": {
18-
"psr-4": {"spec\\Rb\\Specification\\Doctrine\\": "spec/"}
18+
"psr-4": {"spec\\Purist\\Specification\\Doctrine\\": "spec/"}
1919
},
2020
"require": {
21-
"php": ">=5.5",
22-
"doctrine/orm": "^2.2",
23-
"doctrine/collections": "^1.2",
24-
"rikbruil/specification": "0.9.*"
21+
"php": "^8.3",
22+
"doctrine/orm": "^2.2|^3.0",
23+
"doctrine/collections": "^2.0",
24+
"purist/specification": "dev-master"
2525
},
2626
"require-dev": {
27-
"phpspec/phpspec": "^2.0",
28-
"henrikbjorn/phpspec-code-coverage": "^2.0",
29-
"friendsofphp/php-cs-fixer": "^2.0",
30-
"satooshi/php-coveralls": "^1.0"
27+
"phpspec/phpspec": "^7.5",
28+
"rector/rector": "^1.1",
29+
"friendsofphp/php-cs-fixer": "^3.59"
3130
},
3231
"extra": {
3332
"branch-alias": {
@@ -37,5 +36,8 @@
3736
"scripts": {
3837
"test": "vendor/bin/phpspec run",
3938
"fix-style": "vendor/bin/php-cs-fixer fix"
40-
}
39+
},
40+
"repositories": [
41+
{ "type": "git", "url": "https://github.com/PuristPHP/specification.git" }
42+
]
4143
}

docker-compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
php:
3+
image: php:8.3-cli-alpine
4+
volumes:
5+
- .:/app
6+
working_dir: /app

phpspec.yml.dist

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extensions:
2-
- PhpSpec\Extension\CodeCoverageExtension
3-
41
code_coverage:
52
format:
63
- clover
@@ -11,5 +8,5 @@ code_coverage:
118

129
suites:
1310
main:
14-
namespace: Rb\Specification\Doctrine
15-
psr4_prefix: Rb\Specification\Doctrine
11+
namespace: Purist\Specification\Doctrine
12+
psr4_prefix: Purist\Specification\Doctrine

rector.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use Rector\Config\RectorConfig;
4+
5+
return RectorConfig::configure()
6+
->withPaths([
7+
__DIR__.'/src',
8+
__DIR__.'/spec',
9+
])
10+
->withPhpSets(php83: true)
11+
->withAttributesSets(
12+
symfony: true,
13+
doctrine: true,
14+
)
15+
// here we can define, what prepared sets of rules will be applied
16+
->withPreparedSets(
17+
deadCode: true,
18+
codeQuality: true,
19+
typeDeclarations: true,
20+
privatization: true,
21+
instanceOf: true,
22+
earlyReturn: true,
23+
strictBooleans: true,
24+
);

spec/Condition/BetweenSpec.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
<?php
22

3-
namespace spec\Rb\Specification\Doctrine\Condition;
3+
namespace spec\Purist\Specification\Doctrine\Condition;
44

55
use Doctrine\Common\Collections\ArrayCollection;
66
use Doctrine\ORM\Query\Expr;
77
use Doctrine\ORM\QueryBuilder;
88
use PhpSpec\ObjectBehavior;
9-
use Rb\Specification\Doctrine\SpecificationInterface;
9+
use Purist\Specification\Doctrine\SpecificationInterface;
1010

1111
class BetweenSpec extends ObjectBehavior
1212
{
13-
private $field = 'foo';
13+
private string $field = 'foo';
1414

15-
private $from = 1;
15+
private int $from = 1;
1616

17-
private $to = 5;
17+
private int $to = 5;
1818

19-
public function let()
19+
public function let(): void
2020
{
2121
$this->beConstructedWith($this->field, $this->from, $this->to);
2222
}
2323

24-
public function it_is_an_expression()
24+
public function it_is_an_expression(): void
2525
{
2626
$this->shouldBeAnInstanceOf(SpecificationInterface::class);
2727
}
2828

29-
public function it_returns_an_expression_func_object(QueryBuilder $queryBuilder, ArrayCollection $parameters, Expr $expr)
29+
public function it_returns_an_expression_func_object(QueryBuilder $queryBuilder, ArrayCollection $parameters, Expr $expr): void
3030
{
31-
$dqlAlias = 'a';
31+
$dqlAlias = 'a';
3232
$expression = 'a.foo between(:from_10, :to_10)';
3333

3434
$queryBuilder->expr()->willReturn($expr);
@@ -37,16 +37,16 @@ public function it_returns_an_expression_func_object(QueryBuilder $queryBuilder,
3737
$queryBuilder->getParameters()->willReturn($parameters);
3838
$parameters->count()->willReturn(10);
3939

40-
$queryBuilder->setParameter('from_10', $this->from)->shouldBeCalled();
41-
$queryBuilder->setParameter('to_10', $this->to)->shouldBeCalled();
40+
$queryBuilder->setParameter('from_10', $this->from)->shouldBeCalled()->willReturn($queryBuilder);
41+
$queryBuilder->setParameter('to_10', $this->to)->shouldBeCalled()->willReturn($queryBuilder);
4242

4343
$this->isSatisfiedBy('foo')->shouldReturn(true);
4444
$this->modify($queryBuilder, $dqlAlias)->shouldReturn($expression);
4545
}
4646

47-
public function it_should_use_dql_alias_if_set(QueryBuilder $queryBuilder, ArrayCollection $parameters, Expr $expr)
47+
public function it_should_use_dql_alias_if_set(QueryBuilder $queryBuilder, ArrayCollection $parameters, Expr $expr): void
4848
{
49-
$dqlAlias = 'x';
49+
$dqlAlias = 'x';
5050
$expression = 'x.foo between(:from_10, :to_10)';
5151

5252
$this->beConstructedWith($this->field, $this->from, $this->to, $dqlAlias);
@@ -57,8 +57,8 @@ public function it_should_use_dql_alias_if_set(QueryBuilder $queryBuilder, Array
5757
$queryBuilder->getParameters()->willReturn($parameters);
5858
$parameters->count()->willReturn(10);
5959

60-
$queryBuilder->setParameter('from_10', $this->from)->shouldBeCalled();
61-
$queryBuilder->setParameter('to_10', $this->to)->shouldBeCalled();
60+
$queryBuilder->setParameter('from_10', $this->from)->shouldBeCalled()->willReturn($queryBuilder);
61+
$queryBuilder->setParameter('to_10', $this->to)->shouldBeCalled()->willReturn($queryBuilder);
6262

6363
$this->isSatisfiedBy('foo')->shouldReturn(true);
6464
$this->modify($queryBuilder, $dqlAlias)->shouldReturn($expression);

0 commit comments

Comments
 (0)