diff --git a/src/PostProcessors/BertProcessing.php b/src/PostProcessors/BertProcessing.php index 15bf667..dfb5506 100644 --- a/src/PostProcessors/BertProcessing.php +++ b/src/PostProcessors/BertProcessing.php @@ -39,7 +39,7 @@ public function __construct(array $config) * @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model. * @return PostProcessedOutput */ - public function postProcess(array $tokens, array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput + public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput { if ($addSpecialTokens) { $tokens = array_merge([$this->cls], $tokens, [$this->sep]); @@ -60,4 +60,4 @@ public function postProcess(array $tokens, array $tokenPair = null, bool $addSpe return new PostProcessedOutput($tokens, $tokenTypeIds); } -} \ No newline at end of file +} diff --git a/src/PostProcessors/ByteLevelPostProcessor.php b/src/PostProcessors/ByteLevelPostProcessor.php index ad88594..f76657d 100644 --- a/src/PostProcessors/ByteLevelPostProcessor.php +++ b/src/PostProcessors/ByteLevelPostProcessor.php @@ -26,7 +26,7 @@ public function __construct(array $config) * @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model. * @return PostProcessedOutput */ - public function postProcess(array $tokens, array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput + public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput { if ($tokenPair !== null) { $tokens = array_merge($tokens, $tokenPair); @@ -34,4 +34,4 @@ public function postProcess(array $tokens, array $tokenPair = null, bool $addSp return new PostProcessedOutput($tokens, array_fill(0, count($tokens), 0)); } -} \ No newline at end of file +} diff --git a/src/PostProcessors/TemplateProcessing.php b/src/PostProcessors/TemplateProcessing.php index 6fbd864..6d03c2d 100644 --- a/src/PostProcessors/TemplateProcessing.php +++ b/src/PostProcessors/TemplateProcessing.php @@ -37,7 +37,7 @@ public function __construct(array $config) * @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model. * @return PostProcessedOutput */ - public function postProcess(array $tokens, array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput + public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput { $type = $tokenPair === null ? $this->single : $this->pair; @@ -63,4 +63,4 @@ public function postProcess(array $tokens, array $tokenPair = null, bool $addSp return new PostProcessedOutput($processedTokens, $types); } -} \ No newline at end of file +} diff --git a/src/PreTrainedTokenizers/WhisperTokenizer.php b/src/PreTrainedTokenizers/WhisperTokenizer.php index baaf284..72e528a 100644 --- a/src/PreTrainedTokenizers/WhisperTokenizer.php +++ b/src/PreTrainedTokenizers/WhisperTokenizer.php @@ -409,7 +409,7 @@ public function decodeASR( * @throws Exception If there is a bug within the function. * @private */ - private function findLongestCommonSequence(array $sequences, array $tokenTimestampSequences = null): array + private function findLongestCommonSequence(array $sequences, ?array $tokenTimestampSequences = null): array { $leftSequence = $sequences[0]; $leftLength = count($leftSequence); @@ -501,7 +501,7 @@ public function collateWordTimestamps($tokens, $tokenTimestamps, $language): arr */ private function combineTokensIntoWords( array $tokens, - string $language = null + ?string $language = null ): array { $language = $language ?? 'english'; @@ -522,7 +522,7 @@ public function decode( array $tokenIds, bool $skipSpecialTokens = false, ?bool $cleanUpTokenizationSpaces = null, - bool $decodeWithTimestamps = null, + ?bool $decodeWithTimestamps = null, float $timePrecision = 0.02 ): string { diff --git a/src/Tensor/MatrixOperator.php b/src/Tensor/MatrixOperator.php index 868e5f6..8451ab0 100644 --- a/src/Tensor/MatrixOperator.php +++ b/src/Tensor/MatrixOperator.php @@ -10,7 +10,7 @@ class MatrixOperator extends \Rindow\Math\Matrix\MatrixOperator { - protected function alloc(mixed $array, int $dtype = null, array $shape = null): NDArray + protected function alloc(mixed $array, ?int $dtype = null, ?array $shape = null): NDArray { if ($dtype === null) { //$dtype = $this->resolveDtype($array); @@ -18,4 +18,4 @@ protected function alloc(mixed $array, int $dtype = null, array $shape = null): } return new Tensor($array, $dtype, $shape); } -} \ No newline at end of file +} diff --git a/src/Tensor/Tensor.php b/src/Tensor/Tensor.php index e5f34f1..eb10625 100644 --- a/src/Tensor/Tensor.php +++ b/src/Tensor/Tensor.php @@ -61,10 +61,10 @@ class Tensor implements NDArray, Countable, Serializable, IteratorAggregate protected bool $portableSerializeMode = false; public function __construct( - mixed $array = null, - int $dtype = null, - array $shape = null, - int $offset = null, + mixed $array = null, + ?int $dtype = null, + ?array $shape = null, + ?int $offset = null, ) { if ($array === null && $dtype === null && $shape === null && $offset === null) { // Empty definition for Unserialize diff --git a/src/Tensor/TensorBuffer.php b/src/Tensor/TensorBuffer.php index 084beff..3323a59 100644 --- a/src/Tensor/TensorBuffer.php +++ b/src/Tensor/TensorBuffer.php @@ -22,7 +22,7 @@ class TensorBuffer implements LinearBuffer static protected ?FFI $ffi = null; /** @var array $typeString */ - protected static $typeString = [ + protected static array $typeString = [ NDArray::bool => 'uint8_t', NDArray::int8 => 'int8_t', NDArray::int16 => 'int16_t', @@ -114,7 +114,7 @@ protected function assertOffsetIsInt(string $method, mixed $offset): void } } - protected function isComplex(int $dtype = null): bool + protected function isComplex(?int $dtype = null): bool { $dtype = $dtype ?? $this->dtype; return $dtype == NDArray::complex64 || $dtype == NDArray::complex128;