diff -u b/core/modules/file/file.module b/core/modules/file/file.module --- b/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -564,10 +564,10 @@ 'render element' => 'element', ), 'file_audio' => array( - 'variables' => array( 'files' => array(), 'attributes' => NULL), + 'variables' => array('files' => array(), 'attributes' => NULL), ), 'file_video' => array( - 'variables' => array( 'files' => array(), 'attributes' => NULL), + 'variables' => array('files' => array(), 'attributes' => NULL), ), // From file.field.inc. diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileAudioFormatter.php @@ -1,10 +1,5 @@ TRUE, 'autoplay' => FALSE, 'loop' => FALSE, 'multiple_file_behavior' => 'tags', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -131,7 +127,7 @@ * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $summary[] = t('Controls: %controls', array('%controls' => $this->getSetting('controls') ? 'visible' : 'hidden')); $summary[] = t('Autoplay: %autoplay', array('%autoplay' => $this->getSetting('autoplay') ? t('yes') : t('no'))); $summary[] = t('Loop: %loop', array('%loop' => $this->getSetting('loop') ? t('yes') : t('no'))); @@ -143,15 +139,11 @@ * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; $multiple_file_behavior = $this->getSetting('multiple_file_behavior'); - $source_files = array(); + $source_files = []; // Because we can have the files grouped in a single audio tag, we do a // grouping in case the multiple file behavior is not 'tags'. - /** - * @var integer $delta - * @var File $file - */ foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) { $mimeTypeType = static::getMimeTypeType($file->getMimeType()); diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatter.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatter.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileMediaFormatter.php @@ -1,8 +1,4 @@ guess('fakedFile.' . $extension); - if (static::getMimeTypeType($mimeType) == static::applicableMimeType) { + if (static::getMimeTypeType($mimeType) == static::APPLICABLE_MIME_TYPE) { $applicable = TRUE; } } @@ -43,8 +45,12 @@ + * @param string $mimeType + * The full mimeType. + * * @return string - * The mimetype. + * The last part of a mimetype. */ public static function getMimeTypeType($mimeType) { list($type, $subtype) = explode('/', $mimeType, 2); return $type; } -} \ No newline at end of file + +} diff -u b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php --- b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php +++ b/core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php @@ -1,10 +1,5 @@ $this->getSetting('width'), - '%height' => $this->getSetting('height') + '%height' => $this->getSetting('height'), )); } $summary[] = t('Multiple files: %multiple', array('%multiple' => $this->getSetting('multiple_file_behavior'))); @@ -182,11 +178,6 @@ $source_files = array(); // Because we can have the files grouped in a single video tag, we do a // grouping in case the multiple file behavior is not 'tags'. - - /** - * @var integer $delta - * @var FileInterface $file - */ foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) { $mimeTypeType = static::getMimeTypeType($file->getMimeType()); if ($mimeTypeType == 'video') { @@ -233 +224,2 @@ -} \ No newline at end of file + +} diff -u b/core/modules/file/tests/src/Kernel/Formatter/FileAudioFormatterTest.php b/core/modules/file/tests/src/Kernel/Formatter/FileAudioFormatterTest.php --- b/core/modules/file/tests/src/Kernel/Formatter/FileAudioFormatterTest.php +++ b/core/modules/file/tests/src/Kernel/Formatter/FileAudioFormatterTest.php @@ -18,21 +18,29 @@ class FileAudioFormatterTest extends KernelTestBase { /** + * The entity type. + * * @var string */ protected $entityType; /** + * The bundle type. + * * @var string */ protected $bundle; /** + * The field name. + * * @var string */ protected $fieldName; /** + * The view display. + * * @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface */ protected $display; @@ -86,8 +94,7 @@ ]); $this->display->setComponent($this->fieldName, [ 'type' => 'file_audio', - 'settings' => [ - ], + 'settings' => [], ]); $this->display->save(); @@ -103,12 +110,14 @@ 'uri' => 'public://file.mp3', 'filename' => 'file.mp3', ]); - $file-> save(); + $file->save(); $entity = EntityTest::create([ - $this->fieldName => [[ - 'target_id' => $file->id(), - ],], + $this->fieldName => [ + [ + 'target_id' => $file->id(), + ], + ], ]); $entity->save(); @@ -136 +145 @@ -} \ No newline at end of file +} diff -u b/core/modules/file/tests/src/Kernel/Formatter/FileVideoFormatterTest.php b/core/modules/file/tests/src/Kernel/Formatter/FileVideoFormatterTest.php --- b/core/modules/file/tests/src/Kernel/Formatter/FileVideoFormatterTest.php +++ b/core/modules/file/tests/src/Kernel/Formatter/FileVideoFormatterTest.php @@ -18,21 +18,29 @@ class FileVideoFormatterTest extends KernelTestBase { /** + * The entity type. + * * @var string */ protected $entityType; /** + * The bundle type. + * * @var string */ protected $bundle; /** + * The field name. + * * @var string */ protected $fieldName; /** + * The view display. + * * @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface */ protected $display; @@ -86,8 +94,7 @@ ]); $this->display->setComponent($this->fieldName, [ 'type' => 'file_video', - 'settings' => [ - ], + 'settings' => [], ]); $this->display->save(); @@ -103,12 +110,14 @@ 'uri' => 'public://file.mp4', 'filename' => 'file.mp4', ]); - $file-> save(); + $file->save(); $entity = EntityTest::create([ - $this->fieldName => [[ - 'target_id' => $file->id(), - ],], + $this->fieldName => [ + [ + 'target_id' => $file->id(), + ], + ], ]); $entity->save(); @@ -136 +145 @@ -} \ No newline at end of file +}