Skip to content

Commit ff677bf

Browse files
committed
Fix some phpstan findings in tests
1 parent bd7ce0b commit ff677bf

File tree

6 files changed

+6
-32
lines changed

6 files changed

+6
-32
lines changed

tests/Gedmo/SoftDeleteable/HardRelationTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@
2020

2121
final class HardRelationTest extends BaseTestCaseORM
2222
{
23-
/**
24-
* @var SoftDeleteableListener
25-
*/
26-
private $softDeleteableListener;
27-
2823
protected function setUp(): void
2924
{
3025
parent::setUp();
3126

3227
$evm = new EventManager();
33-
$evm->addEventSubscriber($this->softDeleteableListener = new SoftDeleteableListener());
28+
$evm->addEventSubscriber(new SoftDeleteableListener());
3429
$this->getDefaultMockSqliteEntityManager($evm);
3530
$this->em->getConfiguration()->addFilter('softdelete', SoftDeleteableFilter::class);
3631
$this->em->getFilters()->enable('softdelete');

tests/Gedmo/Tool/BaseTestCaseORM.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
abstract class BaseTestCaseORM extends TestCase
4141
{
4242
/**
43-
* @var EntityManager
43+
* @var EntityManager|null
4444
*/
4545
protected $em;
4646

@@ -94,7 +94,7 @@ protected function getDefaultMockSqliteEntityManager(EventManager $evm = null, C
9494
*/
9595
protected function startQueryLog(): void
9696
{
97-
if (!$this->em || !$this->em->getConnection()->getDatabasePlatform()) {
97+
if (null === $this->em || null === $this->em->getConnection()->getDatabasePlatform()) {
9898
throw new \RuntimeException('EntityManager and database platform must be initialized');
9999
}
100100
$this->queryAnalyzer = new QueryAnalyzer($this->em->getConnection()->getDatabasePlatform());

tests/Gedmo/Translatable/Fixture/Type/Custom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
4343
$value = (is_resource($value)) ? stream_get_contents($value) : $value;
4444
$val = unserialize($value);
4545
if (false === $val && 'b:0;' !== $value) {
46-
new \Exception('Conversion failed');
46+
throw new \Exception('Conversion failed');
4747
}
4848

4949
return $val;

tests/Gedmo/Translatable/Issue/Issue173Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* These are tests for translatable behavior
2626
*
2727
* @author Gediminas Morkevicius <[email protected]>
28-
* @contributor Oscar Balladares [email protected] https://github.com/oscarballadares
28+
* @author Oscar Balladares [email protected] https://github.com/oscarballadares
2929
*/
3030
final class Issue173Test extends BaseTestCaseORM
3131
{

tests/Gedmo/Tree/MaterializedPathORMRepositoryTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ final class MaterializedPathORMRepositoryTest extends BaseTestCaseORM
3838
*/
3939
private $listener;
4040

41-
/**
42-
* @var array
43-
*/
44-
private $config = [];
45-
4641
protected function setUp(): void
4742
{
4843
parent::setUp();
@@ -55,7 +50,7 @@ protected function setUp(): void
5550
$this->getDefaultMockSqliteEntityManager($evm);
5651

5752
$meta = $this->em->getClassMetadata(self::CATEGORY);
58-
$this->config = $this->listener->getConfiguration($this->em, $meta->getName());
53+
$this->listener->getConfiguration($this->em, $meta->getName());
5954
$this->populate();
6055

6156
$this->repo = $this->em->getRepository(self::CATEGORY);

tests/Gedmo/Uploadable/UploadableEntityTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,6 @@ final class UploadableEntityTest extends BaseTestCaseORM
9292
/** @var string */
9393
private $destinationTestFile;
9494

95-
/** @var string */
96-
private $destinationTestFile2;
97-
98-
/** @var string */
99-
private $destinationTestFile3;
100-
101-
/** @var string */
102-
private $destinationTestFileWithoutExt;
103-
104-
/** @var string */
105-
private $destinationTestFileWithSpaces;
106-
10795
/** @var false|string */
10896
private $testFilename;
10997

@@ -143,10 +131,6 @@ protected function setUp(): void
143131
$this->testFileWithSpaces = TESTS_PATH.'/data/test with spaces.txt';
144132
$this->destinationTestDir = TESTS_TEMP_DIR.'/uploadable';
145133
$this->destinationTestFile = $this->destinationTestDir.'/test.txt';
146-
$this->destinationTestFile2 = $this->destinationTestDir.'/test2.txt';
147-
$this->destinationTestFile3 = $this->destinationTestDir.'/test_3.txt';
148-
$this->destinationTestFileWithoutExt = $this->destinationTestDir.'/test4';
149-
$this->destinationTestFileWithSpaces = $this->destinationTestDir.'/test with spaces';
150134
$this->testFilename = substr($this->testFile, strrpos($this->testFile, '/') + 1);
151135
$this->testFilename2 = substr($this->testFile2, strrpos($this->testFile2, '/') + 1);
152136
$this->testFilename3 = substr($this->testFile3, strrpos($this->testFile3, '/') + 1);

0 commit comments

Comments
 (0)