Commit c01fefe9 authored by catch's avatar catch
Browse files

Issue #3316198 by mondrake: Fix Database\Schema PHPStan-0 issues

(cherry picked from commit c42342d3)
parent 26182e85
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -605,6 +605,8 @@ abstract public function changeField($table, $field, $field_new, $spec, $keys_ne
   *
   * @throws \Drupal\Core\Database\SchemaObjectExistsException
   *   If the specified table already exists.
   * @throws \BadMethodCallException
   *   When ::createTableSql() is not implemented in the concrete driver class.
   */
  public function createTable($name, $table) {
    if ($this->tableExists($name)) {
@@ -616,6 +618,32 @@ public function createTable($name, $table) {
    }
  }

  /**
   * Generate SQL to create a new table from a Drupal schema definition.
   *
   * This method should be implemented in extending classes.
   *
   * @param string $name
   *   The name of the table to create.
   * @param array $table
   *   A Schema API table definition array.
   *
   * @return array
   *   An array of SQL statements to create the table.
   *
   * @throws \BadMethodCallException
   *   If the method is not implemented in the concrete driver class.
   *
   * @todo This method is called by Schema::createTable on the abstract class, and
   *   therefore should be defined as well on the abstract class to prevent static
   *   analysis errors. In D11, consider changing it to an abstract method, or to
   *   make it private for each driver, and ::createTable actually an abstract
   *   method here for implementation in each driver.
   */
  protected function createTableSql($name, $table) {
    throw new \BadMethodCallException(get_class($this) . '::createTableSql() not implemented.');
  }

  /**
   * Return an array of field names from an array of key/index column specifiers.
   *
+1 −9
Original line number Diff line number Diff line
@@ -81,15 +81,7 @@ protected function buildTableNameCondition($table_name, $operator = '=', $add_pr
  }

  /**
   * Generate SQL to create a new table from a Drupal schema definition.
   *
   * @param $name
   *   The name of the table to create.
   * @param $table
   *   A Schema API table definition array.
   *
   * @return string[]
   *   An array of SQL statements to create the table.
   * {@inheritdoc}
   */
  protected function createTableSql($name, $table) {
    $info = $this->connection->getConnectionOptions();
+1 −9
Original line number Diff line number Diff line
@@ -271,15 +271,7 @@ public function queryFieldInformation($table, $field, $constraint_type = 'c') {
  }

  /**
   * Generate SQL to create a new table from a Drupal schema definition.
   *
   * @param string $name
   *   The name of the table to create.
   * @param array $table
   *   A Schema API table definition array.
   *
   * @return array
   *   An array of SQL statements to create the table.
   * {@inheritdoc}
   */
  protected function createTableSql($name, $table) {
    $sql_fields = [];
+1 −9
Original line number Diff line number Diff line
@@ -44,15 +44,7 @@ public function fieldExists($table, $column) {
  }

  /**
   * Generate SQL to create a new table from a Drupal schema definition.
   *
   * @param $name
   *   The name of the table to create.
   * @param $table
   *   A Schema API table definition array.
   *
   * @return array
   *   An array of SQL statements to create the table.
   * {@inheritdoc}
   */
  public function createTableSql($name, $table) {
    if (!empty($table['primary key']) && is_array($table['primary key'])) {
+0 −5
Original line number Diff line number Diff line
@@ -170,11 +170,6 @@ parameters:
			count: 1
			path: lib/Drupal/Core/Database/Query/Merge.php

		-
			message: "#^Call to an undefined method Drupal\\\\Core\\\\Database\\\\Schema\\:\\:createTableSql\\(\\)\\.$#"
			count: 1
			path: lib/Drupal/Core/Database/Schema.php

		-
			message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
			count: 2