Verified Commit e2aeff00 authored by Dave Long's avatar Dave Long
Browse files

Issue #3364774 by kim.pepper: BrokenPostRequestException incorrectly typehints size as string

parent b9d2e855
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\Core\Form\Exception;

use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -12,36 +14,36 @@ class BrokenPostRequestException extends BadRequestHttpException {
  /**
   * The maximum upload size.
   *
   * @var string
   * @var int
   */
  protected $size;
  protected int $size;

  /**
   * Constructs a new BrokenPostRequestException.
   *
   * @param string $max_upload_size
   *   The size of the maximum upload size.
   * @param int $max_upload_size
   *   The size of the maximum upload size in bytes.
   * @param string $message
   *   The internal exception message.
   * @param \Exception $previous
   * @param \Exception|null $previous
   *   The previous exception.
   * @param int $code
   *   The internal exception code.
   */
  public function __construct($max_upload_size, $message = '', \Exception $previous = NULL, $code = 0) {
  public function __construct(int $max_upload_size, string $message = '', \Exception $previous = NULL, int $code = 0) {
    parent::__construct($message, $previous, $code);

    $this->size = $max_upload_size;
  }

  /**
   * Returns the maximum upload size.
   * Returns the maximum upload size in bytes.
   *
   * @return string
   *   A translated string representation of the size of the file size limit
   *   based on the PHP upload_max_filesize and post_max_size.
   * @return int
   *   The file size limit in bytes based on the PHP upload_max_filesize and
   *   post_max_size.
   */
  public function getSize() {
  public function getSize(): int {
    return $this->size;
  }

+4 −4
Original line number Diff line number Diff line
@@ -1399,11 +1399,11 @@ protected function buttonWasClicked($element, FormStateInterface &$form_state) {
  /**
   * Wraps file_upload_max_size().
   *
   * @return string
   *   A translated string representation of the size of the file size limit
   *   based on the PHP upload_max_filesize and post_max_size.
   * @return int
   *   The file size limit in bytes based on the PHP upload_max_filesize and
   *   post_max_size.
   */
  protected function getFileUploadMaxSize() {
  protected function getFileUploadMaxSize(): int {
    return Environment::getUploadMaxSize();
  }