Fix PHPStan and PHPCS errors

This commit is contained in:
Oliver Davies 2020-06-01 19:03:25 +01:00
parent f5a0225c86
commit b49b487590
4 changed files with 12 additions and 15 deletions

View file

@ -3,18 +3,12 @@ SHELL=/bin/bash -e -o pipefail
.PHONY: * .PHONY: *
phpcs: phpcs:
symfony php vendor/bin/phpcs -n \
--standard="Drupal,DrupalPractice" \
--extensions="php,module,inc,install,test,profile,theme" \
--ignore=*/tests/* \
--exclude="Drupal.Commenting.ClassComment,Drupal.Commenting.FunctionComment" \
web/modules/custom
symfony php vendor/bin/phpcs -n \ symfony php vendor/bin/phpcs -n \
--standard="Drupal,DrupalPractice" \ --standard="Drupal,DrupalPractice" \
--extensions="php,module,inc,install,test,profile,theme" \ --extensions="php,module,inc,install,test,profile,theme" \
--exclude="Drupal.Commenting.ClassComment,Drupal.Commenting.DocComment,Drupal.Commenting.FunctionComment,Drupal.NamingConventions.ValidFunctionName" \ --exclude="Drupal.Commenting.ClassComment,Drupal.Commenting.FunctionComment,Drupal.Commenting.VariableComment" \
web/modules/custom/**/tests web/modules/custom \
web/themes/custom
phpstan: phpstan:
vendor/bin/phpstan analyze vendor/bin/phpstan analyze

View file

@ -8,8 +8,8 @@ parameters:
- *TestBase.php - *TestBase.php
checkMissingIterableValueType: false checkMissingIterableValueType: false
ignoreErrors: ignoreErrors:
- '#Call to an undefined method Drupal\\Core\\Entity\\EntityInterface::set()#' - '#Call to an undefined method Drupal\\Core\\Field\\FieldItemListInterface::referencedEntities()#'
- '#Call to an undefined method Drupal\\Core\\Field\\FieldItemListInterface::referencedEntities()#' - '#Call to an undefined method Illuminate\\Support\\HigherOrderCollectionProxy::id()#'
includes: includes:
- vendor/mglaman/phpstan-drupal/extension.neon - vendor/mglaman/phpstan-drupal/extension.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon - vendor/phpstan/phpstan-deprecation-rules/rules.neon

View file

@ -32,8 +32,10 @@ final class UpdateTalkNodeBeforeSave implements EventSubscriberInterface {
return; return;
} }
$this->reorderEvents($event->getEntity()); /** @var \Drupal\custom\Entity\Node\Talk $talk */
$this->updateCreatedDate($event->getEntity()); $talk = $event->getEntity();
$this->reorderEvents($talk);
$this->updateCreatedDate($talk);
} }
private function reorderEvents(Talk $talk): void { private function reorderEvents(Talk $talk): void {

View file

@ -11,8 +11,9 @@ use Drupal\custom\Entity\Node\Post;
* Implements hook_preprocess_HOOK(). * Implements hook_preprocess_HOOK().
*/ */
function opdavies_preprocess_page(array &$variables): void { function opdavies_preprocess_page(array &$variables): void {
/** @var \Drupal\custom\Entity\Node\Post $node */ /** @var \Drupal\custom\Entity\Node\Post|null $node */
if (!$node = $variables['node'] ?? NULL) { $node = $variables['node'] ?? NULL;
if (!$node) {
return; return;
} }