diff --git a/.gitignore b/.gitignore index 5e5f0a0..d96b0b2 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ yarn-error.log /.vscode vendor vendor/ +composer.lock \ No newline at end of file diff --git a/.idea/php-test-framework.xml b/.idea/php-test-framework.xml deleted file mode 100644 index b8d01bf..0000000 --- a/.idea/php-test-framework.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/composer.json b/composer.json index 3d47ff1..c97f98a 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "ext-bcmath": "*" }, "require-dev": { - "phpunit/phpunit": "^11.3.0" + "phpunit/phpunit": "^11.4.2" }, "autoload": { "psr-4": { diff --git a/src/helpers.php b/src/helpers.php index 930e7fc..95f7da0 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -21,138 +21,175 @@ use Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt32; use Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt8; -/** - * @param int $value - * @return Int8 - */ -function int8(int $value): Int8 -{ - return new Int8($value); -} - -/** - * @param int $value - * @return Int16 - */ -function int16(int $value): Int16 -{ - return new Int16($value); -} - -/** - * @param int $value - * @return Int32 - */ -function int32(int $value): Int32 -{ - return new Int32($value); -} - -/** - * @param int $value - * @return Int64 - */ -function int64(int $value): Int64 -{ - return new Int64($value); -} - -/** - * @param int $value - * @return Int128 - */ -function int128(int $value): Int128 -{ - return new Int128($value); -} - -/** - * @param int $value - * @return UInt8 - */ -function uint8(int $value): UInt8 -{ - return new UInt8($value); -} - -/** - * @param int $value - * @return UInt16 - */ -function uint16(int $value): UInt16 -{ - return new UInt16($value); -} - -/** - * @param int $value - * @return UInt32 - */ -function uint32(int $value): UInt32 -{ - return new UInt32($value); -} - -/** - * @param float $value - * @return Float32 - */ -function float32(float $value): Float32 -{ - return new Float32($value); -} - -/** - * @param float $value - * @return Float64 - */ -function float64(float $value): Float64 -{ - return new Float64($value); +if (!function_exists('int8')) { + /** + * @param int $value + * @return Int8 + */ + function int8(int $value): Int8 + { + return new Int8($value); + } +} + +if (!function_exists('int16')) { + /** + * @param int $value + * @return Int16 + */ + function int16(int $value): Int16 + { + return new Int16($value); + } +} + +if (!function_exists('int32')) { + /** + * @param int $value + * @return Int32 + */ + function int32(int $value): Int32 + { + return new Int32($value); + } +} + +if (!function_exists('int64')) { + /** + * @param int $value + * @return Int64 + */ + function int64(int $value): Int64 + { + return new Int64($value); + } +} + +if (!function_exists('int128')) { + /** + * @param int $value + * @return Int128 + */ + function int128(int $value): Int128 + { + return new Int128($value); + } +} + +if (!function_exists('uint8')) { + /** + * @param int $value + * @return UInt8 + */ + function uint8(int $value): UInt8 + { + return new UInt8($value); + } +} + +if (!function_exists('uint16')) { + /** + * @param int $value + * @return UInt16 + */ + function uint16(int $value): UInt16 + { + return new UInt16($value); + } +} + +if (!function_exists('uint32')) { + /** + * @param int $value + * @return UInt32 + */ + function uint32(int $value): UInt32 + { + return new UInt32($value); + } +} + +if (!function_exists('float32')) { + /** + * @param float $value + * @return Float32 + */ + function float32(float $value): Float32 + { + return new Float32($value); + } +} + +if (!function_exists('float64')) { + /** + * @param float $value + * @return Float64 + */ + function float64(float $value): Float64 + { + return new Float64($value); + } +} + +if (!function_exists('char')) { + function char(string $value): Char + { + return new Char($value); + } +} + +if (!function_exists('byte')) { + function byte(string|int $value): Byte + { + return new Byte($value); + } +} + +if (!function_exists('stringArray')) { + function stringArray(array $value): StringArray + { + return new StringArray($value); + } +} + +if (!function_exists('intArray')) { + function intArray(array $value): IntArray + { + return new IntArray($value); + } +} + +if (!function_exists('floatArray')) { + function floatArray(array $value): FloatArray + { + return new FloatArray($value); + } +} + +if (!function_exists('byteSlice')) { + function byteSlice(array $value): ByteSlice + { + return new ByteSlice($value); + } +} + +if (!function_exists('listData')) { + function listData(array $value): ListData + { + return new ListData($value); + } +} + +if (!function_exists('dictionary')) { + function dictionary(array $value): Dictionary + { + return new Dictionary($value); + } } -function char(string $value): Char -{ - return new Char($value); +if (!function_exists('struct')) { + function struct(array $fields): Struct + { + return new Struct($fields); + } } - -function byte(string|int $value): Byte -{ - return new Byte($value); -} - -function stringArray(array $value): StringArray -{ - return new StringArray($value); -} - -function intArray(array $value): IntArray -{ - return new IntArray($value); -} - -function floatArray(array $value): FloatArray -{ - return new FloatArray($value); -} - -function byteSlice(array $value): ByteSlice -{ - return new ByteSlice($value); -} - -function listData(array $value): ListData -{ - return new ListData($value); -} - -function dictionary(array $value): Dictionary -{ - return new Dictionary($value); -} - -function struct(array $fields): Struct -{ - return new Struct($fields); -} -