Skip to content

Commit 8ad3946

Browse files
authored
Merge pull request #192 from doctrine/types
[2.0] Strict types, native parameter & return types
2 parents 59113bb + d9cf1a9 commit 8ad3946

34 files changed

+1224
-527
lines changed

.doctrine-project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"docsSlug": "doctrine-collections",
66
"versions": [
77
{
8-
"name": "master",
8+
"name": "2.0",
99
"branchName": "master",
1010
"slug": "latest",
1111
"upcoming": true

.scrutinizer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build:
22
environment:
33
php:
4-
version: 7.1.3
4+
version: 7.2
55

66
tools:
77
external_code_coverage:

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ cache:
77
- $HOME/.composer/cache
88

99
php:
10-
- 7.1
1110
- 7.2
1211
- 7.3
1312
- 7.4snapshot
@@ -47,7 +46,7 @@ jobs:
4746
- stage: Code Quality
4847
env: STATIC_ANALYSIS
4948
install: travis_retry composer install --prefer-dist
50-
script: vendor/bin/phpstan analyse -l 3 lib
49+
script: vendor/bin/phpstan analyse
5150

5251
- stage: Code Quality
5352
env: STATIC_ANALYSIS

UPGRADING-2.0.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Upgrading from 1.x to 2.0
2+
=========================
3+
4+
## BC breaking changes
5+
6+
Native parameter and return types were added.
7+
As a consequence, some signatures were changed and will have to be adjusted in sub-classes.
8+
9+
Note that in order to keep compatibility with both 1.x and 2.x versions, extending code would have to omit the added parameter types and add the return types. This would only work in PHP 7.2+ which is the first version featuring [parameter widening](https://wiki.php.net/rfc/parameter-no-type-variance).
10+
11+
You can find a list of major changes to public API below.
12+
13+
#### Doctrine\Common\Collections\Collection
14+
15+
| before | after |
16+
|-------------------------------:|:-----------------------------------------------|
17+
| add($element) | add($element): bool |
18+
| clear() | clear(): void |
19+
| contains($element) | contains($element): bool |
20+
| isEmpty() | isEmpty(): bool |
21+
| removeElement($element) | removeElement($element): bool |
22+
| containsKey($key) | containsKey($key): bool |
23+
| getKeys() | getKeys(): array |
24+
| getValues() | getValues(): array |
25+
| set($key, $value) | set($key, $value): void |
26+
| toArray() | toArray(): array |
27+
| exists(Closure $p) | exists(Closure $p): bool |
28+
| filter(Closure $p) | filter(Closure $p): self |
29+
| forAll(Closure $p) | forAll(Closure $p): bool |
30+
| map(Closure $func) | map(Closure $func): self |
31+
| partition(Closure $p) | partition(Closure $p): array |
32+
| slice($offset, $length = null) | slice(int $offset, ?int $length = null): array |
33+
| count() | count(): int |
34+
| getIterator() | getIterator(): \Traversable |
35+
| offsetSet($offset, $value) | offsetSet($offset, $value): void |
36+
| offsetUnset($offset) | offsetUnset($offset): void |
37+
| offsetExists($offset) | offsetExists($offset): bool |
38+
39+
#### Doctrine\Common\Collections\AbstractLazyCollection
40+
41+
| before | after |
42+
|----------------:|:----------------------|
43+
| isInitialized() | isInitialized(): bool |
44+
| initialize() | initialize(): void |
45+
| doInitialize() | doInitialize(): void |
46+
47+
#### Doctrine\Common\Collections\ArrayCollection
48+
49+
| before | after |
50+
|----------------------------:|:----------------------------------|
51+
| createFrom(array $elements) | createFrom(array $elements): self |
52+
| __toString() | __toString(): string |
53+
54+
#### Doctrine\Common\Collections\Selectable
55+
56+
| before | after |
57+
|-----------------------------:|:-----------------------------------------|
58+
| matching(Criteria $criteria) | matching(Criteria $criteria): Collection |

composer.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@
1818
{"name": "Johannes Schmitt", "email": "[email protected]"}
1919
],
2020
"require": {
21-
"php": "^7.1.3"
21+
"php": "^7.2"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^7.0",
2524
"doctrine/coding-standard": "^6.0",
26-
"phpstan/phpstan-shim": "^0.9.2",
27-
"vimeo/psalm": "^3.2.2",
28-
"infection/infection": "^0.12.2"
25+
"infection/infection": "^0.12.2",
26+
"phpstan/phpstan": "^0.11",
27+
"phpstan/phpstan-phpunit": "^0.11",
28+
"phpunit/phpunit": "^7.0",
29+
"vimeo/psalm": "^3.2.2"
30+
},
31+
"config": {
32+
"sort-packages": true
2933
},
3034
"autoload": {
3135
"psr-4": { "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" }
@@ -37,7 +41,7 @@
3741
},
3842
"extra": {
3943
"branch-alias": {
40-
"dev-master": "1.6.x-dev"
44+
"dev-master": "2.0.x-dev"
4145
}
4246
}
4347
}

0 commit comments

Comments
 (0)