Input with default values cannot be non-null

@param AbstractAnnotation $annotation
422129
final protected function nonNullIfHasDefault(AbstractAnnotation $annotation): void
    {
        $type = $annotation->getTypeInstance();
        if ($type instanceof NonNull && $annotation->hasDefaultValue()) {
            $annotation->setTypeInstance($type->getWrappedType());
        }
    }
698644
public function getJsonArray($annotation, $default = []) {
        $str = $this->getString($annotation);
        if (is_array($str)) {
            $rst = [];
            foreach ($str as $s) {
                $ss = preg_split('/\s+/', $s, 2);
                if (count($ss) == 2) {
                    list($k, $v) = $ss;
                } else {
                    $k = $ss[0];
                    $v = 1;
                }
                $rst[ $k ] = $v;
            }

            return $rst;
        }
        if ($str) {
            $str = trim($str);
            if (preg_match('#^[\[\{](.*)[\}\]]$#', $str)) {
                $rst = json_decode($str, true);
                if ($rst) {
                    return $rst;
                } else {
                    trigger_error($str . ' ' . json_last_error_msg(), E_USER_WARNING);
                }
            } else {
                @parse_str($str, $rst);
                if ($rst) {
                    return $rst;
                }
                trigger_error($str . ' Syntax error', E_USER_WARNING);
            }
        }

        return $default;
    }
705424
protected function getValidatorInstance(string $annotation)
    {
        if (preg_match("/([a-zA-Z0-9_\\\\]+)\\((.*)\\)/", $annotation, $matches))
        {
            $classname = $matches[1];
            $params = $matches[2];
            $in_quote = false;
            $out_quote = false;
            $escaped = false;
            $current_arg = '';

            $args = [];

            for ($i = 0; $i < strlen($params); ++$i)
            {
                $ch = substr($params, $i, 1);
                if ($ch === '"')
                {
                    if ($in_quote)
                    {
                        if ($escaped)
                        {
                            $escaped = false;
                            $current_arg = substr($current_arg, 0, -1) . '"';
                        }
                        else
                        {
                            $in_quote = false;
                            $out_quote = true;
                        }
                    }
                    else if ($out_quote)
                    {
                        throw new BinderException("Unexpected quote on $i in $params");
                    }
                    else
                    {
                        $in_quote = true;
                    }
                    continue;
                }

                if ($ch === '\\' && $in_quote)
                {
                    $escaped = true;
                }
                else if ($escaped)
                {
                    $escaped = false;
                }

                if (!$in_quote && ($ch === ' ' || $ch === "\t"))
                    continue;

                if (!$in_quote && $ch === ',')
                {
                    $args[] = $current_arg;
                    $current_arg = '';
                    $out_quote = false;
                }
                else
                {
                    $current_arg .= $ch;
                }
            }

            if (!empty($current_arg))
            {
                $args[] = $current_arg;
            }

            if ($in_quote)
            {
                throw new BinderException("Invalid syntax - expected '\"'");
            }
        }
        else
        {
            $classname = trim($annotation);
            $args = [];
        }

        if (!class_exists($classname))
            throw new BinderException("Validator class does not exist: $classname");

        if (!is_a($classname, Validator::class, true))
            throw new BinderException("Invalid validator class: $classname");

        $refl = new ReflectionClass($classname);
        $construct = $refl->getConstructor();
        
        $params = $construct->getParameters();
        $param_names = [];
        foreach ($params as $param)
            $param_names[] = $param->getName();

        if (count($args) !== count($param_names))
        {
            throw new BinderException(
                "Invalid amount of arguments for validator constructor: " 
                . count($args) . " given but " . count($param_names) . " required"
            );
        }

        $args = array_combine($param_names, $args);
        return DI::getInjector()->newInstance($classname, $args);
    }
484864
protected function annotationToArray($annotation)
    {
        $options = array();
        foreach ((array) $annotation as $key => $value) {
            if ($value !== null) {
                $options[$key] = $value;
            }
        }

        return $options;
    }
378071
private function isUniqueAnnotation($properties, $annotation)
    {
        foreach ($properties as $property) {
            if ($property['annotation'] == $annotation) {
                return false;
            }
        }

        return true;
    }
1305688
protected function createAttributeByProperty(AttributeAnnotation $annotation, \ReflectionProperty $property): Attribute
    {
        $name = ($annotation->name === null)
            ? $property->getName()
            : $annotation->name;

        $getter = ($annotation->getter === null)
            ? $this->resolveGetter($property)
            : $annotation->getter;

        $setter = ($annotation->setter === null)
            ? $this->resolveSetter($property)
            : $annotation->setter;

        $attribute = new Attribute($name, $getter);
        $attribute->setPropertyName($property->getName());

        if ($setter !== null) {
            $attribute->setSetter($setter);
        }

        $this->processAttributeOptions($annotation, $attribute);

        return $attribute;
    }
540047
public static function arrayValue($annotation)
    {
        $annotation = trim($annotation);
        $openingBrace = substr($annotation, 0, 1);

        // json-style data format
        if (in_array($openingBrace, ['{', '['])) {
            return json_decode($annotation, true);
        }

        // doctrine-style data format
        if ($openingBrace === '(') {
            preg_match_all('~(\w+)\s*?=\s*?"(.*?)"\s*?[,)]~', $annotation, $matches, PREG_SET_ORDER);
            $data = [];
            foreach ($matches as $item) {
                $data[$item[1]] = $item[2];
            }
            return $data;
        }
        return null;
    }
36903
protected function createAnnotationObjects(array $annotations)
    {
        $objects     = array();

        //var_dump($annotations);

        foreach ($annotations as $name => $args) {
            $name = ucfirst($name);
            $class = $this->defaultNamespace . $name . 'Annotation';

            if (in_array(strtolower($name), self::getExcludeAnnotationList())) {
                continue;
            }

            if (! array_key_exists($class, $objects)) {
                if (!class_exists($class)) {
                    if ($this->strict) {
                        throw new \Exception(sprintf('Annotation Class Not Found: %s', $class));
                    } else {
                        continue;
                    }
                }

                $objects[$name] = new $class();
            }
            //var_dump($args);
            foreach ($args as $key => $value) {
                $objects[$name]->set($key, $value);
            }
        }

        return $objects;
    }
190660
private function nested($annotation, $nestedContext)
    {
        if (property_exists($annotation, '_context') && $annotation->_context === $this->_context) {
            $annotation->_context = $nestedContext;
        }
        return $annotation;
    }
294037
public String mapValidationAnnotation(String annotation, String defaultAnnotation) {
		String key = "validation.annotation." + toFirstUpper(annotation);
		if (hasProperty(key)) {
			return getProperty(key);
		} else {
			return defaultAnnotation;
		}
	}
994411
public void setDefaults(Annotation[] defaultAnnotations) {
        if (defaultAnnotations == null) {
            return;
        }
        for (Annotation each : defaultAnnotations) {
            Class<? extends Annotation> key = each.annotationType();
            if (Title.class.equals(key) || Description.class.equals(key)) {
                continue;
            }
            if (!annotations.containsKey(key)) {
                annotations.put(key, each);
            }
        }
    }
368565
public static function parseDays(string $annotation)
	{
		static $validValues = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun',];

		$days = NULL;
		$annotation = Strings::trim($annotation);
		if (Strings::length($annotation)) {
			$days = static::translateToDayNames($annotation);
			$days = static::expandDaysRange($days);
			foreach ($days as $day) {
				if (!in_array($day, $validValues)) {
					throw new InvalidParameterException(
						"Given day parameter '" . $day . "' must be one from " . implode(', ', $validValues) . "."
					);
				}
			}
			$days = array_values(array_intersect($validValues, $days));
		}

		return $days ?: NULL;
	}
930885
public static function parseSimpleAnnotationValue($annotation, $docComment)
    {
        $matches = [];
        preg_match("#@$annotation\\s+([^\\s]+)#", $docComment, $matches);
        return !empty($matches) ? $matches[1] : null;
    }
199421
public function matches(AbstractAnnotation $annotation) {
		if (!$annotation instanceof self) {
			return false;
		}
		$methodName = substr($annotation->getMethod(), 0, strpos($annotation->getMethod(), '('));
		if ($methodName !== substr($this->method, 0, strpos($this->method, '('))) {
			return false;
		}

		return true;
	}
1203691
private function checkDifferentAnnotations(Annotation $annotation, $linesCount)
    {
        if ($linesCount === 1) {
            return;
        }

        $this->phpcsFile->addError(
            \sprintf('Expected 1 lines between different annotations types, found %d.', $linesCount),
            $annotation->getStartPointer(),
            'LineBetweenDifferentTags'
        );
    }
546144
private function loadAnnotations(array $annotations)
    {
        $definition = [];

        foreach ($annotations as $annotation) {
            if ($annotation instanceof Alias) {
                $definition['alias'] = $annotation->alias;
            } elseif ($annotation instanceof Type) {
                $definition['type'] = $annotation->type;
            } elseif ($annotation instanceof Expose) {
                $definition['expose'] = true;
            } elseif ($annotation instanceof Exclude) {
                $definition['exclude'] = true;
            } elseif ($annotation instanceof Readable) {
                $definition['readable'] = $annotation->readable;
            } elseif ($annotation instanceof Writable) {
                $definition['writable'] = $annotation->writable;
            } elseif ($annotation instanceof Accessor) {
                $definition['accessor'] = $annotation->accessor;
            } elseif ($annotation instanceof Mutator) {
                $definition['mutator'] = $annotation->mutator;
            } elseif ($annotation instanceof Since) {
                $definition['since'] = $annotation->version;
            } elseif ($annotation instanceof Until) {
                $definition['until'] = $annotation->version;
            } elseif ($annotation instanceof MaxDepth) {
                $definition['max_depth'] = $annotation->maxDepth;
            } elseif ($annotation instanceof Groups) {
                $definition['groups'] = $annotation->groups;
            } elseif ($annotation instanceof XmlAttribute) {
                $definition['xml_attribute'] = true;
            } elseif ($annotation instanceof XmlValue) {
                $definition['xml_value'] = true;
            } elseif ($annotation instanceof XmlCollection) {
                if ($annotation->entry !== null) {
                    $definition['xml_entry'] = $annotation->entry;
                }

                if ($annotation->entryAttribute !== null) {
                    $definition['xml_entry_attribute'] = $annotation->entryAttribute;
                }

                if ($annotation->keyAsAttribute !== null) {
                    $definition['xml_key_as_attribute'] = $annotation->keyAsAttribute;
                }

                if ($annotation->keyAsNode !== null) {
                    $definition['xml_key_as_node'] = $annotation->keyAsNode;
                }

                if ($annotation->inline !== null) {
                    $definition['xml_inline'] = $annotation->inline;
                }
            }
        }

        return $definition;
    }
1183379
public static function unserializeAnnotations($annotations)
    {
        $returnValue = array();

        
        $matches = array();
        $encoding = self::getApplicationHelper()->getDefaultEncoding();
        
        if (preg_match_all('/(#[\.\:,\|]{0,1}\s+(?:[^\\n]*))/', $annotations, $matches) !== false){
            if (isset($matches[1]) && count($matches[1]) > 0){
                foreach ($matches[1] as $match){
                    $match = trim($match);
                    $matchLen = mb_strlen($match, $encoding);
                    $annotationId = null;
                    $annotationValue = null;
                    
                    switch (mb_substr($match, 1, 1, $encoding)){
                        case "\t":
                        case ' ':
                            // Translator comment.
                            $annotationId = tao_helpers_translation_POTranslationUnit::TRANSLATOR_COMMENTS;
                            $annotationValue = mb_substr($match, 2, $matchLen - 2, $encoding);
                        break;
                        
                        case '.':
                            $annotationId = tao_helpers_translation_POTranslationUnit::EXTRACTED_COMMENTS;
                            $annotationValue = mb_substr($match, 3, $matchLen - 3, $encoding);
                        break;
                        
                        case ':':
                            $annotationId = tao_helpers_translation_POTranslationUnit::REFERENCE;
                            $annotationValue = mb_substr($match, 3, $matchLen - 3, $encoding);
                        break;
                        
                        case ',':
                            $annotationId = tao_helpers_translation_POTranslationUnit::FLAGS;
                            $annotationValue = mb_substr($match, 3, $matchLen - 3, $encoding);
                        break;
                        
                        case '|':
                            if (($pos = mb_strpos($match, 'msgid_plural', 0, $encoding)) !== false){
                                $pos += mb_strlen('msgid_plural', $encoding) + 1;
                                $annotationId = tao_helpers_translation_POTranslationUnit::PREVIOUS_MSGID_PLURAL;
                                $annotationValue = mb_substr($match, $pos, $matchLen - $pos, $encoding);
                            }
                            else if(($pos = mb_strpos($match, 'msgid', 0, $encoding)) !== false){
                                $pos += mb_strlen('msgid', $encoding) + 1;
                                $annotationId = tao_helpers_translation_POTranslationUnit::PREVIOUS_MSGID;
                                $annotationValue = mb_substr($match, $pos, $matchLen - $pos, $encoding);
                            }
                            else if(($pos = mb_strpos($match, 'msgctxt', 0, $encoding)) !== false){
                                $pos += mb_strlen('msgctxt', $encoding) + 1;
                                $annotationId = tao_helpers_translation_POTranslationUnit::PREVIOUS_MSGCTXT;
                                $annotationValue = mb_substr($match, $pos, $matchLen - $pos, $encoding);
                            }
                        break;
                    }
                    
                    if ($annotationId != null && $annotationValue != null){
                        if (!isset($returnValue[$annotationId])){
                            $returnValue[$annotationId] = $annotationValue;
                        }
                        else{
                            $returnValue[$annotationId] .= "\n${annotationValue}";
                        }
                    }
                }
            }
            
        }
        else{
            throw new tao_helpers_translation_TranslationException("An error occured while unserializing annotations '${annotations}'.");
        }
        

        return (array) $returnValue;
    }