Skip to content

Commit

Permalink
Merge pull request #249 from City-of-Helsinki/UHF-9213
Browse files Browse the repository at this point in the history
UHF-9213: Run phpstan
  • Loading branch information
tuutti authored Nov 29, 2023
2 parents c37cf1b + 91d8263 commit 99bd4e7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ jobs:
- name: Run PHPCS
run: |
cd $DRUPAL_ROOT
vendor/bin/phpcs public/themes/contrib/$THEME_NAME --extensions=php,theme,module --standard=Drupal
vendor/bin/phpcs public/themes/contrib/$THEME_NAME --extensions=php,theme,module --standard=Drupal,DrupalPractice
- name: Run phpstan
working-directory: ${{ env.DRUPAL_ROOT }}
run: vendor/bin/phpstan analyze -c public/themes/contrib/$THEME_NAME/phpstan.neon public/themes/contrib/$THEME_NAME
7 changes: 6 additions & 1 deletion hdbt_admin.theme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Contains HDBT Admin theme.
*/

use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\media\MediaInterface;
Expand Down Expand Up @@ -118,8 +119,11 @@ function hdbt_admin_form_node_form_alter(&$form, FormStateInterface $form_state,
hdbt_admin_apply_form_theme($form);

// Get current entity.
$formObject = $form_state->getFormObject();
assert($formObject instanceof EntityFormInterface);

/** @var \Drupal\node\NodeInterface $node */
$node = $form_state->getFormObject()->getEntity();
$node = $formObject->getEntity();

// Disable "Preview" button on new nodes.
if ($node->isNew()) {
Expand Down Expand Up @@ -396,6 +400,7 @@ function hdbt_admin_preprocess_media(&$variables) {
}

if ($variables['media']->hasTranslation($current_language)) {
// @phpstan-ignore-next-line
$alt = $variables['media']
->getTranslation($current_language)->field_media_image->alt;
$variables['alt_text'] = $alt !== '""' ? $alt : FALSE;
Expand Down
13 changes: 13 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
fileExtensions:
- php
- module
- install
- theme
paths:
- ./
excludePaths:
- vendor
level: 3
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false

0 comments on commit 99bd4e7

Please sign in to comment.