Skip to content

Commit 15a6f14

Browse files
authored
Merge branch 'master' into mysql8
2 parents b4e2867 + 4573dd7 commit 15a6f14

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ parameters:
1111
- "#expects array<string>, array<int, int|string> given.#"
1212
- "/Parameter #. \\$types of method Doctrine\\\\DBAL\\\\Connection::.*() expects array<int|string>, array<int, Doctrine\\\\DBAL\\\\Types\\\\Type> given./"
1313
- "#Method TheCodingMachine\\\\TDBM\\\\Schema\\\\ForeignKey::.*() should return .* but returns array<string>|string.#"
14+
-
15+
message: '#Result of && is always false.#'
16+
path: src/Test/Dao/Bean/Generated/ArticleBaseBean.php
1417
reportUnmatchedIgnoredErrors: false
1518
includes:
1619
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

src/Utils/ScalarBeanPropertyDescriptor.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,16 @@ public function getGetterSetterCode(): array
210210

211211
$resourceTypeCheck = '';
212212
if ($normalizedType === 'resource') {
213+
$checkNullable = '';
214+
if ($isNullable) {
215+
$checkNullable = sprintf('$%s !== null && ', $this->column->getName());
216+
}
213217
$resourceTypeCheck .= <<<EOF
214-
215-
if (!\is_resource($%s)) {
218+
if (%s!\is_resource($%s)) {
216219
throw \TheCodingMachine\TDBM\TDBMInvalidArgumentException::badType('resource', $%s, __METHOD__);
217220
}
218221
EOF;
219-
$resourceTypeCheck = sprintf($resourceTypeCheck, $this->column->getName(), $this->column->getName());
222+
$resourceTypeCheck = sprintf($resourceTypeCheck, $checkNullable, $this->column->getName(), $this->column->getName());
220223
}
221224

222225

tests/TDBMAbstractServiceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ private static function initSchema(Connection $connection): void
350350
$db->table('article')
351351
->column('id')->string(36)->primaryKey()->comment('@UUID')
352352
->column('content')->string(255)
353-
->column('author_id')->references('users')->null();
353+
->column('author_id')->references('users')->null()
354+
->column('attachment')->blob()->null();
354355

355356
$db->table('article2')
356357
->column('id')->string(36)->primaryKey()->comment('@UUID v4')

tests/TDBMDaoGeneratorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,4 +2019,17 @@ public function testNonInstantiableAbstractDaosAndBeans()
20192019
$refClass = new ReflectionClass(UserBaseBean::class);
20202020
$this->assertFalse($refClass->isInstantiable());
20212021
}
2022+
2023+
/**
2024+
* @depends testDaoGeneration
2025+
*/
2026+
public function testCanNullifyBlob()
2027+
{
2028+
$article = new ArticleBean('content');
2029+
$fp = fopen(__FILE__, 'r');
2030+
$article->setAttachment($fp);
2031+
$article->setAttachment(null);
2032+
$this->assertNull($article->getAttachment(null));
2033+
fclose($fp);
2034+
}
20222035
}

vendor-bin/couscous/composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor-bin/require-checker/composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)