Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review items and adjustments for magic reflection extension
- Loading branch information
Showing
8 changed files
with
105 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...drupal/modules/phpstan_fixtures/src/EntityFieldReflection/EntityFieldOriginalProperty.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Drupal\phpstan_fixtures\EntityFieldReflection; | ||
|
||
use Drupal\entity_test\Entity\EntityTest; | ||
|
||
class EntityFieldOriginalProperty { | ||
|
||
public function testOriginal() { | ||
/** @var EntityTest $testEntity */ | ||
$testEntity = EntityTest::create([ | ||
'name' => 'Llama', | ||
'type' => 'entity_test', | ||
]); | ||
if ($testEntity->getRevisionId() !== $testEntity->original->getRevisionId()) { | ||
$testEntity->setSyncing(TRUE); | ||
} | ||
|
||
if (empty($testEntity->original) || $testEntity->getRevisionId() !== $testEntity->original->getRevisionId()) { | ||
$testEntity->setSyncing(TRUE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPStan\Drupal; | ||
|
||
final class EntityTestClass extends AnalyzerTestBase | ||
{ | ||
/** | ||
* @dataProvider dataEntitySamples | ||
*/ | ||
public function testEntityFields(string $path, int $count, array $errorMessages) { | ||
$errors = $this->runAnalyze($path); | ||
$this->assertCount($count, $errors, print_r($errors, true)); | ||
foreach ($errors as $key => $error) { | ||
$this->assertEquals($errorMessages[$key], $error->getMessage()); | ||
} | ||
} | ||
|
||
|
||
public function dataEntitySamples(): \Generator | ||
{ | ||
yield [ | ||
__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/src/EntityFieldReflection/EntityFieldMagicalGetters.php', | ||
2, | ||
[ | ||
'Access to an undefined property Drupal\Core\TypedData\TypedDataInterface::$value.', | ||
'Access to an undefined property Drupal\Core\TypedData\TypedDataInterface::$value.', | ||
] | ||
]; | ||
yield [ | ||
__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/src/EntityFieldReflection/EntityFieldOriginalProperty.php', | ||
0, | ||
[] | ||
]; | ||
} | ||
} |