replace class info
@param string $className
@param string $data
@param string $input
@return mixed
518735
public static function replaceClassInfoStr(string $className , string $data , string $input){
        return preg_replace(sprintf('/class\s*%s/' , $className) , $data , $input);
    }
479055
public function unserialise($input, $class = null)
    {
        if(!is_array($input)) {
            $input = eval("return $input;");
        }
        
        if (!is_null($class)) {
            return (new Mapper())->map($input, $class);
        }

        return $input;
    }
395571
public function replace( $string, $data ) {
		foreach ( $data as $k => $v ) {
			$string = str_replace( '${' . $k . '}', $v, $string );
		}

		return $string;
	}
215774
public function denormalize($data, $class, $format = null, array $context = array())
    {
        $allowedAttributes = $this->getAllowedAttributes($class, $context, true);
        $normalizedData = $this->prepareForDenormalization($data);

        $reflectionClass = new \ReflectionClass($class);
        $subcontext = array_merge($context, array('format' => $format));
        $object = $this->instantiateObject($normalizedData, $class, $subcontext, $reflectionClass, $allowedAttributes);

        $classMethods = get_class_methods($object);

        foreach ($normalizedData as $attribute => $value) {
            if ($this->nameConverter) {
                $attribute = $this->nameConverter->denormalize($attribute);
            }

            $allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
            $ignored = in_array($attribute, $this->ignoredAttributes);

            if (!$allowed || $ignored) {
                continue;
            }

            $setter = 'set'.ucfirst($attribute);
            if (!in_array($setter, $classMethods)) {
                continue;
            }

            $value = $this->denormalizeProperty($value, $class, $attribute, $format, $context);

            $object->$setter($value);
        }

        return $object;
    }
477560
function removeClass(element, name) {
    var oldList = classList(element),
        newList;

    if (!hasClass(element, name)) return;

    // Replace the class name.
    newList = oldList.replace(' ' + name + ' ', ' ');

    // Trim the opening and closing spaces.
    element.className = newList.substring(1, newList.length - 1);
  }
904751
protected function cleanInputData(array $input)
    {
        foreach ($input as $key => $value) {
            $const = get_called_class() . '::DIAGNOSTIC_' . strtoupper($key);
            if (defined($const)) {
                $data[constant($const)] = $value;
            }
        }
        if (empty($data)) {
            throw new StorageException('No data to insert into storage');
        }

        return $data;
    }
1254152
public static function arrayToEntity(array $data, string $className)
    {
        $attrs    = [];
        $object   = new $className();
        $entities = EntityCollector::getCollector();

        foreach ($data as $col => $value) {
            if (!isset($entities[$className]['column'][$col])) {
                continue;
            }

            $field        = $entities[$className]['column'][$col];
            $setterMethod = StringHelper::camel('set_' . $field);

            $type  = $entities[$className]['field'][$field]['type'];
            $value = self::trasferTypes($type, $value);

            if (\method_exists($object, $setterMethod)) {
                $attrs[$field] = $value;
                // 当从数据库取出来的数据不为null时，再进行模型赋值
                if ($value !== null) {
                    $object->$setterMethod($value);
                }
            }
        }
        if (\method_exists($object, 'setAttrs')) {
            $object->setAttrs($attrs);
        }

        return $object;
    }
1309566
protected static function setFilters(InputInterface $input, array $data)
    {
        $hasFilters = isset($data['filters']) && is_array($data['filters']);
        if (!$hasFilters) {
            return;
        }

        foreach ($data['filters'] as $filter) {
            $input->addFilter($filter);
        }
    }
503767
public function createModel($className, array $data)
    {
        if (empty($data)) {
            return null;
        }

        return $this->uow->createModel($className, $data);
    }
1189662
public function initialFormData($input)
    {
        if (is_array($input) && isset($input['id'])) {
            return IDEncoder::decode($input['id']);
        }

        return null;
    }
1111914
public function doParser(string $className)
    {
        if(!isset($this->data[$className]))
        {
            return;
        }
        // 类
        if(isset($this->data[$className]['class']))
        {
            foreach($this->data[$className]['class'] as $annotation)
            {
                $annotationClassName = get_class($annotation);
                if($this->hasParser($annotationClassName))
                {
                    $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_CLASS, $className);
                }
                else
                {
                    $this->one('parseComplete.' . $annotationClassName, function() use($annotationClassName, $annotation, $className){
                        $annotationClassName = get_class($annotation);
                        if($this->hasParser($annotationClassName))
                        {
                            $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_CLASS, $className);
                        }
                    });
                }
            }
            AnnotationManager::addClassAnnotations($className, ...$this->data[$className]['class']);
        }
        // 属性
        if(isset($this->data[$className]['prop']))
        {
            foreach($this->data[$className]['prop'] as $propName => $annotations)
            {
                foreach($annotations as $annotation)
                {
                    $annotationClassName = get_class($annotation);
                    if($this->hasParser($annotationClassName))
                    {
                        $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_PROPERTY, $propName);
                    }
                    else
                    {
                        $this->one('parseComplete.' . $annotationClassName, function() use($annotationClassName, $annotation, $className, $propName){
                            $annotationClassName = get_class($annotation);
                            if($this->hasParser($annotationClassName))
                            {
                                $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_PROPERTY, $propName);
                            }
                        });
                    }
                }
                AnnotationManager::addPropertyAnnotations($className, $propName, ...$annotations);
            }
        }
        // 方法
        if(isset($this->data[$className]['method']))
        {
            foreach($this->data[$className]['method'] as $methodName => $annotations)
            {
                foreach($annotations as $annotation)
                {
                    $annotationClassName = get_class($annotation);
                    if($this->hasParser($annotationClassName))
                    {
                        $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_METHOD, $methodName);
                    }
                    else
                    {
                        $this->one('parseComplete.' . $annotationClassName, function() use($annotationClassName, $annotation, $className, $methodName){
                            $annotationClassName = get_class($annotation);
                            if($this->hasParser($annotationClassName))
                            {
                                $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_METHOD, $methodName);
                            }
                        });
                    }
                }
                AnnotationManager::addMethodAnnotations($className, $methodName, ...$annotations);
            }
        }
        // 常量
        if(isset($this->data[$className]['const']))
        {
            foreach($this->data[$className]['const'] as $constName => $annotations)
            {
                foreach($annotations as $annotation)
                {
                    $annotationClassName = get_class($annotation);
                    if($this->hasParser($annotationClassName))
                    {
                        $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_CONST, $constName);
                    }
                    else
                    {
                        $this->one('parseComplete.' . $annotationClassName, function() use($annotationClassName, $annotation, $className, $constName){
                            $annotationClassName = get_class($annotation);
                            if($this->hasParser($annotationClassName))
                            {
                                $this->getParser($annotationClassName)->parse($annotation, $className, BaseParser::TARGET_CONST, $constName);
                            }
                        });
                    }
                }
                AnnotationManager::addConstantAnnotations($className, $constName, ...$annotations);
            }
        }
    }
12899
public function input($name, $value = '', $id = '', $class = '', array $attrs = array())
    {
        return '<input id="' . $id . '" class="' . $class . '" type="' . $this->_type . '" name="' . $name . '"
                          value="' . $value . '" ' . $this->buildAttrs($attrs) . '/>';
    }
1180386
public function inject($input)
    {
        Version::warn(__METHOD__ . ' is deprecated');
        $replace = array();
        foreach ($this->data as $key => $val) {
            $replace['{' . $key . '}'] = $val;
        }

        return strtr($input, $replace);
    }
257833
public function removeClass($className)
    {
        list($oldClassArray, $newClassArray) = $this->getClassArrays($className);

        $this->attributes['class'] = implode(array_diff($oldClassArray, $newClassArray), ' ');

        return $this;
    }
848577
function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
    {
        $attributeContent = $this->classAttributeContent( $classAttribute );
        $classAttributeID = $classAttribute->attribute( 'id' );
        $isMultipleSelection = false;

        if ( $http->hasPostVariable( $base . "_ezselection_ismultiple_value_" . $classAttributeID ) )
        {
            if( $http->postVariable( $base . "_ezselection_ismultiple_value_" . $classAttributeID ) != 0 )
            {
                $isMultipleSelection = true;
            }
        }

        $currentOptions = $attributeContent['options'];
        $hasPostData = false;

        if ( $http->hasPostVariable( $base . "_ezselection_option_name_array_" . $classAttributeID ) )
        {
            $nameArray = $http->postVariable( $base . "_ezselection_option_name_array_" . $classAttributeID );

            // Fill in new names for options
            foreach ( array_keys( $currentOptions ) as $key )
            {
                $currentOptions[$key]['name'] = $nameArray[$currentOptions[$key]['id']];
            }
            $hasPostData = true;

        }

        if ( $http->hasPostVariable( $base . "_ezselection_newoption_button_" . $classAttributeID ) )
        {
            $currentCount = 0;
            foreach ( $currentOptions as $option )
            {
                $currentCount = max( $currentCount, $option['id'] );
            }
            $currentCount += 1;
            $currentOptions[] = array( 'id' => $currentCount,
                                       'name' => '' );
            $hasPostData = true;

        }

        if ( $http->hasPostVariable( $base . "_ezselection_removeoption_button_" . $classAttributeID ) )
        {
            if ( $http->hasPostVariable( $base . "_ezselection_option_remove_array_". $classAttributeID ) )
            {
                $removeArray = $http->postVariable( $base . "_ezselection_option_remove_array_". $classAttributeID );

                foreach ( array_keys( $currentOptions ) as $key )
                {
                    if ( isset( $removeArray[$currentOptions[$key]['id']] ) and
                         $removeArray[$currentOptions[$key]['id']] )
                        unset( $currentOptions[$key] );
                }
                $hasPostData = true;
            }
        }

        if ( $hasPostData )
        {

            // Serialize XML
            $doc = new DOMDocument( '1.0', 'utf-8' );
            $root = $doc->createElement( "ezselection" );
            $doc->appendChild( $root );

            $options = $doc->createElement( "options" );

            $root->appendChild( $options );
            foreach ( $currentOptions as $optionArray )
            {
                unset( $optionNode );
                $optionNode = $doc->createElement( "option" );
                $optionNode->setAttribute( 'id', $optionArray['id'] );
                $optionNode->setAttribute( 'name', $optionArray['name'] );

                $options->appendChild( $optionNode );
            }

            $xml = $doc->saveXML();

            $classAttribute->setAttribute( "data_text5", $xml );

            if ( $isMultipleSelection == true )
                $classAttribute->setAttribute( "data_int1", 1 );
            else
                $classAttribute->setAttribute( "data_int1", 0 );
        }
        return true;
    }
834543
public function unserialise($input, $class = null)
    {
        $reader = Reader::createFromString($input);

        $contents = $reader->fetchAll();

        // @deprecated for the moment
        // for ($i = 0; $i < count($contents); ++$i) {
        //     if ($i <= 0) {
        //         continue;
        //     }
        //
        //     $contents[$i] = array_combine($contents[0], $contents[$i]);
        // }

        if (!is_null($class)) {
            return (new Mapper())->map($contents, $class);
        }

        return $contents;
    }
866013
private function replace(string $text = null, array $data = null)
    {
        if ($text && is_array($data) && sizeof($data) > 0 && $text && is_numeric(array_keys($data)[0])) {
            return vsprintf($text, $data);
        } elseif ($text && !is_null($data) && sizeof($data) > 0) {
            return strtr($text, $data);
        } else {
            return $text ?? null;
        }
    }