yii\db\BaseActiveRecord::getDirtyAttributes PHP Method

getDirtyAttributes() public method

The comparison of new and old values is made for identical values using ===.
public getDirtyAttributes ( string[] | null $names = null ) : array
$names string[] | null the names of the attributes whose values may be returned if they are changed recently. If null, [[attributes()]] will be used.
return array the changed attribute values (name-value pairs)
    public function getDirtyAttributes($names = null)
    {
        if ($names === null) {
            $names = $this->attributes();
        }
        $names = array_flip($names);
        $attributes = [];
        if ($this->_oldAttributes === null) {
            foreach ($this->_attributes as $name => $value) {
                if (isset($names[$name])) {
                    $attributes[$name] = $value;
                }
            }
        } else {
            foreach ($this->_attributes as $name => $value) {
                if (isset($names[$name]) && (!array_key_exists($name, $this->_oldAttributes) || $value !== $this->_oldAttributes[$name])) {
                    $attributes[$name] = $value;
                }
            }
        }
        return $attributes;
    }