Skip to content

Commit 76242ee

Browse files
authored
Merge pull request #208 from moufmouf/merge51
Porting 5.1 changes into master
2 parents 27db626 + 469abda commit 76242ee

32 files changed

+993
-228
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ vendor/*
1717
/phpbench.sh
1818
/xdebug/
1919
.php_cs.cache
20-
tdbm.lock.yml
20+
tdbm.lock.yml

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build:
22
environment:
33
php:
4-
version: 7.1
4+
version: 7.4
55
nodes:
66
analysis:
77
project_setup:

.travis.yml

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
11
language: php
22
php:
3-
- 7.1
3+
- 7.1
44
cache:
55
directories:
66
- $HOME/.composer/cache
77
matrix:
88
include:
9-
- php: 7.2
10-
env: PREFER_LOWEST="" DB=mysql RUN_PHPSTAN=1 RUN_CSCHECK=1 RUN_REQUIRECHECKER=1 RUN_PERF_TEST=1
9+
- php: 7.4
10+
env: PREFER_LOWEST="" DB=mysql NO_WEAKREF=1 RUN_PHPSTAN=1 RUN_CSCHECK=1 RUN_REQUIRECHECKER=1 RUN_PERF_TEST=1
1111
services:
1212
- mysql
1313
- php: 7.3
1414
env: PREFER_LOWEST="" DB=mysql NO_WEAKREF=1
1515
services:
1616
- mysql
17-
- php: 7.1
18-
env: PREFER_LOWEST="" DB=mysql COVERALLS=true
17+
- php: 7.4
18+
env: PREFER_LOWEST="" DB=mysql NO_WEAKREF=1 COVERALLS=true
1919
services:
2020
- mysql
21-
- php: 7.1
21+
- php: 7.2
2222
env: PREFER_LOWEST="--prefer-lowest" DB=mysql
2323
services:
2424
- mysql
25-
- php: 7.1
25+
- php: 7.2
2626
env: PREFER_LOWEST="" DB=mysql8
2727
sudo: required
2828
services:
29-
- docker
30-
- php: 7.1
29+
- docker
30+
- php: 7.2
3131
env: PREFER_LOWEST="" DB=mariadb
3232
addons:
3333
mariadb: '10.3'
34-
- php: 7.1
34+
- php: 7.2
3535
env: PREFER_LOWEST="--prefer-lowest" DB=mariadb
3636
addons:
3737
mariadb: '10.3'
38-
- php: 7.1
38+
- php: 7.2
3939
env: PREFER_LOWEST="--prefer-lowest" DB=oracle PHPUNITFILE="-c phpunit.oracle.xml"
4040
sudo: required
4141
services:
4242
- docker
43-
- php: 7.1
43+
- php: 7.2
4444
env: PREFER_LOWEST="" DB=oracle PHPUNITFILE="-c phpunit.oracle.xml"
4545
sudo: required
4646
services:
4747
- docker
48-
- php: 7.1
48+
- php: 7.2
4949
env: PREFER_LOWEST="--prefer-lowest" DB=postgres PHPUNITFILE="-c phpunit.postgres.xml"
5050
addons:
5151
postgresql: "9.6"
5252
services:
5353
- postgresql
54-
- php: 7.1
54+
- php: 7.2
5555
env: PREFER_LOWEST="" DB=postgres PHPUNITFILE="-c phpunit.postgres.xml"
5656
addons:
5757
postgresql: "9.6"
5858
services:
5959
- postgresql
6060
allow_failures:
61-
- php: 7.1
61+
- php: 7.2
6262
env: PREFER_LOWEST="" DB=oracle PHPUNITFILE="-c phpunit.oracle.xml"
63-
- php: 7.1
63+
- php: 7.2
6464
env: PREFER_LOWEST="--prefer-lowest" DB=oracle PHPUNITFILE="-c phpunit.oracle.xml"
6565
env:
6666
global:
67-
- GIT_NAME: "'Couscous auto deploy'"
68-
- GIT_EMAIL: [email protected]
69-
- GH_REF: github.com/thecodingmachine/tdbm
70-
- secure: pAdXEBkhe0KJbbZEP61lcZzvKKMkVK2RDIZTf1RzjQRgk+PxIG5JLBiHKuvG3MgtFjZbdtl2Vf6nAZbeMyy3H0eCryQCjjqdb5mS3eDekJ4WwviN6hQDc7+Xw6R1saHvDvJs9GQENUzHPWfAfY7LuwUgHXdc+BCLZmV+j0H6liZMNlXIYqP1kdwl7u5a/Y3FvXFws6R7A0giUBCb4HOYkInaXV0yzuAEsB6XBDbTjw3EqI0GBs6746O4tn7N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GT7eMCIL8mvWFRMNiLJTE03J0ZbQDZ9N4OU3tdcgjV+d6pU6bu4SrCFtjCJnLaeLfIjoHkx+kK+kyCOQpOcuHMM6zq8l+ztd7VGZ3Br8HJTs1CxiWXrs+JIx2i8V06IE8nLKA=
7171
before_script:
72-
- composer update --prefer-dist
73-
# For some reason, $PREFER_LOWEST will fail unless a composer update has been run before...
74-
- if [ "$PREFER_LOWEST" = "--prefer-lowest" ] ; then composer update --prefer-dist --prefer-lowest; fi
75-
- if [ -z "$NO_WEAKREF" ] ; then pecl install weakref-beta; fi
72+
- composer update --prefer-dist
73+
# For some reason, $PREFER_LOWEST will fail unless a composer update has been run before...
74+
- if [ "$PREFER_LOWEST" = "--prefer-lowest" ] ; then composer update --prefer-dist --prefer-lowest; fi
75+
- if [ -z "$NO_WEAKREF" ] ; then pecl install weakref-beta; fi
7676
script:
77-
# Let's run the Oracle script only when the password is available (it is not available in forks unfortunately)
78-
- |
79-
if [[ "$COVERALLS" != "true" ]] ; then export NO_COVERAGE="--no-coverage"; fi;
80-
if [ "$DB" == "oracle" ] ; then
81-
docker run -v $(pwd):/app -v $(pwd)/tests/Fixtures/oracle-startup.sql:/docker-entrypoint-initdb.d/oracle-startup.sql moufmouf/oracle-xe-php vendor/bin/phpunit $PHPUNITFILE $NO_COVERAGE;
82-
elif [ "$DB" == "mysql8" ] ; then
83-
sudo /etc/init.d/mysql stop;
84-
tests/phpunit-mysql8.sh
85-
else
86-
echo ./vendor/bin/phpunit $PHPUNITFILE $NO_COVERAGE;
87-
./vendor/bin/phpunit $PHPUNITFILE $NO_COVERAGE;
88-
fi
89-
- |
90-
if [ "$RUN_CSCHECK" == "1" ] ; then
91-
composer cscheck
92-
fi
93-
- |
94-
if [ "$RUN_PHPSTAN" == "1" ] ; then
95-
composer phpstan
96-
fi
97-
- |
98-
if [ "$RUN_REQUIRECHECKER" == "1" ] ; then
99-
composer require-checker
100-
fi
101-
- |
102-
if [ "$RUN_PERF_TEST" == "1" ] ; then
103-
echo "***** Running PHPBENCH on current branch *****" && \
104-
./phpbench.dist.sh run --tag=current_pr --store
105-
fi
77+
# Let's run the Oracle script only when the password is available (it is not available in forks unfortunately)
78+
- |
79+
if [[ "$COVERALLS" != "true" ]] ; then export NO_COVERAGE="--no-coverage"; fi;
80+
if [ "$DB" == "oracle" ] ; then
81+
docker run -v $(pwd):/app -v $(pwd)/tests/Fixtures/oracle-startup.sql:/docker-entrypoint-initdb.d/oracle-startup.sql moufmouf/oracle-xe-php vendor/bin/phpunit $PHPUNITFILE $NO_COVERAGE;
82+
elif [ "$DB" == "mysql8" ] ; then
83+
sudo /etc/init.d/mysql stop;
84+
tests/phpunit-mysql8.sh
85+
else
86+
echo ./vendor/bin/phpunit $PHPUNITFILE $NO_COVERAGE;
87+
./vendor/bin/phpunit $PHPUNITFILE $NO_COVERAGE;
88+
fi
89+
- |
90+
if [ "$RUN_CSCHECK" == "1" ] ; then
91+
composer cscheck
92+
fi
93+
- |
94+
if [ "$RUN_PHPSTAN" == "1" ] ; then
95+
composer phpstan
96+
fi
97+
- |
98+
if [ "$RUN_REQUIRECHECKER" == "1" ] ; then
99+
composer require-checker
100+
fi
101+
- |
102+
if [ "$RUN_PERF_TEST" == "1" ] ; then
103+
echo "***** Running PHPBENCH on current branch *****" && \
104+
./phpbench.dist.sh run --tag=current_pr --store
105+
fi
106106
after_success:
107107
- |
108108
if [ "$RUN_PERF_TEST" == "1" ] && [ "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" != "master" ] ; then
@@ -114,5 +114,5 @@ after_success:
114114
./phpbench.dist.sh report --uuid=tag:current_pr --uuid=tag:master --report='{extends: compare, compare: tag}'
115115
fi
116116
after_script:
117-
- if [ "$COVERALLS" = "true" ] ; then ./vendor/bin/php-coveralls -v; fi
118-
- if [ "$COVERALLS" = "true" ] ; then vendor/bin/couscous travis-auto-deploy --php-version=7.1 -vvv; fi
117+
- if [ "$COVERALLS" = "true" ] ; then ./vendor/bin/php-coveralls -v; fi
118+
- if [ "$COVERALLS" = "true" ] ; then vendor/bin/couscous travis-auto-deploy --php-version=7.2 -vvv; fi

composer-require-checker.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"null", "true", "false",
44
"static", "self", "parent",
55
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
6-
"WeakRef",
6+
"WeakRef", "WeakReference",
77
"TheCodingMachine\\TDBM\\Fixtures\\Interfaces\\TestUserDaoInterface",
88
"TheCodingMachine\\TDBM\\Fixtures\\Traits\\TestUserDaoTrait",
99
"TheCodingMachine\\TDBM\\Fixtures\\Interfaces\\TestUserInterface",

composer.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
}
1919
],
2020
"require" : {
21-
"php" : ">=7.1",
22-
"mouf/magic-query" : "^1.4.0",
21+
"php" : ">=7.2",
22+
"mouf/magic-query" : "^1.4",
2323
"mouf/schema-analyzer": "^1.1.4",
2424
"doctrine/dbal": "^2.9.2",
2525
"psr/log": "~1.0",
@@ -32,25 +32,26 @@
3232
"mouf/utils.log.psr.multi-logger": "^1.0",
3333
"symfony/filesystem": "^2.7 || ^3 || ^4 || ^5",
3434
"ramsey/uuid": "^3.7",
35-
"doctrine/annotations": "^1.6",
35+
"doctrine/annotations": "^1.10",
3636
"zendframework/zend-code": "^3.4",
3737
"psr/container": "^1",
38+
"brain-diminished/schema-version-control": "^1.0.2",
3839
"ext-PDO": "*",
3940
"ext-json": "*",
4041
"ext-hash": "*",
4142
"ext-filter": "*",
42-
"brain-diminished/schema-version-control": "^1.0.2"
43+
"ext-intl": "*"
4344
},
4445
"require-dev" : {
45-
"phpunit/phpunit": "^7.4.4 || ^8.0.0",
46+
"phpunit/phpunit": "^8.5.8",
4647
"php-coveralls/php-coveralls": "^2.1",
4748
"wa72/simplelogger" : "^1.0",
48-
"friendsofphp/php-cs-fixer": "^2.15.1",
49+
"friendsofphp/php-cs-fixer": "^2.16.4",
4950
"symfony/process": "^3 || ^4 || ^5",
5051
"thecodingmachine/tdbm-fluid-schema-builder": "^1.0.0",
51-
"phpstan/phpstan": "^0.11.5",
52-
"thecodingmachine/phpstan-strict-rules": "^0.11.0",
53-
"bamarni/composer-bin-plugin": "^1.2",
52+
"phpstan/phpstan": "^0.11.19",
53+
"thecodingmachine/phpstan-strict-rules": "^0.11.2",
54+
"bamarni/composer-bin-plugin": "^1.4.1",
5455
"phpbench/phpbench": "^0.16.10"
5556
},
5657
"conflict": {

doc/install_service-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ In this document, we will describe integration of TDBM 5 with [Simplex](https://
1818
}
1919
},
2020
"require": {
21-
"php": ">=7.1",
21+
"php": ">=7.2",
2222
"mnapoli/simplex": "^0.4.1",
2323
"thecodingmachine/tdbm-universal-provider": "^5",
2424
"thecodingmachine/discovery": "^1.2"

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ parameters:
1313
#- "#expects array<string>, array<int, int|string> given.#"
1414
- "/Parameter #. \\$types of method Doctrine\\\\DBAL\\\\Connection::.*() expects array<int|string>, array<int, Doctrine\\\\DBAL\\\\Types\\\\Type> given./"
1515
- "#Method TheCodingMachine\\\\TDBM\\\\Schema\\\\ForeignKey::.*() should return .* but returns array<string>|string.#"
16+
- '#Method TheCodingMachine\\TDBM\\NativeWeakrefObjectStorage::get\(\) should return TheCodingMachine\\TDBM\\DbRow\|null but returns object\|null.#'
17+
-
18+
message: '#WeakRef#'
19+
path: src/WeakrefObjectStorage.php
1620
-
1721
message: '#Result of && is always false.#'
1822
path: src/Test/Dao/Bean/Generated/ArticleBaseBean.php

src/InnerResultArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function toIndex($offset): void
102102
}
103103
}
104104

105-
public function next()
105+
public function next(): void
106106
{
107107
// Let's overload the next() method to store the result.
108108
if (isset($this->results[$this->key + 1])) {

src/InnerResultIterator.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function executeQuery(): void
106106

107107
$this->logger->debug('Running SQL request: '.$sql);
108108

109-
$this->statement = $this->tdbmService->getConnection()->executeQuery($sql, $this->parameters, DbalUtils::generateArrayTypes($this->parameters));
109+
$this->statement = $this->tdbmService->getConnection()->executeQuery($sql, $this->parameters, DbalUtils::generateTypes($this->parameters));
110110

111111
$this->fetchStarted = true;
112112
}
@@ -140,7 +140,7 @@ private function getRowCountViaSqlQuery(): int
140140

141141
$this->logger->debug('Running count SQL request: '.$countSql);
142142

143-
$this->count = (int) $this->tdbmService->getConnection()->fetchColumn($countSql, $this->parameters, 0, DbalUtils::generateArrayTypes($this->parameters));
143+
$this->count = (int) $this->tdbmService->getConnection()->fetchColumn($countSql, $this->parameters, 0, DbalUtils::generateTypes($this->parameters));
144144
return $this->count;
145145
}
146146

@@ -168,17 +168,21 @@ public function key()
168168
* Advances the cursor to the next result.
169169
* Casts the database result into one (or several) beans.
170170
*/
171-
public function next()
171+
public function next(): void
172172
{
173173
$row = $this->statement->fetch(\PDO::FETCH_ASSOC);
174174
if ($row) {
175175

176176
// array<tablegroup, array<table, array<column, value>>>
177177
$beansData = [];
178+
$allNull = true;
178179
foreach ($row as $key => $value) {
179180
if (!isset($this->columnDescriptors[$key])) {
180181
continue;
181182
}
183+
if ($allNull !== false && $value !== null) {
184+
$allNull = false;
185+
}
182186

183187
$columnDescriptor = $this->columnDescriptors[$key];
184188

@@ -192,6 +196,10 @@ public function next()
192196

193197
$beansData[$columnDescriptor['tableGroup']][$columnDescriptor['table']][$columnDescriptor['column']] = $value;
194198
}
199+
if ($allNull === true) {
200+
$this->next();
201+
return;
202+
}
195203

196204
$reflectionClassCache = [];
197205
$firstBean = true;

0 commit comments

Comments
 (0)