mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 02:28:35 +08:00 
			
		
		
		
	array union in controllers
! fix issue when handling parameter with string type, add according test
This commit is contained in:
		| @ -217,6 +217,9 @@ class Controller extends \yii\base\Controller | |||||||
|                 return ['', true]; |                 return ['', true]; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             if ($typeName === 'string') { | ||||||
|  |                 return [$param, true]; | ||||||
|  |             } | ||||||
|             $filterResult = $this->filterParamByType($param, $typeName); |             $filterResult = $this->filterParamByType($param, $typeName); | ||||||
|             return [$filterResult, $filterResult !== null]; |             return [$filterResult, $filterResult !== null]; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -235,16 +235,17 @@ class ControllerTest extends TestCase | |||||||
|  |  | ||||||
|         $aksi1 = new InlineAction('aksi1', $this->controller, 'actionAksi1'); |         $aksi1 = new InlineAction('aksi1', $this->controller, 'actionAksi1'); | ||||||
|  |  | ||||||
|         $params = ['foo' => '100', 'bar' => null, 'true' => 'on', 'false' => 'false']; |         $params = ['foo' => '100', 'bar' => null, 'true' => 'on', 'false' => 'false', 'string' => 'strong']; | ||||||
|         list($foo, $bar, $true, $false) = $this->controller->bindActionParams($aksi1, $params); |         list($foo, $bar, $true, $false, $string) = $this->controller->bindActionParams($aksi1, $params); | ||||||
|         $this->assertSame(100, $foo); |         $this->assertSame(100, $foo); | ||||||
|         $this->assertSame(null, $bar); |         $this->assertSame(null, $bar); | ||||||
|         $this->assertSame(true, $true); |         $this->assertSame(true, $true); | ||||||
|         $this->assertSame(false, $false); |         $this->assertSame(false, $false); | ||||||
|  |         $this->assertSame('strong', $string); | ||||||
|  |  | ||||||
|         // allow nullable argument to be set to empty string (as null) |         // allow nullable argument to be set to empty string (as null) | ||||||
|         // https://github.com/yiisoft/yii2/issues/18450 |         // https://github.com/yiisoft/yii2/issues/18450 | ||||||
|         $params = ['foo' => 100, 'bar' => '', 'true' => true, 'false' => true]; |         $params = ['foo' => 100, 'bar' => '', 'true' => true, 'false' => true, 'string' => 'strong']; | ||||||
|         list(, $bar) = $this->controller->bindActionParams($aksi1, $params); |         list(, $bar) = $this->controller->bindActionParams($aksi1, $params); | ||||||
|         $this->assertSame(null, $bar); |         $this->assertSame(null, $bar); | ||||||
|  |  | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ class FakePhp7Controller extends Controller | |||||||
| { | { | ||||||
|     public $enableCsrfValidation = false; |     public $enableCsrfValidation = false; | ||||||
|  |  | ||||||
|     public function actionAksi1(int $foo, ?float $bar, bool $true, bool $false) |     public function actionAksi1(int $foo, ?float $bar, bool $true, bool $false, string $string) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Chris Reichel
					Chris Reichel