Unverified Commit b934af0a authored by Stefan Auditor's avatar Stefan Auditor
Browse files

Issue #3293533: Implement PHPStan suggestions: Unsafe usage of new static()

parent 0f17e8ef
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/**
 * Panolens drush commandfile.
 */
class PanolensCommands extends DrushCommands {
class PanolensCommands extends DrushCommands implements PanolensCommandsInterface {

  const LIBRARY_PANOLENS_VERSION = '0.11.0';

@@ -24,24 +24,20 @@ class PanolensCommands extends DrushCommands {
  const LIBRARY_DESTINATION = 'libraries';

  /**
   * Filesystem.
   *
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $fileSystem;

  /**
   * Constructs a new PanolensCommands.
   *
   * @param \Drupal\Core\File\FileSystemInterface $file_system
   *   File system.
   * {@inheritdoc}
   */
  public function __construct(FileSystemInterface $file_system) {
    parent::__construct();

    $this->fileSystem = $file_system;
  }

  /**
   * Filesystem.
   *
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $fileSystem;

  /**
   * {@inheritDoc}
   */
+20 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\panolens\Commands;

use Drupal\Core\File\FileSystemInterface;

/**
 * Provides a drush commands interface.
 */
interface PanolensCommandsInterface {

  /**
   * Constructs a new Panolens Drush command.
   *
   * @param \Drupal\Core\File\FileSystemInterface $file_system
   *   File system.
   */
  public function __construct(FileSystemInterface $file_system);

}
+3 −23
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 *   }
 * )
 */
class ImagePanoramaFormatter extends ImageFormatter {
class ImagePanoramaFormatter extends ImageFormatter implements ImagePanoramaFormatterInterface {

  /**
   * The file URL generator.
@@ -32,28 +32,7 @@ class ImagePanoramaFormatter extends ImageFormatter {
  protected $fileUrlGenerator;

  /**
   * Constructs a ImagePanoramaFormatter object.
   *
   * @param string $plugin_id
   *   The plugin_id for the formatter.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   The definition of the field to which the formatter is associated.
   * @param array $settings
   *   The formatter settings.
   * @param string $label
   *   The formatter label display setting.
   * @param string $view_mode
   *   The view mode.
   * @param array $third_party_settings
   *   Any third party settings.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param \Drupal\image\ImageStyleStorageInterface $image_style_storage
   *   The image style entity storage handler.
   * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
   *   The file URL generator.
   * {@inheritdoc}
   */
  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, ImageStyleStorageInterface $image_style_storage, FileUrlGeneratorInterface $file_url_generator) {
    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $current_user, $image_style_storage);
@@ -99,6 +78,7 @@ class ImagePanoramaFormatter extends ImageFormatter {
      $base_cache_tags = $image_style->getCacheTags();
    }

    /** @var \Drupal\file\FileInterface $file */
    foreach ($files as $delta => $file) {
      $cache_contexts = [];

+41 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\panolens\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\image\ImageStyleStorageInterface;

/**
 * Provides an image panorama formatter interface.
 */
interface ImagePanoramaFormatterInterface {

  /**
   * Constructs a ImagePanoramaFormatter object.
   *
   * @param string $plugin_id
   *   The plugin_id for the formatter.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   The definition of the field to which the formatter is associated.
   * @param array $settings
   *   The formatter settings.
   * @param string $label
   *   The formatter label display setting.
   * @param string $view_mode
   *   The view mode.
   * @param array $third_party_settings
   *   Any third party settings.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param \Drupal\image\ImageStyleStorageInterface $image_style_storage
   *   The image style entity storage handler.
   * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
   *   The file URL generator.
   */
  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, ImageStyleStorageInterface $image_style_storage, FileUrlGeneratorInterface $file_url_generator);

}
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 *   }
 * )
 */
class VideoPanoramaFormatter extends FileVideoFormatter {
class VideoPanoramaFormatter extends FileVideoFormatter implements VideoPanoramaFormatterInterface {

  /**
   * The file URL generator.
Loading