diff --git a/composer.json b/composer.json index ab11a1e..b5097ac 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "require-dev": { "maglnet/composer-require-checker": "^4.6", "php-forge/support": "dev-main", - "phpunit/phpunit": "^10.2", - "roave/infection-static-analysis-plugin": "^1.32", + "phpunit/phpunit": "10.5.3", + "roave/infection-static-analysis-plugin": "^1.34", "yii2-extensions/phpstan": "dev-main" }, "autoload": { diff --git a/infection.json.dist b/infection.json.dist index d06b334..ee3bcc3 100644 --- a/infection.json.dist +++ b/infection.json.dist @@ -5,7 +5,7 @@ ] }, "logs": { - "text": "php:\/\/stderr", + "text": "infection.log", "stryker": { "report": "main" } diff --git a/phpstan.neon b/phpstan.neon index 0b239cb..6719314 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,12 +1,12 @@ includes: - vendor/yii2-extensions/phpstan/extension.neon + parameters: + bootstrapFiles: + - tests/Support/bootstrap.php + dynamicConstantNames: - - YII_DEBUG - YII_ENV - - YII_ENV_DEV - - YII_ENV_PROD - - YII_ENV_TEST level: 2 diff --git a/src/DateTimePicker.php b/src/DateTimePicker.php index 1bd082a..15a4e42 100644 --- a/src/DateTimePicker.php +++ b/src/DateTimePicker.php @@ -4,12 +4,14 @@ namespace Yii2\Extensions\DateTimePicker; +use JsonException; use PHPForge\Html\Div; use PHPForge\Html\Helper\CssClass; -use PHPForge\Html\Input; +use PHPForge\Html\Input\Text; use PHPForge\Html\Label; use PHPForge\Html\Span; use Yii; +use yii\base\InvalidConfigException; use yii\helpers\Html; use yii\widgets\InputWidget; @@ -33,6 +35,9 @@ final class DateTimePicker extends InputWidget public int $startOfTheWeek = 1; public string $template = "{label}\n{input}\n{span}"; + /** + * @throws InvalidConfigException + */ public function init(): void { parent::init(); @@ -88,9 +93,12 @@ public function run(): string return $this->renderDateTimePicker(); } + /** + * @throws JsonException + */ private function getScript(): string { - $config = json_encode($this->config); + $config = json_encode($this->config, JSON_THROW_ON_ERROR); return <<floatingLabel ? "{input}\n{span}\n{label}" : "{input}\n{span}"; CssClass::add($containerOptions, $this->floatingLabel ? 'form-floating' : ''); @@ -137,10 +144,7 @@ private function renderDateTimePicker(): string ->dataAttributes(['td-target' => "#$this->id", 'td-toggle' => 'datetimepicker']) ->class($this->spanClass) ->content($this->icon); - $input = Input::widget() - ->attributes($this->options) - ->dataAttributes(['td-target' => "#$this->id"]) - ->type('text'); + $input = Text::widget()->attributes($this->options)->dataAttributes(['td-target' => "#$this->id"]); $input = match ($this->hasModel()) { true => $input @@ -172,6 +176,9 @@ private function renderDateTimePicker(): string }; } + /** + * @throws JsonException + */ private function registerClientScript(): void { $view = $this->getView();