Skip to content
Snippets Groups Projects
Unverified Commit cf8f4990 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2959551 by quietone, kaythay, nikhil_110, alexpott, smustgrave,...

Issue #2959551 by quietone, kaythay, nikhil_110, alexpott, smustgrave, tstoeckler: Variable::export should export using short-hand array syntax
parent b03d9ab8
Branches
Tags
14 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #313456 passed with warnings
Pipeline: drupal

#313471

    Pipeline: drupal

    #313457

      ......@@ -50,16 +50,16 @@ public static function callableToString($callable): string {
      public static function export($var, $prefix = '') {
      if (is_array($var)) {
      if (empty($var)) {
      $output = 'array()';
      $output = '[]';
      }
      else {
      $output = "array(\n";
      $output = "[\n";
      // Don't export keys if the array is non associative.
      $export_keys = array_values($var) != $var;
      foreach ($var as $key => $value) {
      $output .= ' ' . ($export_keys ? static::export($key) . ' => ' : '') . static::export($value, ' ') . ",\n";
      }
      $output .= ')';
      $output .= ']';
      }
      }
      elseif (is_bool($var)) {
      ......@@ -85,6 +85,8 @@ public static function export($var, $prefix = '') {
      $output = '(object) ' . static::export((array) $var, $prefix);
      }
      else {
      // @todo var_export() does not use long array syntax. Fix in
      // https://www.drupal.org/project/drupal/issues/3476894
      $output = var_export($var, TRUE);
      }
      ......
      ......@@ -47,7 +47,7 @@ public function testExtractInvalid($value): void {
      */
      public function testExtractFail(): void {
      $this->expectException(MigrateException::class);
      $this->expectExceptionMessage("Array index missing, extraction failed for 'array(\n 'bar' => 'foo',\n)'. Consider adding a `default` key to the configuration.");
      $this->expectExceptionMessage("Array index missing, extraction failed for '[\n 'bar' => 'foo',\n]'. Consider adding a `default` key to the configuration.");
      $this->plugin->transform(['bar' => 'foo'], $this->migrateExecutable, $this->row, 'destination_property');
      }
      ......
      ......@@ -95,17 +95,17 @@ public static function providerTestExport() {
      return [
      // Array.
      [
      'array()',
      '[]',
      [],
      ],
      [
      // non-associative.
      "array(\n 1,\n 2,\n 3,\n 4,\n)",
      "[\n 1,\n 2,\n 3,\n 4,\n]",
      [1, 2, 3, 4],
      ],
      [
      // associative.
      "array(\n 'a' => 1,\n)",
      "[\n 'a' => 1,\n]",
      ['a' => 1],
      ],
      // Bool.
      ......@@ -132,12 +132,12 @@ public static function providerTestExport() {
      '\\',
      ],
      [
      // Double-quote "
      // Double-quote ".
      "'\"'",
      "\"",
      ],
      [
      // Single-quote '
      // Single-quote '.
      '"\'"',
      "'",
      ],
      ......@@ -149,7 +149,7 @@ public static function providerTestExport() {
      // Object.
      [
      // A stdClass object.
      '(object) array()',
      '(object) []',
      new \stdClass(),
      ],
      [
      ......
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Please register or to comment