ソースを参照

remove short array syntax

euromark 11 年 前
コミット
93a7ee4d16
2 ファイル変更29 行追加29 行削除
  1. 14 14
      Lib/View/StringTemplate.php
  2. 15 15
      Test/Case/Lib/View/StringTemplateTest.php

+ 14 - 14
Lib/View/StringTemplate.php

@@ -28,10 +28,10 @@ class StringTemplate {
  *
  * @var array
  */
-	protected $_defaultConfig = [
+	protected $_defaultConfig = array(
 		'attribute' => '{{name}}="{{value}}"',
 		'compactAttribute' => '{{name}}="{{value}}"',
-	];
+	);
 
 	protected $_config;
 
@@ -149,14 +149,14 @@ class StringTemplate {
 
 		$template = $this->config($name);
 		if ($template === null) {
-			return $this->_compiled[$name] = [null, null];
+			return $this->_compiled[$name] = array(null, null);
 		}
 
 		preg_match_all('#\{\{(\w+)\}\}#', $template, $matches);
-		return $this->_compiled[$name] = [
+		return $this->_compiled[$name] = array(
 			str_replace($matches[0], '%s', $template),
 			$matches[1]
-		];
+		);
 	}
 
 /**
@@ -206,13 +206,13 @@ class StringTemplate {
  */
 	public function formatAttributes($options, $exclude = null) {
 		$insertBefore = ' ';
-		$options = (array)$options + ['escape' => true];
+		$options = (array)$options + array('escape' => true);
 
 		if (!is_array($exclude)) {
 			$exclude = array();
 		}
 
-		$exclude = ['escape' => true, 'idPrefix' => true] + array_flip($exclude);
+		$exclude = array('escape' => true, 'idPrefix' => true) + array_flip($exclude);
 		$escape = $options['escape'];
 		$attributes = array();
 
@@ -239,26 +239,26 @@ class StringTemplate {
 			$value = implode(' ', $value);
 		}
 		if (is_numeric($key)) {
-			return $this->format('compactAttribute', [
+			return $this->format('compactAttribute', array(
 				'name' => $value,
 				'value' => $value
-			]);
+			));
 		}
-		$truthy = [1, '1', true, 'true', $key];
+		$truthy = array(1, '1', true, 'true', $key);
 		$isMinimized = in_array($key, $this->_compactAttributes);
 		if ($isMinimized && in_array($value, $truthy, true)) {
-			return $this->format('compactAttribute', [
+			return $this->format('compactAttribute', array(
 				'name' => $key,
 				'value' => $key
-			]);
+			));
 		}
 		if ($isMinimized) {
 			return '';
 		}
-		return $this->format('attribute', [
+		return $this->format('attribute', array(
 			'name' => $key,
 			'value' => $escape ? h($value) : $value
-		]);
+		));
 	}
 
 }

+ 15 - 15
Test/Case/Lib/View/StringTemplateTest.php

@@ -19,9 +19,9 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testConstructorAdd() {
-		$templates = [
+		$templates = array(
 			'link' => '<a href="{{url}}">{{text}}</a>'
-		];
+		);
 		$template = new StringTemplate($templates);
 		debug($template->config('link'));
 		$this->assertEquals($templates['link'], $template->config('link'));
@@ -33,9 +33,9 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testAdd() {
-		$templates = [
+		$templates = array(
 			'link' => '<a href="{{url}}">{{text}}</a>'
-		];
+		);
 		$result = $this->template->add($templates);
 		$this->assertSame(
 			$this->template,
@@ -52,9 +52,9 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testRemove() {
-		$templates = [
+		$templates = array(
 			'link' => '<a href="{{url}}">{{text}}</a>'
-		];
+		);
 		$this->template->add($templates);
 		$this->assertNull($this->template->remove('link'), 'No return');
 		$this->assertNull($this->template->config('link'), 'Template should be gone.');
@@ -66,9 +66,9 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testFormat() {
-		$templates = [
+		$templates = array(
 			'link' => '<a href="{{url}}">{{text}}</a>'
-		];
+		);
 		$this->template->add($templates);
 
 		$result = $this->template->format('not there', []);
@@ -112,14 +112,14 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testFormatAttributesCompact() {
-		$attrs = ['disabled' => true, 'selected' => 1, 'checked' => '1', 'multiple' => 'multiple'];
+		$attrs = array('disabled' => true, 'selected' => 1, 'checked' => '1', 'multiple' => 'multiple');
 		$result = $this->template->formatAttributes($attrs);
 		$this->assertEquals(
 			' disabled="disabled" selected="selected" checked="checked" multiple="multiple"',
 			$result
 		);
 
-		$attrs = ['disabled' => false, 'selected' => 0, 'checked' => '0', 'multiple' => null];
+		$attrs = array('disabled' => false, 'selected' => 0, 'checked' => '0', 'multiple' => null);
 		$result = $this->template->formatAttributes($attrs);
 		$this->assertEquals(
 			'',
@@ -133,22 +133,22 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testFormatAttributes() {
-		$attrs = ['name' => 'bruce', 'data-hero' => '<batman>'];
+		$attrs = array('name' => 'bruce', 'data-hero' => '<batman>');
 		$result = $this->template->formatAttributes($attrs);
 		$this->assertEquals(
 			' name="bruce" data-hero="&lt;batman&gt;"',
 			$result
 		);
 
-		$attrs = ['escape' => false, 'name' => 'bruce', 'data-hero' => '<batman>'];
+		$attrs = array('escape' => false, 'name' => 'bruce', 'data-hero' => '<batman>');
 		$result = $this->template->formatAttributes($attrs);
 		$this->assertEquals(
 			' name="bruce" data-hero="<batman>"',
 			$result
 		);
 
-		$attrs = ['name' => 'bruce', 'data-hero' => '<batman>'];
-		$result = $this->template->formatAttributes($attrs, ['name']);
+		$attrs = array('name' => 'bruce', 'data-hero' => '<batman>');
+		$result = $this->template->formatAttributes($attrs, array('name'));
 		$this->assertEquals(
 			' data-hero="&lt;batman&gt;"',
 			$result
@@ -161,7 +161,7 @@ class StringTemplateTest extends CakeTestCase {
  * @return void
  */
 	public function testFormatAttributesArray() {
-		$attrs = ['name' => ['bruce', 'wayne']];
+		$attrs = array('name' => array('bruce', 'wayne'));
 		$result = $this->template->formatAttributes($attrs);
 		$this->assertEquals(
 			' name="bruce wayne"',