Files
yii2/tests/framework/models/JsonModel.php
2025-10-14 12:37:35 +03:00

55 lines
930 B
PHP

<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/
namespace yiiunit\framework\models;
use JsonSerializable;
use ReturnTypeWillChange;
use yii\base\DynamicModel;
/**
* JSON serializable model for tests.
*
* {@inheritdoc}
*/
class JsonModel extends DynamicModel implements JsonSerializable
{
/**
* @var array
*/
public $data = ['json' => 'serializable'];
/**
* @return array
*/
#[ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->data;
}
/**
* @inheritdoc
*/
public function init(): void
{
$this->defineAttribute('name');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
['name', 'required'],
['name', 'string', 'max' => 100]
];
}
}