Clean data types for zend generator
@param string|null $type
@return string|null
332630
protected function cleanZendType(?string $type): ?string
    {
        if (!$type || strtolower($type) == 'null') {
            return null;
        }
        if (strtolower($type) == 'array') {
            return 'array';
        }
        if (strpos('\\', $type)) {
            return '\\' . $type;
        }
        return $type;
    }
576236
static public function instance($type=null)
    {
        $type = $type ?: 'default';
        if (!isset(static::$instances[$type])) {
            $options = ['type' => $type];
            static::$instances[$type] = new static($options);
        }
        return static::$instances[$type];
    }
673207
public function clear($type = null)
    {
        if (is_null($type)) {
            $_SESSION[$this->key] = [];
        } else {
            unset($_SESSION[$this->key][$type]);
        }

        return $this;
    }
76232
protected function getTypeByCode($type)
    {
        switch ($type) {
            case self::BOOLEAN:
                return 'boolean';
            case self::INT:
                return 'int';
            case self::FLOAT:
                return 'float';
            case self::STRING:
                return 'string';
            case self::DATE:
                return 'date';
            case self::OBJECT:
                return 'object';
            case self::XML:
                return 'xml';
            case self::DATA:
                return 'data';
            case self::DATA_ARRAY:
                return 'array';

            default:
                return null;
        }
    }
573643
function remove_type($type=null)
    {
        if (!isset($type)) {
            $this->mime_types = array();
            return;
        }
        $slash_pos = strpos($type, '/');
        if (!$slash_pos) return;

        $type_info = array('last_match'=>false, 'wildcard'=>false, 'type'=>$type);
        if (substr($type, $slash_pos) == '/*') {
            $type_info['wildcard'] = true;
            $type_info['type'] = substr($type, 0, $slash_pos);
        }
        $this->scan(array(&$this, '_remove_type_callback'), $type_info);
    }
91273
public static function getTypeName($type)
    {
        return isset(self::$names[$type])
            ? self::$names[$type]
            : null;
    }
326707
public function type($type = null)
    {
        if (!func_num_args()) {
            return $this->_type;
        }
        $this->_type = $type;
        return $this;
    }
223389
public function pop($type): ?\stdClass
    {
        $text = array_shift($this->getMessagesStore()[$type]);
        if ($text) {
            $message = new \stdClass();
            $message->text = $text;
            $message->type = $type;
            return $message;
        }
        return null;
    }
1150582
public function getUnits($type = null)
    {
        if (!isset($type)) {
            return $this->units;
        }

        $filtered = array();
        foreach ($this->units as $key => $value) {
            if (isset($value['type']) && $value['type'] === $type) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
775042
public function copy($type = null)
    {
        $builder = new Builder($this->type, $this->dogmatist, $this->parent, $this->strict);
        $this->copyData($builder);

        if ($type !== null) {
            $builder->setType($type);
        }

        return $builder;
    }
1202323
public static function getTypeName($type = null)
    {
        $result = [
            Item::TYPE_PERMISSION => 'Permission',
            Item::TYPE_ROLE => 'Role',
        ];
        if ($type === null) {
            return $result;
        }

        return $result[$type];
    }
923016
public static function get($type = null) {
        return is_null($type) ? self::$_messages : (isset(self::$_messages[$type]) ? self::$_messages[$type] : []);
    }
1312813
private static function scrubAttributes($field, $type = null)
    {
        $invalid_keys = [
            'default',
            'description',
            'label',
            'options',
        ];

        if ($type && $type ==='textarea') {
            $invalid_keys[] = 'value';
        }

        foreach ($invalid_keys as $invalid_key) {
            if (array_key_exists($invalid_key, $field)) {
                unset($field[$invalid_key]);
            }
        }
        return $field;
    }
96520
public function getImages($type = null)
    {
        if ($type) {
            if (! isset($this->imagesOfType[$type])) {
                if (count($this->images)) {
                    $this->imagesOfType[$type] = $this->images->where('image_type', $type);
                } else {
                    $this->imagesOfType[$type] = collect([]);
                }
            }

            return $this->imagesOfType[$type];
        }

        return $this->images;
    }
1084353
protected function getSessionKey($type = null)
    {
        return $this->context
             . ($this->contextSub ? '[' . $this->contextSub . ']' : null)
             . ($type ? ':' . $type : null);
    }
240495
private function getFromMemory($type)
    {
        if (isset($this->loaded[$type])) {
            return $this->loaded[$type];
        }
        return null;
    }
247314
public static function clean($input, $type)
    {
        if (!empty($input)) {
            if (!empty($type)) {
                if ($type === 'secured') {
                    return stripslashes(trim(htmlentities($input, ENT_QUOTES | ENT_HTML5, 'UTF-8')));
                } elseif ($type === 'root') {
                    return stripslashes(trim(htmlentities(htmlspecialchars(strip_tags($input), ENT_QUOTES | ENT_HTML5, 'UTF-8'), ENT_QUOTES | ENT_HTML5, 'UTF-8')));
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }