We use the string type hint as our default in templates

This method will then replace those with the updated type

@param string $filePath
@param string $type
@param string $dbalType
@param bool   $isNullable
2870
public function replaceTypeHintsInFile(
        string $filePath,
        string $type,
        string $dbalType,
        bool $isNullable
    ): void {
        $contents = \ts\file_get_contents($filePath);

        $search = [
            ': string;',
            '(string $',
            ': string {',
            '@var string',
            '@return string',
            '@param string',

        ];

        $replaceNormal   = [
            ": $type;",
            "($type $",
            ": $type {",
            "@var $type",
            "@return $type",
            "@param $type",
        ];
        $replaceNullable = [
            ": ?$type;",
            "(?$type $",
            ": ?$type {",
            "@var $type|null",
            "@return $type|null",
            "@param $type|null",
        ];
        $replaceRemove   = [
            ';',
            '($',
            ' {',
            '',
            '',
            '',
        ];

        $replace = $replaceNormal;

        if (\in_array($dbalType, MappingHelper::MIXED_TYPES, true)) {
            $replace = $replaceRemove;
        } elseif ($isNullable) {
            $replace = $replaceNullable;
        }

        $contents = \str_replace(
            $search,
            $replace,
            $contents
        );

        \file_put_contents($filePath, $contents);
    }
379736
public function queue($filePath = null, string $disk = null, string $readerType = null)
    {
        if (!$this instanceof ShouldQueue) {
            throw new InvalidArgumentException('Importable should implement ShouldQueue to be queued.');
        }

        return $this->import($filePath, $disk, $readerType);
    }
455709
protected function useRelationInterfaceInEntityInterface(string $classPath, string $interfacePath): void
    {
        $entityFqn           = PhpClass::fromFile($classPath)->getQualifiedName();
        $entityInterfaceFqn  = $this->namespaceHelper->getEntityInterfaceFromEntityFqn($entityFqn);
        $entityInterfacePath = (new \ts\Reflection\ReflectionClass($entityInterfaceFqn))->getFileName();
        $entityInterface     = PhpInterface::fromFile($entityInterfacePath);
        $relationInterface   = PhpInterface::fromFile($interfacePath);
        $entityInterface->addInterface($relationInterface);
        $this->codeHelper->generate($entityInterface, $entityInterfacePath);
    }
465928
public function setFilepath($filepath)
    {
        $this->_path = pathinfo($filepath);

        if (!isset($this->_path['extension']))
            $this->_path['extension'] = null;

        return $this;
    }
172754
public function setFilePath($filePath)
    {
        $this->isURI = false;
        $this->filePath = trim($filePath);

        $this->content = null;
        return $this;
    }
735144
public static function ChangeType( $xmlType, $value, $type, $nameTable, $nsmgr )
	{
		if ( $type->TypeCode == XmlTypeCode::AnyAtomicType || $xmlType->TypeCode == $type->TypeCode )
		{
			switch ( $xmlType->TypeCode )
			{
				case XmlTypeCode::Decimal:
					$value = $value instanceof XPath2Item ? $value->getValue() : $value;
					if ( $value instanceof DecimalProxy )
					{
						$value = $value->getValue();
					}
					if ( $value instanceof DecimalValue )
					{
						$value = $value->getValue();
					}
				case XmlTypeCode::Double:
				case XmlTypeCode::Float:

					$value = $value instanceof XPath2Item ? $value->getValue() : $value;
					if ( $value instanceof DoubleProxy )
					{
						return $value;
					}

					if ( is_string( $value ) && strtoupper( $value ) == "NAN" )
					{
						$value = NAN;
					}
					else
					{
						if ($xmlType->TypeCode == XmlTypeCode::Double )
						{
							$value = doubleval( $value );
						}
						else if ( $value == INF || $value == -INF )
						{
							$value = XPath2Item::fromValueAndType( $value, $type->SchemaType );
						}
						else
						{
							// Using ::FromFloat will convert 1.2E-3 to a decimal number
							$decimal = DecimalValue::FromFloat( $value );
							$value = XPath2Item::fromValueAndType( $decimal->ToFloat( null ), $type->SchemaType );
						}
					}
					break;
			}
			return $value;
		}
		try
		{
			switch ( $xmlType->TypeCode )
			{
				case XmlTypeCode::String:
				case XmlTypeCode::UntypedAtomic:

					if ( $value instanceof UntypedAtomic )
					{
						$value = $value->getValue();
					}

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::UntypedAtomic:
							return new UntypedAtomic( $value );
						case XmlTypeCode::String:
							return $value; // ->ToString();
						case XmlTypeCode::DateTime:
							return DateTimeValue::Parse( $value );
						case XmlTypeCode::Date:
							return DateValue::Parse( $value );
						case XmlTypeCode::Time:
							return TimeValue::Parse( $value );
						case XmlTypeCode::GYearMonth:
							return GYearMonthValue::Parse( $value );
						case XmlTypeCode::GYear:
							return GYearValue::Parse( $value );
						case XmlTypeCode::GMonth:
							return GMonthValue::Parse( $value );
						case XmlTypeCode::GMonthDay:
							return GMonthDayValue::Parse( $value );
						case XmlTypeCode::GDay:
							return GDayValue::Parse( $value );
						case XmlTypeCode::Duration:
							return DurationValue::Parse( $value );
						case XmlTypeCode::Name:
							return new NameValue( $value );
						case XmlTypeCode::Token:
							return new TokenValue( $value );
						case XmlTypeCode::Language:
							return new LanguageValue( $value );
						case XmlTypeCode::NormalizedString:
							return new NormalizedStringValue( $value );
						case XmlTypeCode::Id:
							return new IDValue( $value );
						case XmlTypeCode::QName:
							if ($xmlType->TypeCode == XmlTypeCode::UntypedAtomic)
								throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
									array(
										SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
										$type
									)
								);
							if ( is_string( $value ) && empty( $value ) )
							{
								throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, $type->ItemType->getTypeName() ) );
							}
							$qname = \lyquidity\xml\qname( is_object( $value ) ? $value->ToString() : $value, $nsmgr->getNamespaces() );
							if ( is_null( $qname ) )
							{
								throw XPath2Exception::withErrorCode( "FONS0004", Resources::FONS0004 );
							}
							return QNameValue::fromQName( $qname );
						case XmlTypeCode::Notation:
							return NotationValue::Parse( $value, $nsmgr );
						case XmlTypeCode::AnyUri:
							return new AnyUriValue( $value instanceof IXmlSchemaType ? $value->getValue() : $value );
						case XmlTypeCode::NCName:

							$value = trim( $value );
							$pattern = "/^" . NameValue::$ncName . "$/u";
							if ( ! preg_match( $pattern, $value, $matches ) )
							{
								throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, "xs:NCName" ) );
							}

							return XPath2Item::fromValueAndType( $value, $type->SchemaType );

						default:

							$text = is_object( $value ) ? $value->ToString() : $value;
							$text = trim( $value );
							// $res = $type->SchemaType->Datatype->ParseValue( $text, $nameTable, $nsmgr );
							$res = $text;

							// Validate the text input
							$error = false;
							switch ( $type->TypeCode )
							{
								case $type->TypeCode == XmlTypeCode::Boolean:
									$error = is_string( $text ) && strlen( $text ) == 0;
									break;

								case $type->TypeCode == XmlTypeCode::NonPositiveInteger:
									$error = ! is_numeric( $text ) || $text + 0 > 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::NegativeInteger:
									$error = ! is_numeric( $text ) || $text + 0 >= 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::PositiveInteger:
									$error = ! is_numeric( $text ) || $text + 0 <= 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::UnsignedByte:
									$error = ! is_numeric( $text ) || $text + 0 < 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::UnsignedShort:
									$error = ! is_numeric( $text ) || $text + 0 < 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::UnsignedInt:
									$error = ! is_numeric( $text ) || $text + 0 < 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::UnsignedLong:
									$error = ! is_numeric( $text ) || $text + 0 < 0;
									if ( ! $error )
									{
										// The long value can be bigger than PHP is able to cope with.
										// A large unsigned number will appear like a double in PHP
										$error = DecimalValue::FromValue( $text )->CompareTo( "18446744073709551615" ) == 1;
									}
									break;

								case $type->TypeCode == XmlTypeCode::NonNegativeInteger:
									$error = ! is_numeric( $text ) || $text + 0 < 0 || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::Byte:
									$error = ! is_numeric( $text ) || $text + 0 < -128 || $text + 0 > 0x7f || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::Short:
									$error = ! is_numeric( $text ) || $text + 0 < (int)0xffffffffffff8000 || $text + 0 > (int)0x7fff || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::Int:
									$error = ! is_numeric( $text ) || $text + 0 < (int)0xffffffff80000000 || $text + 0 > (int)0x7fffffff || is_double( $text + 0 );
									break;

								case $type->TypeCode == XmlTypeCode::Long:
									$error = ! is_numeric( $text ) || is_double( $text + 0 ) ||
											 DecimalValue::FromValue( $text )->CompareTo( (int)0x8000000000000000 ) == -1 ||
											 DecimalValue::FromValue( $text )->CompareTo( (int)0x7fffffffffffffff ) == 1;
									break;
								case XmlTypeCode::Double:
								case XmlTypeCode::Float:

									$error = ! preg_match( "/^((-|\+)?(\d*((?=\.\d)\.\d*)?((?i)E[-\+]?\d+((?=\.\d)\.\d*)?)?)|(-?INF)|NaN)$/", trim( $value ) );
									break;
							}

							if ( $error )
							{
								throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $text, $type->ItemType->getTypeName() ) );
							}

							switch ( $type->TypeCode )
							{
								case XmlTypeCode::Decimal:

									return new DecimalValue( $text );

								case XmlTypeCode::Double:
								case XmlTypeCode::Float:

									if ( is_string( $text ) )
									{
										if ( strtoupper( $text ) == "NAN" )
											return XPath2Item::fromValueAndType( NAN, $type->SchemaType );

										if ( strtoupper( $text ) == "INF" )
											return XPath2Item::fromValueAndType( INF, $type->SchemaType );
											// return INF;

										if ( strtoupper( $text ) == "-INF" )
											return XPath2Item::fromValueAndType( -INF, $type->SchemaType );
											// return -INF;
									}

									if ( is_numeric( $text ) ) return XPath2Item::fromValueAndType( doubleval( $text ), $type->SchemaType );
									throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, $type->ItemType->getTypeName() ) );
									break;

								case XmlTypeCode::Boolean:
									$result = filter_var( $value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE );
									if ( is_null( $result ) )
									{
										throw new InvalidCastException("Cannot convert '$text' to boolean");
									}
									return $result ? CoreFuncs::$True : CoreFuncs::$False;
									// return $result;
								case XmlTypeCode::Integer:
								case XmlTypeCode::PositiveInteger:
								case XmlTypeCode::NegativeInteger:
								case XmlTypeCode::NonPositiveInteger:
								case XmlTypeCode::NonNegativeInteger:
								Case XmlTypeCode::Int:
								case XmlTypeCode::Short:
								case XmlTypeCode::Byte:
								case XmlTypeCode::UnsignedByte:
								case XmlTypeCode::UnsignedInt:
								case XmlTypeCode::UnsignedShort:
									return Integer::FromValue( $res /* Convert::ToDecimal( $res ) */ );

								case XmlTypeCode::Long:
								case XmlTypeCode::UnsignedLong:
									return Long::FromValue( $res, $type->TypeCode == XmlTypeCode::UnsignedLong );

								case XmlTypeCode::DayTimeDuration:
									return DayTimeDurationValue::Parse( $res );

								case XmlTypeCode::YearMonthDuration:
									return YearMonthDurationValue::Parse( $res );

								case XmlTypeCode::HexBinary:
									return HexBinaryValue::fromString( $res );

								case XmlTypeCode::Base64Binary:
									if ( SchemaTypes::endsWith( $res, "==" ) && ( strlen( $res ) < 3 || strpos( "AQgw", $res[ strlen( $res ) -3 ] ) == -1) )
										throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $res, $type->ItemType->getTypeName() ) );
									return Base64BinaryValue::fromString( $res );

								case XmlTypeCode::Idref:
									if ( $type->SchemaType == XmlSchema::$IDREF )
										return new IDREFValue( $res );
									if ( $type->SchemaType == XmlSchema::$IDREFS )
										return new IDREFSValue( $res );
									return $res;
								case XmlTypeCode::NmToken:
									if ( $type->SchemaType == XmlSchema::$NMTOKEN )
										return new NMTOKENValue( $res );
									if ( $type->SchemaType == XmlSchema::$NMTOKENS )
										return new NMTOKENSValue( $res );
									return $res;
								case XmlTypeCode::Entity:
									if ( $type->SchemaType->Name == "ENTITY" )
										return new ENTITYValue( $res );
									if ( $type->SchemaType == XmlSchema::$ENTITIES )
										return new ENTITIESValue( $res );
									return $res;

								default:
									return $res;
							}
					}

				case XmlTypeCode::Boolean:

					$result = ( is_bool( $value ) && $value ) || ( is_object( $value ) && $value instanceof TrueValue ) ? 1 : 0;

					// Validate the text input
					$error = false;
					switch ( $type->TypeCode)
					{
						case XmlTypeCode::NonPositiveInteger:
							$error = $result;
							break;

						case XmlTypeCode::NegativeInteger:
							$error = true;
							break;

						case XmlTypeCode::PositiveInteger:
							$error = ! $result;
							break;
					}

					if ( $error )
					{
						throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, $type->ItemType->getTypeName() ) );
					}

					switch ( $type->TypeCode)
					{
						case XmlTypeCode::NonPositiveInteger:
						case XmlTypeCode::NegativeInteger:
						case XmlTypeCode::Integer:
						case XmlTypeCode::Long:
						case XmlTypeCode::Int:
						case XmlTypeCode::Short:
						case XmlTypeCode::Byte:
						case XmlTypeCode::NonNegativeInteger:
						case XmlTypeCode::UnsignedLong:
						case XmlTypeCode::UnsignedInt:
						case XmlTypeCode::UnsignedShort:
						case XmlTypeCode::UnsignedByte:
						case XmlTypeCode::PositiveInteger:
							return Integer::FromValue( $result );
							// return XPath2Convert::ChangeObjectType( $value, $type->ItemType );

						case XmlTypeCode::Decimal:
							return DecimalValue::FromValue( $result );

						case XmlTypeCode::Double:
						case XmlTypeCode::Float:
							return $result + 0.0;

						case XmlTypeCode::String:
							return $result ? "true" : "false";

						case XmlTypeCode::UntypedAtomic:
							return new UntypedAtomic( XPath2Convert::ToString( $value ) );

						case XmlTypeCode::Language:

							return XPath2Item::fromValueAndType( $value->ToString( null ), $type->SchemaType );
					}

					break;

				case XmlTypeCode::Integer:
				case XmlTypeCode::NonPositiveInteger:
				case XmlTypeCode::NegativeInteger:
				case XmlTypeCode::Long:
				case XmlTypeCode::Int:
				case XmlTypeCode::Short:
				case XmlTypeCode::Byte:
				case XmlTypeCode::NonNegativeInteger:
				case XmlTypeCode::UnsignedLong:
				case XmlTypeCode::UnsignedInt:
				case XmlTypeCode::UnsignedShort:
				case XmlTypeCode::UnsignedByte:
				case XmlTypeCode::PositiveInteger:
				case XmlTypeCode::Decimal:
				case XmlTypeCode::Float:
				case XmlTypeCode::Double:

					if ( $value instanceof XPath2Item )
					{
						$value = $value->getTypedValue();
					}

					if ( $value instanceof IXmlSchemaType ) $value = $value->getValue();

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::String:

							return XPath2Convert::ToString( $value );

						case XmlTypeCode::UntypedAtomic:

							return new UntypedAtomic( Convert::ToString( $value ) );

						case XmlTypeCode::Boolean:

							return CoreFuncs::BooleanValue( $value );

						case XmlTypeCode::Byte:
						case XmlTypeCode::Integer:
						case XmlTypeCode::Int:
						case XmlTypeCode::Long:
						case XmlTypeCode::NegativeInteger:
						case XmlTypeCode::NonNegativeInteger:
						case XmlTypeCode::NonPositiveInteger:
						case XmlTypeCode::PositiveInteger:
						case XmlTypeCode::Short:
						case XmlTypeCode::UnsignedByte:
						case XmlTypeCode::UnsignedInt:
						case XmlTypeCode::UnsignedLong:
						case XmlTypeCode::UnsignedShort:

							if ( $value instanceof XPath2Item )
							{
								$value = $value->getTypedValue();
							}

							if ( is_numeric( $value ) )
							{
								if ( is_infinite( $value ) || is_nan( $value ) )
								{
									throw XPath2Exception::withErrorCodeAndParams( "FOCA0002", Resources::FOCA0002, array( $value, "Integer" ) );
								}

								if ( $value > PHP_INT_MAX || $value < PHP_INT_MIN )
								{
									throw XPath2Exception::withErrorCodeAndParams( "FOCA0003", Resources::FOCA0003, array( $value, "Integer" ) );
								}
							}

							return XPath2Item::fromValueAndType( Integer::FromValue( Convert::ToInt( $value ) ), $type->SchemaType );

						case XmlTypeCode::Double:

							return Convert::ToDouble( $value, null );

						case XmlTypeCode::Float:

							switch ( $xmlType->TypeCode )
							{
								case XmlTypeCode::Byte:
								case XmlTypeCode::Integer:
								case XmlTypeCode::Int:
								case XmlTypeCode::Long:
								case XmlTypeCode::NegativeInteger:
								case XmlTypeCode::NonNegativeInteger:
								case XmlTypeCode::NonPositiveInteger:
								case XmlTypeCode::PositiveInteger:
								case XmlTypeCode::Short:
								case XmlTypeCode::UnsignedByte:
								case XmlTypeCode::UnsignedInt:
								case XmlTypeCode::UnsignedLong:
								case XmlTypeCode::UnsignedShort:

									return XPath2Item::fromValueAndType( is_numeric( $value ) ? $value + 0.0 : $value, $type->SchemaType );
							}

							if ( preg_match( "/^(?<sign>[+-])?INF/i", $value, $matches ) )
							{
								return ! empty( $matches['sign'] ) && $matches['sign'] == "-" ? -INF : INF;
							}

							if ( is_numeric( $value ) && is_nan( $value ) )
							{
								return $value;
							}

							// Using ::FromFloat will convert 1.2E-3 to a decimal number
							$decimal = DecimalValue::FromFloat( $value );
							return XPath2Item::fromValueAndType( $decimal->ToFloat( null ), $type->SchemaType );

						case XmlTypeCode::Decimal:
							if ( $xmlType->TypeCode == XmlTypeCode::Decimal ) return $value;
							if ( $xmlType->TypeCode == XmlTypeCode::Double ||
								 $xmlType->TypeCode == XmlTypeCode::Float
							)
								return DecimalValue::FromFloat( $value );

							// if ( $xmlType->TypeCode == XmlTypeCode::Integer || $xmlType->TypeCode == XmlTypeCode::Int )
							return new DecimalValue( $value );

						case XmlTypeCode::AnyUri:
							throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
								array(
									SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
									$type
								)
							);
						case XmlTypeCode::YearMonthDuration:
						case XmlTypeCode::DayTimeDuration:
						case XmlTypeCode::Duration:
						case XmlTypeCode::DateTime:
						case XmlTypeCode::Time:
						case XmlTypeCode::Date:
						case XmlTypeCode::GDay:
						case XmlTypeCode::GMonth:
						case XmlTypeCode::GMonthDay:
						case XmlTypeCode::GYear:
						case XmlTypeCode::GYearMonth:
						case XmlTypeCode::Base64Binary:
						case XmlTypeCode::HexBinary:
						case XmlTypeCode::QName:

							throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004, array( $value, "Duration" ) );

						case XmlTypeCode::Language:

							throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
								array(
									$value,
									"xs:language"
								)
							);

							// return XPath2Item::fromValueAndType( $value . "", $type->SchemaType );

						default:
							return XPath2Convert::ChangeObjectType( $value, $type->ItemType );
					}

				case XmlTypeCode::DateTime:
				case XmlTypeCode::Date:
				case XmlTypeCode::Time:
				case XmlTypeCode::GDay:
				case XmlTypeCode::GMonth:
				case XmlTypeCode::GMonthDay:
				case XmlTypeCode::GYear:
				case XmlTypeCode::GYearMonth:

					if ( $type->TypeCode == $xmlType->TypeCode ) return $value;

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::DateTime:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							{
								return $value instanceof \DateTime
									? DateTimeValue::fromDate( false, $value )
									: DateTimeValue::fromDate( $value->S, $value->getValue(), ! $value->IsLocal );
							}

							break;

						case XmlTypeCode::Date:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							{
								return $value instanceof \DateTime
									? DateValue::fromDate( false, $value )
									: DateValue::fromDate( $value->S, $value->getValue(), ! $value->IsLocal );
							}

							break;

						case XmlTypeCode::Time:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Time, XmlTypeCode::DateTime ) ) )
							// if ( $xmlType->TypeCode != XmlTypeCode::Date )
							{
								return $value instanceof \DateTime
									? new TimeValue( $value )
									: new TimeValue( $value->getValue(), ! $value->IsLocal );
							}

							break;

						case XmlTypeCode::GYear:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							// if ( $xmlType->TypeCode != XmlTypeCode::Time )
							{
								return new GYearValue( $value->S, $value->getValue() );
							}

							break;

						case XmlTypeCode::GYearMonth:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							// if ( $xmlType->TypeCode != XmlTypeCode::Time )
							{
								return new GYearMonthValue( $value->S, $value->getValue() );
							}

							break;

						case XmlTypeCode::GDay:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							// if ( $xmlType->TypeCode != XmlTypeCode::Time )
							{
								return new GDayValue( $value->getValue() );
							}

							break;

						case XmlTypeCode::GMonth:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							// if ( $xmlType->TypeCode != XmlTypeCode::Time )
							{
								return new GMonthValue( $value->getValue() );
							}

							break;

						case XmlTypeCode::GMonthDay:

							if ( in_array( $xmlType->TypeCode, array( XmlTypeCode::Date, XmlTypeCode::DateTime ) ) )
							// if ( $xmlType->TypeCode != XmlTypeCode::Time )
							{
								return new GMonthDayValue( $value->getValue() );
							}

							break;

						case XmlTypeCode::UntypedAtomic:

							return new UntypedAtomic( $value->ToString( null ) );

						case XmlTypeCode::String:

							return $value->ToString( null );

						case XmlTypeCode::Language:

							throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
								array(
									$value,
									"xs:language"
								)
							);
					}

					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
						array(
							SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
							$type
						)
					);

				case XmlTypeCode::Duration:
				case XmlTypeCode::DayTimeDuration:
				case XmlTypeCode::YearMonthDuration:

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::DayTimeDuration:
							return DayTimeDurationValue::FromDuration( $value );

						case XmlTypeCode::YearMonthDuration:
							return YearMonthDurationValue::FromDuration( $value );

						case XmlTypeCode::Duration:
							return new DurationValue( $value->getValue() );

						case XmlTypeCode::UntypedAtomic:
							return new UntypedAtomic( $value->ToString( null ) );

						case XmlTypeCode::String:
							return ( $value->ToString( null ) );

						case XmlTypeCode::Language:

							throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
								array(
									$value,
									"xs:language"
								)
							);

					}

					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
						array(
							SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
							$type
						)
					);

				case XmlTypeCode::Base64Binary:

					if ( $type->TypeCode == $xmlType->TypeCode ) return $value;

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::String:

							return $value->ToString();

						case XmlTypeCode::UntypedAtomic:

							return new UntypedAtomic( $value->ToString() );

						case XmlTypeCode::HexBinary:

							return new HexBinaryValue( $value->getValue() );

						case XmlTypeCode::Language:

							throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
								array(
									$value,
									"xs:language"
								)
							);
					}

					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
						array(
							SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
							$type
						)
					);

					break;

				case XmlTypeCode::HexBinary:

					if ( $type->TypeCode == $xmlType->TypeCode ) return $value;

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::String:

							return $value->ToString();

						case XmlTypeCode::UntypedAtomic:

							return new UntypedAtomic( $value->ToString() );

						case XmlTypeCode::Base64Binary:

							return new Base64BinaryValue( $value->getValue() );

						case XmlTypeCode::Language:

							throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
								array(
									$value,
									"xs:language"
								)
							);
					}

					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
						array(
							SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
							$type
						)
					);

					break;

				case XmlTypeCode::AnyUri:

					if ( $type->TypeCode == $xmlType->TypeCode ) return $value;

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::String:

							return $value->ToString();

						case XmlTypeCode::UntypedAtomic:

							return new UntypedAtomic( $value->ToString() );

					}

					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
						array(
							SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
							$type
						)
					);

					break;

				case XmlTypeCode::QName:

					if ( $type->TypeCode == $xmlType->TypeCode ) return $value;

					switch ( $type->TypeCode )
					{
						case XmlTypeCode::String:

							return $value->ToString( null );

						case XmlTypeCode::UntypedAtomic:

							return new UntypedAtomic( $value->ToString( null ) );

						// case XmlTypeCode::Base64Binary:
						// case XmlTypeCode::HexBinary:
						case XmlTypeCode::Language:

							throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
								array(
									$value,
									"xs:language"
								)
							);

					}

					throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
						array(
							SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
							$type
						)
					);

				default:

					$convertable = $value instanceof IXmlConvertable;
					if ( $convertable )
					{
						/**
						 * @var IXmlConvertable $convert
						 */
						$convert = $value;
						return $convert->ValueAs( $type, $nsmgr );
					}
					if ( $type->TypeCode == XmlTypeCode::String)
						return XPath2Convert::ToString( $value);
					if ( $type->TypeCode == XmlTypeCode::UntypedAtomic)
						return new UntypedAtomic( XPath2Convert::ToString( $value ) );

					// Getting here is a dead end
					return $type->SchemaType->Datatype->ChangeType1( $value, $type->ValueType );
			}
		}
		catch ( XmlSchemaException $ex )
		{
			throw XPath2Exception::asDefault( $ex->getMessage(), $ex);
		}
		catch ( \InvalidArgumentException $ex )
		{
			throw XPath2Exception::asDefault( $ex->getMessage(), $ex);
		}
		catch ( InvalidCastException $ex )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001,
					array(
						SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
						$type
					)
				);
		}
		catch ( FormatException $ex )
		{
			throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::XPTY0004,
				array(
					SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
					$type
				)
			);
		}
		throw XPath2Exception::withErrorCodeAndParams("XPTY0004", Resources::XPTY0004,
			array(
				SequenceType::WithTypeCodeAndCardinality( $xmlType->TypeCode, XmlTypeCardinality::One ),
				$type
			)
		);
	}
281391
public function setNamespaceFromPath(string $filePath, string $srcSubFolderName, string $projectRootNamespace): self
    {
        $pathForNamespace = substr(
            $filePath,
            \ts\strpos(
                $filePath,
                $srcSubFolderName
            )
            + \strlen($srcSubFolderName)
            + 1
        );
        $pathForNamespace = substr($pathForNamespace, 0, strrpos($pathForNamespace, '/'));
        $namespaceToSet   = $projectRootNamespace
                            . '\\' . implode(
                                '\\',
                                explode(
                                    '/',
                                    $pathForNamespace
                                )
                            );
        $contents         = \ts\file_get_contents($filePath);
        $contents         = preg_replace(
            '%namespace[^:]+?;%',
            "namespace $namespaceToSet;",
            $contents,
            1,
            $count
        );
        if ($count !== 1) {
            throw new DoctrineStaticMetaException(
                'Namespace replace count is ' . $count . ', should be 1 when updating file: ' . $filePath
            );
        }
        file_put_contents($filePath, $contents);

        return $this;
    }
498212
public function setPathsFromOptions($optionsPath = 'AtomicKitten.Framework.build.source.framework')
    {
        $configuration = $this->objectManager->get(ConfigurationManager::class)
            ->getConfiguration(
                ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
                $optionsPath
            );

        $this->setLayoutRootPath($configuration['layouts']);
        $this->setPartialRootPath($configuration['partials']);
        $this->setTemplatePathAndFilename($configuration['templates']);
    }
1119657
public static function setDefaultMagicFile($filePath = null)
    {
        if (!is_null($filePath) && !file_exists($filePath)) {
            throw new FileNotFoundException('File does not exist or is not readable: ' . $filePath);
        }
        self::$defaultMagicFile = $filePath;
    }
22996
public function updateType($typeId, $status, Type $type)
    {
        try {
            return $this->innerGateway->updateType($typeId, $status, $type);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1222820
private function isValidUpdateType(string $updateType): void
    {
        $allowedUpdateType = $this->getAllowedUpdateType();
        if (!\in_array($updateType, $allowedUpdateType, true)) {
            throw new InvalidTypeException(sprintf(
                'updateType must be either "%s".',
                implode(', ', $allowedUpdateType)
            ));
        }
    }
962776
protected function checkFilePath($filePath)
	{
	    $filePath = rtrim($filePath, '/\\');
	    if (!is_dir($filePath)) {
			mkdir($filePath, 0755, true);
		}
        
		if (!is_writable($filePath)) {
			throw new \RuntimeException(sprintf('The base cache path `%s` is not writable.', $filePath));
		}

		return true;
	}
1072551
public static function isReferencedByOtherImageFiles( $filepath, $attributeId )
    {
        $db = eZDB::instance();
        $filepath = $db->escapeString( $filepath );

        $rows = $db->arrayQuery(
            sprintf(
                "
                SELECT count(*) as count FROM ezcontentobject_attribute
                INNER JOIN ezimagefile ON ezcontentobject_attribute.id=ezimagefile.contentobject_attribute_id
                WHERE ezimagefile.filepath='%s'
                AND ezcontentobject_attribute.id != %d
                ",
                $filepath,
                $attributeId
            )
        );

        return (int)$rows[0]['count'] > 0;
    }
1306806
public function setResultDataType($resultDataType)
    {
        if (is_string($resultDataType) && class_exists($resultDataType)) {
            $resultDataType = new $resultDataType();
        }

        if ($resultDataType instanceof DataInterface) {
            $this->resultDataType = $resultDataType;
        }

        $objectType = is_object($resultDataType) ? get_class($resultDataType) : gettype($resultDataType);

        if (is_array($this->resultDataType)) {
            throw new \Exception(sprintf('Result data type must be instanceof %s, %s given.',
                DataInterface::class,
                $objectType
            ));
        }
    }
1119871
public static function parseFile ($filePath, $xmlValidationEnabled=true)
    {
        // Extract content first
        $fileContent = self::getXmlContentFromFile($filePath);

        // Validate
        if ($xmlValidationEnabled) {
            if (!self::validateXmlContent($fileContent)) {
                throw new Exception("XML validation against rua.xsd failed");
            }
        }

        // Parse
        return self::parseXmlContent($fileContent);
    }
140302
public function restoreFromFile(string $filepath) : Estimator
    {
        if (!file_exists($filepath) || !is_readable($filepath)) {
            throw FileException::cantOpenFile(basename($filepath));
        }

        $object = unserialize(file_get_contents($filepath));
        if ($object === false) {
            throw SerializeException::cantUnserialize(basename($filepath));
        }

        return $object;
    }
619165
public static function parse(string $filePath): FilePathInterface
    {
        if (!self::myFilePathParse(
            DIRECTORY_SEPARATOR,
            $filePath,
            function ($p, $d, &$e) {
                return self::myPartValidator($p, $d, $e);
            },
            null,
            $isAbsolute,
            $aboveBaseLevel,
            $drive,
            $directoryParts,
            $filename,
            $error)
        ) {
            throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
        }

        return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
    }