for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fiv\Form\Element;
/**
* Class TextArea
* Generate
* ```html
* <input type="checkbox" name="languages[]" value="en">
* <input type="checkbox" name="languages[]" value="ru">
* ```
* html tags
*
* @author Ivan Shcherbak <[email protected]>
* @package Fiv\Form
*/
class CheckboxList extends \Fiv\Form\Element\Multiple {
* @param array|string $data
* @return $this
public function setValue($data) {
if (!is_array($data)) {
$data = (array) $data;
}
foreach ($data as $i => $value) {
# remove invalid values
if (!isset($this->options[$value])) {
unset($data[$i]);
$this->value = array_values($data);
array_values($data)
array<integer,?>
null|string
$value
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
return $this;
* Alias of setValue
* @param string[] $values
public function setChecked($values) {
return $this->setValue($values);
* @return string
public function render() {
$html = '';
$currentValues = $this->getValue();
$attributes = $this->attributes;
$attributes['type'] = 'checkbox';
$name = $this->getName();
foreach ($this->options as $value => $text) {
$attributes['value'] = $value;
$attributes['name'] = $name . '[]';
if (in_array($value, $currentValues)) {
$attributes['checked'] = 'checked';
} else {
unset($attributes['checked']);
$html .= '<label>' . static::tag('input', $attributes) . $text . '</label>';
return $html;
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..